]> rtime.felk.cvut.cz Git - coffee/mt-apps.git/blob - mt_rfid.h
Add charset to the html document
[coffee/mt-apps.git] / mt_rfid.h
1 #ifndef MT_RFID_H
2 #define MT_RFID_H
3
4 #include <ev.h>
5 #include <stdint.h>
6
7 typedef struct ev_io_ufr {
8     ev_io w;           // fd watcher
9     char uid_data[24]; // store uid here (uid is 10 bytes max)
10     char *uid;         // current position in uid_data
11     int fd;            // PORT_NAME file descriptor
12 } ev_io_ufr;
13
14 typedef struct mt_rfid_t {
15     ev_io_ufr w; // reader watcher
16     int fd;      // print JSON output here
17 } mt_rfid_t;
18
19 #if HAVE_RFID
20
21 // reader open parameters, see uFR manual
22 #define UFR_READER_TYPE     1       // uFR type (1Mbps)
23 #define UFR_PORT_INTERFACE  1       // serial; auto->ftdi->FAIL
24 #define UFR_PORT_NAME       "/dev/ttyUSB0" // reader device
25 #define UFR_ASYNC_BAUD_RATE 1000000 // 1Mbps, otherwise UFR_COMMUNICATION_BREAK
26
27 #define UFR_BEEP // define this to annoy people
28
29 // connect to the reader, add self to loop and make it write to fd
30 // return 0 on success, negative number otherwise
31 int mt_rfid_init(mt_rfid_t *self, struct ev_loop *loop, int fd);
32
33 // disconnect from reader
34 void mt_rfid_deinit(mt_rfid_t *self);
35
36 #else
37
38 #define mt_rfid_init(self, loop, fd) 0
39 #define mt_rfid_deinit(self) 0
40
41 #endif /* HAVE_RFID */
42
43 void rfid_json_print(int fd,
44                      uint8_t card_type,
45                      uint8_t sak,           //select acknowledge
46                      char *uid,
47                      uint8_t size);
48
49
50 #endif