Skip to content

Commit

Permalink
do not respond to a second LL_VERSION_IND
Browse files Browse the repository at this point in the history
  • Loading branch information
TorstenRobitzki committed Sep 28, 2023
1 parent 846c504 commit 3651359
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bluetoe/link_layer/include/bluetoe/link_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ namespace link_layer {
bool connection_parameters_request_use_signaling_channel_;
bool phy_update_request_pending_;
bool remote_versions_request_pending_;
bool version_indication_received_;

// default configuration parameters
typedef advertising_interval< 100 > default_advertising_interval;
Expand Down Expand Up @@ -868,6 +869,7 @@ namespace link_layer {
, connection_parameters_request_running_( false )
, phy_update_request_pending_( false )
, remote_versions_request_pending_( false )
, version_indication_received_( false )
{
using user_timer_t = typename bluetoe::details::find_by_meta_type<
details::synchronized_connection_event_callback_meta_type,
Expand Down Expand Up @@ -925,6 +927,7 @@ namespace link_layer {
phy_update_request_pending_ = false;
pending_event_ = false;
remote_versions_request_pending_ = false;
version_indication_received_ = false;
disconnecting_reason_ = connection_timeout;
procedure_timeout_ = delta_time();

Expand Down Expand Up @@ -1526,7 +1529,7 @@ namespace link_layer {
commit = false;
result = ll_result::disconnect;
}
else if ( opcode == LL_VERSION_IND && size == 6 )
else if ( opcode == LL_VERSION_IND && size == 6 && !version_indication_received_ )
{
procedure_timeout_ = delta_time();

Expand All @@ -1542,6 +1545,7 @@ namespace link_layer {
} );

this->version_indication_received( &body[ 1 ], connection_data_, static_cast< radio_t& >( *this ) );
version_indication_received_ = true;
}
else if ( opcode == LL_CHANNEL_MAP_REQ && size == 8 )
{
Expand Down
38 changes: 38 additions & 0 deletions tests/link_layer/ll_control_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

#include "connected.hpp"

using test::X;
using test::and_so_on;

BOOST_FIXTURE_TEST_CASE( respond_with_an_unknown_rsp, unconnected )
{
check_single_ll_control_pdu(
Expand Down Expand Up @@ -36,6 +39,41 @@ BOOST_FIXTURE_TEST_CASE( respond_to_a_version_ind, unconnected )
);
}

/**
* LL/CON/PER/BI-15-C
*/
BOOST_FIXTURE_TEST_CASE( respond_to_a_version_ind_ignoring_additional_requests, unconnected )
{
this->respond_to( 37, valid_connection_request_pdu );
for ( int times = 0; times != 5; ++times )
{
ll_control_pdu({
0x0C, // LL_VERSION_IND
0x08, // VersNr = Core Specification 4.2
0x00, 0x02, // CompId
0x00, 0x00 // SubVersNr
});
}
ll_empty_pdus( 4 );

run( 5 );

int num_responses = 0;

check_connection_events( [&]( const test::connection_event& evt ) -> bool
{
for ( const auto& response: evt.transmitted_data )
{
if ( check_pdu( response, { X, X, 0x0C, and_so_on } ) )
++num_responses;
}

return true;
}, "LL_VERSION_IND missing" );

BOOST_CHECK_EQUAL( num_responses, 1 );
}

BOOST_FIXTURE_TEST_CASE( respond_to_a_ping, unconnected )
{
check_single_ll_control_pdu(
Expand Down

0 comments on commit 3651359

Please sign in to comment.