智能生活设备配网 UI 业务包的功能涵盖了目前常见的 Wi-Fi 设备、Zigbee 设备、蓝牙设备,并且支持二维码扫码的设备,例如 GPRS 和 NB-IoT 设备。业务包主要实现不同类型的设备配网前置操作引导,和具体入网激活。
支持 Wi-Fi 智能设备入网连接云服务,Wi-Fi 设备配网主要有快连模式和热点模式两种,其中智能摄像机(IPC)设备支持扫二维码方式配网。
名词 | 说明 |
---|---|
Wi-Fi 快连配网 | 又称快连模式。大致流程如下:
|
Wi-Fi 热点配网 | 又称热点模式,手机作为 STA(STAtion)连接智能设备的热点,双方建立一个 Socket 连接,通过约定端口交互数据。 |
IPC 扫码配网 | IPC 设备通过扫描 App 上的二维码,来获取配网数据信息。 |
支持 Zigbee 网关和子设备配网:
名词 | 说明 |
---|---|
Zigbee 网关 | 融合 Zigbee 网络中协调器和 Wi-Fi 功能的设备,负责 Zigbee 网络的组建及数据信息存储。 |
Zigbee 子设备 | Zigbee 网络中的路由或者终端设备,负责数据转发或者终端控制响应。 |
涂鸦蓝牙有以下几种技术方案:
名词 | 说明 |
---|---|
蓝牙单点 | 蓝牙设备与手机一对一连接的单点设备(蓝牙或蓝牙 LE)。 |
蓝牙 Mesh | 蓝牙技术联盟发布的蓝牙拓扑通信。 |
涂鸦 Mesh | 涂鸦自研的蓝牙拓扑通信,使用场景与蓝牙 Mesh 产品相同。 |
双模设备 | 一些多协议设备也会使用到蓝牙技术,例如同时具备 Wi-Fi 能力和蓝牙能力的 双模设备。 |
扫码配网设备上电后即连接了涂鸦的云服务,App 通过扫描设备上的二维码让设备在云端激活绑定。这个二维码必须是涂鸦支持的二维码规则,具体接入方式可找我咨询。
名词 | 说明 |
---|---|
GPRS 设备 | 采用 GPRS 通信技术接入网络连接云服务的智能设备。 |
NB-IoT 设备 | 采用窄带物联网(NarrowBand-Internet of Things)技术的智能设备。 |
融合涂鸦智能通用配网技术实现,为用户提供一套快捷配网的功能。
创建工程。
在 Android Studio 中建立的工程,接入涂鸦智能生活 SDK 并完成 业务包框架接入。
配置业务的 build.gradle。
dependencies {
api 'com.tuya.smart:tuyasmart-bizbundle-device_activator:4.2.0-22'
}
混淆配置。
#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 |
是否支持蓝牙 |
| 是否支持蓝牙设备配网功能 | true |
是否支持蓝牙 Mesh |
| 是否支持蓝牙 Mesh 设备配网功能 | true |
是否支持扫一扫 |
| 是否支持列表页面右上角扫描配网功能 | true |
自发现是否支持 Wi-Fi 快连配网 |
| 是否支持自发现页面配网 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 | 未执行配网,主动退出配网业务,根据实际业务需要选择实现 |
安卓版通用配网业务包提供配网列表数据查询能力,提供了查询数据列表自定义展示的方法。大家可以结合涂鸦 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)
请求参数
名称 | 参数类型 | 说明 |
---|---|---|
levelCode | String | 一级类目的 levelCode |
type | Int | 一级类目的 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)
请求参数
名称 | 参数类型 | 说明 |
---|---|---|
bizType | Int |
|
bizValue | String |
|
请求示例
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"
}
下一篇:当ChatGPT遇到前端开发