Skip to content

Instantly share code, notes, and snippets.

@LeviSchuck
Created August 10, 2018 04:24
Show Gist options
  • Save LeviSchuck/c97ad9496bcdd1144662b2b3d0c25cb6 to your computer and use it in GitHub Desktop.
Save LeviSchuck/c97ad9496bcdd1144662b2b3d0c25cb6 to your computer and use it in GitHub Desktop.
/*
* Commands
* - Wifi commands
* - MQTT commands
* Whenever a command is not recognized, a response of "?" is given
* --------------------------------------------------------------------------------
*
* Wifi Commands
*
* Set IP
* WI<ip byte[4]><gateway byte[4]><subnet byte[4]><dns byte[4]>
* Replies with
* - WI: Set successfully
*
* Connect to Wifi (not blocking)
* WC<ssid length byte><password length byte><ssid string, not 0 terminated><password string, not 0 terminated>
* password length may be 0, subsequently the password string may have no content
* Replies with
* - WCF Internal failure or parameter failure
* - WCS Successfully initiated the wifi connection
*
* Disconnect from Wifi
* WD
* Replies with
* - WD Called disconnect
*
* Get Wifi status
* WS
* Replies with
* - WS<status int32>
* Copied from the documentation, the status int should be one of the following values
* 0 : WL_IDLE_STATUS when Wi-Fi is in process of changing between statuses
* 1 : WL_NO_SSID_AVAIL in case configured SSID cannot be reached
* 3 : WL_CONNECTED after successful connection is established
* 4 : WL_CONNECT_FAILED if password is incorrect
* 6 : WL_DISCONNECTED if module is not configured in station mode
*
* --------------------------------------------------------------------------------
*
* Configure MQTT
* MI<server length byte><port uint16><server string, not 0 terminated>
* Replies with
* - MI
*
* Connect MQTT (blocking)
* MC<device id length byte><user length byte><password length byte><device id string, not 0 terminated><user string, not 0 terminated><password string, not 0 terminated>
* Replies with
* - MCF Internal failure or bad input
* - MCS Success
* user length may be 0, subsequently the user string may have no content
* password length may be 0, subsequently the password string may have no conent
*
* Disconnect MQTT
* MD
* Replies with
* - MD
*
* Subscribe to MQTT topic (blocking)
* MB<topic length byte><topic string, not 0 terminated>
* Replies with
* - MBF on internal failure, bad input, or on bad MQTT response
* - MBS on success
*
* TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
* Unsubscribe to MQTT topic (blocking)
* MU<topic length byte><topic string, not 0 terminated>
* Replies with
* - MUF on internal failure, bad input, or bad MQTT response
* - MUS on success
*
* Get MQTT Status
* MS
* Replies with
* - MS<status int32>
* Copied from the source of PubSubClient
* -4 MQTT_CONNECTION_TIMEOUT
* -3 MQTT_CONNECTION_LOST
* -2 MQTT_CONNECT_FAILED
* -1 MQTT_DISCONNECTED
* +0 MQTT_CONNECTED
* +1 MQTT_CONNECT_BAD_PROTOCOL
* +2 MQTT_CONNECT_BAD_CLIENT_ID
* +3 MQTT_CONNECT_UNAVAILABLE
* +4 MQTT_CONNECT_BAD_CREDENTIALS
* +5 MQTT_CONNECT_UNAUTHORIZED
*
* TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
* Publish
* MP<topic length><content length><topic string, not 0 terminated><content bytes>
* Replies with
* - MPF on internal failure, bad input, or bad MQTT response
* - MPS on success
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment