このページは、お客様の言語ではご利用いただけません。Huawei Cloudは、より多くの言語バージョンを追加するために懸命に取り組んでいます。ご協力ありがとうございました。

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Binding a Device

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

API Function

A device must be bound to the IoT platform before accessing the IoT platform for the first time. The upper-layer application calls this API to transfer the device serial number, MAC address, or other device information to bind a device to the IoT platform.

Before binding a device, developers must call the BindConfig.setConfig API to set the IP address and port number of the IoCM server to be bound. The default port number is 8943 for the AgentLite.

API Description

1
public static boolean bind(String verifyCode, IotaDeviceInfo deviceInfo);

Class

BindService

Parameter Description

Parameter

Mandatory or Optional

Type

Description

verifyCode

Mandatory

String

Specifies a device binding verification code.

If the device is registered on the SP portal, set verifyCode to the preSecret used during device registration.

deviceInfo

Mandatory

IotaDeviceInfo

Specifies information about the device.

Return Value

Return Value

Description

true

Success

false

Failure

NOTE:
  • Return values only show API calling results. For example, the return value true indicates that the API is called successfully but does not indicate that the binding is successful. The binding is successful only after the BindService broadcast is received.
  • If the binding fails, the AgentLite automatically binds the device after 30 seconds. If the retry fails for five consecutive times (the total number of attempts is six), a message is returned indicating that the binding fails and the binding stops. If developers want to re-initiate the binding, restart the device.

Example

Call this API to bind a device.

1
2
3
String verifyCode =   "123456"  ;
deviceInfo = new IotaDeviceInfo(nodeId,manufactrueId,deviceType,model,protocolType);
BindService.bind(verifyCode,deviceInfo);

Implement the observer API provided by the AgentLite before calling this API.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
//Call the bindService.registerObserver(this) to register the observer for receiving the binding result callback and obtaining callback parameters, which are used in login configuration.
public class AgentliteBind implements MyObserver{
    public Subscribe (Observable bindService) {
        bindService. registerObserver (this);
    }
}
//Override the update method in the AgentliteBind.
@Override
public void update(IotaMessage arg0) {
    System.out.println("BindManager receives a binding notification:" + arg0);
    int status = arg0.getUint(BindService.BIND_IE_RESULT, -1);
    System.out.println("status is :" + status);
    switch (status) {
        case 0:
        saveBindParaAndGotoLogin(arg0);
        break;
        default:
        System.out.println("============= binding failure ==============")
        bindAction();
        break;
    }
}

Receive a device binding response.

1
2
3
4
5
6
7
8
9
//After a device is bound, the AgentLite will return the parameters shown in the following output. Developers must store these parameters and configure these parameters on the device before connecting the device to the IoT platform.
//Save the parameters carried in the device binding response.
private void saveBindParaAndGotoLogin(IotaMessage iotaMsg) {
    String appId = iotaMsg.getString(BindService.BIND_IE_APPID);
    String deviceId = iotaMsg.getString(BindService.BIND_IE_DEVICEID);
    String secret = iotaMsg.getString(BindService.BIND_IE_DEVICESECRET);
    String haAddress = null, lvsAddress = null;
    saveGatewayInfo(appId, deviceId, secret, haAddress, lvsAddress);
}

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback