aboutsummaryrefslogtreecommitdiffstats
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.c57
1 files changed, 45 insertions, 12 deletions
diff --git a/src/agl-identity-binding.c b/src/agl-identity-binding.c
index f246ea9..bac7b90 100644
--- a/src/agl-identity-binding.c
+++ b/src/agl-identity-binding.c
@@ -234,6 +234,41 @@ out:
return ret;
}
+static void parse_nfc_tag_record(struct json_object *object)
+{
+ const char *tag_uid;
+ const char *tag_vin;
+ const char *value;
+ char *tmp;
+
+ value = json_object_get_string(object);
+ if (!value) {
+ AFB_API_ERROR(this_api, "ignore tag - empty content value");
+ goto out;
+ }
+
+ tag_vin = strtok_r(value,":", &tmp);
+ if (!tag_vin) {
+ AFB_API_ERROR(this_api, "ignore tag - missing vin value");
+ goto out;
+ }
+
+ tag_uid = strtok_r(NULL, ":", &tmp);
+ if (!tag_uid) {
+ AFB_API_ERROR(this_api, "ignore tag - missing uid value");
+ goto out;
+ }
+
+ if (!strcmp(tag_vin, vin)) {
+ AFB_API_NOTICE(this_api, "tag record: vin=%s, key=%s", tag_vin, tag_uid);
+ agl_forgerock_download_request(vin, "nfc", tag_uid);
+ }
+
+out:
+ return;
+
+}
+
static void on_nfc_target_add(struct json_object *object)
{
struct json_object *json_status;
@@ -246,6 +281,10 @@ static void on_nfc_target_add(struct json_object *object)
goto out;
}
+ AFB_API_DEBUG(this_api,
+ "nfc/presence debug: %s",
+ json_object_to_json_string(object));
+
if (!json_object_object_get_ex(object, "status", &json_status)) {
AFB_API_ERROR(this_api, "nfc/presence missing status");
goto out;
@@ -256,19 +295,13 @@ static void on_nfc_target_add(struct json_object *object)
goto out;
}
- if (json_object_object_get_ex(object, "uid", &json_uid))
- {
- uid = json_object_get_string(json_uid);
- AFB_API_NOTICE(this_api,
- "nfc tag detected, call forgerock with vincode=%s and key=%s",
- vin ? vin : default_vin, uid);
-
- agl_forgerock_download_request(vin ? vin : default_vin, "nfc", uid);
+ if (!json_object_object_get_ex(object, "uid", &json_uid)) {
+ AFB_API_ERROR(this_api, "nfc/presence missing uid");
+ goto out;
}
- else
- AFB_API_ERROR(this_api,
- "nfc tag detected event but no UID found: %s",
- json_object_to_json_string(object));
+
+ parse_nfc_tag_record(json_uid);
+
out:
return;
}