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
26 #include <librfid/rfid.h>
27 #include <librfid/rfid_layer2.h>
28 #include <librfid/rfid_reader.h>
29 #include <librfid/rfid_layer2_iso15693.h>
31 struct iso15693_request_read {
32 struct iso15693_request req;
35 } __attribute__ ((packed));
37 #define ISO15693_BLOCK_SIZE_MAX (256/8)
38 #define ISO15693_RESP_SIZE_MAX (4+ISO15693_BLOCK_SIZE_MAX)
42 iso15693_read_block(struct rfid_layer2_handle *handle,
43 u_int8_t blocknr, u_int32_t *data)
46 struct iso15693_request_read req;
47 u_int8_t resp[ISO15693_RESP_SIZE_MAX];
50 req.command = ISO15693_CMD_READ_BLOCK_SINGLE;
51 memcpy(&req.uid, handle->..., ISO15693_UID_LEN);
52 req.blocknum = blocknr;
54 /* FIXME: fill CRC if required */
56 rc = iso15693_transceive(... &req, ..., );
61 memcpy(data, resp+1, rc-1); /* FIXME rc-3 in case of CRC */
67 iso15693_write_block()
69 struct iso16593_request_read *rreq;
70 u_int32_t buf[sizeof(req)+ISO15693_BLOCK_SIZE_MAX];
72 rreq = (struct iso15693_request_read *) req;
75 rreq->req.command = ISO15693_CMD_WRITE_BLOCK_SINGLE;
76 memcpy(rreq->uid, handle->, ISO15693_UID_LEN);
77 rreq->blocknum = blocknr;
90 iso15693_anticol(struct rfid_layer2_handle *handle)
95 static struct rfid_layer2_handle *
96 iso15693_init(struct rfid_reader_handle *rh)
99 struct rfid_layer2_handle *h = malloc_layer2_handle(sizeof(*h));
103 h->l2 = &rfid_layer2_iso15693;
105 h->priv.iso15693.state = ISO15693_STATE_NONE;
106 ret = h->rh->reader->iso15693.init(h->rh);
108 free_layer2_handle(h);
116 iso15693_fini(struct rfid_layer2_handle *handle)
118 free_layer2_handle(handle);
123 const struct rfid_layer2 rfid_layer2_iso15693 = {
124 .id = RFID_LAYER2_ISO15693,
127 .init = &iso15693_init,
128 .open = &iso15693_anticol,
129 //.transceive = &iso15693_transceive,
130 //.close = &iso14443a_hlta,
131 .fini = &iso15693_fini,