设备配网和通用配网 UI 业务包(内附代码段)
创始人
2024-05-24 19:01:24
0

设备配网UI业务包

智能生活设备配网 UI 业务包的功能涵盖了目前常见的 Wi-Fi 设备、Zigbee 设备、蓝牙设备,并且支持二维码扫码的设备,例如 GPRS 和 NB-IoT 设备。业务包主要实现不同类型的设备配网前置操作引导,和具体入网激活。

设备类型

Wi-Fi 设备配网

支持 Wi-Fi 智能设备入网连接云服务,Wi-Fi 设备配网主要有快连模式和热点模式两种,其中智能摄像机(IPC)设备支持扫二维码方式配网。

名词说明
Wi-Fi 快连配网又称快连模式。大致流程如下:
  1. App 把配网数据包打包到 802.11 数据包的指定区域中,发送到周围环境。
  2. 智能设备的 Wi-Fi 模组处于混杂模式下,监听捕获网络中的所有报文。
  3. Wi-Fi 模组按照约定的协议数据格式,解析出 App 发出配网信息包。
Wi-Fi 热点配网又称热点模式,手机作为 STA(STAtion)连接智能设备的热点,双方建立一个 Socket 连接,通过约定端口交互数据。
IPC 扫码配网IPC 设备通过扫描 App 上的二维码,来获取配网数据信息。

Zigbee 设备配网

支持 Zigbee 网关和子设备配网:

名词说明
Zigbee 网关融合 Zigbee 网络中协调器和 Wi-Fi 功能的设备,负责 Zigbee 网络的组建及数据信息存储。
Zigbee 子设备Zigbee 网络中的路由或者终端设备,负责数据转发或者终端控制响应。

蓝牙设备配网

涂鸦蓝牙有以下几种技术方案:

名词说明
蓝牙单点蓝牙设备与手机一对一连接的单点设备(蓝牙或蓝牙 LE)。
蓝牙 Mesh蓝牙技术联盟发布的蓝牙拓扑通信。
涂鸦 Mesh涂鸦自研的蓝牙拓扑通信,使用场景与蓝牙 Mesh 产品相同。
双模设备一些多协议设备也会使用到蓝牙技术,例如同时具备 Wi-Fi 能力和蓝牙能力的 双模设备

扫码配网设备

扫码配网设备上电后即连接了涂鸦的云服务,App 通过扫描设备上的二维码让设备在云端激活绑定。这个二维码必须是涂鸦支持的二维码规则,具体接入方式可找我咨询。

名词说明
GPRS 设备采用 GPRS 通信技术接入网络连接云服务的智能设备。
NB-IoT 设备采用窄带物联网(NarrowBand-Internet of Things)技术的智能设备。

自动发现配网

融合涂鸦智能通用配网技术实现,为用户提供一套快捷配网的功能。

集成业务包

  1. 创建工程。

    在 Android Studio 中建立的工程,接入涂鸦智能生活 SDK 并完成 业务包框架接入。

  2. 配置业务的 build.gradle。

    dependencies {
    api 'com.tuya.smart:tuyasmart-bizbundle-device_activator:4.2.0-22'
    }
    
  3. 混淆配置。

    #fastJson
    -keep class com.alibaba.fastjson.**{*;}
    -dontwarn com.alibaba.fastjson.**#rx
    -dontwarn rx.**
    -keep class rx.** {*;}
    -keep class io.reactivex.**{*;}
    -dontwarn io.reactivex.**
    -keep class rx.**{ *; }
    -keep class rx.android.**{*;}#fresco
    -keep class com.facebook.drawee.backends.pipeline.Fresco
    -keep @com.facebook.common.internal.DoNotStrip class *
    -keepclassmembers class * {
    @com.facebook.common.internal.DoNotStrip *;
    }#tuya
    -keep class com.tuya.**{*;}
    -dontwarn com.tuya.**
    

功能调用

功能配置

配置项字段名描述默认配置
热点名称配置SmartLife热点配网支持的热点前缀列表SmartLife
是否支持蓝牙true是否支持蓝牙设备配网功能true
是否支持蓝牙 Meshtrue是否支持蓝牙 Mesh 设备配网功能true
是否支持扫一扫true是否支持列表页面右上角扫描配网功能true
自发现是否支持 Wi-Fi 快连配网false是否支持自发现页面配网 Wi-Fi 快连类型设备false

方法调用

TuyaDeviceActivatorManager.startDeviceActiveAction(this);TuyaDeviceActivatorManager.setListener(new ITuyaDeviceActiveListener() {@Overridepublic void onDevicesAdd(List list) {}@Overridepublic void onRoomDataUpdate() {}@Overridepublic void onOpenDevicePanel(String s) {}@Overridepublic void onExitConfigBiz() {}});

入参说明

参数说明
activity配网 activity
homeId家庭 ID,详情请参考涂鸦智能生活 SDK 家庭信息管理

出参说明

参数说明
devIds配网成功的设备 ID 列表
updateRoomData房间设备信息是否有变更
onOpenDevicePanel可以打开某个面板,根据实际业务需要选择实现
onExitConfigBiz未执行配网,主动退出配网业务,根据实际业务需要选择实现

通用配网UI业务包 

安卓版通用配网业务包提供配网列表数据查询能力,提供了查询数据列表自定义展示的方法。大家可以结合涂鸦 IoT 平台支持的配网列表页数据,来配置列表页。

功能说明

  • 通过 TyActivatorExtraBusinessKit 提供的对应方法查询对应的数据类目信息。

  • 请在 build.gradle 文件依赖声明中,配置相关依赖:

    dependencies {...implementation 'com.tuya.smart:tuyasmart-TuyaSmartActivatorExtraBizBundle:1.0.0'...}
    

查询配网列表一级品类数据

接口说明

getDeviceLevelFirstData(callback)

请求参数

请求示例

		TyActivatorExtraBusinessKit.INSTANCE.getDeviceLevelFirstData(new Business.ResultListener() {@Overridepublic void onFailure(BusinessResponse businessResponse, CategoryResultBean categoryResultBean, String s) {}@Overridepublic void onSuccess(BusinessResponse businessResponse, CategoryResultBean categoryResultBean, String s) {}});

返回示例

{"result":{"defaultLevel2List":[//默认二级品类列表{"tagCode":"cz_tag",//二级标签"name":"Socket",//二级标签名称"level3Items":[//三级类目信息{"capability":1,//能力值"icon":"https://images.tuyaus.com/smart/product_icon2/cz_1.png",//图标"name":"Socket",//品类名称"attribute":5,//标位"category":"wf_cz",//品类 code"activatorDes":"Wi-Fi"}]},{"tagCode":"gj_tag","name":"Tool","level3Items":[{"capability":1024,"icon":"https://images.tuyaus.com/smart/app_category/dcb_2b_4_1618543239196.png","name":"Battery pack","attribute":5,"category":"dcb_2b_4","activatorDes":"BLE"}]}],"level1List":[//一级类目列表{"level1Code":"dgzm",//一级类目 code"name":"Electrical",//一级类目名称"type":0//配网列表类型:0-标准},{"level1Code":"zm","name":"Lighting","type":0}],"defaultWglist":[//默认网关列表{"capability":4097,//能力值"display":{//配网引导描述"wcAddBtText":"Confirm the two green lights are on.","wcTip":"Please plug in the gateway and connect it to the router, making sure your phone and the gateway are under the same network. Then, comfirm that the light is on.","wifiIconUrl":"https://images.tuyaus.com/smart_res/Group_8@2x.png","wcHelpUrl":"https://images.tuyaus.com/smart/connect-scheme-v3/help/template/wc_wgzk_zigbee/common_network/wc_wgzk_zigbee_ez_en.html","wifiTitle":"Select 2.4 GHz Wi-Fi Network and enter password.","wifiContent":"If your Wi-Fi is 5GHz, please set it to be 2.4GHz.","wcTipIconUrl":"https://images.tuyaus.com/smart_res/iot_os/wgzk_wc_2green@2x.png"},"icon":"https://images.tuyaus.com/smart/product_icon2/zigbee_4097.png","name":"Gateway","linkModes":[{"leadList":[{"iconUrl":"https://images.tuyaus.com/smart_res/iot_os/wgzk_doublelink_power_network.png","title":"Please plug in the gateway and connect it to the router."},{"iconUrl":"https://images.tuyaus.com/smart_res/iot_os/wgzk_reset@2x.png","title":"Hold the RESET button for 5s."},{"iconUrl":"https://images.tuyaus.com/smart_res/iot_os/wgzk_wc_2green@2x.png","title":"Confirm the two green lights are on."}],"linkMode":8,"title":"Cable"}],"enableLead":false,"attribute":0,"category":"wf_zig_zigbee"}]},"t":1622190464866,"success":true,"status":"ok"
}

查询配网列表二级品类数据

接口说明

getDeviceLevelSecondData(levelCode,type,callback)

请求参数

名称参数类型说明
levelCodeString一级类目的 levelCode
typeInt一级类目的 type

请求示例

TyActivatorExtraBusinessKit.INSTANCE.getDeviceLevelSecondData(level1Bean.getLevel1Code(),level1Bean.getType(),new Business.ResultListener>() {@Overridepublic void onFailure(BusinessResponse businessResponse, ArrayList categoryLevelTwoBeans, String s) {}@Overridepublic void onSuccess(BusinessResponse businessResponse, ArrayList categoryLevelTwoBeans, String s) {}});

返回示例

{"result":[{"tagCode":"zm_dj_tag",//二级标签"name":"光源",//二级标签名称"level3Items":[{"capability":1025,//能力值"icon":"https://images.tuyacn.com/smart/program_category_icon/wf_ble_dj.png",//图标"name":"光源",//品类名称"attribute":4,"category":"wf_ble_dj",//品类 code"activatorDes":"蓝牙+Wi-Fi"}]},{"tagCode":"zm_dd_tag","name":"灯带","level3Items":[{"capability":1025,"sale":"","icon":"https://images.tuyacn.com/smart/app_category/wf_ble_dd_1598683823026.png","name":"灯带","sort":0,"attribute":4,"category":"wf_ble_dd","activatorDes":"蓝牙+Wi-Fi"}]}],"t":1622688701083,"success":true,"status":"ok"
}

查询配网列表三级品类详情数据

接口说明

getDeviceLevelThirdDetailData(bizType,bizValue,callback)

请求参数

名称参数类型说明
bizTypeInt
  • 0:表示产品品类
  • 1:表示产品
bizValueString
  • 如果 bizType=0,则 bizValue=category
  • 如果 bizType=1,则 bizValue=pid

请求示例

TyActivatorExtraBusinessKit.INSTANCE.getDeviceLevelThirdDetailData(0,thirdBean.getCategory(),new Business.ResultListener() {@Overridepublic void onFailure(BusinessResponse businessResponse, CategoryLevelThirdBean categoryLevelThirdBean, String s) {}@Overridepublic void onSuccess(BusinessResponse businessResponse, CategoryLevelThirdBean categoryLevelThirdBean, String s) {}});

返回示例

{"result":{"display":{"ezAddBtText":"确认指示灯快闪","wifiIconUrl":"https://images.tuyacn.com/smart_res/Group_8@2x.png","ezHelpUrl":"https://images.tuyacn.com/smart/connect-scheme-v3/help/template/ez_default_default/common_network/ez_default_default_ez_zh.html","ezTipIconUrl":"https://images.tuyacn.com/smart/connect-scheme-v3/tip-icon/ty_common_fast%402x.gif","apTip":"接通电源, 确认指示灯在慢闪。注意:重置设备后,请在三分钟内完成配网操作","wifiTitle":"选择 2.4GHz Wi-Fi 网络并输入密码","apTipIconUrl":"https://images.tuyacn.com/smart/connect-scheme-v3/tip-icon/ty_common_slow%402x.gif","apAddBtText":"确认指示灯慢闪","wifiContent":"如果你的 Wi-Fi 是 5GHz 的,请先设置为 2.4GHz","ezTip":"接通电源, 确认指示灯在快闪。注意:重置设备后,请在三分钟内完成配网操作","apHelpUrl":"https://images.tuyacn.com/smart/connect-scheme-v3/help/template/ap_default_default/common_network/ap_default_default_ap_zh.html"},"linkModes":[//配网方式{"leadList":[//配网引导{"iconUrl":"https://images.tuyacn.com/smart_res/iot_os/step1ty.png","title":"将设备接通电源,10 秒后断电再接通电源"},{"iconUrl":"https://images.tuyacn.com/smart_res/iot_os/step2ty.png","title":"长按复位键 5 秒"},{"iconUrl":"https://images.tuyacn.com/smart_res/iot_os/step3tykuai.gif","title":"确认指示灯快闪"}],"linkMode":1,"desText":"默认","title":"Wi_Fi 快连"},{"leadList":[{"iconUrl":"https://images.tuyacn.com/smart_res/iot_os/step1ty.png","title":"将设备接通电源,10 秒后断电再接通电源"},{"iconUrl":"https://images.tuyacn.com/smart_res/iot_os/step2ty.png","title":"长按复位键 5 秒"},{"iconUrl":"https://images.tuyacn.com/smart_res/iot_os/step3tykuai.gif","title":"确认指示灯快闪后,再进行下一步骤"},{"iconUrl":"https://images.tuyacn.com/smart_res/iot_os/step4tyman.gif","title":"再次长按复位键 5 秒,直至指示灯慢闪"}],"linkMode":2,"title":"热点配网(兼容模式)"}],"enableLead":false},"t":1622689764143,"success":true,"status":"ok"
}

相关内容

热门资讯

监控摄像头接入GB28181平... 流程简介将监控摄像头的视频在网站和APP中直播,要解决的几个问题是:1&...
Windows10添加群晖磁盘... 在使用群晖NAS时,我们需要通过本地映射的方式把NAS映射成本地的一块磁盘使用。 通过...
protocol buffer... 目录 目录 什么是protocol buffer 1.protobuf 1.1安装  1.2使用...
在Word、WPS中插入AxM... 引言 我最近需要写一些文章,在排版时发现AxMath插入的公式竟然会导致行间距异常&#...
【PdgCntEditor】解... 一、问题背景 大部分的图书对应的PDF,目录中的页码并非PDF中直接索引的页码...
Fluent中创建监测点 1 概述某些仿真问题,需要创建监测点,用于获取空间定点的数据࿰...
educoder数据结构与算法...                                                   ...
MySQL下载和安装(Wind... 前言:刚换了一台电脑,里面所有东西都需要重新配置,习惯了所...
修复 爱普生 EPSON L4... L4151 L4153 L4156 L4158 L4163 L4165 L4166 L4168 L4...
MFC文件操作  MFC提供了一个文件操作的基类CFile,这个类提供了一个没有缓存的二进制格式的磁盘...