mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
Prevent disconnection handling when already disconnected, curing a race condition.
This commit is contained in:
parent
90ce46392a
commit
d30e7c4e2c
1 changed files with 2 additions and 7 deletions
|
|
@ -706,7 +706,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||
|
||||
try {
|
||||
_connectionSubscription = device.connectionState.listen((state) {
|
||||
if (state == BluetoothConnectionState.disconnected) {
|
||||
if (state == BluetoothConnectionState.disconnected && isConnected) {
|
||||
_handleDisconnection();
|
||||
}
|
||||
});
|
||||
|
|
@ -959,12 +959,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||
if (!isConnected) return;
|
||||
if (_batteryRequested && !force) return;
|
||||
_batteryRequested = true;
|
||||
try {
|
||||
await sendFrame(buildGetBattAndStorageFrame());
|
||||
} catch (e) {
|
||||
// Connection likely lost - trigger disconnection handling
|
||||
_handleDisconnection();
|
||||
}
|
||||
await sendFrame(buildGetBattAndStorageFrame());
|
||||
}
|
||||
|
||||
void _startBatteryPolling() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue