IoTIoT

Compute
Elastic Cloud Server
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
Domain Name Service
VPC Endpoint
Cloud Connect
Enterprise Switch
Security & Compliance
Anti-DDoS
Web Application Firewall
Host Security Service
Data Encryption Workshop
Database Security Service
Advanced Anti-DDoS
Data Security Center
Container Guard Service
Situation Awareness
Managed Threat Detection
Compass
Cloud Certificate Manager
Anti-DDoS Service
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GaussDB NoSQL
GaussDB(for MySQL)
Distributed Database Middleware
GaussDB(for openGauss)
Developer Services
ServiceStage
Distributed Cache Service
Simple Message Notification
Application Performance Management
Application Operations Management
Blockchain Service
API Gateway
Cloud Performance Test Service
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
DevCloud
ProjectMan
CodeHub
CloudRelease
CloudPipeline
CloudBuild
CloudDeploy
Cloud Communications
Message & SMS
Cloud Ecosystem
Marketplace
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP License Service
Support Plans
Customer Operation Capabilities
Partner Support Plans
Professional Services
enterprise-collaboration
Meeting
IoT
IoT
Intelligent EdgeFabric
DeveloperTools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Updated at: Feb 24, 2022 GMT+08:00

Receiving Device Commands

API Function

This API is used to register the broadcast for receiving control commands from the IoT platform.

API Description

1
IOTA_TOPIC_SERVICE_COMMAND_RECEIVE/{deviceId};

Parameter Description

For details, see IEs in the EN_IOTA_DATATRANS_IE_TYPE Messages.

Output

None

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
//Developers call this API to register the function for subsequent processing after device commands are received.
HW_iNT Switch_CommandRecvtHandler(HW_UiNT uiCookie, HW_MSG pstMsg) 
{
    HW_cHAR *pcMethod, *pcServiceId, *pcCmdContent, *pcDeviceId;
    pcDeviceId = HW_MsgGetStr(pstMsg, EN_IOTA_DATATRANS_IE_DEVICEID);
    pcServiceId = HW_MsgGetStr(pstMsg, EN_IOTA_DATATRANS_IE_SERVICEID);
    pcMethod = HW_MsgGetStr(pstMsg, EN_IOTA_DATATRANS_IE_METHOD);
    pcCmdContent = HW_MsgGetStr(pstMsg, EN_IOTA_DATATRANS_IE_CMDCONTENT);
if (strcmp(pcServiceId, "switch"))
    {
//Developers call this API to use the JSON components to parse pcCmdContent based on command parameters in the profile.
        //Send command to Switch
    }
    return 0;
}
//Developers call this API to register the broadcast for receiving device commands immediately after the device is added.
HW_BroadCastReg("IOTA_TOPIC_SERVICE_CMD_RECEIVE/XXXX_XXXX_XXXX_XXXX",
Device_AddResultHandler);

After a device is added, developers must register the broadcast for receiving commands for the device. The broadcast is in format of IOTA_TOPIC_SERVICE_CMD_RECEIVE/Device ID. When the AgentLite receives commands delivered by the IoT platform to the device, it broadcasts these commands to the broadcast processing function registered by the device. If the commands do not need to be dispatched by device ID, the broadcast can be in format of IOTA_TOPIC_SERVICE_CMD_RECEIVE.

Did you find this page helpful?

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel