|
|
|
|
|
|
|
|
wx.getBLEDeviceServices({ |
|
|
wx.getBLEDeviceServices({ |
|
|
deviceId, |
|
|
deviceId, |
|
|
success: (res) => { |
|
|
success: (res) => { |
|
|
|
|
|
console.log(res) |
|
|
for (let i = 0; i < res.services.length; i++) { |
|
|
for (let i = 0; i < res.services.length; i++) { |
|
|
if (res.services[i].isPrimary) { |
|
|
|
|
|
|
|
|
if (res.services[i].isPrimary && res.services[i].uuid.indexOf("FFE0")>-1) { |
|
|
this.getBLEDeviceCharacteristics(deviceId, res.services[i].uuid) |
|
|
this.getBLEDeviceCharacteristics(deviceId, res.services[i].uuid) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wx.onBLECharacteristicValueChange((characteristic) => { |
|
|
wx.onBLECharacteristicValueChange((characteristic) => { |
|
|
// 解析特征值,返回解密后的数据 |
|
|
// 解析特征值,返回解密后的数据 |
|
|
|
|
|
console.log("===" + plugin.ab2hex(characteristic.value)) |
|
|
let bleData = plugin.parseBleData(characteristic.value) |
|
|
let bleData = plugin.parseBleData(characteristic.value) |
|
|
if (bleData.status == 0) { |
|
|
if (bleData.status == 0) { |
|
|
console.log("握手成功") |
|
|
console.log("握手成功") |