Serial Line Commands


The Wi-Fi module is able to receive commands from both the serial port and the WiFi radio. The supported commands are divided into two groups: 1) normal commands; 2) protected commands. The first group contains commands that are usually required during the normal use of the system, e.g. for configuring the WiFi radio (name, password, etc). The second group, instead, contains commands that may alter permanently the system functions (e.g. firmare upgrade, serial line speed, etc). Since the execution of protected command by the user should be avoided in a final product, a special command exists to restrict the execution of protected commands to the controller connected to the serial line. 

Commands must begin with the dollar character ($) and terminate with the carriage return character (i.e. ascii code 10, or \n). The system is however tolerant to other types of line termination (such as \r and \r\n).

The default speed of the serial line is 57600 baud. This value can be changed through its specific command.

The list of supported command follows in this section.


$P (protected)

This command defines the graphical layout and elements of the panel in HCTML format. The maximum length of the HCTML string that defines the panel is 1000 characters.

Command syntax

$P: Panel_Design_in_HCTML_code


Command results

$OK-PANEL immediately after command reception and execution

Example

A simple panel with a button containing the text Start:  $P:B1:Start;


$APP-CLIM (protected)

This command permits to lock the execution of the protected commands by the WiFi Radio (e.g. from the mobile application). When the protected commands are locked, their execution can occur only through the serial line. This command may be useful before distributing a final product in which it is necessary to avoid that the final user can alter or change the WiFi module functions. This command can be executed only through the serial line.

Command syntax

$APP-CLIM

Command results

$OK-APPLIM immediately after command reception on success
$ERR-DENIED immediately after command reception if issued from the WiFi

Command retention

The configuration is saved into the non-volatile memory, so there is no need to issue this command at each reboot



$APP-CFULL (protected)

This command gives full control of the user through the WiFi, allowing the WiFi interface to execute also protected commands. Please note that this is the default situation.  

Command syntax

$APP-CFULL

 

Command results

$OK-APPFULL immediately after command reception on success
$ERR-DENIED immediately after command reception if issued from the WiFi with protected commands locked

Command retention

The configuration is saved into the non-volatile memory, so there is no need to issue this command at each reboot


 


$RESET (protected)

This command generates a software reset

Command syntax

$RESET

 


$LINK (protected)

This command permits either to connect a virtual LED on the panel to a real physical input pin of the WiFi module, or a virtual Switch on the panel to a real physical output pin of the WiFi Module. Interacting with the panel is thus possible to monitor and control real pins of the WiFi Module. More input and output pins can be simultaneously linked and controlled. Please note that, connecting a virtual LED to a pin, the system automatically configures that pin as input. Connecting a virtual Switch to a pin, the system automatically configures that pin as output. In addition, if the pin is multiplexed with a peripheral function, during the direct pin control that function will not be available.

This command can be protected by $AP-CLIM. When protected the command can be executed only from the serial line (i.e. it can not be executed from the mobile application)

Command syntax

$LINK :Lx -z

$LINK :Wy -z

Command results

$LINKED immediately after command reception (regardless the success of the operation)

Examples

  • For monitoring the GPIO2 digital state with the LED number 3 on the panel: $LINK:L3-2
  • For controlling the GPIO2 digital state with the Switch number 4 on the panel: $LINK:W4-2

$UNLINK (protected)

This command disconnects ALL the virtual LEDs and Switches from the WiFi Module pins, restoring the initial pin functions.

This command can be protected by $AP-CLIM. When protected the command can be executed only from the serial line (i.e. it can not be executed from the mobile application)

Command syntax

$UNLINK


Command results

$UNLINKED always and immediately after command reception


$FIRMWARE_UPGRADE (protected)

This command upgrade the µPanel Firmware of the WiFi Module. To execute this command the WiFi module has to be connected to the Internet (with $CONNECT command) and to the server (confirmed by the $NOTIFY message). 

This command can be protected by $AP-CLIM. When protected the command can be executed only from the serial line (i.e. it can not be executed from the mobile application)

Command syntax 

$FIRMWARE_UPGRADE

 

Command results

$UPGRADE-NOT-ALLOWED immediately after command reception to indicate that the firmware upgrade is currently not permitted
$UPGRADE-NOT-NEEDED immediately after command reception to indicate that the WiFi module already runs the latest firmware
$UPGRADE-NOT-POSSIBLE immediately after command reception to indicate that the upgrade is not possible (e.g. no internet connection, no connection to server)
$WAIT immediately after command reception to indicate that the download process started
$ERROR:DNS after command execution to indicate that the process failed since the WiFi Module was unable to contact the server.
$ERROR-UPGRADING after command execution to indicate that the process timed out
$ERROR:BAD-CODE after command execution to indicate that the process failed since the server rejected the request or the received data were corrupted
$INSTALL-AND-REBOOT after command execution to indicate that the system is rebooting with the new firmware.

Command retention

/


$DOWNLOAD_AT (protected)

This command downloads and executes from internet the AT-Firmware. To execute this command the WiFi module has to be connected to the Internet (with $CONNECT command). By default, the AT-Firmware is already present in the WiFi Module memory, however, its space in memory might be reused in some cases.

This command can be protected by $AP-CLIM. When protected the command can be executed only from the serial line (i.e. it can not be executed from the mobile application)

Please note that, the execution of wrong AT commands may stuck the device into AT mode or even damage the device. If you need TCP/UDP sockets and network communication use the functions provided directly by the µPanel firmware instead (since version 003A). The use of the AT commands is at your own risk!

Command syntax 

$DOWNLOAD_AT

 

Command results

$WAIT immediately after command reception to indicate that the download process started
$ERROR:DNS after command execution to indicate that the process failed since the WiFi Module was unable to contact the server.
$ERROR-UPGRADING after command execution to indicate that the process timed out
$ERROR:BAD-CODE after command execution to indicate that the process failed since the server rejected the request or the received data were corrupted
$INSTALL-AND-REBOOT after command execution to indicate that the system is rebooting with the AT-Firmware

Command retention

After this command the WiFi Module will always boot on AT mode. To re-enable the µPanel use the AT command: AT+PANEL

NOTE: never perform a firmware upgrade using the AT commands since the µPanel firmware will be lost forever


$AT-REVERT (protected)

This command reboots the module with the AT-Firmware instead of µPanel. After this command is executed, the only way to re-enable µPanel is to send the command AT+PANEL from the serial line. Please note that the AT-Firmware configures the serial line at 115200 baud.

This command can be protected by $AP-CLIM. When protected the command can be executed only from the serial line (i.e. it can not be executed from the mobile application)

Please note that, the execution of wrong AT commands may stuck the device into AT mode or even damage the device. If you need TCP/UDP sockets and network communication use the functions provided directly by the µPanel firmware instead (since version 003A). The use of the AT commands is at your own risk!

Command syntax 

$AT-REVERT

 

Command results

$SWITCH TO AT FIRMWARE immediately after command reception and right before execution
$ERROR AT NOT PRESENT immediately after command reception to indicate that the AT-Firmware is not loaded on the WiFi module. To download the firmware use $DOWNLOAD_AT

Command retention

After this command the WiFi Module will always boot on AT mode. To re-enable the µPanel use the AT command: AT+PANEL

NOTE: never perform a firmware upgrade using the AT commands or the µPanel firmware will be lost forever


$BAUD (protected)

This command permits to change the speed (baud) of the serial interface. The default value is 57600 baud. Standard values in the range 9600 - 115200 are accepted. 

This command can be protected by $AP-CLIM. When protected the command can be executed only from the serial line (i.e. it can not be executed from the mobile application)

Command syntax 

$BAUD :Baud_Value

 

Command results

$OK-BAUD immediately after command reception and execution on success
$ERR-BAUD immediately after command reception and execution on error (e.g. bad parameters)

Command retention

This command and its parameters are saved into the non-volatile memory, so there is no need to issue this command at each reboot


$ROUTER

This command configures the router auto-configurator. In order to be able to communicate with your module from the Internet (i.e. from everywhere in the world) you have to configure your router to allow incoming TCP connections to reach the module port 80 and 81. The µPanel firmware is able to automatically configure most of the routers so that they will accept and forward these incoming connections. The currently supported protocols are the NAT-PMP and UPnP

Command syntax 

$ROUTER :PORT 1 :PORT 2

The command issued without parameters simply enables the router auto-configurator using two default TCP ports. The user can however specify the available ports to be used by the router to accept incoming TCP connections. If the first parameter is specified, also the second one has to be specified.

Command results

$OK-ROUTER immediately after the command reception
$ROUTER:IP,Port 1,Port 2 upon successful command execution (depending on the router, the command may require from a few seconds up to 1 min to complete. If the command fails no reply is provided)

Command retention

This command and its parameters are saved into the non-volatile memory, so there is no need to issue this command at each reboot


$NOROUTER

This command disables the router auto-configurator. 

Command syntax 

$NOROUTER

 

Command results

$OK-NOROUTER immediately after the command reception and execution

Command retention

The configuration is saved into the non-volatile memory, so there is no need to issue this command at each reboot


$APSET

This command permits to configure name, password and channel of the Access Point created by the WiFi module. By default, the name is miuPanel followed by the WiFi module ID, and the password is uPanel11.

Command syntax 

$APSET :SSID :PASSWORD :CHANNEL

The password and channel fields are optional. If the password is not specified, an open Access Point will be created. Channel can be an integer number in the range 1-13.

Command results

$OK-APSET after the command execution on success
$ERR-APSET after the command execution on error

Command retention

This command and its parameters are saved into the non-volatile memory, so there is no need to issue this command at each reboot


$CONNECT

This command asks the WiFi module to join an existing WiFi network, usually with the aim of connecting the system to the Internet.

Command syntax 

$CONNECT :SSID :PASSWORD

SSID represents the name of the existing WiFi network to join (usually this is the name of your own home WiFi network). Password is the password for accessing the network. If the network is open the password field has to be omitted. If both the command parameters are omitted, the WiFi module try to connect using the las used parameters.

Command results

$OK-CONN immediately after the command reception to indicate that the WiFi module is trying to join the network 
$ERR-CONN immediately after the command reception if the specified parameters are not valid
$CONNECTED when the connection succeeds
$NOTIFY after the connection to indicate that the WiFi module correctly registered itself on the cloud server. This permits to take advantage of the firmware upgrade and of the module IP discovery.

 

 


$DISCONNECT

This command disconnects the WiFi module from the WiFi network (joined with the $CONNECT command)

Command syntax 

$DISCONNECT

 

Command results

$OK-DISC immediately after the command reception and execution

Command retention

The configuration is saved into the non-volatile memory, so there is no need to issue this command at each reboot.


$CONFIG

This command displays most of the WiFi Module configuration parameters

Command syntax 

$CONFIG

$PING

This command set the maximum communication interval between App and WiFi Module. Decreasing the PING interval results in a more responsive communication but it increases the traffic. The default PING value is of 500 ms. PING values lower than 250 ms maybe necessary to achieve real-time response. 

Command syntax 

$PING ms

 

Command results

$OK-PING always and immediately after the command reception and execution


$PASSWORD

This command protects the access to the module with a password. The password will be requested by the APP when the user starts the connection with the module. The password can be any number composed by up to 15 digits in the range {0..9}. 

Please note that the App will remember the password, so it will be requested only once or only if the password has been changed. 

Command syntax 

$PASSWORD:numeric_password:

 

Don't forget the colon after the numeric_password

To disable the password simply set an empty one with the command $PASSWORD::

Command results

$OK-PASSWORD-SET  when the password has been successfully changed

$OK-PASSWORD:xxxxxx  when the password has been requested (i.e. numeric_password is not provided)

$ERR-PASSWORD  if the given password is invalid and can not be set


Serial Line Commands (available since firmware version 003A)

$ECHO

This command send a message to the micro-controller through the serial port

Command syntax 

$ECHO:message

$STAIP

This command can be used to display or set the static IP settings. If the command is executed without parameter the current setting are displayed.

Display current STATIC IP settings - Command syntax 

$STAIP

 

Command results

$STAIP AAA.AAA.AAA.AAA BBB.BBB.BBB.BBB CCC.CCC.CCC where A, B and C are respectively IP, Gateway, and Mask.

Assign a STATIC IP - Command syntax 

$STAIP AAA.AAA.AAA.AAA BBB.BBB.BBB.BBB CCC.CCC.CCC.CCC


Where A,B and C are respectively IP, Gateway and Mask. To disable static IP (and enable DHCP) set A,B  and C to 255.255.255.255

Command results

$OK-STAIP  immediately after the command execution if the parameters are accepted 

$ERR-STAIP   immediately after the command execution if the parameters are invalid

$SET-STAIP  when the static IP takes affect (this message will appear also after boot)


Command retention

This command and its parameters are saved into the non-volatile memory, so there is no need to issue this command at each reboot. 


$CONNSTA

This command displays the status of the connection with the router.

Command syntax 

$CONNSTA


Command results

$CONNSTA XXX AAA.AAA.AAA.AAA BBB.BBB.BBB.BBB RSSI   immediately after the command reception and execution

Where XXX is a decimal number (3 digits) representing the connection state: (005 = Connected, 255 = Disconnected)

A and B represent respectively the module's IP and the gateway.

RSSI is a negative number that represents the strength (RSSI in dB) of the router WiFi connection.

 


$APSTA

This command displays the status of the Access Point 

Command syntax 

$APSTA


Command results

$APSTA XXX AAA.AAA.AAA.AAA    immediately after the command reception and execution

Where XXX is a decimal number (3 digits) representing the number of devices (clients) connected to the module's access point, and A is the module's IP of the access point's interface.

 


$APLIST

This command displays the list of devices connected to the module's access point 

Command syntax 

$APLIST


Command results (for each connected device)

$APLIST XXX MM:MM:MM:MM:MM:MM AAA.AAA.AAA.AAA    immediately after the command reception and execution

Where XXX is the client number (sequential number of connected devices, starting from 1), MM is the device's MAC Address, and A is the IP assigned to the connected device.

If no devices are connected the output will be

$APLIST 000

 


$APP-CLIMSET

This command protects (blocks) the access to some commands by the App. Four groups of commands can be protected:

  • Hardware ($P, $PASSWORD, $RESET, $LINK, $UNLINK, $FIRMWARE_UPGRADE, $DOWNLOAD_AT, $AT_REVERT, $BAUD, $TCP, $UDP, $ECHO, $STAIP, $DISK, $FILE)
  • Access Point ($APSET)
  • Router ($CONNECT, $DISCONNECT, $ROUTER, $NOROUTER)
  • Configuration (UART Monitor, $CONFIG, $PASSWORD)

Each group correspond to one ID code, as follow:

  • Hardware = 1
  • Access Point = 2
  • Router = 4
  • Configuration = 8

Command syntax 

$APP-CLIMSET[:SumOfGroupCodes]


Command results

$APP-CLIMSET: Sum_of_protected_group_codes

Where Sum_of_protected_group_codes represents the sum of the IDs of the groups currently protected/to proctect. For instance if the Hardware and Configuration groups are protected, the reply is: $APP-CLIMSET:9

If the optional parameter :SumOfGroupCodes is omitted, the command simply displays the current settings

The legacy command $APP-CFULL corresponds to $APP-CLIMSET:0

The legacy command $APP-CLIM corresponds to $APP-CLIMSET:1



$DISK

This command permits to manage the virtual disk created into the WiFi module's flash memory.

For the full documentation please refer to the FILE SYSTEM - DISK section. 


$FILE

This command permits to manage the file stored into the virtual disk created into the WiFi module's flash memory.

For the full documentation please refer to the FILE SYSTEM - DISK section. 


$TCP

This command permits to create and use TCP sockets.

For the full documentation please refer to the TCP SOCKETS - File/Data Transfer section. 


$UDP

This command permits to create and use UDP sockets.

For the full documentation please refer to the UDP SOCKETS - Panel Networks section. 


Serial Line Commands (available since firmware version 004A)

$NAME (protected)

This command sets the name of the product. This name will appear automatically in the APP when the user registers the module.

Command syntax 

$NAME:Product_name

The maximum name length is of 63 characters (or 63 bytes). The name is NOT stored into the flash memory, so it has to be set each time the system is powered up or reset.


$WIFI (protected)

This command temporarily switch OFF/ON the WiFi radio, either as access point or as client.

Command syntax 

$WIFI:Mode

Mode can be a number as follow:

Mode = 0: Access Point OFF, Client OFF
Mode = 1: Access Point OFF, Client ON
Mode = 2: Access Point ON, Client OFF
Mode = 3: Access Point ON, Client ON


$PWRD (protected)

This command enters/exits the power down mode.

Command syntax 

$PWRD:E

Where E can be:

E = 0: Power down disabled
E = 1: Power down enabled

During the power down mode the WiFi radio is turned off in order to reduce the power consumption. The serial interface and the internal DISK will continue to operate normally. 


$CBRIDGE-ON (protected)

This command enables the cloud-bridge connection mode. When this connection mode is enabled, the communication with the miuPanel APP will transit across the cloud-bridge server, which acts as a bridge and permits the communication even if the module can not use a public IP. When this connection mode is enabled, the connection through router (both local or via Internet) will be disabled. It is still possible, however, to connect to the module through its access point. By default all modules uses our free cloud-bridge server, but on request, a dedicated cloud-bridge server can be created for a set of modules.

Command syntax 

$CBRDIGE-ON

This configuration is stored into the flash memory, so it is not necessary to issue the command at each reboot.


$CBRIDGE-OFF (protected)

This command disables the cloud-bridge connection mode. 

Command syntax 

$CBRDIGE-OFF

This configuration is stored into the flash memory, so it is not necessary to issue the command at each reboot.


$PID

This command displays the Product ID (S/N) and the Full Product ID 

Command syntax 

$PID

 


$NEWREG (protected)

This command de-registers all the APP. After this command is issued, the module will be removed from all the mobile devices, and the registration process has to be repeated to add again the module into the list. The APPs that will not repeat the registration process will not receive push-notifications anymore.

Command syntax 

$NEWREG

 

After the execution of this command the µPanel module will reboot


$CLOUD (protected)

This command permits to use some cloud functionalities. 

Command syntax 

$CLOUD Command:Parameters

 

Many cloud commands can be made available. The current supported commands are:

$CLOUD GET:TIME

Retrieve the date and time from the cloud. The reply will include the time in Java format followed by readable UTC date time. An example follows:

$CLOUD:TIME:1464599263603 2016-05-30 09:07:43 UTC

$CLOUD GET:TIME+TimeZone

Retrieve the date and time from the cloud. The reply will include the time in Java format followed by readable date time for the specifies time zone. As an example, the request $CLOUD GET:TIME+2 will produce the following reply:

$CLOUD:TIME:1464599263603 2016-05-30 11:07:43 UTC+2

$CLOUD SEND:PUSH:Message

Send a push notification (Message) to all APPs that have registered the module. Please note that, push notification messages are not stored on the cloud, therefore, if a mobile device (e.g. smartphone) is off-line (e.g. turned off), only the last message sent to that spefic mobile device will be received when the device is turned on again.