From 852829c4ab597ce137bac4bb9b612fd57b1dd282 Mon Sep 17 00:00:00 2001 From: laforge Date: Sat, 22 Oct 2005 18:12:48 +0000 Subject: add convenience functions to set lock bits git-svn-id: https://svn.gnumonks.org/trunk/librfid@1553 e0336214-984f-0b4b-a45f-81c69e1f0ede --- openct-escape.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'openct-escape.c') diff --git a/openct-escape.c b/openct-escape.c index ecdb2d9..7085fc7 100644 --- a/openct-escape.c +++ b/openct-escape.c @@ -236,6 +236,28 @@ iso7816_read_ef(u_int16_t fid, unsigned char *buf, unsigned int *len) return iso7816_read_binary(buf, len); } +int +mifare_ulight_write(struct rfid_protocol_handle *ph) +{ + unsigned char buf[4] = { 0xa1, 0xa2, 0xa3, 0xa4 }; + + return rfid_protocol_write(ph, 20, buf, 4); +} + +int +mifare_ulight_blank(struct rfid_protocol_handle *ph) +{ + unsigned char buf[4] = { 0x00, 0x00, 0x00, 0x00 }; + int i, ret; + + for (i = 4; i <= MIFARE_UL_PAGE_MAX; i++) { + ret = rfid_protocol_write(ph, i, buf, 4); + if (ret < 0) + return ret; + } + return 0; +} + int mifare_ulight_read(struct rfid_protocol_handle *ph) { @@ -244,7 +266,7 @@ mifare_ulight_read(struct rfid_protocol_handle *ph) int ret; int i; - for (i = 0; i < 7; i++) { + for (i = 0; i <= MIFARE_UL_PAGE_MAX; i++) { ret = rfid_protocol_read(ph, i, buf, &len); if (ret < 0) return ret; @@ -264,7 +286,7 @@ int main(int argc, char **argv) exit(1); protocol = RFID_PROTOCOL_MIFARE_UL; - protocol = RFID_PROTOCOL_TCL; +// protocol = RFID_PROTOCOL_TCL; if (l3(protocol) < 0) exit(1); @@ -286,6 +308,9 @@ int main(int argc, char **argv) #endif break; case RFID_PROTOCOL_MIFARE_UL: + mifare_ulight_read(ph); + //mifare_ulight_blank(ph); + mifare_ulight_write(ph); mifare_ulight_read(ph); break; } -- cgit v1.2.3