1 /* ISO 15693 anticollision implementation
3 * (C) 2005-2008 by Harald Welte <laforge@gnumonks.org>
4 * (C) 2007 by Bjoern Riemer <bjoern.riemer@web.de>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 //#define DEBUG_LIBRFID
28 #include <librfid/rfid.h>
29 #include <librfid/rfid_layer2.h>
30 #include <librfid/rfid_reader.h>
31 #include <librfid/rfid_layer2_iso15693.h>
33 /*struct iso15693_request_read {
34 struct iso15693_request head;
37 } __attribute__ ((packed));*/
39 struct iso15693_request_adressed {
40 struct iso15693_request head;
42 } __attribute__ ((packed));
44 struct iso15693_request_block_addressed {
45 struct iso15693_request head;
49 } __attribute__ ((packed));
51 struct iso15693_request_block_selected {
52 struct iso15693_request head;
55 } __attribute__ ((packed));
57 struct iso15693_err_resp {
58 struct iso15693_response head;
61 } __attribute__ ((packed));
63 struct iso15693_response_sec {
64 struct iso15693_response head;
67 } __attribute__ ((packed));
69 #define ISO15693_BLOCK_SIZE_MAX (256/8)
70 #define ISO15693_RESP_SIZE_MAX (4+ISO15693_BLOCK_SIZE_MAX)
72 const unsigned int iso15693_timing[2][5] = {
74 [ISO15693_T1] = 1216, /* max time after VCD EOF before VICC SOF */
75 [ISO15693_T2] = 1200, /* min time before VCD EOF after VICC response */
76 [ISO15693_T3] = 1502, /* min time after VCD EOF before next EOF if no VICC response */
77 [ISO15693_T4] = 1216, /* time after wich VICC transmits after VCD EOF */
78 [ISO15693_T4_WRITE]=20000, /* time after wich VICC transmits after VCD EOF */
81 [ISO15693_T1] = 304, /* max time after VCD EOF before VICC SOF */
82 [ISO15693_T2] = 300, /* min time before VCD EOF after VICC response */
83 [ISO15693_T3] = 602, /* min time after VCD EOF before next EOF if no VICC response */
84 [ISO15693_T4] = 304, /* time after wich VICC transmits after VCD EOF */
85 [ISO15693_T4_WRITE]=20000, /* time after wich VICC transmits after VCD EOF */
90 iso15693_get_response_error_name(u_int8_t error){
92 case RFID_15693_ERR_NOTSUPP:
94 case RFID_15693_ERR_INVALID: /* command not recognized */
96 case RFID_15693_ERR_UNKNOWN: /* unknown error */
98 case RFID_15693_ERR_NOTSUPP_OPTION:
99 return "ERR_NotSuppOpt";
100 case RFID_15693_ERR_BLOCK_NA: /* block not available */
101 return "ERR_BLOCK_N";
102 case RFID_15693_ERR_BLOCK_LOCKED:
103 return "ERR_BLOCK_LOCKE";
104 case RFID_15693_ERR_BLOCK_LOCKED_CH:
105 return "ERR_BLOCK_LOCKED_CH";
106 case RFID_15693_ERR_BLOCK_NOTPROG:
107 return "ERR_BLOCK_NOTPROG";
108 case RFID_15693_ERR_BLOCK_NOTLOCK:
109 return "ERR_BLOCK_NOTLOCK";
110 case 0xA0: /* until 0xDF*/
111 return "Custom Command error Code";
118 static int iso15693_transceive(struct rfid_layer2_handle *handle,
119 enum rfid_frametype frametype,
120 const unsigned char *tx_buf, unsigned int tx_len,
121 unsigned char *rx_buf, unsigned int *rx_len,
122 u_int64_t timeout, unsigned int flags)
124 return handle->rh->reader->transceive(handle->rh, frametype, tx_buf,
125 tx_len, rx_buf, rx_len, timeout, flags);
128 /* Transmit an anticollission frame */
130 iso15693_transceive_acf(struct rfid_layer2_handle *handle,
131 const struct iso15693_anticol_cmd *acf,
132 unsigned int acf_len,
133 struct iso15693_anticol_resp *resp,
134 unsigned int *rx_len, char *bit_of_col)
136 const struct rfid_reader *rdr = handle->rh->reader;
137 if (!rdr->iso15693.transceive_ac)
139 return rdr->iso15693.transceive_ac(handle->rh, acf, acf_len, resp, rx_len, bit_of_col);
144 iso15693_read_block(struct rfid_layer2_handle *handle,
145 u_int8_t blocknr, u_int32_t *data, unsigned int len,
146 unsigned char *block_sec_out)
149 struct iso15693_request_block_selected sel;
150 struct iso15693_request_block_addressed addr;
154 unsigned char *errstr;
155 unsigned int rx_len, tx_len,timeout;
156 u_int8_t resp[ISO15693_RESP_SIZE_MAX];
157 struct iso15693_err_resp *rx_err;
158 struct iso15693_response *rx_pkt;
159 struct iso15693_response_sec *rx_pkt_sec;
161 rx_pkt_sec = (struct iso15693_response *)&resp[0];
162 rx_pkt = (struct iso15693_response *)&resp[0];
163 rx_err = (struct iso15693_err_resp *)&resp[0];
165 memset(&tx_req,0,sizeof(tx_req));
167 rx_len = sizeof(resp);
169 tx_req.sel.head.command = ISO15693_CMD_READ_BLOCK_SINGLE;
171 if (handle->priv.iso15693.vicc_fast){
172 tx_req.sel.head.flags |= RFID_15693_F_RATE_HIGH;
173 timeout=iso15693_timing[ISO15693_T_FAST][ISO15693_T4];
175 timeout=iso15693_timing[ISO15693_T_SLOW][ISO15693_T4];
177 if (handle->priv.iso15693.vicc_two_subc)
178 tx_req.sel.head.flags |= RFID_15693_F_SUBC_TWO;
180 if (block_sec_out!=NULL)
181 tx_req.sel.head.flags |= RFID_15693_F4_CUSTOM;
183 if (handle->priv.iso15693.state==RFID_15693_STATE_SELECTED) {
184 tx_len = sizeof(struct iso15693_request_block_selected);
185 tx_req.sel.blocknum = blocknr;
186 tx_req.sel.head.flags |= RFID_15693_F4_SELECTED;
188 tx_len = sizeof(struct iso15693_request_block_addressed);
189 memcpy(&tx_req.addr.uid, handle->uid, ISO15693_UID_LEN);
190 tx_req.addr.head.flags |= RFID_15693_F4_ADDRESS;
191 tx_req.addr.blocknum = blocknr;
194 //DEBUGP("sizeof: addr: %d sel:%d\n",sizeof(struct iso15693_request_read_addressed),sizeof(struct iso15693_request_read_selected));
195 DEBUGP("tx_len=%u", tx_len); DEBUGPC(" rx_len=%u\n",rx_len);
197 ret = iso15693_transceive(handle, RFID_15693_FRAME, (u_int8_t*)&tx_req,
198 tx_len, resp, &rx_len, timeout, 0);
206 DEBUGP("length: %d rx_len: %d ret: %d%s\n",len,rx_len,ret,errstr);
213 DEBUGP("error_flag: %d", rx_pkt->flags&RFID_15693_RF_ERROR);
214 if (rx_pkt->flags & RFID_15693_RF_ERROR) {
215 DEBUGPC(" -> error: %02x '%s'\n", rx_err->error,
216 iso15693_get_response_error_name(rx_err->error));
218 } else if (block_sec_out != NULL) {
219 DEBUGPC(" block_sec_stat: 0x%02x\n",rx_pkt_sec->block_sec);
220 memcpy(data, rx_pkt_sec->data, rx_len-2);
223 memcpy(data, rx_pkt->data, rx_len-1); /* FIXME rc-3 in case of CRC */
229 iso15693_write_block(struct rfid_layer2_handle *handle,
230 u_int8_t blocknr, u_int32_t *data, unsigned int len)
233 unsigned char *errstr;
234 unsigned int rx_len, tx_len,timeout;
237 struct iso15693_request_block_selected sel;
238 struct iso15693_request_block_addressed addr;
239 u_int32_t buf[sizeof(struct iso15693_request_block_addressed)+ISO15693_BLOCK_SIZE_MAX];
242 u_int8_t resp[ISO15693_RESP_SIZE_MAX];
243 struct iso15693_response *rx_pkt;
244 struct iso15693_err_resp *rx_err;
246 rx_pkt = (struct iso15693_response *)&resp[0];
247 rx_err = (struct iso15693_err_resp *)&resp[0];
248 rx_len = sizeof(resp);
250 if (len > ISO15693_BLOCK_SIZE_MAX)
255 memset(&tx_req,0,sizeof(tx_req));
256 tx_req.sel.head.command = ISO15693_CMD_WRITE_BLOCK_SINGLE;
258 if (handle->priv.iso15693.vicc_fast) {
259 tx_req.sel.head.flags |= RFID_15693_F_RATE_HIGH;
260 timeout = iso15693_timing[ISO15693_T_FAST][ISO15693_T4_WRITE];
262 timeout = iso15693_timing[ISO15693_T_SLOW][ISO15693_T4_WRITE];
264 if (handle->priv.iso15693.vicc_two_subc)
265 tx_req.sel.head.flags |= RFID_15693_F_SUBC_TWO;
267 if (handle->priv.iso15693.state == RFID_15693_STATE_SELECTED) {
268 tx_len=sizeof(struct iso15693_request_block_selected)+len;
269 tx_req.sel.head.flags |= RFID_15693_F4_SELECTED;
270 tx_req.sel.blocknum = blocknr;
271 memcpy(&tx_req.sel.data,data,len);
273 memcpy(&tx_req.addr.uid, handle->uid, ISO15693_UID_LEN);
274 tx_len=sizeof(struct iso15693_request_block_addressed)+len;
275 tx_req.addr.head.flags |= RFID_15693_F4_ADDRESS;
276 tx_req.addr.blocknum = blocknr;
277 memcpy(&tx_req.addr.data,data,len);
280 //DEBUGP("sizeof: addr: %d sel:%d\n",sizeof(struct iso15693_request_read_addressed),sizeof(struct iso15693_request_read_selected));
281 DEBUGP("tx_len=%u", tx_len); DEBUGPC(" rx_len=%u\n",rx_len);
283 ret = iso15693_transceive(handle, RFID_15693_FRAME, (u_int8_t*)&tx_req,
284 tx_len, resp, &rx_len, timeout, 0);
286 if (ret == -ETIMEDOUT)
287 errstr = "(TIMEOUT)";
288 else if (ret == -EIO)
292 DEBUGP("length: %d rx_len: %d ret: %d%s\n",len,rx_len,ret,errstr);
299 DEBUGP("error_flag: %d", rx_pkt->flags & RFID_15693_RF_ERROR);
300 if (rx_pkt->flags & RFID_15693_RF_ERROR) {
301 DEBUGPC(" -> error: %02x '%s'\n", rx_err->error,
302 iso15693_get_response_error_name(rx_err->error));
305 //DEBUGPC(" block_sec_stat: 0x%02x\n",rx_pkt->data[0]);
306 //memcpy(data, rx_pkt->data, rx_len-1); /* FIXME rc-3 in case of CRC */
317 iso15693_lock_block()
323 /* Helper function to build an ISO 15693 anti collision frame */
325 iso15693_build_acf(u_int8_t *target, u_int8_t flags, u_int8_t afi,
326 u_int8_t mask_len, u_int8_t *mask)
328 struct iso15693_request *req = (struct iso15693_request *) target;
329 int i = 0, j, mask_bytes;
334 req->command = ISO15693_CMD_INVENTORY;
335 if (flags & RFID_15693_F5_AFI_PRES)
336 req->data[i++] = afi;
337 req->data[i++] = mask_len;
339 mask_bytes = mask_len/8 + (mask_len%8)?1:0;
340 mask_p = &req->data[i];
342 for (j = 0; j < mask_bytes; j++)
343 req->data[i++] = mask[j];
345 byte = 0xFF >> (8-mask_len%8);
346 req->data[i-1] &= byte;
348 DEBUGP("mask_len: %d mask_bytes: %d i: %d return: %d mask:%s\n",
349 mask_len,mask_bytes,i,i + sizeof(*req),rfid_hexdump(mask_p,mask_bytes));
350 return i + sizeof(*req);
354 iso15693_anticol(struct rfid_layer2_handle *handle)
356 int i, ret, mask_len;
360 struct iso15693_anticol_cmd_afi w_afi;
361 struct iso15693_anticol_cmd no_afi;
364 struct iso15693_anticol_resp resp;
368 int num_slots = MAX_SLOTS;
370 u_int8_t uuid_list[MAX_SLOTS][ISO15693_UID_LEN];
371 int uuid_list_valid[MAX_SLOTS];
379 memset(uuid_list_valid, MY_NONE, sizeof(uuid_list_valid));
380 memset(uuid_list, 0, sizeof(uuid_list));
382 //memset(&acf, 0, sizeof(acf));
384 /* FIXME: we can't use multiple slots at this point, since the RC632
385 * with librfid on the host PC has too much latency between 'EOF pulse
386 * to mark start of next slot' and 'receive data' commands :( */
388 flags = RFID_15693_F_INV_TABLE_5;
389 if (handle->priv.iso15693.vicc_fast)
390 flags |= RFID_15693_F_RATE_HIGH;
391 if (handle->priv.iso15693.vicc_two_subc)
392 flags |= RFID_15693_F_SUBC_TWO;
393 if (handle->priv.iso15693.single_slot) {
394 flags |= RFID_15693_F5_NSLOTS_1;
397 if (handle->priv.iso15693.use_afi)
398 flags |= RFID_15693_F5_AFI_PRES;
400 tx_len = iso15693_build_acf((u_int8_t *)&acf, flags,
401 handle->priv.iso15693.afi, 0, NULL);
404 u_int8_t uid[8]={0x1f, 0x1e, 0x95, 0x01, 0x00, 0x01, 0x04, 0xe0};
405 //u_int8_t uid[8]={0xe3, 0xe8, 0xf1, 0x01, 0x00, 0x00, 0x07, 0xe0};
406 tx_len = iso15693_build_acf((u_int8_t *)&acf, flags,
407 handle->priv.iso15693.afi, 2, uid);
410 for (i = 0; i < num_slots; i++) {
411 rx_len = sizeof(resp);
412 memset(&resp, 0, rx_len);
413 ret = iso15693_transceive_acf(handle, (u_int8_t *) &acf, tx_len, &resp, &rx_len, &boc);
415 if (ret == -ETIMEDOUT) {
416 //DEBUGP("no answer from vicc in slot %d\n", i);
417 DEBUGP("slot[%d]: timeout\n",i);
418 uuid_list_valid[i] = MY_NONE;
419 } else if (ret < 0) {
420 DEBUGP("slot[%d]: ERROR ret: %d\n", i, ret);
421 uuid_list_valid[i] = MY_NONE;
424 DEBUGP("iso15693_transceive_acf() ret: %d\n",ret);
426 DEBUGP("slot[%d]: Collision! bit:%d byte:%d,%d (UID bit:%d byte:%d,%d)\n",
428 boc-16,(boc-16)/8,(boc-16)%8);
429 DEBUGP("Slot[%d]: ret: %d DSFID: %02x UUID: %s\n", i, ret,
430 resp.dsfid, rfid_hexdump(resp.uuid, ISO15693_UID_LEN));
432 uuid_list_valid[i]=-boc;
433 memcpy(uuid_list[i], resp.uuid, ISO15693_UID_LEN);
435 DEBUGP("Slot[%d]: ret: %d DSFID: %02x UUID: %s\n", i, ret,
436 resp.dsfid, rfid_hexdump(resp.uuid, ISO15693_UID_LEN));
437 uuid_list_valid[i] = MY_UUID;
438 memcpy(&uuid_list[i][0], resp.uuid, ISO15693_UID_LEN);
440 memcpy(handle->uid,resp.uuid, ISO15693_UID_LEN);
441 /* FIXME: move to init_iso15693 */
442 handle->uid_len = ISO15693_UID_LEN;
449 for (i = 0; i < num_slots; i++) {
450 if (uuid_list_valid[i] < 0) {
451 boc=uuid_list_valid[i]*-1;
456 DEBUGP("slot[%d]:boc is smaller than 2 bytes (collision before uid)!!!!\n",i);
459 tx_len = iso15693_build_acf((u_int8_t *)&acf, flags,
460 handle->priv.iso15693.afi, boc+1, resp.uuid);
462 // FIXME: dont use goto
463 goto start_of_ac_loop;
465 DEBUGP("slot[%d]:boc is bigger than 64 (uid size)(collision after uid)\n",i);
466 memcpy(handle->uid,uuid_list[i],ISO15693_UID_LEN);
468 /* FIXME: move to init_iso15693 */
469 handle->uid_len = ISO15693_UID_LEN;
475 for (i = 0; i < num_slots; i++) {
476 if (uuid_list_valid[i] == MY_NONE) {
477 DEBUGP("slot[%d]: timeout\n",i);
478 } else if (uuid_list_valid[i] == MY_UUID) {
479 DEBUGP("slot[%d]: VALID uuid: %s\n", i,
480 rfid_hexdump(uuid_list[i], ISO15693_UID_LEN));
481 memcpy(handle->uid, uuid_list[i], ISO15693_UID_LEN);
482 /* FIXME: move to init_iso15693 */
483 handle->uid_len = ISO15693_UID_LEN;
485 } else if (uuid_list_valid[i] < 0) {
490 DEBUGP("boc is smaller than 2 bytes (collision before uid)!!!!\n");
492 uuid_list_valid[i] = -boc;
494 tx_len = iso15693_build_acf((u_int8_t *)&acf, flags,
495 handle->priv.iso15693.afi, boc+1, resp.uuid);
497 // FIXME: dont use goto
498 goto start_of_ac_loop;
500 DEBUGP("boc is bigger than 64 (uid size)\n");
501 uuid_list_valid[i] = MY_UUID;
513 iso15693_select(struct rfid_layer2_handle *l2h)
515 struct iso15693_request_adressed tx_req;
517 unsigned int rx_len, tx_len, timeout;
520 struct iso15693_response head;
522 unsigned char crc[2];
524 rx_len = sizeof(rx_buf);
526 if (l2h->priv.iso15693.vicc_fast) {
527 tx_req.head.flags |= RFID_15693_F_RATE_HIGH;
528 timeout = iso15693_timing[ISO15693_T_FAST][ISO15693_T4];
530 timeout = iso15693_timing[ISO15693_T_SLOW][ISO15693_T4];
532 tx_req.head.command = ISO15693_CMD_SELECT;
533 tx_req.head.flags = RFID_15693_F4_ADDRESS;
535 if (l2h->priv.iso15693.vicc_fast)
536 tx_req.head.flags |= RFID_15693_F_RATE_HIGH;
537 if (l2h->priv.iso15693.vicc_two_subc)
538 tx_req.head.flags |= RFID_15693_F_SUBC_TWO;
540 memcpy(&tx_req.uid, l2h->uid, ISO15693_UID_LEN);
541 tx_len = sizeof(tx_req);
543 DEBUGP("tx_len=%u, rx_len=%u\n", tx_len,rx_len);
545 ret = iso15693_transceive(l2h, RFID_15693_FRAME, (u_int8_t*)&tx_req,
546 tx_len, (u_int8_t*)&rx_buf, &rx_len,timeout ,0);
548 DEBUGP("ret: %d%s, rx_len: %d, error_flag: %d", ret,
549 (ret==-ETIMEDOUT)?"(TIMEOUT)":"", rx_len,
550 rx_buf.head.flags&RFID_15693_RF_ERROR);
551 if (rx_buf.head.flags & RFID_15693_RF_ERROR) {
552 DEBUGPC(" -> error: %02x '%s'\n", rx_buf.error,
553 iso15693_get_response_error_name(rx_buf.error));
556 DEBUGPC(" SELECTED\n");
557 l2h->priv.iso15693.state = RFID_15693_STATE_SELECTED;
563 iso15693_stay_quiet(struct rfid_layer2_handle *l2h)
565 struct iso15693_request_adressed tx_req;
567 unsigned int rx_len, tx_len;
570 struct iso15693_response head;
572 unsigned char crc[2];
574 rx_len = sizeof(rx_buf);
576 tx_req.head.command = ISO15693_CMD_STAY_QUIET;
578 tx_req.head.flags = RFID_15693_F4_ADDRESS;
579 if (l2h->priv.iso15693.vicc_fast)
580 tx_req.head.flags |= RFID_15693_F_RATE_HIGH;
581 if (l2h->priv.iso15693.vicc_two_subc)
582 tx_req.head.flags |= RFID_15693_F_SUBC_TWO;
583 memcpy(&tx_req.uid, l2h->uid, ISO15693_UID_LEN);
584 tx_len = sizeof(tx_req);
586 DEBUGP("tx_len=%u", tx_len); DEBUGPC(" rx_len=%u\n",rx_len);
588 ret = iso15693_transceive(l2h, RFID_15693_FRAME, (u_int8_t*)&tx_req,
589 tx_len, (u_int8_t*)&rx_buf, &rx_len, 30,0);
591 l2h->priv.iso15693.state = RFID_15693_STATE_QUIET;
593 DEBUGP("ret: %d%s, error_flag: %d", ret,(ret==-ETIMEDOUT)?"(TIMEOUT)":"",
594 rx_buf.head.flags&RFID_15693_RF_ERROR);
595 if (rx_buf.head.flags&RFID_15693_RF_ERROR)
596 DEBUGPC(" -> error: %02x\n", rx_buf.error);
604 iso15693_getopt(struct rfid_layer2_handle *handle,
605 int optname, void *optval, unsigned int *optlen)
607 unsigned int *val = optval;
608 u_int8_t *val_u8 = optval;
610 if (!optlen || !optval || *optlen < sizeof(unsigned int))
613 *optlen = sizeof(unsigned int);
616 case RFID_OPT_15693_MOD_DEPTH:
617 if (handle->priv.iso15693.vcd_ask100)
618 *val = RFID_15693_MOD_100ASK;
620 *val = RFID_15693_MOD_10ASK;
622 case RFID_OPT_15693_VCD_CODING:
623 if (handle->priv.iso15693.vcd_out256)
624 *val = RFID_15693_VCD_CODING_1OUT256;
626 *val = RFID_15693_VCD_CODING_1OUT4;
628 case RFID_OPT_15693_VICC_SUBC:
629 if (handle->priv.iso15693.vicc_two_subc)
630 *val = RFID_15693_VICC_SUBC_DUAL;
632 *val = RFID_15693_VICC_SUBC_SINGLE;
634 case RFID_OPT_15693_VICC_SPEED:
635 if (handle->priv.iso15693.vicc_fast)
636 *val = RFID_15693_VICC_SPEED_FAST;
638 *val = RFID_15693_VICC_SPEED_SLOW;
640 case RFID_OPT_15693_VCD_SLOTS:
641 if (handle->priv.iso15693.single_slot)
646 case RFID_OPT_15693_USE_AFI:
647 if (handle->priv.iso15693.use_afi)
652 case RFID_OPT_15693_AFI:
653 *val_u8 = handle->priv.iso15693.afi;
654 *optlen = sizeof(u_int8_t);
665 iso15693_setopt(struct rfid_layer2_handle *handle, int optname,
666 const void *optval, unsigned int optlen)
670 if (optlen < sizeof(u_int8_t) || !optval)
673 if (optlen == sizeof(u_int8_t))
674 val = *((u_int8_t *) optval);
675 if (optlen == sizeof(u_int16_t))
676 val = *((u_int16_t *) optval);
677 if (optlen == sizeof(unsigned int))
678 val = *((unsigned int *) optval);
681 case RFID_OPT_15693_MOD_DEPTH:
683 case RFID_15693_MOD_10ASK:
684 handle->priv.iso15693.vcd_ask100 = 0;
686 case RFID_15693_MOD_100ASK:
687 handle->priv.iso15693.vcd_ask100 = 1;
693 case RFID_OPT_15693_VCD_CODING:
695 case RFID_15693_VCD_CODING_1OUT256:
696 handle->priv.iso15693.vcd_out256 = 1;
698 case RFID_15693_VCD_CODING_1OUT4:
699 handle->priv.iso15693.vcd_out256 = 0;
705 case RFID_OPT_15693_VICC_SUBC:
707 case RFID_15693_VICC_SUBC_SINGLE:
708 handle->priv.iso15693.vicc_two_subc = 0;
710 case RFID_15693_VICC_SUBC_DUAL:
711 handle->priv.iso15693.vicc_two_subc = 1;
717 case RFID_OPT_15693_VICC_SPEED:
719 case RFID_15693_VICC_SPEED_SLOW:
720 handle->priv.iso15693.vicc_fast = 0;
722 case RFID_15693_VICC_SPEED_FAST:
723 handle->priv.iso15693.vicc_fast = 1;
728 case RFID_OPT_15693_VCD_SLOTS:
731 handle->priv.iso15693.single_slot = 0;
734 handle->priv.iso15693.single_slot = 1;
740 case RFID_OPT_15693_USE_AFI:
742 handle->priv.iso15693.use_afi = 1;
744 handle->priv.iso15693.use_afi = 0;
746 case RFID_OPT_15693_AFI:
749 handle->priv.iso15693.afi = val;
757 static int transceive_inventory(struct rfid_layer2_handle *l2h)
762 static struct rfid_layer2_handle *
763 iso15693_init(struct rfid_reader_handle *rh)
766 struct rfid_layer2_handle *h = malloc_layer2_handle(sizeof(*h));
770 h->l2 = &rfid_layer2_iso15693;
772 h->priv.iso15693.state = ISO15693_STATE_NONE;
773 h->priv.iso15693.vcd_ask100 = 1; /* 100ASK is easier to generate */
774 h->priv.iso15693.vicc_two_subc = 0;
775 h->priv.iso15693.vicc_fast = 1;
776 h->priv.iso15693.single_slot = 1;
777 h->priv.iso15693.vcd_out256 = 0;
778 h->priv.iso15693.use_afi = 0; /* not all VICC support AFI */
779 h->priv.iso15693.afi = 0;
781 ret = h->rh->reader->init(h->rh, RFID_LAYER2_ISO15693);
783 free_layer2_handle(h);
791 iso15693_fini(struct rfid_layer2_handle *handle)
793 free_layer2_handle(handle);
798 const struct rfid_layer2 rfid_layer2_iso15693 = {
799 .id = RFID_LAYER2_ISO15693,
802 .init = &iso15693_init,
803 .open = &iso15693_anticol,
804 //.open = &iso15693_select,
805 //.transceive = &iso15693_transceive,
806 .close = &iso15693_stay_quiet,
807 .fini = &iso15693_fini,
808 .setopt = &iso15693_setopt,
809 .getopt = &iso15693_getopt,