This is an automated email from the ASF dual-hosted git repository.
kopyscinski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
The following commit(s) were added to refs/heads/master by this push:
new 301cc998b host/audio/pacs: fix notifications for available contexts
301cc998b is described below
commit 301cc998b6ca5c51cafd2f39bc5843c07a1002ff
Author: Krzysztof Kopyściński <[email protected]>
AuthorDate: Thu Apr 11 10:24:16 2024 +0200
host/audio/pacs: fix notifications for available contexts
Available contexts values are per connection. When value is changed, read
access for notification gives BLE_HS_CONN_HANDLE_NONE as conn handle.
This was making impossible to fetch the right value.
Now, flag was introduced, for marking the changed value.
---
.../audio/services/pacs/src/ble_audio_svc_pacs.c | 23 ++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/nimble/host/audio/services/pacs/src/ble_audio_svc_pacs.c
b/nimble/host/audio/services/pacs/src/ble_audio_svc_pacs.c
index 25b2e0490..eb3a9244e 100644
--- a/nimble/host/audio/services/pacs/src/ble_audio_svc_pacs.c
+++ b/nimble/host/audio/services/pacs/src/ble_audio_svc_pacs.c
@@ -29,6 +29,7 @@ static struct available_ctx {
uint16_t conn_handle;
uint16_t ble_svc_audio_pacs_avail_sink_contexts;
uint16_t ble_svc_audio_pacs_avail_source_contexts;
+ uint8_t val_changed;
} ble_svc_audio_pacs_avail_contexts[MYNEWT_VAL(BLE_MAX_CONNECTIONS)] = {
[0 ... MYNEWT_VAL(BLE_MAX_CONNECTIONS) - 1] = {
.conn_handle = BLE_HS_CONN_HANDLE_NONE,
@@ -253,12 +254,20 @@ static int
ble_svc_audio_pacs_avail_audio_ctx_read_access(uint16_t conn_handle,
struct ble_gatt_access_ctxt
*ctxt)
{
- struct available_ctx *avail_ctx;
+ struct available_ctx *avail_ctx = NULL;
uint8_t *buf;
+ int i;
- avail_ctx = ble_svc_audio_pacs_find_avail_ctx(conn_handle);
- if (!avail_ctx) {
- return BLE_HS_ENOENT;
+ if (conn_handle == BLE_HS_CONN_HANDLE_NONE) {
+ for (i = 0; i < MYNEWT_VAL(BLE_MAX_CONNECTIONS); i++) {
+ if (ble_svc_audio_pacs_avail_contexts[i].val_changed) {
+ avail_ctx = &ble_svc_audio_pacs_avail_contexts[i];
+ avail_ctx->val_changed = false;
+ break;
+ }
+ }
+ } else {
+ avail_ctx = ble_svc_audio_pacs_find_avail_ctx(conn_handle);
}
buf = os_mbuf_extend(ctxt->om, 4);
@@ -266,6 +275,11 @@ ble_svc_audio_pacs_avail_audio_ctx_read_access(uint16_t
conn_handle,
return BLE_ATT_ERR_INSUFFICIENT_RES;
}
+ if (!avail_ctx) {
+ put_le32(buf + 0, 0);
+ return 0;
+ }
+
put_le16(buf + 0, avail_ctx->ble_svc_audio_pacs_avail_sink_contexts);
put_le16(buf + 2, avail_ctx->ble_svc_audio_pacs_avail_source_contexts);
@@ -409,6 +423,7 @@ ble_svc_audio_pacs_avail_contexts_set(uint16_t conn_handle,
avail_ctx->ble_svc_audio_pacs_avail_sink_contexts = sink_contexts;
avail_ctx->ble_svc_audio_pacs_avail_source_contexts = source_contexts;
+ avail_ctx->val_changed = true;
return pac_notify(BLE_SVC_AUDIO_PACS_CHR_UUID16_AVAILABLE_AUDIO_CONTEXTS);
}