expo-ble模块测试demo 联调BLE模块 take 8 新增空数据包测试

This commit is contained in:
Yudi Xiao
2025-12-11 13:48:45 +08:00
parent b612335d95
commit 675036f07c
6 changed files with 62 additions and 22 deletions

View File

@@ -95,9 +95,11 @@ export class BleClient {
autoConnect: false,
requestMTU: BLE_UUIDS.REQUEST_MTU
});
if (device.mtu !== BLE_UUIDS.REQUEST_MTU) {
if (device.mtu < BLE_UUIDS.REQUEST_MTU) {
console.log("MTU not supported, requesting default to ", BLE_UUIDS.REQUEST_MTU);
device = await device.requestMTU(BLE_UUIDS.REQUEST_MTU)
device = await device.requestMTU(BLE_UUIDS.REQUEST_MTU);
// Give some time for the stack to stabilize after MTU change
await new Promise(resolve => setTimeout(resolve, 500));
}
console.log("Connected to device with MTU = ", device.mtu);
this.connectedDevice = await device.discoverAllServicesAndCharacteristics();