n == 200) {
this.connectedDevice.state = false;
this.connectedDevice.deviceId = '';
this.adapterHasInit = false
}
this.startConnect();
}
说明:
1、 serviceId_2~6 是我已知的想要连接的蓝牙设备的serviceId可以只写一个。
2、characterId_write 是我已知的想要连接的蓝牙设备写入数据的特征值。
3、characterId_read是我已知的想要连接的蓝牙设备读取数据的特征值。
(以上3个都是为了做比对,真实的操作按照获取到的sericeid, characterid为准)。
4、connectedDevice 是已连接了的设备信息对象。
init完成后开始调用连接 startConnect();
startConnect代码:
startConnect: function () {
var that = this;
if (that.connectedDevice.state) return;
that.connectedDevice.deviceId = "";
that.connectedDevice.state = false;
// 如果适配器已经初始化不在调用初始化(重复初始化会报错)
if (this.adapterHasInit == undefined 关键词:微信小程序中蓝牙的链接