mirror of git://git.jvnv.net/cardio
Add scanning for ISO18092 tags.
This commit is contained in:
parent
7c379452d3
commit
6f792ca13b
48
main.cpp
48
main.cpp
|
@ -8,6 +8,11 @@
|
|||
#include <usb/usb.h>
|
||||
#include <usb/descriptor.h>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue