Bluetooth: Use BT_BYTES_LIST_LEXX macros for encoding of data

Modify the BT_UUID_XX_ENCODE and BT_LE_SUPP_FEAT_XX_ENCODE
macros to use the SYS_ENCODE_LEXX macros, instead of re-inventing
the encoding.

Also apply the macros for several other places.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2022-08-30 14:32:12 +02:00 committed by Carles Cufí
commit 426bc4545a
10 changed files with 37 additions and 86 deletions

View file

@ -9,6 +9,7 @@
#include <zephyr/sys/printk.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/byteorder.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/bap.h>
@ -32,10 +33,8 @@ BUILD_ASSERT((CONFIG_BT_PACS_SNK_CONTEXT & MANDATORY_SINK_CONTEXT) == MANDATORY_
static uint8_t unicast_server_addata[] = {
BT_UUID_16_ENCODE(BT_UUID_ASCS_VAL), /* ASCS UUID */
BT_AUDIO_UNICAST_ANNOUNCEMENT_TARGETED, /* Target Announcement */
(((AVAILABLE_SINK_CONTEXT) >> 0) & 0xFF),
(((AVAILABLE_SINK_CONTEXT) >> 8) & 0xFF),
(((AVAILABLE_SOURCE_CONTEXT) >> 0) & 0xFF),
(((AVAILABLE_SOURCE_CONTEXT) >> 8) & 0xFF),
BT_BYTES_LIST_LE16(AVAILABLE_SINK_CONTEXT),
BT_BYTES_LIST_LE16(AVAILABLE_SOURCE_CONTEXT),
0x00, /* Metadata length */
};

View file

@ -11,6 +11,7 @@
#include <zephyr/sys/printk.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/byteorder.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/bap.h>
@ -56,10 +57,8 @@ static K_SEM_DEFINE(sem_disconnected, 0, 1);
static uint8_t unicast_server_addata[] = {
BT_UUID_16_ENCODE(BT_UUID_ASCS_VAL), /* ASCS UUID */
BT_AUDIO_UNICAST_ANNOUNCEMENT_TARGETED, /* Target Announcement */
(((AVAILABLE_SINK_CONTEXT) >> 0) & 0xFF),
(((AVAILABLE_SINK_CONTEXT) >> 8) & 0xFF),
(((AVAILABLE_SOURCE_CONTEXT) >> 0) & 0xFF),
(((AVAILABLE_SOURCE_CONTEXT) >> 8) & 0xFF),
BT_BYTES_LIST_LE16(AVAILABLE_SINK_CONTEXT),
BT_BYTES_LIST_LE16(AVAILABLE_SOURCE_CONTEXT),
0x00, /* Metadata length */
};