Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-03-03 Thread via GitHub


KKopyscinski merged PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-03-03 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1510643594


##
nimble/host/audio/include/audio/ble_audio.h:
##
@@ -329,6 +536,18 @@ struct ble_audio_event_broadcast_announcement {
 struct ble_audio_broadcast_name *name;
 };
 
+/** @brief Codec Registered */
+struct ble_audio_event_codec_changed {
+/** Change type */
+enum {
+CODEC_REGISTERED,
+CODEC_UNREGISTERED,
+} change;
+
+/** Codec Record */
+const struct ble_audio_codec_record *record;
+};

Review Comment:
   Ok, I'll also give them different structs 
(`ble_audio_event_codec_registered` and `ble_audio_event_codec_unregistered`), 
maybe in the future it'll have something more than `ble_audio_codec_record`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-03-03 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1510620720


##
nimble/host/audio/syscfg.yml:
##
@@ -17,5 +17,9 @@
 #
 
 syscfg.defs:
+BLE_AUDIO_MAX_CODEC_RECORDS:
+description: >
+Maximum number of registered audio codecs.
+value: 0

Review Comment:
   I think you can have app withouth codecs registered - it's not mandatory to 
register codecs you will use. So you can for example include this package, 
create broadcast application (bare bones, just sending advertising chain and 
BISes), use some codec to encode audio and not register it. But you need to 
register so it'll be visible in PACS (and also include PACS itself).
   
   I think I should add compiler guards so ble_audio_codec.c is compiled only 
when this is >0



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-03-03 Thread via GitHub


andrzej-kaczmarek commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1510240158


##
nimble/host/audio/syscfg.yml:
##
@@ -17,5 +17,9 @@
 #
 
 syscfg.defs:
+BLE_AUDIO_MAX_CODEC_RECORDS:
+description: >
+Maximum number of registered audio codecs.
+value: 0

Review Comment:
   does it make sense to include audio package and have no audio codecs 
registered?



##
nimble/host/audio/services/pacs/lc3/pkg.yml:
##
@@ -0,0 +1,35 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+pkg.name: nimble/host/audio/services/pacs/lc3
+pkg.description: LC3 codec entry for Published Audio Capabilities Service
+pkg.author: "Apache Mynewt "
+pkg.homepage: "https://mynewt.apache.org/";
+pkg.keywords:
+  - ble
+  - bluetooth
+  - pacs
+  - nimble
+
+pkg.deps:
+  - nimble/host/audio/services/pacs
+  - nimble/host
+
+pkg.init:
+#  ble_svc_audio_pacs_lc3_init: 
'MYNEWT_VAL(BLE_SVC_AUDIO_PACS_LC3_SYSINIT_STAGE)'

Review Comment:
   remove



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-03-01 Thread via GitHub


MariuszSkamra commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1508947111


##
nimble/host/audio/include/audio/ble_audio.h:
##
@@ -329,6 +536,18 @@ struct ble_audio_event_broadcast_announcement {
 struct ble_audio_broadcast_name *name;
 };
 
+/** @brief Codec Registered */
+struct ble_audio_event_codec_changed {
+/** Change type */
+enum {
+CODEC_REGISTERED,
+CODEC_UNREGISTERED,
+} change;
+
+/** Codec Record */
+const struct ble_audio_codec_record *record;
+};

Review Comment:
   I'm not sure about this one. IMO it would be cleaner to split this into 2 
events:
   BLE_AUDIO_EVENT_CODEC_REGISTERED
   BLE_AUDIO_EVENT_CODEC_UNREGISTERED



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-03-01 Thread via GitHub


KKopyscinski commented on PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#issuecomment-1973037248

   @MariuszSkamra @rymanluk rebased onto master


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-29 Thread via GitHub


KKopyscinski commented on PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#issuecomment-1972665692

   This patch is blocked by https://github.com/apache/mynewt-nimble/pull/1714. 
I'll update this with working one once the other one is merged (There are 
issues with includes in current tree structure. They need to be fixed first, 
and this PR with  use new directories)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-29 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1507355904


##
nimble/host/include/host/ble_audio_codec.h:
##
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_AUDIO_CODEC_
+#define H_BLE_AUDIO_CODEC_
+
+/**
+ * @file ble_audio_codec.h
+ *
+ * @brief Bluetooth LE Audio Codec
+ *
+ * This header file provides the public API for managing LE Audio Codecs
+ *
+ * @defgroup ble_audio_codec Bluetooth LE Audio Codec
+ * @ingroup bt_host
+ * @{
+ *
+ * This API allows to create and manage list of LE Audio codecs with their 
capabilities and
+ * metadata. This list can be used by higher level services, like PACS. Memory 
management of
+ * codec entries is left to application and neither static nor dynamic 
allocation is enforced.
+ *
+ */
+
+#include "stdint.h"
+#include "ble_audio_common.h"
+
+#define BLE_AUDIO_CODEC_FLAG_SOURCE 0x01
+#define BLE_AUDIO_CODEC_FLAG_SINK   0x02
+
+/** OP Codes for Codec events */
+enum ble_audio_codec_event_op {
+/** Codec was registered */
+BLE_AUDIO_CODEC_REGISTERED_EVENT,
+/** Codec was unregistered */
+BLE_AUDIO_CODEC_UNREGISTERED_EVENT
+};
+
+/** Codec list entry */
+struct ble_audio_codec_record {
+/* Pointer to next codec list entry */
+STAILQ_ENTRY(ble_audio_codec_record) next;
+
+/* Codec ID */
+struct ble_audio_codec_id codec_id;
+
+/* Length of Codec Specific Capabilities */
+uint8_t codec_spec_caps_len;
+
+/* Codec Specific Capabilities data */
+const uint8_t *codec_spec_caps;
+
+/* Metadata length */
+uint8_t metadata_len;
+
+/* Metadata */
+const uint8_t *metadata;
+
+/* Codec entry flags. It is any combination of following flags:
+ *  - BLE_AUDIO_CODEC_FLAG_SOURCE
+ *  - BLE_AUDIO_CODEC_FLAG_SINK
+ */
+uint8_t flags;
+};
+
+/** Type definition codec iteration callback function. */
+typedef int ble_audio_codec_foreach_fn(const struct ble_audio_codec_record 
*record, void *arg);
+
+struct ble_audio_codec_register_params {
+/* Codec ID structure */
+struct ble_audio_codec_id codec_id;
+
+/* Codec Specific Capabilities length */
+uint8_t codec_spec_caps_len;
+
+/* Codec Specific Capabilities data */
+uint8_t *codec_spec_caps;
+
+/* Metadata length */
+uint8_t metadata_len;
+
+/* Metadata */
+uint8_t *metadata;
+
+/* Codec entry flags. It is any combination of following flags:
+ *  - BLE_AUDIO_CODEC_FLAG_SOURCE
+ *  - BLE_AUDIO_CODEC_FLAG_SINK
+ */
+uint8_t flags;

Review Comment:
   changed to bitfield as in 
https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1502183969, and 
renamed to direction



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-29 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1507354199


##
nimble/host/include/host/ble_audio_codec.h:
##
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_AUDIO_CODEC_
+#define H_BLE_AUDIO_CODEC_
+
+/**
+ * @file ble_audio_codec.h
+ *
+ * @brief Bluetooth LE Audio Codec
+ *
+ * This header file provides the public API for managing LE Audio Codecs
+ *
+ * @defgroup ble_audio_codec Bluetooth LE Audio Codec
+ * @ingroup bt_host
+ * @{
+ *
+ * This API allows to create and manage list of LE Audio codecs with their 
capabilities and
+ * metadata. This list can be used by higher level services, like PACS. Memory 
management of
+ * codec entries is left to application and neither static nor dynamic 
allocation is enforced.
+ *
+ */
+
+#include "stdint.h"
+#include "ble_audio_common.h"
+
+#define BLE_AUDIO_CODEC_FLAG_SOURCE 0x01
+#define BLE_AUDIO_CODEC_FLAG_SINK   0x02
+
+/** OP Codes for Codec events */
+enum ble_audio_codec_event_op {
+/** Codec was registered */
+BLE_AUDIO_CODEC_REGISTERED_EVENT,
+/** Codec was unregistered */
+BLE_AUDIO_CODEC_UNREGISTERED_EVENT
+};
+
+/** Codec list entry */
+struct ble_audio_codec_record {
+/* Pointer to next codec list entry */
+STAILQ_ENTRY(ble_audio_codec_record) next;
+
+/* Codec ID */
+struct ble_audio_codec_id codec_id;
+
+/* Length of Codec Specific Capabilities */
+uint8_t codec_spec_caps_len;
+
+/* Codec Specific Capabilities data */
+const uint8_t *codec_spec_caps;
+
+/* Metadata length */
+uint8_t metadata_len;
+
+/* Metadata */
+const uint8_t *metadata;
+
+/* Codec entry flags. It is any combination of following flags:
+ *  - BLE_AUDIO_CODEC_FLAG_SOURCE
+ *  - BLE_AUDIO_CODEC_FLAG_SINK
+ */
+uint8_t flags;
+};
+
+/** Type definition codec iteration callback function. */
+typedef int ble_audio_codec_foreach_fn(const struct ble_audio_codec_record 
*record, void *arg);
+
+struct ble_audio_codec_register_params {
+/* Codec ID structure */
+struct ble_audio_codec_id codec_id;
+
+/* Codec Specific Capabilities length */
+uint8_t codec_spec_caps_len;
+
+/* Codec Specific Capabilities data */
+uint8_t *codec_spec_caps;
+
+/* Metadata length */
+uint8_t metadata_len;
+
+/* Metadata */
+uint8_t *metadata;
+
+/* Codec entry flags. It is any combination of following flags:
+ *  - BLE_AUDIO_CODEC_FLAG_SOURCE
+ *  - BLE_AUDIO_CODEC_FLAG_SINK
+ */
+uint8_t flags;
+};
+
+/**
+ * @brief Register codec entry
+ *
+ * @param[in] paramsPointer to a 
`ble_audio_codec_register_params`
+ *  structure that defines Codec Specific 
Capabilities
+ * @param[in] cbFunction used to parse Codec
+ *  Specific Capabilities
+ * @param[in] cb_argOptional callback argument.
+ * @param[out] out_record   Pointer to registered codec entry.
+ *
+ * @return  0 on success;
+ *  A non-zero value on failure.
+ */
+int ble_audio_codec_register(const struct ble_audio_codec_register_params
+ *params,
+ struct ble_audio_codec_record *out_record);
+/**
+ * @brief Remove codec entry from register
+ *
+ * @param[in] codec_record  Pointer to registered codec entry.
+ *
+ * @return  0 on success;
+ *  A non-zero value on failure.
+ */
+int ble_audio_codec_unregister(struct ble_audio_codec_record *codec_record);
+
+/**
+ * @brief Iterate through all registered codecs and call function on every
+ *one of them.
+ *
+ * @param[in] cbCallback to be called on codec entries.
+ * @param[in] arg   Optional callback argument.
+ * @param[in] flags Codec entry flags. It is any
+ *  combination of foll

Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-28 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1505645615


##
nimble/host/include/host/ble_audio_codec.h:
##
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_AUDIO_CODEC_
+#define H_BLE_AUDIO_CODEC_
+
+/**
+ * @file ble_audio_codec.h
+ *
+ * @brief Bluetooth LE Audio Codec
+ *
+ * This header file provides the public API for managing LE Audio Codecs
+ *
+ * @defgroup ble_audio_codec Bluetooth LE Audio Codec
+ * @ingroup bt_host
+ * @{
+ *
+ * This API allows to create and manage list of LE Audio codecs with their 
capabilities and
+ * metadata. This list can be used by higher level services, like PACS. Memory 
management of
+ * codec entries is left to application and neither static nor dynamic 
allocation is enforced.
+ *
+ */
+
+#include "stdint.h"
+#include "ble_audio_common.h"
+
+#define BLE_AUDIO_CODEC_FLAG_SOURCE 0x01
+#define BLE_AUDIO_CODEC_FLAG_SINK   0x02
+
+/** OP Codes for Codec events */
+enum ble_audio_codec_event_op {
+/** Codec was registered */
+BLE_AUDIO_CODEC_REGISTERED_EVENT,
+/** Codec was unregistered */
+BLE_AUDIO_CODEC_UNREGISTERED_EVENT
+};
+
+/** Codec list entry */
+struct ble_audio_codec_record {
+/* Pointer to next codec list entry */
+STAILQ_ENTRY(ble_audio_codec_record) next;
+
+/* Codec ID */
+struct ble_audio_codec_id codec_id;
+
+/* Length of Codec Specific Capabilities */
+uint8_t codec_spec_caps_len;
+
+/* Codec Specific Capabilities data */
+const uint8_t *codec_spec_caps;
+
+/* Metadata length */
+uint8_t metadata_len;
+
+/* Metadata */
+const uint8_t *metadata;
+
+/* Codec entry flags. It is any combination of following flags:
+ *  - BLE_AUDIO_CODEC_FLAG_SOURCE
+ *  - BLE_AUDIO_CODEC_FLAG_SINK
+ */
+uint8_t flags;
+};
+
+/** Type definition codec iteration callback function. */
+typedef int ble_audio_codec_foreach_fn(const struct ble_audio_codec_record 
*record, void *arg);
+
+struct ble_audio_codec_register_params {
+/* Codec ID structure */
+struct ble_audio_codec_id codec_id;
+
+/* Codec Specific Capabilities length */
+uint8_t codec_spec_caps_len;
+
+/* Codec Specific Capabilities data */
+uint8_t *codec_spec_caps;
+
+/* Metadata length */
+uint8_t metadata_len;
+
+/* Metadata */
+uint8_t *metadata;
+
+/* Codec entry flags. It is any combination of following flags:
+ *  - BLE_AUDIO_CODEC_FLAG_SOURCE
+ *  - BLE_AUDIO_CODEC_FLAG_SINK
+ */
+uint8_t flags;
+};
+
+/**
+ * @brief Register codec entry
+ *
+ * @param[in] paramsPointer to a 
`ble_audio_codec_register_params`
+ *  structure that defines Codec Specific 
Capabilities
+ * @param[in] cbFunction used to parse Codec
+ *  Specific Capabilities
+ * @param[in] cb_argOptional callback argument.
+ * @param[out] out_record   Pointer to registered codec entry.
+ *
+ * @return  0 on success;
+ *  A non-zero value on failure.
+ */
+int ble_audio_codec_register(const struct ble_audio_codec_register_params
+ *params,
+ struct ble_audio_codec_record *out_record);
+/**
+ * @brief Remove codec entry from register
+ *
+ * @param[in] codec_record  Pointer to registered codec entry.
+ *
+ * @return  0 on success;
+ *  A non-zero value on failure.
+ */
+int ble_audio_codec_unregister(struct ble_audio_codec_record *codec_record);
+
+/**
+ * @brief Iterate through all registered codecs and call function on every
+ *one of them.
+ *
+ * @param[in] cbCallback to be called on codec entries.
+ * @param[in] arg   Optional callback argument.
+ * @param[in] flags Codec entry flags. It is any
+ *  combination of foll

Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-27 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1505462253


##
nimble/host/include/host/ble_audio_codec.h:
##
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_AUDIO_CODEC_
+#define H_BLE_AUDIO_CODEC_
+
+/**
+ * @file ble_audio_codec.h
+ *
+ * @brief Bluetooth LE Audio Codec
+ *
+ * This header file provides the public API for managing LE Audio Codecs
+ *
+ * @defgroup ble_audio_codec Bluetooth LE Audio Codec
+ * @ingroup bt_host
+ * @{
+ *
+ * This API allows to create and manage list of LE Audio codecs with their 
capabilities and
+ * metadata. This list can be used by higher level services, like PACS. Memory 
management of
+ * codec entries is left to application and neither static nor dynamic 
allocation is enforced.
+ *
+ */
+
+#include "stdint.h"
+#include "ble_audio_common.h"
+
+#define BLE_AUDIO_CODEC_FLAG_SOURCE 0x01
+#define BLE_AUDIO_CODEC_FLAG_SINK   0x02
+
+/** OP Codes for Codec events */
+enum ble_audio_codec_event_op {
+/** Codec was registered */
+BLE_AUDIO_CODEC_REGISTERED_EVENT,
+/** Codec was unregistered */
+BLE_AUDIO_CODEC_UNREGISTERED_EVENT
+};
+
+/** Codec list entry */
+struct ble_audio_codec_record {
+/* Pointer to next codec list entry */
+STAILQ_ENTRY(ble_audio_codec_record) next;
+
+/* Codec ID */
+struct ble_audio_codec_id codec_id;
+
+/* Length of Codec Specific Capabilities */
+uint8_t codec_spec_caps_len;
+
+/* Codec Specific Capabilities data */
+const uint8_t *codec_spec_caps;
+
+/* Metadata length */
+uint8_t metadata_len;
+
+/* Metadata */
+const uint8_t *metadata;
+
+/* Codec entry flags. It is any combination of following flags:
+ *  - BLE_AUDIO_CODEC_FLAG_SOURCE
+ *  - BLE_AUDIO_CODEC_FLAG_SINK
+ */
+uint8_t flags;

Review Comment:
   I'll change it to bits as in 
https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1502183969 And I 
think it's good idea to change `ble_svc_audio_pacs_set` too: rename `flags` 
argument to direction, and change `switch` statement to ifs, so we can set both 
at the same time, if params are to be the same. That way, we can truly use bits 
for marking both directions



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-26 Thread via GitHub


rymanluk commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1502185811


##
nimble/host/services/audio/pacs/lc3/syscfg.yml:
##
@@ -0,0 +1,136 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+syscfg.defs:
+BLE_SVC_AUDIO_PACS_LC3_SRC_SAMPLING_FREQUENCIES:
+description: >
+Sampling frequencies supported by LC3 codec, as source. This 
setting is mandatory.
+Accepts any combination of values defined in Bluetooth Assigned 
Numbers 6.12.4.1.
+Default value: 48000Hz
+value: 0x80
+restrictions:
+- $notnull
+BLE_SVC_AUDIO_PACS_LC3_SRC_FRAME_DURATIONS:
+description: >
+Frame Durations supported by LC3 codec, as source. This setting is 
mandatory.
+Accepts any combination of values defined in Bluetooth Assigned 
Numbers 6.12.4.2.
+Default value: 7.5ms and 10ms supported, 10ms preferred.
+value: 0x23
+restrictions:
+- $notnull
+BLE_SVC_AUDIO_PACS_LC3_SRC_AUDIO_CHANNEL_COUNTS:
+description: >
+Audio Channel Counts supported by LC3 codec, as source. This 
setting is optional.
+Accepts any combination of values defined in Bluetooth Assigned 
Numbers 6.12.4.3.
+value:
+BLE_SVC_AUDIO_PACS_LC3_SRC_MIN_OCTETS_PER_CODEC_FRAME:
+description: >
+Minimum number of Octets Per Codec Frame supported by LC3 codec, 
as source.
+This setting is mandatory. Default value: 80
+value: 80
+restrictions:
+- $notnull
+BLE_SVC_AUDIO_PACS_LC3_SRC_MAX_OCTETS_PER_CODEC_FRAME:
+description: >
+Maximum number of Octets Per Codec Frame supported by LC3 codec, 
as source.
+This setting is mandatory. Default value: 120
+value: 120
+restrictions:
+- $notnull
+BLE_SVC_AUDIO_PACS_LC3_SRC_MAX_CODEC_FRAMES_PER_SDU:
+description: >
+Maximum number of Codec Frames Per SDU supported by LC3 codec, as 
source.
+This setting is optional.
+value:
+BLE_SVC_AUDIO_PACS_LC3_SRC_METADATA:
+description: >
+Optional Metadata to be attached to source codec capabilities. 
This value shall be in
+form of bytes forming LTVs of Metadata. Example: '0x03, 0x01, 
0x00, 0x08'
+(lenght = 3, type = 0x01 (Preferred_Audio_Contexts), 0x00, 0x04 
(Media))
+value:
+BLE_SVC_AUDIO_PACS_LC3_SRC_AUDIO_LOCATIONS:
+description: >
+Audio Locations supported by source codec. Value is an any 
combination of values defined
+in Bluetooth Assigned Numbers 6.12.1. Default: Front Left and 
Front Right
+value: 0x0003
+BLE_SVC_AUDIO_PACS_LC3_SRC_SUP_CONTEXTS:
+description: >
+Audio Locations supported by source codec. Value is an any 
combination of values defined
+in Bluetooth Assigned Numbers 6.12.3. Default: Media
+value: 0x0004
+
+BLE_SVC_AUDIO_PACS_LC3_SNK_SAMPLING_FREQUENCIES:
+description: >
+Sampling frequencies supported by LC3 codec, as sink. This setting 
is mandatory.
+Accepts any combination of values defined in Bluetooth Assigned 
Numbers 6.12.4.1.
+Default value: 48000Hz
+value: 0x80
+restrictions:
+- $notnull
+BLE_SVC_AUDIO_PACS_LC3_SNK_FRAME_DURATIONS:
+description: >
+Frame Durations supported by LC3 codec, as sink. This setting is 
mandatory.
+Accepts any combination of values defined in Bluetooth Assigned 
Numbers 6.12.4.2.
+Default value: 7.5ms and 10ms supported, 10ms preferred.
+value: 0x23
+restrictions:
+- $notnull
+BLE_SVC_AUDIO_PACS_LC3_SNK_AUDIO_CHANNEL_COUNTS:
+description: >
+Audio Channel Counts supported by LC3 codec, as sink. This setting 
is optional.
+Accepts any combination of values defined in Bluetooth Assigned 
Numbers 6.12.4.3.
+value:
+BLE_SVC_AUDIO_PACS_LC3_SNK_MIN_OCTETS_PER_CODEC_FRAME:
+description: >
+Minimum number of Octets Pe

Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-26 Thread via GitHub


rymanluk commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1502183969


##
nimble/host/include/host/ble_audio_codec.h:
##
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_AUDIO_CODEC_
+#define H_BLE_AUDIO_CODEC_
+
+/**
+ * @file ble_audio_codec.h
+ *
+ * @brief Bluetooth LE Audio Codec
+ *
+ * This header file provides the public API for managing LE Audio Codecs
+ *
+ * @defgroup ble_audio_codec Bluetooth LE Audio Codec
+ * @ingroup bt_host
+ * @{
+ *
+ * This API allows to create and manage list of LE Audio codecs with their 
capabilities and
+ * metadata. This list can be used by higher level services, like PACS. Memory 
management of
+ * codec entries is left to application and neither static nor dynamic 
allocation is enforced.
+ *
+ */
+
+#include "stdint.h"
+#include "ble_audio_common.h"
+
+#define BLE_AUDIO_CODEC_FLAG_SOURCE 0x01
+#define BLE_AUDIO_CODEC_FLAG_SINK   0x02

Review Comment:
   #define BLE_AUDIO_CODEC_FLAG_SOURCE_BIT  (1 << 0)
   #define BLE_AUDIO_CODEC_FLAG_SINK_BIT (1 << 1)
   
   ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-26 Thread via GitHub


rymanluk commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1502179021


##
nimble/host/include/host/ble_audio_codec.h:
##
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_AUDIO_CODEC_
+#define H_BLE_AUDIO_CODEC_
+
+/**
+ * @file ble_audio_codec.h
+ *
+ * @brief Bluetooth LE Audio Codec
+ *
+ * This header file provides the public API for managing LE Audio Codecs
+ *
+ * @defgroup ble_audio_codec Bluetooth LE Audio Codec
+ * @ingroup bt_host
+ * @{
+ *
+ * This API allows to create and manage list of LE Audio codecs with their 
capabilities and
+ * metadata. This list can be used by higher level services, like PACS. Memory 
management of
+ * codec entries is left to application and neither static nor dynamic 
allocation is enforced.
+ *
+ */
+
+#include "stdint.h"
+#include "ble_audio_common.h"
+
+#define BLE_AUDIO_CODEC_FLAG_SOURCE 0x01
+#define BLE_AUDIO_CODEC_FLAG_SINK   0x02
+
+/** OP Codes for Codec events */
+enum ble_audio_codec_event_op {
+/** Codec was registered */
+BLE_AUDIO_CODEC_REGISTERED_EVENT,
+/** Codec was unregistered */
+BLE_AUDIO_CODEC_UNREGISTERED_EVENT
+};
+
+/** Codec list entry */
+struct ble_audio_codec_record {
+/* Pointer to next codec list entry */
+STAILQ_ENTRY(ble_audio_codec_record) next;
+
+/* Codec ID */
+struct ble_audio_codec_id codec_id;
+
+/* Length of Codec Specific Capabilities */
+uint8_t codec_spec_caps_len;
+
+/* Codec Specific Capabilities data */
+const uint8_t *codec_spec_caps;
+
+/* Metadata length */
+uint8_t metadata_len;
+
+/* Metadata */
+const uint8_t *metadata;
+
+/* Codec entry flags. It is any combination of following flags:
+ *  - BLE_AUDIO_CODEC_FLAG_SOURCE
+ *  - BLE_AUDIO_CODEC_FLAG_SINK
+ */
+uint8_t flags;

Review Comment:
   is it bitmask? Despite direction, do we expect other flags?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-22 Thread via GitHub


MariuszSkamra commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1499055152


##
nimble/host/include/host/ble_audio_codec.h:
##
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_AUDIO_CODEC_
+#define H_BLE_AUDIO_CODEC_
+
+/**
+ * @file ble_audio_codec.h
+ *
+ * @brief Bluetooth LE Audio Codec
+ *
+ * This header file provides the public API for managing LE Audio Codecs
+ *
+ * @defgroup ble_audio_codec Bluetooth LE Audio Codec
+ * @ingroup bt_host
+ * @{
+ *
+ * This API allows to create and manage list of LE Audio codecs with their 
capabilities and
+ * metadata. This list can be used by higher level services, like PACS. Memory 
management of
+ * codec entries is left to application and neither static nor dynamic 
allocation is enforced.
+ *
+ */
+
+#include "stdint.h"
+#include "ble_audio_common.h"
+
+#define BLE_AUDIO_CODEC_FLAG_SOURCE 0x01
+#define BLE_AUDIO_CODEC_FLAG_SINK   0x02

Review Comment:
   Could this be an enum?



##
nimble/host/include/host/ble_audio_codec.h:
##
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_AUDIO_CODEC_
+#define H_BLE_AUDIO_CODEC_
+
+/**
+ * @file ble_audio_codec.h
+ *
+ * @brief Bluetooth LE Audio Codec
+ *
+ * This header file provides the public API for managing LE Audio Codecs
+ *
+ * @defgroup ble_audio_codec Bluetooth LE Audio Codec
+ * @ingroup bt_host
+ * @{
+ *
+ * This API allows to create and manage list of LE Audio codecs with their 
capabilities and
+ * metadata. This list can be used by higher level services, like PACS. Memory 
management of
+ * codec entries is left to application and neither static nor dynamic 
allocation is enforced.
+ *
+ */
+
+#include "stdint.h"
+#include "ble_audio_common.h"
+
+#define BLE_AUDIO_CODEC_FLAG_SOURCE 0x01
+#define BLE_AUDIO_CODEC_FLAG_SINK   0x02
+
+/** OP Codes for Codec events */
+enum ble_audio_codec_event_op {
+/** Codec was registered */
+BLE_AUDIO_CODEC_REGISTERED_EVENT,
+/** Codec was unregistered */
+BLE_AUDIO_CODEC_UNREGISTERED_EVENT
+};
+
+/** Codec list entry */
+struct ble_audio_codec_record {
+/* Pointer to next codec list entry */
+STAILQ_ENTRY(ble_audio_codec_record) next;
+
+/* Codec ID */
+struct ble_audio_codec_id codec_id;
+
+/* Length of Codec Specific Capabilities */
+uint8_t codec_spec_caps_len;
+
+/* Codec Specific Capabilities data */
+const uint8_t *codec_spec_caps;
+
+/* Metadata length */
+uint8_t metadata_len;
+
+/* Metadata */
+const uint8_t *metadata;
+
+/* Codec entry flags. It is any combination of following flags:
+ *  - BLE_AUDIO_CODEC_FLAG_SOURCE
+ *  - BLE_AUDIO_CODEC_FLAG_SINK
+ */
+uint8_t flags;
+};
+
+/** Type definition codec iteration callback function. */
+typedef int ble_audio_codec_foreach_fn(const struct ble_audio_codec_record 
*record, void *arg);
+
+struct ble_audio_codec_register_params {
+/* Codec ID structure */
+struct ble_audio_codec_id codec_id;
+
+/* Codec Specific Capabilities length */
+uint8_t codec_spec_caps_len;
+
+/* Codec Specific Capabilities data */
+uint8_t *codec_spec_caps;
+
+/* Metadata length */
+uint8_t metadata_len;
+
+/* Metadata */
+uint8_t *metada

Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-14 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1489404323


##
nimble/host/services/audio/pacs/src/ble_audio_svc_pacs.c:
##
@@ -0,0 +1,434 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "host/ble_hs.h"
+#include "host/ble_gatt.h"
+#include "host/ble_audio_codec.h"
+#include "services/pacs/ble_audio_svc_pacs.h"
+
+static uint32_t ble_svc_audio_pacs_sink_audio_locations;
+static uint32_t ble_svc_audio_pacs_source_audio_locations;
+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;
+}  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,
+.ble_svc_audio_pacs_avail_sink_contexts = 0,
+.ble_svc_audio_pacs_avail_source_contexts = 0
+}
+};
+static uint16_t ble_svc_audio_pacs_sup_sink_contexts;
+static uint16_t ble_svc_audio_pacs_sup_source_contexts;
+
+static struct ble_gap_event_listener ble_pacs_listener;
+
+struct pac_read_cb_arg {
+struct os_mbuf *om;
+uint8_t pac_count;
+};
+
+static int
+ble_svc_audio_pacs_access(uint16_t conn_handle, uint16_t attr_handle,
+  struct ble_gatt_access_ctxt *ctxt, void *arg);
+
+static const struct ble_gatt_svc_def ble_svc_audio_pacs_defs[] = {
+{ /*** Service: Published Audio Capabilities Service (PACS) */
+.type = BLE_GATT_SVC_TYPE_PRIMARY,
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_UUID16),
+.characteristics = (struct ble_gatt_chr_def[]) { {
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_AVAILABLE_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC | 
BLE_GATT_CHR_F_NOTIFY,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SUPPORTED_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+}, {
+0, /* No more characteristics in this service */
+}
+}
+},
+{
+0, /* No more services. */
+},
+};
+
+static int
+codec_record_to_pacs_entry(const struct ble_audio_codec_record *record, void 
*arg)
+{
+struct pac_read_cb_arg *cb_arg = (struct pac_read_cb_arg *)arg;
+uint8_t *buf;
+int rc;
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_id.format, sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+buf = os_mbuf_extend(cb_arg->om, 4);
+if (buf == NULL) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+put_le16(buf + 0, record->codec_id.company_id);
+put_le16(buf + 2, record->codec_id.vendor_specific);
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_spec_caps_len, 
sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+rc = os_mbuf_append(cb_arg->om, record->codec_spec_caps, 
record->codec_spec_caps_len);
+if (rc) {
+return BLE_ATT_ERR_INSU

Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-14 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1489403992


##
nimble/host/services/audio/pacs/src/ble_audio_svc_pacs.c:
##
@@ -0,0 +1,434 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "host/ble_hs.h"
+#include "host/ble_gatt.h"
+#include "host/ble_audio_codec.h"
+#include "services/pacs/ble_audio_svc_pacs.h"
+
+static uint32_t ble_svc_audio_pacs_sink_audio_locations;
+static uint32_t ble_svc_audio_pacs_source_audio_locations;
+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;
+}  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,
+.ble_svc_audio_pacs_avail_sink_contexts = 0,
+.ble_svc_audio_pacs_avail_source_contexts = 0
+}
+};
+static uint16_t ble_svc_audio_pacs_sup_sink_contexts;
+static uint16_t ble_svc_audio_pacs_sup_source_contexts;
+
+static struct ble_gap_event_listener ble_pacs_listener;
+
+struct pac_read_cb_arg {
+struct os_mbuf *om;
+uint8_t pac_count;
+};
+
+static int
+ble_svc_audio_pacs_access(uint16_t conn_handle, uint16_t attr_handle,
+  struct ble_gatt_access_ctxt *ctxt, void *arg);
+
+static const struct ble_gatt_svc_def ble_svc_audio_pacs_defs[] = {
+{ /*** Service: Published Audio Capabilities Service (PACS) */
+.type = BLE_GATT_SVC_TYPE_PRIMARY,
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_UUID16),
+.characteristics = (struct ble_gatt_chr_def[]) { {
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_AUDIO_LOCATIONS),

Review Comment:
   done as suggested



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-14 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1489403390


##
nimble/host/services/audio/pacs/syscfg.yml:
##
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+syscfg.defs:
+  BLE_SVC_AUDIO_PACS_SYSINIT_STAGE:
+description: >
+  Sysinit stage for Published Audio Capabilities Service.
+value: 303

Review Comment:
   Added syscfg for all characteristics, compliant with PACS Table 3.1. All 
optional notifications are togglable, as well as optional characteristics. At 
least PAC Sink or Source must be enabled



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-14 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1489396806


##
nimble/host/services/audio/pacs/pkg.yml:
##
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+pkg.name: nimble/host/services/audio/pacs
+pkg.description: Published Audio Capabilities Service

Review Comment:
   described here now:
   
https://github.com/apache/mynewt-nimble/pull/1675/files#diff-178ede07be6e74aa4413ba875159639488343779da1b0d31cd715403528679a6R34



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-12 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1486142649


##
nimble/host/services/audio/pacs/src/ble_audio_svc_pacs.c:
##
@@ -0,0 +1,434 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "host/ble_hs.h"
+#include "host/ble_gatt.h"
+#include "host/ble_audio_codec.h"
+#include "services/pacs/ble_audio_svc_pacs.h"
+
+static uint32_t ble_svc_audio_pacs_sink_audio_locations;
+static uint32_t ble_svc_audio_pacs_source_audio_locations;
+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;
+}  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,
+.ble_svc_audio_pacs_avail_sink_contexts = 0,
+.ble_svc_audio_pacs_avail_source_contexts = 0
+}
+};
+static uint16_t ble_svc_audio_pacs_sup_sink_contexts;
+static uint16_t ble_svc_audio_pacs_sup_source_contexts;
+
+static struct ble_gap_event_listener ble_pacs_listener;
+
+struct pac_read_cb_arg {
+struct os_mbuf *om;
+uint8_t pac_count;
+};
+
+static int
+ble_svc_audio_pacs_access(uint16_t conn_handle, uint16_t attr_handle,
+  struct ble_gatt_access_ctxt *ctxt, void *arg);
+
+static const struct ble_gatt_svc_def ble_svc_audio_pacs_defs[] = {
+{ /*** Service: Published Audio Capabilities Service (PACS) */
+.type = BLE_GATT_SVC_TYPE_PRIMARY,
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_UUID16),
+.characteristics = (struct ble_gatt_chr_def[]) { {
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_AVAILABLE_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC | 
BLE_GATT_CHR_F_NOTIFY,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SUPPORTED_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+}, {
+0, /* No more characteristics in this service */
+}
+}
+},
+{
+0, /* No more services. */
+},
+};
+
+static int
+codec_record_to_pacs_entry(const struct ble_audio_codec_record *record, void 
*arg)
+{
+struct pac_read_cb_arg *cb_arg = (struct pac_read_cb_arg *)arg;
+uint8_t *buf;
+int rc;
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_id.format, sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+buf = os_mbuf_extend(cb_arg->om, 4);
+if (buf == NULL) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+put_le16(buf + 0, record->codec_id.company_id);
+put_le16(buf + 2, record->codec_id.vendor_specific);
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_spec_caps_len, 
sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+rc = os_mbuf_append(cb_arg->om, record->codec_spec_caps, 
record->codec_spec_caps_len);
+if (rc) {
+return BLE_ATT_ERR_INSU

Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-12 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1486021687


##
nimble/host/services/audio/pacs/src/ble_audio_svc_pacs.c:
##
@@ -0,0 +1,434 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "host/ble_hs.h"
+#include "host/ble_gatt.h"
+#include "host/ble_audio_codec.h"
+#include "services/pacs/ble_audio_svc_pacs.h"
+
+static uint32_t ble_svc_audio_pacs_sink_audio_locations;
+static uint32_t ble_svc_audio_pacs_source_audio_locations;
+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;
+}  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,
+.ble_svc_audio_pacs_avail_sink_contexts = 0,
+.ble_svc_audio_pacs_avail_source_contexts = 0
+}
+};
+static uint16_t ble_svc_audio_pacs_sup_sink_contexts;
+static uint16_t ble_svc_audio_pacs_sup_source_contexts;
+
+static struct ble_gap_event_listener ble_pacs_listener;
+
+struct pac_read_cb_arg {
+struct os_mbuf *om;
+uint8_t pac_count;
+};
+
+static int
+ble_svc_audio_pacs_access(uint16_t conn_handle, uint16_t attr_handle,
+  struct ble_gatt_access_ctxt *ctxt, void *arg);
+
+static const struct ble_gatt_svc_def ble_svc_audio_pacs_defs[] = {
+{ /*** Service: Published Audio Capabilities Service (PACS) */
+.type = BLE_GATT_SVC_TYPE_PRIMARY,
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_UUID16),
+.characteristics = (struct ble_gatt_chr_def[]) { {
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_AVAILABLE_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC | 
BLE_GATT_CHR_F_NOTIFY,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SUPPORTED_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+}, {
+0, /* No more characteristics in this service */
+}
+}
+},
+{
+0, /* No more services. */
+},
+};
+
+static int
+codec_record_to_pacs_entry(const struct ble_audio_codec_record *record, void 
*arg)
+{
+struct pac_read_cb_arg *cb_arg = (struct pac_read_cb_arg *)arg;
+uint8_t *buf;
+int rc;
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_id.format, sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+buf = os_mbuf_extend(cb_arg->om, 4);
+if (buf == NULL) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+put_le16(buf + 0, record->codec_id.company_id);
+put_le16(buf + 2, record->codec_id.vendor_specific);
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_spec_caps_len, 
sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+rc = os_mbuf_append(cb_arg->om, record->codec_spec_caps, 
record->codec_spec_caps_len);
+if (rc) {
+return BLE_ATT_ERR_INSU

Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-12 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1486013917


##
nimble/host/services/audio/pacs/lc3/include/services/pacs/ble_audio_svc_pacs_lc3.h:
##
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_AUDIO_SVC_PACS_LC3_
+#define H_BLE_AUDIO_SVC_PACS_LC3_
+

Review Comment:
   doxygen about more LC3 pacs



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-12 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1485933760


##
nimble/host/services/audio/pacs/lc3/syscfg.yml:
##
@@ -0,0 +1,136 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+syscfg.defs:
+BLE_SVC_AUDIO_PACS_LC3_SRC_SAMPLING_FREQUENCIES:
+description: >
+Sampling frequencies supported by LC3 codec, as source. This 
setting is mandatory.
+Accepts any combination of values defined in Bluetooth Assigned 
Numbers 6.12.4.1.
+Default value: 48000Hz
+value: 0x80
+restrictions:
+- $notnull
+BLE_SVC_AUDIO_PACS_LC3_SRC_FRAME_DURATIONS:
+description: >
+Frame Durations supported by LC3 codec, as source. This setting is 
mandatory.
+Accepts any combination of values defined in Bluetooth Assigned 
Numbers 6.12.4.2.
+Default value: 7.5ms and 10ms supported, 10ms preferred.
+value: 0x23
+restrictions:
+- $notnull
+BLE_SVC_AUDIO_PACS_LC3_SRC_AUDIO_CHANNEL_COUNTS:
+description: >
+Audio Channel Counts supported by LC3 codec, as source. This 
setting is optional.
+Accepts any combination of values defined in Bluetooth Assigned 
Numbers 6.12.4.3.
+value:
+BLE_SVC_AUDIO_PACS_LC3_SRC_MIN_OCTETS_PER_CODEC_FRAME:
+description: >
+Minimum number of Octets Per Codec Frame supported by LC3 codec, 
as source.
+This setting is mandatory. Default value: 80
+value: 80
+restrictions:
+- $notnull
+BLE_SVC_AUDIO_PACS_LC3_SRC_MAX_OCTETS_PER_CODEC_FRAME:
+description: >
+Maximum number of Octets Per Codec Frame supported by LC3 codec, 
as source.
+This setting is mandatory. Default value: 120
+value: 120
+restrictions:
+- $notnull
+BLE_SVC_AUDIO_PACS_LC3_SRC_MAX_CODEC_FRAMES_PER_SDU:
+description: >
+Maximum number of Codec Frames Per SDU supported by LC3 codec, as 
source.
+This setting is optional.
+value:
+BLE_SVC_AUDIO_PACS_LC3_SRC_METADATA:
+description: >
+Optional Metadata to be attached to source codec capabilities. 
This value shall be in
+form of bytes forming LTVs of Metadata. Example: '0x03, 0x01, 
0x00, 0x08'
+(lenght = 3, type = 0x01 (Preferred_Audio_Contexts), 0x00, 0x04 
(Media))
+value:
+BLE_SVC_AUDIO_PACS_LC3_SRC_AUDIO_LOCATIONS:
+description: >
+Audio Locations supported by source codec. Value is an any 
combination of values defined
+in Bluetooth Assigned Numbers 6.12.1. Default: Front Left and 
Front Right
+value: 0x0003
+BLE_SVC_AUDIO_PACS_LC3_SRC_SUP_CONTEXTS:
+description: >
+Audio Locations supported by source codec. Value is an any 
combination of values defined
+in Bluetooth Assigned Numbers 6.12.3. Default: Media
+value: 0x0004
+
+BLE_SVC_AUDIO_PACS_LC3_SNK_SAMPLING_FREQUENCIES:
+description: >
+Sampling frequencies supported by LC3 codec, as sink. This setting 
is mandatory.
+Accepts any combination of values defined in Bluetooth Assigned 
Numbers 6.12.4.1.
+Default value: 48000Hz
+value: 0x80
+restrictions:
+- $notnull
+BLE_SVC_AUDIO_PACS_LC3_SNK_FRAME_DURATIONS:
+description: >
+Frame Durations supported by LC3 codec, as sink. This setting is 
mandatory.
+Accepts any combination of values defined in Bluetooth Assigned 
Numbers 6.12.4.2.
+Default value: 7.5ms and 10ms supported, 10ms preferred.
+value: 0x23
+restrictions:
+- $notnull
+BLE_SVC_AUDIO_PACS_LC3_SNK_AUDIO_CHANNEL_COUNTS:
+description: >
+Audio Channel Counts supported by LC3 codec, as sink. This setting 
is optional.
+Accepts any combination of values defined in Bluetooth Assigned 
Numbers 6.12.4.3.
+value:
+BLE_SVC_AUDIO_PACS_LC3_SNK_MIN_OCTETS_PER_CODEC_FRAME:
+description: >
+Minimum number of Octet

Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-12 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1485921639


##
nimble/host/services/audio/pacs/src/ble_audio_svc_pacs.c:
##
@@ -0,0 +1,434 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "host/ble_hs.h"
+#include "host/ble_gatt.h"
+#include "host/ble_audio_codec.h"
+#include "services/pacs/ble_audio_svc_pacs.h"
+
+static uint32_t ble_svc_audio_pacs_sink_audio_locations;
+static uint32_t ble_svc_audio_pacs_source_audio_locations;
+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;
+}  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,
+.ble_svc_audio_pacs_avail_sink_contexts = 0,
+.ble_svc_audio_pacs_avail_source_contexts = 0
+}
+};
+static uint16_t ble_svc_audio_pacs_sup_sink_contexts;
+static uint16_t ble_svc_audio_pacs_sup_source_contexts;
+
+static struct ble_gap_event_listener ble_pacs_listener;
+
+struct pac_read_cb_arg {
+struct os_mbuf *om;
+uint8_t pac_count;
+};
+
+static int
+ble_svc_audio_pacs_access(uint16_t conn_handle, uint16_t attr_handle,
+  struct ble_gatt_access_ctxt *ctxt, void *arg);
+
+static const struct ble_gatt_svc_def ble_svc_audio_pacs_defs[] = {
+{ /*** Service: Published Audio Capabilities Service (PACS) */
+.type = BLE_GATT_SVC_TYPE_PRIMARY,
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_UUID16),
+.characteristics = (struct ble_gatt_chr_def[]) { {
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_AUDIO_LOCATIONS),

Review Comment:
   On second thought we probably should (and can) support optional 
notifications or all characteristics



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-12 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1485913709


##
nimble/host/services/audio/pacs/src/ble_audio_svc_pacs.c:
##
@@ -0,0 +1,434 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "host/ble_hs.h"
+#include "host/ble_gatt.h"
+#include "host/ble_audio_codec.h"
+#include "services/pacs/ble_audio_svc_pacs.h"
+
+static uint32_t ble_svc_audio_pacs_sink_audio_locations;
+static uint32_t ble_svc_audio_pacs_source_audio_locations;
+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;
+}  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,
+.ble_svc_audio_pacs_avail_sink_contexts = 0,
+.ble_svc_audio_pacs_avail_source_contexts = 0
+}
+};
+static uint16_t ble_svc_audio_pacs_sup_sink_contexts;
+static uint16_t ble_svc_audio_pacs_sup_source_contexts;
+
+static struct ble_gap_event_listener ble_pacs_listener;
+
+struct pac_read_cb_arg {
+struct os_mbuf *om;
+uint8_t pac_count;
+};
+
+static int
+ble_svc_audio_pacs_access(uint16_t conn_handle, uint16_t attr_handle,
+  struct ble_gatt_access_ctxt *ctxt, void *arg);
+
+static const struct ble_gatt_svc_def ble_svc_audio_pacs_defs[] = {
+{ /*** Service: Published Audio Capabilities Service (PACS) */
+.type = BLE_GATT_SVC_TYPE_PRIMARY,
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_UUID16),
+.characteristics = (struct ble_gatt_chr_def[]) { {
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_AUDIO_LOCATIONS),

Review Comment:
   1. I'll add configs that enable/disable these characteristics
   2. Initially I added notifications only for Available  Audio Contexts, as 
it's mandatory, but I think nothing stops us from adding notifications for the 
rest. One exception is PAC - as it depends on Codec module it should probably 
stay as is, as adding codecs would need to be calling service API, from host.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-11 Thread via GitHub


rymanluk commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1485635281


##
nimble/host/services/audio/pacs/src/ble_audio_svc_pacs.c:
##
@@ -0,0 +1,434 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "host/ble_hs.h"
+#include "host/ble_gatt.h"
+#include "host/ble_audio_codec.h"
+#include "services/pacs/ble_audio_svc_pacs.h"
+
+static uint32_t ble_svc_audio_pacs_sink_audio_locations;
+static uint32_t ble_svc_audio_pacs_source_audio_locations;
+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;
+}  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,
+.ble_svc_audio_pacs_avail_sink_contexts = 0,
+.ble_svc_audio_pacs_avail_source_contexts = 0
+}
+};
+static uint16_t ble_svc_audio_pacs_sup_sink_contexts;
+static uint16_t ble_svc_audio_pacs_sup_source_contexts;
+
+static struct ble_gap_event_listener ble_pacs_listener;
+
+struct pac_read_cb_arg {
+struct os_mbuf *om;
+uint8_t pac_count;
+};
+
+static int
+ble_svc_audio_pacs_access(uint16_t conn_handle, uint16_t attr_handle,
+  struct ble_gatt_access_ctxt *ctxt, void *arg);
+
+static const struct ble_gatt_svc_def ble_svc_audio_pacs_defs[] = {
+{ /*** Service: Published Audio Capabilities Service (PACS) */
+.type = BLE_GATT_SVC_TYPE_PRIMARY,
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_UUID16),
+.characteristics = (struct ble_gatt_chr_def[]) { {
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_AVAILABLE_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC | 
BLE_GATT_CHR_F_NOTIFY,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SUPPORTED_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+}, {
+0, /* No more characteristics in this service */
+}
+}
+},
+{
+0, /* No more services. */
+},
+};
+
+static int
+codec_record_to_pacs_entry(const struct ble_audio_codec_record *record, void 
*arg)
+{
+struct pac_read_cb_arg *cb_arg = (struct pac_read_cb_arg *)arg;
+uint8_t *buf;
+int rc;
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_id.format, sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+buf = os_mbuf_extend(cb_arg->om, 4);
+if (buf == NULL) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+put_le16(buf + 0, record->codec_id.company_id);
+put_le16(buf + 2, record->codec_id.vendor_specific);
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_spec_caps_len, 
sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+rc = os_mbuf_append(cb_arg->om, record->codec_spec_caps, 
record->codec_spec_caps_len);
+if (rc) {
+return BLE_ATT_ERR_INSUFFIC

Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-11 Thread via GitHub


rymanluk commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1485635281


##
nimble/host/services/audio/pacs/src/ble_audio_svc_pacs.c:
##
@@ -0,0 +1,434 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "host/ble_hs.h"
+#include "host/ble_gatt.h"
+#include "host/ble_audio_codec.h"
+#include "services/pacs/ble_audio_svc_pacs.h"
+
+static uint32_t ble_svc_audio_pacs_sink_audio_locations;
+static uint32_t ble_svc_audio_pacs_source_audio_locations;
+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;
+}  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,
+.ble_svc_audio_pacs_avail_sink_contexts = 0,
+.ble_svc_audio_pacs_avail_source_contexts = 0
+}
+};
+static uint16_t ble_svc_audio_pacs_sup_sink_contexts;
+static uint16_t ble_svc_audio_pacs_sup_source_contexts;
+
+static struct ble_gap_event_listener ble_pacs_listener;
+
+struct pac_read_cb_arg {
+struct os_mbuf *om;
+uint8_t pac_count;
+};
+
+static int
+ble_svc_audio_pacs_access(uint16_t conn_handle, uint16_t attr_handle,
+  struct ble_gatt_access_ctxt *ctxt, void *arg);
+
+static const struct ble_gatt_svc_def ble_svc_audio_pacs_defs[] = {
+{ /*** Service: Published Audio Capabilities Service (PACS) */
+.type = BLE_GATT_SVC_TYPE_PRIMARY,
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_UUID16),
+.characteristics = (struct ble_gatt_chr_def[]) { {
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_AVAILABLE_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC | 
BLE_GATT_CHR_F_NOTIFY,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SUPPORTED_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+}, {
+0, /* No more characteristics in this service */
+}
+}
+},
+{
+0, /* No more services. */
+},
+};
+
+static int
+codec_record_to_pacs_entry(const struct ble_audio_codec_record *record, void 
*arg)
+{
+struct pac_read_cb_arg *cb_arg = (struct pac_read_cb_arg *)arg;
+uint8_t *buf;
+int rc;
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_id.format, sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+buf = os_mbuf_extend(cb_arg->om, 4);
+if (buf == NULL) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+put_le16(buf + 0, record->codec_id.company_id);
+put_le16(buf + 2, record->codec_id.vendor_specific);
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_spec_caps_len, 
sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+rc = os_mbuf_append(cb_arg->om, record->codec_spec_caps, 
record->codec_spec_caps_len);
+if (rc) {
+return BLE_ATT_ERR_INSUFFIC

Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-11 Thread via GitHub


rymanluk commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1485634807


##
nimble/host/services/audio/pacs/src/ble_audio_svc_pacs.c:
##
@@ -0,0 +1,434 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "host/ble_hs.h"
+#include "host/ble_gatt.h"
+#include "host/ble_audio_codec.h"
+#include "services/pacs/ble_audio_svc_pacs.h"
+
+static uint32_t ble_svc_audio_pacs_sink_audio_locations;
+static uint32_t ble_svc_audio_pacs_source_audio_locations;
+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;
+}  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,
+.ble_svc_audio_pacs_avail_sink_contexts = 0,
+.ble_svc_audio_pacs_avail_source_contexts = 0
+}
+};
+static uint16_t ble_svc_audio_pacs_sup_sink_contexts;
+static uint16_t ble_svc_audio_pacs_sup_source_contexts;
+
+static struct ble_gap_event_listener ble_pacs_listener;
+
+struct pac_read_cb_arg {
+struct os_mbuf *om;
+uint8_t pac_count;
+};
+
+static int
+ble_svc_audio_pacs_access(uint16_t conn_handle, uint16_t attr_handle,
+  struct ble_gatt_access_ctxt *ctxt, void *arg);
+
+static const struct ble_gatt_svc_def ble_svc_audio_pacs_defs[] = {
+{ /*** Service: Published Audio Capabilities Service (PACS) */
+.type = BLE_GATT_SVC_TYPE_PRIMARY,
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_UUID16),
+.characteristics = (struct ble_gatt_chr_def[]) { {
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_AVAILABLE_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC | 
BLE_GATT_CHR_F_NOTIFY,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SUPPORTED_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+}, {
+0, /* No more characteristics in this service */
+}
+}
+},
+{
+0, /* No more services. */
+},
+};
+
+static int
+codec_record_to_pacs_entry(const struct ble_audio_codec_record *record, void 
*arg)
+{
+struct pac_read_cb_arg *cb_arg = (struct pac_read_cb_arg *)arg;
+uint8_t *buf;
+int rc;
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_id.format, sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+buf = os_mbuf_extend(cb_arg->om, 4);
+if (buf == NULL) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+put_le16(buf + 0, record->codec_id.company_id);
+put_le16(buf + 2, record->codec_id.vendor_specific);
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_spec_caps_len, 
sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+rc = os_mbuf_append(cb_arg->om, record->codec_spec_caps, 
record->codec_spec_caps_len);
+if (rc) {
+return BLE_ATT_ERR_INSUFFIC

Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-11 Thread via GitHub


rymanluk commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1485634720


##
nimble/host/services/audio/pacs/src/ble_audio_svc_pacs.c:
##
@@ -0,0 +1,434 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "host/ble_hs.h"
+#include "host/ble_gatt.h"
+#include "host/ble_audio_codec.h"
+#include "services/pacs/ble_audio_svc_pacs.h"
+
+static uint32_t ble_svc_audio_pacs_sink_audio_locations;
+static uint32_t ble_svc_audio_pacs_source_audio_locations;
+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;
+}  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,
+.ble_svc_audio_pacs_avail_sink_contexts = 0,
+.ble_svc_audio_pacs_avail_source_contexts = 0
+}
+};
+static uint16_t ble_svc_audio_pacs_sup_sink_contexts;
+static uint16_t ble_svc_audio_pacs_sup_source_contexts;
+
+static struct ble_gap_event_listener ble_pacs_listener;
+
+struct pac_read_cb_arg {
+struct os_mbuf *om;
+uint8_t pac_count;
+};
+
+static int
+ble_svc_audio_pacs_access(uint16_t conn_handle, uint16_t attr_handle,
+  struct ble_gatt_access_ctxt *ctxt, void *arg);
+
+static const struct ble_gatt_svc_def ble_svc_audio_pacs_defs[] = {
+{ /*** Service: Published Audio Capabilities Service (PACS) */
+.type = BLE_GATT_SVC_TYPE_PRIMARY,
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_UUID16),
+.characteristics = (struct ble_gatt_chr_def[]) { {
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_AVAILABLE_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC | 
BLE_GATT_CHR_F_NOTIFY,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SUPPORTED_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+}, {
+0, /* No more characteristics in this service */
+}
+}
+},
+{
+0, /* No more services. */
+},
+};
+
+static int
+codec_record_to_pacs_entry(const struct ble_audio_codec_record *record, void 
*arg)
+{
+struct pac_read_cb_arg *cb_arg = (struct pac_read_cb_arg *)arg;
+uint8_t *buf;
+int rc;
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_id.format, sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+buf = os_mbuf_extend(cb_arg->om, 4);
+if (buf == NULL) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+put_le16(buf + 0, record->codec_id.company_id);
+put_le16(buf + 2, record->codec_id.vendor_specific);
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_spec_caps_len, 
sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+rc = os_mbuf_append(cb_arg->om, record->codec_spec_caps, 
record->codec_spec_caps_len);
+if (rc) {
+return BLE_ATT_ERR_INSUFFIC

Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-11 Thread via GitHub


rymanluk commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1485634422


##
nimble/host/services/audio/pacs/lc3/syscfg.yml:
##
@@ -0,0 +1,136 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+syscfg.defs:
+BLE_SVC_AUDIO_PACS_LC3_SRC_SAMPLING_FREQUENCIES:
+description: >
+Sampling frequencies supported by LC3 codec, as source. This 
setting is mandatory.
+Accepts any combination of values defined in Bluetooth Assigned 
Numbers 6.12.4.1.
+Default value: 48000Hz
+value: 0x80
+restrictions:
+- $notnull
+BLE_SVC_AUDIO_PACS_LC3_SRC_FRAME_DURATIONS:
+description: >
+Frame Durations supported by LC3 codec, as source. This setting is 
mandatory.
+Accepts any combination of values defined in Bluetooth Assigned 
Numbers 6.12.4.2.
+Default value: 7.5ms and 10ms supported, 10ms preferred.
+value: 0x23
+restrictions:
+- $notnull
+BLE_SVC_AUDIO_PACS_LC3_SRC_AUDIO_CHANNEL_COUNTS:
+description: >
+Audio Channel Counts supported by LC3 codec, as source. This 
setting is optional.
+Accepts any combination of values defined in Bluetooth Assigned 
Numbers 6.12.4.3.
+value:
+BLE_SVC_AUDIO_PACS_LC3_SRC_MIN_OCTETS_PER_CODEC_FRAME:
+description: >
+Minimum number of Octets Per Codec Frame supported by LC3 codec, 
as source.
+This setting is mandatory. Default value: 80
+value: 80
+restrictions:
+- $notnull
+BLE_SVC_AUDIO_PACS_LC3_SRC_MAX_OCTETS_PER_CODEC_FRAME:
+description: >
+Maximum number of Octets Per Codec Frame supported by LC3 codec, 
as source.
+This setting is mandatory. Default value: 120
+value: 120
+restrictions:
+- $notnull
+BLE_SVC_AUDIO_PACS_LC3_SRC_MAX_CODEC_FRAMES_PER_SDU:
+description: >
+Maximum number of Codec Frames Per SDU supported by LC3 codec, as 
source.
+This setting is optional.
+value:
+BLE_SVC_AUDIO_PACS_LC3_SRC_METADATA:
+description: >
+Optional Metadata to be attached to source codec capabilities. 
This value shall be in
+form of bytes forming LTVs of Metadata. Example: '0x03, 0x01, 
0x00, 0x08'
+(lenght = 3, type = 0x01 (Preferred_Audio_Contexts), 0x00, 0x04 
(Media))
+value:
+BLE_SVC_AUDIO_PACS_LC3_SRC_AUDIO_LOCATIONS:
+description: >
+Audio Locations supported by source codec. Value is an any 
combination of values defined
+in Bluetooth Assigned Numbers 6.12.1. Default: Front Left and 
Front Right
+value: 0x0003
+BLE_SVC_AUDIO_PACS_LC3_SRC_SUP_CONTEXTS:
+description: >
+Audio Locations supported by source codec. Value is an any 
combination of values defined
+in Bluetooth Assigned Numbers 6.12.3. Default: Media
+value: 0x0004
+
+BLE_SVC_AUDIO_PACS_LC3_SNK_SAMPLING_FREQUENCIES:
+description: >
+Sampling frequencies supported by LC3 codec, as sink. This setting 
is mandatory.
+Accepts any combination of values defined in Bluetooth Assigned 
Numbers 6.12.4.1.
+Default value: 48000Hz
+value: 0x80
+restrictions:
+- $notnull
+BLE_SVC_AUDIO_PACS_LC3_SNK_FRAME_DURATIONS:
+description: >
+Frame Durations supported by LC3 codec, as sink. This setting is 
mandatory.
+Accepts any combination of values defined in Bluetooth Assigned 
Numbers 6.12.4.2.
+Default value: 7.5ms and 10ms supported, 10ms preferred.
+value: 0x23
+restrictions:
+- $notnull
+BLE_SVC_AUDIO_PACS_LC3_SNK_AUDIO_CHANNEL_COUNTS:
+description: >
+Audio Channel Counts supported by LC3 codec, as sink. This setting 
is optional.
+Accepts any combination of values defined in Bluetooth Assigned 
Numbers 6.12.4.3.
+value:
+BLE_SVC_AUDIO_PACS_LC3_SNK_MIN_OCTETS_PER_CODEC_FRAME:
+description: >
+Minimum number of Octets Pe

Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-11 Thread via GitHub


rymanluk commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1485633734


##
nimble/host/services/audio/pacs/src/ble_audio_svc_pacs.c:
##
@@ -0,0 +1,434 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "host/ble_hs.h"
+#include "host/ble_gatt.h"
+#include "host/ble_audio_codec.h"
+#include "services/pacs/ble_audio_svc_pacs.h"
+
+static uint32_t ble_svc_audio_pacs_sink_audio_locations;
+static uint32_t ble_svc_audio_pacs_source_audio_locations;
+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;
+}  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,
+.ble_svc_audio_pacs_avail_sink_contexts = 0,
+.ble_svc_audio_pacs_avail_source_contexts = 0
+}
+};
+static uint16_t ble_svc_audio_pacs_sup_sink_contexts;
+static uint16_t ble_svc_audio_pacs_sup_source_contexts;
+
+static struct ble_gap_event_listener ble_pacs_listener;
+
+struct pac_read_cb_arg {
+struct os_mbuf *om;
+uint8_t pac_count;
+};
+
+static int
+ble_svc_audio_pacs_access(uint16_t conn_handle, uint16_t attr_handle,
+  struct ble_gatt_access_ctxt *ctxt, void *arg);
+
+static const struct ble_gatt_svc_def ble_svc_audio_pacs_defs[] = {
+{ /*** Service: Published Audio Capabilities Service (PACS) */
+.type = BLE_GATT_SVC_TYPE_PRIMARY,
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_UUID16),
+.characteristics = (struct ble_gatt_chr_def[]) { {
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_AUDIO_LOCATIONS),

Review Comment:
   two comments here
   1. As mentioned in other comment, we could have mynewt val which would 
enable given direction
   2. We could have Mynewt_VAL to decide if this characteristic should have 
Notify property



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-11 Thread via GitHub


rymanluk commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1485632951


##
nimble/host/services/audio/pacs/src/ble_audio_svc_pacs.c:
##
@@ -0,0 +1,434 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "host/ble_hs.h"
+#include "host/ble_gatt.h"
+#include "host/ble_audio_codec.h"
+#include "services/pacs/ble_audio_svc_pacs.h"
+
+static uint32_t ble_svc_audio_pacs_sink_audio_locations;
+static uint32_t ble_svc_audio_pacs_source_audio_locations;
+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;
+}  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,
+.ble_svc_audio_pacs_avail_sink_contexts = 0,
+.ble_svc_audio_pacs_avail_source_contexts = 0
+}
+};
+static uint16_t ble_svc_audio_pacs_sup_sink_contexts;
+static uint16_t ble_svc_audio_pacs_sup_source_contexts;
+
+static struct ble_gap_event_listener ble_pacs_listener;
+
+struct pac_read_cb_arg {
+struct os_mbuf *om;
+uint8_t pac_count;
+};
+
+static int
+ble_svc_audio_pacs_access(uint16_t conn_handle, uint16_t attr_handle,
+  struct ble_gatt_access_ctxt *ctxt, void *arg);
+
+static const struct ble_gatt_svc_def ble_svc_audio_pacs_defs[] = {
+{ /*** Service: Published Audio Capabilities Service (PACS) */
+.type = BLE_GATT_SVC_TYPE_PRIMARY,
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_UUID16),
+.characteristics = (struct ble_gatt_chr_def[]) { {
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_AVAILABLE_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC | 
BLE_GATT_CHR_F_NOTIFY,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SUPPORTED_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+}, {
+0, /* No more characteristics in this service */
+}
+}
+},
+{
+0, /* No more services. */
+},
+};
+
+static int
+codec_record_to_pacs_entry(const struct ble_audio_codec_record *record, void 
*arg)
+{
+struct pac_read_cb_arg *cb_arg = (struct pac_read_cb_arg *)arg;
+uint8_t *buf;
+int rc;
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_id.format, sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+buf = os_mbuf_extend(cb_arg->om, 4);
+if (buf == NULL) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+put_le16(buf + 0, record->codec_id.company_id);
+put_le16(buf + 2, record->codec_id.vendor_specific);
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_spec_caps_len, 
sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+rc = os_mbuf_append(cb_arg->om, record->codec_spec_caps, 
record->codec_spec_caps_len);
+if (rc) {
+return BLE_ATT_ERR_INSUFFIC

Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-11 Thread via GitHub


rymanluk commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1485632327


##
nimble/host/services/audio/pacs/syscfg.yml:
##
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+syscfg.defs:
+  BLE_SVC_AUDIO_PACS_SYSINIT_STAGE:
+description: >
+  Sysinit stage for Published Audio Capabilities Service.
+value: 303

Review Comment:
   I think we should have MYNEWT_VAL to enable SINK and SOURCE records with a 
restriction that at least one have ot be choose



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-11 Thread via GitHub


rymanluk commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1485631839


##
nimble/host/services/audio/pacs/pkg.yml:
##
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+pkg.name: nimble/host/services/audio/pacs
+pkg.description: Published Audio Capabilities Service

Review Comment:
   could you add here more description, especially on how to add here other 
codec ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-05 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1477986303


##
nimble/host/services/audio/pacs/pkg.yml:
##
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+pkg.name: nimble/host/services/audio/pacs
+pkg.description: Published Audio Capabilities Service
+pkg.author: "Apache Mynewt "
+pkg.homepage: "http://mynewt.apache.org/";

Review Comment:
   https



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-05 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1477985587


##
nimble/host/services/audio/pacs/pkg.yml:
##
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0

Review Comment:
   https



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-02-05 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1477978471


##
nimble/host/services/audio/pacs/include/services/pacs/ble_audio_svc_pacs.h:
##
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_AUDIO_SVC_PACS_
+#define H_BLE_AUDIO_SVC_PACS_
+
+#define BLE_SVC_AUDIO_PACS_UUID16   0x1850
+#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_PAC  0x2BC9
+#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_AUDIO_LOCATIONS  0x2BCA
+#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_PAC0x2BCB
+#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_AUDIO_LOCATIONS0x2BCC
+#define BLE_SVC_AUDIO_PACS_CHR_UUID16_AVAILABLE_AUDIO_CONTEXTS  0x2BCD
+#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SUPPORTED_AUDIO_CONTEXTS  0x2BCE
+
+
+struct ble_svc_audio_pacs_set_param {
+/* Supported Audio Locations */
+uint32_t audio_locations;
+
+/* Supported Contexts */
+uint16_t supported_contexts;
+};
+
+/**
+ * @brief Set PACS params.
+ *
+ * Set device capabilities reported in Published Audio Capabilities Service. 
This function
+ * shall be called only once per Sink/Source, as capabilities shall not be 
changed after being
+ * initialised.
+ *
+ * @param[in] flags Flags that define if capabilities 
being set are for
+ *  Sink or Source. Valid values are either
+ *  `BLE_AUDIO_CODEC_FLAG_SOURCE` or 
`BLE_AUDIO_CODEC_FLAG_SINK`
+ * @param[in] param Pointer to a 
`ble_svc_audio_pacs_set_param`
+ *  structure that defines capabilities 
supported by
+ *  device.
+ *
+ * @return  0 on success;
+ *  A non-zero value on failure.
+ */
+int ble_svc_audio_pacs_set(uint8_t flags, struct ble_svc_audio_pacs_set_param 
*param);
+
+/**
+ * @brief Set available context types.
+ *
+ * @param[in] conn_handle   Connection handle identifying 
connection for which contexts
+ *  being set
+ * @param[in] sink_contexts Available Sink Contexts
+ * @param[in] source_contexts   Available Source Contexts
+ *
+ * @return  0 on success;
+ *  A non-zero value on failure.
+ */
+int ble_svc_audio_pacs_set_avail_contexts(uint16_t conn_handle,

Review Comment:
   set at the end
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-01-31 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1472790860


##
nimble/host/services/audio/pacs/include/services/pacs/ble_audio_svc_pacs.h:
##
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_AUDIO_SVC_PACS_
+#define H_BLE_AUDIO_SVC_PACS_
+
+#define BLE_SVC_AUDIO_PACS_UUID16   0x1850
+#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_PAC  0x2BC9
+#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_AUDIO_LOCATIONS  0x2BCA
+#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_PAC0x2BCB
+#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_AUDIO_LOCATIONS0x2BCC
+#define BLE_SVC_AUDIO_PACS_CHR_UUID16_AVAILABLE_AUDIO_CONTEXTS  0x2BCD
+#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SUPPORTED_AUDIO_CONTEXTS  0x2BCE
+
+int ble_svc_audio_pacs_set_sink_audio_loc(uint32_t audio_locations);
+int ble_svc_audio_pacs_set_source_audio_loc(uint32_t audio_locations);
+int ble_svc_audio_pacs_set_sup_contexts(uint16_t sink_contexts,
+uint16_t source_contexts);
+int ble_svc_audio_pacs_set_avail_contexts(uint16_t conn_handle,
+  uint16_t sink_contexts,
+  uint16_t source_contexts);

Review Comment:
   We discussed this offline and I made it into single functions, as you 
suggested. There is also second function that sets `available_contexts` - this 
must be done after connection exists and we know `conn_handle`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-01-31 Thread via GitHub


KKopyscinski commented on PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#issuecomment-1919041186

   @rymanluk Added LC3 PACS package, resolved some bugs and tested code. I'll 
add doxygen soon


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-01-29 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1469398076


##
nimble/host/services/audio/pacs/include/services/pacs/ble_audio_svc_pacs.h:
##
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_AUDIO_SVC_PACS_
+#define H_BLE_AUDIO_SVC_PACS_
+
+#define BLE_SVC_AUDIO_PACS_UUID16   0x1850

Review Comment:
   doxygen



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-01-29 Thread via GitHub


KKopyscinski commented on PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#issuecomment-1914413065

   TODO: add LC3 PACS package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-01-25 Thread via GitHub


KKopyscinski commented on PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#issuecomment-1910142854

   Fixed `ble_svc_audio_pacs_avail_contexts` array, all array elements should 
have `BLE_HS_CONN_HANDLE_NONE` on init


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-01-25 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1466129161


##
nimble/host/services/audio/pacs/include/services/pacs/ble_audio_svc_pacs.h:
##
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_AUDIO_SVC_PACS_
+#define H_BLE_AUDIO_SVC_PACS_
+
+#define BLE_SVC_AUDIO_PACS_UUID16   0x1850
+#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_PAC  0x2BC9
+#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_AUDIO_LOCATIONS  0x2BCA
+#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_PAC0x2BCB
+#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_AUDIO_LOCATIONS0x2BCC
+#define BLE_SVC_AUDIO_PACS_CHR_UUID16_AVAILABLE_AUDIO_CONTEXTS  0x2BCD
+#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SUPPORTED_AUDIO_CONTEXTS  0x2BCE
+
+int ble_svc_audio_pacs_set_sink_audio_loc(uint32_t audio_locations);
+int ble_svc_audio_pacs_set_source_audio_loc(uint32_t audio_locations);
+int ble_svc_audio_pacs_set_sup_contexts(uint16_t sink_contexts,
+uint16_t source_contexts);
+int ble_svc_audio_pacs_set_avail_contexts(uint16_t conn_handle,
+  uint16_t sink_contexts,
+  uint16_t source_contexts);

Review Comment:
   One problem I see is that `available_contexts` are per connection - so they 
cannot be set on service init, but after connection is established. So we have 
one exception. And because in previous comment you asked to disallow re-setting 
these values, because there is no notifications support for them (which I 100% 
agree with), we would have to split these into these that init on startup and 
`available_contexts`. On the other hand we here, as you notice, SRC/SNK pairs, 
and there will be more in other services. So I'm not sure if we can solve this 
cleanly with flags(types?) as we do in codecs.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-01-25 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1466056703


##
nimble/host/services/audio/pacs/src/ble_audio_svc_pacs.c:
##
@@ -0,0 +1,428 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "host/ble_hs.h"
+#include "host/ble_gatt.h"
+#include "host/ble_audio_codec.h"
+#include "services/pacs/ble_audio_svc_pacs.h"
+
+static uint32_t ble_svc_audio_pacs_sink_audio_locations;
+static uint32_t ble_svc_audio_pacs_source_audio_locations;
+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;
+}  ble_svc_audio_pacs_avail_contexts[MYNEWT_VAL(BLE_MAX_CONNECTIONS)] = {
+{
+.conn_handle = BLE_HS_CONN_HANDLE_NONE,
+}
+};
+static uint16_t ble_svc_audio_pacs_sup_sink_contexts;
+static uint16_t ble_svc_audio_pacs_sup_source_contexts;
+
+static struct ble_gap_event_listener ble_pacs_listener;
+
+struct pac_read_cb_arg {
+uint8_t flags;
+struct os_mbuf *om;
+uint8_t pac_count;
+};
+static int
+ble_svc_audio_pacs_access(uint16_t conn_handle, uint16_t attr_handle,
+  struct ble_gatt_access_ctxt *ctxt, void *arg);
+
+static const struct ble_gatt_svc_def ble_svc_audio_pacs_defs[] = {
+{ /*** Service: Published Audio Capabilities Service (PACS) */
+.type = BLE_GATT_SVC_TYPE_PRIMARY,
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_UUID16),
+.characteristics = (struct ble_gatt_chr_def[]) { {
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ_ENC
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ_ENC,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_AVAILABLE_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ_ENC | BLE_GATT_CHR_F_NOTIFY,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SUPPORTED_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ_ENC,
+}, {
+0, /* No more characteristics in this service */
+}
+}
+},
+{
+0, /* No more services. */
+},
+};
+
+static int
+codec_record_to_pacs_entry(struct ble_audio_codec_record *record, void *arg)
+{
+struct pac_read_cb_arg *cb_arg = (struct pac_read_cb_arg *)arg;
+int rc;
+
+if (!(record->flags & cb_arg->flags)) {
+return 0;
+}
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_id,
+sizeof(struct ble_audio_codec_id));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_spec_caps_len,
+   sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_spec_caps, 
record->codec_spec_caps_len);
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+rc = os_mbuf_append(cb_arg->om, &record->metadata_len,
+   sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+rc = os_mbuf_append(cb_arg->om, &record->metadata, record->metadata_len);
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+cb_arg->pac_count++;
+
+return 0;
+}
+
+static int

Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-01-25 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1466051083


##
nimble/host/services/audio/pacs/src/ble_audio_svc_pacs.c:
##
@@ -0,0 +1,428 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "host/ble_hs.h"
+#include "host/ble_gatt.h"
+#include "host/ble_audio_codec.h"
+#include "services/pacs/ble_audio_svc_pacs.h"
+
+static uint32_t ble_svc_audio_pacs_sink_audio_locations;
+static uint32_t ble_svc_audio_pacs_source_audio_locations;
+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;
+}  ble_svc_audio_pacs_avail_contexts[MYNEWT_VAL(BLE_MAX_CONNECTIONS)] = {
+{
+.conn_handle = BLE_HS_CONN_HANDLE_NONE,
+}
+};
+static uint16_t ble_svc_audio_pacs_sup_sink_contexts;
+static uint16_t ble_svc_audio_pacs_sup_source_contexts;
+
+static struct ble_gap_event_listener ble_pacs_listener;
+
+struct pac_read_cb_arg {
+uint8_t flags;
+struct os_mbuf *om;
+uint8_t pac_count;
+};
+static int
+ble_svc_audio_pacs_access(uint16_t conn_handle, uint16_t attr_handle,
+  struct ble_gatt_access_ctxt *ctxt, void *arg);
+
+static const struct ble_gatt_svc_def ble_svc_audio_pacs_defs[] = {
+{ /*** Service: Published Audio Capabilities Service (PACS) */
+.type = BLE_GATT_SVC_TYPE_PRIMARY,
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_UUID16),
+.characteristics = (struct ble_gatt_chr_def[]) { {
+.uuid = BLE_UUID16_DECLARE(BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ_ENC,
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_PAC),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ_ENC
+} , {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_AUDIO_LOCATIONS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ_ENC,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_AVAILABLE_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ_ENC | BLE_GATT_CHR_F_NOTIFY,
+}, {
+.uuid = BLE_UUID16_DECLARE(
+BLE_SVC_AUDIO_PACS_CHR_UUID16_SUPPORTED_AUDIO_CONTEXTS),
+.access_cb = ble_svc_audio_pacs_access,
+.flags = BLE_GATT_CHR_F_READ_ENC,
+}, {
+0, /* No more characteristics in this service */
+}
+}
+},
+{
+0, /* No more services. */
+},
+};
+
+static int
+codec_record_to_pacs_entry(struct ble_audio_codec_record *record, void *arg)
+{
+struct pac_read_cb_arg *cb_arg = (struct pac_read_cb_arg *)arg;
+int rc;
+
+if (!(record->flags & cb_arg->flags)) {
+return 0;
+}
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_id,
+sizeof(struct ble_audio_codec_id));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_spec_caps_len,
+   sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+rc = os_mbuf_append(cb_arg->om, &record->codec_spec_caps, 
record->codec_spec_caps_len);
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+rc = os_mbuf_append(cb_arg->om, &record->metadata_len,
+   sizeof(uint8_t));
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+rc = os_mbuf_append(cb_arg->om, &record->metadata, record->metadata_len);
+if (rc) {
+return BLE_ATT_ERR_INSUFFICIENT_RES;
+}
+
+cb_arg->pac_count++;
+
+return 0;
+}
+
+static int

Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-01-24 Thread via GitHub


KKopyscinski commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1465961979


##
nimble/host/include/host/ble_audio_codec.h:
##
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_AUDIO_CODEC_
+#define H_BLE_AUDIO_CODEC_
+
+#include "stdint.h"
+#include "ble_audio_common.h"
+
+#define BLE_AUDIO_CODEC_FLAG_SOURCE 0x01
+#define BLE_AUDIO_CODEC_FLAG_SINK   0x02
+
+/** Type definition for Codec Specific Capabilities parser function. */
+typedef int ble_audio_codec_parser(uint8_t codec_spec_caps_len,
+   uint8_t *codec_spec_caps,
+   void *cb_arg);
+
+
+/** Codec list entry */
+struct ble_audio_codec_record {
+/* Pointer to next codec list entry */
+STAILQ_ENTRY(ble_audio_codec_record) next;
+
+/* Codec ID */
+struct ble_audio_codec_id codec_id;
+
+/* Length of Codec Specific Capabilities */
+uint8_t codec_spec_caps_len;
+
+/* Codec Specific Capabilities data */
+uint8_t *codec_spec_caps;
+
+/* Metadata length */
+uint8_t metadata_len;
+
+/* Metadata */
+uint8_t *metadata;
+
+/* Codec entry flags. It is any combination of following flags:
+ *  - BLE_AUDIO_CODEC_FLAG_SOURCE
+ *  - BLE_AUDIO_CODEC_FLAG_SINK
+ */
+uint8_t flags;
+
+/* Function used to parse Codec Specific Capabilities */
+ble_audio_codec_parser *parser;

Review Comment:
   Initially I was thinking app, but it can manage this on its own. I think 
you're right, this is not needed here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-01-24 Thread via GitHub


MariuszSkamra commented on code in PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#discussion_r1465909058


##
nimble/host/include/host/ble_audio_codec.h:
##
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_AUDIO_CODEC_
+#define H_BLE_AUDIO_CODEC_
+
+#include "stdint.h"
+#include "ble_audio_common.h"
+
+#define BLE_AUDIO_CODEC_FLAG_SOURCE 0x01
+#define BLE_AUDIO_CODEC_FLAG_SINK   0x02
+
+/** Type definition for Codec Specific Capabilities parser function. */
+typedef int ble_audio_codec_parser(uint8_t codec_spec_caps_len,
+   uint8_t *codec_spec_caps,
+   void *cb_arg);
+
+
+/** Codec list entry */
+struct ble_audio_codec_record {
+/* Pointer to next codec list entry */
+STAILQ_ENTRY(ble_audio_codec_record) next;
+
+/* Codec ID */
+struct ble_audio_codec_id codec_id;
+
+/* Length of Codec Specific Capabilities */
+uint8_t codec_spec_caps_len;
+
+/* Codec Specific Capabilities data */
+uint8_t *codec_spec_caps;
+
+/* Metadata length */
+uint8_t metadata_len;
+
+/* Metadata */
+uint8_t *metadata;
+
+/* Codec entry flags. It is any combination of following flags:
+ *  - BLE_AUDIO_CODEC_FLAG_SOURCE
+ *  - BLE_AUDIO_CODEC_FLAG_SINK
+ */
+uint8_t flags;
+
+/* Function used to parse Codec Specific Capabilities */
+ble_audio_codec_parser *parser;
+
+/* Optional argument for `ble_audio_codec_parser` */
+void *parser_arg;
+};
+
+/** Type definition codec iteration callback function. */
+typedef int ble_audio_codec_foreach_fn(struct ble_audio_codec_record *
+   record, void *arg);
+/**
+ * @brief Register codec entry
+ *
+ * @param[in] codec_id  Codec ID structure.
+ * @param[in] codec_spec_caps_len   Codec Specific Capabilities length.
+ * @param[in] codec_spec_caps   Codec Specific Capabilities data.
+ * @param[in] metadata_len  Metadata length.
+ * @param[in] metadata  Metadata.
+ * @param[in] flags Codec entry flags. It is any
+ *  combination of following flags:
+ *  - BLE_AUDIO_CODEC_FLAG_SOURCE
+ *  - BLE_AUDIO_CODEC_FLAG_SINK
+ * @param[in] cbFunction used to parse Codec
+ *  Specific Capabilities
+ * @param[in] cb_argOptional callback argument.
+ * @param[out] out_record   Pointer to registered codec entry.
+ *
+ * @return  0 on success;
+ *  A non-zero value on failure.
+ */
+int ble_audio_codec_register(struct ble_audio_codec_id codec_id,
+ uint8_t codec_spec_caps_len,
+ uint8_t *codec_spec_caps,
+ uint8_t metadata_len,
+ uint8_t *metadata,
+ uint8_t flags,
+ ble_audio_codec_parser *cb,
+ void *cb_arg,
+ struct ble_audio_codec_record *out_record);
+/**
+ * @brief Remove codec entry from register
+ *
+ * @param[in] codec_record  Pointer to registered codec entry.
+ *
+ * @return  0 on success;
+ *  A non-zero value on failure.
+ */
+int ble_audio_codec_unregister(struct ble_audio_codec_record *codec_record);
+
+/**
+ * @brief Iterate through all registered codecs and call function on every
+ *one of them.
+ *
+ * @param[in] cbCallback to be called on codec entries.
+ * @param[in] arg   Optional callback argument.
+ *
+ * @return  0 on success;
+ *  A non-zero value on failure.
+ */
+int ble_audio_codec_foreach(ble_audio_codec_foreach_fn *cb, void *arg);

Review Comment:
   Having `flags` param

Re: [PR] nimble/services: add PACS [mynewt-nimble]

2024-01-22 Thread via GitHub


KKopyscinski commented on PR #1675:
URL: https://github.com/apache/mynewt-nimble/pull/1675#issuecomment-1903930547

   @MariuszSkamra 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org