This topic describes how to perform batch provisioning for Bluetooth Mesh devices using the Android SDK.
Dependencies
Dependent SDK | Overview |
MeshSdk | Provides basic Bluetooth Mesh capabilities. |
DeviceCenter | A unified entry point for provisioning. |
ApiClient | Provides API channel capabilities and basic environment configuration information. |
Initialization
For more information about initialization, see SDK Initialization.
Network provisioning
Obtain the list of devices to be provisioned
The DeviceInfo source is returned by device discovery. Do not modify it.The following table describes the properties of DeviceInfo.
Property
Type
Required
Description
linkType
enum
Yes
ALI_APP_MESH indicates discovery by the app. ALI_GATEWAY_MESH indicates discovery by a gateway.
productId
String
Yes
mac
String
Yes
productKey
String
Yes
addDeviceFrom
String
Yes
Description
meshGatewayIotId
String
No
meshDeviceId
String
Yes
deviceId
String
No
Start provisioning
AddDeviceBiz.getInstance().startConcurrentAddDevice(Context context,List<DeviceInfo> devicesInfos,IConcurrentAddDeviceListener listener);Provisioning result callback
interface IConcurrentAddDeviceListener { /** * Triggered after the DeviceInfo is verified. * * @param deviceInfo The DeviceInfo that is being processed. * @param isSuccess A value of true indicates success. A value of false indicates failure. * @param dcErrorCode The error code returned if the operation failed. */ void onPreCheck(DeviceInfo deviceInfo, boolean isSuccess, DCErrorCode dcErrorCode); /** * Triggered when the system is preparing for provisioning. */ void onProvisionPrepare(DeviceInfo deviceInfo, int prepareType); /** * Triggered when provisioning starts. */ void onProvisioning(DeviceInfo deviceInfo); /** * Triggered when the provisioning status changes. * @param status The current provisioning status. For more information, see ProvisionStatus. */ void onProvisionStatus(DeviceInfo deviceInfo, ProvisionStatus status); /** * Triggered when provisioning ends. * * @param isSuccess Specifies whether the operation was successful. * @param deviceInfo The device information returned on success. * @param dcErrorCode The error code returned on failure. */ void onProvisionedResult(boolean isSuccess, DeviceInfo deviceInfo, DCErrorCode dcErrorCode);Stop provisioning
AddDeviceBiz.getInstance().stopConcurrentAddDevice();
Gateway control
For more information about gateway control, see Thing Specification Language Model SDK.