Problem encoding and advertising the BT_UUID_NUS_VAL

Hi. I am working on a project trying to encode the BT_UUID_NUS_VAL into advertising packets without success. 

In am using the unicast_server.c file as a reference. There there is the following : 

static uint8_t unicast_server_adv_data[] = {
	BT_UUID_16_ENCODE(BT_UUID_ASCS_VAL),
	BT_AUDIO_UNICAST_ANNOUNCEMENT_TARGETED,
	BT_BYTES_LIST_LE16(AVAILABLE_SINK_CONTEXT),
	BT_BYTES_LIST_LE16(AVAILABLE_SOURCE_CONTEXT),
	0x00, /* Metadata length */
};

This advertises fine as expected. However, instead of advertising BT_UUID_ASCS_VAL which has a simple value of 0x1853, I would like to advertise BT_UUID_NUS_VAL. The problem is that this has a large value of 6e400001-b5a3-f393-e0a9-e50e24dcca9e. 

I tried the following without success :  

static uint8_t unicast_server_adv_data[] = {
	BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
	BT_AUDIO_UNICAST_ANNOUNCEMENT_TARGETED,
	BT_BYTES_LIST_LE16(AVAILABLE_SINK_CONTEXT),
	BT_BYTES_LIST_LE16(AVAILABLE_SOURCE_CONTEXT),
	0x00, /* Metadata length */
};

How could I go about possibly solving this? Thank you in advance.

  •  Sorry for the delay. I'm just back at work now. 

    The problem with using bt_le_adv_start() is that the application sometimes crashes when the receiver disconnects from the central device reporting no valid advertising data.

    It became clear that I needed to call bt_mgmt_adv_start() initially. When bt_mgmt_adv_start() is used, the advertising_process() function gets invoked eventually which uses extended_adv_create() and bt_le_ext_adv_start(). This must use a struct like the unicast_server_adv_data above for containing the advertising data data. 

    How have you set the advertising type and UUID type in your project?

    How do I ? I'm not really sure. Here is how the BT_DATA_BYTES is used in the Peripheral UART sample, but when using bt_le_adv_start(). 

    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_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),
    };
    
    static const struct bt_data sd[] = {
    	BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
    };

  • Hi again Sam

    I don't see how an application crashing when the receiver disconnects (already in a connection) would be because of the advertising data. What error exactly is causing this disconnect, do you have an error log to show?

    Can you confirm you're trying to develop for the Audio application or not, since this bt_mgmt_adv_start() function is specifically made for ACL connections in the LE audio application. If not bt_mgmt_adv_start() won't be the correct call to use here. I will need to ask the devs about if it's possible to use bt_mgmt_adv_start() with 128 bit UUIDs as I haven't been able to find a way on my own unfortunately.

    Best regards,

    Simon

  • Hi. I am trying to develop for the audio application. 

    The crashing problem was also reported here when just using bt_le_adv_start() without bt_mgmt_adv_start()  :  

    (1) Audio application - No valid advertising data stored - Nordic Q&A - Nordic DevZone - Nordic DevZone (nordicsemi.com)

     

  • Hi

    I've been discussing this issue with a colleague that is more into the LE audio stack than me, and we would like to see if you can recreate this issue using the SoftDevice controller (SDC)as well, just to confirm this doesn't have something to do with the packetcraft controller specifically, so here are some steps you can try:

    1. Checkout the latest NCS main, since the SDC with ISO is merged after NCS 2.5.0, and also some modification are needed for applications to run with the SDC. This PR brings ISO onto the SDC, and this one updates buildprog.py for switching between SDC and PCFT.
    2. For using buildprog.py, add the command --ctlr="SDC" in the end. E.g., $ python buildprog.py -c both -b debug -d both -p --pristine--ctlr="SDC"
    3. For using west, we need to add -DCONFIG_BT_LL_ACS_NRF53=n
      E.g., $ west build -b nrf5340_audio_dk_nrf5340_cpuapp -d build_headset -p -- -DCONFIG_AUDIO_DEV=1 -DCONFIG_BT_LL_ACS_NRF53=n; west flash --build-dir=build_headset

    If that doesn't change anything either, we will need to take a closer look at your project. If you could upload a version of your project where we can reproduce this on our end that would be very helpful.

    I know that the LE audio application has been able to advertise custom UUIDs in the past, so we will get to the bottom of this, one way or the other.

    Best regards,

    Simon

Related