readRemoteRSSI method

Future<int> readRemoteRSSI()

Implementation

Future<int> readRemoteRSSI() async {
  final rssiGetResult = await FlutterBlue.instance._channel
      .invokeMethod('readRemoteRSSI', id.toString());
  if (!rssiGetResult) {
    throw Error();
  }

  return FlutterBlue.instance._methodStream
      .where((m) => m.method == 'onReadRemoteRssi')
      .map((m) => m.arguments)
      .map((buffer) => protos.RSSIResponse.fromBuffer(buffer))
      .where((p) => p.remoteId == id.toString())
      .map((p) => p.rssi)
      .first;
}