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.

Parents
  • Hi

    What issues exactly did you have with bt_le_adv_start()? You need to make sure that the mgmt_adv_start() has room for 128 bits for the UUID. What errors are you running into exactly when trying to use bt_mgmt_adv_start() to advertise with the NUS UUID?

    Best regards,

    Simon

  •  Hi  

    When I try to create the advertising data as follows, for mgmt_adv_start() : 

    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 */
    };

    I get all sorts of issues : 

    warning: braces around scalar initializer
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: (near initialization for 'adv_data[0]')
    In file included from C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/conn.h:23,
                     from C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/hci.h:16,
                     from C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/buf.h:24,
                     from C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/audio/audio.h:22,
                     from ../../../src/bluetooth/le_audio.h:10,
                     from ../../../src/bluetooth/bt_stream/broadcast/broadcast_sink.h:10,
                     from ../../../src/audio/streamctrl_broadcast_sink.c:13:
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:451:17: error: field name not in record or union initializer
      451 |                 .type = (_type), \
          |                 ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:451:17: note: (near initialization for 'adv_data[0]')
      451 |                 .type = (_type), \
          |                 ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:452:17: error: field name not in record or union initializer
      452 |                 .data_len = (_data_len), \
          |                 ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:452:17: note: (near initialization for 'adv_data[0]')
      452 |                 .data_len = (_data_len), \
          |                 ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:452:29: warning: excess elements in scalar initializer
      452 |                 .data_len = (_data_len), \
          |                             ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:452:29: note: (near initialization for 'adv_data[0]')
      452 |                 .data_len = (_data_len), \
          |                             ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:453:17: error: field name not in record or union initializer
      453 |                 .data = (const uint8_t *)(_data), \
          |                 ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:453:17: note: (near initialization for 'adv_data[0]')
      453 |                 .data = (const uint8_t *)(_data), \
          |                 ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:453:25: warning: excess elements in scalar initializer
      453 |                 .data = (const uint8_t *)(_data), \
          |                         ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:453:25: note: (near initialization for 'adv_data[0]')
      453 |                 .data = (const uint8_t *)(_data), \
          |                         ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    ninja: build stopped: subcommand failed.

Reply
  •  Hi  

    When I try to create the advertising data as follows, for mgmt_adv_start() : 

    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 */
    };

    I get all sorts of issues : 

    warning: braces around scalar initializer
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: (near initialization for 'adv_data[0]')
    In file included from C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/conn.h:23,
                     from C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/hci.h:16,
                     from C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/buf.h:24,
                     from C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/audio/audio.h:22,
                     from ../../../src/bluetooth/le_audio.h:10,
                     from ../../../src/bluetooth/bt_stream/broadcast/broadcast_sink.h:10,
                     from ../../../src/audio/streamctrl_broadcast_sink.c:13:
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:451:17: error: field name not in record or union initializer
      451 |                 .type = (_type), \
          |                 ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:451:17: note: (near initialization for 'adv_data[0]')
      451 |                 .type = (_type), \
          |                 ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:452:17: error: field name not in record or union initializer
      452 |                 .data_len = (_data_len), \
          |                 ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:452:17: note: (near initialization for 'adv_data[0]')
      452 |                 .data_len = (_data_len), \
          |                 ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:452:29: warning: excess elements in scalar initializer
      452 |                 .data_len = (_data_len), \
          |                             ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:452:29: note: (near initialization for 'adv_data[0]')
      452 |                 .data_len = (_data_len), \
          |                             ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:453:17: error: field name not in record or union initializer
      453 |                 .data = (const uint8_t *)(_data), \
          |                 ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:453:17: note: (near initialization for 'adv_data[0]')
      453 |                 .data = (const uint8_t *)(_data), \
          |                 ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:453:25: warning: excess elements in scalar initializer
      453 |                 .data = (const uint8_t *)(_data), \
          |                         ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:453:25: note: (near initialization for 'adv_data[0]')
      453 |                 .data = (const uint8_t *)(_data), \
          |                         ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/bluetooth/bluetooth.h:466:9: note: in expansion of macro 'BT_DATA'
      466 |         BT_DATA(_type, ((uint8_t []) { _bytes }), \
          |         ^~~~~~~
    ../../../src/audio/streamctrl_broadcast_sink.c:504:9: note: in expansion of macro 'BT_DATA_BYTES'
      504 |         BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
          |         ^~~~~~~~~~~~~
    ninja: build stopped: subcommand failed.

Children
No Data
Related