<h2 id="air800介绍" style="outline: 0px; padding: 0px; margin: 8px 0px 16px; font-size: 24px; color: rgb(79, 79, 79); font-weight: 700; line-height: 32px; word-break: break-all; font-family: -apple-system, " sf="" ui="" text",="" arial,="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei",="" "wenquanyi="" micro="" hei",="" sans-serif;="" font-variant-ligatures:="" common-ligatures;"="">OneNet平台介绍<br></h2><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, " sf="" ui="" text",="" arial,="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei",="" "wenquanyi="" micro="" hei",="" sans-serif;="" font-variant-ligatures:="" common-ligatures;"="">OneNET作为中国移动通信集团推出的一个专业物联网开放云平台,提供了丰富的智能硬件开发工具和可靠的服务,助力各类终端设备迅速接入网络,实现数据传输、数据存储、数据管理等完整的交互流程。</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, " sf="" ui="" text",="" arial,="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei",="" "wenquanyi="" micro="" hei",="" sans-serif;="" font-variant-ligatures:="" common-ligatures;"="">支持公开协议包括EDP、MODBUS、MQTT以及HTTP等多种协议。详细资料参见:<a href="https://open.iot.10086.cn/doc" rel="nofollow" target="_blank" style="outline: 0px; color: rgb(103, 149, 181); cursor: pointer; word-break: break-all;">https://open.iot.10086.cn/doc</a></p><h2 id="所需api" style="outline: 0px; padding: 0px; margin: 8px 0px 16px; font-size: 24px; color: rgb(79, 79, 79); font-weight: 700; line-height: 32px; word-break: break-all; font-family: -apple-system, " sf="" ui="" text",="" arial,="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei",="" "wenquanyi="" micro="" hei",="" sans-serif;="" font-variant-ligatures:="" common-ligatures;"=""><a name="t2" style="outline: 0px; color: rgb(78, 161, 219); cursor: pointer; word-break: break-all;"></a>所需API</h2><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, " sf="" ui="" text",="" arial,="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei",="" "wenquanyi="" micro="" hei",="" sans-serif;="" font-variant-ligatures:="" common-ligatures;"="">Luat封装了很多的实用API,所以在实现一些功能的时候就无需自己造轮子,直接调用其API即可</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, " sf="" ui="" text",="" arial,="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei",="" "wenquanyi="" micro="" hei",="" sans-serif;="" font-variant-ligatures:="" common-ligatures;"=""><a href="http://wiki.openluat.com/doc/luatApi/#mqtt" rel="nofollow" target="_blank" style="outline: 0px; color: rgb(103, 149, 181); cursor: pointer; word-break: break-all;">mqtt</a></p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, " sf="" ui="" text",="" arial,="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei",="" "wenquanyi="" micro="" hei",="" sans-serif;="" font-variant-ligatures:="" common-ligatures;"=""><a href="http://wiki.openluat.com/doc/luatApi/#pack" rel="nofollow" target="_blank" style="outline: 0px; color: rgb(103, 149, 181); cursor: pointer; word-break: break-all;">pack</a></p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, " sf="" ui="" text",="" arial,="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei",="" "wenquanyi="" micro="" hei",="" sans-serif;="" font-variant-ligatures:="" common-ligatures;"=""><a href="http://wiki.openluat.com/doc/luatApi/#gps" rel="nofollow" target="_blank" style="outline: 0px; color: rgb(103, 149, 181); cursor: pointer; word-break: break-all;">gps</a></p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, " sf="" ui="" text",="" arial,="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei",="" "wenquanyi="" micro="" hei",="" sans-serif;="" font-variant-ligatures:="" common-ligatures;"="">lbs</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, " sf="" ui="" text",="" arial,="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei",="" "wenquanyi="" micro="" hei",="" sans-serif;="" font-variant-ligatures:="" common-ligatures;"=""><a href="http://wiki.openluat.com/doc/luatApi/#json" target="_blank">json</a></p><h2 id="实现思路" style="outline: 0px; padding: 0px; margin: 8px 0px 16px; font-size: 24px; color: rgb(79, 79, 79); font-weight: 700; line-height: 32px; word-break: break-all; font-family: -apple-system, " sf="" ui="" text",="" arial,="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei",="" "wenquanyi="" micro="" hei",="" sans-serif;="" font-variant-ligatures:="" common-ligatures;"=""><a name="t3" style="outline: 0px; color: rgb(78, 161, 219); cursor: pointer; word-break: break-all;"></a>实现思路</h2><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, " sf="" ui="" text",="" arial,="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei",="" "wenquanyi="" micro="" hei",="" sans-serif;="" font-variant-ligatures:="" common-ligatures;"="">本例通过MQTT将Air800获取到的GPS坐标发送到OneNET平台并显示。</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, " sf="" ui="" text",="" arial,="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei",="" "wenquanyi="" micro="" hei",="" sans-serif;="" font-variant-ligatures:="" common-ligatures;"="">MQTT协议是一个面向物联网应用的即时通信协议,使用TCP/IP提供网络连接,能够对负载内容实现消息屏蔽传输,开销小,可以有效降低网络流量。OneNET平台采用的是标准MQTT协议,所以使用合宙提供的MQTT API就能很方便的连上。只需要在OneNET上生成一个应用方可得到MQTT鉴权</p><pre class="prettyprint" name="code" style="outline: 0px; padding: 8px 16px 6px 56px; margin-bottom: 24px; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 14px; position: relative; overflow-y: hidden; line-height: 22px; color: rgb(0, 0, 0); background-color: rgb(246, 248, 250); border-width: initial; border-style: none; border-color: initial; font-variant-ligatures: common-ligatures;"><code class="hljs has-numbering" style="outline: 0px; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 14px; display: block; padding: 0.5em; color: rgb(0, 0, 0); line-height: 22px; background-color: rgb(246, 248, 250); border-radius: 4px; overflow-x: auto; white-space: pre; word-wrap: normal; text-size-adjust: none; word-break: break-all;">Q1:MQTT连接鉴权时,Payload中ClientIdentifier;UserName;UserPassword分别填写什么?
A: ClientIdentifier: 创建设备时得到的设备ID,为数字字串;
UserName: 注册产品时,平台分配的产品ID,为数字字串;
UserPassword: 为设备的鉴权信息(即唯一设备编号,SN),或者为apiKey,为字符串。</code><ul class="pre-numbering" style="outline: 0px; padding-top: 8px; padding-bottom: 8px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: inherit; word-break: break-all; position: absolute; width: 48px; background-color: rgb(238, 240, 244); top: 0px; left: 0px; text-align: right;"><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">1</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">2</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">3</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">4</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">5</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">6</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">7</li></ul></pre><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, " sf="" ui="" text",="" arial,="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei",="" "wenquanyi="" micro="" hei",="" sans-serif;="" font-variant-ligatures:="" common-ligatures;"="">OneNET平台优势之一可以利用数据点快速生成应用</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, " sf="" ui="" text",="" arial,="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei",="" "wenquanyi="" micro="" hei",="" sans-serif;="" font-variant-ligatures:="" common-ligatures;"=""><img src="http://oldask.openluat.com/image/show/attachments-2018-09-MvPFGaTu5b9c730355901.png" class="img-responsive" style="color: rgb(0, 0, 0); font-size: 14px; text-align: start; width: 865.5px;"></p><div><br></div><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, " sf="" ui="" text",="" arial,="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei",="" "wenquanyi="" micro="" hei",="" sans-serif;="" font-variant-ligatures:="" common-ligatures;"=""><img src="http://oldask.openluat.com/image/show/attachments-2018-09-5bFg4QYI5b9c7307e3436.png" class="img-responsive" style="color: rgb(0, 0, 0); font-size: 14px; text-align: start; width: 709.5px;"></p><div><br>要想让数据在OneNET平台上以数据点形式展现出来就得按照OneNET协议上传数据,使用OneNET平台的mqtt协议调试工具可以看到payload以json格式发送,并在json前面加0x01,0x00,0x20(这个字节为json长度),payload格式发送。</div><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, " sf="" ui="" text",="" arial,="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei",="" "wenquanyi="" micro="" hei",="" sans-serif;="" font-variant-ligatures:="" common-ligatures;"="">json格式如下</p><pre class="prettyprint" name="code" style="outline: 0px; padding: 8px 16px 6px 56px; margin-bottom: 24px; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 14px; position: relative; overflow-y: hidden; line-height: 22px; color: rgb(0, 0, 0); background-color: rgb(246, 248, 250); border-width: initial; border-style: none; border-color: initial; font-variant-ligatures: common-ligatures;"><code class="language-json hljs has-numbering" style="outline: 0px; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 14px; display: block; padding: 0.5em; color: rgb(0, 0, 0); line-height: 22px; background-color: rgb(246, 248, 250); border-radius: 4px; overflow-x: auto; white-space: pre; word-wrap: normal; text-size-adjust: none; word-break: break-all;">{
"<span class="hljs-attribute" style="outline: 0px; font-size: inherit; word-break: break-all;">datastreams</span>": <span class="hljs-value" style="outline: 0px; font-size: inherit; word-break: break-all;">[
{
"<span class="hljs-attribute" style="outline: 0px; font-size: inherit; word-break: break-all;">id</span>": <span class="hljs-value" style="outline: 0px; font-size: inherit; word-break: break-all;"><span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"temperature"</span></span>, //数据流名称或数据流模板名称
"<span class="hljs-attribute" style="outline: 0px; font-size: inherit; word-break: break-all;">datapoints</span>": <span class="hljs-value" style="outline: 0px; font-size: inherit; word-break: break-all;">[
{
"<span class="hljs-attribute" style="outline: 0px; font-size: inherit; word-break: break-all;">at</span>": <span class="hljs-value" style="outline: 0px; font-size: inherit; word-break: break-all;"><span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"2013-04-22T00:35:43"</span></span>, //上传数据点时间,可选。如果为空,则设备云会取当前时间。
//如果存在其格式必须为”YYYY-MM-DDThh:mm:ss”的形式(例如:2015-03-22T22:31:12)
“value“: 42 //上传数据点值
},
{
“at“: “2013-04-22T00:55:43”,
“value“: 84 //上传数据点值
}
]
},
{
“id“: “key”, //数据流名称或数据流模板名称
“datapoints“: [
{
“at“: “2013-04-22T00:35:43”,//上传数据点时间,可选。
“value“: {…}//上传数据点值
},
{
“at“: “2013-04-22T00:35:43”,
“value“: {…}//上传数据点值
}
]
},
{…}
]
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38