* improve scanning support:
[librfid] / include / librfid / rfid_reader.h
1 #ifndef _RFID_READER_H
2 #define _RFID_READER_H
3
4 #include <librfid/rfid_asic.h>
5 #include <librfid/rfid_layer2_iso14443a.h>
6
7 struct rfid_reader_handle;
8
9 struct rfid_reader {
10         char *name;
11         unsigned int id;
12         unsigned int l2_supported;
13         unsigned int proto_supported;
14
15         int (*get_api_version)(
16             struct rfid_reader_handle *h,
17             u_int8_t *version);
18
19         int (*get_environment)(
20             struct rfid_reader_handle *rh,
21             unsigned char num_bytes,
22             unsigned char *buf);
23
24         int (*set_environment)(
25             struct rfid_reader_handle *rh,
26             unsigned char num_bytes,
27             const unsigned char *buf);
28
29         int (*reset)(struct rfid_reader_handle *h);
30
31         int (*transceive)(struct rfid_reader_handle *h,
32                           enum rfid_frametype frametype,
33                           const unsigned char *tx_buf, unsigned int tx_len,
34                           unsigned char *rx_buf, unsigned int *rx_len,
35                           u_int64_t timeout, unsigned int flags);
36         struct rfid_reader_handle * (*open)(void *data);
37         void (*close)(struct rfid_reader_handle *h);
38         int (*rf_power)(struct rfid_reader_handle *h, int on);
39
40         struct rfid_14443a_reader {
41                 int (*init)(struct rfid_reader_handle *h);
42                 int (*transceive_sf)(struct rfid_reader_handle *h,
43                                      unsigned char cmd,
44                                      struct iso14443a_atqa *atqa);
45                 int (*transceive_acf)(struct rfid_reader_handle *h,
46                                       struct iso14443a_anticol_cmd *cmd,
47                                       unsigned int *bit_of_col);
48                 int (*set_speed)(struct rfid_reader_handle *h,
49                                  unsigned int tx,
50                                  unsigned int speed);
51                 unsigned int speed;
52         } iso14443a;
53         struct rfid_14443b_reader {
54                 int (*init)(struct rfid_reader_handle *rh);
55                 unsigned int speed;
56         } iso14443b;
57         struct rfid_15693_reader {
58                 int (*init)(struct rfid_reader_handle *rh);
59         } iso15693;
60         struct rfid_mifare_classic_reader {
61                 int (*setkey)(struct rfid_reader_handle *h, const unsigned char *key);
62                 int (*auth)(struct rfid_reader_handle *h, u_int8_t cmd,
63                             u_int32_t serno, u_int8_t block);
64         } mifare_classic;
65 };
66
67 enum rfid_reader_id {
68         RFID_READER_CM5121,
69         RFID_READER_PEGODA,
70         RFID_READER_OPENPCD,
71         RFID_READER_SPIDEV,
72 };
73
74 struct rfid_reader_handle {
75         struct rfid_asic_handle *ah;
76
77         union {
78
79         } priv;
80         const struct rfid_reader *reader;
81 };
82
83 extern struct rfid_reader_handle *
84 rfid_reader_open(void *data, unsigned int id);
85
86 extern void rfid_reader_close(struct rfid_reader_handle *rh);
87 #endif