client/btpclient: Add BAP/ASCS/PACS support for auto-pts BAP tests
Subsystems (2)
cover client/btpclient: Add BAP/ASCS/PACS support for auto-pts BAP tests
This series extends btpclient with support for the BAP, ASCS, and PACS BTP services required to pass the auto-pts Basic Audio Profile test suites (BAP/UCL/*, BAP/USR/*).
- Patch 1 adds BTP_EV_BAP_ASE_FOUND, needed by BAP/UCL/SCC/BV-004-C and BAP/UCL/SCC/BV-019-C.
- Patch 2 fetches Codec capabilities when replying to an ASE.
- Patch 3 introduces ASCS BTP support: audio endpoints are registered via the VENDOR service's ASCS setup command, and the SelectProperties() D-Bus reply is postponed until auto-pts has requested the ASE and PACS characteristic values, allowing BAP/UCL/SCC/* tests to pass.
- Patch 4 adds BTP_OP_PACS_SET_LOCATION support to store the expected location for a local endpoint.
- Patch 5 adds BTP_OP_BAP_SEND support.
- Patch 6 extends ASCS support to cover the BAP/UCL/STR/* tests.
- Patch 7 fixes CIG/CIS id assignment to be deferred and based on the Unicast Client/Server role, matching what auto-pts expects (0/0 for Client tests, 1/1 for Server tests) instead of eagerly assigning CIG 0 to every discovered ASE.
- Patch 8 adds automatic stream acquisition and data sending for the BAP/USR/STR/* tests.
Together these patches allow btpclient to pass the BAP/UCL and BAP/USR auto-pts test suites.
Frédéric Danis (8):
client/btpclient: Add BTP_EV_BAP_ASE_FOUND support client/btpclient: Get Codec capabilities on ASE reply client/btpclient: Add ASCS BTP support
client/btpclient: Add BTP_OP_PACS_SET_LOCATION support client/btpclient: Add BTP_OP_BAP_SEND support client/btpclient: Add ASCS support for BAP/UCL/STR/* tests client/btpclient: Defer CIG/CIS assignment based on Client/Server role client/btpclient: Add stream auto acquire for BAP/USR/STR/* tests
Makefile.tools | 7 +- client/btpclient/ascs.c | 1641 ++++++++++++++++++++++++++++++++++ client/btpclient/ascs.h | 21 + client/btpclient/bap.c | 381 ++++++++ client/btpclient/bap.h | 4 + client/btpclient/btpclient.c | 194 +++- client/btpclient/btpclient.h | 36 + client/btpclient/core.c | 75 +- client/btpclient/gap.c | 3 - client/btpclient/pacs.c | 107 +++ client/btpclient/pacs.h | 13 + client/btpclient/vendor.c | 103 +++ client/btpclient/vendor.h | 13 + src/shared/btp.h | 156 ++++ 14 files changed, 2744 insertions(+), 10 deletions(-) create mode 100644 client/btpclient/ascs.c create mode 100644 client/btpclient/ascs.h create mode 100644 client/btpclient/pacs.c create mode 100644 client/btpclient/pacs.h create mode 100644 client/btpclient/vendor.c create mode 100644 client/btpclient/vendor.h
Signature · 1 line
2.43.0
PATCH 1/8 client/btpclient: Add BTP_EV_BAP_ASE_FOUND support
This is used at least for BAP/UCL/SCC/BV-004-C and BAP/UCL/SCC/BV-019-C tests.
--- client/btpclient/bap.c | 109 +++++++++++++++++++++++++++++++++++ client/btpclient/bap.h | 2 + client/btpclient/btpclient.c | 6 ++ client/btpclient/btpclient.h | 8 +++ src/shared/btp.h | 11 ++++ 5 files changed, 136 insertions(+)
client/btpclient/bap.c +109 -0
@@ -96,6 +96,115 @@ failed:btp_send_error (btp,BTP_BAP_SERVICE , index, status); } +static void bap_charac_read_setup (struct l_dbus_message *message, +void *user_data) +{ +struct l_dbus_message_builder *builder; + + builder =l_dbus_message_builder_new (message); +l_dbus_message_builder_enter_array (builder,"{sv}" ); +l_dbus_message_builder_enter_dict (builder,"sv" ); +l_dbus_message_builder_leave_dict (builder); +l_dbus_message_builder_leave_array (builder); +l_dbus_message_builder_finalize (builder); +l_dbus_message_builder_destroy (builder); +} + +static void bap_read_ase_reply (struct l_dbus_proxy *proxy, +struct l_dbus_message *result, +void *user_data) +{ +struct btp_ase *ase = user_data; +struct btp_device *device = ase->device; +struct btp_adapter *adapter =find_adapter_by_device (device); +struct btp_bap_ase_found_ev *rp; +struct l_dbus_message_iter iter; +uint8_t *data; +uint32_t n; + +if (l_dbus_message_is_error (result)) { +const char *name, *desc; + +l_dbus_message_get_error (result, &name, &desc); +l_error ("Failed to read value (%s), %s" , name, desc); + +btp_send_error (btp,BTP_BAP_SERVICE , adapter->index, +BTP_ERROR_FAIL ); +return ; + } + +if (!l_dbus_message_get_arguments (result,"ay" , &iter)) + goto failed; + +if (!l_dbus_message_iter_get_fixed_array (&iter, &data, &n)) { +l_debug ("Cannot read value" ); + goto failed; + } + + ase->ase_id = data[0 ]; + + rp = l_new(struct btp_bap_ase_found_ev, 1); + rp->address_type = device->address_type; + rp->address = device->address; + rp->dir = ase->dir; + rp->ase_id = data[0 ]; + +btp_send (btp,BTP_BAP_SERVICE ,BTP_EV_BAP_ASE_FOUND , adapter->index, +sizeof (struct btp_bap_ase_found_ev ), rp); + +free (rp); + +return ; + +failed: +btp_send_error (btp,BTP_BAP_SERVICE , adapter->index,BTP_ERROR_FAIL ); +} + +void bap_proxy_added (struct l_dbus_proxy *proxy,void *user_data) +{ +struct btp_device *device = user_data; +const char *interface =l_dbus_proxy_get_interface (proxy); + +if (!strcmp (interface,"org.bluez.GattCharacteristic1" )) { +char *str, str_uuid[MAX_LEN_UUID_STR ]; +bt_uuid_t uuid; +struct btp_ase *ase; + +if (!l_dbus_proxy_get_property (proxy,"UUID" ,"s" , &str)) +return ; + +bt_uuid16_create (&uuid,ASE_SINK_UUID ); +bt_uuid_to_string (&uuid, str_uuid,MAX_LEN_UUID_STR ); +if (!bt_uuid_strcmp (str, str_uuid)) { + ase = l_new(struct btp_ase, 1); + ase->device = device; + ase->dir =BTP_BAP_DIR_SINK ; + ase->uuid = uuid; +l_queue_push_tail (device->ases, ase); + +l_dbus_proxy_method_call (proxy,"ReadValue" , + bap_charac_read_setup, + bap_read_ase_reply, + ase,NULL ); + } + +bt_uuid16_create (&uuid,ASE_SOURCE_UUID ); +bt_uuid_to_string (&uuid, str_uuid,MAX_LEN_UUID_STR ); +if (!bt_uuid_strcmp (str, str_uuid)) { + ase = l_new(struct btp_ase, 1); + ase->device = device; + ase->dir =BTP_BAP_DIR_SOURCE ; + ase->uuid = uuid; +l_queue_push_tail (device->ases, ase); + +l_dbus_proxy_method_call (proxy,"ReadValue" , + bap_charac_read_setup, + bap_read_ase_reply, + ase,NULL ); + } + } +} +bool bap_register_service (struct btp *btp_,struct l_dbus *dbus_,struct l_dbus_client *client) {
client/btpclient/bap.h +2 -0
@@ -11,3 +11,5 @@ bool bap_register_service(struct btp *btp_, struct l_dbus *dbus_, struct l_dbus_client *client);void bap_unregister_service (struct btp *btp);bool bap_is_service_registered (void ); + +void bap_proxy_added (struct l_dbus_proxy *proxy,void *user_data);
client/btpclient/btpclient.c +6 -0
@@ -25,6 +25,7 @@#include "bluetooth/uuid.h" #include "src/shared/btp.h" #include "btpclient.h" +#include "bap.h" #include "core.h" #include "gap.h" #include "gatt.h"
@@ -347,6 +348,7 @@ static void signal_handler(uint32_t signo, void *user_data)static void btp_device_free (struct btp_device *device) { +l_queue_destroy (device->ases, l_free);l_queue_destroy (device->services, l_free);l_queue_destroy (device->characteristics, l_free);l_queue_destroy (device->descriptors, l_free);
@@ -444,6 +446,7 @@ static void proxy_added(struct l_dbus_proxy *proxy, void *user_data) device->services =l_queue_new (); device->characteristics =l_queue_new (); device->descriptors =l_queue_new (); + device->ases =l_queue_new ();l_queue_push_tail (adapter->devices, device);
@@ -545,6 +548,9 @@ static void proxy_added(struct l_dbus_proxy *proxy, void *user_data) }l_queue_push_tail (device->characteristics, attribute); + +if (bap_is_service_registered ()) +bap_proxy_added (proxy, device); }if (!strcmp (interface,"org.bluez.GattDescriptor1" )) {
client/btpclient/btpclient.h +8 -0
@@ -26,6 +26,14 @@ struct btp_device {struct l_queue *services;struct l_queue *characteristics;struct l_queue *descriptors; +struct l_queue *ases; +}; + +struct btp_ase { +struct btp_device *device; +bt_uuid_t uuid; +uint8_t dir; +uint8_t ase_id; };struct btp_agent {
src/shared/btp.h +11 -0
@@ -425,6 +425,9 @@ struct btp_gatt_write_rp {uint8_t att_response; } __packed; +#define BTP_BAP_DIR_SINK 0x01 +#define BTP_BAP_DIR_SOURCE 0x02 +#define BTP_OP_BAP_READ_SUPPORTED_COMMANDS 0x01#define BTP_OP_BAP_DISCOVER 0x02
@@ -440,6 +443,14 @@ struct btp_bap_discovery_completed_ev {uint8_t status; } __packed; +#define BTP_EV_BAP_ASE_FOUND 0x82 +struct btp_bap_ase_found_ev { +uint8_t address_type; +bdaddr_t address; +uint8_t dir; +uint8_t ase_id; +} __packed; +struct btp ;typedef void (*btp_destroy_func_t )(void *user_data);
Signature · 1 line
2.43.0
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1158120
---Test result---
Test Summary:
CheckPatch PASS 3.99 seconds GitLint FAIL 1.84 seconds BuildEll PASS 16.00 seconds BluezMake PASS 488.30 seconds MakeCheck PASS 18.12 seconds MakeDistcheck PASS 122.64 seconds CheckValgrind PASS 176.17 seconds CheckSmatch PASS 233.12 seconds bluezmakeextell PASS 74.74 seconds IncrementalBuild FAIL 530.91 seconds ScanBuild FAIL 81.94 seconds
Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[BlueZ,7/8] client/btpclient: Defer CIG/CIS assignment based on Client/Server role
1: T1 Title exceeds max length (82>80): "[BlueZ,7/8] client/btpclient: Defer CIG/CIS assignment based on Client/Server role"
##############################
Test: IncrementalBuild - FAIL
Desc: Incremental build with the patches in the series
Output:
client/btpclient/bap.c: In function ‘btp_bap_send’:client/btpclient/bap.c:125:8: error: implicit declaration of function ‘find_ase_by_dir’; did you mean ‘find_ase_by_uuid’? [-Werror=implicit-function-declaration]
125 | ase = find_ase_by_dir(dev, BTP_BAP_DIR_SINK);
| ^~~~~~~~~~~~~~~
| find_ase_by_uuidclient/btpclient/bap.c:125:6: error: assignment to ‘struct btp_ase *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
125 | ase = find_ase_by_dir(dev, BTP_BAP_DIR_SINK);
| ^client/btpclient/bap.c:126:18: error: ‘struct btp_ase’ has no member named ‘io’
126 | if (!ase || !ase->io)
| ^~client/btpclient/bap.c:129:39: error: ‘struct btp_ase’ has no member named ‘io’
129 | bytes_written = write(l_io_get_fd(ase->io), cp->data,
| ^~client/btpclient/bap.c:130:22: error: ‘struct btp_ase’ has no member named ‘tx_mtu’
130 | cp->data_len <= ase->tx_mtu ? cp->data_len : ase->tx_mtu);
| ^~client/btpclient/bap.c:130:51: error: ‘struct btp_ase’ has no member named ‘tx_mtu’
130 | cp->data_len <= ase->tx_mtu ? cp->data_len : ase->tx_mtu);
| ^~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:7197: client/btpclient/bap.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:4264: all] Error 2
[BlueZ,5/8] client/btpclient: Add BTP_OP_BAP_SEND support
client/btpclient/bap.c: In function ‘btp_bap_send’:client/btpclient/bap.c:125:8: error: implicit declaration of function ‘find_ase_by_dir’; did you mean ‘find_ase_by_uuid’? [-Werror=implicit-function-declaration]
125 | ase = find_ase_by_dir(dev, BTP_BAP_DIR_SINK);
| ^~~~~~~~~~~~~~~
| find_ase_by_uuidclient/btpclient/bap.c:125:6: error: assignment to ‘struct btp_ase *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
125 | ase = find_ase_by_dir(dev, BTP_BAP_DIR_SINK);
| ^client/btpclient/bap.c:126:18: error: ‘struct btp_ase’ has no member named ‘io’
126 | if (!ase || !ase->io)
| ^~client/btpclient/bap.c:129:39: error: ‘struct btp_ase’ has no member named ‘io’
129 | bytes_written = write(l_io_get_fd(ase->io), cp->data,
| ^~client/btpclient/bap.c:130:22: error: ‘struct btp_ase’ has no member named ‘tx_mtu’
130 | cp->data_len <= ase->tx_mtu ? cp->data_len : ase->tx_mtu);
| ^~client/btpclient/bap.c:130:51: error: ‘struct btp_ase’ has no member named ‘tx_mtu’
130 | cp->data_len <= ase->tx_mtu ? cp->data_len : ase->tx_mtu);
| ^~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:7197: client/btpclient/bap.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:4264: all] Error 2
##############################
Test: ScanBuild - FAIL
Desc: Run Scan Build
Output:
src/shared/gatt-client.c:447:21: warning: Use of memory after it is freed
gatt_db_unregister(op->client->db, op->db_id);
^~~~~~~~~~
src/shared/gatt-client.c:692:2: warning: Use of memory after it is freed
discovery_op_complete(op, false, att_ecode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:992:2: warning: Use of memory after it is freed
discovery_op_complete(op, success, att_ecode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1098:2: warning: Use of memory after it is freed
discovery_op_complete(op, success, att_ecode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1292:2: warning: Use of memory after it is freed
discovery_op_complete(op, success, att_ecode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1357:2: warning: Use of memory after it is freed
discovery_op_complete(op, success, att_ecode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1632:6: warning: Use of memory after it is freed
if (read_db_hash(op)) {
^~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1637:2: warning: Use of memory after it is freed
discover_all(op);
^~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1693:56: warning: Use of memory after it is freed
notify_data->chrc->ccc_write_id = notify_data->att_id = att_id;
~~~~~~~~~~~~~~~~~~~ ^
src/shared/gatt-client.c:2146:6: warning: Use of memory after it is freed
if (read_db_hash(op)) {
^~~~~~~~~~~~~~~~
src/shared/gatt-client.c:2154:8: warning: Use of memory after it is freed
discovery_op_ref(op),
^~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:3332:2: warning: Use of memory after it is freed
complete_write_long_op(req, success, 0, false);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:3354:2: warning: Use of memory after it is freed
request_unref(req);
^~~~~~~~~~~~~~~~~~
13 warnings generated.
src/shared/rap.c:3554:13: warning: Use of memory after it is freed
attached = queue_find(sessions, NULL, rap);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
src/shared/bap.c:1543:8: warning: Use of memory after it is freed
bap = bt_bap_ref_safe(bap);
^~~~~~~~~~~~~~~~~~~~
src/shared/bap.c:2354:20: warning: Use of memory after it is freed
return queue_find(stream->bap->streams, NULL, stream);
^~~~~~~~~~~~~~~~~~~~
2 warnings generated.
src/shared/gatt-client.c:447:21: warning: Use of memory after it is freed
gatt_db_unregister(op->client->db, op->db_id);
^~~~~~~~~~
src/shared/gatt-client.c:692:2: warning: Use of memory after it is freed
discovery_op_complete(op, false, att_ecode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:992:2: warning: Use of memory after it is freed
discovery_op_complete(op, success, att_ecode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1098:2: warning: Use of memory after it is freed
discovery_op_complete(op, success, att_ecode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1292:2: warning: Use of memory after it is freed
discovery_op_complete(op, success, att_ecode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1357:2: warning: Use of memory after it is freed
discovery_op_complete(op, success, att_ecode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1632:6: warning: Use of memory after it is freed
if (read_db_hash(op)) {
^~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1637:2: warning: Use of memory after it is freed
discover_all(op);
^~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1693:56: warning: Use of memory after it is freed
notify_data->chrc->ccc_write_id = notify_data->att_id = att_id;
~~~~~~~~~~~~~~~~~~~ ^
src/shared/gatt-client.c:2146:6: warning: Use of memory after it is freed
if (read_db_hash(op)) {
^~~~~~~~~~~~~~~~
src/shared/gatt-client.c:2154:8: warning: Use of memory after it is freed
discovery_op_ref(op),
^~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:3332:2: warning: Use of memory after it is freed
complete_write_long_op(req, success, 0, false);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:3354:2: warning: Use of memory after it is freed
request_unref(req);
^~~~~~~~~~~~~~~~~~
13 warnings generated.
src/shared/rap.c:3554:13: warning: Use of memory after it is freed
attached = queue_find(sessions, NULL, rap);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
tools/hciattach.c:817:7: warning: Although the value stored to 'n' is used in the enclosing expression, the value is never actually read from 'n'
if ((n = read_hci_event(fd, resp, 10)) < 0) {
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tools/hciattach.c:865:7: warning: Although the value stored to 'n' is used in the enclosing expression, the value is never actually read from 'n'
if ((n = read_hci_event(fd, resp, 4)) < 0) {
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
tools/hciattach.c:887:8: warning: Although the value stored to 'n' is used in the enclosing expression, the value is never actually read from 'n'
if ((n = read_hci_event(fd, resp, 10)) < 0) {
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tools/hciattach.c:909:7: warning: Although the value stored to 'n' is used in the enclosing expression, the value is never actually read from 'n'
if ((n = read_hci_event(fd, resp, 4)) < 0) {
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
tools/hciattach.c:930:7: warning: Although the value stored to 'n' is used in the enclosing expression, the value is never actually read from 'n'
if ((n = read_hci_event(fd, resp, 4)) < 0) {
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
tools/hciattach.c:974:7: warning: Although the value stored to 'n' is used in the enclosing expression, the value is never actually read from 'n'
if ((n = read_hci_event(fd, resp, 6)) < 0) {
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
6 warnings generated.
src/shared/bap.c:1543:8: warning: Use of memory after it is freed
bap = bt_bap_ref_safe(bap);
^~~~~~~~~~~~~~~~~~~~
src/shared/bap.c:2354:20: warning: Use of memory after it is freed
return queue_find(stream->bap->streams, NULL, stream);
^~~~~~~~~~~~~~~~~~~~
2 warnings generated.
src/oui.c:50:2: warning: Value stored to 'hwdb' is never read
hwdb = udev_hwdb_unref(hwdb);
^ ~~~~~~~~~~~~~~~~~~~~~
src/oui.c:53:2: warning: Value stored to 'udev' is never read
udev = udev_unref(udev);
^ ~~~~~~~~~~~~~~~~
2 warnings generated.
tools/rfcomm.c:234:3: warning: Value stored to 'i' is never read
i = execvp(cmdargv[0], cmdargv);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
tools/rfcomm.c:234:7: warning: Null pointer passed to 1st parameter expecting 'nonnull'
i = execvp(cmdargv[0], cmdargv);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
tools/rfcomm.c:354:8: warning: Although the value stored to 'fd' is used in the enclosing expression, the value is never actually read from 'fd'
if ((fd = open(devname, O_RDONLY | O_NOCTTY)) < 0) {
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tools/rfcomm.c:497:14: warning: Assigned value is garbage or undefined
req.channel = raddr.rc_channel;
^ ~~~~~~~~~~~~~~~~
tools/rfcomm.c:515:8: warning: Although the value stored to 'fd' is used in the enclosing expression, the value is never actually read from 'fd'
if ((fd = open(devname, O_RDONLY | O_NOCTTY)) < 0) {
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 warnings generated.
tools/ciptool.c:351:7: warning: 5th function call argument is an uninitialized value
sk = do_connect(ctl, dev_id, &src, &dst, psm, (1 << CMTP_LOOPBACK));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
src/sdp-xml.c:129:10: warning: Assigned value is garbage or undefined
buf[1] = data[i + 1];
^ ~~~~~~~~~~~
src/sdp-xml.c:309:11: warning: Assigned value is garbage or undefined
buf[1] = data[i + 1];
^ ~~~~~~~~~~~
src/sdp-xml.c:347:11: warning: Assigned value is garbage or undefined
buf[1] = data[i + 1];
^ ~~~~~~~~~~~
3 warnings generated.
tools/sdptool.c:941:26: warning: Result of 'malloc' is converted to a pointer of type 'uint32_t', which is incompatible with sizeof operand type 'int'
uint32_t *value_int = malloc(sizeof(int));
~~~~~~~~~~ ^~~~~~ ~~~~~~~~~~~
tools/sdptool.c:980:4: warning: 1st function call argument is an uninitialized value
free(allocArray[i]);
^~~~~~~~~~~~~~~~~~~
tools/sdptool.c:3777:2: warning: Potential leak of memory pointed to by 'si.name'
return add_service(0, &si);
^~~~~~~~~~~~~~~~~~~~~~~~~~
tools/sdptool.c:4112:4: warning: Potential leak of memory pointed to by 'context.svc'
return -1;
^~~~~~~~~
4 warnings generated.
tools/avtest.c:243:5: warning: Value stored to 'len' is never read
len = write(sk, buf, 3);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:253:5: warning: Value stored to 'len' is never read
len = write(sk, buf, 4);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:262:5: warning: Value stored to 'len' is never read
len = write(sk, buf, 3);
^ ~~~~~~~~~~~~~~~~~tools/avtest.c:276:5: warning: Value stored to 'len' is never read
len = write(sk, buf,
^ ~~~~~~~~~~~~~~tools/avtest.c:283:5: warning: Value stored to 'len' is never read
len = write(sk, buf,
^ ~~~~~~~~~~~~~~tools/avtest.c:290:5: warning: Value stored to 'len' is never read
len = write(sk, buf,
^ ~~~~~~~~~~~~~~tools/avtest.c:297:5: warning: Value stored to 'len' is never read
len = write(sk, buf,
^ ~~~~~~~~~~~~~~tools/avtest.c:309:5: warning: Value stored to 'len' is never read
len = write(sk, buf, 4);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:313:5: warning: Value stored to 'len' is never read
len = write(sk, buf, 2);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:322:5: warning: Value stored to 'len' is never read
len = write(sk, buf, 3);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:326:5: warning: Value stored to 'len' is never read
len = write(sk, buf, 2);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:335:5: warning: Value stored to 'len' is never read
len = write(sk, buf, 3);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:342:5: warning: Value stored to 'len' is never read
len = write(sk, buf, 2);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:364:5: warning: Value stored to 'len' is never read
len = write(sk, buf, 4);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:368:5: warning: Value stored to 'len' is never read
len = write(sk, buf, 2);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:377:5: warning: Value stored to 'len' is never read
len = write(sk, buf, 3);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:381:5: warning: Value stored to 'len' is never read
len = write(sk, buf, 2);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:394:5: warning: Value stored to 'len' is never read
len = write(sk, buf, 4);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:398:5: warning: Value stored to 'len' is never read
len = write(sk, buf, 2);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:405:4: warning: Value stored to 'len' is never read
len = write(sk, buf, 2);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:415:4: warning: Value stored to 'len' is never read
len = write(sk, buf, 2);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:580:3: warning: Value stored to 'len' is never read
len = write(sk, buf, 2);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:588:3: warning: Value stored to 'len' is never read
len = write(sk, buf, invalid ? 2 : 3);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tools/avtest.c:602:3: warning: Value stored to 'len' is never read
len = write(sk, buf, 4 + media_transport_size);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tools/avtest.c:615:3: warning: Value stored to 'len' is never read
len = write(sk, buf, 3);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:625:3: warning: Value stored to 'len' is never read
len = write(sk, buf, 3);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:637:3: warning: Value stored to 'len' is never read
len = write(sk, buf, 3);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:652:3: warning: Value stored to 'len' is never read
len = write(sk, buf, 3);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:664:3: warning: Value stored to 'len' is never read
len = write(sk, buf, 3);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:673:3: warning: Value stored to 'len' is never read
len = write(sk, buf, 3);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:680:3: warning: Value stored to 'len' is never read
len = write(sk, buf, 2);
^ ~~~~~~~~~~~~~~~~~
tools/avtest.c:716:2: warning: Value stored to 'len' is never read
len = write(sk, buf, AVCTP_HEADER_LENGTH + sizeof(play_pressed));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32 warnings generated.
tools/btproxy.c:836:15: warning: Null pointer passed to 1st parameter expecting 'nonnull'
tcp_port = atoi(optarg);
^~~~~~~~~~~~
tools/btproxy.c:839:8: warning: Null pointer passed to 1st parameter expecting 'nonnull'
if (strlen(optarg) > 3 && !strncmp(optarg, "hci", 3))
^~~~~~~~~~~~~~
2 warnings generated.
tools/create-image.c:76:3: warning: Value stored to 'fd' is never read
fd = -1;
^ ~~
tools/create-image.c:84:3: warning: Value stored to 'fd' is never read
fd = -1;
^ ~~
tools/create-image.c:92:3: warning: Value stored to 'fd' is never read
fd = -1;
^ ~~
tools/create-image.c:105:2: warning: Value stored to 'fd' is never read
fd = -1;
^ ~~
4 warnings generated.
tools/check-selftest.c:42:3: warning: Value stored to 'ptr' is never read
ptr = fgets(result, sizeof(result), fp);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
tools/btgatt-server.c:1204:2: warning: Value stored to 'argv' is never read
argv -= optind;
^ ~~~~~~
1 warning generated.
tools/btgatt-client.c:1822:2: warning: Value stored to 'argv' is never read
argv += optind;
^ ~~~~~~
1 warning generated.
tools/gatt-service.c:294:2: warning: 2nd function call argument is an uninitialized value
chr_write(chr, value, len);
^~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
tools/obex-server-tool.c:133:13: warning: Null pointer passed to 1st parameter expecting 'nonnull'
data->fd = open(name, O_WRONLY | O_CREAT | O_NOCTTY, 0600);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tools/obex-server-tool.c:192:13: warning: Null pointer passed to 1st parameter expecting 'nonnull'
data->fd = open(name, O_RDONLY | O_NOCTTY, 0);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.
client/btpclient/bap.c: In function ‘btp_bap_send’:
client/btpclient/bap.c:125:8: error: implicit declaration of function ‘find_ase_by_dir’; did you mean ‘find_ase_by_uuid’? [-Werror=implicit-function-declaration]
125 | ase = find_ase_by_dir(dev, BTP_BAP_DIR_SINK);
| ^~~~~~~~~~~~~~~
| find_ase_by_uuidclient/btpclient/bap.c:125:6: error: assignment to ‘struct btp_ase *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
125 | ase = find_ase_by_dir(dev, BTP_BAP_DIR_SINK);
| ^client/btpclient/bap.c:126:18: error: ‘struct btp_ase’ has no member named ‘io’
126 | if (!ase || !ase->io)
| ^~client/btpclient/bap.c:129:39: error: ‘struct btp_ase’ has no member named ‘io’
129 | bytes_written = write(l_io_get_fd(ase->io), cp->data,
| ^~client/btpclient/bap.c:130:22: error: ‘struct btp_ase’ has no member named ‘tx_mtu’
130 | cp->data_len <= ase->tx_mtu ? cp->data_len : ase->tx_mtu);
| ^~client/btpclient/bap.c:130:51: error: ‘struct btp_ase’ has no member named ‘tx_mtu’
130 | cp->data_len <= ase->tx_mtu ? cp->data_len : ase->tx_mtu);
| ^~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:7197: client/btpclient/bap.o] Error 1
make[1]: *** Waiting for unfinished jobs....tools/test-runner.c:1367:2: warning: Address of stack memory associated with local variable 'kernel_path' is still referred to by the global variable 'kernel_image' upon returning to the caller. This will be a dangling reference
return EXIT_SUCCESS;
^~~~~~~~~~~~~~~~~~~1 warning generated.
make: *** [Makefile:4264: all] Error 2
https://github.com/bluez/bluez/pull/2491
---
Regards,
Linux Bluetooth
PATCH 2/8 client/btpclient: Get Codec capabilities on ASE reply
In reply to Frédéric Danis--- Makefile.tools | 2 +- client/btpclient/bap.c | 94 ++++++++++++++++++++++++++++++++++++++++-- src/shared/btp.h | 12 ++++++ 3 files changed, 104 insertions(+), 4 deletions(-)
Makefile.tools +1 -1
@@ -567,7 +567,7 @@ noinst_PROGRAMS += client/btpclient/btpclient client/btpclient/btpclientctl client_btpclient_btpclient_SOURCES = client/btpclient/btpclient.c \ client/btpclient/btpclient.h \ - src/shared/btp.c src/shared/btp.h \ + src/shared/btp.c src/shared/btp.h src/shared/bap-defs.h \ client/btpclient/bap.c client/btpclient/bap.h \ client/btpclient/core.c client/btpclient/core.h \ client/btpclient/gap.c client/btpclient/gap.h \
client/btpclient/bap.c +91 -3
132 lines not on this page · raw message
src/shared/btp.h +12 -0
@@ -443,6 +443,18 @@ struct btp_bap_discovery_completed_ev {uint8_t status; } __packed; +#define BTP_BAP_EV_CODEC_CAP_FOUND 0x81 +struct btp_bap_codec_cap_found_ev { +uint8_t address_type; +bdaddr_t address; +uint8_t dir; +uint8_t coding_format; +uint16_t frequencies; +uint8_t frame_durations; +uint32_t octets_per_frame; +uint8_t channel_counts; +} __packed; +#define BTP_EV_BAP_ASE_FOUND 0x82struct btp_bap_ase_found_ev {uint8_t address_type;
Signature · 1 line
2.43.0
PATCH 3/8 client/btpclient: Add ASCS BTP support
In reply to Frédéric DanisThe audio endpoints are registered by ASCS setup command of VENDOR service at start of the test.
For SelectProperties() D-Bus method, the reply is postponed after auto-pts has requested the ASE and PACS characteritic values.
This allows to pass the BAP/UCL/SCC/* tests.
--- Makefile.tools | 4 +- client/btpclient/ascs.c | 937 +++++++++++++++++++++++++++++++++++ client/btpclient/ascs.h | 18 + client/btpclient/btpclient.c | 85 +++- client/btpclient/btpclient.h | 7 + client/btpclient/core.c | 59 ++- client/btpclient/gap.c | 3 - client/btpclient/vendor.c | 102 ++++ client/btpclient/vendor.h | 13 + src/shared/btp.h | 43 ++ 10 files changed, 1262 insertions(+), 9 deletions(-) create mode 100644 client/btpclient/ascs.c create mode 100644 client/btpclient/ascs.h create mode 100644 client/btpclient/vendor.c create mode 100644 client/btpclient/vendor.h
Makefile.tools +3 -1
@@ -568,10 +568,12 @@ noinst_PROGRAMS += client/btpclient/btpclient client/btpclient/btpclientctl client_btpclient_btpclient_SOURCES = client/btpclient/btpclient.c \ client/btpclient/btpclient.h \ src/shared/btp.c src/shared/btp.h src/shared/bap-defs.h \ + client/btpclient/ascs.c client/btpclient/ascs.h \ client/btpclient/bap.c client/btpclient/bap.h \ client/btpclient/core.c client/btpclient/core.h \ client/btpclient/gap.c client/btpclient/gap.h \ - client/btpclient/gatt.c client/btpclient/gatt.h + client/btpclient/gatt.c client/btpclient/gatt.h \ + client/btpclient/vendor.c client/btpclient/vendor.h client_btpclient_btpclient_LDADD = lib/libbluetooth-internal.la \ src/libshared-ell.la $(ell_ldadd) client/btpclient/btpclient.$(OBJEXT): src/libshared-ell.la ell/internal
client/btpclient/ascs.c new file +937 -0
937 lines not on this page · raw message
client/btpclient/ascs.h new file +18 -0
@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +/* +* +* BlueZ - Bluetooth protocol stack for Linux +* +* Copyright (C) 2026 Collabora Ltd. +* +*/ + +bool ascs_register_service (struct btp *btp_,struct l_dbus *dbus_, +struct l_dbus_client *client); +void ascs_unregister_service (struct btp *btp); +bool ascs_is_service_registered (void ); + +bool ascs_setup (struct btp_adapter *adapter); + +void ascs_property_changed (struct l_dbus_proxy *proxy,const char *name, +struct l_dbus_message *msg,void *user_data);
client/btpclient/btpclient.c +84 -1
134 lines not on this page · raw message
client/btpclient/btpclient.h +7 -0
@@ -12,11 +12,14 @@struct btp_adapter {struct l_dbus_proxy *proxy;struct l_dbus_proxy *ad_proxy; +struct l_dbus_proxy *media_proxy;uint8_t index;uint32_t supported_settings;uint32_t current_settings;uint32_t default_settings;struct l_queue *devices; + +uint8_t target_latency; };struct btp_device {
@@ -27,6 +30,7 @@ struct btp_device {struct l_queue *characteristics;struct l_queue *descriptors;struct l_queue *ases; +struct l_queue *endpoints; };struct btp_ase {
@@ -34,6 +38,7 @@ struct btp_ase {bt_uuid_t uuid;uint8_t dir;uint8_t ase_id; +struct l_dbus_proxy *ep_proxy; };struct btp_agent {
@@ -58,6 +63,8 @@ struct btp_device *find_device_by_address(struct btp_adapter *adapter,struct btp_device *find_device_by_path (const char *path);struct btp_adapter *find_adapter_by_device (struct btp_device *device);struct btp_device *find_device_by_proxy (struct l_dbus_proxy *proxy); +struct btp_device *find_device_by_service_path (const char *path); +struct btp_ase *find_ase_by_uuid (struct btp_device *device,char *uuid);struct btp_agent *get_agent (void );
client/btpclient/core.c +55 -4
107 lines not on this page · raw message
client/btpclient/gap.c +0 -3
@@ -2684,9 +2684,6 @@ void gap_property_changed(struct l_dbus_proxy *proxy, const char *name, struct l_dbus_message *msg, void *user_data) { const char *interface = l_dbus_proxy_get_interface(proxy); -const char *path =l_dbus_proxy_get_path (proxy); - -l_info ("property_changed %s %s %s" , name, path, interface);if (!strcmp (interface,"org.bluez.Adapter1" )) {struct btp_adapter *adapter =find_adapter_by_proxy (proxy);
client/btpclient/vendor.c new file +102 -0
102 lines not on this page · raw message
client/btpclient/vendor.h new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +/* +* +* BlueZ - Bluetooth protocol stack for Linux +* +* Copyright (C) 2026 Collabora Ltd. +* +*/ + +bool vendor_register_service (struct btp *btp_,struct l_dbus *dbus_, +struct l_dbus_client *client); +void vendor_unregister_service (struct btp *btp); +bool vendor_is_service_registered (void );
src/shared/btp.h +43 -0
62 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 4/8 client/btpclient: Add BTP_OP_PACS_SET_LOCATION support
In reply to Frédéric DanisThis allows to store the expected location for a local endpoint.
--- Makefile.tools | 1 + client/btpclient/btpclient.h | 3 + client/btpclient/core.c | 16 ++++++ client/btpclient/pacs.c | 107 +++++++++++++++++++++++++++++++++++ client/btpclient/pacs.h | 13 +++++ src/shared/btp.h | 9 +++ 6 files changed, 149 insertions(+) create mode 100644 client/btpclient/pacs.c create mode 100644 client/btpclient/pacs.h
Makefile.tools +1 -0
@@ -573,6 +573,7 @@ client_btpclient_btpclient_SOURCES = client/btpclient/btpclient.c \ client/btpclient/core.c client/btpclient/core.h \ client/btpclient/gap.c client/btpclient/gap.h \ client/btpclient/gatt.c client/btpclient/gatt.h \ + client/btpclient/pacs.c client/btpclient/pacs.h \ client/btpclient/vendor.c client/btpclient/vendor.h client_btpclient_btpclient_LDADD = lib/libbluetooth-internal.la \ src/libshared-ell.la $(ell_ldadd)
client/btpclient/btpclient.h +3 -0
@@ -19,6 +19,9 @@ struct btp_adapter {uint32_t default_settings;struct l_queue *devices; +uint32_t sink_locations; +uint32_t source_locations; +uint8_t target_latency; };
client/btpclient/core.c +16 -0
@@ -18,6 +18,7 @@#include "core.h" #include "gap.h" #include "gatt.h" +#include "pacs.h" #include "vendor.h" static struct btp *btp;
@@ -67,6 +68,7 @@ static void btp_core_read_services(uint8_t index, const void *param,BTP_CORE_SERVICE ,BTP_GAP_SERVICE ,BTP_GATT_SERVICE , +BTP_PACS_SERVICE ,BTP_ASCS_SERVICE ,BTP_BAP_SERVICE , BTP_VENDOR_SERVICE,
@@ -130,6 +132,14 @@ static void btp_core_register(uint8_t index, const void *param,if (!gatt_register_service (btp, dbus, client)) goto failed; +break ; +case BTP_PACS_SERVICE : +if (pacs_is_service_registered ()) + goto failed; + +if (!pacs_register_service (btp, dbus, client)) + goto failed; +break ;case BTP_ASCS_SERVICE :if (ascs_is_service_registered ())
@@ -197,6 +207,12 @@ static void btp_core_unregister(uint8_t index, const void *param,gatt_unregister_service (btp);break ; +case BTP_PACS_SERVICE : +if (!pacs_is_service_registered ()) + goto failed; + +ascs_unregister_service (btp); +break ;case BTP_ASCS_SERVICE :if (!ascs_is_service_registered ()) goto failed;
client/btpclient/pacs.c new file +107 -0
107 lines not on this page · raw message
client/btpclient/pacs.h new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +/* +* +* BlueZ - Bluetooth protocol stack for Linux +* +* Copyright (C) 2026 Collabora Ltd. +* +*/ + +bool pacs_register_service (struct btp *btp_,struct l_dbus *dbus_, +struct l_dbus_client *client); +void pacs_unregister_service (struct btp *btp); +bool pacs_is_service_registered (void );
src/shared/btp.h +9 -0
@@ -26,6 +26,7 @@#define BTP_GATT_SERVICE 2#define BTP_L2CAP_SERVICE 3#define BTP_MESH_NODE_SERVICE 4 +#define BTP_PACS_SERVICE 12#define BTP_ASCS_SERVICE 13#define BTP_BAP_SERVICE 14#define BTP_VENDOR_SERVICE 255
@@ -427,6 +428,14 @@ struct btp_gatt_write_rp {uint8_t att_response; } __packed; +#define BTP_OP_PACS_READ_SUPPORTED_COMMANDS 0x01 + +#define BTP_OP_PACS_SET_LOCATION 0x03 +struct btp_pacs_set_location_cp { +uint8_t dir; +uint32_t location; +} __packed; +#define BTP_OP_ASCS_READ_SUPPORTED_COMMANDS 0x01#define BTP_OP_ASCS_CONFIGURE_CODEC 0x02
Signature · 1 line
2.43.0
PATCH 5/8 client/btpclient: Add BTP_OP_BAP_SEND support
In reply to Frédéric Danis--- client/btpclient/bap.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/shared/btp.h | 13 +++++++++++++ 2 files changed, 54 insertions(+)
client/btpclient/bap.c +41 -0
@@ -31,6 +31,7 @@ static void btp_bap_read_commands(uint8_t index, const void *param,const uint8_t supported_commands[] = {BTP_OP_BAP_READ_SUPPORTED_COMMANDS ,BTP_OP_BAP_DISCOVER , +BTP_OP_BAP_SEND , };uint8_t *commands =NULL ;size_t commands_len =0 ;
@@ -104,6 +105,43 @@ failed:btp_send_error (btp,BTP_BAP_SERVICE , index, status); } +static void btp_bap_send (uint8_t index,const void *param,uint16_t length, +void *user_data) +{ +const struct btp_bap_send_cp *cp = param; +struct btp_adapter *adapter =find_adapter_by_index (index); +uint8_t status =BTP_ERROR_FAIL ; +struct btp_device *dev; +struct btp_ase *ase; +ssize_t bytes_written; +struct btp_bap_send_rp rp; + +if (!adapter) { + status =BTP_ERROR_INVALID_INDEX ; + goto failed; + } + + dev =find_device_by_address (adapter, &cp->address, cp->address_type); + ase =find_ase_by_dir (dev,BTP_BAP_DIR_SINK ); +if (!ase || !ase->io) + goto failed; + + bytes_written =write (l_io_get_fd (ase->io), cp->data, + cp->data_len <= ase->tx_mtu ? cp->data_len : ase->tx_mtu); +if (bytes_written <0 ) { +l_error ("Failed to write (%d)" , errno); + goto failed; + } + rp.data_len = bytes_written; + +btp_send (btp,BTP_BAP_SERVICE ,BTP_OP_BAP_SEND , index,sizeof (rp), &rp); + +return ; + +failed: +btp_send_error (btp,BTP_BAP_SERVICE , index, status); +} +static void bap_charac_read_setup (struct l_dbus_message *message,void *user_data) {
@@ -304,6 +342,9 @@ bool bap_register_service(struct btp *btp_, struct l_dbus *dbus_,btp_register (btp,BTP_BAP_SERVICE ,BTP_OP_BAP_DISCOVER , btp_bap_discover,NULL ,NULL ); +btp_register (btp,BTP_BAP_SERVICE ,BTP_OP_BAP_SEND , + btp_bap_send,NULL ,NULL ); + bap_service_registered = true;return true;
src/shared/btp.h +13 -0
@@ -481,6 +481,19 @@ struct btp_bap_discover_cp {bdaddr_t address; } __packed; +#define BTP_OP_BAP_SEND 0x03 +struct btp_bap_send_cp { +uint8_t address_type; +bdaddr_t address; +uint8_t ase_id; +uint8_t data_len; +uint8_t data[]; +} __packed; + +struct btp_bap_send_rp { +uint8_t data_len; +} __packed; +#define BTP_EV_BAP_DISCOVERY_COMPLETED 0x80struct btp_bap_discovery_completed_ev {uint8_t address_type;
Signature · 1 line
2.43.0
PATCH 6/8 client/btpclient: Add ASCS support for BAP/UCL/STR/* tests
In reply to Frédéric Danis--- client/btpclient/ascs.c | 696 ++++++++++++++++++++++++++++++++--- client/btpclient/ascs.h | 3 + client/btpclient/bap.c | 107 +++++- client/btpclient/btpclient.c | 35 ++ client/btpclient/btpclient.h | 16 + client/btpclient/vendor.c | 1 + src/shared/btp.h | 68 ++++ 7 files changed, 872 insertions(+), 54 deletions(-)
client/btpclient/ascs.c +645 -51
@@ -131,6 +131,11 @@ static void btp_ascs_read_commands(uint8_t index, const void *param,const uint8_t supported_commands[] = {BTP_OP_ASCS_READ_SUPPORTED_COMMANDS ,BTP_OP_ASCS_CONFIGURE_CODEC , +BTP_OP_ASCS_CONFIGURE_QOS , +BTP_OP_ASCS_ENABLE , +BTP_OP_ASCS_RECEIVER_START_READY , +BTP_OP_ASCS_ADD_ASE_TO_CIS , +BTP_OP_ASCS_PRECONFIGURE_QOS , };uint8_t *commands =NULL ;size_t commands_len =0 ;
@@ -362,6 +367,394 @@ failed:btp_send_error (btp,BTP_ASCS_SERVICE , index, status); } +static bool match_ase (const void *entry,const void *data) +{ +const struct btp_ase *ase = entry; +uint8_t id =L_PTR_TO_UINT (data); + +return ase->ase_id == id; +} + +struct configure_qos_complete_data { +struct btp_adapter *adapter; +const struct btp_ascs_configure_qos_cp *cp; +}; + +static void configure_qos_complete_cb (void *data,void *user_data) +{ +struct btp_ase *ase = data; +struct configure_qos_complete_data *param = user_data; +const struct btp_ascs_configure_qos_cp *cp = param->cp; +struct btp_ascs_operation_completed_ev ev; + +if ((cp->ase_id && cp->ase_id != ase->ase_id) || + (cp->cig_id != ase->cig_id)) +return ; + +memcpy (&ev.address, &cp->address,sizeof (ev.address)); + ev.address_type = cp->address_type; + ev.ase_id = ase->ase_id; + ev.opcode =BTP_OP_ASCS_CONFIGURE_QOS ; + ev.status =0 ; + ev.flags =0 ; + +btp_send (btp,BTP_ASCS_SERVICE ,BTP_EV_ASCS_OPERATION_COMPLETED , + param->adapter->index,sizeof (ev), &ev); + +send_state_changed (param->adapter->index, &cp->address, + cp->address_type, ase->ase_id, +BT_BAP_STREAM_STATE_QOS ); +} + +static void btp_ascs_configure_qos (uint8_t index,const void *param, +uint16_t length,void *user_data) +{ +struct btp_adapter *adapter =find_adapter_by_index (index); +struct btp_device *dev; +const struct btp_ascs_configure_qos_cp *cp = param; +struct configure_qos_complete_data data; +uint8_t status =BTP_ERROR_FAIL ; + +if (!adapter) { + status =BTP_ERROR_INVALID_INDEX ; + goto failed; + } + + dev =find_device_by_address (adapter, &cp->address, cp->address_type); +if (!dev) + goto failed; + +btp_send (btp,BTP_ASCS_SERVICE ,BTP_OP_ASCS_CONFIGURE_QOS , index,0 , +NULL ); + +/* Send BTP_EV_ASCS_OPERATION_COMPLETED for each of the ASEs */ + data.adapter = adapter; + data.cp = cp; +l_queue_foreach (dev->ases, configure_qos_complete_cb, &data); + +return ; + +failed: +btp_send_error (btp,BTP_ASCS_SERVICE , index, status); +} + +static bool read_cb (struct l_io *io,void *user_data) +{ +struct btp_ase *ase = user_data; +struct btp_device *device = ase->device; +struct btp_adapter *adapter =find_adapter_by_device (device); +struct btp_bap_stream_received_ev *ev; +ssize_t bytes_read; + + ev =l_malloc (sizeof (struct btp_bap_stream_received_ev ) + ase->rx_mtu); +memcpy (&ev->address, &device->address,sizeof (ev->address)); + ev->address_type = device->address_type; + ev->ase_id = ase->ase_id; + + bytes_read =read (l_io_get_fd (io), ev->data, ase->rx_mtu); +if (bytes_read <0 ) { +l_info ("Invalid read length: %ld" , bytes_read); +l_free (ev); +return false; + } + ev->data_len = bytes_read; + +btp_send (btp,BTP_BAP_SERVICE ,BTP_EV_BAP_STREAM_RECEIVED , + adapter->index,sizeof (*ev) + bytes_read, ev); + +l_free (ev); + +return false; +} + +static bool match_ase_path (const void *entry,const void *data) +{ +const struct btp_ase *ase = entry; +const char *path = data; +const char *ase_path =l_dbus_proxy_get_path (ase->transport_proxy); + +if (!path || !ase_path) +return false; + +return !strcmp (path, ase_path); +} + +static void ase_change_state (struct btp_ase *ase, +enum ase_transport_state state) +{ +struct btp_device *device = ase->device; +struct btp_adapter *adapter =find_adapter_by_device (device); +struct l_dbus_message_iter iter; +const char *path; + + ase->transport_state = state; +if (state ==ASE_TRANSPORT_ACQUIRED ) +send_state_changed (adapter->index, &device->address, + device->address_type, + ase->ase_id, +BT_BAP_STREAM_STATE_ENABLING ); + +if (adapter->desync) +return ; + +/* Update linked endpoints */ +if (!l_dbus_proxy_get_property (ase->transport_proxy,"Links" ,"ao" , + &iter)) +return ; + +while (l_dbus_message_iter_next_entry (&iter, &path)) { +struct btp_ase *l; + + l =l_queue_find (device->ases, match_ase_path, path); +if (!l) +continue ; + + l->transport_state = state; +if (state !=ASE_TRANSPORT_ACQUIRED ) +continue ; + +send_state_changed (adapter->index, &l->device->address, + l->device->address_type, + l->ase_id, +BT_BAP_STREAM_STATE_ENABLING ); + } +} + +static void ascs_acquire_reply (struct l_dbus_proxy *proxy, +struct l_dbus_message *result, +void *user_data) +{ +struct btp_ase *ase = user_data; +struct btp_device *device = ase->device; +struct btp_adapter *adapter =find_adapter_by_device (device); +uint8_t status =BTP_ERROR_FAIL ; +int sk; +uint16_t rx, tx; +struct l_dbus_message_iter iter; + +if (l_dbus_message_is_error (result)) { +const char *name, *desc; + +l_dbus_message_get_error (result, &name, &desc); +l_error ("Failed to acquire endpoint (%s), %s" , name, desc); + + goto failed; + } + +if (!l_dbus_message_get_arguments (result,"hqq" , &sk, &rx, &tx)) + goto failed; + +ase_change_state (ase,ASE_TRANSPORT_ACQUIRED ); + ase->rx_mtu = rx; + ase->tx_mtu = tx; + ase->io =l_io_new (sk); +if (!ase->io) { +close (sk); + goto failed; + } + +if (ase->dir ==BTP_BAP_DIR_SOURCE ) +l_io_set_read_handler (ase->io, read_cb, ase,NULL ); + +/* Update linked endpoints */ +if (l_dbus_proxy_get_property (ase->transport_proxy,"Links" ,"ao" , + &iter)) { +const char *path; + +while (l_dbus_message_iter_next_entry (&iter, &path)) { +struct btp_ase *l; + + l =l_queue_find (device->ases, match_ase_path, path); +if (l) { + l->rx_mtu = rx; + l->tx_mtu = tx; +if (l->dir ==BTP_BAP_DIR_SOURCE ) +l_io_set_read_handler (ase->io, + read_cb, l,NULL ); +break ; + } + } + } + +return ; + +failed: +btp_send_error (btp,BTP_ASCS_SERVICE , adapter->index, status); +} + +static void btp_ascs_enable (uint8_t index,const void *param, +uint16_t length,void *user_data) +{ +struct btp_adapter *adapter =find_adapter_by_index (index); +const struct btp_ascs_enable_cp *cp = param; +struct btp_ascs_operation_completed_ev ev; +struct btp_device *dev; +struct btp_ase *ase; +uint8_t status =BTP_ERROR_FAIL ; + +if (!adapter) { + status =BTP_ERROR_INVALID_INDEX ; + goto failed; + } + +btp_send (btp,BTP_ASCS_SERVICE ,BTP_OP_ASCS_ENABLE , index,0 ,NULL ); + +memcpy (&ev.address, &cp->address,sizeof (ev.address)); + ev.address_type = cp->address_type; + ev.ase_id = cp->ase_id; + ev.opcode =BTP_OP_ASCS_ENABLE ; + ev.status =0 ; + ev.flags =0 ; + +btp_send (btp,BTP_ASCS_SERVICE ,BTP_EV_ASCS_OPERATION_COMPLETED , + adapter->index,sizeof (ev), &ev); + + dev =find_device_by_address (adapter, &cp->address, cp->address_type); +if (!dev) + goto failed; + + ase =l_queue_find (dev->ases, match_ase,L_UINT_TO_PTR (cp->ase_id)); +if (!ase) + goto failed; + +/* In desync mode, Acquire the transport straight away and defer +* sending the ENABLING state notification until Acquire completes; +* otherwise notify ENABLING immediately. +*/ +if (adapter->desync) { +l_dbus_proxy_method_call (ase->transport_proxy,"Acquire" , +NULL , ascs_acquire_reply, ase,NULL ); +ase_change_state (ase,ASE_TRANSPORT_ACQUIRING ); + }else { +send_state_changed (adapter->index, &cp->address, + cp->address_type, + ase->ase_id, +BT_BAP_STREAM_STATE_ENABLING ); + } + +return ; + +failed: +btp_send_error (btp,BTP_ASCS_SERVICE , index, status); +} + +static void btp_ascs_receiver_start_ready (uint8_t index,const void *param, +uint16_t length,void *user_data) +{ +struct btp_adapter *adapter =find_adapter_by_index (index); +const struct btp_ascs_enable_cp *cp = param; +uint8_t status =BTP_ERROR_FAIL ; + +if (!adapter) { + status =BTP_ERROR_INVALID_INDEX ; + goto failed; + } + +/* Outside desync mode, Acquire the transport on Receiver Start +* Ready; in desync mode it was already Acquired when Enable was +* received. +*/ +if (!adapter->desync) { +struct btp_device *dev; +struct btp_ase *ase; + + dev =find_device_by_address (adapter, &cp->address, + cp->address_type); +if (!dev) + goto failed; + + ase =l_queue_find (dev->ases, match_ase, +L_UINT_TO_PTR (cp->ase_id)); +if (!ase) + goto failed; + +l_dbus_proxy_method_call (ase->transport_proxy,"Acquire" , +NULL , ascs_acquire_reply, ase,NULL ); +ase_change_state (ase,ASE_TRANSPORT_ACQUIRING ); + +if (adapter->desync) +return ; + +send_state_changed (adapter->index, &cp->address, + cp->address_type, + ase->ase_id, +BT_BAP_STREAM_STATE_ENABLING ); + } + +btp_send (btp,BTP_ASCS_SERVICE ,BTP_OP_ASCS_RECEIVER_START_READY , + index,0 ,NULL ); + +return ; + +failed: +btp_send_error (btp,BTP_ASCS_SERVICE , index, status); +} + +static void btp_ascs_add_ase_to_cis (uint8_t index,const void *param, +uint16_t length,void *user_data) +{ +struct btp_adapter *adapter =find_adapter_by_index (index); +struct btp_device *dev; +const struct btp_ascs_add_ase_to_cis_cp *cp = param; +struct btp_ase *ase; +uint8_t status =BTP_ERROR_FAIL ; + +if (!adapter) { + status =BTP_ERROR_INVALID_INDEX ; + goto failed; + } + + dev =find_device_by_address (adapter, &cp->address, cp->address_type); +if (!dev) + goto failed; + + ase =l_queue_find (dev->ases, match_ase,L_UINT_TO_PTR (cp->ase_id)); +if (!ase) + goto failed; + +if (ase->cig_id != cp->cig_id || ase->cis_id != cp->cis_id) { +l_error ("Invalid CIG/CIS ID, expecting %u/%u, got %u/%u" , + ase->cig_id, ase->cis_id, + cp->cig_id, cp->cis_id); + goto failed; + } + +btp_send (btp,BTP_ASCS_SERVICE ,BTP_OP_ASCS_ADD_ASE_TO_CIS , index,0 , +NULL ); + +if (ase->transport_proxy) { +struct btp_ascs_cis_connected_ev ev; + +memcpy (&ev.address, &dev->address,sizeof (ev.address)); + ev.address_type = dev->address_type; + ev.ase_id = ase->ase_id; + ev.cis_id = ase->cis_id; + +btp_send (btp,BTP_ASCS_SERVICE ,BTP_EV_ASCS_CIS_CONNECTED , + adapter->index,sizeof (ev), &ev); + } + +return ; + +failed: +btp_send_error (btp,BTP_ASCS_SERVICE , index, status); +} + +static void btp_ascs_preconfigure_qos (uint8_t index,const void *param, +uint16_t length,void *user_data) +{ +struct btp_adapter *adapter =find_adapter_by_index (index); + +if (!adapter) { +btp_send_error (btp,BTP_ASCS_SERVICE , index, +BTP_ERROR_INVALID_INDEX ); +return ; + } + +btp_send (btp,BTP_ASCS_SERVICE ,BTP_OP_ASCS_PRECONFIGURE_QOS , index,0 , +NULL ); +} +bool ascs_setup (struct btp_adapter *adapter) {bt_uuid_t uuid;
@@ -626,6 +1019,28 @@ static struct l_dbus_message *get_properties_reply(l_dbus_message_builder_enter_variant (builder,"a{sv}" );l_dbus_message_builder_enter_array (builder,"{sv}" ); +if (ase->cig_id !=BT_ISO_QOS_CIG_UNSET ) { +l_dbus_message_builder_enter_dict (builder,"sv" ); +l_dbus_message_builder_append_basic (builder,'s' , +"CIG" ); +l_dbus_message_builder_enter_variant (builder,"y" ); +l_dbus_message_builder_append_basic (builder,'y' , + &ase->cig_id); +l_dbus_message_builder_leave_variant (builder); +l_dbus_message_builder_leave_dict (builder); + } + +if (ase->cis_id !=BT_ISO_QOS_CIS_UNSET ) { +l_dbus_message_builder_enter_dict (builder,"sv" ); +l_dbus_message_builder_append_basic (builder,'s' , +"CIS" ); +l_dbus_message_builder_enter_variant (builder,"y" ); +l_dbus_message_builder_append_basic (builder,'y' , + &ase->cis_id); +l_dbus_message_builder_leave_variant (builder); +l_dbus_message_builder_leave_dict (builder); + } +l_dbus_message_builder_enter_dict (builder,"sv" );l_dbus_message_builder_append_basic (builder,'s' ,"PresentationDelay" );
@@ -815,79 +1230,242 @@ static struct l_dbus_message *find_pending_msg(struct l_queue *l,return NULL ; } +static void set_desync_reply (struct l_dbus_proxy *proxy, +struct l_dbus_message *result,void *user_data) +{ +struct btp_ase *ase = user_data; +struct btp_adapter *adapter; +struct btp_ascs_cis_connected_ev ev; + +if (l_dbus_message_is_error (result)) { +const char *name, *desc; + +l_dbus_message_get_error (result, &name, &desc); +l_error ("Failed to desync Links (%s), %s" , name, desc); +return ; + } + + adapter =find_adapter_by_device (ase->device); +if (!adapter) +return ; + +memcpy (&ev.address, &ase->device->address,sizeof (ev.address)); + ev.address_type = ase->device->address_type; + ev.ase_id = ase->ase_id; + ev.cis_id = ase->cis_id; + +btp_send (btp,BTP_ASCS_SERVICE ,BTP_EV_ASCS_CIS_CONNECTED , + adapter->index,sizeof (ev), &ev); +} + +void ascs_ase_replied (struct btp_adapter *adapter,struct btp_ase *ase) +{ +struct l_dbus_message *msg, *reply; + + msg =find_pending_msg (pending_select_properties, ase); +if (msg) { +l_queue_remove (pending_select_properties, msg); + reply =get_properties_reply (msg, adapter, ase); +l_dbus_send (dbus, reply); + +l_dbus_message_unref (msg); + } +} + +static bool transport_get_cig_cis (struct l_dbus_proxy *proxy,uint8_t *cig, +uint8_t *cis) +{ +struct l_dbus_message_iter iter, var; +const char *key; + + *cig =BT_ISO_QOS_CIG_UNSET ; + *cis =BT_ISO_QOS_CIS_UNSET ; + +if (!l_dbus_proxy_get_property (proxy,"QoS" ,"a{sv}" , &iter)) +return false; + +while (l_dbus_message_iter_next_entry (&iter, &key, &var)) { +if (!strcmp (key,"CIG" )) { +if (!l_dbus_message_iter_get_variant (&var,"y" , cig)) +return false; + } + +if (!strcmp (key,"CIS" )) { +if (!l_dbus_message_iter_get_variant (&var,"y" , cis)) +return false; + } + } + +return true; +} + +void ascs_proxy_added (struct l_dbus_proxy *proxy,void *user_data) +{ +char *str, *state; +struct btp_device *device = user_data; +struct btp_adapter *adapter; +uint8_t dir; +uint8_t cig =BT_ISO_QOS_CIG_UNSET , cis =BT_ISO_QOS_CIS_UNSET ; +struct btp_ase *ase; + + adapter =find_adapter_by_device (device); +if (!adapter) +return ; + +if (!l_dbus_proxy_get_property (proxy,"UUID" ,"s" , &str)) +return ; + +if (!l_dbus_proxy_get_property (proxy,"State" ,"s" , &state)) +return ; + +if (!bt_uuid_strcmp (str,PAC_SINK_UUID )) + dir =BTP_BAP_DIR_SOURCE ; +else + dir =BTP_BAP_DIR_SINK ; + +if (!transport_get_cig_cis (proxy, &cig, &cis)) +return ; + + ase =find_ase (device, cig, cis, dir); +if (!ase) +return ; + + ase->transport_proxy = proxy; + +/* In desync mode, the CIS_CONNECTED event is sent later, once the +* "Desynchronized" property has been set (see set_desync_reply()); +* otherwise send it now. +*/ +if (!adapter->desync) { +struct btp_ascs_cis_connected_ev ev; + +memcpy (&ev.address, &device->address,sizeof (ev.address)); + ev.address_type = device->address_type; + ev.ase_id = ase->ase_id; + ev.cis_id = ase->cis_id; + +btp_send (btp,BTP_ASCS_SERVICE ,BTP_EV_ASCS_CIS_CONNECTED , + adapter->index,sizeof (ev), &ev); + } + +if (ase->transport_state ==ASE_TRANSPORT_ACQUIRING && + !strcmp (state,"idle" )) { +l_dbus_proxy_method_call (proxy,"Acquire" , +NULL , + ascs_acquire_reply, + ase,NULL ); + } +} +void ascs_property_changed (struct l_dbus_proxy *proxy,const char *name,struct l_dbus_message *msg,void *user_data) {const char *interface =l_dbus_proxy_get_interface (proxy); -if (!strcmp (interface,"org.bluez.GattCharacteristic1" )) { -char *uuid, *str; -struct btp_device *device; -struct btp_adapter *adapter; -struct btp_ase *ase; -struct l_dbus_message_iter iter; -uint8_t *data; -uint32_t n; -const struct l_queue_entry *entry; -struct l_dbus_message *reply; +if (!strcmp (interface,"org.bluez.MediaTransport1" )) { +if (!strcmp (name,"State" )) { +const char *state, *path, *uuid; +struct btp_device *dev; +struct btp_adapter *adapter; +uint8_t dir, cig, cis; +struct btp_ase *ase; +uint8_t ase_state; -if (strcmp (name,"Value" )) -return ; +if (!l_dbus_message_get_arguments (msg,"s" , &state)) +return ; -if (!l_dbus_proxy_get_property (proxy,"UUID" ,"s" , &uuid)) -return ; +if (!l_dbus_proxy_get_property (proxy,"Device" ,"o" , + &path)) +return ; -if (!l_dbus_proxy_get_property (proxy,"Service" ,"o" , &str)) -return ; + dev =find_device_by_path (path); +if (!dev) +return ; - device =find_device_by_service_path (str); -if (!device) -return ; + adapter =find_adapter_by_device (dev); +if (!adapter) +return ; - adapter =find_adapter_by_device (device); -if (!adapter) -return ; +if (!l_dbus_proxy_get_property (proxy,"UUID" ,"s" , + &uuid)) +return ; - ase =find_ase_by_uuid (device, uuid); -if (!ase) -return ; +if (!bt_uuid_strcmp (uuid,PAC_SINK_UUID )) + dir =BTP_BAP_DIR_SOURCE ; +else + dir =BTP_BAP_DIR_SINK ; -if (!l_dbus_message_get_arguments (msg,"ay" , &iter)) -return ; +if (!transport_get_cig_cis (proxy, &cig, &cis)) +return ; -if (!l_dbus_message_iter_get_fixed_array (&iter, &data, &n)) { -l_debug ("Cannot read value" ); -return ; + ase =find_ase (dev, cig, cis, dir); +if (!ase) +return ; + +if (!strcmp (state,"active" )) + ase_state =BT_BAP_STREAM_STATE_STREAMING ; +else { +if (ase->io) { +l_io_destroy (ase->io); + ase->io =NULL ; + } + + ase_state =BT_BAP_STREAM_STATE_IDLE ; + } + +send_state_changed (adapter->index, &dev->address, + dev->address_type, + ase->ase_id, + ase_state); } - ase->ase_id = data[0 ]; +if (!strcmp (name,"Desynchronized" )) { +struct btp_device *dev; +struct btp_adapter *adapter; +const bool desynchronized; +const char *path, *uuid; +uint8_t dir, cig, cis; +struct btp_ase *ase; -for (entry =l_queue_get_entries (device->endpoints); entry; - entry = entry->next) { -struct l_dbus_proxy *p = entry->data; -const char *str, *pac_uuid; +if (!l_dbus_message_get_arguments (msg,"b" , + &desynchronized)) +return ; -if (!l_dbus_proxy_get_property (p,"UUID" ,"s" , &str)) -continue ; +if (!l_dbus_proxy_get_property (proxy,"Device" ,"o" , + &path)) +return ; + + dev =find_device_by_path (path); +if (!dev) +return ; + + adapter =find_adapter_by_device (dev); +if (!adapter || !adapter->desync) +return ; + +if (!l_dbus_proxy_get_property (proxy,"UUID" ,"s" , + &uuid)) +return ; -if (bt_uuid16_cmp (&ase->uuid,ASE_SINK_UUID )) - pac_uuid =PAC_SINK_UUID ; +if (!bt_uuid_strcmp (uuid,PAC_SINK_UUID )) + dir =BTP_BAP_DIR_SOURCE ;else - pac_uuid =PAC_SOURCE_UUID ; + dir =BTP_BAP_DIR_SINK ; -if (!strcmp (str, pac_uuid)) { - ase->ep_proxy = p; -break ; - } - } +if (!transport_get_cig_cis (proxy, &cig, &cis)) +return ; - msg =find_pending_msg (pending_select_properties, ase); -if (msg) { -l_queue_remove (pending_select_properties, msg); - reply =get_properties_reply (msg, adapter, ase); -l_dbus_send (dbus, reply); + ase =find_ase (dev, cig, cis, dir); +if (!ase) +return ; -l_dbus_message_unref (msg); +if (!desynchronized) { +l_dbus_proxy_set_property (proxy, + set_desync_reply, + ase,NULL , +"Desynchronized" ,"b" , + true); + } } } }
@@ -905,6 +1483,22 @@ bool ascs_register_service(struct btp *btp_, struct l_dbus *dbus_,btp_register (btp,BTP_ASCS_SERVICE ,BTP_OP_ASCS_CONFIGURE_CODEC , btp_ascs_configure_codec,NULL ,NULL ); +btp_register (btp,BTP_ASCS_SERVICE ,BTP_OP_ASCS_CONFIGURE_QOS , + btp_ascs_configure_qos,NULL ,NULL ); + +btp_register (btp,BTP_ASCS_SERVICE ,BTP_OP_ASCS_ENABLE , + btp_ascs_enable,NULL ,NULL ); + +btp_register (btp,BTP_ASCS_SERVICE ,BTP_OP_ASCS_RECEIVER_START_READY , + btp_ascs_receiver_start_ready, +NULL ,NULL ); + +btp_register (btp,BTP_ASCS_SERVICE ,BTP_OP_ASCS_ADD_ASE_TO_CIS , + btp_ascs_add_ase_to_cis,NULL ,NULL ); + +btp_register (btp,BTP_ASCS_SERVICE ,BTP_OP_ASCS_PRECONFIGURE_QOS , + btp_ascs_preconfigure_qos,NULL ,NULL ); +if (!l_dbus_register_interface (dbus,ENDPOINT_IFACE , setup_endpoint_interface,NULL , false)) {
client/btpclient/ascs.h +3 -0
@@ -14,5 +14,8 @@ bool ascs_is_service_registered(void);bool ascs_setup (struct btp_adapter *adapter); +void ascs_proxy_added (struct l_dbus_proxy *proxy,void *user_data);void ascs_property_changed (struct l_dbus_proxy *proxy,const char *name,struct l_dbus_message *msg,void *user_data); + +void ascs_ase_replied (struct btp_adapter *adapter,struct btp_ase *ase);
client/btpclient/bap.c +104 -3
157 lines not on this page · raw message
client/btpclient/btpclient.c +35 -0
@@ -230,6 +230,26 @@ struct btp_device *find_device_by_proxy(struct l_dbus_proxy *proxy)return NULL ; } +static bool match_cigcisdir (const void *entry,const void *data) +{ +const struct btp_ase *ase = entry; +uint32_t cigcisdir =L_PTR_TO_UINT (data); +uint8_t cig = cigcisdir &0xFF ; +uint8_t cis = (cigcisdir >>8 ) &0xFF ; +uint8_t dir = (cigcisdir >>16 ) &0xFF ; + +return ase->cig_id == cig && ase->cis_id == cis && ase->dir == dir; +} + +struct btp_ase *find_ase (struct btp_device *device,uint8_t cig,uint8_t cis, +uint8_t dir) +{ +uint32_t cigcisdir = cig + (cis <<8 ) + (dir <<16 ); + +return l_queue_find (device->ases, match_cigcisdir, +L_UINT_TO_PTR (cigcisdir)); +} +static bool match_uuid (const void *entry,const void *data) {const struct btp_ase *ase = entry;
@@ -633,6 +653,21 @@ static void proxy_added(struct l_dbus_proxy *proxy, void *user_data)return ; } + +if (!strcmp (interface,"org.bluez.MediaTransport1" )) { +char *str; +struct btp_device *device; + +if (!l_dbus_proxy_get_property (proxy,"Device" ,"o" , &str)) +return ; + + device =find_device_by_path (str); +if (!device) +return ; + +if (ascs_is_service_registered ()) +ascs_proxy_added (proxy, device); + } }static bool device_match_by_proxy (const void *a,const void *b)
client/btpclient/btpclient.h +16 -0
@@ -23,6 +23,7 @@ struct btp_adapter {uint32_t source_locations;uint8_t target_latency; +bool desync; };struct btp_device {
@@ -36,12 +37,25 @@ struct btp_device {struct l_queue *endpoints; }; +enum ase_transport_state { +ASE_TRANSPORT_READY =0 , +ASE_TRANSPORT_ACQUIRING , +ASE_TRANSPORT_ACQUIRED , +}; +struct btp_ase {struct btp_device *device;bt_uuid_t uuid;uint8_t dir;uint8_t ase_id; +uint8_t cig_id; +uint8_t cis_id;struct l_dbus_proxy *ep_proxy; +struct l_dbus_proxy *transport_proxy; +enum ase_transport_state transport_state; +struct l_io *io; +uint16_t rx_mtu; +uint16_t tx_mtu; };struct btp_agent {
@@ -67,6 +81,8 @@ struct btp_device *find_device_by_path(const char *path);struct btp_adapter *find_adapter_by_device (struct btp_device *device);struct btp_device *find_device_by_proxy (struct l_dbus_proxy *proxy);struct btp_device *find_device_by_service_path (const char *path); +struct btp_ase *find_ase (struct btp_device *device,uint8_t cig,uint8_t cis, +uint8_t dir);struct btp_ase *find_ase_by_uuid (struct btp_device *device,char *uuid);struct btp_agent *get_agent (void );
client/btpclient/vendor.c +1 -0
@@ -65,6 +65,7 @@ static void btp_vendor_ascs_setup(uint8_t index, const void *param,const struct btp_vendor_ascs_setup_cp *cp = param; adapter->target_latency = cp->target_latency; + adapter->desync = cp->desync;ascs_setup (adapter);
src/shared/btp.h +68 -0
91 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 7/8 client/btpclient: Defer CIG/CIS assignment based on Client/Server role
In reply to Frédéric DanisPreviously, CIG/CIS ids were eagerly assigned to each ASE as soon as it was discovered (CIG 0, next available CIS), regardless of whether the btpclient was acting as the Unicast Client or Server for that ASE. This did not match how CIG/CIS ids are actually negotiated, nor what auto-pts expects: unicast client tests expect CIG/CIS to start at 0/0, while unicast server tests expect them to start at 1/1.
- As Unicast Client, the CIG/CIS ids are chosen locally when building the QoS properties returned from SelectProperties(), starting at 0.
- As Unicast Server, the CIG/CIS ids are only known once the transport reports them; if not yet available, all of the device's ASEs should share a common CIG (1) with CIS ids starting at 1 as well.
Move get_next_cis() from bap.c to ascs.c and extend it to take a base CIS value, so it can be reused both for the Client and Server code paths (base 0 and base 1 respectively) and skips ASEs whose CIS id is still unset. Leave ase->cig_id and ase->cis_id unset (BT_ISO_QOS_CIG_UNSET/BT_ISO_QOS_CIS_UNSET) at ASE discovery time, and resolve them lazily:
- In get_properties_reply(), assign CIG 0 and the next CIS starting at 0 when building the QoS reply for SelectProperties() (Client role).
- In ascs_proxy_added(), when the transport does not yet report a CIG/CIS, assign CIG 1 to all of the device's ASEs and derive CIS ids starting at 1 via the new set_cig_cis()/set_cig_cis_data helpers (Server role).
--- client/btpclient/ascs.c | 144 ++++++++++++++++++++++++++++++++++------ client/btpclient/bap.c | 74 ++------------------- 2 files changed, 127 insertions(+), 91 deletions(-)
client/btpclient/ascs.c +123 -21
@@ -918,6 +918,76 @@ static void ltv_find(size_t i, uint8_t l, uint8_t t, uint8_t *v, *found = true; } +static uint8_t get_next_cis (struct btp_device *device,uint8_t dir, +uint8_t base) +{ +const struct l_queue_entry *adapter_entry; +const struct l_queue_entry *ase_entry; +uint8_t cis = base; +bool found = false; + +/* For the same device, reuse the opposite cis_id if there is no ASE +* in the requested direction already using that same cis_id +*/ +for (ase_entry =l_queue_get_entries (device->ases); ase_entry; + ase_entry = ase_entry->next) { +struct btp_ase *ase = ase_entry->data; +const struct l_queue_entry *entry; +bool has_same_dir = false; + +if (ase->dir == dir) +continue ; + +for (entry =l_queue_get_entries (device->ases); entry; + entry = entry->next) { +struct btp_ase *peer = entry->data; + +if (peer->dir == dir && peer->cis_id == ase->cis_id) { + has_same_dir = true; +break ; + } + } + +if (!has_same_dir) +return ase->cis_id; + } + +/* Else returns the global highest cis_id + 1 across all ASEs of all +* devices, or 'base' if none has already been assigned +*/ +for (adapter_entry =l_queue_get_entries (get_adapters_list ()); + adapter_entry; + adapter_entry = adapter_entry->next) { +struct btp_adapter *adapter = adapter_entry->data; +const struct l_queue_entry *device_entry; + +for (device_entry =l_queue_get_entries (adapter->devices); + device_entry; + device_entry = device_entry->next) { +struct btp_device *dev = device_entry->data; + +for (ase_entry =l_queue_get_entries (dev->ases); + ase_entry; + ase_entry = ase_entry->next) { +struct btp_ase *ase = ase_entry->data; + +if (ase->cis_id ==BT_ISO_QOS_CIS_UNSET ) +continue ; + +if (!found || ase->cis_id > cis) + cis = ase->cis_id; + + found = true; + } + } + } + +if (!found) +return cis; + +return cis +1 ; +} + static struct l_dbus_message *get_properties_reply( struct l_dbus_message *message, struct btp_adapter *adapter,
@@ -1019,27 +1089,31 @@ static struct l_dbus_message *get_properties_reply(l_dbus_message_builder_enter_variant (builder,"a{sv}" );l_dbus_message_builder_enter_array (builder,"{sv}" ); -if (ase->cig_id !=BT_ISO_QOS_CIG_UNSET ) { -l_dbus_message_builder_enter_dict (builder,"sv" ); -l_dbus_message_builder_append_basic (builder,'s' , -"CIG" ); -l_dbus_message_builder_enter_variant (builder,"y" ); -l_dbus_message_builder_append_basic (builder,'y' , - &ase->cig_id); -l_dbus_message_builder_leave_variant (builder); -l_dbus_message_builder_leave_dict (builder); - } +/* SelectProperties() is only invoked when acting as the Unicast Client, +* so assign CIG 0 here and pick the next available CIS for this ASE. +*/ +if (ase->cig_id ==BT_ISO_QOS_CIG_UNSET ) + ase->cig_id =0 ; +if (ase->cis_id ==BT_ISO_QOS_CIS_UNSET ) + ase->cis_id =get_next_cis (ase->device, ase->dir,0 ); -if (ase->cis_id !=BT_ISO_QOS_CIS_UNSET ) { -l_dbus_message_builder_enter_dict (builder,"sv" ); -l_dbus_message_builder_append_basic (builder,'s' , -"CIS" ); -l_dbus_message_builder_enter_variant (builder,"y" ); -l_dbus_message_builder_append_basic (builder,'y' , - &ase->cis_id); -l_dbus_message_builder_leave_variant (builder); -l_dbus_message_builder_leave_dict (builder); - } +l_dbus_message_builder_enter_dict (builder,"sv" ); +l_dbus_message_builder_append_basic (builder,'s' , +"CIG" ); +l_dbus_message_builder_enter_variant (builder,"y" ); +l_dbus_message_builder_append_basic (builder,'y' , + &ase->cig_id); +l_dbus_message_builder_leave_variant (builder); +l_dbus_message_builder_leave_dict (builder); + +l_dbus_message_builder_enter_dict (builder,"sv" ); +l_dbus_message_builder_append_basic (builder,'s' , +"CIS" ); +l_dbus_message_builder_enter_variant (builder,"y" ); +l_dbus_message_builder_append_basic (builder,'y' , + &ase->cis_id); +l_dbus_message_builder_leave_variant (builder); +l_dbus_message_builder_leave_dict (builder);l_dbus_message_builder_enter_dict (builder,"sv" ); l_dbus_message_builder_append_basic(builder, 's',
@@ -1299,6 +1373,24 @@ static bool transport_get_cig_cis(struct l_dbus_proxy *proxy, uint8_t *cig,return true; } +struct set_cig_cis_data { +struct btp_device *device; +uint8_t cig; +}; + +static void set_cig_cis (void *data,void *user_data) +{ +struct btp_ase *ase = data; +struct set_cig_cis_data *param = user_data; +uint8_t cis =get_next_cis (param->device, ase->dir,1 ); + +if (ase->cig_id !=BT_ISO_QOS_CIG_UNSET ) +return ; + + ase->cig_id = param->cig; + ase->cis_id = cis; +} +void ascs_proxy_added (struct l_dbus_proxy *proxy,void *user_data) {char *str, *state;
@@ -1323,8 +1415,18 @@ void ascs_proxy_added(struct l_dbus_proxy *proxy, void *user_data)else dir =BTP_BAP_DIR_SINK ; -if (!transport_get_cig_cis (proxy, &cig, &cis)) +if (!transport_get_cig_cis (proxy, &cig, &cis)) { +struct set_cig_cis_data data; + +/* No CIG/CIS reported on the transport yet, meaning this ASE +* is acting as the Unicast Server: assign CIG 1 to all of the +* device's ASEs and let set_cig_cis() derive their CIS ids. +*/ + data.device = device; + data.cig =1 ; +l_queue_foreach (device->ases, set_cig_cis, &data);return ; + } ase =find_ase (device, cig, cis, dir);if (!ase)
client/btpclient/bap.c +4 -70
92 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 8/8 client/btpclient: Add stream auto acquire for BAP/USR/STR/* tests
In reply to Frédéric DanisThe sink stream should be auto acquired and data sent on it.
--- client/btpclient/ascs.c | 10 +++- client/btpclient/bap.c | 108 +++++++++++++++++++++++++++++++++++ client/btpclient/bap.h | 2 + client/btpclient/btpclient.c | 68 ++++++++++++++++++++++ client/btpclient/btpclient.h | 2 + 5 files changed, 189 insertions(+), 1 deletion(-)
client/btpclient/ascs.c +9 -1
@@ -1506,7 +1506,15 @@ void ascs_property_changed(struct l_dbus_proxy *proxy, const char *name,if (!strcmp (state,"active" )) ase_state =BT_BAP_STREAM_STATE_STREAMING ; -else { +else if (!strcmp (state,"pending" ) && + ase->transport_state ==ASE_TRANSPORT_READY ) { +l_dbus_proxy_method_call (proxy,"Acquire" , +NULL , + ascs_acquire_reply, + ase,NULL ); +ase_change_state (ase,ASE_TRANSPORT_ACQUIRING ); + ase_state =BT_BAP_STREAM_STATE_ENABLING ; + }else {if (ase->io) {l_io_destroy (ase->io); ase->io =NULL ;
client/btpclient/bap.c +108 -0
114 lines not on this page · raw message
client/btpclient/bap.h +2 -0
@@ -13,3 +13,5 @@ void bap_unregister_service(struct btp *btp);bool bap_is_service_registered (void );void bap_proxy_added (struct l_dbus_proxy *proxy,void *user_data); +void bap_property_changed (struct l_dbus_proxy *proxy,const char *name, +struct l_dbus_message *msg,void *user_data);
client/btpclient/btpclient.c +68 -0
85 lines not on this page · raw message
client/btpclient/btpclient.h +2 -0
@@ -56,6 +56,8 @@ struct btp_ase {struct l_io *io;uint16_t rx_mtu;uint16_t tx_mtu; +bool auto_send; +struct l_idle *idle_writer; };struct btp_agent {
Signature · 1 line
2.43.0