Skip to content

Commit

Permalink
in case, a connection parameter update request is rejected, the timeo…
Browse files Browse the repository at this point in the history
…ut timer has to be canceled
  • Loading branch information
TorstenRobitzki committed Nov 17, 2023
1 parent 5195f89 commit 98e708a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bluetoe/link_layer/include/bluetoe/link_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down
33 changes: 33 additions & 0 deletions tests/link_layer/ll_remote_request_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

0 comments on commit 98e708a

Please sign in to comment.