在忙了一个周末以后,照样小有效果的。宣布了一个简朴的物联网平台: http://mqtt.phodal.com,简朴地写一下运用指南。
CoAP协定
运用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
MQTT协定
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!")
HTTP协定
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 }
代码: 还在整顿中,过些时刻宣布。能够关注下github: https://github.com/phodal