dreed47 / WifiMQTTManager

ESP32/ESP8266 library for managing your IoT devices.
GNU General Public License v3.0
82 stars 33 forks source link

After _recconect _subscriptionCallback called instead of subscriptionCallback #9

Open TinajaLabs opened 5 years ago

TinajaLabs commented 5 years ago

As one can see below, before a connection is lost, the subscriptionCallback (without the underscore) is called periodically from Basic.ino.

After the _reconnect method is called the subscription callback defaults to _subscriptionCallback (with the underscore) in WifiMQTTManager.cpp.

There is a line I don't understand: subscriptionCallback = _subscriptionCallback;

Also, this line: subscribeTo = _placeholderSubscibeTo;

Any tips appreciated, thanks, Chris.

09:16:30.193 -> subscriptionCallback called... top level
09:16:30.193 -> Message arrived in top level on topic: kensington/home/room/night-light/wemosd1-1/Tinaja_a020a6194f75/output. Payload: 1
09:16:30.226 -> free heap: 38696
09:16:30.226 -> mqtt pub - LED State: 1
09:16:35.189 -> subscriptionCallback called... top level
09:16:35.189 -> Message arrived in top level on topic: kensington/home/room/night-light/wemosd1-1/Tinaja_a020a6194f75/output. Payload: 0
09:16:35.222 -> free heap: 38696
09:16:35.222 -> mqtt pub - LED State: 0
09:16:52.185 -> subscriptionCallback called... top level
09:16:52.185 -> Message arrived in top level on topic: kensington/home/room/night-light/wemosd1-1/Tinaja_a020a6194f75/output. Payload: 1
09:16:52.185 -> free heap: 38544
09:16:52.185 -> mqtt pub - LED State: 1
09:16:55.451 -> subscriptionCallback called... top level
09:16:55.484 -> Message arrived in top level on topic: kensington/home/room/night-light/wemosd1-1/Tinaja_a020a6194f75/output. Payload: 0
09:16:55.484 -> free heap: 38696
09:16:55.484 -> mqtt pub - LED State: 0
09:17:12.191 -> subscriptionCallback called... top level
09:17:12.191 -> Message arrived in top level on topic: kensington/home/room/night-light/wemosd1-1/Tinaja_a020a6194f75/output. Payload: 1
09:17:12.191 -> free heap: 37912
09:17:12.191 -> mqtt pub - LED State: 1
09:17:42.192 -> not connected, calling _reconnect
09:17:42.192 -> WMM: attempting MQTT connection...mqtt connected...via reconnect loop...
09:17:42.225 -> subscribing to some topics (top level):
09:17:42.225 ->   kensington/home/room/night-light/wemosd1-1/Tinaja_a020a6194f75/output
09:17:42.225 -> WMM: subscribed to service: service/Tinaja_a020a6194f75
09:17:50.189 -> WMM: _subscriptionCallback called...
09:17:50.189 -> WMM: Message arrived on topic in WifiMQTTManager: kensington/home/room/night-light/wemosd1-1/Tinaja_a020a6194f75/output. Message: 1
09:17:55.193 -> WMM: _subscriptionCallback called...
09:17:55.193 -> WMM: Message arrived on topic in WifiMQTTManager: kensington/home/room/night-light/wemosd1-1/Tinaja_a020a6194f75/output. Message: 0
09:18:13.861 -> WMM: _subscriptionCallback called...
09:18:13.861 -> WMM: Message arrived on topic in WifiMQTTManager: kensington/home/room/night-light/wemosd1-1/Tinaja_a020a6194f75/output. Message: 1
09:18:42.223 -> not connected, calling _reconnect
09:18:42.223 -> WMM: attempting MQTT connection...mqtt connect failed, rc=-2 try again in 5 seconds...
09:18:52.253 -> WMM: attempting MQTT connection...mqtt connected...via reconnect loop...
09:18:54.382 -> subscribing to some topics (top level):
09:18:54.382 ->   kensington/home/room/night-light/wemosd1-1/Tinaja_a020a6194f75/output
09:18:54.382 -> WMM: subscribed to service: service/Tinaja_a020a6194f75
09:18:55.213 -> WMM: _subscriptionCallback called...
09:18:55.213 -> WMM: Message arrived on topic in WifiMQTTManager: kensington/home/room/night-light/wemosd1-1/Tinaja_a020a6194f75/output. Message: 0
09:19:10.193 -> WMM: _subscriptionCallback called...
09:19:10.193 -> WMM: Message arrived on topic in WifiMQTTManager: kensington/home/room/night-light/wemosd1-1/Tinaja_a020a6194f75/output. Message: 1
09:19:15.194 -> WMM: _subscriptionCallback called...
09:19:15.194 -> WMM: Message arrived on topic in WifiMQTTManager: kensington/home/room/night-light/wemosd1-1/Tinaja_a020a6194f75/output. Message: 0
09:19:30.191 -> WMM: _subscriptionCallback called...
09:19:30.191 -> WMM: Message arrived on topic in WifiMQTTManager: kensington/home/room/night-light/wemosd1-1/Tinaja_a020a6194f75/output. Message: 1
09:19:35.195 -> WMM: _subscriptionCallback called...
09:19:35.195 -> WMM: Message arrived on topic in WifiMQTTManager: kensington/home/room/night-light/wemosd1-1/Tinaja_a020a6194f75/output. Message: 0