void radio_base::check_scheduling( const std::function< bool ( const schedule_data& first, const schedule_data& next ) >& check, const char* message ) const { check_scheduling( [&]( const schedule_data& ) { return true; }, check, message ); }
BOOST_FIXTURE_TEST_CASE( channels_are_iterated, advertising ) { check_scheduling( [&]( const test::schedule_data& a, const test::schedule_data& b ) { return a.channel != b.channel; }, "channels_are_iterated" ); }
void radio_base::check_scheduling( const std::function< bool ( const schedule_data& ) >& filter, const std::function< bool ( const schedule_data& data ) >& check, const char* message ) const { check_scheduling( [&]( const schedule_data& data ) -> bool { return !filter( data ) || check( data ); }, message ); }
/** * @test according to the specs, the distance between two advertising PDUs shall be shorter than or equal to 10ms * We identify the start of an advertising event by the first channel 37 */ BOOST_FIXTURE_TEST_CASE( less_than_10ms_between_two_PDUs, advertising ) { check_scheduling( [&]( const test::schedule_data& a, const test::schedule_data& b ) { return a.channel != 37 && a.channel != 38 || ( b.on_air_time - a.on_air_time ) <= bluetoe::link_layer::delta_time::msec( 10 ); }, "less_than_10ms_between_two_PDUs" ); }
/** * @test by default, the link layer will advertise Connectable Undirected Events */ BOOST_FIXTURE_TEST_CASE( connectable_undirected_is_the_default, advertising ) { check_scheduling( [&]( const test::schedule_data& scheduled ) -> bool { return !scheduled.transmitted_data.empty() && ( scheduled.transmitted_data[ 0 ] & 0xf ) == 0; }, "connectable_undirected_is_the_default" ); }
BOOST_FIXTURE_TEST_CASE( length_field_is_set_corretly, advertising ) { check_scheduling( [&]( const test::schedule_data& data ) { const auto& pdu = data.transmitted_data; return pdu.size() >= 2 && ( pdu[ 1 ] & 0x3f ) == pdu.size() - 2; }, "length_field_is_set_corretly" ); }
BOOST_FIXTURE_TEST_CASE( txadd_and_rxadd_bits_are_set_corretly_for_random_address, advertising ) { check_scheduling( [&]( const test::schedule_data& data ) { const auto& pdu = data.transmitted_data; return pdu.size() >= 1 && ( pdu[ 0 ] & ( 3 << 6 ) ) == ( 1 << 6 ); }, "txadd_and_rxadd_bits_are_set_corretly_for_random_address" ); }
BOOST_FIXTURE_TEST_CASE( sending_advertising_pdus, advertising ) { check_scheduling( []( const test::schedule_data& data ) { const auto& pdu = data.transmitted_data; return pdu.size() >= 2 && ( pdu[ 0 ] & 0x0f ) == 0; }, "sending_advertising_pdus" ); }
BOOST_FIXTURE_TEST_CASE( pdus_contain_the_gap_data, advertising ) { std::uint8_t gap[ 31 ]; const std::size_t gap_size = gatt_server_.advertising_data( &gap[ 0 ], sizeof( gap ) ); check_scheduling( [&]( const test::schedule_data& data ) { const auto& pdu = data.transmitted_data; return pdu.size() == 8 + gap_size && std::equal( &pdu[ 8 ], &pdu[ 8 + gap_size ], &gap[ 0 ] ); }, "pdus_contain_the_gap_data" ); }
BOOST_FIXTURE_TEST_CASE( advertising_pdus_contain_the_address, advertising ) { static const bluetoe::link_layer::address expected_address = bluetoe::link_layer::address::generate_static_random_address( 0x47110815 ); check_scheduling( [&]( const test::schedule_data& data ) { const auto& pdu = data.transmitted_data; return pdu.size() >= 8 && bluetoe::link_layer::address( &pdu[ 2 ] ) == expected_address; }, "advertising_pdus_contain_the_address" ); }
/** * @test by default, the interval is 100ms */ BOOST_FIXTURE_TEST_CASE( default_advertising_interval_is_kept, advertising ) { check_scheduling( filter_channel_37, [&]( const test::schedule_data& a, const test::schedule_data& b ) { const auto diff = b.on_air_time - a.on_air_time; return diff >= bluetoe::link_layer::delta_time::msec( 100 ) && diff <= bluetoe::link_layer::delta_time::msec( 110 ); }, "configured_advertising_interval_is_kept" ); }
int schedule_task_set(int policy, int save) { int i; int j; FILE* fp; int duration; switch (policy) { case 0: { // duration = schedule_random(task_num, processor_num, lcm_period, execute, period); // check_scheduling(task_num, processor_num, lcm_period, execute, period); break; } case 1: { duration = schedule_laxity_hierarchy(); // check_scheduling(task_num, processor_num, lcm_period, execute, period); break; } default: break; } /* for(i=0; i<task_num; i++) { printf("[Task: %d]", i); for(j=0; j<duration; j++) { if (!(j%period[i])) printf(YELLOW"|"END"%d", execute_flag[i][j]); else printf(" %d", execute_flag[i][j]); } printf("\n"); } */ duration = check_scheduling(); return duration; }