2017-02-24 04:28:33 -05:00
|
|
|
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2018-04-08 00:10:50 -04:00
|
|
|
#include "common/bt_target.h"
|
2017-02-24 04:28:33 -05:00
|
|
|
#include <string.h>
|
|
|
|
#include "esp_bt_main.h"
|
|
|
|
#include "esp_gap_bt_api.h"
|
2018-04-08 00:10:50 -04:00
|
|
|
#include "common/bt_trace.h"
|
2019-10-21 08:18:21 -04:00
|
|
|
#include "bta/bta_api.h"
|
2018-04-08 00:10:50 -04:00
|
|
|
#include "btc/btc_manage.h"
|
2017-02-24 04:28:33 -05:00
|
|
|
#include "btc_gap_bt.h"
|
2018-05-03 07:05:57 -04:00
|
|
|
#include "btc/btc_storage.h"
|
2017-02-24 04:28:33 -05:00
|
|
|
|
2017-11-24 04:28:43 -05:00
|
|
|
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
|
|
|
|
|
|
|
esp_err_t esp_bt_gap_register_callback(esp_bt_gap_cb_t callback)
|
|
|
|
{
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (callback == NULL) {
|
|
|
|
return ESP_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
btc_profile_cb_set(BTC_PID_GAP_BT, callback);
|
|
|
|
return ESP_OK;
|
|
|
|
}
|
2017-03-17 03:08:47 -04:00
|
|
|
|
2018-04-09 06:30:48 -04:00
|
|
|
esp_err_t esp_bt_gap_set_scan_mode(esp_bt_connection_mode_t c_mode, esp_bt_discovery_mode_t d_mode)
|
2017-02-24 04:28:33 -05:00
|
|
|
{
|
|
|
|
btc_msg_t msg;
|
|
|
|
btc_gap_bt_args_t arg;
|
|
|
|
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
2017-11-24 04:28:43 -05:00
|
|
|
|
2017-02-24 04:28:33 -05:00
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_GAP_BT;
|
|
|
|
msg.act = BTC_GAP_BT_ACT_SET_SCAN_MODE;
|
2018-04-09 06:30:48 -04:00
|
|
|
arg.set_scan_mode.c_mode = c_mode;
|
|
|
|
arg.set_scan_mode.d_mode = d_mode;
|
2017-02-24 04:28:33 -05:00
|
|
|
|
2022-08-09 02:16:30 -04:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
2017-02-24 04:28:33 -05:00
|
|
|
}
|
|
|
|
|
2017-11-24 04:28:43 -05:00
|
|
|
esp_err_t esp_bt_gap_start_discovery(esp_bt_inq_mode_t mode, uint8_t inq_len, uint8_t num_rsps)
|
|
|
|
{
|
|
|
|
btc_msg_t msg;
|
|
|
|
btc_gap_bt_args_t arg;
|
|
|
|
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mode != ESP_BT_INQ_MODE_GENERAL_INQUIRY &&
|
2018-04-10 08:24:52 -04:00
|
|
|
mode != ESP_BT_INQ_MODE_LIMITED_INQUIRY) {
|
2017-11-24 04:28:43 -05:00
|
|
|
return ESP_ERR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inq_len < ESP_BT_GAP_MIN_INQ_LEN ||
|
|
|
|
inq_len > ESP_BT_GAP_MAX_INQ_LEN) {
|
|
|
|
return ESP_ERR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_GAP_BT;
|
|
|
|
msg.act = BTC_GAP_BT_ACT_START_DISCOVERY;
|
|
|
|
|
|
|
|
arg.start_disc.mode = mode;
|
|
|
|
arg.start_disc.inq_len = inq_len;
|
|
|
|
arg.start_disc.num_rsps = num_rsps;
|
|
|
|
|
2022-08-09 02:16:30 -04:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
2017-11-24 04:28:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
esp_err_t esp_bt_gap_cancel_discovery(void)
|
|
|
|
{
|
|
|
|
btc_msg_t msg;
|
|
|
|
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_GAP_BT;
|
|
|
|
msg.act = BTC_GAP_BT_ACT_CANCEL_DISCOVERY;
|
|
|
|
|
2022-08-09 02:16:30 -04:00
|
|
|
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
2017-11-24 04:28:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
esp_err_t esp_bt_gap_get_remote_services(esp_bd_addr_t remote_bda)
|
|
|
|
{
|
|
|
|
btc_msg_t msg;
|
|
|
|
btc_gap_bt_args_t arg;
|
|
|
|
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_GAP_BT;
|
|
|
|
msg.act = BTC_GAP_BT_ACT_GET_REMOTE_SERVICES;
|
|
|
|
|
|
|
|
memcpy(&arg.bda, remote_bda, sizeof(bt_bdaddr_t));
|
2022-08-09 02:16:30 -04:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
2017-11-24 04:28:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
esp_err_t esp_bt_gap_get_remote_service_record(esp_bd_addr_t remote_bda, esp_bt_uuid_t *uuid)
|
|
|
|
{
|
|
|
|
btc_msg_t msg;
|
|
|
|
btc_gap_bt_args_t arg;
|
|
|
|
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_GAP_BT;
|
|
|
|
msg.act = BTC_GAP_BT_ACT_GET_REMOTE_SERVICE_RECORD;
|
|
|
|
|
|
|
|
memcpy(&arg.get_rmt_srv_rcd.bda, remote_bda, sizeof(bt_bdaddr_t));
|
|
|
|
memcpy(&arg.get_rmt_srv_rcd.uuid, uuid, sizeof(esp_bt_uuid_t));
|
2022-08-09 02:16:30 -04:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
2017-11-24 04:28:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t *esp_bt_gap_resolve_eir_data(uint8_t *eir, esp_bt_eir_type_t type, uint8_t *length)
|
|
|
|
{
|
|
|
|
if (!eir) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return BTM_CheckEirData(eir, type, length);
|
|
|
|
}
|
2018-04-09 07:25:26 -04:00
|
|
|
|
2019-06-03 07:29:54 -04:00
|
|
|
esp_err_t esp_bt_gap_config_eir_data(esp_bt_eir_data_t *eir_data)
|
|
|
|
{
|
|
|
|
btc_msg_t msg;
|
|
|
|
btc_gap_bt_args_t arg;
|
|
|
|
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (eir_data == NULL) {
|
|
|
|
return ESP_ERR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (eir_data->manufacturer_len > ESP_BT_EIR_MAX_LEN
|
|
|
|
|| eir_data->url_len > ESP_BT_EIR_MAX_LEN) {
|
|
|
|
return ESP_ERR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((eir_data->manufacturer_len > 0 && eir_data->p_manufacturer_data == NULL)
|
|
|
|
|| (eir_data->url_len > 0 && eir_data->p_url == NULL)) {
|
|
|
|
return ESP_ERR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_GAP_BT;
|
|
|
|
msg.act = BTC_GAP_BT_ACT_CONFIG_EIR;
|
|
|
|
|
|
|
|
memcpy(&arg.config_eir, eir_data, sizeof(esp_bt_eir_data_t));
|
|
|
|
|
2022-08-09 02:16:30 -04:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), btc_gap_bt_arg_deep_copy,
|
|
|
|
btc_gap_bt_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
2019-06-03 07:29:54 -04:00
|
|
|
}
|
|
|
|
|
2018-04-09 07:25:26 -04:00
|
|
|
esp_err_t esp_bt_gap_set_cod(esp_bt_cod_t cod, esp_bt_cod_mode_t mode)
|
|
|
|
{
|
|
|
|
btc_msg_t msg;
|
|
|
|
btc_gap_bt_args_t arg;
|
|
|
|
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case ESP_BT_SET_COD_MAJOR_MINOR:
|
|
|
|
case ESP_BT_SET_COD_SERVICE_CLASS:
|
|
|
|
case ESP_BT_CLR_COD_SERVICE_CLASS:
|
|
|
|
case ESP_BT_SET_COD_ALL:
|
|
|
|
case ESP_BT_INIT_COD:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return ESP_ERR_INVALID_ARG;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_GAP_BT;
|
|
|
|
msg.act = BTC_GAP_BT_ACT_SET_COD;
|
|
|
|
|
|
|
|
arg.set_cod.mode = mode;
|
|
|
|
memcpy(&arg.set_cod.cod, &cod, sizeof(esp_bt_cod_t));
|
2022-08-09 02:16:30 -04:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
2018-04-09 07:25:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
esp_err_t esp_bt_gap_get_cod(esp_bt_cod_t *cod)
|
|
|
|
{
|
|
|
|
return btc_gap_bt_get_cod(cod);
|
|
|
|
}
|
|
|
|
|
2018-05-03 07:05:57 -04:00
|
|
|
|
2018-01-16 05:36:31 -05:00
|
|
|
esp_err_t esp_bt_gap_read_rssi_delta(esp_bd_addr_t remote_addr)
|
|
|
|
{
|
|
|
|
btc_msg_t msg;
|
|
|
|
btc_gap_bt_args_t arg;
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_GAP_BT;
|
|
|
|
msg.act = BTC_GAP_BT_ACT_READ_RSSI_DELTA;
|
|
|
|
memcpy(arg.read_rssi_delta.bda.address, remote_addr, sizeof(esp_bd_addr_t));
|
|
|
|
|
2022-08-09 02:16:30 -04:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
2018-01-16 05:36:31 -05:00
|
|
|
}
|
|
|
|
|
2018-05-03 07:05:57 -04:00
|
|
|
esp_err_t esp_bt_gap_remove_bond_device(esp_bd_addr_t bd_addr)
|
|
|
|
{
|
|
|
|
btc_msg_t msg;
|
|
|
|
btc_gap_bt_args_t arg;
|
|
|
|
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_GAP_BT;
|
|
|
|
msg.act = BTC_GAP_BT_ACT_REMOVE_BOND_DEVICE;
|
|
|
|
|
|
|
|
memcpy(arg.rm_bond_device.bda.address, bd_addr, sizeof(esp_bd_addr_t));
|
2022-08-09 02:16:30 -04:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
2018-05-03 07:05:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int esp_bt_gap_get_bond_device_num(void)
|
|
|
|
{
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
2020-07-08 23:17:51 -04:00
|
|
|
return ESP_ERR_INVALID_STATE;
|
2018-05-03 07:05:57 -04:00
|
|
|
}
|
|
|
|
return btc_storage_get_num_bt_bond_devices();
|
|
|
|
}
|
|
|
|
|
|
|
|
esp_err_t esp_bt_gap_get_bond_device_list(int *dev_num, esp_bd_addr_t *dev_list)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (dev_num == NULL || dev_list == NULL) {
|
|
|
|
return ESP_ERR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
2020-07-08 23:17:51 -04:00
|
|
|
ret = btc_storage_get_bonded_bt_devices_list((bt_bdaddr_t *)dev_list, dev_num);
|
2018-05-03 07:05:57 -04:00
|
|
|
|
|
|
|
return (ret == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
|
|
|
}
|
|
|
|
|
2018-09-04 09:11:03 -04:00
|
|
|
esp_err_t esp_bt_gap_set_pin(esp_bt_pin_type_t pin_type, uint8_t pin_code_len, esp_bt_pin_code_t pin_code)
|
|
|
|
{
|
|
|
|
btc_msg_t msg;
|
|
|
|
btc_gap_bt_args_t arg;
|
|
|
|
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_GAP_BT;
|
|
|
|
msg.act = BTC_GAP_BT_ACT_SET_PIN_TYPE;
|
|
|
|
arg.set_pin_type.pin_type = pin_type;
|
|
|
|
if (pin_type == ESP_BT_PIN_TYPE_FIXED){
|
|
|
|
arg.set_pin_type.pin_code_len = pin_code_len;
|
|
|
|
memcpy(arg.set_pin_type.pin_code, pin_code, pin_code_len);
|
|
|
|
} else {
|
|
|
|
arg.set_pin_type.pin_code_len = 0;
|
|
|
|
memset(arg.set_pin_type.pin_code, 0, ESP_BT_PIN_CODE_LEN);
|
|
|
|
}
|
|
|
|
|
2022-08-09 02:16:30 -04:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), btc_gap_bt_arg_deep_copy,
|
|
|
|
btc_gap_bt_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
2018-09-04 09:11:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
esp_err_t esp_bt_gap_pin_reply(esp_bd_addr_t bd_addr, bool accept, uint8_t pin_code_len, esp_bt_pin_code_t pin_code)
|
|
|
|
{
|
|
|
|
btc_msg_t msg;
|
|
|
|
btc_gap_bt_args_t arg;
|
|
|
|
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_GAP_BT;
|
|
|
|
msg.act = BTC_GAP_BT_ACT_PIN_REPLY;
|
|
|
|
arg.pin_reply.accept = accept;
|
|
|
|
arg.pin_reply.pin_code_len = pin_code_len;
|
|
|
|
memcpy(arg.pin_reply.bda.address, bd_addr, sizeof(esp_bd_addr_t));
|
|
|
|
memcpy(arg.pin_reply.pin_code, pin_code, pin_code_len);
|
|
|
|
|
2022-08-09 02:16:30 -04:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), btc_gap_bt_arg_deep_copy,
|
|
|
|
btc_gap_bt_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
2018-09-04 09:11:03 -04:00
|
|
|
}
|
|
|
|
|
2018-07-09 23:18:52 -04:00
|
|
|
#if (BT_SSP_INCLUDED == TRUE)
|
|
|
|
esp_err_t esp_bt_gap_set_security_param(esp_bt_sp_param_t param_type,
|
|
|
|
void *value, uint8_t len)
|
|
|
|
{
|
|
|
|
btc_msg_t msg;
|
|
|
|
btc_gap_bt_args_t arg;
|
|
|
|
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_GAP_BT;
|
|
|
|
msg.act = BTC_GAP_BT_ACT_SET_SECURITY_PARAM;
|
|
|
|
arg.set_security_param.param_type = param_type;
|
|
|
|
arg.set_security_param.len = len;
|
|
|
|
arg.set_security_param.value = value;
|
|
|
|
|
2022-08-09 02:16:30 -04:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), btc_gap_bt_arg_deep_copy,
|
|
|
|
btc_gap_bt_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
2018-07-09 23:18:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
esp_err_t esp_bt_gap_ssp_passkey_reply(esp_bd_addr_t bd_addr, bool accept, uint32_t passkey)
|
|
|
|
{
|
|
|
|
btc_msg_t msg;
|
|
|
|
btc_gap_bt_args_t arg;
|
|
|
|
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_GAP_BT;
|
|
|
|
msg.act = BTC_GAP_BT_ACT_PASSKEY_REPLY;
|
|
|
|
arg.passkey_reply.accept = accept;
|
|
|
|
arg.passkey_reply.passkey = passkey;
|
|
|
|
memcpy(arg.passkey_reply.bda.address, bd_addr, sizeof(esp_bd_addr_t));
|
2022-08-09 02:16:30 -04:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), btc_gap_bt_arg_deep_copy,
|
|
|
|
btc_gap_bt_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
2018-07-09 23:18:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
esp_err_t esp_bt_gap_ssp_confirm_reply(esp_bd_addr_t bd_addr, bool accept)
|
|
|
|
{
|
|
|
|
btc_msg_t msg;
|
|
|
|
btc_gap_bt_args_t arg;
|
|
|
|
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_GAP_BT;
|
|
|
|
msg.act = BTC_GAP_BT_ACT_CONFIRM_REPLY;
|
|
|
|
arg.confirm_reply.accept = accept;
|
|
|
|
memcpy(arg.confirm_reply.bda.address, bd_addr, sizeof(esp_bd_addr_t));
|
2022-08-09 02:16:30 -04:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), btc_gap_bt_arg_deep_copy,
|
|
|
|
btc_gap_bt_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
2018-07-09 23:18:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /*(BT_SSP_INCLUDED == TRUE)*/
|
|
|
|
|
2019-09-29 04:20:40 -04:00
|
|
|
esp_err_t esp_bt_gap_set_afh_channels(esp_bt_gap_afh_channels channels)
|
|
|
|
{
|
|
|
|
btc_msg_t msg;
|
|
|
|
btc_gap_bt_args_t arg;
|
|
|
|
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_GAP_BT;
|
|
|
|
msg.act = BTC_GAP_BT_ACT_SET_AFH_CHANNELS;
|
|
|
|
|
|
|
|
memcpy(&arg.set_afh_channels.channels, channels, ESP_BT_GAP_AFH_CHANNELS_LEN);
|
|
|
|
arg.set_afh_channels.channels[ESP_BT_GAP_AFH_CHANNELS_LEN -1] &= 0x7F;
|
2022-08-09 02:16:30 -04:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
2019-09-29 04:20:40 -04:00
|
|
|
}
|
2019-10-30 03:06:29 -04:00
|
|
|
|
|
|
|
esp_err_t esp_bt_gap_read_remote_name(esp_bd_addr_t remote_bda)
|
|
|
|
{
|
|
|
|
btc_msg_t msg;
|
|
|
|
btc_gap_bt_args_t arg;
|
|
|
|
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_GAP_BT;
|
|
|
|
msg.act = BTC_GAP_BT_ACT_READ_REMOTE_NAME;
|
|
|
|
|
|
|
|
memcpy(&arg.rmt_name_bda, remote_bda, sizeof(bt_bdaddr_t));
|
2022-08-09 02:16:30 -04:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
2019-10-30 03:06:29 -04:00
|
|
|
}
|
|
|
|
|
2021-01-04 21:32:47 -05:00
|
|
|
esp_err_t esp_bt_gap_set_qos(esp_bd_addr_t remote_bda, uint32_t t_poll)
|
|
|
|
{
|
|
|
|
btc_msg_t msg;
|
|
|
|
btc_gap_bt_args_t arg;
|
|
|
|
|
|
|
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_GAP_BT;
|
|
|
|
msg.act = BTC_GAP_BT_ACT_SET_QOS;
|
|
|
|
|
|
|
|
memcpy(&arg.set_qos.bda, remote_bda, sizeof(bt_bdaddr_t));
|
|
|
|
arg.set_qos.t_poll = t_poll;
|
2022-08-09 02:16:30 -04:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
2021-01-04 21:32:47 -05:00
|
|
|
}
|
2017-11-24 04:28:43 -05:00
|
|
|
#endif /* #if BTC_GAP_BT_INCLUDED == TRUE */
|