summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2018-01-13 12:00:18 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2018-01-13 12:00:18 +0100
commit6f792ca13b2cc261daea81e5a914afe6b523bd1f (patch)
tree271f0a514a9ccdf59336eac1b9e514aaf7de9fd0 /main.cpp
parent7c379452d368bafbbe1fe3cea621295424ced1e1 (diff)
Add scanning for ISO18092 tags.HEADmaster
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp48
1 files 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 <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;
+ }
}
}