From b612335d95be533282be3347f9bdbd384bee9549 Mon Sep 17 00:00:00 2001 From: Yudi Xiao <463708580@qq.com> Date: Thu, 11 Dec 2025 12:45:27 +0800 Subject: [PATCH] =?UTF-8?q?expo-ble=E6=A8=A1=E5=9D=97=E6=B5=8B=E8=AF=95dem?= =?UTF-8?q?o=20=E8=81=94=E8=B0=83BLE=E6=A8=A1=E5=9D=97=20take=207=20?= =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BA=8C=E6=AC=A1=E8=AE=BE=E7=BD=AEMTU=3D512?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ble/core/BleClient.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ble/core/BleClient.ts b/ble/core/BleClient.ts index f72a540..d3e992c 100644 --- a/ble/core/BleClient.ts +++ b/ble/core/BleClient.ts @@ -91,7 +91,14 @@ export class BleClient { if (!this.manager) throw new Error('BLE not supported on web'); try { this.emit('connectionStateChange', {deviceId, state: ConnectionState.CONNECTING}); - const device = await this.manager.connectToDevice(deviceId, {requestMTU: BLE_UUIDS.REQUEST_MTU}); + let device = await this.manager.connectToDevice(deviceId, { + autoConnect: false, + requestMTU: 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) + } console.log("Connected to device with MTU = ", device.mtu); this.connectedDevice = await device.discoverAllServicesAndCharacteristics(); this.emit('connectionStateChange', {deviceId, state: ConnectionState.CONNECTED});