aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Greer <mgreer@animalcreek.com>2017-06-12 16:05:27 -0700
committerSamuel Ortiz <sameo@linux.intel.com>2017-11-10 00:23:57 +0100
commit92316a87f782d3710da1dc4ced632394e5921677 (patch)
tree3ce7228bdf0f4135a8427d0475fe3350eb750f55
parent37cf1d4e312a92642f4fbaff81686b0475e575f1 (diff)
downloadneard-92316a87f782d3710da1dc4ced632394e5921677.tar.gz
nfctype5: Add support for TI Standard and Pro Type 5 tag
Standard and Pro Type 5 tags from Texas Instruments do not support the Get System Information command which means they cannot be read with the current neard code. Fortunately, both types of tags have eight, 4-byte blocks so that information can be filled in instead of issuing the Get System Information command to get it. With this change, Standard and Pro tags can now be formatted, read, and written. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
-rw-r--r--plugins/nfctype5.c61
1 files changed, 59 insertions, 2 deletions
diff --git a/plugins/nfctype5.c b/plugins/nfctype5.c
index 689dec3..f26d8fa 100644
--- a/plugins/nfctype5.c
+++ b/plugins/nfctype5.c
@@ -117,6 +117,7 @@
#define TYPE5_UID_MANUFAC_IDX 0x06
#define TYPE5_UID_MANUFAC_ID_STMICRO 0x02
+#define TYPE5_UID_MANUFAC_ID_TI 0x07
struct type5_cmd_hdr {
uint8_t flags;
@@ -217,6 +218,49 @@ static bool t5_manufacturer_is_stmicro(struct near_tag *tag)
return t5_manufacturer_is(tag, TYPE5_UID_MANUFAC_ID_STMICRO);
}
+static bool t5_manufacturer_is_ti(struct near_tag *tag)
+{
+ return t5_manufacturer_is(tag, TYPE5_UID_MANUFAC_ID_TI);
+}
+
+static bool t5_tag_is_ti_std(struct near_tag *tag)
+{
+ uint8_t *uid;
+ bool ret = false;
+
+ uid = near_tag_get_iso15693_uid(near_tag_get_adapter_idx(tag),
+ near_tag_get_target_idx(tag));
+ if (!uid) {
+ near_error("No type 5 UID");
+ return false;
+ }
+
+ if ((uid[5] == 0xc0) || (uid[5] == 0xc1))
+ ret = true;
+
+ g_free(uid);
+ return ret;
+}
+
+static bool t5_tag_is_ti_pro(struct near_tag *tag)
+{
+ uint8_t *uid;
+ bool ret;
+
+ uid = near_tag_get_iso15693_uid(near_tag_get_adapter_idx(tag),
+ near_tag_get_target_idx(tag));
+ if (!uid) {
+ near_error("No type 5 UID");
+ return false;
+ }
+
+ if ((uid[5] == 0xc4) || (uid[5] == 0xc5))
+ ret = true;
+
+ g_free(uid);
+ return ret;
+}
+
static int t5_cmd_hdr_init(struct near_tag *tag, struct type5_cmd_hdr *cmd_hdr,
int cmd)
{
@@ -851,10 +895,23 @@ static int nfctype5_read(uint32_t adapter_idx, uint32_t target_idx,
* num_blks once. near_tag_get_blk_size() will return 0 if
* t5_get_sys_info() hasn't been called yet.
*/
- if (near_tag_get_blk_size(tag))
+ if (near_tag_get_blk_size(tag)) {
err = t5_read_meta(tag, cookie);
- else
+ } else if (t5_manufacturer_is_ti(tag) &&
+ (t5_tag_is_ti_std(tag) || t5_tag_is_ti_pro(tag))) {
+ /*
+ * TI Standard and Pro tags do not support the Get System
+ * Information command but are known to have eight, 4-byte
+ * blocks so we can fill that info in and call t5_read_meta()
+ * here.
+ */
+ near_tag_set_blk_size(tag, 4);
+ near_tag_set_num_blks(tag, 8);
+
+ err = t5_read_meta(tag, cookie);
+ } else {
err = t5_get_sys_info(tag, cookie);
+ }
if (err < 0)
err = t5_cookie_release(err, cookie);