summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2018-12-16 21:55:05 -0500
committerScott Murray <scott.murray@konsulko.com>2018-12-16 21:55:05 -0500
commit025f9e643da7272123fb94fdf37d4284a356c4fe (patch)
tree4646ff2bb192f712bd7be57862ac53a92359eb09
parent43ca26febeba4605e71ef99ce804b0dfa72074c8 (diff)
Switch back to sending all tag contents to clients
Switch back to sending all tag records to subscribed clients on presence detection. While sending the first text record as the "uid" value the identity agent expects works, in the grand scheme of things, it is better to keep the NFC service generic and add the required parsing to the identity agent instead. Change-Id: I157dde987fb499772bb792b4c723e85734e2c9e4 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
-rw-r--r--README.md5
-rw-r--r--binding/afm-nfc-binding.c30
2 files changed, 15 insertions, 20 deletions
diff --git a/README.md b/README.md
index a9eec9b..506d984 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,8 @@
## Overview
NFC service uses neard package to detect the presence of NFC tags and signal clients via an event.
-The NDEF data shall include a text record ('uid') to keep compatibility with the existing agl-service-identity-agent.
+The presence event shall include a dictionary named "record" that contains entries with a "Type"
+field and a value field named after the "Type" value.
## Verbs
@@ -18,4 +19,4 @@ The NDEF data shall include a text record ('uid') to keep compatibility with the
| Name | Description | JSON Response |
|--------------------|:-------------------------------------|:-----------------------------------------------------------------------|
| presence | event that reports NFC tag presence | *Response:* {"status": "detected", |
-| | | "uid": "042eb3628e4981"}, |
+| | | "record": { "Type": "URI", "URI": "http://www.nfc-forum.com" } } |
diff --git a/binding/afm-nfc-binding.c b/binding/afm-nfc-binding.c
index d605632..ef87a7d 100644
--- a/binding/afm-nfc-binding.c
+++ b/binding/afm-nfc-binding.c
@@ -103,34 +103,28 @@ static void record_found(const char *tag_name, void *ptr)
gchar *str = g_variant_print(v, 0);
str[strlen(str) - 1] = '\0';
- AFB_API_DEBUG(afbBindingV3root,
- "%s tag, record %s= %s", tag_name, s, str);
+ AFB_API_WARNING(afbBindingV3root,
+ "%s tag, record %s= %s", tag_name, s, str);
json_object_object_add(jdict, s,
json_object_new_string(str + 1));
g_free(str);
}
+ json_object_object_add(jresp, "record", jdict);
+
neardal_free_record(record);
- /*
- * get record dictionary and look for 'Representation' field which should
- * contain the uid value the identity agent needs.
- *
- */
- if (json_object_object_get_ex(jdict, "Representation", &jtemp)) {
- const char *uid = json_object_get_string(jtemp);
+ AFB_API_WARNING(afbBindingV3root, "sending: %s",
+ json_object_to_json_string_ext(jresp, JSON_C_TO_STRING_SPACED | JSON_C_TO_STRING_PRETTY));
- pthread_mutex_lock(&mutex);
- data->jresp = jresp;
- json_object_object_add(jresp, "uid", json_object_new_string(uid));
- pthread_mutex_unlock(&mutex);
+ pthread_mutex_lock(&mutex);
+ data->jresp = jresp;
+ json_object_get(jresp);
+ pthread_mutex_unlock(&mutex);
- afb_event_push(presence_event, jresp);
- AFB_API_DEBUG(afbBindingV3root,
- "sent presence event, record content %s, tag %s",
- uid, tag_name);
- }
+ afb_event_push(presence_event, jresp);
+ AFB_API_WARNING(afbBindingV3root, "sent presence event");
return;
}