aboutsummaryrefslogtreecommitdiffstats
path: root/ctl-lib/ctl-event.c
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-08-16 17:56:23 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-08-20 16:06:43 +0200
commit4386ec54f811f19a14d0f60688321d4a1a69b78a (patch)
tree7ac0dec659f66b13e292811138b99c65e489a4b7 /ctl-lib/ctl-event.c
parent789a8ae5080bc91ab9ec3bd7760f88b5d214001c (diff)
Migration to v3
This makes controller fully compatible with binding v3 and also keeps the compatibility with the Pre-V3 + DYNAPI bindings. Change-Id: Iaa47e51b9cb964bbe2f050784fca355c780673f8 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'ctl-lib/ctl-event.c')
-rw-r--r--ctl-lib/ctl-event.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/ctl-lib/ctl-event.c b/ctl-lib/ctl-event.c
index 235be28..4174000 100644
--- a/ctl-lib/ctl-event.c
+++ b/ctl-lib/ctl-event.c
@@ -22,16 +22,19 @@
#include "ctl-config.h"
-
// Event dynamic API-V3 mode
-#ifdef AFB_BINDING_PREV3
+#if defined AFB_BINDING_PREV3 || AFB_BINDING_VERSION == 3
void CtrlDispatchApiEvent (AFB_ApiT apiHandle, const char *evtLabel, struct json_object *eventJ) {
int idx = 0;
CtlActionT* actions = NULL;
AFB_ApiDebug (apiHandle, "Received event=%s, query=%s", evtLabel, json_object_get_string(eventJ));
// retrieve section config from api handle
+ #ifdef AFB_BINDING_PREV3
CtlConfigT *ctrlConfig = (CtlConfigT*) afb_dynapi_get_userdata(apiHandle);
+ #elif AFB_BINDING_VERSION == 3
+ CtlConfigT *ctrlConfig = (CtlConfigT*) afb_api_get_userdata(apiHandle);
+ #endif
for (idx = 0; ctrlConfig->sections[idx].key != NULL; ++idx)
{
@@ -67,7 +70,7 @@ void CtrlDispatchV2Event(const char *evtLabel, json_object *eventJ) {
int index= ActionLabelToIndex(actions, evtLabel);
if (index < 0) {
- AFB_WARNING ("CtlDispatchEvent: fail to find uid=%s in action event section", evtLabel);
+ AFB_WARNING_V2("CtlDispatchEvent: fail to find uid=%s in action event section", evtLabel);
return;
}