writeCommand method
void
writeCommand(
- List<int> commands
)
Implementation
void writeCommand(List<int> commands) {
Uint8 commandLength = Uint8(commands.length);
List<int> finalCommandsList = [];
Uint8 checksum = Uint8.zero();
// Adding all the necessary padding commands and add some of them to the
// checksum (I actually don't really know why some of same aren't taken
// into account when we calculate the checksum)
finalCommandsList.add(pn532Preamble);
checksum += Uint8(pn532Preamble);
finalCommandsList.add(pn532StartCode1);
checksum += Uint8(pn532StartCode1);
finalCommandsList.add(pn532StartCode2);
checksum += Uint8(pn532StartCode2);
finalCommandsList.add(commandLength.value);
finalCommandsList.add((~commandLength + Uint8(1)).value);
// adding the actual commands to the final list
//and calculate checksum with it
for (int command in commands) {
finalCommandsList.add(command);
checksum += Uint8(command);
}
finalCommandsList.add((~checksum).value);
finalCommandsList.add(pn532Postamble);
// sending the commands
pn532ProtocolImpl.writeData(finalCommandsList);
}