summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2018-10-17 11:41:13 +0200
committerMatt Ranostay <matt.ranostay@konsulko.com>2018-10-18 14:48:25 +0000
commitcd4d1ca0f47d934b683a0246163ef486cbb61ace (patch)
tree4d85e726444f1a950181ad212ebd6136ea6847c9
parent937f332a920c85417ddc420fb3756bf1ea375bf6 (diff)
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 <matt.ranostay@konsulko.com>
-rw-r--r--src/agl-identity-binding.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/agl-identity-binding.c b/src/agl-identity-binding.c
index 9bbe629..20a9384 100644
--- a/src/agl-identity-binding.c
+++ b/src/agl-identity-binding.c
@@ -217,17 +217,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))
@@ -241,7 +234,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;
}
@@ -251,7 +247,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);
@@ -264,7 +260,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;