aboutsummaryrefslogtreecommitdiffstats
path: root/signal-composer-binding
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-12-19 16:23:13 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-19 16:40:28 +0100
commitdda0abe9314a7c296d62092c2a08e18f37db4e0a (patch)
treed84cf3ee45bf1f73cfdf3b651246b8151b6abca6 /signal-composer-binding
parentc8f07ec99af84895ef899457c35b9beb000ad11e (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')
-rw-r--r--signal-composer-binding/signal-composer-binding.cpp2
-rw-r--r--signal-composer-binding/signal-composer.cpp51
-rw-r--r--signal-composer-binding/signal-composer.hpp2
3 files changed, 9 insertions, 46 deletions
diff --git a/signal-composer-binding/signal-composer-binding.cpp b/signal-composer-binding/signal-composer-binding.cpp
index 9afed5a..c7ca567 100644
--- a/signal-composer-binding/signal-composer-binding.cpp
+++ b/signal-composer-binding/signal-composer-binding.cpp
@@ -261,7 +261,7 @@ int loadConf()
std::string bindingDirPath = GetBindingDirPath();
std::string rootdir = bindingDirPath + "/etc";
- err = Composer::instance().loadConfig(rootdir.c_str());
+ err = Composer::instance().loadConfig(rootdir);
return err;
}
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;
}
diff --git a/signal-composer-binding/signal-composer.hpp b/signal-composer-binding/signal-composer.hpp
index 9dc80ed..b3e1fed 100644
--- a/signal-composer-binding/signal-composer.hpp
+++ b/signal-composer-binding/signal-composer.hpp
@@ -55,7 +55,7 @@ public:
static void* createContext(void* ctx);
static void destroyContext(void* ctx);
static std::vector<std::string> parseURI(const std::string& uri);
- int loadConfig(const std::string& filepath);
+ int loadConfig(std::string& filepath);
int loadSources(json_object* sourcesJ);
int loadSignals(json_object* signalsJ);
void initSignals();