Skip to content

Commit 1fa9dfd

Browse files
szymon-czaprackisjanc
authored andcommitted
nimble/audio: Add subgroups information for modify operation
This commit adds subgroups info for modify source operation. Now metadata field can be handled in scan delegator during modify procedure.
1 parent b0c3e4a commit 1fa9dfd

File tree

3 files changed

+27
-29
lines changed

3 files changed

+27
-29
lines changed

nimble/host/audio/services/bass/include/services/bass/ble_audio_svc_bass.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,6 @@ struct ble_svc_audio_bass_operation {
327327
/** Number of subgroups */
328328
uint16_t num_subgroups;
329329

330-
/** BIS Synchronisation of subgroups */
331-
uint32_t bis_sync[BLE_SVC_AUDIO_BASS_SUB_NUM_MAX];
332330
/** Subgroup entries */
333331
struct ble_svc_audio_bass_subgroup
334332
subgroups[BLE_SVC_AUDIO_BASS_SUB_NUM_MAX];

nimble/host/audio/services/bass/src/ble_audio_svc_bass.c

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -282,28 +282,6 @@ ble_svc_audio_bass_remote_scan_started(uint8_t *data, uint16_t data_len, uint16_
282282
return 0;
283283
}
284284

285-
static int
286-
check_bis_sync(uint16_t num_subgroups, const uint32_t *bis_sync_list)
287-
{
288-
uint32_t bis_sync_mask = 0;
289-
int i;
290-
int j;
291-
292-
for (i = 0; i < num_subgroups; i++) {
293-
if (bis_sync_list[i] != 0xFFFFFFFF) {
294-
for (j = 0; j < num_subgroups; j++) {
295-
if (bis_sync_list[i] & bis_sync_mask) {
296-
return BLE_HS_EINVAL;
297-
}
298-
299-
bis_sync_mask |= bis_sync_list[i];
300-
}
301-
}
302-
}
303-
304-
return 0;
305-
}
306-
307285
static int
308286
ble_svc_audio_bass_add_source(uint8_t *data, uint16_t data_len, uint16_t conn_handle)
309287
{
@@ -382,7 +360,7 @@ ble_svc_audio_bass_add_source(uint8_t *data, uint16_t data_len, uint16_t conn_ha
382360
data_len -= operation.add_source.subgroups[i].metadata_length;
383361

384362
if (check_bis_sync(operation.add_source.num_subgroups,
385-
operation.add_source.bis_sync)) {
363+
operation.add_source.subgroups)) {
386364
rc = BLE_HS_EINVAL;
387365
ev.bass_operation_status.status = BLE_HS_EREJECT;
388366
goto done;
@@ -466,6 +444,27 @@ ble_svc_audio_bass_add_source(uint8_t *data, uint16_t data_len, uint16_t conn_ha
466444
}
467445

468446
static int
447+
check_bis_sync(uint16_t num_subgroups, struct ble_svc_audio_bass_subgroup *subgroups)
448+
{
449+
uint32_t bis_sync_mask = 0;
450+
int i;
451+
int j;
452+
453+
for (i = 0; i < num_subgroups; i++) {
454+
if (subgroups[i].bis_sync != 0xFFFFFFFF) {
455+
for (j = 0; j < num_subgroups; j++) {
456+
if (subgroups[i].bis_sync & bis_sync_mask) {
457+
return BLE_HS_EINVAL;
458+
}
459+
460+
bis_sync_mask |= subgroups[i].bis_sync;
461+
}
462+
}
463+
}
464+
465+
return 0;
466+
}
467+
469468
ble_svc_audio_bass_modify_source(uint8_t *data, uint16_t data_len, uint16_t conn_handle)
470469
{
471470
struct ble_svc_audio_bass_operation operation;
@@ -517,7 +516,7 @@ ble_svc_audio_bass_modify_source(uint8_t *data, uint16_t data_len, uint16_t conn
517516
}
518517

519518
for (i = 0; i < operation.modify_source.num_subgroups; i++) {
520-
operation.modify_source.bis_sync[i] = get_le32(&data[offset]);
519+
operation.modify_source.subgroups.bis_sync[i] = get_le32(&data[offset]);
521520
offset += 4;
522521
operation.modify_source.subgroups[i].metadata_length = data[offset++];
523522
data_len -= 5;
@@ -532,7 +531,7 @@ ble_svc_audio_bass_modify_source(uint8_t *data, uint16_t data_len, uint16_t conn
532531
}
533532

534533
if (check_bis_sync(operation.modify_source.num_subgroups,
535-
operation.modify_source.bis_sync)) {
534+
operation.modify_source.subgroups)) {
536535
rc = BLE_HS_EINVAL;
537536
ev.bass_operation_status.status = BLE_HS_EREJECT;
538537
goto done;

nimble/host/audio/src/ble_audio_scan_delegator.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ bass_modify_source_op_handler(struct ble_svc_audio_bass_operation *op, void *arg
197197
BLE_AUDIO_DBG_ASSERT(sync_opt->num_subgroups < ARRAY_SIZE(sync_opt->subgroups));
198198

199199
for (uint8_t i = 0; i < sync_opt->num_subgroups; i++) {
200-
sync_opt->subgroups[i].bis_sync = op->modify_source.bis_sync[i];
201-
/* FIXME: Missing metadata in Modify Source */
200+
sync_opt->subgroups[i].bis_sync = op->modify_source.subgroups[i].bis_sync_state;
201+
sync_opt->subgroups[i].metadata_length = op->modify_source.subgroups[i].metadata_length;
202+
sync_opt->subgroups[i].metadata = op->modify_source.subgroups[i].metadata;
202203
}
203204

204205
action.type = BLE_AUDIO_SCAN_DELEGATOR_ACTION_SOURCE_MODIFY;

0 commit comments

Comments
 (0)