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_sec *)&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,
414 (struct iso15693_anticol_cmd *) &acf,
415 tx_len, &resp, &rx_len, &boc);
417 if (ret == -ETIMEDOUT) {
418 //DEBUGP("no answer from vicc in slot %d\n", i);
419 DEBUGP("slot[%d]: timeout\n",i);
420 uuid_list_valid[i] = MY_NONE;
421 } else if (ret < 0) {
422 DEBUGP("slot[%d]: ERROR ret: %d\n", i, ret);
423 uuid_list_valid[i] = MY_NONE;
426 DEBUGP("iso15693_transceive_acf() ret: %d\n",ret);
428 DEBUGP("slot[%d]: Collision! bit:%d byte:%d,%d (UID bit:%d byte:%d,%d)\n",
430 boc-16,(boc-16)/8,(boc-16)%8);
431 DEBUGP("Slot[%d]: ret: %d DSFID: %02x UUID: %s\n", i, ret,
432 resp.dsfid, rfid_hexdump(resp.uuid, ISO15693_UID_LEN));
434 uuid_list_valid[i]=-boc;
435 memcpy(uuid_list[i], resp.uuid, ISO15693_UID_LEN);
437 DEBUGP("Slot[%d]: ret: %d DSFID: %02x UUID: %s\n", i, ret,
438 resp.dsfid, rfid_hexdump(resp.uuid, ISO15693_UID_LEN));
439 uuid_list_valid[i] = MY_UUID;
440 memcpy(&uuid_list[i][0], resp.uuid, ISO15693_UID_LEN);
442 memcpy(handle->uid,resp.uuid, ISO15693_UID_LEN);
443 /* FIXME: move to init_iso15693 */
444 handle->uid_len = ISO15693_UID_LEN;
451 for (i = 0; i < num_slots; i++) {
452 if (uuid_list_valid[i] < 0) {
453 boc=uuid_list_valid[i]*-1;
458 DEBUGP("slot[%d]:boc is smaller than 2 bytes (collision before uid)!!!!\n",i);
461 tx_len = iso15693_build_acf((u_int8_t *)&acf, flags,
462 handle->priv.iso15693.afi, boc+1, resp.uuid);
464 // FIXME: dont use goto
465 goto start_of_ac_loop;
467 DEBUGP("slot[%d]:boc is bigger than 64 (uid size)(collision after uid)\n",i);
468 memcpy(handle->uid,uuid_list[i],ISO15693_UID_LEN);
470 /* FIXME: move to init_iso15693 */
471 handle->uid_len = ISO15693_UID_LEN;
477 for (i = 0; i < num_slots; i++) {
478 if (uuid_list_valid[i] == MY_NONE) {
479 DEBUGP("slot[%d]: timeout\n",i);
480 } else if (uuid_list_valid[i] == MY_UUID) {
481 DEBUGP("slot[%d]: VALID uuid: %s\n", i,
482 rfid_hexdump(uuid_list[i], ISO15693_UID_LEN));
483 memcpy(handle->uid, uuid_list[i], ISO15693_UID_LEN);
484 /* FIXME: move to init_iso15693 */
485 handle->uid_len = ISO15693_UID_LEN;
487 } else if (uuid_list_valid[i] < 0) {
492 DEBUGP("boc is smaller than 2 bytes (collision before uid)!!!!\n");
494 uuid_list_valid[i] = -boc;
496 tx_len = iso15693_build_acf((u_int8_t *)&acf, flags,
497 handle->priv.iso15693.afi, boc+1, resp.uuid);
499 // FIXME: dont use goto
500 goto start_of_ac_loop;
502 DEBUGP("boc is bigger than 64 (uid size)\n");
503 uuid_list_valid[i] = MY_UUID;
515 iso15693_select(struct rfid_layer2_handle *l2h)
517 struct iso15693_request_adressed tx_req;
519 unsigned int rx_len, tx_len, timeout;
522 struct iso15693_response head;
524 unsigned char crc[2];
526 rx_len = sizeof(rx_buf);
528 if (l2h->priv.iso15693.vicc_fast) {
529 tx_req.head.flags |= RFID_15693_F_RATE_HIGH;
530 timeout = iso15693_timing[ISO15693_T_FAST][ISO15693_T4];
532 timeout = iso15693_timing[ISO15693_T_SLOW][ISO15693_T4];
534 tx_req.head.command = ISO15693_CMD_SELECT;
535 tx_req.head.flags = RFID_15693_F4_ADDRESS;
537 if (l2h->priv.iso15693.vicc_fast)
538 tx_req.head.flags |= RFID_15693_F_RATE_HIGH;
539 if (l2h->priv.iso15693.vicc_two_subc)
540 tx_req.head.flags |= RFID_15693_F_SUBC_TWO;
542 memcpy(&tx_req.uid, l2h->uid, ISO15693_UID_LEN);
543 tx_len = sizeof(tx_req);
545 DEBUGP("tx_len=%u, rx_len=%u\n", tx_len,rx_len);
547 ret = iso15693_transceive(l2h, RFID_15693_FRAME, (u_int8_t*)&tx_req,
548 tx_len, (u_int8_t*)&rx_buf, &rx_len,timeout ,0);
550 DEBUGP("ret: %d%s, rx_len: %d, error_flag: %d", ret,
551 (ret==-ETIMEDOUT)?"(TIMEOUT)":"", rx_len,
552 rx_buf.head.flags&RFID_15693_RF_ERROR);
553 if (rx_buf.head.flags & RFID_15693_RF_ERROR) {
554 DEBUGPC(" -> error: %02x '%s'\n", rx_buf.error,
555 iso15693_get_response_error_name(rx_buf.error));
558 DEBUGPC(" SELECTED\n");
559 l2h->priv.iso15693.state = RFID_15693_STATE_SELECTED;
565 iso15693_stay_quiet(struct rfid_layer2_handle *l2h)
567 struct iso15693_request_adressed tx_req;
569 unsigned int rx_len, tx_len;
572 struct iso15693_response head;
574 unsigned char crc[2];
576 rx_len = sizeof(rx_buf);
578 tx_req.head.command = ISO15693_CMD_STAY_QUIET;
580 tx_req.head.flags = RFID_15693_F4_ADDRESS;
581 if (l2h->priv.iso15693.vicc_fast)
582 tx_req.head.flags |= RFID_15693_F_RATE_HIGH;
583 if (l2h->priv.iso15693.vicc_two_subc)
584 tx_req.head.flags |= RFID_15693_F_SUBC_TWO;
585 memcpy(&tx_req.uid, l2h->uid, ISO15693_UID_LEN);
586 tx_len = sizeof(tx_req);
588 DEBUGP("tx_len=%u", tx_len); DEBUGPC(" rx_len=%u\n",rx_len);
590 ret = iso15693_transceive(l2h, RFID_15693_FRAME, (u_int8_t*)&tx_req,
591 tx_len, (u_int8_t*)&rx_buf, &rx_len, 30,0);
593 l2h->priv.iso15693.state = RFID_15693_STATE_QUIET;
595 DEBUGP("ret: %d%s, error_flag: %d", ret,(ret==-ETIMEDOUT)?"(TIMEOUT)":"",
596 rx_buf.head.flags&RFID_15693_RF_ERROR);
597 if (rx_buf.head.flags&RFID_15693_RF_ERROR)
598 DEBUGPC(" -> error: %02x\n", rx_buf.error);
606 iso15693_getopt(struct rfid_layer2_handle *handle,
607 int optname, void *optval, unsigned int *optlen)
609 unsigned int *val = optval;
610 u_int8_t *val_u8 = optval;
612 if (!optlen || !optval || *optlen < sizeof(unsigned int))
615 *optlen = sizeof(unsigned int);
618 case RFID_OPT_15693_MOD_DEPTH:
619 if (handle->priv.iso15693.vcd_ask100)
620 *val = RFID_15693_MOD_100ASK;
622 *val = RFID_15693_MOD_10ASK;
624 case RFID_OPT_15693_VCD_CODING:
625 if (handle->priv.iso15693.vcd_out256)
626 *val = RFID_15693_VCD_CODING_1OUT256;
628 *val = RFID_15693_VCD_CODING_1OUT4;
630 case RFID_OPT_15693_VICC_SUBC:
631 if (handle->priv.iso15693.vicc_two_subc)
632 *val = RFID_15693_VICC_SUBC_DUAL;
634 *val = RFID_15693_VICC_SUBC_SINGLE;
636 case RFID_OPT_15693_VICC_SPEED:
637 if (handle->priv.iso15693.vicc_fast)
638 *val = RFID_15693_VICC_SPEED_FAST;
640 *val = RFID_15693_VICC_SPEED_SLOW;
642 case RFID_OPT_15693_VCD_SLOTS:
643 if (handle->priv.iso15693.single_slot)
648 case RFID_OPT_15693_USE_AFI:
649 if (handle->priv.iso15693.use_afi)
654 case RFID_OPT_15693_AFI:
655 *val_u8 = handle->priv.iso15693.afi;
656 *optlen = sizeof(u_int8_t);
667 iso15693_setopt(struct rfid_layer2_handle *handle, int optname,
668 const void *optval, unsigned int optlen)
672 if (optlen < sizeof(u_int8_t) || !optval)
675 if (optlen == sizeof(u_int8_t))
676 val = *((u_int8_t *) optval);
677 if (optlen == sizeof(u_int16_t))
678 val = *((u_int16_t *) optval);
679 if (optlen == sizeof(unsigned int))
680 val = *((unsigned int *) optval);
683 case RFID_OPT_15693_MOD_DEPTH:
685 case RFID_15693_MOD_10ASK:
686 handle->priv.iso15693.vcd_ask100 = 0;
688 case RFID_15693_MOD_100ASK:
689 handle->priv.iso15693.vcd_ask100 = 1;
695 case RFID_OPT_15693_VCD_CODING:
697 case RFID_15693_VCD_CODING_1OUT256:
698 handle->priv.iso15693.vcd_out256 = 1;
700 case RFID_15693_VCD_CODING_1OUT4:
701 handle->priv.iso15693.vcd_out256 = 0;
707 case RFID_OPT_15693_VICC_SUBC:
709 case RFID_15693_VICC_SUBC_SINGLE:
710 handle->priv.iso15693.vicc_two_subc = 0;
712 case RFID_15693_VICC_SUBC_DUAL:
713 handle->priv.iso15693.vicc_two_subc = 1;
719 case RFID_OPT_15693_VICC_SPEED:
721 case RFID_15693_VICC_SPEED_SLOW:
722 handle->priv.iso15693.vicc_fast = 0;
724 case RFID_15693_VICC_SPEED_FAST:
725 handle->priv.iso15693.vicc_fast = 1;
730 case RFID_OPT_15693_VCD_SLOTS:
733 handle->priv.iso15693.single_slot = 0;
736 handle->priv.iso15693.single_slot = 1;
742 case RFID_OPT_15693_USE_AFI:
744 handle->priv.iso15693.use_afi = 1;
746 handle->priv.iso15693.use_afi = 0;
748 case RFID_OPT_15693_AFI:
751 handle->priv.iso15693.afi = val;
759 static int transceive_inventory(struct rfid_layer2_handle *l2h)
764 static struct rfid_layer2_handle *
765 iso15693_init(struct rfid_reader_handle *rh)
768 struct rfid_layer2_handle *h = malloc_layer2_handle(sizeof(*h));
772 h->l2 = &rfid_layer2_iso15693;
774 h->priv.iso15693.state = ISO15693_STATE_NONE;
775 h->priv.iso15693.vcd_ask100 = 1; /* 100ASK is easier to generate */
776 h->priv.iso15693.vicc_two_subc = 0;
777 h->priv.iso15693.vicc_fast = 1;
778 h->priv.iso15693.single_slot = 1;
779 h->priv.iso15693.vcd_out256 = 0;
780 h->priv.iso15693.use_afi = 0; /* not all VICC support AFI */
781 h->priv.iso15693.afi = 0;
783 ret = h->rh->reader->init(h->rh, RFID_LAYER2_ISO15693);
785 free_layer2_handle(h);
793 iso15693_fini(struct rfid_layer2_handle *handle)
795 free_layer2_handle(handle);
800 const struct rfid_layer2 rfid_layer2_iso15693 = {
801 .id = RFID_LAYER2_ISO15693,
804 .init = &iso15693_init,
805 .open = &iso15693_anticol,
806 //.open = &iso15693_select,
807 //.transceive = &iso15693_transceive,
808 .close = &iso15693_stay_quiet,
809 .fini = &iso15693_fini,
810 .setopt = &iso15693_setopt,
811 .getopt = &iso15693_getopt,