Symbol Type Value
Type value | Characters contain | Example | Notes |
[0 → 9] | 0123456789 | 0 , 123, 457 | Number only |
[a → z] | abcdefghijklmnopqrstuvwxyz | esprtk |
|
[A → Z] | ABCDEFGHIJKLMNOPQRSTUVWXYZ | ESPRTK |
|
[INTEGER] | -0123456789 | 0 , -123, -457 | Number only and ‘-’ |
[FLOAT] | -0123456789. | 0.123 , -12.23 , 67.97 | Number only and ‘-’ and ‘.’ |
[BIT] | 01 | 011101, 1111001, 001 | ‘0’ and ‘1’ only |
[HEX_Up] | 0123456789ABCDEF | A0,B0, C045, AD7C, A8E4C0D2 | 1 byte of data must be represented by 2 characters. |
[HEX] | 0123456789acbdefABCDEF | A0,b7, a3ee, B3f5, A8E4c0d2 | 1 byte of data must be represented by 2 characters. |
[<CR><LF>] | 2 byte value are 0x0D , 0x0A |
|
|
[PRINT] | abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM NOPQRSTUVWXYZ0123456789 "#%&'()+,-./:;<=>@^_`{}~ | Hello_ESPrtk_01 , Hello-ESPrtk-02 , Hello ESPrtk $# , | Not allow contain <CR><LF>, $*| |
[STRING] | AbcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM NOPQRSTUVWXYZ0123456789 -_+(.):, | Hello_ESPrtk_01 , Hello-ESPrtk-02 , | Not allow contain <CR><LF>, WhiteSpace , !=&"~<\/>?|%#[]{}^$* |
[PASS_A] | [STRING] |
| Not allow contain <CR><LF>, , !=&"~<\/>?|%#[]{}^$* |
[PASS_B] | [PASS_A] |
| Not allow contain WhiteSpace |
[PASS_C] | [PASS_A] |
| Must contain atleast 1 Upper Case and 1 Lower Case and 1 Number Min length 8 chars |
[PASS_D] | [PASS_C] |
| Not allow contain WhiteSpace |
Format the message frame communicating on the port UART0.
Message Frame:
<Header> + <Length_Payload> + <Payload> + <*CRC> + <CR> <LF> |
Example : $ESPLOG|25|2|INFO|GO to MAIN ACTION|*6360
Label | Characters allowed to contain. |
<Header> | [0 → 9] [a → z] [A → Z] |
<Length_Payload> | [0 → 9] |
<Payload> | [ASC] |
<*CRC> | [HEX_Up] |
<CR><LF> | [<CR><LF>] |
Label | Sub | Min Bytes | Max Bytes | Describe |
<Header> | ‘$’ + ‘Header_Name’ + ‘|’ | 3 | 10 | Start Message |
<Length_Payload> | ‘Length_Payload’ +’|’ | 2 | 10 | Numbers Bytes of Payload |
<Payload> | ‘Payload’ | 1 | Length_Payload | Payload data |
<*CRC> | ‘*’ + ‘CRC_16’ | 5 | 5 | Checksum of Message |
<CR><LF> | 0x0D + 0x0A | 2 | 2 | End Message |
| <Header> | <Length_Payload> | <Payload> | <*CRC> | <CR><LF> |
Ex 1 | $ESPLOG| | 25| | 2|INFO|GO to MAIN ACTION| | *6360 | \r\n |
Ex 2 | $ESPLOG| | 34| | 1|ERROR|0,0,G-G-G-G,<br> No ERROR| | *7A58 | \r\n |
Ex 3 | $ESP_OK| | 5| | X|_|| | *5309 | \r\n |
Ex 4 | $ESP_OK| | 14| | W|m|3|0|0|0|0| | *6D76 | \r\n |
Length_Payload calculate.
Example message : $ESP_OK|14|W|m|3|0|0|0|0|*6D76
Then Payload range is : W|m|3|0|0|0|0| and Total of characters (Length) is 14
CRC calculate.
CRC_Range calculate from after '$' to begin '*' ( not contain '$' and '*')
‘Header_Name’ + ‘|’+ <Length_Payload> + <Payload> |
Example message : $ESP_OK|14|W|m|3|0|0|0|0|*6D76
Then CRC Range is: ESP_OK|14|W|m|3|0|0|0|0|
CRC16 Algorithm calculate in C/C++ for ESPrtk frame:
#include <stdio.h> const char MSG[]= "$ESP_OK|14|W|m|3|0|0|0|0|*????\r\n"; // Calculate CRC uint8_t FIRST_CRC = 0 ; uint8_t SECOND_CRC = 0 ; uint16_t i = 0 ; while ( MSG [i] != '*' ){ // CRC_Range calculate from after '$' to begin '*' ( not contain '$' and '*') if ( MSG [i] != '$' ){ FIRST_CRC ^= ( uint8_t ) MSG [i]; SECOND_CRC ^= ( uint8_t ) FIRST_CRC; } i++; } //Format CRC to [HEX_Up] string and store to buffer char CRC16_OUT [4+1] ; sprintf ( CRC16_OUT , "%02X%02X" , FIRST_CRC , SECOND_CRC ); //Print out result printf ( "\n Your CRC16 is %s \n", CRC16_OUT); //Result should be [ Your CRC16 is 6D76 ]
ESPrtk support suggestions for fixing errors.
When ESPrtk receives an incorrectly structured message frame, it returns a NACK message.
If the message is valid and corrupted, ESPrtk will give an error and suggest correction.
A valid structured message (minimum) must include <Header> <Length_Payload> <Payload> <* CRC>, for example: $ESP_OK|??|?|?|*????
Note : The error correction suggestion function is only fully supported when running in UART Configure mode.
Examples:
HOST Send | $ESP_OK|??|?|?|*???? |
Respond | NACK :[?] LENGTH_MESSAGE invalid (not a number) - [?] Do you mean LENGTH_MESSAGE = 4 |
HOST Send | $ESP_OK|4|?|?|*???? |
Respond | NACK : Your_CRC = [????]: [?] Do you mean Checksum_CRC = 295A |
HOST Send | $ESP_OK|?|P|_||*???? |
Respond | NACK :[?] LENGTH_MESSAGE invalid (not a number) - [?] Do you mean LENGTH_MESSAGE = 5 |
HOST Send | $ESP_OK|5|P|_||*???? |
Respond | NACK : Your_CRC = [????]: [?] Do you mean Checksum_CRC = 5B01 |
HOST Send | $ESP_OK|5|P|_||*5B01 |
Respond | $ESP_OK|5|P|_||*5B01 |