summaryrefslogtreecommitdiff
path: root/include/librfid/rfid_reader.h
blob: 8dc7860c9ba8eed943e64764b923b602544186aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef _RFID_READER_H
#define _RFID_READER_H

#include <librfid/rfid_asic.h>
#include <librfid/rfid_layer2_iso14443a.h>
#include <librfid/rfid_layer2_iso15693.h>

struct rfid_reader_handle;

struct rfid_reader {
	char *name;
	unsigned int id;
	unsigned int l2_supported;
	unsigned int proto_supported;

        int (*get_api_version)(
            struct rfid_reader_handle *h,
            u_int8_t *version);

        int (*get_environment)(
            struct rfid_reader_handle *rh,
            unsigned char num_bytes,
            unsigned char *buf);

        int (*set_environment)(
            struct rfid_reader_handle *rh,
            unsigned char num_bytes,
            const unsigned char *buf);

        int (*reset)(struct rfid_reader_handle *h);

	int (*transceive)(struct rfid_reader_handle *h,
			  enum rfid_frametype frametype,
			  const unsigned char *tx_buf, unsigned int tx_len,
			  unsigned char *rx_buf, unsigned int *rx_len,
			  u_int64_t timeout, unsigned int flags);
	struct rfid_reader_handle * (*open)(void *data);
	void (*close)(struct rfid_reader_handle *h);
	int (*rf_power)(struct rfid_reader_handle *h, int on);

	struct rfid_14443a_reader {
		int (*init)(struct rfid_reader_handle *h);
		int (*transceive_sf)(struct rfid_reader_handle *h,
				     unsigned char cmd,
				     struct iso14443a_atqa *atqa);
		int (*transceive_acf)(struct rfid_reader_handle *h,
				      struct iso14443a_anticol_cmd *cmd,
				      unsigned int *bit_of_col);
		int (*set_speed)(struct rfid_reader_handle *h,
				 unsigned int tx,
				 unsigned int speed);
		unsigned int speed;
	} iso14443a;
	struct rfid_14443b_reader {
		int (*init)(struct rfid_reader_handle *rh);
		unsigned int speed;
	} iso14443b;
	struct rfid_15693_reader {
		int (*init)(struct rfid_reader_handle *rh);
		int (*transceive_ac)(struct rfid_reader_handle *h,
				     struct iso15693_anticol_cmd *acf,
				     unsigned char *uuid,
				     char *bit_of_col);
	} iso15693;
	struct rfid_mifare_classic_reader {
		int (*setkey)(struct rfid_reader_handle *h, const unsigned char *key);
		int (*auth)(struct rfid_reader_handle *h, u_int8_t cmd,
			    u_int32_t serno, u_int8_t block);
	} mifare_classic;
};

enum rfid_reader_id {
	RFID_READER_CM5121,
	RFID_READER_PEGODA,
	RFID_READER_OPENPCD,
	RFID_READER_SPIDEV,
};

struct rfid_reader_handle {
	struct rfid_asic_handle *ah;

	union {

	} priv;
	const struct rfid_reader *reader;
};

extern struct rfid_reader_handle *
rfid_reader_open(void *data, unsigned int id);

extern void rfid_reader_close(struct rfid_reader_handle *rh);
#endif
personal git repositories of Harald Welte. Your mileage may vary