getControllerData method

RGBController getControllerData(
  1. int deviceId
)

Get controller data of one device with given deviceId.

Implementation

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

  final payload = readPkt();
  return RGBController.fromData(payload.restOfPkt);
}