Skip to content

Commit 3e512fb

Browse files
author
dingo35
committed
OneWire.cpp: if UID bytes 5 and later are zero, assume 4 byte UID
1 parent b235c16 commit 3e512fb

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

SmartEVSE-3/src/OneWire.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,18 @@ void CheckRFID(void) {
258258
if (OcppMode && RFIDReader == 6) { // Remote authorization via OCPP?
259259
// Use OCPP
260260
if (!RFIDstatus) {
261-
if (RFID[0] == 0x01) {
262-
ocppUpdateRfidReading(RFID + 1, 6); // UID starts at RFID+1; Pad / truncate UID to 6-bytes for now
263-
} else {
264-
ocppUpdateRfidReading(RFID, 7); // UID starts at RFID; 7 byte UID
261+
if (RFID[0] == 0x01) { // old 6 byte reader
262+
if (RFID[5] == 0 && RFID[6] == 0) { // so we have 4 byte UID
263+
ocppUpdateRfidReading(RFID + 1, 4); // UID starts at RFID+1; Pad / truncate UID to 4 bytes
264+
} else { // 7 byte UID
265+
ocppUpdateRfidReading(RFID + 1, 6); // UID starts at RFID+1; Pad / truncate UID to 6 bytes for now since 7th byte is missing
266+
}
267+
} else { // new 7 byte reader
268+
if (RFID[4] == 0 && RFID[5] == 0 && RFID[6] == 0) { // so we have 4 byte UID
269+
ocppUpdateRfidReading(RFID, 4); // UID starts at RFID; 4 byte UID
270+
} else { // 7 byte UID
271+
ocppUpdateRfidReading(RFID, 7); // UID starts at RFID; 7 byte UID
272+
}
265273
}
266274
}
267275
RFIDstatus = 1;

0 commit comments

Comments
 (0)