TX_UART0 output on ESPrtk follows the message protocol standard:
- All transmitted data are printable ASCII characters between 0x20 (space) and 0x7e (~)
- Start the message with 5 bytes “$ESPEL”.
- Finish the content with a asterisk (*) and 2 bytes checksum.
- End the message with 2 bytes <CR> <LF>.
ESPEL meaning : ESPrtk Status Print and Event Log.
Message frame:
$ESPEL,<Payload_Length>,<Payload>*<CheckSum><CR><LF>
Payload: The content of the message, after the second comma (,) and before the asterisk (*). The content of the payload does not contain ‘$’ and ‘*’.
Payload_Length: The number of characters of Payload, of type NUMBER (see below), the value in the range [0 -> 32768].
CheckSum : a checksum represented as a two-digit hexadecimal number. The checksum is the bitwise exclusive OR of ASCII codes of all characters between the ($ )and (*). (does not include $ and * ).
<CR> : “Carriage return” or ‘\r’ or ‘0x0D in hex’ (13 in decimal)
<LF> : “Line Feed” or ‘\n’ or ‘0x0A in hex ‘ (10 in decimal) .
Example for : $ESPEL,28,1,0,0,G-G-G-G,</br> No ERROR*1D<0x0D,0x0A>
<Payload>: <1,0,0,G-G-G-G,</br> No ERROR>
<Payload_Length>: <28>
<Checksum>:<1D>
[CheckSum Range] : [ESPEL,28,1,0,0,G-G-G-G,</br> No ERROR]
<CR><LF>:<0x0D,0x0A>
Definition of content type representation:
- Printable ASCII: !”#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
- [0->9]: 0123456789
- [a->z]: abcdefghijklmnopqrstuvwxyz
- [A->Z]: ABCDEFGHIJKLMNOPQRSTUVWXYZ
- NUMBER: Contains only characters from [0->9], and ‘+’ ‘-‘ ‘.’
- SENTENCE: Contains only characters [0->9], [a->z],[A->Z], white space, ‘_’ ‘-‘
- STATE: Contains only characters [0-> 9], [a->z], [A->Z], white space, ‘.’ ‘-‘ ‘+’ ‘_’
- STRING: All characters range from 0x20 (space) to 0x7e (~), (including commas ‘,’), not including ‘$’ and ‘*’.
Printout ESP32 Status.
Print out information and status about ESP32.
$ESPEL,<Payload_Length>,< TYPE_EL_ESP32>,<Text message>,<<FREE HEAPRAM>*<CheckSum><0x0D,0x0A>
#define TYPE_EL_ESP32 ‘0’
Text message : STRING .
Printout ESPrtk’s error status.
Print out the errors in the stack.
$ESPEL,<Payload_Length>,<TYPE_EL_ERROR>,<Error TYPE >,<Error in ID >,<Error in Color>,<Error Text>*<CheckSum><0x0D,0x0A>
#define TYPE_EL_ERROR ‘1’
Error TYPE: NUMBER, [0->9],
- <0>:FIRST_SETTING_AND_BOOT_UP_error
- <1>:UART_error.
- <2>:INTERNET_error.
- <3>:MQTT_error.
- <4>:NTRIP_error.
- <5>: Other_ERROR_TYPE_1
- <6>: Other_ERROR_TYPE_2
- <7>: Other_ERROR_TYPE_3
- <8>: Other_ERROR_TYPE_4
- <9>: Other_ERROR_TYPE_5
Error in ID : NUMBER , [0 -> 1024].
Error in Color: SENTENCE – (Contain only : ‘R’,G’,B’,’W’, ‘-‘)
Error Text : STRING .
Ex:
$ESPEL,28,1,0,0,G-G-G-G,</br> No ERROR*1D
Printout a text message .
Print out a text message.
$ESPEL,<Payload_Length>,< TYPE_EL_TEXT>,<Text message>*<CheckSum><0x0D,0x0A>
#define TYPE_EL_TEXT ‘1’
Text message : STRING .
$ESPEL,21,2,Saved Rtcm:( L1=25)*43
$ESPEL,25,2,State Send to client 0:*35
$ESPEL,11,2,Sending..*0D
Printout process.
The process is running on ESPrtk.
$ESPEL,<Payload_Length>,<TYPE_EL_IN_FUN>,<ID_FUN>,<Text message>*<CheckSum><0x0D,0x0A>
#define TYPE_EL_IN_FUN ‘2’
ID_FUN : NUMBER.
Text message : STRING .
Printout Wifi Scan .
Wifi Hotspot network scan results.
$ESPEL,<Payload_Length>,<TYPE_EL_RESULT_SCAN_WIFI>,<Text message>*<CheckSum><0x0D,0x0A>
#define TYPE_EL_RESULT_SCAN_WIFI ‘3’
Text message : STRING .
Printout queries the file by webconfigure.
To know which file the WebConfigure has queryed.
$ESPEL,<Payload_Length>,<TYPE_EL_WEBSERVER_READ_FILE>,<Text message>*<CheckSum><0x0D,0x0A>
#define TYPE_EL_WEBSERVER_READ_FILE ‘6’
Text message : STRING .
Printout MQTT Broker’s Status.
Print the MQTT Broker status (MQTT Cloud Server).
$ESPEL,<Payload_Length>,<TYPE_EL_MQTT_BROKER_STATUS>,<TYPE BROKER_STATUS in ID>,<TYPE BROKER_STATUS >,<BROKER_STATUS>*<CheckSum><0x0D,0x0A>
#define TYPE_EL_MQTT_BROKER_STATUS ‘7’
<TYPE BROKER_STATUS in ID> : NUMBER trong [1,7].
- <1>:The total number of bytes received since the broker started.
- <2>:The total number of bytes sent since the broker started.
- <3>:The number of currently connected clients.
- <4>:The number of disconnected persistent clients that have been expired and removed through the persistent_client_expiration option.
- <5>:The maximum number of clients that have been connected to the broker at the same time.
- <6>:The total number of active and inactive clients currently connected and registered on the broker.
- <7>:When bridges are configured to/from the broker, common practice is to provide a status topic that indicates the state of the connection. This is provided within $SYS/broker/connection/ by default. If the value of the topic is 1 the connection is active, if 0 then it is not active. See the Bridges section below for more information on bridges.
TYPE BROKER_STATUS : SENTENCE.
BROKER_STATUS : NUMBER.
(Base) Printout Rover’s NMEA sent to.:
Notice there is a message NMEA from Rover will print out. Following the message is 1 (or more) messages of NMEA of Rover.
$ESPEL,<Payload_Length>,<TYPE_EL_NMEA_FROM_CLIENT>,<Device ID of Rover>*<CheckSum><0x0D,0x0A>
…<NMEA 1><NMEA 2>..
#define TYPE_EL_NMEA_FROM_CLIENT ‘8’
Device ID of Rover: SENTENCE.
(Base) Printout Rover’s Status sent to:
Print out other Rover’s status information.
$ESPEL,<Payload_Length>,<TYPE_EL_STATUS_FROM_CLIENT>,<Device ID of Rover>,<State 1> ,<State 2>,<State 3>,<State 4>,<State 5>*<CheckSum><0x0D,0x0A>
#define TYPE_EL_STATUS_FROM_CLIENT ‘9’
Device ID of Rover: SENTENCE .
State 1, State 2, State 3, State 4, State 5 : STATE.
(Rover) Printout Base’s Status sent to:
Print other information status of Base.
$ESPEL,<Payload_Length>,<TYPE_EL_STATUS_FROM_MASTER>,<Device ID of Base>,<State 1> ,<State 2>,<State 3>,<State 4>,<State 5>*<CheckSum><0x0D,0x0A>
#define TYPE_EL_STATUS_FROM_MASTER ’10’
Device ID of Base: SENTENCE .
State 1, State 2, State 3, State 4, State 5 : STATE.
Printout IMU data from MPU9250 sensor.
$EPIM1, GX,GY,GZ, MX,MY,MZ, AX,AY,AZ, T, MXc,MYc,MZc,* <CS><CR><LF>
- GX,GY,GZ : Raw Gyroscope 3 Axis (Degree/second)
- MX,MY,MZ : Raw Magnetometer 3 Axis (uT) (micro-Tesla)
- AX,AY,AZ : Raw Accelerometer 3 Axis ( scale 0.1 m/s^2)
- T : Temperature sensor (°C) (degrees Celsius)
- MXc,MYc,MZc : Magnetometer 3 Axis + Calibrated.
$EPIM2, QW,QX,QY,QZ, Yaw,Pitch,Roll, H, FQW,FQX,FQY,FQZ, FYaw,FPitch,FRoll, FH,* <CS><CR><LF>
- QW,QX,QY,QZ : DMP-Quaternion.
- Yaw,Pitch,Roll: DMP-Euler 3 Axis. (Degree)
- H :Compass Heading (using magnetometer calibrated) + Tilt compensation. (Degree)
- FQW,FQX,FQY,FQZ : DMP-Quaternion + Kalman Filter.
- FYaw,FPitch,FRoll : DMP-Euler 3 Axis + Kalman Filter. (Degree)
- FH :Compass Heading (using magnetometer calibrated) + Tilt compensation + Kalman Filter (Degree)
Parsing.
Calculate checksum in C:
#include <stdio.h> int checksum(const char *s) { int c = 0; while(*s) c ^= *s++; return c; } int main() { char mystring[] = "ESPEL,28,1,0,0,G-G-G-G,</br> No ERROR"; printf("Checksum: 0x%02X\n", checksum(mystring)); // result -> Checksum:0x1D return 0; }