mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 17:45:22 +00:00
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:
@@ -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 (
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user