- oppo系列机型:小程序蓝牙与nrf Connect建立连接后未知断开,如何解决?
oppo系列测了几款机型都有类似问题,如OPPO Find X3,OPPO reno6等机型 以下数据采自OPPO Find X3( 系统版本Andriod14,微信版本8.0.56,基础库版本3.7.8) 小程序蓝牙与nRf Connect软件建立连接后,并发送键值成功,几s后小程序进入wx.onBLEPeripheralConnectionStateChanged 方法监听到断开,nRf Connect软件报错,小程序log如图所示: [图片] nRF Connect报错如图所示: [图片]
02-21 - 华为手机小程序做外围设备创建服务,连接ble调试软件成功,多次连接断开后,为什么报添加服务失败?
华为P50 -鸿蒙4.2.0系统,微信是最新版本,初始化蓝牙适配器,创建服务成功,发广播成功,多次连接断开后,调用BLEPeripheralServer.addService进入err报错,如图所示:[图片] 代码如下: 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) => { console.log('服务特征值创建失败');} });
2024-12-23 - 小米手机小程序做外围设备,发广播成功,但是无法发现创建的服务,为什么?
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) => {} });
2024-12-11