设备接收云端指令
设备成功上报消息后,您可以尝试从云端下发指令到设备端。本文档讲解了如何通过云端应用通过在线调试和调用接口的方式,设置产品属性。同时,设备成功接收云端指令。
1 在线调试下发
选择 运维 -> 在线调试 -> 选择智能平板产品 -> 选择调试设备为“301房间测试平板” -> 调试类型为“下行” -> 调试功能“[属性][SET]颜色” -> 参数“{"color":"green"}
” -> 点击发送指令。
在刚才打开的demo的运行日志中,会查看到设备端接收到云端的设置属性命令。
2 调用平台接口下发
TIP
此处平台API指iot管理平台暴露的接口,包括rpc和http接口,云端SDK尚未集成这些API。
2.1 RPC调用
- 内部用户可获取平台依赖api和对应源码,源码已提供文档说明,请自行查阅:
<dependency>
<groupId>com.seewo.iot.platform</groupId>
<artifactId>iot-platform-service-api</artifactId>
<version>${iot-platform-service-api.version}</version>
</dependency>
- 示例:执行设备服务
// com.seewo.iot.platform.api.DeviceService#callDeviceService
@com.alibaba.dubbo.config.annotation.Reference
private DeviceService deviceService;
DeviceServiceRequestDto dto = new DeviceServiceRequestDto();
dto.setProductKey(PRODUCT_KEY);
dto.setDeviceId(DEVICE_ID);
dto.setTraceId(TRACE_ID);
dto.setServiceKey("getWeather");
Map<String, Object> params = new HashMap<>();
params.put("color", "pink");
params.put("volume", 10);
dto.setParams(params);
BaseResponse baseResponse = deviceService.callDeviceService(dto);
printJson(baseResponse);
2.2 HTTP调用
接口说明请查阅:HTTP接口文档