Skip to content

Commit 5adcc6f

Browse files
apps/bttester: add btp command to configure security mode and level
This adds command to configure security mode and level. For now, this can't be done dynamically, we can just check if our settings comply with provided mode and level. This is needed for various GAP/SEC/SEM qualification test cases.
1 parent 07b0b0d commit 5adcc6f

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

apps/bttester/src/btp/btp_gap.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,12 @@ struct gap_subrate_request_cmd {
339339
uint16_t supervision_timeout;
340340
} __packed;
341341

342+
#define GAP_CONFIGURE_SECURITY_MODE 0x34
343+
struct gap_configure_security_mode_cmd {
344+
uint8_t mode;
345+
uint8_t level;
346+
} __packed;
347+
342348
/* events */
343349
#define BTP_GAP_EV_NEW_SETTINGS 0x80
344350
struct btp_gap_new_settings_ev {

apps/bttester/src/btp_gap.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,6 +2270,35 @@ subrate_request(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len)
22702270
}
22712271
#endif
22722272

2273+
static uint8_t
2274+
configure_security_mode(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len)
2275+
{
2276+
const struct gap_configure_security_mode_cmd *cp = cmd;
2277+
2278+
switch (cp->mode) {
2279+
case 1:
2280+
if (cp->level != MYNEWT_VAL(BLE_SM_LVL)) {
2281+
return BTP_STATUS_FAILED;
2282+
}
2283+
break;
2284+
2285+
case 2:
2286+
/* Data signing is not supported */
2287+
return BTP_STATUS_FAILED;
2288+
2289+
case 3:
2290+
if (cp->level != 1) {
2291+
/* Broadcast code encryption (lvl 2,3) is not supported */
2292+
return BTP_STATUS_FAILED;
2293+
}
2294+
break;
2295+
}
2296+
2297+
SYS_LOG_DBG("");
2298+
2299+
return BTP_STATUS_SUCCESS;
2300+
}
2301+
22732302
static const struct btp_handler handlers[] = {
22742303
{
22752304
.opcode = BTP_GAP_READ_SUPPORTED_COMMANDS,
@@ -2447,6 +2476,11 @@ static const struct btp_handler handlers[] = {
24472476
.func = subrate_request,
24482477
},
24492478
#endif
2479+
{
2480+
.opcode = GAP_CONFIGURE_SECURITY_MODE,
2481+
.expect_len = sizeof(struct gap_configure_security_mode_cmd),
2482+
.func = configure_security_mode,
2483+
},
24502484
};
24512485

24522486
static void

0 commit comments

Comments
 (0)