pack method

  1. @override
Uint8List pack()
override

pack() should produce a message data payload that can be parsed by a corresponding parser in the frameside application (Lua) The 0x01 (raw user data marker) byte and the msgCode byte are prepended to each bluetooth write() call by the Frame BLE sendDataRaw() method, followed by the maximum amount of payload data that will fit until the whole message is sent.

Implementation

@override
Uint8List pack() {
  // manual shutter has a range 4..16384 so just map it to a Uint16 over 2 bytes
  int intManShutterMsb = (_manualShutter >> 8) & 0xFF;
  int intManShutterLsb = _manualShutter & 0xFF;

  // manual color gains have a range 0..1023 so just map them to a Uint16 over 2 bytes
  int intManRedGainMsb = (_manualRedGain >> 8) & 0x03;
  int intManRedGainLsb = _manualRedGain & 0xFF;
  int intManGreenGainMsb = (_manualGreenGain >> 8) & 0x03;
  int intManGreenGainLsb = _manualGreenGain & 0xFF;
  int intManBlueGainMsb = (_manualBlueGain >> 8) & 0x03;
  int intManBlueGainLsb = _manualBlueGain & 0xFF;

  // 9 bytes of manual exposure settings. sendMessage will prepend the data byte & msgCode to each packet
  // and the Uint16 payload length to the first packet
  return Uint8List.fromList([
    intManShutterMsb,
    intManShutterLsb,
    _manualAnalogGain & 0xFF,
    intManRedGainMsb,
    intManRedGainLsb,
    intManGreenGainMsb,
    intManGreenGainLsb,
    intManBlueGainMsb,
    intManBlueGainLsb,
  ]);
}