From 025f9e643da7272123fb94fdf37d4284a356c4fe Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Sun, 16 Dec 2018 21:55:05 -0500 Subject: 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 --- binding/afm-nfc-binding.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'binding/afm-nfc-binding.c') 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; } -- cgit 1.2.3-korg