diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-12-19 16:23:13 +0100 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-12-19 16:40:28 +0100 |
commit | dda0abe9314a7c296d62092c2a08e18f37db4e0a (patch) | |
tree | d84cf3ee45bf1f73cfdf3b651246b8151b6abca6 /signal-composer-binding/signal-composer.cpp | |
parent | c8f07ec99af84895ef899457c35b9beb000ad11e (diff) |
Get builtin plugin as a normal plugin
- Back in normal configuration file
- Remove builtin special callback as it is just a plugin after all
- Rename main configuration files to get it works on a target
board.
Change-Id: I69165c47e5e58eb519e727cfdd83ee628d90abba
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'signal-composer-binding/signal-composer.cpp')
-rw-r--r-- | signal-composer-binding/signal-composer.cpp | 51 |
1 files changed, 7 insertions, 44 deletions
diff --git a/signal-composer-binding/signal-composer.cpp b/signal-composer-binding/signal-composer.cpp index 00d2a07..83a2b9f 100644 --- a/signal-composer-binding/signal-composer.cpp +++ b/signal-composer-binding/signal-composer.cpp @@ -203,21 +203,6 @@ CtlActionT* Composer::convert2Action(const std::string& name, json_object* actio { ctlActionJ = buildPluginAction(name, function, functionArgsJ); } - else if(startsWith(function, "builtin://")) - { - std::string uri = std::string(function).substr(10); - std::vector<std::string> uriV = Composer::parseURI(uri); - if(uriV.size() > 1) {AFB_WARNING("Too many thing specified. Uri has to be like: builtin://<builtin-function-name>");} - - json_object *callbackJ = nullptr; - wrap_json_pack(&callbackJ, "{ss,ss,so*}", - "plugin", "builtin", - "function", uriV[0].c_str(), - "args", functionArgsJ); - wrap_json_pack(&ctlActionJ, "{ss,so}", - "uid", name.c_str(), - "callback", callbackJ); - } else { AFB_ERROR("Wrong function uri specified. You have to specified 'lua://', 'plugin://' or 'api://'. (%s)", function); @@ -237,7 +222,7 @@ CtlActionT* Composer::convert2Action(const std::string& name, json_object* actio return nullptr; } -/// @brief Add the builtin plugin in the default plugins section definition +/// @brief Load controller plugins /// /// @param[in] section - Control Section structure /// @param[in] pluginsJ - JSON object containing all plugins definition made in @@ -246,31 +231,7 @@ CtlActionT* Composer::convert2Action(const std::string& name, json_object* actio /// @return 0 if OK, other if not. int Composer::pluginsLoad(AFB_ApiT apiHandle, CtlSectionT *section, json_object *pluginsJ) { - json_object* builtinJ = nullptr, * completePluginsJ = nullptr; - - if(pluginsJ) - { - wrap_json_pack(&builtinJ, "{ss,ss,ss,ss,s[s]}", - "uid", "builtin", - "ldpath", CONTROL_PLUGIN_PATH, - "info", "Builtin routine for onReceived or getSignals routines", - "basename", "builtin", - "lua2c", "setSignalValueWrap"); - - if (json_object_get_type(pluginsJ) == json_type_array) - { - json_object_array_add(pluginsJ, builtinJ); - completePluginsJ = pluginsJ; - } - else - { - completePluginsJ = json_object_new_array(); - json_object_array_add(completePluginsJ, pluginsJ); - json_object_array_add(completePluginsJ, builtinJ); - } - } - - return PluginConfig(nullptr, section, completePluginsJ); + return PluginConfig(nullptr, section, pluginsJ); } int Composer::loadOneSourceAPI(json_object* sourceJ) @@ -623,14 +584,16 @@ std::vector<std::string> Composer::parseURI(const std::string& uri) return uriV; } -int Composer::loadConfig(const std::string& filepath) +int Composer::loadConfig(std::string& filepath) { const char *dirList= getenv("CONTROL_CONFIG_PATH"); if (!dirList) dirList=CONTROL_CONFIG_PATH; - const char *configPath = CtlConfigSearch (nullptr, dirList, "control-"); + filepath.append(":"); + filepath.append(dirList); + const char *configPath = CtlConfigSearch(nullptr, filepath.c_str(), "control-"); if (!configPath) { - AFB_ApiError(apiHandle, "CtlPreInit: No control-* config found invalid JSON %s ", dirList); + AFB_ApiError(apiHandle, "CtlPreInit: No control-* config found invalid JSON %s ", filepath.c_str()); return -1; } |