diff --git a/nimble/host/include/host/ble_hs.h b/nimble/host/include/host/ble_hs.h index 43979ba57e..2145550964 100644 --- a/nimble/host/include/host/ble_hs.h +++ b/nimble/host/include/host/ble_hs.h @@ -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 * @@ -250,6 +250,9 @@ 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. @@ -257,6 +260,9 @@ struct ble_hs_cfg { */ 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).. */ diff --git a/nimble/host/include/host/ble_uuid.h b/nimble/host/include/host/ble_uuid.h index d3576c5950..86afa94998 100644 --- a/nimble/host/include/host/ble_uuid.h +++ b/nimble/host/include/host/ble_uuid.h @@ -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), \ } @@ -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 }, \ } diff --git a/nimble/host/src/ble_hs.c b/nimble/host/src/ble_hs.c index adb8046a73..ae17066e46 100644 --- a/nimble/host/src/ble_hs.c +++ b/nimble/host/src/ble_hs.c @@ -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); @@ -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; diff --git a/porting/npl/freertos/include/nimble/nimble_port_freertos.h b/porting/npl/freertos/include/nimble/nimble_port_freertos.h index ddeefc71c1..79d467b32c 100644 --- a/porting/npl/freertos/include/nimble/nimble_port_freertos.h +++ b/porting/npl/freertos/include/nimble/nimble_port_freertos.h @@ -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 diff --git a/porting/npl/freertos/src/nimble_port_freertos.c b/porting/npl/freertos/src/nimble_port_freertos.c index f0f80561fa..1271711800 100644 --- a/porting/npl/freertos/src/nimble_port_freertos.c +++ b/porting/npl/freertos/src/nimble_port_freertos.c @@ -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 /* @@ -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