All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-nfc] [PATCH v2] tag: Implement readout of tag UID via DBus interface
@ 2021-03-16 11:22 ` Schrempf Frieder
  0 siblings, 0 replies; 12+ messages in thread
From: Schrempf Frieder @ 2021-03-16 11:22 UTC (permalink / raw)
  To: linux-nfc

[-- Attachment #1: Type: text/plain, Size: 4030 bytes --]

From: Frieder Schrempf <frieder.schrempf@kontron.de>

NFC tags usually provide an unique identifier. Neard already checks
if one of the two types of identifiers is available, reads them from
tags and stores them in near_tag.nfcid or near_tag.iso15693_uid
respectively.

Though currently it is not possible for any client application to get
this information via the D-Bus interface as no property for the UID
is implemented.

This adds a 'Uid' property to the D-Bus interface for tags, which
exposes the UID of the tag as byte array. If nfcid is available this
is returned as UID, otherwise if iso15693_uid is available this is
returned. If no UID is available, no 'Uid' property is exposed.

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
Changes in v2:
* Add whitespaces after 'for' statements
* Add more details to the commit message
---
 src/tag.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 54 insertions(+), 3 deletions(-)

diff --git a/src/tag.c b/src/tag.c
index 9eba4ee..d530893 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -53,6 +53,7 @@ struct near_tag {
 	uint8_t nfcid_len;
 
 	uint8_t iso15693_dsfid;
+	uint8_t iso15693_uid_len;
 	uint8_t iso15693_uid[NFC_MAX_ISO15693_UID_LEN];
 
 	size_t data_length;
@@ -168,6 +169,29 @@ static const char *type_string(struct near_tag *tag)
 	return type;
 }
 
+static const uint8_t uid_array(struct near_tag *tag, uint8_t **uid)
+{
+	if (tag->nfcid_len) {
+		DBG("NFCID: ");
+		for (int i = 0; i < tag->nfcid_len; i++)
+			DBG("%x", tag->nfcid[i]);
+
+		*uid = tag->nfcid;
+
+		return tag->nfcid_len;
+	} else if (tag->iso15693_uid_len) {
+		DBG("ISO-UID: ");
+		for (int i = 0; i < tag->iso15693_uid_len; i++)
+			DBG("%x", tag->iso15693_uid[i]);
+
+		*uid = tag->iso15693_uid;
+
+		return tag->iso15693_uid_len;
+	}
+
+	return 0;
+}
+
 static const char *protocol_string(struct near_tag *tag)
 {
 	const char *protocol;
@@ -219,6 +243,30 @@ static gboolean property_get_type(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static gboolean property_get_uid(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *user_data)
+{
+	struct near_tag *tag = user_data;
+	DBusMessageIter entry;
+	uint8_t *uid;
+	uint8_t len;
+
+	len = uid_array(tag, &uid);
+	if (!uid || !len)
+		return FALSE;
+
+	dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+					 "{y}", &entry);
+
+	for (int i = 0; i < len; i++)
+		dbus_message_iter_append_basic(&entry, DBUS_TYPE_BYTE,
+					       (void *)&uid[i]);
+
+	dbus_message_iter_close_container(iter, &entry);
+
+	return TRUE;
+}
+
 static gboolean property_get_protocol(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *user_data)
 {
@@ -526,6 +574,7 @@ static const GDBusPropertyTable tag_properties[] = {
 	{ "Protocol", "s", property_get_protocol },
 	{ "ReadOnly", "b", property_get_readonly },
 	{ "Adapter", "o", property_get_adapter },
+	{ "Uid", "ay", property_get_uid },
 
 	{ }
 };
@@ -671,8 +720,10 @@ static int tag_initialize(struct near_tag *tag,
 	if (nfcid_len && nfcid_len <= NFC_MAX_NFCID1_LEN) {
 		tag->nfcid_len = nfcid_len;
 		memcpy(tag->nfcid, nfcid, nfcid_len);
-	} else if (iso15693_uid_len) {
+	} else if (iso15693_uid_len &&
+		   iso15693_uid_len <= NFC_MAX_ISO15693_UID_LEN) {
 		tag->iso15693_dsfid = iso15693_dsfid;
+		tag->iso15693_uid_len = iso15693_uid_len;
 		memcpy(tag->iso15693_uid, iso15693_uid, iso15693_uid_len);
 	}
 
@@ -837,11 +888,11 @@ uint8_t *near_tag_get_iso15693_uid(uint32_t adapter_idx, uint32_t target_idx)
 	if (!tag)
 		goto fail;
 
-	iso15693_uid = g_try_malloc0(NFC_MAX_ISO15693_UID_LEN);
+	iso15693_uid = g_try_malloc0(tag->iso15693_uid_len);
 	if (!iso15693_uid)
 		goto fail;
 
-	memcpy(iso15693_uid, tag->iso15693_uid, NFC_MAX_ISO15693_UID_LEN);
+	memcpy(iso15693_uid, tag->iso15693_uid, tag->iso15693_uid_len);
 
 	return iso15693_uid;
 
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2] tag: Implement readout of tag UID via DBus interface
@ 2021-03-16 11:22 ` Schrempf Frieder
  0 siblings, 0 replies; 12+ messages in thread
From: Schrempf Frieder @ 2021-03-16 11:22 UTC (permalink / raw)
  To: linux-nfc

[-- Attachment #1: Type: text/plain, Size: 4030 bytes --]

From: Frieder Schrempf <frieder.schrempf@kontron.de>

NFC tags usually provide an unique identifier. Neard already checks
if one of the two types of identifiers is available, reads them from
tags and stores them in near_tag.nfcid or near_tag.iso15693_uid
respectively.

Though currently it is not possible for any client application to get
this information via the D-Bus interface as no property for the UID
is implemented.

This adds a 'Uid' property to the D-Bus interface for tags, which
exposes the UID of the tag as byte array. If nfcid is available this
is returned as UID, otherwise if iso15693_uid is available this is
returned. If no UID is available, no 'Uid' property is exposed.

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
Changes in v2:
* Add whitespaces after 'for' statements
* Add more details to the commit message
---
 src/tag.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 54 insertions(+), 3 deletions(-)

diff --git a/src/tag.c b/src/tag.c
index 9eba4ee..d530893 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -53,6 +53,7 @@ struct near_tag {
 	uint8_t nfcid_len;
 
 	uint8_t iso15693_dsfid;
+	uint8_t iso15693_uid_len;
 	uint8_t iso15693_uid[NFC_MAX_ISO15693_UID_LEN];
 
 	size_t data_length;
@@ -168,6 +169,29 @@ static const char *type_string(struct near_tag *tag)
 	return type;
 }
 
+static const uint8_t uid_array(struct near_tag *tag, uint8_t **uid)
+{
+	if (tag->nfcid_len) {
+		DBG("NFCID: ");
+		for (int i = 0; i < tag->nfcid_len; i++)
+			DBG("%x", tag->nfcid[i]);
+
+		*uid = tag->nfcid;
+
+		return tag->nfcid_len;
+	} else if (tag->iso15693_uid_len) {
+		DBG("ISO-UID: ");
+		for (int i = 0; i < tag->iso15693_uid_len; i++)
+			DBG("%x", tag->iso15693_uid[i]);
+
+		*uid = tag->iso15693_uid;
+
+		return tag->iso15693_uid_len;
+	}
+
+	return 0;
+}
+
 static const char *protocol_string(struct near_tag *tag)
 {
 	const char *protocol;
@@ -219,6 +243,30 @@ static gboolean property_get_type(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static gboolean property_get_uid(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *user_data)
+{
+	struct near_tag *tag = user_data;
+	DBusMessageIter entry;
+	uint8_t *uid;
+	uint8_t len;
+
+	len = uid_array(tag, &uid);
+	if (!uid || !len)
+		return FALSE;
+
+	dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+					 "{y}", &entry);
+
+	for (int i = 0; i < len; i++)
+		dbus_message_iter_append_basic(&entry, DBUS_TYPE_BYTE,
+					       (void *)&uid[i]);
+
+	dbus_message_iter_close_container(iter, &entry);
+
+	return TRUE;
+}
+
 static gboolean property_get_protocol(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *user_data)
 {
@@ -526,6 +574,7 @@ static const GDBusPropertyTable tag_properties[] = {
 	{ "Protocol", "s", property_get_protocol },
 	{ "ReadOnly", "b", property_get_readonly },
 	{ "Adapter", "o", property_get_adapter },
+	{ "Uid", "ay", property_get_uid },
 
 	{ }
 };
@@ -671,8 +720,10 @@ static int tag_initialize(struct near_tag *tag,
 	if (nfcid_len && nfcid_len <= NFC_MAX_NFCID1_LEN) {
 		tag->nfcid_len = nfcid_len;
 		memcpy(tag->nfcid, nfcid, nfcid_len);
-	} else if (iso15693_uid_len) {
+	} else if (iso15693_uid_len &&
+		   iso15693_uid_len <= NFC_MAX_ISO15693_UID_LEN) {
 		tag->iso15693_dsfid = iso15693_dsfid;
+		tag->iso15693_uid_len = iso15693_uid_len;
 		memcpy(tag->iso15693_uid, iso15693_uid, iso15693_uid_len);
 	}
 
@@ -837,11 +888,11 @@ uint8_t *near_tag_get_iso15693_uid(uint32_t adapter_idx, uint32_t target_idx)
 	if (!tag)
 		goto fail;
 
-	iso15693_uid = g_try_malloc0(NFC_MAX_ISO15693_UID_LEN);
+	iso15693_uid = g_try_malloc0(tag->iso15693_uid_len);
 	if (!iso15693_uid)
 		goto fail;
 
-	memcpy(iso15693_uid, tag->iso15693_uid, NFC_MAX_ISO15693_UID_LEN);
+	memcpy(iso15693_uid, tag->iso15693_uid, tag->iso15693_uid_len);
 
 	return iso15693_uid;
 
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [linux-nfc] Re: [PATCH v2] tag: Implement readout of tag UID via DBus interface
  2021-03-16 11:22 ` Schrempf Frieder
@ 2021-03-16 18:49 ` Gottstein, Fabian
  -1 siblings, 0 replies; 12+ messages in thread
From: Gottstein, Fabian @ 2021-03-16 18:49 UTC (permalink / raw)
  To: linux-nfc

[-- Attachment #1: Type: text/plain, Size: 6654 bytes --]

Hi Frieder,

thanks for the patch.

Could you please also consider the following situation:
In the case of a NFC Tag Type 1, the identifier is delivered via the RID command (see NFC Digital Protocol). Thus, the Tag's nfcid property is updated in a later step.
To inform the neard users, a property changed signal has to be emitted when nfcid has changed (in near_tag_set_nfcid). Also, a exists() handler for the new DBus property should be implemented.

Another thing regarding building the response message:
The following code snippet could simplify and improve the readability of the usage of the dbus message builder:

dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &entry);
dbus_message_iter_append_fixed_array(&entry, DBUS_TYPE_BYTE, &uid, len);
dbus_message_iter_close_container(iter, &entry);


Best Regards
Fabian


-----Original Message-----
From: Schrempf Frieder <frieder.schrempf@kontron.de>
Sent: Dienstag, 16. März 2021 12:22
To: Samuel Ortiz <sameo@linux.intel.com>; linux-nfc@lists.01.org
Cc: Frieder Schrempf <frieder.schrempf@kontron.de>
Subject: [linux-nfc] [PATCH v2] tag: Implement readout of tag UID via DBus interface

Caution: This e-mail originated from outside of Philips, be careful for phishing.


From: Frieder Schrempf <frieder.schrempf@kontron.de>

NFC tags usually provide an unique identifier. Neard already checks if one of the two types of identifiers is available, reads them from tags and stores them in near_tag.nfcid or near_tag.iso15693_uid respectively.

Though currently it is not possible for any client application to get this information via the D-Bus interface as no property for the UID is implemented.

This adds a 'Uid' property to the D-Bus interface for tags, which exposes the UID of the tag as byte array. If nfcid is available this is returned as UID, otherwise if iso15693_uid is available this is returned. If no UID is available, no 'Uid' property is exposed.

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
Changes in v2:
* Add whitespaces after 'for' statements
* Add more details to the commit message
---
 src/tag.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 54 insertions(+), 3 deletions(-)

diff --git a/src/tag.c b/src/tag.c
index 9eba4ee..d530893 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -53,6 +53,7 @@ struct near_tag {
        uint8_t nfcid_len;

        uint8_t iso15693_dsfid;
+       uint8_t iso15693_uid_len;
        uint8_t iso15693_uid[NFC_MAX_ISO15693_UID_LEN];

        size_t data_length;
@@ -168,6 +169,29 @@ static const char *type_string(struct near_tag *tag)
        return type;
 }

+static const uint8_t uid_array(struct near_tag *tag, uint8_t **uid) {
+       if (tag->nfcid_len) {
+               DBG("NFCID: ");
+               for (int i = 0; i < tag->nfcid_len; i++)
+                       DBG("%x", tag->nfcid[i]);
+
+               *uid = tag->nfcid;
+
+               return tag->nfcid_len;
+       } else if (tag->iso15693_uid_len) {
+               DBG("ISO-UID: ");
+               for (int i = 0; i < tag->iso15693_uid_len; i++)
+                       DBG("%x", tag->iso15693_uid[i]);
+
+               *uid = tag->iso15693_uid;
+
+               return tag->iso15693_uid_len;
+       }
+
+       return 0;
+}
+
 static const char *protocol_string(struct near_tag *tag)  {
        const char *protocol;
@@ -219,6 +243,30 @@ static gboolean property_get_type(const GDBusPropertyTable *property,
        return TRUE;
 }

+static gboolean property_get_uid(const GDBusPropertyTable *property,
+                                       DBusMessageIter *iter, void
+*user_data) {
+       struct near_tag *tag = user_data;
+       DBusMessageIter entry;
+       uint8_t *uid;
+       uint8_t len;
+
+       len = uid_array(tag, &uid);
+       if (!uid || !len)
+               return FALSE;
+
+       dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+                                        "{y}", &entry);
+
+       for (int i = 0; i < len; i++)
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_BYTE,
+                                              (void *)&uid[i]);
+
+       dbus_message_iter_close_container(iter, &entry);
+
+       return TRUE;
+}
+
 static gboolean property_get_protocol(const GDBusPropertyTable *property,
                                        DBusMessageIter *iter, void *user_data)  { @@ -526,6 +574,7 @@ static const GDBusPropertyTable tag_properties[] = {
        { "Protocol", "s", property_get_protocol },
        { "ReadOnly", "b", property_get_readonly },
        { "Adapter", "o", property_get_adapter },
+       { "Uid", "ay", property_get_uid },

        { }
 };
@@ -671,8 +720,10 @@ static int tag_initialize(struct near_tag *tag,
        if (nfcid_len && nfcid_len <= NFC_MAX_NFCID1_LEN) {
                tag->nfcid_len = nfcid_len;
                memcpy(tag->nfcid, nfcid, nfcid_len);
-       } else if (iso15693_uid_len) {
+       } else if (iso15693_uid_len &&
+                  iso15693_uid_len <= NFC_MAX_ISO15693_UID_LEN) {
                tag->iso15693_dsfid = iso15693_dsfid;
+               tag->iso15693_uid_len = iso15693_uid_len;
                memcpy(tag->iso15693_uid, iso15693_uid, iso15693_uid_len);
        }

@@ -837,11 +888,11 @@ uint8_t *near_tag_get_iso15693_uid(uint32_t adapter_idx, uint32_t target_idx)
        if (!tag)
                goto fail;

-       iso15693_uid = g_try_malloc0(NFC_MAX_ISO15693_UID_LEN);
+       iso15693_uid = g_try_malloc0(tag->iso15693_uid_len);
        if (!iso15693_uid)
                goto fail;

-       memcpy(iso15693_uid, tag->iso15693_uid, NFC_MAX_ISO15693_UID_LEN);
+       memcpy(iso15693_uid, tag->iso15693_uid, tag->iso15693_uid_len);

        return iso15693_uid;

--
2.25.1
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org To unsubscribe send an email to linux-nfc-leave@lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

________________________________
The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] tag: Implement readout of tag UID via DBus interface
@ 2021-03-16 18:49 ` Gottstein, Fabian
  0 siblings, 0 replies; 12+ messages in thread
From: Gottstein, Fabian @ 2021-03-16 18:49 UTC (permalink / raw)
  To: linux-nfc

[-- Attachment #1: Type: text/plain, Size: 6660 bytes --]

Hi Frieder,

thanks for the patch.

Could you please also consider the following situation:
In the case of a NFC Tag Type 1, the identifier is delivered via the RID command (see NFC Digital Protocol). Thus, the Tag's nfcid property is updated in a later step.
To inform the neard users, a property changed signal has to be emitted when nfcid has changed (in near_tag_set_nfcid). Also, a exists() handler for the new DBus property should be implemented.

Another thing regarding building the response message:
The following code snippet could simplify and improve the readability of the usage of the dbus message builder:

dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &entry);
dbus_message_iter_append_fixed_array(&entry, DBUS_TYPE_BYTE, &uid, len);
dbus_message_iter_close_container(iter, &entry);


Best Regards
Fabian


-----Original Message-----
From: Schrempf Frieder <frieder.schrempf@kontron.de>
Sent: Dienstag, 16. März 2021 12:22
To: Samuel Ortiz <sameo@linux.intel.com>; linux-nfc(a)lists.01.org
Cc: Frieder Schrempf <frieder.schrempf@kontron.de>
Subject: [linux-nfc] [PATCH v2] tag: Implement readout of tag UID via DBus interface

Caution: This e-mail originated from outside of Philips, be careful for phishing.


From: Frieder Schrempf <frieder.schrempf@kontron.de>

NFC tags usually provide an unique identifier. Neard already checks if one of the two types of identifiers is available, reads them from tags and stores them in near_tag.nfcid or near_tag.iso15693_uid respectively.

Though currently it is not possible for any client application to get this information via the D-Bus interface as no property for the UID is implemented.

This adds a 'Uid' property to the D-Bus interface for tags, which exposes the UID of the tag as byte array. If nfcid is available this is returned as UID, otherwise if iso15693_uid is available this is returned. If no UID is available, no 'Uid' property is exposed.

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
Changes in v2:
* Add whitespaces after 'for' statements
* Add more details to the commit message
---
 src/tag.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 54 insertions(+), 3 deletions(-)

diff --git a/src/tag.c b/src/tag.c
index 9eba4ee..d530893 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -53,6 +53,7 @@ struct near_tag {
        uint8_t nfcid_len;

        uint8_t iso15693_dsfid;
+       uint8_t iso15693_uid_len;
        uint8_t iso15693_uid[NFC_MAX_ISO15693_UID_LEN];

        size_t data_length;
@@ -168,6 +169,29 @@ static const char *type_string(struct near_tag *tag)
        return type;
 }

+static const uint8_t uid_array(struct near_tag *tag, uint8_t **uid) {
+       if (tag->nfcid_len) {
+               DBG("NFCID: ");
+               for (int i = 0; i < tag->nfcid_len; i++)
+                       DBG("%x", tag->nfcid[i]);
+
+               *uid = tag->nfcid;
+
+               return tag->nfcid_len;
+       } else if (tag->iso15693_uid_len) {
+               DBG("ISO-UID: ");
+               for (int i = 0; i < tag->iso15693_uid_len; i++)
+                       DBG("%x", tag->iso15693_uid[i]);
+
+               *uid = tag->iso15693_uid;
+
+               return tag->iso15693_uid_len;
+       }
+
+       return 0;
+}
+
 static const char *protocol_string(struct near_tag *tag)  {
        const char *protocol;
@@ -219,6 +243,30 @@ static gboolean property_get_type(const GDBusPropertyTable *property,
        return TRUE;
 }

+static gboolean property_get_uid(const GDBusPropertyTable *property,
+                                       DBusMessageIter *iter, void
+*user_data) {
+       struct near_tag *tag = user_data;
+       DBusMessageIter entry;
+       uint8_t *uid;
+       uint8_t len;
+
+       len = uid_array(tag, &uid);
+       if (!uid || !len)
+               return FALSE;
+
+       dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+                                        "{y}", &entry);
+
+       for (int i = 0; i < len; i++)
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_BYTE,
+                                              (void *)&uid[i]);
+
+       dbus_message_iter_close_container(iter, &entry);
+
+       return TRUE;
+}
+
 static gboolean property_get_protocol(const GDBusPropertyTable *property,
                                        DBusMessageIter *iter, void *user_data)  { @@ -526,6 +574,7 @@ static const GDBusPropertyTable tag_properties[] = {
        { "Protocol", "s", property_get_protocol },
        { "ReadOnly", "b", property_get_readonly },
        { "Adapter", "o", property_get_adapter },
+       { "Uid", "ay", property_get_uid },

        { }
 };
@@ -671,8 +720,10 @@ static int tag_initialize(struct near_tag *tag,
        if (nfcid_len && nfcid_len <= NFC_MAX_NFCID1_LEN) {
                tag->nfcid_len = nfcid_len;
                memcpy(tag->nfcid, nfcid, nfcid_len);
-       } else if (iso15693_uid_len) {
+       } else if (iso15693_uid_len &&
+                  iso15693_uid_len <= NFC_MAX_ISO15693_UID_LEN) {
                tag->iso15693_dsfid = iso15693_dsfid;
+               tag->iso15693_uid_len = iso15693_uid_len;
                memcpy(tag->iso15693_uid, iso15693_uid, iso15693_uid_len);
        }

@@ -837,11 +888,11 @@ uint8_t *near_tag_get_iso15693_uid(uint32_t adapter_idx, uint32_t target_idx)
        if (!tag)
                goto fail;

-       iso15693_uid = g_try_malloc0(NFC_MAX_ISO15693_UID_LEN);
+       iso15693_uid = g_try_malloc0(tag->iso15693_uid_len);
        if (!iso15693_uid)
                goto fail;

-       memcpy(iso15693_uid, tag->iso15693_uid, NFC_MAX_ISO15693_UID_LEN);
+       memcpy(iso15693_uid, tag->iso15693_uid, tag->iso15693_uid_len);

        return iso15693_uid;

--
2.25.1
_______________________________________________
Linux-nfc mailing list -- linux-nfc(a)lists.01.org To unsubscribe send an email to linux-nfc-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

________________________________
The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [linux-nfc] Re: [PATCH v2] tag: Implement readout of tag UID via DBus interface
       [not found] ` <AM0P122MB011340CE87F73F55335D040C826B9@AM0P122MB0113.EURP122.PROD.OUTLOOK.COM>
@ 2021-03-18 16:14     ` Frieder Schrempf
  0 siblings, 0 replies; 12+ messages in thread
From: Frieder Schrempf @ 2021-03-18 16:14 UTC (permalink / raw)
  To: linux-nfc

[-- Attachment #1: Type: text/plain, Size: 7570 bytes --]

Hi Fabian,

On 16.03.21 19:49, Gottstein, Fabian wrote:
> Hi Frieder,
> 
> thanks for the patch.

thanks for your feedback.

> 
> Could you please also consider the following situation:
> In the case of a NFC Tag Type 1, the identifier is delivered via the RID command (see NFC Digital Protocol). Thus, the Tag's nfcid property is updated in a later step.
> To inform the neard users, a property changed signal has to be emitted when nfcid has changed (in near_tag_set_nfcid). Also, a exists() handler for the new DBus property should be implemented.

I'm new to NFC and D-Bus, so I don't know much about what use-cases and 
requirements there are.

Your request sounds reasonable and I think I have a rough understanding 
of what is probably needed to implement this. Still to actually do this 
I need to look@the specifications and the code more closely and I 
don't know if/when I will find time to do this.

Also I don't have any hardware to test this with NFC type 1 tags.

> 
> Another thing regarding building the response message:
> The following code snippet could simplify and improve the readability of the usage of the dbus message builder:
> 
> dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &entry);
> dbus_message_iter_append_fixed_array(&entry, DBUS_TYPE_BYTE, &uid, len);
> dbus_message_iter_close_container(iter, &entry);
> 
Thanks for the improved code, I will use this instead.

Frieder

> 
> 
> -----Original Message-----
> From: Schrempf Frieder <frieder.schrempf@kontron.de>
> Sent: Dienstag, 16. März 2021 12:22
> To: Samuel Ortiz <sameo@linux.intel.com>; linux-nfc@lists.01.org
> Cc: Frieder Schrempf <frieder.schrempf@kontron.de>
> Subject: [linux-nfc] [PATCH v2] tag: Implement readout of tag UID via DBus interface
> 
> Caution: This e-mail originated from outside of Philips, be careful for phishing.
> 
> 
> From: Frieder Schrempf <frieder.schrempf@kontron.de>
> 
> NFC tags usually provide an unique identifier. Neard already checks if one of the two types of identifiers is available, reads them from tags and stores them in near_tag.nfcid or near_tag.iso15693_uid respectively.
> 
> Though currently it is not possible for any client application to get this information via the D-Bus interface as no property for the UID is implemented.
> 
> This adds a 'Uid' property to the D-Bus interface for tags, which exposes the UID of the tag as byte array. If nfcid is available this is returned as UID, otherwise if iso15693_uid is available this is returned. If no UID is available, no 'Uid' property is exposed.
> 
> Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> ---
> Changes in v2:
> * Add whitespaces after 'for' statements
> * Add more details to the commit message
> ---
>   src/tag.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
>   1 file changed, 54 insertions(+), 3 deletions(-)
> 
> diff --git a/src/tag.c b/src/tag.c
> index 9eba4ee..d530893 100644
> --- a/src/tag.c
> +++ b/src/tag.c
> @@ -53,6 +53,7 @@ struct near_tag {
>          uint8_t nfcid_len;
> 
>          uint8_t iso15693_dsfid;
> +       uint8_t iso15693_uid_len;
>          uint8_t iso15693_uid[NFC_MAX_ISO15693_UID_LEN];
> 
>          size_t data_length;
> @@ -168,6 +169,29 @@ static const char *type_string(struct near_tag *tag)
>          return type;
>   }
> 
> +static const uint8_t uid_array(struct near_tag *tag, uint8_t **uid) {
> +       if (tag->nfcid_len) {
> +               DBG("NFCID: ");
> +               for (int i = 0; i < tag->nfcid_len; i++)
> +                       DBG("%x", tag->nfcid[i]);
> +
> +               *uid = tag->nfcid;
> +
> +               return tag->nfcid_len;
> +       } else if (tag->iso15693_uid_len) {
> +               DBG("ISO-UID: ");
> +               for (int i = 0; i < tag->iso15693_uid_len; i++)
> +                       DBG("%x", tag->iso15693_uid[i]);
> +
> +               *uid = tag->iso15693_uid;
> +
> +               return tag->iso15693_uid_len;
> +       }
> +
> +       return 0;
> +}
> +
>   static const char *protocol_string(struct near_tag *tag)  {
>          const char *protocol;
> @@ -219,6 +243,30 @@ static gboolean property_get_type(const GDBusPropertyTable *property,
>          return TRUE;
>   }
> 
> +static gboolean property_get_uid(const GDBusPropertyTable *property,
> +                                       DBusMessageIter *iter, void
> +*user_data) {
> +       struct near_tag *tag = user_data;
> +       DBusMessageIter entry;
> +       uint8_t *uid;
> +       uint8_t len;
> +
> +       len = uid_array(tag, &uid);
> +       if (!uid || !len)
> +               return FALSE;
> +
> +       dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
> +                                        "{y}", &entry);
> +
> +       for (int i = 0; i < len; i++)
> +               dbus_message_iter_append_basic(&entry, DBUS_TYPE_BYTE,
> +                                              (void *)&uid[i]);
> +
> +       dbus_message_iter_close_container(iter, &entry);
> +
> +       return TRUE;
> +}
> +
>   static gboolean property_get_protocol(const GDBusPropertyTable *property,
>                                          DBusMessageIter *iter, void *user_data)  { @@ -526,6 +574,7 @@ static const GDBusPropertyTable tag_properties[] = {
>          { "Protocol", "s", property_get_protocol },
>          { "ReadOnly", "b", property_get_readonly },
>          { "Adapter", "o", property_get_adapter },
> +       { "Uid", "ay", property_get_uid },
> 
>          { }
>   };
> @@ -671,8 +720,10 @@ static int tag_initialize(struct near_tag *tag,
>          if (nfcid_len && nfcid_len <= NFC_MAX_NFCID1_LEN) {
>                  tag->nfcid_len = nfcid_len;
>                  memcpy(tag->nfcid, nfcid, nfcid_len);
> -       } else if (iso15693_uid_len) {
> +       } else if (iso15693_uid_len &&
> +                  iso15693_uid_len <= NFC_MAX_ISO15693_UID_LEN) {
>                  tag->iso15693_dsfid = iso15693_dsfid;
> +               tag->iso15693_uid_len = iso15693_uid_len;
>                  memcpy(tag->iso15693_uid, iso15693_uid, iso15693_uid_len);
>          }
> 
> @@ -837,11 +888,11 @@ uint8_t *near_tag_get_iso15693_uid(uint32_t adapter_idx, uint32_t target_idx)
>          if (!tag)
>                  goto fail;
> 
> -       iso15693_uid = g_try_malloc0(NFC_MAX_ISO15693_UID_LEN);
> +       iso15693_uid = g_try_malloc0(tag->iso15693_uid_len);
>          if (!iso15693_uid)
>                  goto fail;
> 
> -       memcpy(iso15693_uid, tag->iso15693_uid, NFC_MAX_ISO15693_UID_LEN);
> +       memcpy(iso15693_uid, tag->iso15693_uid, tag->iso15693_uid_len);
> 
>          return iso15693_uid;
> 
> --
> 2.25.1
> _______________________________________________
> Linux-nfc mailing list -- linux-nfc@lists.01.org To unsubscribe send an email to linux-nfc-leave@lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
> 
> ________________________________
> The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] tag: Implement readout of tag UID via DBus interface
@ 2021-03-18 16:14     ` Frieder Schrempf
  0 siblings, 0 replies; 12+ messages in thread
From: Frieder Schrempf @ 2021-03-18 16:14 UTC (permalink / raw)
  To: linux-nfc

[-- Attachment #1: Type: text/plain, Size: 7579 bytes --]

Hi Fabian,

On 16.03.21 19:49, Gottstein, Fabian wrote:
> Hi Frieder,
> 
> thanks for the patch.

thanks for your feedback.

> 
> Could you please also consider the following situation:
> In the case of a NFC Tag Type 1, the identifier is delivered via the RID command (see NFC Digital Protocol). Thus, the Tag's nfcid property is updated in a later step.
> To inform the neard users, a property changed signal has to be emitted when nfcid has changed (in near_tag_set_nfcid). Also, a exists() handler for the new DBus property should be implemented.

I'm new to NFC and D-Bus, so I don't know much about what use-cases and 
requirements there are.

Your request sounds reasonable and I think I have a rough understanding 
of what is probably needed to implement this. Still to actually do this 
I need to look at the specifications and the code more closely and I 
don't know if/when I will find time to do this.

Also I don't have any hardware to test this with NFC type 1 tags.

> 
> Another thing regarding building the response message:
> The following code snippet could simplify and improve the readability of the usage of the dbus message builder:
> 
> dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &entry);
> dbus_message_iter_append_fixed_array(&entry, DBUS_TYPE_BYTE, &uid, len);
> dbus_message_iter_close_container(iter, &entry);
> 
Thanks for the improved code, I will use this instead.

Frieder

> 
> 
> -----Original Message-----
> From: Schrempf Frieder <frieder.schrempf@kontron.de>
> Sent: Dienstag, 16. März 2021 12:22
> To: Samuel Ortiz <sameo@linux.intel.com>; linux-nfc(a)lists.01.org
> Cc: Frieder Schrempf <frieder.schrempf@kontron.de>
> Subject: [linux-nfc] [PATCH v2] tag: Implement readout of tag UID via DBus interface
> 
> Caution: This e-mail originated from outside of Philips, be careful for phishing.
> 
> 
> From: Frieder Schrempf <frieder.schrempf@kontron.de>
> 
> NFC tags usually provide an unique identifier. Neard already checks if one of the two types of identifiers is available, reads them from tags and stores them in near_tag.nfcid or near_tag.iso15693_uid respectively.
> 
> Though currently it is not possible for any client application to get this information via the D-Bus interface as no property for the UID is implemented.
> 
> This adds a 'Uid' property to the D-Bus interface for tags, which exposes the UID of the tag as byte array. If nfcid is available this is returned as UID, otherwise if iso15693_uid is available this is returned. If no UID is available, no 'Uid' property is exposed.
> 
> Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> ---
> Changes in v2:
> * Add whitespaces after 'for' statements
> * Add more details to the commit message
> ---
>   src/tag.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
>   1 file changed, 54 insertions(+), 3 deletions(-)
> 
> diff --git a/src/tag.c b/src/tag.c
> index 9eba4ee..d530893 100644
> --- a/src/tag.c
> +++ b/src/tag.c
> @@ -53,6 +53,7 @@ struct near_tag {
>          uint8_t nfcid_len;
> 
>          uint8_t iso15693_dsfid;
> +       uint8_t iso15693_uid_len;
>          uint8_t iso15693_uid[NFC_MAX_ISO15693_UID_LEN];
> 
>          size_t data_length;
> @@ -168,6 +169,29 @@ static const char *type_string(struct near_tag *tag)
>          return type;
>   }
> 
> +static const uint8_t uid_array(struct near_tag *tag, uint8_t **uid) {
> +       if (tag->nfcid_len) {
> +               DBG("NFCID: ");
> +               for (int i = 0; i < tag->nfcid_len; i++)
> +                       DBG("%x", tag->nfcid[i]);
> +
> +               *uid = tag->nfcid;
> +
> +               return tag->nfcid_len;
> +       } else if (tag->iso15693_uid_len) {
> +               DBG("ISO-UID: ");
> +               for (int i = 0; i < tag->iso15693_uid_len; i++)
> +                       DBG("%x", tag->iso15693_uid[i]);
> +
> +               *uid = tag->iso15693_uid;
> +
> +               return tag->iso15693_uid_len;
> +       }
> +
> +       return 0;
> +}
> +
>   static const char *protocol_string(struct near_tag *tag)  {
>          const char *protocol;
> @@ -219,6 +243,30 @@ static gboolean property_get_type(const GDBusPropertyTable *property,
>          return TRUE;
>   }
> 
> +static gboolean property_get_uid(const GDBusPropertyTable *property,
> +                                       DBusMessageIter *iter, void
> +*user_data) {
> +       struct near_tag *tag = user_data;
> +       DBusMessageIter entry;
> +       uint8_t *uid;
> +       uint8_t len;
> +
> +       len = uid_array(tag, &uid);
> +       if (!uid || !len)
> +               return FALSE;
> +
> +       dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
> +                                        "{y}", &entry);
> +
> +       for (int i = 0; i < len; i++)
> +               dbus_message_iter_append_basic(&entry, DBUS_TYPE_BYTE,
> +                                              (void *)&uid[i]);
> +
> +       dbus_message_iter_close_container(iter, &entry);
> +
> +       return TRUE;
> +}
> +
>   static gboolean property_get_protocol(const GDBusPropertyTable *property,
>                                          DBusMessageIter *iter, void *user_data)  { @@ -526,6 +574,7 @@ static const GDBusPropertyTable tag_properties[] = {
>          { "Protocol", "s", property_get_protocol },
>          { "ReadOnly", "b", property_get_readonly },
>          { "Adapter", "o", property_get_adapter },
> +       { "Uid", "ay", property_get_uid },
> 
>          { }
>   };
> @@ -671,8 +720,10 @@ static int tag_initialize(struct near_tag *tag,
>          if (nfcid_len && nfcid_len <= NFC_MAX_NFCID1_LEN) {
>                  tag->nfcid_len = nfcid_len;
>                  memcpy(tag->nfcid, nfcid, nfcid_len);
> -       } else if (iso15693_uid_len) {
> +       } else if (iso15693_uid_len &&
> +                  iso15693_uid_len <= NFC_MAX_ISO15693_UID_LEN) {
>                  tag->iso15693_dsfid = iso15693_dsfid;
> +               tag->iso15693_uid_len = iso15693_uid_len;
>                  memcpy(tag->iso15693_uid, iso15693_uid, iso15693_uid_len);
>          }
> 
> @@ -837,11 +888,11 @@ uint8_t *near_tag_get_iso15693_uid(uint32_t adapter_idx, uint32_t target_idx)
>          if (!tag)
>                  goto fail;
> 
> -       iso15693_uid = g_try_malloc0(NFC_MAX_ISO15693_UID_LEN);
> +       iso15693_uid = g_try_malloc0(tag->iso15693_uid_len);
>          if (!iso15693_uid)
>                  goto fail;
> 
> -       memcpy(iso15693_uid, tag->iso15693_uid, NFC_MAX_ISO15693_UID_LEN);
> +       memcpy(iso15693_uid, tag->iso15693_uid, tag->iso15693_uid_len);
> 
>          return iso15693_uid;
> 
> --
> 2.25.1
> _______________________________________________
> Linux-nfc mailing list -- linux-nfc(a)lists.01.org To unsubscribe send an email to linux-nfc-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
> 
> ________________________________
> The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [linux-nfc] Re: [PATCH v2] tag: Implement readout of tag UID via DBus interface
  2021-03-18 16:14     ` Frieder Schrempf
@ 2021-08-08  1:55       ` Mark Greer
  -1 siblings, 0 replies; 12+ messages in thread
From: Mark Greer @ 2021-08-08  1:55 UTC (permalink / raw)
  To: Frieder Schrempf; +Cc: linux-nfc

On Thu, Mar 18, 2021 at 05:14:35PM +0100, Frieder Schrempf wrote:
> Hi Fabian,
> 
> On 16.03.21 19:49, Gottstein, Fabian wrote:
> > Hi Frieder,
> > 
> > thanks for the patch.
> 
> thanks for your feedback.
> 
> > 
> > Could you please also consider the following situation:
> > In the case of a NFC Tag Type 1, the identifier is delivered via the RID command (see NFC Digital Protocol). Thus, the Tag's nfcid property is updated in a later step.
> > To inform the neard users, a property changed signal has to be emitted when nfcid has changed (in near_tag_set_nfcid). Also, a exists() handler for the new DBus property should be implemented.
> 
> I'm new to NFC and D-Bus, so I don't know much about what use-cases and
> requirements there are.
> 
> Your request sounds reasonable and I think I have a rough understanding of
> what is probably needed to implement this. Still to actually do this I need
> to look at the specifications and the code more closely and I don't know
> if/when I will find time to do this.
> 
> Also I don't have any hardware to test this with NFC type 1 tags.
> 
> > 
> > Another thing regarding building the response message:
> > The following code snippet could simplify and improve the readability of the usage of the dbus message builder:
> > 
> > dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &entry);
> > dbus_message_iter_append_fixed_array(&entry, DBUS_TYPE_BYTE, &uid, len);
> > dbus_message_iter_close_container(iter, &entry);
> > 
> Thanks for the improved code, I will use this instead.
> 
> Frieder

Hi Frieder.

Do you have an updated version of this patch (or did I miss it)?

Thanks,

Mark
--
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] tag: Implement readout of tag UID via DBus interface
@ 2021-08-08  1:55       ` Mark Greer
  0 siblings, 0 replies; 12+ messages in thread
From: Mark Greer @ 2021-08-08  1:55 UTC (permalink / raw)
  To: linux-nfc

[-- Attachment #1: Type: text/plain, Size: 1717 bytes --]

On Thu, Mar 18, 2021 at 05:14:35PM +0100, Frieder Schrempf wrote:
> Hi Fabian,
> 
> On 16.03.21 19:49, Gottstein, Fabian wrote:
> > Hi Frieder,
> > 
> > thanks for the patch.
> 
> thanks for your feedback.
> 
> > 
> > Could you please also consider the following situation:
> > In the case of a NFC Tag Type 1, the identifier is delivered via the RID command (see NFC Digital Protocol). Thus, the Tag's nfcid property is updated in a later step.
> > To inform the neard users, a property changed signal has to be emitted when nfcid has changed (in near_tag_set_nfcid). Also, a exists() handler for the new DBus property should be implemented.
> 
> I'm new to NFC and D-Bus, so I don't know much about what use-cases and
> requirements there are.
> 
> Your request sounds reasonable and I think I have a rough understanding of
> what is probably needed to implement this. Still to actually do this I need
> to look at the specifications and the code more closely and I don't know
> if/when I will find time to do this.
> 
> Also I don't have any hardware to test this with NFC type 1 tags.
> 
> > 
> > Another thing regarding building the response message:
> > The following code snippet could simplify and improve the readability of the usage of the dbus message builder:
> > 
> > dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &entry);
> > dbus_message_iter_append_fixed_array(&entry, DBUS_TYPE_BYTE, &uid, len);
> > dbus_message_iter_close_container(iter, &entry);
> > 
> Thanks for the improved code, I will use this instead.
> 
> Frieder

Hi Frieder.

Do you have an updated version of this patch (or did I miss it)?

Thanks,

Mark
--

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [linux-nfc] Re: [PATCH v2] tag: Implement readout of tag UID via DBus interface
  2021-08-08  1:55       ` Mark Greer
@ 2021-08-10  9:58         ` Frieder Schrempf
  -1 siblings, 0 replies; 12+ messages in thread
From: Frieder Schrempf @ 2021-08-10  9:58 UTC (permalink / raw)
  To: Mark Greer; +Cc: linux-nfc

On 08.08.21 03:55, Mark Greer wrote:
> On Thu, Mar 18, 2021 at 05:14:35PM +0100, Frieder Schrempf wrote:
>> Hi Fabian,
>>
>> On 16.03.21 19:49, Gottstein, Fabian wrote:
>>> Hi Frieder,
>>>
>>> thanks for the patch.
>>
>> thanks for your feedback.
>>
>>>
>>> Could you please also consider the following situation:
>>> In the case of a NFC Tag Type 1, the identifier is delivered via the RID command (see NFC Digital Protocol). Thus, the Tag's nfcid property is updated in a later step.
>>> To inform the neard users, a property changed signal has to be emitted when nfcid has changed (in near_tag_set_nfcid). Also, a exists() handler for the new DBus property should be implemented.
>>
>> I'm new to NFC and D-Bus, so I don't know much about what use-cases and
>> requirements there are.
>>
>> Your request sounds reasonable and I think I have a rough understanding of
>> what is probably needed to implement this. Still to actually do this I need
>> to look at the specifications and the code more closely and I don't know
>> if/when I will find time to do this.
>>
>> Also I don't have any hardware to test this with NFC type 1 tags.
>>
>>>
>>> Another thing regarding building the response message:
>>> The following code snippet could simplify and improve the readability of the usage of the dbus message builder:
>>>
>>> dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &entry);
>>> dbus_message_iter_append_fixed_array(&entry, DBUS_TYPE_BYTE, &uid, len);
>>> dbus_message_iter_close_container(iter, &entry);
>>>
>> Thanks for the improved code, I will use this instead.
>>
>> Frieder
> 
> Hi Frieder.
> 
> Do you have an updated version of this patch (or did I miss it)?

No, unfortunately not. I implemented this fix for a project that is now discontinued. I can try to find some time in my spare time to implement at least Fabian's code improvement suggestion. But I don't know if it makes sense to upstream this without the changes Fabian suggested in regard to NFC Tag Type 1 and I currently have neither time to dig into this, nor hardware to test it.

_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] tag: Implement readout of tag UID via DBus interface
@ 2021-08-10  9:58         ` Frieder Schrempf
  0 siblings, 0 replies; 12+ messages in thread
From: Frieder Schrempf @ 2021-08-10  9:58 UTC (permalink / raw)
  To: linux-nfc

[-- Attachment #1: Type: text/plain, Size: 2141 bytes --]

On 08.08.21 03:55, Mark Greer wrote:
> On Thu, Mar 18, 2021 at 05:14:35PM +0100, Frieder Schrempf wrote:
>> Hi Fabian,
>>
>> On 16.03.21 19:49, Gottstein, Fabian wrote:
>>> Hi Frieder,
>>>
>>> thanks for the patch.
>>
>> thanks for your feedback.
>>
>>>
>>> Could you please also consider the following situation:
>>> In the case of a NFC Tag Type 1, the identifier is delivered via the RID command (see NFC Digital Protocol). Thus, the Tag's nfcid property is updated in a later step.
>>> To inform the neard users, a property changed signal has to be emitted when nfcid has changed (in near_tag_set_nfcid). Also, a exists() handler for the new DBus property should be implemented.
>>
>> I'm new to NFC and D-Bus, so I don't know much about what use-cases and
>> requirements there are.
>>
>> Your request sounds reasonable and I think I have a rough understanding of
>> what is probably needed to implement this. Still to actually do this I need
>> to look at the specifications and the code more closely and I don't know
>> if/when I will find time to do this.
>>
>> Also I don't have any hardware to test this with NFC type 1 tags.
>>
>>>
>>> Another thing regarding building the response message:
>>> The following code snippet could simplify and improve the readability of the usage of the dbus message builder:
>>>
>>> dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &entry);
>>> dbus_message_iter_append_fixed_array(&entry, DBUS_TYPE_BYTE, &uid, len);
>>> dbus_message_iter_close_container(iter, &entry);
>>>
>> Thanks for the improved code, I will use this instead.
>>
>> Frieder
> 
> Hi Frieder.
> 
> Do you have an updated version of this patch (or did I miss it)?

No, unfortunately not. I implemented this fix for a project that is now discontinued. I can try to find some time in my spare time to implement at least Fabian's code improvement suggestion. But I don't know if it makes sense to upstream this without the changes Fabian suggested in regard to NFC Tag Type 1 and I currently have neither time to dig into this, nor hardware to test it.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [linux-nfc] Re: [PATCH v2] tag: Implement readout of tag UID via DBus interface
  2021-08-10  9:58         ` Frieder Schrempf
@ 2021-08-20 15:31           ` Mark Greer
  -1 siblings, 0 replies; 12+ messages in thread
From: Mark Greer @ 2021-08-20 15:31 UTC (permalink / raw)
  To: Frieder Schrempf; +Cc: linux-nfc

On Tue, Aug 10, 2021 at 11:58:31AM +0200, Frieder Schrempf wrote:
> On 08.08.21 03:55, Mark Greer wrote:
> > On Thu, Mar 18, 2021 at 05:14:35PM +0100, Frieder Schrempf wrote:
> >> Hi Fabian,
> >>
> >> On 16.03.21 19:49, Gottstein, Fabian wrote:
> >>> Hi Frieder,
> >>>
> >>> thanks for the patch.
> >>
> >> thanks for your feedback.
> >>
> >>>
> >>> Could you please also consider the following situation:
> >>> In the case of a NFC Tag Type 1, the identifier is delivered via the RID command (see NFC Digital Protocol). Thus, the Tag's nfcid property is updated in a later step.
> >>> To inform the neard users, a property changed signal has to be emitted when nfcid has changed (in near_tag_set_nfcid). Also, a exists() handler for the new DBus property should be implemented.
> >>
> >> I'm new to NFC and D-Bus, so I don't know much about what use-cases and
> >> requirements there are.
> >>
> >> Your request sounds reasonable and I think I have a rough understanding of
> >> what is probably needed to implement this. Still to actually do this I need
> >> to look at the specifications and the code more closely and I don't know
> >> if/when I will find time to do this.
> >>
> >> Also I don't have any hardware to test this with NFC type 1 tags.
> >>
> >>>
> >>> Another thing regarding building the response message:
> >>> The following code snippet could simplify and improve the readability of the usage of the dbus message builder:
> >>>
> >>> dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &entry);
> >>> dbus_message_iter_append_fixed_array(&entry, DBUS_TYPE_BYTE, &uid, len);
> >>> dbus_message_iter_close_container(iter, &entry);
> >>>
> >> Thanks for the improved code, I will use this instead.
> >>
> >> Frieder
> > 
> > Hi Frieder.
> > 
> > Do you have an updated version of this patch (or did I miss it)?
> 
> No, unfortunately not. I implemented this fix for a project that is now discontinued. I can try to find some time in my spare time to implement at least Fabian's code improvement suggestion. But I don't know if it makes sense to upstream this without the changes Fabian suggested in regard to NFC Tag Type 1 and I currently have neither time to dig into this, nor hardware to test it.

Okay, no problem.

Mark
--
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] tag: Implement readout of tag UID via DBus interface
@ 2021-08-20 15:31           ` Mark Greer
  0 siblings, 0 replies; 12+ messages in thread
From: Mark Greer @ 2021-08-20 15:31 UTC (permalink / raw)
  To: linux-nfc

[-- Attachment #1: Type: text/plain, Size: 2323 bytes --]

On Tue, Aug 10, 2021 at 11:58:31AM +0200, Frieder Schrempf wrote:
> On 08.08.21 03:55, Mark Greer wrote:
> > On Thu, Mar 18, 2021 at 05:14:35PM +0100, Frieder Schrempf wrote:
> >> Hi Fabian,
> >>
> >> On 16.03.21 19:49, Gottstein, Fabian wrote:
> >>> Hi Frieder,
> >>>
> >>> thanks for the patch.
> >>
> >> thanks for your feedback.
> >>
> >>>
> >>> Could you please also consider the following situation:
> >>> In the case of a NFC Tag Type 1, the identifier is delivered via the RID command (see NFC Digital Protocol). Thus, the Tag's nfcid property is updated in a later step.
> >>> To inform the neard users, a property changed signal has to be emitted when nfcid has changed (in near_tag_set_nfcid). Also, a exists() handler for the new DBus property should be implemented.
> >>
> >> I'm new to NFC and D-Bus, so I don't know much about what use-cases and
> >> requirements there are.
> >>
> >> Your request sounds reasonable and I think I have a rough understanding of
> >> what is probably needed to implement this. Still to actually do this I need
> >> to look at the specifications and the code more closely and I don't know
> >> if/when I will find time to do this.
> >>
> >> Also I don't have any hardware to test this with NFC type 1 tags.
> >>
> >>>
> >>> Another thing regarding building the response message:
> >>> The following code snippet could simplify and improve the readability of the usage of the dbus message builder:
> >>>
> >>> dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &entry);
> >>> dbus_message_iter_append_fixed_array(&entry, DBUS_TYPE_BYTE, &uid, len);
> >>> dbus_message_iter_close_container(iter, &entry);
> >>>
> >> Thanks for the improved code, I will use this instead.
> >>
> >> Frieder
> > 
> > Hi Frieder.
> > 
> > Do you have an updated version of this patch (or did I miss it)?
> 
> No, unfortunately not. I implemented this fix for a project that is now discontinued. I can try to find some time in my spare time to implement at least Fabian's code improvement suggestion. But I don't know if it makes sense to upstream this without the changes Fabian suggested in regard to NFC Tag Type 1 and I currently have neither time to dig into this, nor hardware to test it.

Okay, no problem.

Mark
--

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-08-20 15:31 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 18:49 [linux-nfc] Re: [PATCH v2] tag: Implement readout of tag UID via DBus interface Gottstein, Fabian
2021-03-16 18:49 ` Gottstein, Fabian
  -- strict thread matches above, loose matches on Subject: below --
2021-03-16 11:22 [linux-nfc] " Schrempf Frieder
2021-03-16 11:22 ` Schrempf Frieder
     [not found] ` <AM0P122MB011340CE87F73F55335D040C826B9@AM0P122MB0113.EURP122.PROD.OUTLOOK.COM>
2021-03-18 16:14   ` [linux-nfc] " Frieder Schrempf
2021-03-18 16:14     ` Frieder Schrempf
2021-08-08  1:55     ` [linux-nfc] " Mark Greer
2021-08-08  1:55       ` Mark Greer
2021-08-10  9:58       ` [linux-nfc] " Frieder Schrempf
2021-08-10  9:58         ` Frieder Schrempf
2021-08-20 15:31         ` [linux-nfc] " Mark Greer
2021-08-20 15:31           ` Mark Greer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.