设备管理 IOTDM(联通用户专用)-更新设备状态:示例

时间:2024-07-03 16:54:08

示例

1
HubService.deviceStatusUpdate(0, deviceId, ONLINE, NONE);

然后等待命令执行结果

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
// 开发者注册广播接收器对设备状态更新结果进行相应的处理 
BroadcastReceiver mReceiverDevStatus;
mReceiverDevStatus = new BroadcastReceiver() {
    @Override 
    public void onReceive(Context context, Intent intent) {
        //获取IotaMessage
        IotaMessage iotaMsg = (IotaMessage)intent.getSerializableExtra(HubService.HUB_BROADCAST_IE_IOTAMSG);
        //获取响应的错误码 
        String result = iotaMsg.getString(HubService.HUB_IE_RESULT);
        String deviceId = iotaMsg.getString(HubService.HUB_IE_DEVICEID);
        ... 
        return true;
    }
}
mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);
IntentFilter filterDiscon= new IntentFilter(HubService. TOPIC_DEVSTATUS_UPDATA_RSP);
mLocalBroadcastManager.registerReceiver(mReceiverDevStatus, filterDiscon);
support.huaweicloud.com/sdkreference-iot/iot_06_1017.html