getControllerData method

Future<RGBController> getControllerData(
  1. int deviceId
)

Get controller data of one device with given deviceId.

Implementation

Future<RGBController> getControllerData(int deviceId) async {
  if (_controllerCount == 0) {
    await getControllerCount();
  }
  if (deviceId >= _controllerCount) {
    throw Exception('Device index out of range!');
  }
  await _send(
    CommandId.requestControllerData,
    Uint8List.fromList([3, 0, 0, 0]),
    deviceId: deviceId,
  );

  final payload = await _rx.next;
  return RGBController.fromData(payload.restOfPkt);
}