Harmony Clean Flat Responsive WordPress Blog Theme

Subscribe topics every seconds in MQTT protocol.

오전 7:33 Unknown 0 Comments Category :

This time, I made a gateway to get a topic every 3 sec from end devices. In order to do this job, I needed to use subscribe and unsubscribe. I am gonna make a gateway to gather data from end devices every few min and then send it to server. The gateway need to know that every data come to gateway or not and the transporting data from end devices is completed or not. However for this time, I just made a code to receiving data for every 3 sec. The code is followed:


I used a 'count' for switch to control subscribe and unsubscribe. This code means that subscribing some topics in every 3 seconds. So the gateway devices with this code can save some power by switching to unsubscribe. This is main reason why I made this switching code for subscribe and unsubscribe. 

Following screenshot is showing the result of this code. FYI the end device is sending a 'from pi03_1'



RELATED POSTS

0 개의 댓글