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
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

Adding a Device

API Function

This API is used to add a device that accesses the IoT platform through the gateway. After the device is connected to the IoT platform, the IoT platform will assign a unique logical ID to the device.

API Description

1
HW_INT IOTA_HubDeviceAdd(HW_UINT uiCookie, const ST_IOTA_DEVICE_INFO *pstDeviceInfo);

Parameter Description

Parameter

Mandatory or Optional

Type

Description

uiCookie

Optional

HW_UINT

The value ranges from 1 to 65535.

pstDeviceInfo

Mandatory

ST_IOTA_DEVICE_INFO structure

Specifies the device information. The value must end with \0.

Return Value

For details, see 4.2 Function Return Values.

Output

Broadcast Name

Broadcast Parameter

Member

Description

IOTA_TOPIC_HUB_ADDDEV_RSP

HW_MSG object

EN_IOTA_HUB_IE_TYPE

Specifies the device addition result. If the addition is successful, the device ID is returned.

Example

1
2
3
4
5
6
7
8
9
//Developers call this API to add a device.
ST_IOTA_DEVICE_INFO stDeviceInfo 
stDeviceInfo.pcNodeId = "SN Number";
stDeviceInfo.pcManufacturerId = "Huawei";
stDeviceInfo.pcDeviceType = "Camera"; 
stDeviceInfo.pcModel = "HW_CAM101";
stDeviceInfo.pcProtocolType = "ONVIF";

IOTA_HubDeviceAdd(29011, &stDeviceInfo);

The device waits for the result.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
//Developers call this API to register the function for subsequent processing after the device is added.
HW_iNT Device_AddResultHandler(HW_UiNT uiCookie, HW_MSG pstMsg) 
{
    uiResult = HW_MsgGetUint(pstMsg, EN_IOTA_HUB_IE_RESULT);
    if (EN_IOTA_HUB_RESULT_SUCCESS != uiResult) 
    {
        // retry with uiCookie 
        return 0;
    }
    return 0;
}
//Bind the broadcast reception processing function HW_BroadCastReg ("IOTA_TOPIC_HUB_ADDDEV_RSP", Device_AddResultHandler).

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