diff --git a/Kconfig b/Kconfig index f49c5ebc6c..2dd48b1f12 100644 --- a/Kconfig +++ b/Kconfig @@ -14,10 +14,6 @@ if SIDEWALK config MAIN_STACK_SIZE default 2048 -config BT_ID_MAX - default 3 if SIDEWALK_DFU - default 2 - config SIDEWALK_SUBGHZ_SUPPORT bool "Enable Sub-GHz link type support in Sidewalk libraries" default y diff --git a/Kconfig.dependencies b/Kconfig.dependencies index 519592afb2..9e1c1f5a04 100644 --- a/Kconfig.dependencies +++ b/Kconfig.dependencies @@ -38,6 +38,14 @@ config SIDEWALK_BLE help Sidewalk Bluetooth Low Energy (BLE) module +config BT_ID_MAX + default 3 if SIDEWALK_DFU + default 2 + +config BT_APP_IFC + bool "Enable BT app wrapper" + default y if SIDEWALK_BLE + config SIDEWALK_ASSERT bool default SIDEWALK diff --git a/samples/sid_end_device/src/hello/app.c b/samples/sid_end_device/src/hello/app.c index 18ada34b85..13d37e0e65 100644 --- a/samples/sid_end_device/src/hello/app.c +++ b/samples/sid_end_device/src/hello/app.c @@ -269,13 +269,9 @@ static void app_btn_dfu_state(uint32_t unused) ARG_UNUSED(unused); static bool go_to_dfu_state = true; if (go_to_dfu_state) { - sidewalk_event_send(sidewalk_event_exit, NULL, NULL); sidewalk_event_send(app_event_enter_dfu_mode, NULL, NULL); - application_state_working(&global_state_notifier, false); } else { sidewalk_event_send(app_event_exit_dfu_mode, NULL, NULL); - sidewalk_event_send(sidewalk_event_autostart, NULL, NULL); - application_state_working(&global_state_notifier, true); } go_to_dfu_state = !go_to_dfu_state; diff --git a/samples/sid_end_device/src/sensor_monitoring/app.c b/samples/sid_end_device/src/sensor_monitoring/app.c index 04fc08a72b..98595732ef 100644 --- a/samples/sid_end_device/src/sensor_monitoring/app.c +++ b/samples/sid_end_device/src/sensor_monitoring/app.c @@ -182,11 +182,9 @@ static void app_btn_dfu_state(uint32_t unused) ARG_UNUSED(unused); static bool go_to_dfu_state = true; if (go_to_dfu_state) { - sidewalk_event_send(sidewalk_event_exit, NULL, NULL); sidewalk_event_send(app_event_enter_dfu_mode, NULL, NULL); } else { sidewalk_event_send(app_event_exit_dfu_mode, NULL, NULL); - sidewalk_event_send(sidewalk_event_autostart, NULL, NULL); } go_to_dfu_state = !go_to_dfu_state; diff --git a/subsys/sal/common/CMakeLists.txt b/subsys/sal/common/CMakeLists.txt index 61bf74755a..1eedcc5d14 100644 --- a/subsys/sal/common/CMakeLists.txt +++ b/subsys/sal/common/CMakeLists.txt @@ -9,3 +9,5 @@ zephyr_include_directories(sid_pal_ifc) zephyr_include_directories(sid_time_ops) add_subdirectory_ifdef(CONFIG_SIDEWALK_ON_DEV_CERT sid_on_dev_cert) + +zephyr_library_sources(sid_ifc/bt_app_callbacks.c) diff --git a/subsys/sal/common/sid_ifc/bt_app_callbacks.c b/subsys/sal/common/sid_ifc/bt_app_callbacks.c index 17cc97b7ee..ef6d79d6ab 100644 --- a/subsys/sal/common/sid_ifc/bt_app_callbacks.c +++ b/subsys/sal/common/sid_ifc/bt_app_callbacks.c @@ -23,8 +23,8 @@ int app_bt_enable(bt_ready_cb_t cb) bt_enable_count++; if (cb) { cb(0); - return 0; } + return 0; } int app_bt_disable() diff --git a/subsys/sal/common/sid_ifc/bt_app_callbacks.h b/subsys/sal/common/sid_ifc/bt_app_callbacks.h index 7abf0d24e9..bf16225c64 100644 --- a/subsys/sal/common/sid_ifc/bt_app_callbacks.h +++ b/subsys/sal/common/sid_ifc/bt_app_callbacks.h @@ -10,21 +10,20 @@ #include #include +#if defined (CONFIG_BT_APP_IFC) int app_bt_enable(bt_ready_cb_t cb); int app_bt_disable(); enum BT_id_values{ _BT_ID_DEFAULT = BT_ID_DEFAULT, - #if defined (CONFIG_SIDEWALK) BT_ID_SIDEWALK, - #endif #if defined (CONFIG_SIDEWALK_DFU) BT_ID_SMP_DFU, #endif - _BT_ID_MAX = CONFIG_BT_ID_MAX + _BT_ID_MAX }; -BUILD_ASSERT(_BT_ID_MAX <= CONFIG_BT_ID_MAX, "Too many BT Ids! Configured limit is %d, but used %d", CONFIG_BT_ID_MAX, _BT_ID_MAX); - +BUILD_ASSERT(_BT_ID_MAX <= CONFIG_BT_ID_MAX, "Too many BT Ids! increase CONFIG_BT_ID_MAX, to match _BT_ID_MAX"); +#endif #endif diff --git a/subsys/sal/sid_pal/src/sid_ble_advert.c b/subsys/sal/sid_pal/src/sid_ble_advert.c index a0a64577fc..b339b70c59 100644 --- a/subsys/sal/sid_pal/src/sid_ble_advert.c +++ b/subsys/sal/sid_pal/src/sid_ble_advert.c @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -37,7 +38,7 @@ LOG_MODULE_REGISTER(sid_ble_advert, CONFIG_SIDEWALK_BLE_ADAPTER_LOG_LEVEL); /* Advertising parameters. */ static struct bt_le_adv_param adv_param_fast = { - .id = CONFIG_SIDEWALK_BLE_ID, + .id = BT_ID_SIDEWALK, .options = (AMA_ADV_OPTIONS), .interval_min = MS_TO_INTERVAL_VAL(CONFIG_SIDEWALK_BLE_ADV_INT_FAST), .interval_max = MS_TO_INTERVAL_VAL(CONFIG_SIDEWALK_BLE_ADV_INT_FAST + @@ -45,7 +46,7 @@ static struct bt_le_adv_param adv_param_fast = { }; static struct bt_le_adv_param adv_param_slow = { - .id = CONFIG_SIDEWALK_BLE_ID, + .id = BT_ID_SIDEWALK, .options = (AMA_ADV_OPTIONS), .interval_min = MS_TO_INTERVAL_VAL(CONFIG_SIDEWALK_BLE_ADV_INT_SLOW), .interval_max = MS_TO_INTERVAL_VAL(CONFIG_SIDEWALK_BLE_ADV_INT_SLOW + diff --git a/tests/unit_tests/pal_ble_adapter/Kconfig b/tests/unit_tests/pal_ble_adapter/Kconfig index 67222c2460..2fd294e7d8 100644 --- a/tests/unit_tests/pal_ble_adapter/Kconfig +++ b/tests/unit_tests/pal_ble_adapter/Kconfig @@ -31,8 +31,8 @@ config SIDEWALK_LOG_LEVEL config SIDEWALK_BLE_ADAPTER_LOG_LEVEL default 0 -config SIDEWALK_BLE_ID - default 1 +config BT_APP_IFC + default y config BT_ID_MAX default 2 diff --git a/tests/unit_tests/pal_ble_adapter/src/main.c b/tests/unit_tests/pal_ble_adapter/src/main.c index a608686bd0..3c09cecee1 100644 --- a/tests/unit_tests/pal_ble_adapter/src/main.c +++ b/tests/unit_tests/pal_ble_adapter/src/main.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -174,7 +175,7 @@ void test_sid_pal_ble_adapter_init(void) TEST_ASSERT_EQUAL(SID_ERROR_NONE, sid_pal_ble_adapter_create(&p_test_ble_ifc)); - bt_id_create_fake.return_val = CONFIG_SIDEWALK_BLE_ID; + bt_id_create_fake.return_val = BT_ID_SIDEWALK; __cmock_sid_ble_conn_init_Expect(); __cmock_sid_ble_advert_init_IgnoreAndReturn(0); TEST_ASSERT_EQUAL(SID_ERROR_NONE, p_test_ble_ifc->init(&test_ble_cfg)); @@ -193,7 +194,7 @@ void test_sid_pal_ble_adapter_deinit(void) TEST_ASSERT_EQUAL(SID_ERROR_NONE, sid_pal_ble_adapter_create(&p_test_ble_ifc)); __cmock_settings_load_ExpectAndReturn(ESUCCESS); __cmock_sid_ble_conn_init_Expect(); - bt_id_create_fake.return_val = CONFIG_SIDEWALK_BLE_ID; + bt_id_create_fake.return_val = BT_ID_SIDEWALK; __cmock_sid_ble_advert_init_IgnoreAndReturn(0); TEST_ASSERT_EQUAL(SID_ERROR_NONE, p_test_ble_ifc->init(&test_ble_cfg)); diff --git a/tests/unit_tests/sid_ble_advert/Kconfig b/tests/unit_tests/sid_ble_advert/Kconfig index 296292f60e..0526cc9ccc 100644 --- a/tests/unit_tests/sid_ble_advert/Kconfig +++ b/tests/unit_tests/sid_ble_advert/Kconfig @@ -9,6 +9,9 @@ config SIDEWALK_BUILD config SIDEWALK_LOG_LEVEL default 0 +config BT_APP_IFC + default y + module = SIDEWALK_BLE_ADAPTER module-str = Sidewalk BLE interface source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config" @@ -29,8 +32,4 @@ config SIDEWALK_BLE_ADV_INT_TRANSITION int "test value for Sidewalk configuration macro" default 30 -config SIDEWALK_BLE_ID - int "test value for Sidewalk configuration" - default 1 - source "Kconfig.zephyr" diff --git a/tests/unit_tests/sid_ble_connection/Kconfig b/tests/unit_tests/sid_ble_connection/Kconfig index 081b348335..cb92a98f62 100644 --- a/tests/unit_tests/sid_ble_connection/Kconfig +++ b/tests/unit_tests/sid_ble_connection/Kconfig @@ -12,10 +12,10 @@ config SIDEWALK_LOG_LEVEL config SIDEWALK_BLE_ADAPTER_LOG_LEVEL default 0 -config SIDEWALK_BLE_ID - default 1 - config BT_ID_MAX default 2 +config BT_APP_IFC + default y + source "Kconfig.zephyr" diff --git a/tests/unit_tests/sid_ble_connection/src/main.c b/tests/unit_tests/sid_ble_connection/src/main.c index bfcaf0d77d..3b09bb3a42 100644 --- a/tests/unit_tests/sid_ble_connection/src/main.c +++ b/tests/unit_tests/sid_ble_connection/src/main.c @@ -15,6 +15,7 @@ #include #include +#include DEFINE_FFF_GLOBALS; @@ -24,7 +25,7 @@ FAKE_VALUE_FUNC(struct bt_conn *, bt_conn_ref, struct bt_conn *); FAKE_VOID_FUNC(bt_conn_unref, struct bt_conn *); FAKE_VALUE_FUNC(const bt_addr_le_t *, bt_conn_get_dst, const struct bt_conn *); FAKE_VALUE_FUNC(int, bt_conn_disconnect, struct bt_conn *, uint8_t); -FAKE_VALUE_FUNC(int,bt_conn_get_info,const struct bt_conn *, struct bt_conn_info *); +FAKE_VALUE_FUNC(int, bt_conn_get_info, const struct bt_conn *, struct bt_conn_info *); #define FFF_FAKES_LIST(FAKE) \ FAKE(bt_conn_cb_register) \ @@ -32,7 +33,7 @@ FAKE_VALUE_FUNC(int,bt_conn_get_info,const struct bt_conn *, struct bt_conn_info FAKE(bt_conn_ref) \ FAKE(bt_conn_unref) \ FAKE(bt_conn_get_dst) \ - FAKE(bt_conn_disconnect)\ + FAKE(bt_conn_disconnect) \ FAKE(bt_conn_get_info) #define CONNECTED (true) @@ -104,8 +105,9 @@ void test_sid_ble_conn_params_get(void) TEST_ASSERT_NULL(params); } -int bt_conn_get_info_fake1(const struct bt_conn * a, struct bt_conn_info * b){ - b->id = CONFIG_SIDEWALK_BLE_ID; +int bt_conn_get_info_fake1(const struct bt_conn *a, struct bt_conn_info *b) +{ + b->id = BT_ID_SIDEWALK; return 0; } @@ -122,9 +124,9 @@ void test_sid_ble_conn_positive(void) bt_conn_get_dst_fake.return_val = &test_addr; bt_conn_ref_fake.return_val = &test_conn; - int (*custom_fakes[])(const struct bt_conn *, struct bt_conn_info *) = {bt_conn_get_info_fake1}; + int (*custom_fakes[])(const struct bt_conn *, + struct bt_conn_info *) = { bt_conn_get_info_fake1 }; SET_CUSTOM_FAKE_SEQ(bt_conn_get_info, custom_fakes, 1); - sid_ble_conn_deinit(); sid_ble_conn_init(); @@ -153,7 +155,8 @@ void test_sid_ble_set_conn_cb_positive(void) bt_conn_get_dst_fake.return_val = &test_addr; bt_conn_ref_fake.return_val = &test_conn; - int (*custom_fakes[])(const struct bt_conn *, struct bt_conn_info *) = {bt_conn_get_info_fake1}; + int (*custom_fakes[])(const struct bt_conn *, + struct bt_conn_info *) = { bt_conn_get_info_fake1 }; SET_CUSTOM_FAKE_SEQ(bt_conn_get_info, custom_fakes, 1); sid_ble_conn_init(); @@ -185,7 +188,8 @@ void test_sid_ble_conn_cb_set_call_count(void) bt_conn_get_dst_fake.return_val = &test_addr; bt_conn_ref_fake.return_val = &test_conn; - int (*custom_fakes[])(const struct bt_conn *, struct bt_conn_info *) = {bt_conn_get_info_fake1}; + int (*custom_fakes[])(const struct bt_conn *, + struct bt_conn_info *) = { bt_conn_get_info_fake1 }; SET_CUSTOM_FAKE_SEQ(bt_conn_get_info, custom_fakes, 1); sid_ble_conn_init(); @@ -222,7 +226,8 @@ void test_sid_ble_disconnected_wrong_conn(void) bt_conn_get_dst_fake.return_val = &test_addr; bt_conn_ref_fake.return_val = &test_conn; - int (*custom_fakes[])(const struct bt_conn *, struct bt_conn_info *) = {bt_conn_get_info_fake1}; + int (*custom_fakes[])(const struct bt_conn *, + struct bt_conn_info *) = { bt_conn_get_info_fake1 }; SET_CUSTOM_FAKE_SEQ(bt_conn_get_info, custom_fakes, 1); sid_ble_conn_init(); @@ -249,7 +254,8 @@ void test_sid_ble_cb_set_before_init(void) struct bt_conn test_conn = { .dummy = 0xDC }; bt_conn_ref_fake.return_val = &test_conn; - int (*custom_fakes[])(const struct bt_conn *, struct bt_conn_info *) = {bt_conn_get_info_fake1}; + int (*custom_fakes[])(const struct bt_conn *, + struct bt_conn_info *) = { bt_conn_get_info_fake1 }; SET_CUSTOM_FAKE_SEQ(bt_conn_get_info, custom_fakes, 1); sid_ble_conn_deinit(); @@ -287,7 +293,8 @@ void test_sid_ble_conn_mtu_callback_curent_connection(void) sid_ble_conn_init(); bt_conn_ref_fake.return_val = &curr_conn; - int (*custom_fakes[])(const struct bt_conn *, struct bt_conn_info *) = {bt_conn_get_info_fake1}; + int (*custom_fakes[])(const struct bt_conn *, + struct bt_conn_info *) = { bt_conn_get_info_fake1 }; SET_CUSTOM_FAKE_SEQ(bt_conn_get_info, custom_fakes, 1); __cmock_sid_ble_adapter_conn_connected_ExpectAnyArgs();