From 61e3796da490e30cc4ca636f54acd69b788ab1fb Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Wed, 17 Oct 2018 11:41:13 +0200 Subject: binding: identity: update event processing for nfc binding data Switch from old NFC binding event data to new format in the binding rewrite. Change-Id: Ie7669f2a3e8005c10e680b2d4f821fc96d4a421d Signed-off-by: Matt Ranostay --- src/agl-identity-binding.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/agl-identity-binding.c b/src/agl-identity-binding.c index 12f43bd..c8c5924 100644 --- a/src/agl-identity-binding.c +++ b/src/agl-identity-binding.c @@ -221,17 +221,10 @@ static void on_nfc_subscribed(void *closure, int status, struct json_object *res AFB_ERROR("Failed to subscribe to nfc events."); } -static void on_nfc_started(void *closure, int status, struct json_object *result) -{ - if (!status) { - afb_service_call("nfc", "subscribe", NULL, on_nfc_subscribed, NULL); - } - else - AFB_ERROR("Failed to start nfc polling."); -} - static int service_init() { + struct json_object *jrequest = NULL; + agl_forgerock_setcb(on_forgerock_data); event = afb_daemon_make_event("event"); if (!afb_event_is_valid(event)) @@ -245,7 +238,10 @@ static int service_init() if (afb_daemon_require_api("persistence", 1)) return -1; - afb_service_call("nfc", "start", NULL, on_nfc_started, NULL); + jrequest = json_object_new_object(); + json_object_object_add(jrequest, "value", json_object_new_string("presence")); + + afb_service_call("nfc", "subscribe", jrequest, on_nfc_subscribed, NULL); return 0; } @@ -255,7 +251,7 @@ static void on_nfc_target_add(struct json_object *object) struct json_object * json_uid; const char *uid; - if (json_object_object_get_ex(object, "UID", &json_uid)) + if (json_object_object_get_ex(object, "uid", &json_uid)) { uid = json_object_get_string(json_uid); AFB_NOTICE("nfc tag detected, call forgerock with vincode=%s and key=%s", vin ? vin : default_vin, uid); @@ -268,7 +264,7 @@ static void on_nfc_target_add(struct json_object *object) static void onevent(const char *event, struct json_object *object) { AFB_NOTICE("Received event: %s", event); - if (!strcmp("nfc/on-nfc-target-add", event)) + if (!strcmp("nfc/presence", event)) { on_nfc_target_add(object); return; -- cgit 1.2.3-korg