- Mon Jan 12, 2015 4:34 pm
#7129
Am I the only one that gets that "MQTT:Published." print?
23:15:59.745> connected with OpenWrt, channel 1
23:15:59.745> dhcp client start...
23:16:00.183> STATION_IDLE
23:16:00.556> ip:192.168.1.8,mask:255.255.255.0,gw:192.168.1.1
23:16:00.681> TCP: Connect to ip 192.168.1.1:1883
23:16:00.743> MQTT: Connected to broker 192.168.1.1:1883
23:16:00.743> MQTT: Send mqtt connection info, to broker 192.168.1.1:1883
23:16:00.743> TCP: Sent
23:16:00.743> TCP: data received
23:16:00.743> MQTT: Connected to 192.168.1.1:1883
23:16:00.743> MQTT: Connected
23:16:00.743> MQTT: subscribe, topic"/test/control/sleeptime" at broker 192.168.1.1:1883
23:16:00.743> TCP: Sent
23:16:00.743> TCP: data received
23:16:00.743> MQTT: Subscribed
23:16:00.743> MQTT: sending publish...
23:16:00.743> MQTT: Subscribe successful
23:16:00.743> TCP: Sent
23:16:00.743> MQTT: Published23:16:00.743> TCP: data received
23:16:00.743> MQTT topic: /test/control/sleeptime40, data: 40
23:16:01.243> Guard timer elapsed, going to sleep for 40 secondsrm match
23:16:01.243> pm close 7 0 0/1530383
23:16:01.243> TCP: Reconnect to 192.168.1.1:1883
23:16:01.306> deep sleep 40s
Timestamps are from my serial terminal, guard timer is not relevant here, just protection if something fails in any of the states. At the end it ensures 500ms to get any subscribed messages (like the sleeptime).
/test/control/sleeptime holds a retained message that sets the sensor sleep period (40s in this case).
I have added also "subscribed" callback to be able to tick my state machine completely on events. No need of queues, no delays on polling
Just effective event programming.
I also made some trials with wifi_set_sleep_type(), it works but I need to measure and document the results like Tuan has done it in the other topic (scope pictures).