MQTT Python example code to connect to MCS via mqtt protocol.
Please follows the MCS tutorial to create your prototype and test device.
$ pip install paho
If you want to subscribe a topic, the format should be mcs/deviceId/deviceKey/dataChnnelId
.
The format of the subscribe arguments are: host
、port
and topic
.
For example,
$ python subscribe.py mqtt.mcs.medaitek.com 1883 mcs/xxxxxx/yyyyyyyy/int
The format of the publish arguments are: host
、port
、 topic
and values
.
$ python publish.py mqtt.mcs.mediatek.com 1883 mcs/deviceId/deviceKey/dataChannelId timestamp,dataChannelId/values
For more information about MCS MQTT protocol, please check TCP and MQTT Connection.