From 8eaebc2cdfcab4b2f7cd5381241bb0e8bc39701c Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Tue, 4 Apr 2017 00:18:55 +0200 Subject: 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 --- src/low-can-binding.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/low-can-binding.cpp') 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; -- cgit 1.2.3-korg