I want to create an app sending commands to a colormeter via bluetooth. The colormeter simply wants two Byte as its command, one being the real command and one being its checksum, which is just the next higher hex number, the documentation I have gives me Hex codes (e.g. 0x21
, 0x22
), but the function from the flutter_bluetooth_serial
package (that I have to use because the device uses bluetooth serial port protocol) wants a Uint8List.
How can I convert two two-digit hex codes into a Uint8List?
This should do the job:
import 'dart:typed_data';
void main() {
int i1 = 0x21;
int i2 = 0x22;
Uint8List bytes = Uint8List.fromList([i1, i2]);
print(bytes);
}