Skip to content

Commit

Permalink
application upcall even for the case that no phy changed (required to…
Browse files Browse the repository at this point in the history
… implement HCI)
  • Loading branch information
TorstenRobitzki committed Oct 5, 2023
1 parent 9e3f30b commit 713fb59
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions bluetoe/link_layer/include/bluetoe/connection_callbacks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ namespace link_layer {
template < class Connection, class Radio >
void remote_features_received( const std::uint8_t[8], Connection&, Radio& ) {}

template < class Connection, class Radio >
void phy_update( std::uint8_t, std::uint8_t, Connection&, Radio& ) {}

};
}

Expand Down
5 changes: 4 additions & 1 deletion bluetoe/link_layer/include/bluetoe/link_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,10 @@ namespace link_layer {

if ( c_to_p == phy_ll_encoding::le_unchanged_coding
&& p_to_c == phy_ll_encoding::le_unchanged_coding )
{
link_layer.phy_update( c_to_p, p_to_c, link_layer.connection_data_, link_layer );
return true;
}

link_layer.defered_ll_control_pdu_ = pdu;
link_layer.defered_conn_event_counter_ = ::bluetoe::details::read_16bit( pdu_body + 3 );
Expand Down Expand Up @@ -339,7 +342,7 @@ namespace link_layer {
private:
bool valid_phy_encoding( std::uint8_t c ) const
{
return c == 0
return c == phy_ll_encoding::le_unchanged_coding
|| c == phy_ll_encoding::le_1m_phy
|| c == phy_ll_encoding::le_2m_phy;
}
Expand Down
20 changes: 20 additions & 0 deletions tests/link_layer/connection_callbacks_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,3 +720,23 @@ BOOST_FIXTURE_TEST_CASE( phy_update_test_II, link_layer_only_phy_updated_callbac
BOOST_CHECK_EQUAL( only_phy_updated_callback.transmit_encoding, bluetoe::link_layer::phy_ll_encoding::le_unchanged_coding );
BOOST_CHECK_EQUAL( only_phy_updated_callback.receive_encoding, bluetoe::link_layer::phy_ll_encoding::le_1m_phy );
}

BOOST_FIXTURE_TEST_CASE( phy_update_test_III, link_layer_only_phy_updated_callback )
{
respond_to( 37, valid_connection_request_pdu );
ll_empty_pdus( 3 );
ll_control_pdu(
{
0x18, // LL_PHY_UPDATE_IND
0x00, // PHY_C_TO_P unchanged
0x00, // PHY_P_TO_C unchanged
0x00, 0x00 // Instant
}
);

run( 40 );

BOOST_REQUIRE( only_phy_updated_callback.phy_updated_called );
BOOST_CHECK_EQUAL( only_phy_updated_callback.transmit_encoding, bluetoe::link_layer::phy_ll_encoding::le_unchanged_coding );
BOOST_CHECK_EQUAL( only_phy_updated_callback.receive_encoding, bluetoe::link_layer::phy_ll_encoding::le_unchanged_coding );
}

0 comments on commit 713fb59

Please sign in to comment.