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