# TCP CMD Interface ## Introduction The tcp cmd interface is a way to control the device over TCP. It is a simple protocol that allows the user to send commands to the device and receive responses. The protocol looks like bash commands. The commands are separated by a new line character (`\n`). The response is sent after the command is executed. The response is also terminated by a new line character (`\n`). The response can be a simple string or a JSON object. ## Table of contents * [Introduction](#introduction) * [Table of contents](#table-of-contents) * [Usage of TCP CMD Interface](#usage-of-tcp-cmd-interface) * [Connecting to the device](#connecting-to-the-device) * [Sending commands](#sending-commands) * [Available commands](#available-commands) * [`help`](#help) * [`text`](#text) * [`bgcolor`](#bgcolor) * [`color`](#color) * [`listImages`](#listimages) * [`setImage`](#setimage) * [`setGif`](#setgif) ## Usage of TCP CMD Interface ### Connecting to the device The device can be connected to using a TCP client. The device will listen on port 23. The device will send a welcome message when a client connects. On Linux, the device can be connected to using the `nc` command: ```bash nc 23 ``` ### Sending commands Commands can be sent to the device by typing them in the terminal and pressing enter. The device will execute the command and send a response. ### Available commands #### `help` The `help` command will print a list of available commands. ```bash $> help help : shows a list of commands text "" : puts text on the lcd color : set the background color of the lcd textColor : set the color of the text listImages : shows a list with images in the filesystem setImage : put an image on the screen setGif : put a gif on the screen exit : closes the connection ``` #### `text` The `text` command will print the given text on the screen. The text can be one or multiple words. one word does'n need quotes, multiple words do. The text will rapp around when it reaches the end of the screen. ```bash $> text "Hello World!" ``` #### `bgcolor` The `bgcolor` command will set the background color of the screen. The color can be provided in 2 ways: as three numbers between 0 and 255 and one hex value. The first number is the red value, the second is the green value and the third is the blue value. ```bash bgcolor 255 0 0 ``` or ```bash bgcolor 0xFF0000 ``` #### `color` The `color` command will set the color of the text. The color can be provided in 2 ways: as three numbers between 0 and 255 and one hex value. The first number is the red value, the second is the green value and the third is the blue value. ```bash color 255 0 0 ``` or ```bash color 0xFF0000 ``` #### `listImages` The `listImages` command will print a list of images that are present in the filesystem. ```bash $> listImages image1.bmp image2.bmp image3.bmp gif1.gif ... ``` #### `setImage` The `setImage` command will put an image on the screen. The image must be present in the filesystem. If the image is not present in the filesystem, the device will send an error message. This function only works for BMP images, if you give any other file type, the device will send an error message. ```bash $> setImage image1.bmp ``` #### `setGif` The `setGif` command will put a gif on the screen. The gif must be present in the filesystem. If the gif is not present in the filesystem, the device will send an error message. This function only works for GIF images, if you give any other file type, the device will send an error message. ```bash $> setGif gif1.gif ```