Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions nimble/host/include/host/ble_hs.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ extern "C" {
*
* @param reason Reason code for reset
*/
typedef void ble_hs_reset_fn(int reason);
typedef void ble_hs_reset_fn(int reason, void *arg);


/** @brief Stack sync callback */
typedef void ble_hs_sync_fn(void);
typedef void ble_hs_sync_fn(void *arg);

/** @brief Bluetooth Host main configuration structure
*
Expand Down Expand Up @@ -250,13 +250,19 @@ struct ble_hs_cfg {
*/
ble_hs_reset_fn *reset_cb;

/** An optional argument that gets passed to the reset callback. */
void *reset_cb_arg;

/** @brief Stack sync callback
*
* This callback is executed when the host and controller become synced.
* This happens at startup and after a reset.
*/
ble_hs_sync_fn *sync_cb;

/** An optional argument that gets passed to the sync callback. */
void *sync_cb_arg;

/* XXX: These need to go away. Instead, the nimble host package should
* require the host-store API (not yet implemented)..
*/
Expand Down
9 changes: 7 additions & 2 deletions nimble/host/include/host/ble_uuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ typedef union {

#define BLE_UUID16_INIT(uuid16) \
{ \
.u.type = BLE_UUID_TYPE_16, \
.u = { \
.type = BLE_UUID_TYPE_16, \
}, \
.value = (uuid16), \
}

Expand All @@ -94,7 +96,10 @@ typedef union {

#define BLE_UUID128_INIT(uuid128...) \
{ \
.u.type = BLE_UUID_TYPE_128, \
.u = \
{ \
.type = BLE_UUID_TYPE_128, \
}, \
.value = { uuid128 }, \
}

Expand Down
4 changes: 2 additions & 2 deletions nimble/host/src/ble_hs.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ ble_hs_sync(void)
}

if (ble_hs_cfg.sync_cb != NULL) {
ble_hs_cfg.sync_cb();
ble_hs_cfg.sync_cb(ble_hs_cfg.sync_cb_arg);
}

STATS_INC(ble_hs_stats, sync);
Expand Down Expand Up @@ -393,7 +393,7 @@ ble_hs_reset(void)
ble_hs_id_reset();

if (ble_hs_cfg.reset_cb != NULL && ble_hs_reset_reason != 0) {
ble_hs_cfg.reset_cb(ble_hs_reset_reason);
ble_hs_cfg.reset_cb(ble_hs_reset_reason, ble_hs_cfg.reset_cb_arg);
}
ble_hs_reset_reason = 0;

Expand Down
1 change: 1 addition & 0 deletions porting/npl/freertos/include/nimble/nimble_port_freertos.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern "C" {
#endif

void nimble_port_freertos_init(TaskFunction_t host_task_fn);
void nimble_port_freertos_init_param(TaskFunction_t host_task_fn, void * const host_task_param);
void nimble_port_freertos_deinit(void);

#ifdef __cplusplus
Expand Down
11 changes: 9 additions & 2 deletions porting/npl/freertos/src/nimble_port_freertos.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ static TaskHandle_t ll_task_h;
static TaskHandle_t host_task_h;

void
nimble_port_freertos_init(TaskFunction_t host_task_fn)
nimble_port_freertos_init_param(TaskFunction_t host_task_fn, void * const host_task_param);

void nimble_port_freertos_init(TaskFunction_t host_task_fn) {
nimble_port_freertos_init_param(host_task_fn, NULL);
}

void
nimble_port_freertos_init_param(TaskFunction_t host_task_fn, void * const host_task_param)
{
#if NIMBLE_CFG_CONTROLLER
/*
Expand All @@ -47,7 +54,7 @@ nimble_port_freertos_init(TaskFunction_t host_task_fn)
* default queue it is just easier to make separate task which does this.
*/
xTaskCreatePinnedToCore(host_task_fn, "ble", NIMBLE_STACK_SIZE,
NULL, (configMAX_PRIORITIES - 4), &host_task_h, NIMBLE_CORE);
host_task_param, (configMAX_PRIORITIES - 4), &host_task_h, NIMBLE_CORE);
}

void
Expand Down