aboutsummaryrefslogtreecommitdiffstats
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-11-28 07:29:33 -0800
commit61e3796da490e30cc4ca636f54acd69b788ab1fb (patch)
tree7052573ab24c0fe3bdc0d2e6104104a0100377c2
parent316100d2ff0a2ca398ba26447a4522c036eba4c0 (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 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;