diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-07-04 14:23:11 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-07-04 14:23:11 +0200 |
commit | 4f4be8b532332735768c07f8fb3ca105c579c0be (patch) | |
tree | 24ae2787e8ce51563af5240148e7a070756eef11 | |
parent | 72a12086728bc21f54b1cfeb3549cd09e8e90d4f (diff) |
DAB RC3 Fixes follows appfw API break.
Following functions now return 0 on success and negative value
on failure :
o afb_req_subcall
o afb_req_subcall_sync
o afb_service_call
o afb_service_call_sync
Verbosity macros used in v2 bindings now needs to be prefixed
with AFB_ (ERROR -> AFB_ERROR)
Change-Id: I7b41f26875226861d8826936c712b4a59e5bb783
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r-- | high-can-binding/high-can-binding-hat.cpp | 4 | ||||
-rw-r--r-- | high-can-binding/high.cpp | 36 |
2 files changed, 20 insertions, 20 deletions
diff --git a/high-can-binding/high-can-binding-hat.cpp b/high-can-binding/high-can-binding-hat.cpp index 0bf7090..71dd3b7 100644 --- a/high-can-binding/high-can-binding-hat.cpp +++ b/high-can-binding/high-can-binding-hat.cpp @@ -27,9 +27,9 @@ const struct afb_binding_v2 afbBindingV2 = { /// @return Exit code, zero if success. int init_service() { - NOTICE("high level binding is initializing"); + AFB_NOTICE("high level binding is initializing"); afb_daemon_require_api("low-can", 1); initHigh(); - NOTICE("high level binding is initialized and running"); + AFB_NOTICE("high level binding is initialized and running"); return 0; } diff --git a/high-can-binding/high.cpp b/high-can-binding/high.cpp index b37fda6..097ef73 100644 --- a/high-can-binding/high.cpp +++ b/high-can-binding/high.cpp @@ -86,7 +86,7 @@ void High::parseConfigAndSubscribe() const std::string uri = name + id; jvalue = json_object_array_get_idx(jarray2, i); if(properties.find(name) == properties.end()) { - NOTICE("Unable to find name %s in properties", name.c_str()); + AFB_WARNING("Unable to find name %s in properties", name.c_str()); continue; } const std::map<std::string, Property> props = properties[name]; @@ -99,7 +99,7 @@ void High::parseConfigAndSubscribe() json_object_object_foreach(jvalue, key, val) { const std::string value = json_object_get_string(val); if(props.find(key) == props.end()) { - NOTICE("Unable to find key %s in properties", value.c_str()); + AFB_WARNING("Unable to find key %s in properties", value.c_str()); continue; } Property prop = props.at(key); @@ -107,7 +107,7 @@ void High::parseConfigAndSubscribe() const std::string canMessage = value.substr(2, value.size() - 1); const std::vector<std::string> params = split(canMessage, ','); if(params.size() != 2) { - NOTICE("Invalid CAN message definition %s", value.c_str()); + AFB_WARNING("Invalid CAN message definition %s", value.c_str()); continue; } prop.lowMessageName = params.at(0); @@ -127,7 +127,7 @@ void High::parseConfigAndSubscribe() else if(prop.type == "int") prop.value_int = 0; else - NOTICE("ERROR 2! unexpected type in parseConfig %s %s", prop.description.c_str(), prop.type.c_str()); + AFB_ERROR("ERROR 2! unexpected type in parseConfig %s %s", prop.description.c_str(), prop.type.c_str()); } else { prop.value_string= std::string(value); } @@ -155,14 +155,14 @@ void High::parseConfigAndSubscribe() } json_object *dummy; const std::string js = json_object_get_string(jobj); - if(afb_service_call_sync("low-can", "subscribe", jobj, &dummy) != 1) - NOTICE("high-can subscription to low-can FAILED %s", js.c_str()); + if(afb_service_call_sync("low-can", "subscribe", jobj, &dummy) < 0) + AFB_ERROR("high-can subscription to low-can FAILED %s", js.c_str()); else - NOTICE("high-can subscribed to low-can %s", js.c_str()); + AFB_NOTICE("high-can subscribed to low-can %s", js.c_str()); json_object_put(dummy); } json_object_put(config); - NOTICE("configuration loaded"); + AFB_NOTICE("configuration loaded"); } /// @brief Create and start a systemD timer. Only one timer is created per frequency. @@ -186,7 +186,7 @@ High::~High() /// void High::callBackFromSubscribe(void *handle, int iserror, json_object *result) { - NOTICE("high level callBackFromSubscribe method called %s", json_object_get_string(result)); + AFB_NOTICE("high level callBackFromSubscribe method called %s", json_object_get_string(result)); } /// @brief Entry point for all timer events. Treats all requests linked to the specific timer frequency. @@ -197,7 +197,7 @@ void High::callBackFromSubscribe(void *handle, int iserror, json_object *result) void High::tick(sd_event_source *source, const long &now, void *interv) { const int interval = *(int*)interv; - NOTICE("tick! %d %ld", interval, now); + AFB_NOTICE("tick! %d %ld", interval, now); bool hasEvents = false; if(timedEvents.find(interval) != timedEvents.end()) { std::vector<TimedEvent> evts = timedEvents[interval]; @@ -223,7 +223,7 @@ void High::tick(sd_event_source *source, const long &now, void *interv) evts.erase(evts.begin() + i); timedEvents[interval] = evts; } - //NOTICE("%s event pushed to %d subscribers", e.eventName.c_str(), nbSubscribers); + //AFB_NOTICE("%s event pushed to %d subscribers", e.eventName.c_str(), nbSubscribers); } if(evts.size() > 0) hasEvents = true; @@ -232,7 +232,7 @@ void High::tick(sd_event_source *source, const long &now, void *interv) sd_event_source_set_time(source, now + interval * 1000); sd_event_source_set_enabled(source, SD_EVENT_ON); } else { - //NOTICE("timer removed %d", interval); + //AFB_NOTICE("timer removed %d", interval); delete (int*)interv; if(timers.find(interval) != timers.end()) { timers.erase(interval); @@ -253,10 +253,10 @@ void High::treatMessage(json_object *message) json_object_object_get_ex(message, "value", &jvalue); const std::string messageName(json_object_get_string(nameJson)); if(lowMessagesToObjects.find(messageName) == lowMessagesToObjects.end()) { - NOTICE("message not linked to any object %s", json_object_get_string(message)); + AFB_ERROR("message not linked to any object %s", json_object_get_string(message)); return; } -// NOTICE("message received %s", json_object_get_string(message)); +// AFB_NOTICE("message received %s", json_object_get_string(message)); const std::set<std::string> objects = lowMessagesToObjects.at(messageName); std::vector<std::string> candidateMessages; for(const std::string &uri : objects) { @@ -281,7 +281,7 @@ void High::treatMessage(json_object *message) else if(property.type == "int") property.value_int = json_object_get_int(jvalue); else - NOTICE("ERROR 3! unexpected type %s %s", property.description.c_str(), property.type.c_str()); + AFB_ERROR("ERROR 3! unexpected type %s %s", property.description.c_str(), property.type.c_str()); properties[foundProperty] = property; registeredObjects[uri] = properties; } @@ -342,7 +342,7 @@ json_object *High::generateJson(const std::string &messageObject, std::vector<st const int value = p.second.value_int; json_object_object_add(json, p.first.c_str(), json_object_new_int(value)); } else { - NOTICE("ERROR 1! unexpected type %s %s %s", p.first.c_str(), p.second.description.c_str(), p.second.type.c_str()); + AFB_ERROR("ERROR 1! unexpected type %s %s %s", p.first.c_str(), p.second.description.c_str(), p.second.type.c_str()); } } return json; @@ -409,10 +409,10 @@ bool High::subscribe(afb_req request) char ext[20]; sprintf(ext, "_%d", ms); std::string messageName = message + std::string(ext); - //NOTICE("subscribe with interval %s", messageName.c_str()); + //AFB_NOTICE("subscribe with interval %s", messageName.c_str()); afbEvent = afb_daemon_make_event(messageName.c_str()); if (!afb_event_is_valid(afbEvent)) { - NOTICE("unable to create event"); + AFB_ERROR("unable to create event"); return false; } TimedEvent e; |