@@ -54,23 +54,11 @@ static struct bt_le_oob oob_sc_remote = { 0 };
54
54
#define REJECT_LATENCY 0x0000
55
55
#define REJECT_SUPERVISION_TIMEOUT 0x0C80
56
56
57
- #if defined(CONFIG_BT_PRIVACY )
58
57
static struct {
59
58
bt_addr_le_t addr ;
60
59
bool supported ;
61
60
} cars [CONFIG_BT_MAX_PAIRED ];
62
61
63
- static uint8_t read_car_cb (struct bt_conn * conn , uint8_t err ,
64
- struct bt_gatt_read_params * params , const void * data ,
65
- uint16_t length );
66
-
67
- static struct bt_gatt_read_params read_car_params = {
68
- .func = read_car_cb ,
69
- .by_uuid .uuid = BT_UUID_CENTRAL_ADDR_RES ,
70
- .by_uuid .start_handle = BT_ATT_FIRST_ATTRIBUTE_HANDLE ,
71
- .by_uuid .end_handle = BT_ATT_LAST_ATTRIBUTE_HANDLE ,
72
- };
73
-
74
62
static uint8_t read_car_cb (struct bt_conn * conn , uint8_t err ,
75
63
struct bt_gatt_read_params * params , const void * data ,
76
64
uint16_t length )
@@ -98,7 +86,13 @@ static uint8_t read_car_cb(struct bt_conn *conn, uint8_t err,
98
86
99
87
return BT_GATT_ITER_STOP ;
100
88
}
101
- #endif
89
+
90
+ static struct bt_gatt_read_params read_car_params = {
91
+ .func = read_car_cb ,
92
+ .by_uuid .uuid = BT_UUID_CENTRAL_ADDR_RES ,
93
+ .by_uuid .start_handle = BT_ATT_FIRST_ATTRIBUTE_HANDLE ,
94
+ .by_uuid .end_handle = BT_ATT_LAST_ATTRIBUTE_HANDLE ,
95
+ };
102
96
103
97
static void le_connected (struct bt_conn * conn , uint8_t err )
104
98
{
@@ -314,11 +308,11 @@ static uint8_t controller_info(const void *cmd, uint16_t cmd_len,
314
308
* If privacy is used, the device uses random type address, otherwise
315
309
* static random or public type address is used.
316
310
*/
317
- #if !defined(CONFIG_BT_PRIVACY )
318
- if (oob_local .addr .type == BT_ADDR_LE_RANDOM ) {
319
- atomic_set_bit (& current_settings , BTP_GAP_SETTINGS_STATIC_ADDRESS );
311
+ if (!IS_ENABLED (CONFIG_BT_PRIVACY )) {
312
+ if (oob_local .addr .type == BT_ADDR_LE_RANDOM ) {
313
+ atomic_set_bit (& current_settings , BTP_GAP_SETTINGS_STATIC_ADDRESS );
314
+ }
320
315
}
321
- #endif /* CONFIG_BT_PRIVACY */
322
316
323
317
supported_settings = BIT (BTP_GAP_SETTINGS_POWERED );
324
318
supported_settings |= BIT (BTP_GAP_SETTINGS_CONNECTABLE );
@@ -642,20 +636,24 @@ int tester_gap_create_adv_instance(struct bt_le_adv_param *param, uint8_t own_ad
642
636
case BTP_GAP_ADDR_TYPE_IDENTITY :
643
637
param -> options |= BT_LE_ADV_OPT_USE_IDENTITY ;
644
638
break ;
645
- #if defined(CONFIG_BT_PRIVACY )
646
639
case BTP_GAP_ADDR_TYPE_RESOLVABLE_PRIVATE :
640
+ if (!IS_ENABLED (CONFIG_BT_PRIVACY )) {
641
+ return - EINVAL ;
642
+ }
647
643
/* RPA usage is controlled via privacy settings */
648
644
if (!atomic_test_bit (& current_settings , BTP_GAP_SETTINGS_PRIVACY )) {
649
645
return - EINVAL ;
650
646
}
651
647
break ;
652
648
case BTP_GAP_ADDR_TYPE_NON_RESOLVABLE_PRIVATE :
649
+ if (!IS_ENABLED (CONFIG_BT_PRIVACY )) {
650
+ return - EINVAL ;
651
+ }
653
652
/* NRPA is used only for non-connectable advertising */
654
653
if (atomic_test_bit (& current_settings , BTP_GAP_SETTINGS_CONNECTABLE )) {
655
654
return - EINVAL ;
656
655
}
657
656
break ;
658
- #endif
659
657
default :
660
658
return - EINVAL ;
661
659
}
@@ -786,8 +784,7 @@ static uint8_t start_directed_advertising(const void *cmd, uint16_t cmd_len,
786
784
adv_param .interval_min = BT_GAP_ADV_FAST_INT_MIN_2 ;
787
785
}
788
786
789
- if (options & BTP_GAP_START_DIRECTED_ADV_PEER_RPA ) {
790
- #if defined(CONFIG_BT_PRIVACY )
787
+ if (IS_ENABLED (CONFIG_BT_PRIVACY ) && (options & BTP_GAP_START_DIRECTED_ADV_PEER_RPA )) {
791
788
/* check if peer supports Central Address Resolution */
792
789
for (int i = 0 ; i < CONFIG_BT_MAX_PAIRED ; i ++ ) {
793
790
if (bt_addr_le_eq (& cp -> address , & cars [i ].addr )) {
@@ -796,7 +793,6 @@ static uint8_t start_directed_advertising(const void *cmd, uint16_t cmd_len,
796
793
}
797
794
}
798
795
}
799
- #endif
800
796
}
801
797
802
798
if (bt_le_adv_start (& adv_param , NULL , 0 , NULL , 0 ) < 0 ) {
@@ -1127,12 +1123,10 @@ void auth_pairing_failed(struct bt_conn *conn, enum bt_security_err reason)
1127
1123
1128
1124
static void auth_pairing_complete (struct bt_conn * conn , bool bonded )
1129
1125
{
1130
- #if defined(CONFIG_BT_PRIVACY )
1131
- /* Read peer's Central Address Resolution if bonded */
1132
- if (bonded ) {
1126
+ if (IS_ENABLED (CONFIG_BT_PRIVACY ) && bonded ) {
1127
+ /* Read peer's Central Address Resolution if bonded */
1133
1128
bt_gatt_read (conn , & read_car_params );
1134
1129
}
1135
- #endif
1136
1130
}
1137
1131
1138
1132
static struct bt_conn_auth_info_cb auth_info_cb = {
@@ -1918,9 +1912,9 @@ uint8_t tester_init_gap(void)
1918
1912
atomic_set_bit (& current_settings , BTP_GAP_SETTINGS_CONNECTABLE );
1919
1913
atomic_set_bit (& current_settings , BTP_GAP_SETTINGS_BONDABLE );
1920
1914
atomic_set_bit (& current_settings , BTP_GAP_SETTINGS_LE );
1921
- # if defined( CONFIG_BT_PRIVACY )
1922
- atomic_set_bit (& current_settings , BTP_GAP_SETTINGS_PRIVACY );
1923
- #endif /* CONFIG_BT_PRIVACY */
1915
+ if ( IS_ENABLED ( CONFIG_BT_PRIVACY )) {
1916
+ atomic_set_bit (& current_settings , BTP_GAP_SETTINGS_PRIVACY );
1917
+ }
1924
1918
1925
1919
bt_conn_cb_register (& conn_callbacks );
1926
1920
bt_conn_auth_info_cb_register (& auth_info_cb );
0 commit comments