完成HBY102
This commit is contained in:
@ -6,6 +6,11 @@ const serviceDic = [ //合作供应商的蓝牙主服务
|
||||
"writeId": "0000FFE1-0000-1000-8000-00805F9B34FB",
|
||||
"notifyId": "0000FFE2-0000-1000-8000-00805F9B34FB"
|
||||
},
|
||||
{
|
||||
"serviceId": "0000FFF0-0000-1000-8000-00805F9B34FB",
|
||||
"writeId": "0000FFF2-0000-1000-8000-00805F9B34FB",
|
||||
"notifyId": "0000FFF1-0000-1000-8000-00805F9B34FB"
|
||||
},
|
||||
{
|
||||
"serviceId": "0000AE30-0000-1000-8000-00805F9B34FB",
|
||||
"writeId": "0000AE03-0000-1000-8000-00805F9B34FB",
|
||||
@ -638,9 +643,9 @@ class BleHelper {
|
||||
let arr = [];
|
||||
for (var i = 0; i < res.devices.length; i++) {
|
||||
let item = res.devices[i];
|
||||
if(item.name){
|
||||
console.log("发现新设备",item.name+" "+item.RSSI);
|
||||
}
|
||||
// if(item.name){
|
||||
// console.log("发现新设备",item.name+" "+item.RSSI);
|
||||
// }
|
||||
|
||||
let f = serviceDic.find(v => {
|
||||
return item.advertisServiceUUIDs
|
||||
@ -648,7 +653,7 @@ class BleHelper {
|
||||
});
|
||||
if (f) {
|
||||
|
||||
console.log("发现目标设备:", item);
|
||||
// console.log("发现目标设备:", item);
|
||||
arr.push(item);
|
||||
}
|
||||
|
||||
@ -1203,7 +1208,7 @@ class BleHelper {
|
||||
deviceId: id,
|
||||
success: (res) => {
|
||||
if (res.services && res.services.length > 0) {
|
||||
// console.log("获取到服务:" + JSON.stringify(res));
|
||||
console.log("获取到服务:" + JSON.stringify(res));
|
||||
|
||||
this.data.LinkedList.find((v) => {
|
||||
if (v.deviceId == id) {
|
||||
@ -1228,7 +1233,7 @@ class BleHelper {
|
||||
});
|
||||
|
||||
if (se) {
|
||||
// console.log("合作供应商的", s)
|
||||
console.log("合作供应商的", s)
|
||||
this.data.LinkedList.find((v) => {
|
||||
if (v.deviceId == id) {
|
||||
v.writeServiceId = s.serviceId;
|
||||
@ -1246,7 +1251,9 @@ class BleHelper {
|
||||
// notifyCharId));
|
||||
|
||||
|
||||
} else {
|
||||
} else
|
||||
|
||||
{
|
||||
console.error("预设的蓝牙服务和特征中找不到");
|
||||
for (var i = 0; i < res.services.length; i++) {
|
||||
let service = res.services[i];
|
||||
@ -1266,6 +1273,7 @@ class BleHelper {
|
||||
|
||||
Promise.all(promises)
|
||||
.then(results => {
|
||||
console.log("results= ",results);
|
||||
if (!s) {
|
||||
//非指定供应商的设备,走订阅消息
|
||||
return this.subScribe(id, true);
|
||||
@ -1326,10 +1334,10 @@ class BleHelper {
|
||||
serviceId: serviceId,
|
||||
success: (res) => {
|
||||
|
||||
// console.log("获取到特征:" + JSON.stringify(res));
|
||||
// res.characteristics.forEach((v) => {
|
||||
// v.serviceId = serviceId;
|
||||
// });
|
||||
console.log("获取到特征:" + JSON.stringify(res));
|
||||
res.characteristics.forEach((v) => {
|
||||
v.serviceId = serviceId;
|
||||
});
|
||||
|
||||
//写特征
|
||||
let writeChar = res.characteristics.find(char => {
|
||||
|
||||
Reference in New Issue
Block a user