summaryrefslogtreecommitdiff
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-02-18 14:12:16 +0100
commit652595d813d8f9eb13794cb53b3462d9f667cdc3 (patch)
treed580d38ec906cc04e7d4d7b1f688ea0dd778a4a0
parentda3181f50f0cc21f50c6a95bac0d09bc5e755208 (diff)
Add scanning for ISO18092 tags.
-rw-r--r--main.cpp44
1 files changed, 38 insertions, 6 deletions
diff --git a/main.cpp b/main.cpp
index fbc3e23..8e267bf 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(2, 1, 0, 0xc0, 0,
interface_desc(1, 0, 1, 0xff, 0x00, 0x00, 0,
@@ -175,11 +180,10 @@ int main() {
bool cmd_sent = false;
uint32_t nfc_delay_until = 0;
uint8_t bulk_buf[8];
+ 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);
kp_cols.set_mode(Pin::Input);
kp_cols.set_pull(Pin::PullUp);
@@ -195,8 +199,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;
@@ -204,10 +221,19 @@ int main() {
if(buf[0] == 128 && buf[14] == 0) {
led.on();
- uint8_t* id_raw = &buf[11];
uint8_t* id_buf = bulk_buf;
- for(uint32_t i = 0; i < 8; i++) {
- *id_buf++ = *id_raw--;
+
+ if(active_type == ISO15693) {
+ uint8_t* id_raw = &buf[11];
+ for(uint32_t i = 0; i < 8; i++) {
+ *id_buf++ = *id_raw--;
+ }
+
+ } else if(active_type == ISO18092) {
+ uint8_t* id_raw = &buf[3];
+ for(uint32_t i = 0; i < 8; i++) {
+ *id_buf++ = *id_raw++;
+ }
}
if(usb.ep_ready(1)) {
@@ -217,6 +243,12 @@ int main() {
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;
+ }
}
}