[iot-阿里SDS对接]--bonKit

LC(BoneKit)—序列图

Bonkit 界面开发

Bonkit 基于React Native,基本组件通用,阿里提供了一部分组件,可以提高开发效率。

阿里组件文档

基础组件

! 注意 react-native-actionsheet boneKit提供 需要修改

1
2
3
4
5
6
7
8
9
10
标题隐藏 功能
<!-- 修改 var title = config.title || "标题"; -->
var title = config.title || "";
...
<!-- 参数一致性修改 -->
set title(title){
setTimeout(()=>{
this.cls.setState({title})
});
}

Bonkit 界面刷新

1
2
3
boneView(viewName, context)
boneRender(viewName, state)
boneRenderAll(state)

Bonkit 数据发送

客户端通用API

产品相关 – (查询厂商的产品列表)[](查询产品信息)(查询标准属性)

设备相关 – (注册设备)(绑定设备)(获取设备最新状态)(设置设备属性)(获取设备详情)(上报设备数据)(更新设备昵称)(保存设备私有数据)(提取设备私有数据)(请求设备服务)(查询子设备列表)(设备数据清理)

用户相关 – (获取系统时间)(生成二维码内容)(扫描二维码)(解绑设备)(管理员解绑其他用户)(获取用户设备列表)(保存用户私有数据)(获取用户私有数据)(通过三方账号ID和类型获取云账号ID)

! 注意
设备注册请求接口 – mtop.openalink.app.core.device.requestremoteservice

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!-- 产品入网配置 -->
- this.ali_api_fuc('mtop.openalink.app.core.device.requestremoteservice',
{ uuid:Bone.query.uuid,
args:JSON.stringify({enable:"1",duration:"120",shortModel:"00501f4b"}),
service:"PermitJoin"},
(res,error) => {console.log(res)});
<!-- 获取服务器端产品列表 -->
- this.ali_api_fuc('mtop.openalink.app.product.list',
{},
(res,error) => {console.log(res)});
<!-- 获取产品详情 -->
- this.ali_api_fuc('mtop.openalink.app.core.device.getdetail',
{uuid: Bone.query.uuid},
(res,error) => {this.refresh(res,error)});
<!-- 产品解绑 -->
- this.ali_api_fuc('mtop.openalink.app.core.user.unbinddevice',
{uuid: Bone.query.uuid},
(res,error) => {console.log(res)});
<!-- 产品绑定 -->
- this.ali_api_fuc('mtop.openalink.app.core.user.binddevice',
{uuid: Bone.query.uuid},
(res,error) => {});
/**
* 阿里通用请求接口
* @param {function} callback 回调
*/
ali_api_fuc(ali_api,params,callback){
Bone.request(ali_api, params)
.response((next, reject, res)=>{
//resHandler
console.log(res);
if (callback){
callback(res,null)
}
}).catch((error) => {
console.log(error);
if (callback){
callback(res,null)
}
});
}

Bonkit 数据接收

数据接收
在一个容器内默认不会收到任何的设备数据,你需要手动管理哪些设备需要往容器中发送设备数据。 在容器内将维护一个需要监听的 UUID 队列,该队列一开始是空的,只有在队列中的 UUID 且将监听总开关打开的情况下,才会收到设备数据

⚠️ 注意
TRD: TRD 产品属性表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

this.device = new this.ctx.service.device("DAB7900A7DDB66363A5A0F18541DD4C3", TRD);
this.device.applyStatusMiddleware(this.deviceStatusChange);
Bone.watch.addUUID(["DAB7900A7DDB66363A5A0F18541DD4C3"]);

deviceStatusChange = app => next => (error, state) => {
// 打印 CurrentTemp 的值
console.log("state",state);
// 用特征对象打印 CurrentTemp 的值
console.log("this.device.co",this.device.co);
// 打印 Switch 的所有可用标签
// 打印 Switch 的所有可用标签
// 打包该消息与上一次数据发生了变化的 key
console.log("state.keyChange",state.keyChange);
return next(error, state);
}