nrf5340 audio broadcast sink sync fail when connecting with app through BLE

Hello,

I'm using an NRF5340 audio broadcast sink, and the nRF Connect SDK version is v3.4.0.

I've added ble connection related definitions to the code to allow the mobile app to connect to the NRF5340 audio broadcast sink via BLE.

CONFIG_APP_CONTROL=y
CONFIG_BT_GATT_DYNAMIC_DB=y
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_ATT_PREPARE_COUNT=3
CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION=n
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n
CONFIG_BLE_ACL_SUP_TIMEOUT=0
CONFIG_BT_MAX_CONN=2

During testing, I found that when connected to the app through ble, the broadcast sink cannot sync with the broadcast source, and occurring "invalid parameter error."

Here is the error log.

rtt:~$ ASSERTION FAIL [attr] @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/gatt.c:3343
        invalid parameter

HS [00:00:23.684,265] <inf> bt_mgmt_scan: Broadcast source NRF5340_BROADCASTER found, id: 0xdffe3d
HS [00:00:23.841,583] <inf> bt_mgmt_scan: PA synced to name: NRF5340_BROADCASTER, id: 0xdffe3d, addr: 00:02:5B:00:FF:03 (public)
HS [00:00:23.847,137] <err> error_handler: Assert post action: file: WEST_TOPDIR/zephyr/subsys/bluetooth/host/gatt.c, line 3343
HS [00:00:23.847,167] <err> error_handler: Caught system error -- reason 0. Entering infinite loop
rtt:~$ 

However, if not connected to the app through ble, the broadcast sink can successfully sync with the broadcast source, but after syncing, it cannot connect to the app through ble.

I previously used nRF Connect SDK v2.2.0 to achieve the same functionality without this problem. How can I modify the code to allow the v3.4.0 broadcast sink to simultaneously sync with the source and connect to the app through ble?

Parents
  • Hello, 

    The log shows that the assert is raised here because the "attr" pointer is NULL: https://github.com/nrfconnect/sdk-zephyr/blob/bf801e4e3d19e1ffa76164346480cb7734dd2800/subsys/bluetooth/host/gatt.c#L3343 but it doesn't show where bt_gatt_is_subscribed() is being called from, do you know? Also, do you get the same error if you keep CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION enabled?

    Best regards,

    Vidar

  • Thank you for your reply.

    Now I've added `CONFIG_BT_MAX_CONN` to both `prj.conf` and `overlay-broadcast_sink.conf`. Without connecting to the app via BLE, the broadcast sink can sync with the broadcast source, and after synchronization, it can connect to the app via BLE. However, if it connects to the app via BLE first, it still cannot synchronize with the broadcast source.

    In short, currently, synchronizing with the broadcast source first and then connecting to the app via BLE succeeds, but connecting to the app via BLE first and then synchronizing with the broadcast source causes problems.

    where bt_gatt_is_subscribed() is being called from, do you know?

    `bt_gatt_is_subscribed` is called from `set_receive_state_changed_cb` in bap_scan_delegator.c.

    Also, do you get the same error if you keep CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION enabled?

    If `CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION` is enabled, BLE read/write operations after connecting to the app via BLE will have problems, so I'm not considering enabling it.

  • Thanks, knowing that the call is made from set_receive_state_changed_cb() helps narrow down the problem. I will check with the developers who are more familiar with this codebase to get their thoughts. In the meantime, you could try skipping notifications when the attr pointer is NULL.

    static void set_receive_state_changed_cb(struct bt_conn *conn, void *data)
    {
    	struct bass_recv_state_internal *internal_state = data;
    	struct bass_recv_state_flags *flags = &internal_state->flags[bt_conn_index(conn)];
    	struct bt_conn_info conn_info;
    	int err;
    	
    	if (internal_state->attr == NULL) {
    		return;
    	}
    	...

Reply
  • Thanks, knowing that the call is made from set_receive_state_changed_cb() helps narrow down the problem. I will check with the developers who are more familiar with this codebase to get their thoughts. In the meantime, you could try skipping notifications when the attr pointer is NULL.

    static void set_receive_state_changed_cb(struct bt_conn *conn, void *data)
    {
    	struct bass_recv_state_internal *internal_state = data;
    	struct bass_recv_state_flags *flags = &internal_state->flags[bt_conn_index(conn)];
    	struct bt_conn_info conn_info;
    	int err;
    	
    	if (internal_state->attr == NULL) {
    		return;
    	}
    	...

Children
Related