From 713fb59c44f583f49a31195991185a49d90eb164 Mon Sep 17 00:00:00 2001 From: Torsten Robitzki Date: Thu, 5 Oct 2023 09:37:58 +0200 Subject: [PATCH] application upcall even for the case that no phy changed (required to implement HCI) --- .../include/bluetoe/connection_callbacks.hpp | 3 +++ .../link_layer/include/bluetoe/link_layer.hpp | 5 ++++- .../link_layer/connection_callbacks_tests.cpp | 20 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/bluetoe/link_layer/include/bluetoe/connection_callbacks.hpp b/bluetoe/link_layer/include/bluetoe/connection_callbacks.hpp index 4602e575..d8f6206a 100644 --- a/bluetoe/link_layer/include/bluetoe/connection_callbacks.hpp +++ b/bluetoe/link_layer/include/bluetoe/connection_callbacks.hpp @@ -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& ) {} + }; } diff --git a/bluetoe/link_layer/include/bluetoe/link_layer.hpp b/bluetoe/link_layer/include/bluetoe/link_layer.hpp index e8ed9f1b..1cd1de5e 100644 --- a/bluetoe/link_layer/include/bluetoe/link_layer.hpp +++ b/bluetoe/link_layer/include/bluetoe/link_layer.hpp @@ -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 ); @@ -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; } diff --git a/tests/link_layer/connection_callbacks_tests.cpp b/tests/link_layer/connection_callbacks_tests.cpp index 27b81518..04703394 100644 --- a/tests/link_layer/connection_callbacks_tests.cpp +++ b/tests/link_layer/connection_callbacks_tests.cpp @@ -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 ); +}