MIUI10.2.35稳定版小米9手机,微信最新版,调用BLEPeripheralServer.addService创建服务成功,并且发广播成功,用BLE调试工具,无法发现创建的服务SERVICEID,只有系统服务,为什么?
let characteristics = [
{
properties: {
read: true,
write: true,
notify: true,
},
permission: {
readable: true,
writeable: true
},,
uuid: CHARACTERISTIC_UUID,
},
];
characteristics.forEach((characteristic) => {
if (that.data.phone === 'ios') {
characteristic.value = new Uint8Array([0x00, 0x00]).buffer;
} else if (that.data.phone === 'android') {
characteristic.descriptors = [{
uuid: DESCRIPTORS_UUID,
permission: {
read: true,
write: true
},
}];
}
});
// 添加服务
that.data.server?.addService({
service: {
uuid: SERVICEID,
characteristics: characteristics,
},
success: () => {
console.log('服务特征值创建成功');
//发送广播
that.data.server?.startAdvertising({
advertiseRequest: {
deviceName:"test",
serviceUuids: [SERVICEID]
},
powerLevel: 'high',
success: (res) => { console.log('开始广播啦!!!')},
fail: (err) => {console.error('广播失败啦', err)}
})
},
fail: (err) => {}
});