From 98e708af02b95bd46454b7f8c7f2d7cb67efe075 Mon Sep 17 00:00:00 2001 From: Torsten Robitzki Date: Fri, 17 Nov 2023 11:29:46 +0100 Subject: [PATCH] in case, a connection parameter update request is rejected, the timeout timer has to be canceled --- .../link_layer/include/bluetoe/link_layer.hpp | 10 +++--- tests/link_layer/ll_remote_request_tests.cpp | 33 +++++++++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/bluetoe/link_layer/include/bluetoe/link_layer.hpp b/bluetoe/link_layer/include/bluetoe/link_layer.hpp index 1cd1de5e..112fbb81 100644 --- a/bluetoe/link_layer/include/bluetoe/link_layer.hpp +++ b/bluetoe/link_layer/include/bluetoe/link_layer.hpp @@ -761,7 +761,7 @@ namespace link_layer { static constexpr std::uint8_t LL_REJECT_IND = 0x0D; static constexpr std::uint8_t LL_CONNECTION_PARAM_REQ = 0x0F; static constexpr std::uint8_t LL_CONNECTION_PARAM_RSP = 0x10; - static constexpr std::uint8_t LL_REJECT_IND_EXT = 0x11; + static constexpr std::uint8_t LL_REJECT_EXT_IND = 0x11; static constexpr std::uint8_t LL_PING_REQ = 0x12; static constexpr std::uint8_t LL_PING_RSP = 0x13; static constexpr std::uint8_t LL_PHY_REQ = 0x16; @@ -1330,7 +1330,7 @@ namespace link_layer { if ( used_features_ & link_layer_feature::extended_reject_indication ) { fill< layout_t >( output, { - ll_control_pdu_code, 3, LL_REJECT_IND_EXT, opcode, error_code } ); + ll_control_pdu_code, 3, LL_REJECT_EXT_IND, opcode, error_code } ); } else { @@ -1620,12 +1620,14 @@ namespace link_layer { this->remote_features_received( &body[ 1 ], connection_data_, static_cast< radio_t& >( *this ) ); } - else if ( ( opcode == LL_UNKNOWN_RSP && size == 2 ) || ( opcode == LL_REJECT_IND && size == 2 ) || ( opcode == LL_REJECT_IND_EXT && size == 3 ) ) + else if ( ( opcode == LL_UNKNOWN_RSP && size == 2 ) || ( opcode == LL_REJECT_IND && size == 2 ) || ( opcode == LL_REJECT_EXT_IND && size == 3 ) ) { - bool opcode_contains_request = opcode == LL_UNKNOWN_RSP || opcode == LL_REJECT_IND_EXT; + bool opcode_contains_request = opcode == LL_UNKNOWN_RSP || opcode == LL_REJECT_EXT_IND; if ( !opcode_contains_request || ( opcode_contains_request && body[ 1 ] == LL_CONNECTION_PARAM_REQ ) ) { + procedure_timeout_ = delta_time(); + if ( connection_parameters_request_running_ && connection_parameters_request_use_signaling_channel_ ) { connection_parameters_request_use_signaling_channel_ = false; diff --git a/tests/link_layer/ll_remote_request_tests.cpp b/tests/link_layer/ll_remote_request_tests.cpp index ba006d95..9150a520 100644 --- a/tests/link_layer/ll_remote_request_tests.cpp +++ b/tests/link_layer/ll_remote_request_tests.cpp @@ -308,3 +308,36 @@ BOOST_FIXTURE_TEST_CASE( Initiating_Connection_Parameter_Request__Timeout, fixtu BOOST_CHECK( callbacks.connection_closed ); BOOST_CHECK_EQUAL( callbacks.closed_reason, 0x22 ); } + +BOOST_FIXTURE_TEST_CASE( Initiating_Connection_Parameter_Request__Reject_No_Timeout, fixture ) +{ + bool tested = false; + + ll_empty_pdus( 1 ); + ll_function_call( [this](){ + BOOST_CHECK( initiating_connection_parameter_request( 6, 6, 0, 300 ) ); + BOOST_CHECK( !initiating_connection_parameter_request( 6, 6, 0, 300 ) ); + }); + ll_empty_pdus( 4 ); + + ll_control_pdu( + { + 0x11, // LL_REJECT_EXT_IND + 0x0F, // LL_CONNECTION_PARAM_REQ + 0x06 // Error Code + } + ); + + // connection interval is 30ms / timeout 4000ms = 1333,3 + ll_empty_pdus( 1340 ); + ll_function_call( [&](){ + tested = true; + BOOST_CHECK( !callbacks.connection_closed ); + }); + ll_empty_pdus( 3 ); + + run(1500); + + // make sure, the important test above is part of the simulation + BOOST_CHECK( tested ); +}