如何通过配网基座及业务包快速搭建自定义配网首页

App开发相关产品技术讨论,包括OEM App、App SDK等话题


Post Reply
ZoeTuya
Posts: 9

5.17.0 配网业务包发布单产品配网入口,结合配网基座提供的复合扫描功能,用户可自定义配网首页。
公版首页包含设备搜索功能、手动配网和扫一扫配网,三个功能均可已提供接口自定义样式。

    设备搜索

    针对 OEM APP,设备搜索提供两种交互,目前可在开发者平台进行配置。客户仍可使用基座提供的复合扫描设备功能来自定义设备搜索交互。搜索设备类型可自由控制,但需要注意不同设备类型搜索的前置条件。

    如需要同时扫描双模、单点、SIGMesh和 Beacon 设备,示例如下:

    Code: Select all

        class searchModeConfigurationVC: UITableViewController {
        
    var typeList:[ThingSmartActivatorTypeModel] = [] private var sigModel: ThingSmartActivatorTypeSigMeshModel = { let type = ThingSmartActivatorTypeSigMeshModel() type.type = ThingSmartActivatorType.sigMesh type.typeName = NSStringFromThingSmartActivatorType(ThingSmartActivatorType.sigMesh) type.timeout = 120 return type }() private var bleModel: ThingSmartActivatorTypeBleModel = { let type = ThingSmartActivatorTypeBleModel() type.type = ThingSmartActivatorType.ble type.typeName = NSStringFromThingSmartActivatorType(ThingSmartActivatorType.ble) type.timeout = 120 return type }() private var beaconModel: ThingSmartActivatorTypeBeaconModel = { let type = ThingSmartActivatorTypeBeaconModel() type.type = ThingSmartActivatorType.beacon type.typeName = NSStringFromThingSmartActivatorType(ThingSmartActivatorType.beacon) type.timeout = 120 return type }() lazy var discovery: ThingSmartActivatorDiscovery = { let discovery = ThingSmartActivatorDiscovery() self.typeList = [self.matterModel,self.EZModel,self.wiredModel,self.pegasusModel,self.bleModel,self.sigModel,self.beaconModel,self.subDeviceModel,self.routerModel] discovery.register(withActivatorList: self.typeList) discovery.setupDelegate(self) discovery.loadConfig() return discovery }() private func startSearch() { guard let homeID = Home.current?.homeId else { return } sigModel.spaceId = homeID bleModel.spaceId = homeID discovery.startSearch(typeList) } } extension searchModeConfigurationVC: ThingSmartActivatorSearchDelegate { func activatorService(_ service: ThingSmartActivatorSearchProtocol, activatorType type: ThingSmartActivatorTypeModel, didFindDevice device: ThingSmartActivatorDeviceModel?, error errorModel: ThingSmartActivatorErrorModel?) { if let device = device { /// discovery Device } } func activatorService(_ service: ThingSmartActivatorSearchProtocol, activatorType type: ThingSmartActivatorTypeModel, didUpdateDevice device: ThingSmartActivatorDeviceModel) { } }

      手动配网

      公版手动配网列表种类多且展示为品类入口,OEM 客户可自定义配网品类列表,但是需要使用涂鸦提供样式,如果产品类型较少或者想在提供产品展示添加配网入口无法实现,因此5.17.0开放了单产品配网入口,配网信息可到开发者平台->产品配置中完成。

      产品的配网列表展示和入口可自定义。

      获取产品配网信息及跳转示例如下:

      Code: Select all

                  let requestData =  ThingActivatorCategoryDetailRequestData()
                  requestData.bizType = 1
                  requestData.bizValue = "rj74cnjwwsste1g6"
                  requestService.requestCategoryDetail(withParam: requestData) { result in
                      let impl = ThingSmartBizCore.sharedInstance().service(of: ThingActivatorProtocol.self)
                      (impl as AnyObject).gotoAcvitavor(with: result, userInfo: [:])
                  } failure: { error in
                      
      }

      另配网流程交互也可自定义交互实现,可通过上述示例的接口获取配网信息自行实现交互。

        扫一扫

        扫码入口可自定义,但扫码 UI 不支持定制,目前仅提供带扫码 UI 的联合功能。

        使用示例:

        Code: Select all

            if let impl = ThingSmartBizCore.sharedInstance.service(of: ThingActivatorProtocol.self),
               impl.responds(to: #selector(impl.gotoQRCodeViewController(withUserInfo:))) {
                impl.gotoQRCodeViewController(withUserInfo: nil)
            }

        参考文档
        快速搭建单品类配网流程
        iOS:https://developer.tuya.com/cn/docs/app- ... hotgklw3rv
        Android:https://developer.tuya.com/cn/docs/app- ... hpg3cwjo0k

        符合扫描设备功能
        iOS:https://developer.tuya.com/cn/docs/app- ... 5yxmgx0isv
        Android:https://developer.tuya.com/cn/docs/app- ... 38exgyp6om

        扫一扫
        iOS:https://developer.tuya.com/cn/docs/app- ... le-19-扫码功能
        Android:https://developer.tuya.com/cn/docs/app- ... e-12-打开扫一扫


        Tags:
        Post Reply