aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-04-04 00:18:55 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-04-11 12:41:43 +0200
commit8eaebc2cdfcab4b2f7cd5381241bb0e8bc39701c (patch)
treef84ce3c873ac5f80871c496ba5caf733f9dfc455 /src
parent09ca1df3717438701d0abda96acb0bbcb6dc7666 (diff)
Unsubscribe instead of subscribe if can't adding to recurring request
Not useful to get a subscription on an adding error. Change-Id: I211016a1cbeb9cd5677cd8f8c7a28ccc93ef9a34 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src')
-rw-r--r--src/low-can-binding.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/low-can-binding.cpp b/src/low-can-binding.cpp
index bcbfc2c..07b3f1e 100644
--- a/src/low-can-binding.cpp
+++ b/src/low-can-binding.cpp
@@ -139,7 +139,6 @@ static int subscribe_unsubscribe_signals(struct afb_req request, bool subscribe,
for(const std::string& sig : signals)
{
int ret;
- bool to_subscribe = false;
if (active_diagnostic_request_t::is_diagnostic_signal(sig))
{
diagnostic_message_t* diag_msg = configuration_t::instance().get_diagnostic_message(sig);
@@ -151,7 +150,7 @@ static int subscribe_unsubscribe_signals(struct afb_req request, bool subscribe,
if(diag_msg->get_supported() && subscribe)
{
float frequency = diag_msg->get_frequency();
- to_subscribe = configuration_t::instance().get_diagnostic_manager().add_recurring_request(
+ subscribe = configuration_t::instance().get_diagnostic_manager().add_recurring_request(
diag_req, sig.c_str(), false, diag_msg->get_decoder(), diag_msg->get_callback(), (float)frequency);
//TODO: Adding callback requesting ignition status: diag_req, sig.c_str(), false, diagnostic_message_t::decode_obd2_response, diagnostic_message_t::check_ignition_status, frequency);
}
@@ -164,13 +163,11 @@ static int subscribe_unsubscribe_signals(struct afb_req request, bool subscribe,
}
}
- if(to_subscribe)
- {
- ret = subscribe_unsubscribe_signal(request, subscribe, sig);
- if(ret <= 0)
- return ret;
- rets++;
- }
+ ret = subscribe_unsubscribe_signal(request, subscribe, sig);
+ if(ret <= 0)
+ return ret;
+ rets++;
+
DEBUG(binder_interface, "Signal: %s subscribed", sig.c_str());
}
return rets;