aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--high-viwi-binding/high-viwi-binding.cpp8
-rw-r--r--high-viwi-binding/high.cpp12
-rw-r--r--high-viwi-binding/high.hpp2
3 files changed, 14 insertions, 8 deletions
diff --git a/high-viwi-binding/high-viwi-binding.cpp b/high-viwi-binding/high-viwi-binding.cpp
index e42a175..3b54003 100644
--- a/high-viwi-binding/high-viwi-binding.cpp
+++ b/high-viwi-binding/high-viwi-binding.cpp
@@ -45,7 +45,7 @@ void unsubscribe(afb_req request)
if(high.unsubscribe(request))
afb_req_success(request, NULL, NULL);
else
- afb_req_fail(request, "error", NULL);
+ afb_req_fail(request, "error when unsubscribe", NULL);
}
/// @brief verb that loads JSON configuration (old high.json file now)
@@ -55,7 +55,11 @@ void load(afb_req request)
const char* confd;
wrap_json_unpack(args, "{s:s}", "path", &confd);
- high.parseConfigAndSubscribe(confd);
+ int ret = high.parseConfigAndSubscribe(confd);
+ if( ret == 0)
+ afb_req_success(request, NULL, NULL);
+ else
+ afb_req_fail_f(request, "Loading configuration or subscription error", "Error code: %d", ret);
}
/// @brief entry point for get requests. Treatment itself is made in High class.
diff --git a/high-viwi-binding/high.cpp b/high-viwi-binding/high.cpp
index 2aa5b6a..d656ef3 100644
--- a/high-viwi-binding/high.cpp
+++ b/high-viwi-binding/high.cpp
@@ -198,7 +198,7 @@ void High::loadResources(json_object* resources, std::map<std::string, std::map<
///
/// @param[in] confd - path to configuration directory which holds the binding configuration to load
///
-void High::parseConfigAndSubscribe(const std::string& confd)
+int High::parseConfigAndSubscribe(const std::string& confd)
{
char* filename;
char* fullpath;
@@ -209,7 +209,7 @@ void High::parseConfigAndSubscribe(const std::string& confd)
if (!conf_filesJ || json_object_array_length(conf_filesJ) == 0)
{
AFB_ERROR("No JSON config files found in %s", confd.c_str());
- return;
+ return -1;
}
// Fill a vector of config files path
@@ -220,7 +220,7 @@ void High::parseConfigAndSubscribe(const std::string& confd)
int err = wrap_json_unpack (entryJ, "{s:s, s:s !}", "fullpath", &fullpath,"filename", &filename);
if (err) {
AFB_ERROR ("OOOPs invalid config file path = %s", json_object_get_string(entryJ));
- return;
+ return -1;
}
std::string filepath = fullpath;
filepath += "/";
@@ -259,7 +259,7 @@ void High::parseConfigAndSubscribe(const std::string& confd)
}
AFB_NOTICE("configuration loaded");
- subscribeRegisteredObjects();
+ return subscribeRegisteredObjects();
}
int High::subscribeRegisteredObjects() const
@@ -294,7 +294,9 @@ int High::subscribeRegisteredObjects() const
}
}
}
- return ok == i ? 0 : -1;
+
+ AFB_DEBUG("Subscribed to %d/%d signals.", ok, i);
+ return ok == i ? 0 : -2;
}
/// @brief Create and start a systemD timer. Only one timer is created per frequency.
diff --git a/high-viwi-binding/high.hpp b/high-viwi-binding/high.hpp
index ecc36be..989dda5 100644
--- a/high-viwi-binding/high.hpp
+++ b/high-viwi-binding/high.hpp
@@ -47,7 +47,7 @@ public:
void tick(sd_event_source *source, const long &now, void *interv);
void startTimer(const int &t);
~High();
- void parseConfigAndSubscribe(const std::string& confd);
+ int parseConfigAndSubscribe(const std::string& confd);
static bool startsWith(const std::string &s, const std::string &val);
static void callBackFromSubscribe(void *handle, int iserror, json_object *result);
private: