mirror of
https://github.com/i12bp8/TagTinker.git
synced 2026-07-02 20:31:38 +00:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user