移動onenet mqtt c sdk使用
阿新 • • 發佈:2018-12-21
編譯SDK需要cmake(沒有請自行安裝)
進入 mqtt_sdk
開啟終端
cmake .
make
上面是onenet提供的c語言的SDK,裡面有個sample但是我連線了半天也沒有連線上
連線需要三樣東西device id product id auth_info,其實還有ip和埠
然後對sample.c進行修改
裡面ip和埠改為 這個官方文件裡面有
smpctx->host = "183.230.40.39";
smpctx->port = 6002;
char* prjid = "xxxxx"; //project_id //char* auth_info = "{\"SYS\":\"password\"}"; //authoriz info char* auth_info = "password"; //authoriz info你的裝置鑑權資訊 char* devid = "xxxxx"; //device_id
進入 bin檔案執行Mqttsample
[email protected]:~/桌面/MQTT-master/mqtt_sdk/bin$ ./MqttSample Commands: connect Establish the connection. ping Send ping packet. publish send data points, support parameter -q 0/1/2 (Qos0/Qos1/Qos2), -t 1-7 push_dp push data points cmdret reponse cmd to server, support parameter -q 0/1/2 (Qos0/Qos1/Qos2) subscribe Subscribe the data streams. unsubscribe Unsubscribe the data streams. disconnect Close the connection. exit Exit the sample. help Print the usage of the commands. connect dev id:503950981 project id:187677 auth info:password send one pkt 10 27 00 04 4D 51 54 54 04 C2 04 B0 00 09 35 30 33 39 35 30 39 38 31 00 06 31 38 37 36 37 37 00 08 70 61 73 73 77 6F 72 64 send over Success to connect to the server, flags(1), code(0).