在忙了一个周末之后,还是小有成果的。发布了一个简单的物联网平台: http://mqtt.phodal.com,简单地写一下使用指南。
使用Libcoap
的话可以用
coap-client -m get coap://mqtt.phodal.com:5683/topics/zero
用coap-cli则可以用:
echo -n ‘hello world‘ | coap post coap://mqtt.phodal.com/topics/zero
echo -n ‘{"lettuce": 123}‘ | coap post coap://mqtt.phodal.com/topics/zero
Mosquitto示例
mosquitto_pub -h mqtt.phodal.com -d -t lettuce -m "Hello, MQTT. This is my first message."
Python MQTT示例:
import mosquitto
mqttc = mosquitto.Mosquitto("python_pub")
mqttc.connect("mqtt.phodal.com", 1883, 60, True)
mqttc.publish("lettuce", "Hello, World!")
POST示例
$ curl -X PUT -d ‘{ "dream": 1 }‘ -H "Content-Type: application/json" http://mqtt.phodal.com/topics/lettuce
GET示例
$ curl http://mqtt.phodal.com/topics/lettuce
{ "dream": 1 }
原文地址:http://blog.csdn.net/phodal/article/details/42610539