Skip to content

Commit

Permalink
sbdt: disable sidewalk file transfer when in DFU mode
Browse files Browse the repository at this point in the history
To prevent conflict with SMP DFU, disable sbdt

Signed-off-by: Robert Gałat <[email protected]>
  • Loading branch information
RobertGalatNordic committed Nov 19, 2024
1 parent caa1e20 commit 4b0c6e3
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
22 changes: 22 additions & 0 deletions samples/sid_end_device/include/sbdt/dfu_file_transfer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@ void app_file_transfer_demo_init(struct sid_handle *handle);
*/
void app_file_transfer_demo_deinit(struct sid_handle *handle);

/**
* @brief Sidewalk event to handle payload of file transfer
*
* @param sid sidewalk_ctx_t object
* @param ctx sidewalk_transfer_t object
*/
void sidewalk_event_file_transfer(sidewalk_ctx_t *sid, void *ctx);

/**
* @brief Sidewalk event to deinit sbdt
*
* @param sid sidewalk_ctx_t object
* @param ctx Ignored
*/
void sidewalk_event_file_transfer_deinit(sidewalk_ctx_t *sid, void *ctx);

/**
* @brief Sidewalk event to init sbdt
*
* @param sid sidewalk_ctx_t object
* @param ctx Ignored
*/
void sidewalk_event_file_transfer_init(sidewalk_ctx_t *sid, void *ctx);

#endif /* FILE_TRANSFER_H */
7 changes: 7 additions & 0 deletions samples/sid_end_device/src/cli/app_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include <sidewalk_dfu/nordic_dfu.h>
#endif

#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU
#include <sbdt/dfu_file_transfer.h>
#endif

#define CLI_CMD_OPT_LINK_BLE 1
#define CLI_CMD_OPT_LINK_FSK 2
#define CLI_CMD_OPT_LINK_LORA 3
Expand Down Expand Up @@ -303,6 +307,9 @@ static void app_event_enter_dfu_mode(sidewalk_ctx_t *sid, void *ctx)
// shell handlers
int cmd_nordic_dfu(const struct shell *shell, int32_t argc, const char **argv)
{
#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU
sidewalk_event_send(sidewalk_event_file_transfer_deinit, NULL, NULL);
#endif
sidewalk_event_send(app_event_enter_dfu_mode, (void *)shell, NULL);
return 0;
}
Expand Down
9 changes: 9 additions & 0 deletions samples/sid_end_device/src/hello/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#include <sid_hal_reset_ifc.h>
#include <sid_hal_memory_ifc.h>
#include <stdbool.h>
#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU
#include <sbdt/dfu_file_transfer.h>
#endif

#include <sid_ble_uuid.h>
#include <bt_app_callbacks.h>
Expand Down Expand Up @@ -278,9 +281,15 @@ static void app_btn_dfu_state(uint32_t unused)
ARG_UNUSED(unused);
static bool go_to_dfu_state = true;
if (go_to_dfu_state) {
#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU
sidewalk_event_send(sidewalk_event_file_transfer_deinit, NULL, NULL);
#endif
sidewalk_event_send(app_event_enter_dfu_mode, NULL, NULL);
} else {
sidewalk_event_send(app_event_exit_dfu_mode, NULL, NULL);
#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU
sidewalk_event_send(sidewalk_event_file_transfer_init, NULL, NULL);
#endif
}

go_to_dfu_state = !go_to_dfu_state;
Expand Down
10 changes: 10 additions & 0 deletions samples/sid_end_device/src/sbdt/dfu_file_transfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,13 @@ void app_file_transfer_demo_deinit(struct sid_handle *handle)
LOG_ERR("sid_bulk_data_transfer_deinit returned %s", SID_ERROR_T_STR(err));
}
}

void sidewalk_event_file_transfer_deinit(sidewalk_ctx_t *sid, void *ctx)
{
app_file_transfer_demo_deinit(sid->handle);
}

void sidewalk_event_file_transfer_init(sidewalk_ctx_t *sid, void *ctx)
{
app_file_transfer_demo_init(sid->handle);
}
9 changes: 9 additions & 0 deletions samples/sid_end_device/src/sensor_monitoring/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include <zephyr/logging/log.h>
#include <sid_demo_parser.h>
#include <json_printer/sidTypes2str.h>
#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU
#include <sbdt/dfu_file_transfer.h>
#endif

#include <sid_ble_uuid.h>
#include <bt_app_callbacks.h>
Expand Down Expand Up @@ -189,9 +192,15 @@ static void app_btn_dfu_state(uint32_t unused)
ARG_UNUSED(unused);
static bool go_to_dfu_state = true;
if (go_to_dfu_state) {
#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU
sidewalk_event_send(sidewalk_event_file_transfer_deinit, NULL, NULL);
#endif
sidewalk_event_send(app_event_enter_dfu_mode, NULL, NULL);
} else {
sidewalk_event_send(app_event_exit_dfu_mode, NULL, NULL);
#ifdef CONFIG_SIDEWALK_FILE_TRANSFER_DFU
sidewalk_event_send(sidewalk_event_file_transfer_init, NULL, NULL);
#endif
}

go_to_dfu_state = !go_to_dfu_state;
Expand Down

0 comments on commit 4b0c6e3

Please sign in to comment.