simulateConnectionStateUpdate method

void simulateConnectionStateUpdate(
  1. String deviceAddress,
  2. BleConnectionState state
)

Simulates a connection state update by emitting a new value on the connection stream.

This method can be used in tests to simulate real-time changes in connection state after a device has been connected or disconnected.

Example usage:

fakeCentral.simulateConnectionStateUpdate('00:11:22:33:44:55', BleConnectionState.disconnected);

Implementation

void simulateConnectionStateUpdate(String deviceAddress, BleConnectionState state) {
  _connectionStates[deviceAddress] = state;
  _connectionControllers[deviceAddress]?.add(state);
}