aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--conf.d/project/etc/control-signal-composer.json (renamed from conf.d/project/etc/control-daemon.json)8
-rw-r--r--conf.d/project/etc/sig-demoboard.json2
-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
5 files changed, 16 insertions, 49 deletions
diff --git a/conf.d/project/etc/control-daemon.json b/conf.d/project/etc/control-signal-composer.json
index 7a7e162..d44a8fe 100644
--- a/conf.d/project/etc/control-daemon.json
+++ b/conf.d/project/etc/control-signal-composer.json
@@ -10,15 +10,19 @@
"plugins": [
{
"uid": "low-can-callbacks",
- "ldpath": "lib/plugins",
"info": "Manage interaction with low-can service",
"basename": "low-can"
},
{
"uid": "gps-callbacks",
- "ldpath": "lib/plugins",
"info": "Manage interaction with gps service",
"basename": "gps"
+ },
+ {
+ "uid": "builtin",
+ "info": "Builtin routine for onReceived or getSignals routines",
+ "basename": "builtin",
+ "lua2c": "setSignalValueWrap"
}
],
"signals": {
diff --git a/conf.d/project/etc/sig-demoboard.json b/conf.d/project/etc/sig-demoboard.json
index bb64fe9..da64a26 100644
--- a/conf.d/project/etc/sig-demoboard.json
+++ b/conf.d/project/etc/sig-demoboard.json
@@ -26,7 +26,7 @@
"unit": "rpm",
"frequency": 1,
"onReceived": {
- "function": "builtin://defaultOnReceived"
+ "function": "plugin://defaultOnReceived"
}
},
{
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();