nimble/iso: Fix missing big_handle return parameter
This fixes ble_iso_create_big to return the BIG handle created
to the API user.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
diff --git a/apps/btshell/src/cmd_iso.c b/apps/btshell/src/cmd_iso.c
index 284f021..27a9bc9 100644
--- a/apps/btshell/src/cmd_iso.c
+++ b/apps/btshell/src/cmd_iso.c
@@ -164,6 +164,7 @@
{
struct ble_iso_create_big_params params = { 0 };
struct ble_iso_big_params big_params = { 0 };
+ uint8_t big_handle;
int rc;
rc = parse_arg_init(argc - 1, argv + 1);
@@ -235,12 +236,14 @@
big_params.broadcast_code = parse_arg_extract("broadcast_code");
big_params.encryption = big_params.broadcast_code ? 1 : 0;
- rc = ble_iso_create_big(¶ms, &big_params);
+ rc = ble_iso_create_big(¶ms, &big_params, &big_handle);
if (rc != 0) {
console_printf("BIG create failed (%d)\n", rc);
return rc;
}
+ console_printf("New big_handle %u created\n", big_handle);
+
return 0;
}
diff --git a/nimble/host/audio/src/ble_audio_broadcast_source.c b/nimble/host/audio/src/ble_audio_broadcast_source.c
index d243a5f..20edcce 100644
--- a/nimble/host/audio/src/ble_audio_broadcast_source.c
+++ b/nimble/host/audio/src/ble_audio_broadcast_source.c
@@ -25,6 +25,7 @@
#if MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE)
struct ble_audio_broadcast {
SLIST_ENTRY(ble_audio_broadcast) next;
+ uint8_t big_handle;
uint8_t adv_instance;
struct ble_audio_base *base;
struct ble_iso_big_params *big_params;
@@ -332,7 +333,8 @@
return rc;
}
- rc = ble_iso_create_big(&create_big_params, broadcast->big_params);
+ rc = ble_iso_create_big(&create_big_params, broadcast->big_params,
+ &broadcast->big_handle);
if (rc) {
BLE_HS_LOG_ERROR("Failed to create BIG (rc=%d)\n", rc);
return rc;
@@ -378,7 +380,7 @@
return rc;
}
- rc = ble_iso_terminate_big(adv_instance);
+ rc = ble_iso_terminate_big(broadcast->big_handle);
if (rc) {
BLE_HS_LOG_ERROR("Failed to terminate BIG\n");
return rc;
diff --git a/nimble/host/include/host/ble_iso.h b/nimble/host/include/host/ble_iso.h
index 1bae336..ee99b96 100644
--- a/nimble/host/include/host/ble_iso.h
+++ b/nimble/host/include/host/ble_iso.h
@@ -307,6 +307,7 @@
* the BIG. These parameters include settings
* such as SDU interval, maximum SDU size,
* transport latency, etc.
+ * @param[out] big_handle BIG instance handle
*
* @return 0 on success;
* an error code on failure.
@@ -315,7 +316,8 @@
* function specified in @p create_params.
*/
int ble_iso_create_big(const struct ble_iso_create_big_params *create_params,
- const struct ble_iso_big_params *big_params);
+ const struct ble_iso_big_params *big_params,
+ uint8_t *big_handle);
/**
* Terminates an existing Broadcast Isochronous Group (BIG).
diff --git a/nimble/host/src/ble_iso.c b/nimble/host/src/ble_iso.c
index 503cdd0..76bc948 100644
--- a/nimble/host/src/ble_iso.c
+++ b/nimble/host/src/ble_iso.c
@@ -228,7 +228,8 @@
#if MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE)
int
ble_iso_create_big(const struct ble_iso_create_big_params *create_params,
- const struct ble_iso_big_params *big_params)
+ const struct ble_iso_big_params *big_params,
+ uint8_t *big_handle)
{
struct ble_hci_le_create_big_cp cp = { 0 };
struct ble_iso_big *big;
@@ -271,6 +272,8 @@
memcpy(cp.broadcast_code, big_params->broadcast_code, 16);
}
+ *big_handle = big->handle;
+
return ble_hs_hci_cmd_tx(BLE_HCI_OP(BLE_HCI_OGF_LE,
BLE_HCI_OCF_LE_CREATE_BIG),
&cp, sizeof(cp),NULL, 0);