From 1b9529d55bad1f7c9166470e305a367023c74c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Ga=C5=82at?= Date: Tue, 12 Nov 2024 16:01:40 +0000 Subject: [PATCH] app: allow DFU and Sidewalk to run in parallel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit remove disabling of Sidewalk when entering to DFU mode Signed-off-by: Robert Gałat --- samples/sid_end_device/src/hello/app.c | 4 ---- samples/sid_end_device/src/sensor_monitoring/app.c | 2 -- subsys/sal/common/CMakeLists.txt | 2 ++ subsys/sal/common/sid_ifc/bt_app_callbacks.h | 4 ++-- subsys/sal/sid_pal/src/sid_ble_advert.c | 5 +++-- 5 files changed, 7 insertions(+), 10 deletions(-) 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.h b/subsys/sal/common/sid_ifc/bt_app_callbacks.h index 7abf0d24e9..2f720fcdee 100644 --- a/subsys/sal/common/sid_ifc/bt_app_callbacks.h +++ b/subsys/sal/common/sid_ifc/bt_app_callbacks.h @@ -22,9 +22,9 @@ enum BT_id_values{ #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 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 +