summaryrefslogtreecommitdiffstats
path: root/src/agl-identity-binding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/agl-identity-binding.c')
-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;