From 6f792ca13b2cc261daea81e5a914afe6b523bd1f Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sat, 13 Jan 2018 12:00:18 +0100 Subject: Add scanning for ISO18092 tags. --- main.cpp | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/main.cpp b/main.cpp index 73b4d2c..73d0109 100644 --- a/main.cpp +++ b/main.cpp @@ -8,6 +8,11 @@ #include #include +enum tag_type_t { + ISO15693, + ISO18092, +}; + auto dev_desc = device_desc(0x200, 0, 0, 0, 64, 0x1d50, 0x60f8, 0, 0, 0, 0, 1); auto conf_desc = configuration_desc(1, 1, 0, 0xc0, 0, // MSC BBB @@ -510,11 +515,10 @@ int main() { uint8_t buf[64]; bool cmd_sent = false; uint32_t nfc_delay_until = 0; + tag_type_t active_type = ISO15693; Time::sleep(1000); - cr95hf.send_cmd(0x02, 2, (uint8_t*)"\x01\x05"); // Select ISO 15693 - cr95hf.get_response(64, buf); while(1) { if(Time::time() < nfc_delay_until) { @@ -522,8 +526,21 @@ int main() { } else if(!cmd_sent) { led.off(); - cr95hf.send_cmd(0x04, 3, (uint8_t*)"\x26\x01\x00"); // INVENTORY + if(active_type == ISO15693) { + cr95hf.send_cmd(0x02, 2, (uint8_t*)"\x01\x05"); // Select ISO 15693 + cr95hf.get_response(64, buf); + + cr95hf.send_cmd(0x04, 3, (uint8_t*)"\x26\x01\x00"); // INVENTORY + + } else if(active_type == ISO18092) { + cr95hf.send_cmd(0x02, 2, (uint8_t*)"\x04\x51"); // Select ISO 18092 + cr95hf.get_response(64, buf); + + cr95hf.send_cmd(0x04, 5, (uint8_t*)"\x00\xff\xff\x00\x00"); // REQC + } + cmd_sent = true; + } else if(!nfc_irq_out.get()) { cr95hf.get_response(64, buf); cmd_sent = false; @@ -532,18 +549,35 @@ int main() { led.on(); USB.reg.BCDR &= ~(1 << 15); - uint8_t* id_raw = &buf[11]; uint8_t* id_ascii = sectors[4]; - for(uint32_t i = 0; i < 8; i++) { - *id_ascii++ = "0123456789ABCDEF"[*id_raw >> 4]; - *id_ascii++ = "0123456789ABCDEF"[*id_raw-- & 0xf]; + + if(active_type == ISO15693) { + uint8_t* id_raw = &buf[11]; + for(uint32_t i = 0; i < 8; i++) { + *id_ascii++ = "0123456789ABCDEF"[*id_raw >> 4]; + *id_ascii++ = "0123456789ABCDEF"[*id_raw-- & 0xf]; + } + + } else if(active_type == ISO18092) { + uint8_t* id_raw = &buf[3]; + for(uint32_t i = 0; i < 8; i++) { + *id_ascii++ = "0123456789ABCDEF"[*id_raw >> 4]; + *id_ascii++ = "0123456789ABCDEF"[*id_raw++ & 0xf]; + } } + Time::sleep(10); USB.reg.BCDR |= 1 << 15; nfc_delay_until = Time::time() + 5000; // Valid for five seconds. } else { nfc_delay_until = Time::time() + 100; // Retry in 100ms. + + if(active_type == ISO15693) { + active_type = ISO18092; + } else { + active_type = ISO15693; + } } } -- cgit v1.2.3