物模型初始化

<p>物模型初始化流程:</p> <p><img src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20191410120023-148c51679b4b.png" style="height:180px; width:499px" /></p> <p>物模型:&nbsp;</p> <table border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="background-color:#ededed; vertical-align:top"> <p><strong>功能</strong></p> </td> <td style="background-color:#ededed; vertical-align:top"> <p>上报物模型请求指令</p> </td> </tr> <tr> <td style="vertical-align:top"> <p><strong>MQTT</strong></p> <p><strong>客户端</strong></p> </td> <td style="vertical-align:top"> <p>topic: {productKeyKey}/{deviceName}/sys/thing/dsltemplate/get</p> <p>数据格式:</p> <p>{</p> <p>&ldquo;id&rdquo;:&ldquo;xxx&rdquo;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ---消息id,设备端生成,唯一</p> <p>&ldquo;version&rdquo;:&rdquo;1.0&rdquo;,&nbsp;&nbsp;&nbsp; ---协议版本号,当前版本是1.0</p> <p>&ldquo;tslType&rdquo;:1,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ---物模型类型:1 精简版,0 完整版;如果无此字段则为完整版</p> <p>&ldquo;params&rdquo;:{},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ---请求参数,当前值为空</p> <p>&ldquo;method&rdquo;:&rdquo;thing.dsltemplate.get&rdquo;&nbsp;&nbsp;&nbsp; ---请求方法</p> <p>&nbsp;</p> <p>}</p> <p>&nbsp;</p> </td> </tr> <tr> <td style="vertical-align:top"> <p><strong>功能</strong></p> </td> <td style="vertical-align:top"> <p>下发物模型模板</p> </td> </tr> <tr> <td style="vertical-align:top"> <p><strong>MQTT</strong></p> <p><strong>服务器</strong></p> </td> <td style="vertical-align:top"> <p>Topic: {productKeyKey}/{deviceName}/sys/thing/dsltemplate/get_reply</p> <p>数据格式:</p> <p>{</p> <p>&ldquo;id&rdquo;:&ldquo;xxx&rdquo;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ---消息id,设备端生成,唯一</p> <p>&ldquo;code&rdquo;:xxx,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ---返回码,成功-200</p> <p>&ldquo;data&rdquo;:{</p> <p>TSL模板 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;---物模型模板</p> <p>}</p> <p>}</p> <p>&nbsp;</p> </td> </tr> </tbody> </table> <p>示例程序\example\ pa_iot_mqtt_uart中物模型相关代码讲解:</p> <p>MQTT客户端发送请求,获取物模型模版,根据物模型的服务、事件、属性标识符订阅对应的topic,并设置回调函数on_sys_sub_callback处理接收的数据:</p> <pre> <code>void iot_mqtt_client_tsl_ready() { ………… /*register callback function which will be called when mqtt client receive data from server */ iot_mqtt_obj_module_set_listen(mqtt_client_test_handle, on_sys_sub_callback); /*subscribe topic :*/dsltemplate/get_reply,register callback*/ iot_mqtt_obj_module_tsl_get_regist(mqtt_client_test_handle); /*publish request command to server*/ iot_mqtt_obj_module_request(mqtt_client_test_handle, OBJ_MODULE_DEV_GET_TSL, NULL, NULL); } </code></pre> <p>本地运行结果:</p> <p><img src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20191410115909-19194b9f9ce0.png" style="height:149px; width:554px" /></p> <p>云端运行结果:</p> <p><img src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20191410115827-16d60aa990b4.png" style="height:257px; width:554px" /></p>
以上内容是否解决了您的问题?
请补全提交信息!
咨询·建议

电话咨询 - 7x24 小时

400-151-8800

邮件咨询

cloud@pingan.com

在线客服

7x24 小时,急速解答

工单支持

解决云产品相关技术问题