ESP8266 - Implemented MQTT disconnect

pull/1/head
Jan Gromeš 2018-07-09 11:14:57 +02:00
rodzic c8783b599b
commit b07e5f8058
2 zmienionych plików z 14 dodań i 0 usunięć

Wyświetl plik

@ -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);

Wyświetl plik

@ -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