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});