diff --git a/tests/bluetooth/tester/src/btp_gap.c b/tests/bluetooth/tester/src/btp_gap.c index 93958720d300b4b..78afac0d91760d4 100644 --- a/tests/bluetooth/tester/src/btp_gap.c +++ b/tests/bluetooth/tester/src/btp_gap.c @@ -449,6 +449,37 @@ static uint8_t set_oob_sc_remote_data(const void *cmd, uint16_t cmd_len, } #endif /* !defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY) */ +static uint8_t set_powered(const void *cmd, uint16_t cmd_len, + void *rsp, uint16_t *rsp_len) +{ + const struct btp_gap_set_powered_cmd *cp = cmd; + struct btp_gap_set_powered_rp *rp = rsp; + int err; + + if (cp->powered) { + err = bt_enable(NULL); + if (err < 0) { + LOG_ERR("Unable to enable Bluetooth: %d", err); + return BTP_STATUS_FAILED; + } + bt_conn_cb_register(&conn_callbacks); + atomic_set_bit(¤t_settings, BTP_GAP_SETTINGS_POWERED); + } else { + err = bt_disable(); + if (err < 0) { + LOG_ERR("Unable to disable Bluetooth: %d", err); + return BTP_STATUS_FAILED; + } + bt_conn_cb_unregister(&conn_callbacks); + atomic_clear_bit(¤t_settings, BTP_GAP_SETTINGS_POWERED); + } + rp->current_settings = sys_cpu_to_le32(current_settings); + + *rsp_len = sizeof(*rp); + + return BTP_STATUS_SUCCESS; +} + static uint8_t set_connectable(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len) { @@ -1684,6 +1715,11 @@ static const struct btp_handler handlers[] = { .expect_len = 0, .func = controller_info, }, + { + .opcode = BTP_GAP_SET_POWERED, + .expect_len = sizeof(struct btp_gap_set_powered_cmd), + .func = set_powered, + }, { .opcode = BTP_GAP_SET_CONNECTABLE, .expect_len = sizeof(struct btp_gap_set_connectable_cmd),