From e599b4ba129df475a9c8bb8290c3803f9dda664a Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Thu, 7 Dec 2017 18:49:09 +0100 Subject: Load additionnals object at runtime Later integrated in controller submodule Change-Id: I7d5c7431e60fc16cc2053747674fe4f14efd6a14 Signed-off-by: Romain Forlot --- plugins/low-can.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/low-can.cpp b/plugins/low-can.cpp index 57c389e..011b9a9 100644 --- a/plugins/low-can.cpp +++ b/plugins/low-can.cpp @@ -65,7 +65,7 @@ CTLP_ONLOAD(plugin, composerHandle) memset(&pluginCtx->allDoorsCtx, 0, sizeof(allDoorsCtxT)); struct signalCBT* handle = (struct signalCBT*)composerHandle; - handle->pluginCtx = pluginCtx; + handle->pluginCtx = (void*)pluginCtx; return (void*)handle; } @@ -117,10 +117,15 @@ CTLP_CAPI (subscribeToLow, source, argsJ, eventJ) { } else { - AFB_DEBUG("Calling subscribe with %s", json_object_to_json_string_ext(pluginCtx->subscriptionBatch, JSON_C_TO_STRING_PRETTY)); + json_object_get(pluginCtx->subscriptionBatch); + AFB_DEBUG("Calling subscribe with %s", json_object_to_json_string(pluginCtx->subscriptionBatch)); err = afb_service_call_sync("low-can", "subscribe", pluginCtx->subscriptionBatch, &responseJ); if(err) - {AFB_ERROR("Subscribe to '%s' responseJ:%s", json_object_to_json_string_ext(pluginCtx->subscriptionBatch, JSON_C_TO_STRING_PRETTY), json_object_to_json_string(responseJ));} + {AFB_ERROR("Subscribe to '%s' responseJ:%s", json_object_to_json_string(pluginCtx->subscriptionBatch), json_object_to_json_string(responseJ));} + + // Renew subscription json object for the next time we need it + json_object_put(pluginCtx->subscriptionBatch); + pluginCtx->subscriptionBatch = json_object_new_array(); } return err; -- cgit 1.2.3-korg