Add peripheral support with BIS enabled.

Hi,

I am currently working with the nRF5340 Audio DKs and have successfully implemented the gateway and handset functionalities.

Now, I want to extend the system by enabling the peripheral role and GATT services to modify the broadcast information.

I've attempted to configure this by adjusting the relevant settings and connection intervals, but I haven't had success so far.

Additionally, when I connect the device to my S23, it seems to time out easily.

uart:~$ GW [00:01:02.533,172] <inf> bt_mgmt: Disconnected: 7B:5D:3B:CA:42:69 (random) (reason 0x13)
GW [00:01:02.533,203] <wrn> main: Unexpected/unhandled bt_mgmt event: 6
GW [00:01:02.533,233] <inf> main: advertising for config
GW [00:01:02.533,172] <inf> bt_mgmt: Disconnected: 7B:5D:3B:CA:42:69 (random) (reason 0x13)
GW [00:01:02.533,203] <wrn> main: Unexpected/unhandled bt_mgmt event: 6
GW [00:01:02.533,233] <inf> main: advertising for config
uart:~$ GW [00:01:04.993,286] <inf> bt_mgmt: Connected: 55:4D:60:32:5D:45 (random)
GW [00:01:04.993,316] <wrn> main: Unexpected/unhandled bt_mgmt event: 2
GW [00:01:04.993,377] <inf> main: Request conn param min=200 max=200
GW [00:01:04.993,469] <inf> main: Connected 55:4D:60:32:5D:45 (random)
GW [00:01:04.993,286] <inf> bt_mgmt: Connected: 55:4D:60:32:5D:45 (random)
GW [00:01:04.993,316] <wrn> main: Unexpected/unhandled bt_mgmt event: 2
GW [00:01:04.993,377] <inf> main: Request conn param min=200 max=200
GW [00:01:04.993,469] <inf> main: Connected 55:4D:60:32:5D:45 (random)
uart:~$ GW [00:01:10.293,090] <inf> main: updated: interval=200 latency=2, timeout=400
GW [00:01:10.293,090] <inf> main: updated: interval=200 latency=2, timeout=400
uart:~$ GW [00:01:14.030,578] <inf> bt_mgmt: Disconnected: 55:4D:60:32:5D:45 (random) (reason 0x08)
GW [00:01:14.030,609] <wrn> main: Unexpected/unhandled bt_mgmt event: 6
GW [00:01:14.030,700] <inf> main: advertising for config
GW [00:01:14.030,578] <inf> bt_mgmt: Disconnected: 55:4D:60:32:5D:45 (random) (reason 0x08)
GW [00:01:14.030,609] <wrn> main: Unexpected/unhandled bt_mgmt event: 6
GW [00:01:14.030,700] <inf> main: advertising for config
uart:~$

Your assistance would be greatly appreciated.

Thank you.

---

Here is my board and SDK information:

Board: nRF5340 Audio DK

SDK: nRF Connect SDK v2.7.0

Application: nrf/applications/nrf5340_audio

1464.diff_based_on_v2.7.0.patch

Parents Reply Children
  • #include <zephyr/kernel.h>
    #include <zephyr/bluetooth/bluetooth.h>
    #include <zephyr/zbus/zbus.h>
    
    #include "broadcast_source.h"
    #include "config.h"
    
    #include <zephyr/logging/log.h>
    LOG_MODULE_DECLARE(main, CONFIG_MAIN_LOG_LEVEL);
    
    ZBUS_CHAN_DECLARE(bt_mgmt_chan);
    
    static struct k_work adv_work;
    
    #define DEVICE_NAME	"BROADCASTER_CONFIG"
    #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1)
    
    struct bt_le_adv_param adv_param = {
    	.id = BT_ID_DEFAULT,
    	.sid = 0U,
    	.secondary_max_skip = 0U,
    	.options = (BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_CONNECTABLE),
    	.interval_min = BT_GAP_ADV_FAST_INT_MIN_2,
    	.interval_max = BT_GAP_ADV_FAST_INT_MAX_2,
    	.peer = NULL,
    };
    struct bt_le_ext_adv *adv;
    
    static const struct bt_data ad[] = {
    	BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
    	BT_DATA(BT_DATA_NAME_SHORTENED, DEVICE_NAME, DEVICE_NAME_LEN),
    };
    
    static void advertising_process(struct k_work *work)
    {
    	int err;
    
    	LOG_INF("advertising for config");
    
    	err = bt_le_ext_adv_start(adv, BT_LE_EXT_ADV_START_DEFAULT);
    	if (err) {
    		printk("Failed to set advertising data (err %d)\n", err);
    	}
    }
    
    static void connected_cb(struct bt_conn *conn, uint8_t err)
    {
    	char addr[BT_ADDR_LE_STR_LEN];
    	int ret;
    
    	struct bt_le_conn_param param = {
    		.interval_min = 200,
    		.interval_max = 200,
    		.latency = 2,
    		.timeout = 400,
    	};
    
    	LOG_INF("Request conn param min=%d max=%d", param.interval_min, param.interval_max);
    
    	ret = bt_conn_le_param_update(conn, &param);
    	if (ret != 0) {
    		LOG_ERR("conn param update failed (%d)", ret);
    	}
    
    	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
    	LOG_INF("Connected %s", addr);
    }
    
    static void disconnected_cb(struct bt_conn *conn, uint8_t err)
    
    {
    	k_work_submit(&adv_work);
    }
    
    static void le_param_updated_cb(struct bt_conn *conn, uint16_t interval, uint16_t latency,
    				uint16_t timeout)
    {
    	char addr[BT_ADDR_LE_STR_LEN];
    
    	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
    
    	LOG_INF("updated: interval=%hu latency=%hu, timeout=%hu", interval, latency, timeout);
    }
    
    BT_CONN_CB_DEFINE(conn_callbacks) = {
    	.connected = connected_cb,
    	.disconnected = disconnected_cb,
    	.le_param_updated = le_param_updated_cb,
    };
    
    int bt_config_adv_start(void)
    {
    	int err;
    
    	err = bt_le_ext_adv_create(BT_LE_ADV_CONN, NULL, &adv);
    	if (err) {
    		printk("Failed to create advertising set (err %d)\n", err);
    	}
    
    	err = bt_le_ext_adv_set_data(adv, ad, ARRAY_SIZE(ad), NULL, 0);
    	if (err) {
    		printk("Failed to set advertising data (err %d)\n", err);
    	}
    
    	err = bt_le_ext_adv_start(adv, BT_LE_EXT_ADV_START_DEFAULT);
    	if (err) {
    		printk("Failed to set advertising data (err %d)\n", err);
    	}
    
    	k_work_init(&adv_work, advertising_process);
    
    	return 0;
    }
    
    3527.config.h

    Hi Maira, sorry. I miss these two files.

    Thanks for your assistance.

  • Hi Maria,

    Is there any update?

    Best regards,

    Jimmy

  • Hi Jimmy,

    My apologies for the wait here. 

    Are you still experiencing this issue?

    Best regards,

    Maria

  • Hi Maria,

    Sorry, I haven’t tried that with nRF Connect SDK v2.9.0 yet.

    I'll try it once I have time.

    Thanks for your reply.

    Best regards,
    Jimmy

Related