ESP8266 - Implemented MQTT disconnect
This commit is contained in:
parent
c8783b599b
commit
b07e5f8058
2 changed files with 14 additions and 0 deletions
|
@ -412,6 +412,19 @@ uint8_t ESP8266::MqttConnect(const char* host, const char* clientId, const char*
|
|||
return(ERR_RESPONSE_MALFORMED);
|
||||
}
|
||||
|
||||
uint8_t ESP8266::MqttDisconnect() {
|
||||
// build the DISCONNECT packet
|
||||
uint8_t packet[2];
|
||||
|
||||
// fixed header
|
||||
packet[0] = (MQTT_DISCONNECT << 4);
|
||||
packet[1] = 0x00;
|
||||
|
||||
// send MQTT packet
|
||||
uint8_t state = send(packet, 2);
|
||||
return(state);
|
||||
}
|
||||
|
||||
uint8_t ESP8266::MqttPublish(const char* topic, const char* message) {
|
||||
// encode packet length
|
||||
size_t topicLen = strlen(topic);
|
||||
|
|
|
@ -44,6 +44,7 @@ class ESP8266 {
|
|||
|
||||
// MQTT methods
|
||||
uint8_t MqttConnect(const char* host, const char* clientId, const char* userName = "", const char* password = "", uint16_t keepAlive = 60, bool cleanSession = true, const char* willTopic = "", const char* willMessage = "");
|
||||
uint8_t MqttDisconnect();
|
||||
uint8_t MqttPublish(const char* topic, const char* message);
|
||||
|
||||
// Transport layer methods
|
||||
|
|
Loading…
Add table
Reference in a new issue