ble: add 1 second delay after connecting

This might help with some people that have connection issues where the
OS is still busy enumerating the device when we are trying to read
characteristics.
This commit is contained in:
David Lechner
2022-07-15 18:05:48 -05:00
parent 662a1ae097
commit a86967573c
2 changed files with 22 additions and 1 deletions
+7
View File
@@ -10,6 +10,7 @@ import { Task, buffers, eventChannel } from 'redux-saga';
import {
call,
cancel,
delay,
fork,
put,
select,
@@ -164,6 +165,12 @@ function* handleBleConnectPybricks(): Generator {
defer.push(() => server.disconnect());
// istanbul ignore if
if (process.env.NODE_ENV !== 'test') {
// give OS Bluetooth stack some time to settle
yield* delay(1000);
}
const deviceInfoService = yield* call(() =>
server.getPrimaryService(deviceInformationServiceUUID).catch((err) => {
if (
+15 -1
View File
@@ -4,7 +4,15 @@
// Handles Bluetooth Low Energy connection to LEGO Wireless Protocol v3 Bootloader service.
import { END, eventChannel } from 'redux-saga';
import { call, cancel, put, spawn, takeEvery, takeMaybe } from 'typed-redux-saga/macro';
import {
call,
cancel,
delay,
put,
spawn,
takeEvery,
takeMaybe,
} from 'typed-redux-saga/macro';
import { alertsShowAlert } from '../alerts/actions';
import { ensureError } from '../utils';
import {
@@ -99,6 +107,12 @@ function* handleConnect(): Generator {
return;
}
// istanbul ignore if
if (process.env.NODE_ENV !== 'test') {
// give OS Bluetooth stack some time to settle
yield* delay(1000);
}
let service: BluetoothRemoteGATTService;
try {
service = yield* call([server, 'getPrimaryService'], lwp3BootloaderServiceUUID);