本文介绍iOS SDK中提供蓝牙Mesh设备批量配网的能力。

依赖

依赖 SDK 概述
IMSMeshSdk 提供蓝牙mesh基础能力。
IMSDeviceCenter 配网统一入口。
IMSApiClient 提供API通道能力,和基础环境配置信息。

初始化

初始化前需确保已集成安全图片,初始化的操作请参见SDK初始化

使用说明

  • Mesh 设备配网

    Mesh设备发现以及单设备配网请参考配网SDK

  • Mesh 设备批量配网
    • 带配网设备列表
      IMLCandDeviceModel来源由设备发现返回,不用做修改。
      说明 其中(IMLCandDeviceModel *)model 为本地发现待配设备或者云端拉取产品列表组装的model。

      IMLCandDeviceModel 属性说明如下:

      属性 类型 是否必填 描述
      linkType NS_ENUM
      productId NSString
      mac NSString
      productKey NSString
      authFlag BOOL
      random NSString
      authDevice NSString
      subDeviceId NSString
      confirmCloud NSString
      addDeviceFrom(网关单独使用) NSString
      meshGatewayIotId(网关单独使用) NSString
      meshDeviceId(网关单独使用) NSString
      deviceId(网关单独使用) NSString
      gatewayDeviceName(网关单独使用) NSString
      gatewayProductKey(网关单独使用) NSString
    • 开始配网
      // 引入头文件
      #import <IMSDeviceCenter/IMLDeviceCenter.h>
      
      
      /**
      mesh 设备批量配网  目前只支持LinkType为ForceAliLinkTypeAppMesh或者ForceAliLinkTypeGatewayMesh的设备进行配网。
      添加完成设备,立即开始进行配网
      */
      - (LKDCErrCode)startConcurrentAddDevices:(nonnull NSArray<IMLCandDeviceModel *> *)devList delegate:(nullable id<ILKConcurrentAddDeviceNotifier>)delegate;
    • 配网结果回调
      // 引入头文件
      #import <IMSDeviceCenter/IMLDeviceCenter.h>
      
      - (void)notifyConcurrentProvisionResult:(nonnull IMLCandDeviceModel *)candDeviceModel withProvisionError:(nullable NSError *)provisionError{
          if (provisionError){
              NSLog(@"配网失败,错误信息:%@", provisionError);
          }else{
              NSLog(@"配网成功:%@",candDeviceModel);
          }
      }
    • 停止配网
      // 引入头文件
      #import <IMSDeviceCenter/IMLDeviceCenter.h>
      
      [kLkAddDevBiz stopAddDevice];
      [kLkAddDevBiz stopConcurrentAddDevice];
  • 网关控制

    网关控制参考物模型SDK