Updated on 2022-02-24 GMT+08:00

Receiving a Command

API Function

This API is used to process the control commands delivered by the IoT platform.

API Description

1
DataTransService.TOPIC_COMMAND_RECEIVE;

Class

DataTransService

Parameter Description

N/A

Return Value

N/A

Example

Implement the observer API provided by the AgentLite.

 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
public class AgentLiteDataTrans implements MyObserver {
    public AgentLiteDataTrans (Observable dataTransService) {
        dataTransService. registerObserver (this);
    }
    @Override
    public void update(IotaMessage arg0) {
        // TODO Auto-generated method stub
        System.out.println("AgentLiteDataTrans receives a notification:" + arg0)
        int mMsgType = arg0.getMsgType();
        switch(mMsgType) {
//Receive a data reporting response.
            case IodevService.IODEV_MSG_DATA_REPORT_RSP:
            getDataReportAnswer(arg0);
            break;
//Receive a command passively.
            case IodevService.IODEV_MSG_RECEIVE_CMD:
            getCmdReceive(arg0);
            break;
//MQTT message push
            case IodevService.IODEV_MSG_MQTT_PUB_RSP:
            //logoutResultAction(iotaMsg);
            break;
            default:
            break;
        }
    }