Bluetooth: Add and use missing own_addr_type defines

The own_addr_type used for various HCI commands sometimes
had a BT_HCI_OWN_ADDR_* type value or a BT_ADDR_* type
value. Those are 2 different value spaces, and if the public
address types would ever change, it would start have incorrect
behavior.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2024-10-10 11:15:29 +02:00 committed by Carles Cufí
commit da2e8c3c96
16 changed files with 61 additions and 48 deletions

View file

@ -14,6 +14,7 @@
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/hci.h>
#include <zephyr/bluetooth/hci_raw.h>
#include <zephyr/bluetooth/hci_types.h>
#include "common/bt_str.h"
@ -483,7 +484,7 @@ void start_adv(void)
set_param.channel_map = 0x07;
set_param.filter_policy = BT_LE_ADV_FP_NO_FILTER;
set_param.type = BT_HCI_ADV_IND;
set_param.own_addr_type = 0x01; /* random */
set_param.own_addr_type = BT_HCI_OWN_ADDR_RANDOM;
/* configure */
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_ADV_PARAM, sizeof(set_param));

View file

@ -14,6 +14,7 @@
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/hci.h>
#include <zephyr/bluetooth/hci_raw.h>
#include <zephyr/bluetooth/hci_types.h>
#include "common/bt_str.h"
@ -459,7 +460,7 @@ void start_adv(void)
set_param.channel_map = 0x07;
set_param.filter_policy = BT_LE_ADV_FP_NO_FILTER;
set_param.type = BT_HCI_ADV_IND;
set_param.own_addr_type = 0x01; /* random */
set_param.own_addr_type = BT_HCI_OWN_ADDR_RANDOM;
/* configure */
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_ADV_PARAM, sizeof(set_param));

View file

@ -14,6 +14,7 @@
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/hci.h>
#include <zephyr/bluetooth/hci_raw.h>
#include <zephyr/bluetooth/hci_types.h>
#include "common/bt_str.h"
@ -402,7 +403,7 @@ static void start_adv(uint16_t interval, const char *name, size_t name_len)
set_param.channel_map = 0x07;
set_param.filter_policy = BT_LE_ADV_FP_NO_FILTER;
set_param.type = BT_HCI_ADV_IND;
set_param.own_addr_type = 0x01; /* random */
set_param.own_addr_type = BT_HCI_OWN_ADDR_RANDOM;
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_ADV_PARAM, sizeof(set_param));
__ASSERT_NO_MSG(buf);

View file

@ -14,6 +14,7 @@
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/hci.h>
#include <zephyr/bluetooth/hci_raw.h>
#include <zephyr/bluetooth/hci_types.h>
#include "common/bt_str.h"
@ -438,7 +439,7 @@ void start_adv(uint16_t interval)
set_param.channel_map = 0x07;
set_param.filter_policy = BT_LE_ADV_FP_NO_FILTER;
set_param.type = BT_HCI_ADV_IND;
set_param.own_addr_type = 0x01; /* random */
set_param.own_addr_type = BT_HCI_OWN_ADDR_RANDOM;
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_ADV_PARAM, sizeof(set_param));
__ASSERT_NO_MSG(buf);

View file

@ -14,6 +14,7 @@
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/hci.h>
#include <zephyr/bluetooth/hci_raw.h>
#include <zephyr/bluetooth/hci_types.h>
#include "common/bt_str.h"
@ -437,7 +438,7 @@ void start_adv(void)
set_param.channel_map = 0x07;
set_param.filter_policy = BT_LE_ADV_FP_NO_FILTER;
set_param.type = BT_HCI_ADV_IND;
set_param.own_addr_type = 0x01; /* random */
set_param.own_addr_type = BT_HCI_OWN_ADDR_RANDOM;
/* configure */
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_ADV_PARAM, sizeof(set_param));

View file

@ -14,6 +14,7 @@
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/hci.h>
#include <zephyr/bluetooth/hci_raw.h>
#include <zephyr/bluetooth/hci_types.h>
#include <zephyr/bluetooth/gap.h>
#include "common/bt_str.h"
@ -467,7 +468,7 @@ static void start_adv(uint16_t interval, const char *name, size_t name_len)
set_param.channel_map = 0x07;
set_param.filter_policy = BT_LE_ADV_FP_NO_FILTER;
set_param.type = BT_HCI_ADV_IND;
set_param.own_addr_type = 0x01; /* random */
set_param.own_addr_type = BT_HCI_OWN_ADDR_RANDOM;
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_ADV_PARAM, sizeof(set_param));
__ASSERT_NO_MSG(buf);

View file

@ -14,6 +14,7 @@
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/hci.h>
#include <zephyr/bluetooth/hci_types.h>
#include "ll.h"
@ -28,8 +29,8 @@
#define EVT_PROP_TXP BIT(6)
#define ADV_INTERVAL 0x20 /* 20 ms advertising interval */
#define ADV_WAIT_MS 10 /* 10 ms wait loop */
#define OWN_ADDR_TYPE BT_ADDR_LE_RANDOM_ID
#define PEER_ADDR_TYPE BT_ADDR_LE_RANDOM_ID
#define OWN_ADDR_TYPE BT_HCI_OWN_ADDR_RANDOM
#define PEER_ADDR_TYPE BT_HCI_OWN_ADDR_RANDOM
#define PEER_ADDR peer_addr
#define ADV_CHAN_MAP 0x07
#define FILTER_POLICY 0x00