parseResponse method
Parse the response bytes from the device.
Implementation
@override
VtjCommandResult<bool> parseResponse(Uint8List response) {
if (response.length < 2) {
return const VtjCommandResult.failure('Invalid response length', null);
}
if (response[0] != commandId) {
return const VtjCommandResult.failure('Invalid command ID in response', null);
}
final status = response[1];
if (status == 0x00) {
return const VtjCommandResult.success(true);
}
if (status == 0x02) {
return const VtjCommandResult.failure('Invalid arguments', 2);
}
if (status == 0x04) {
return const VtjCommandResult.failure('Access denied', 4);
}
return VtjCommandResult.failure(
'Authentication failed with status: 0x${status.toRadixString(16).padLeft(2, '0')}',
status,
);
}