updateConnection method
void
updateConnection(
- String deviceId,
- bool isConnected, [
- String? error,
- BleShieldNativeErrorCode? errorCode,
- int? nativeErrorCode,
Implementation
void updateConnection(
String deviceId,
bool isConnected, [
String? error,
BleShieldNativeErrorCode? errorCode,
int? nativeErrorCode,
]) {
deviceId = _deviceId(deviceId).canonical;
final update = BleConnectionChange(
deviceId: deviceId,
isConnected: isConnected,
error: error,
errorCode: errorCode,
nativeErrorCode: nativeErrorCode,
);
bleConnectionChangeStreamController.add(update);
try {
onConnectionChange?.call(update);
} catch (_) {}
if (!isConnected) {
// Clear per-device state (all keyed by the canonical id).
CacheHandler.instance.resetDeviceCache(deviceId);
// Connection parameters belong to this connection, so drop them. Pairing/bond state deliberately
// outlives the connection (a bonded device stays bonded across reconnects) and is left in
// _lastPairStateMap.
_lastConnectionParametersMap.remove(deviceId);
}
}