mqttclient.cpp: unsubcribe & keepalive
This commit is contained in:
parent
4093a39e09
commit
2d2a8abd79
@ -12,6 +12,7 @@ WiFiClient netClient;
|
|||||||
MQTTClient mqttClient;
|
MQTTClient mqttClient;
|
||||||
|
|
||||||
void mqtt_deinit(void) {
|
void mqtt_deinit(void) {
|
||||||
|
mqttClient.unsubscribe(MQTT_INTOPIC);
|
||||||
mqttClient.onMessageAdvanced(NULL);
|
mqttClient.onMessageAdvanced(NULL);
|
||||||
mqttClient.disconnect();
|
mqttClient.disconnect();
|
||||||
vTaskDelete(mqttTask);
|
vTaskDelete(mqttTask);
|
||||||
@ -22,6 +23,7 @@ esp_err_t mqtt_init(void) {
|
|||||||
// setup network connection and MQTT client
|
// setup network connection and MQTT client
|
||||||
ETH.begin();
|
ETH.begin();
|
||||||
mqttClient.begin(MQTT_SERVER, MQTT_PORT, netClient);
|
mqttClient.begin(MQTT_SERVER, MQTT_PORT, netClient);
|
||||||
|
mqttClient.setKeepAlive(MQTT_KEEPALIVE);
|
||||||
mqttClient.onMessageAdvanced(mqtt_callback);
|
mqttClient.onMessageAdvanced(mqtt_callback);
|
||||||
|
|
||||||
_ASSERT(SEND_QUEUE_SIZE > 0);
|
_ASSERT(SEND_QUEUE_SIZE > 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user