Add RFID_OPT_14443A_WUPA to request WUPA instead of REQA (Rainer Keller <mail@rainerk...
[librfid] / src / rfid_reader_openpcd.c
index 15486b6..f439c04 100644 (file)
@@ -32,7 +32,6 @@
 #include <string.h>
 #include <errno.h>
 
-#include <usb.h>
 
 #include <librfid/rfid.h>
 #include <librfid/rfid_reader.h>
@@ -57,6 +56,7 @@ static struct openpcd_hdr *rcv_hdr;
 
 #ifndef LIBRFID_FIRMWARE
 
+#include <usb.h>
 static struct usb_device *dev;
 static struct usb_dev_handle *hdl;
 
@@ -95,7 +95,7 @@ static int openpcd_xcv(u_int8_t cmd, u_int8_t reg, u_int8_t val,
        ret = openpcd_send_command(cmd, reg, val, len, data);
        if (ret < 0)
                return ret;
-       if (ret < sizeof(sizeof(struct openpcd_hdr)))
+       if (ret < sizeof(struct openpcd_hdr))
                return -EINVAL;
 
        return openpcd_recv_reply();
@@ -226,12 +226,14 @@ const struct rfid_asic_transport openpcd_rat = {
 static int openpcd_reg_write(struct rfid_asic_transport_handle *rath,
                             unsigned char reg, unsigned char value)
 {
+       return opcd_rc632_reg_write(rath, reg, value);
 }
 
 static int openpcd_reg_read(struct rfid_asic_transport_handle *rath,
                            unsigned char reg,
                            unsigned char *value)
 {
+       return opcd_rc632_reg_read(rath, reg, value);
 }
 
 
@@ -239,6 +241,7 @@ static int openpcd_fifo_read(struct rfid_asic_transport_handle *rath,
                             unsigned char num_bytes,
                             unsigned char *buf)
 {
+       return opcd_rc632_fifo_read(rath, num_bytes, buf);
 }
 
 static int openpcd_fifo_write(struct rfid_asic_transport_handle *rath,
@@ -246,6 +249,7 @@ static int openpcd_fifo_write(struct rfid_asic_transport_handle *rath,
                             const unsigned char *bytes,
                             unsigned char flags)
 {
+       return opcd_rc632_fifo_write(rath, len, bytes, flags);
 }
 
 const struct rfid_asic_transport openpcd_rat = {
@@ -365,6 +369,7 @@ openpcd_open(void *data)
        snd_hdr = (struct openpcd_hdr *)snd_buf;
        rcv_hdr = (struct openpcd_hdr *)rcv_buf;
 
+#ifndef LIBRFID_FIRMWARE
        usb_init();
        if (usb_find_busses() < 0)
                return NULL;
@@ -388,6 +393,7 @@ openpcd_open(void *data)
                usb_close(hdl);
                return NULL;
        }
+#endif
 
        rh = malloc_reader_handle(sizeof(*rh));
        if (!rh)
@@ -426,7 +432,9 @@ openpcd_close(struct rfid_reader_handle *rh)
        free_rat_handle(rath);
        free_reader_handle(rh);
 
+#ifndef LIBRFID_FIRMWARE
        usb_close(hdl);
+#endif
 }
 
 const struct rfid_reader rfid_reader_openpcd = {
@@ -452,6 +460,9 @@ const struct rfid_reader rfid_reader_openpcd = {
        .iso14443b = {
                .init = &openpcd_14443b_init,
        },
+       .iso15693 = {
+               .init = &openpcd_15693_init,
+       },
        .mifare_classic = {
                .setkey = &openpcd_mifare_setkey,
                .auth = &openpcd_mifare_auth,