BLEPeripheralServer.startAdvertising
广播同样的信息,但是在不同手机看到的收包不一致。
代码如下:
async startAdvertising() {
await this.getBattery();
// 屏幕常亮下,小程序的广播持续时间:3分钟
// [18:09:20.076 ~ 18:12:19.483]
const u8a = new Uint8Array([0x04, 0x00, 0x01,0x00,0xa0]);
console.log('发数据是', this.data.mac);
const mac1 = '0x' + this.data.mac.slice(8,10);
const mac2 = '0x' + this.data.mac.slice(10,12);
const data3 = (this.data.alarm << 7) + 0;
const data4 = (this.data.battery << 4) + (this.data.mode << 2) + this.data.powerLevel;
const ints = new Uint8Array([
0x04,
mac1,
mac2,
data3,
data4
]);
const crc = crc16(ints);
const aaa = new Uint8Array([
0x04,
mac1,
mac2,
data3,
data4,
crc >> 8,
crc & 0xff,
0x2f, 0x61,0xAC,0xCC,0x27,0x45,0x67,0xF7,0xDB,0x34,
0xC4,0x03,0x8E,0x5C,0x0B,0xAA,0x97,0x30,0x56,0xE6]);
let m_id = "0x000d";
let powerLevel = 'high';
if (this.data.powerLevel === 1) {
powerLevel = 'low';
} else if (this.data.powerLevel === 2) {
powerLevel = 'medium';
} else if (this.data.powerLevel === 3) {
powerLevel = 'high';
}
this.data.server.startAdvertising({
advertiseRequest: {
connectable: false,
deviceName: '',
manufacturerData: [{
manufacturerId: m_id,
manufacturerSpecificData: aaa.buffer
}]
},
powerLevel: powerLevel
})
},
荣耀V9 PLAY收包:
红米K30PRO:
会发现,荣耀那个收包多了一个flags,并且把0xff中的字段截取掉了一部分。请问是什么原因导致的?是因为不同手机的蓝牙不一致么?
请问这个看数据的APP是什么
你好,麻烦再重现一次,在手机微信那里上传下日志: 我->设置->帮助与反馈右上角有个上报日志的入口,提供一下微信号,复现问题的详细时间点(如:2020-4-10 10:10)