Fix barcode checksum to include prefix letter

Pricer barcodes validate with (sum of all 17 chars) mod 10 == 0,
with the letter prefix contributing by its ASCII offset from '0'.
The old formula compared sum of the first 16 digits to the 17th,
rejecting valid codes like A4120365539013704.
This commit is contained in:
I12BP8
2026-04-24 12:02:35 -04:00
parent 934bc2e309
commit 955cb86fc1
+2 -2
View File
@@ -286,8 +286,8 @@ void tagtinker_free_image_payload(TagTinkerImagePayload* payload) {
bool tagtinker_is_barcode_valid(const char* barcode) {
if(!barcode || strlen(barcode) != 17) return false;
int cs = 0; for(int i = 0; i < 16; i++) cs += (int)(barcode[i] - '0');
return ((cs % 10) == (barcode[16] - '0'));
int cs = 0; for(int i = 0; i < 17; i++) cs += (int)(barcode[i] - '0');
return (cs % 10) == 0;
}
size_t tagtinker_make_addressed_frame(uint8_t* buf, const uint8_t plid[4], const uint8_t* payload, size_t len) {