1 /* ISO 15693 anticollision implementation
3 * (C) 2005-2006 by Harald Welte <laforge@gnumonks.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <librfid/rfid.h>
28 #include <librfid/rfid_layer2.h>
29 #include <librfid/rfid_reader.h>
30 #include <librfid/rfid_layer2_iso15693.h>
32 struct iso15693_request_read {
33 struct iso15693_request req;
36 } __attribute__ ((packed));
38 #define ISO15693_BLOCK_SIZE_MAX (256/8)
39 #define ISO15693_RESP_SIZE_MAX (4+ISO15693_BLOCK_SIZE_MAX)
43 iso15693_read_block(struct rfid_layer2_handle *handle,
44 u_int8_t blocknr, u_int32_t *data)
47 struct iso15693_request_read req;
48 u_int8_t resp[ISO15693_RESP_SIZE_MAX];
51 req.command = ISO15693_CMD_READ_BLOCK_SINGLE;
52 memcpy(&req.uid, handle->..., ISO15693_UID_LEN);
53 req.blocknum = blocknr;
55 /* FIXME: fill CRC if required */
57 rc = iso15693_transceive(... &req, ..., );
62 memcpy(data, resp+1, rc-1); /* FIXME rc-3 in case of CRC */
68 iso15693_write_block()
70 struct iso16593_request_read *rreq;
71 u_int32_t buf[sizeof(req)+ISO15693_BLOCK_SIZE_MAX];
73 rreq = (struct iso15693_request_read *) req;
76 rreq->req.command = ISO15693_CMD_WRITE_BLOCK_SINGLE;
77 memcpy(rreq->uid, handle->, ISO15693_UID_LEN);
78 rreq->blocknum = blocknr;
91 iso15693_anticol(struct rfid_layer2_handle *handle)
97 iso15693_getopt(struct rfid_layer2_handle *handle,
98 int optname, void *optval, unsigned int optlen)
101 case RFID_OPT_15693_MOD_DEPTH:
102 case RFID_OPT_15693_VCD_CODING:
103 case RFID_OPT_15693_VICC_SUBC:
104 case RFID_OPT_15693_VICC_SPEED:
113 iso15693_setopt(struct rfid_layer2_handle *handle, int optname,
114 const void *optval, unsigned int optlen)
117 case RFID_OPT_15693_MOD_DEPTH:
118 case RFID_OPT_15693_VCD_CODING:
119 case RFID_OPT_15693_VICC_SUBC:
120 case RFID_OPT_15693_VICC_SPEED:
128 static int transceive_inventory(struct rfid_layer2_handle *l2h)
132 static struct rfid_layer2_handle *
133 iso15693_init(struct rfid_reader_handle *rh)
136 struct rfid_layer2_handle *h = malloc_layer2_handle(sizeof(*h));
140 h->l2 = &rfid_layer2_iso15693;
142 h->priv.iso15693.state = ISO15693_STATE_NONE;
143 ret = h->rh->reader->iso15693.init(h->rh);
145 free_layer2_handle(h);
153 iso15693_fini(struct rfid_layer2_handle *handle)
155 free_layer2_handle(handle);
160 const struct rfid_layer2 rfid_layer2_iso15693 = {
161 .id = RFID_LAYER2_ISO15693,
164 .init = &iso15693_init,
165 .open = &iso15693_anticol,
166 //.transceive = &iso15693_transceive,
167 //.close = &iso14443a_hlta,
168 .fini = &iso15693_fini,
169 .setopt = &iso15693_setopt,
170 .getopt = &iso15693_getopt,