@@ -1196,6 +1196,41 @@ static uint8_t br_start_discovery(const struct btp_gap_start_discovery_cmd *cp)
1196
1196
}
1197
1197
#endif /* CONFIG_BT_CLASSIC */
1198
1198
1199
+ static struct bt_le_scan_param scan_param = {
1200
+ .type = BT_LE_SCAN_TYPE_PASSIVE ,
1201
+ .options = BT_LE_SCAN_OPT_FILTER_DUPLICATE ,
1202
+ .interval = BT_GAP_SCAN_FAST_INTERVAL ,
1203
+ .window = BT_GAP_SCAN_FAST_WINDOW ,
1204
+ .timeout = 0 ,
1205
+ .interval_coded = 0 ,
1206
+ .window_coded = 0 ,
1207
+ };
1208
+
1209
+ static uint8_t set_discovery_params (const void * cmd , uint16_t cmd_len , void * rsp , uint16_t * rsp_len )
1210
+ {
1211
+ const struct btp_gap_set_discovery_params_cmd * cp = cmd ;
1212
+
1213
+ if (cp -> interval < 4 || cp -> window < 4 || cp -> window > cp -> interval ) {
1214
+ LOG_ERR ("Invalid discovery parameters" );
1215
+ return BTP_STATUS_FAILED ;
1216
+ }
1217
+
1218
+ /* 1M default we do not need to test for it */
1219
+ if (cp -> phy & ~(BTP_GAP_PHY_LE_1M | BTP_GAP_PHY_LE_CODED )) {
1220
+ LOG_ERR ("Invalid PHY" );
1221
+ return BTP_STATUS_FAILED ;
1222
+ }
1223
+
1224
+ scan_param .interval = cp -> interval ;
1225
+ scan_param .window = cp -> window ;
1226
+
1227
+ if (cp -> phy & BTP_GAP_PHY_LE_CODED ) {
1228
+ scan_param .options |= BT_LE_SCAN_OPT_CODED ;
1229
+ }
1230
+
1231
+ return BTP_STATUS_SUCCESS ;
1232
+ }
1233
+
1199
1234
static uint8_t start_discovery (const void * cmd , uint16_t cmd_len ,
1200
1235
void * rsp , uint16_t * rsp_len )
1201
1236
{
@@ -1206,16 +1241,6 @@ static uint8_t start_discovery(const void *cmd, uint16_t cmd_len,
1206
1241
return br_start_discovery (cp );
1207
1242
}
1208
1243
1209
- struct bt_le_scan_param scan_param = {
1210
- .type = BT_LE_SCAN_TYPE_PASSIVE ,
1211
- .options = BT_LE_SCAN_OPT_FILTER_DUPLICATE ,
1212
- .interval = BT_GAP_SCAN_FAST_INTERVAL ,
1213
- .window = BT_GAP_SCAN_FAST_WINDOW ,
1214
- .timeout = 0 ,
1215
- .interval_coded = 0 ,
1216
- .window_coded = 0 ,
1217
- };
1218
-
1219
1244
if (cp -> flags & BTP_GAP_DISCOVERY_FLAG_LE_ACTIVE_SCAN ) {
1220
1245
scan_param .type = BT_LE_SCAN_TYPE_ACTIVE ;
1221
1246
}
@@ -2884,6 +2909,11 @@ static const struct btp_handler handlers[] = {
2884
2909
.expect_len = 0 ,
2885
2910
.func = stop_advertising ,
2886
2911
},
2912
+ {
2913
+ .opcode = BTP_GAP_SET_DISCOVERY_PARAMS ,
2914
+ .expect_len = sizeof (struct btp_gap_set_discovery_params_cmd ),
2915
+ .func = set_discovery_params ,
2916
+ },
2887
2917
{
2888
2918
.opcode = BTP_GAP_START_DISCOVERY ,
2889
2919
.expect_len = sizeof (struct btp_gap_start_discovery_cmd ),
0 commit comments