forked from yudi_xiao/expo-ble-app-demo
expo-ble模块测试demo 联调BLE模块 take 7 尝试二次设置MTU=512
This commit is contained in:
parent
9100a20a2d
commit
b612335d95
|
|
@ -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});
|
||||
|
|
|
|||
Loading…
Reference in New Issue