2021-10-26 08:24:54 +00:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2020-02-13 11:41:42 +00:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "esp_err.h"
|
|
|
|
|
2020-10-26 08:04:34 +00:00
|
|
|
#include "btc_ble_mesh_ble.h"
|
|
|
|
#include "esp_ble_mesh_ble_api.h"
|
2020-02-13 11:41:42 +00:00
|
|
|
|
2020-10-26 07:51:18 +00:00
|
|
|
#if CONFIG_BLE_MESH_BLE_COEX_SUPPORT
|
2020-10-26 08:04:34 +00:00
|
|
|
esp_err_t esp_ble_mesh_register_ble_callback(esp_ble_mesh_ble_cb_t callback)
|
|
|
|
{
|
|
|
|
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
|
|
|
|
|
|
|
return (btc_profile_cb_set(BTC_PID_BLE_MESH_BLE_COEX, callback) == 0 ? ESP_OK : ESP_FAIL);
|
|
|
|
}
|
2020-10-26 07:51:18 +00:00
|
|
|
#endif /* CONFIG_BLE_MESH_BLE_COEX_SUPPORT */
|
2020-02-13 11:41:42 +00:00
|
|
|
|
2020-10-26 07:51:18 +00:00
|
|
|
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
|
2020-02-13 11:41:42 +00:00
|
|
|
esp_err_t esp_ble_mesh_start_ble_advertising(const esp_ble_mesh_ble_adv_param_t *param,
|
|
|
|
const esp_ble_mesh_ble_adv_data_t *data)
|
|
|
|
{
|
2020-10-26 08:04:34 +00:00
|
|
|
btc_ble_mesh_ble_args_t arg = {0};
|
2020-02-13 11:41:42 +00:00
|
|
|
btc_msg_t msg = {0};
|
|
|
|
|
|
|
|
if (param == NULL) {
|
|
|
|
return ESP_ERR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
2020-10-26 08:04:34 +00:00
|
|
|
msg.pid = BTC_PID_BLE_MESH_BLE_COEX;
|
|
|
|
msg.act = BTC_BLE_MESH_ACT_START_BLE_ADV;
|
2020-02-13 11:41:42 +00:00
|
|
|
|
2020-10-26 08:04:34 +00:00
|
|
|
memcpy(&arg.start_ble_adv.param, param, sizeof(esp_ble_mesh_ble_adv_param_t));
|
2020-02-13 11:41:42 +00:00
|
|
|
if (data) {
|
2020-10-26 08:04:34 +00:00
|
|
|
memcpy(&arg.start_ble_adv.data, data, sizeof(esp_ble_mesh_ble_adv_data_t));
|
2020-02-13 11:41:42 +00:00
|
|
|
}
|
|
|
|
|
2020-10-26 08:04:34 +00:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_ble_args_t), NULL)
|
2020-02-13 11:41:42 +00:00
|
|
|
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
|
|
|
}
|
|
|
|
|
|
|
|
esp_err_t esp_ble_mesh_stop_ble_advertising(uint8_t index)
|
|
|
|
{
|
2020-10-26 08:04:34 +00:00
|
|
|
btc_ble_mesh_ble_args_t arg = {0};
|
2020-02-13 11:41:42 +00:00
|
|
|
btc_msg_t msg = {0};
|
|
|
|
|
|
|
|
if (index >= CONFIG_BLE_MESH_BLE_ADV_BUF_COUNT) {
|
|
|
|
return ESP_ERR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
2020-10-26 08:04:34 +00:00
|
|
|
msg.pid = BTC_PID_BLE_MESH_BLE_COEX;
|
|
|
|
msg.act = BTC_BLE_MESH_ACT_STOP_BLE_ADV;
|
2020-02-13 11:41:42 +00:00
|
|
|
|
2020-10-26 08:04:34 +00:00
|
|
|
arg.stop_ble_adv.index = index;
|
2020-02-13 11:41:42 +00:00
|
|
|
|
2020-10-26 08:04:34 +00:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_ble_args_t), NULL)
|
2020-02-13 11:41:42 +00:00
|
|
|
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */
|
2020-10-26 07:51:18 +00:00
|
|
|
|
|
|
|
#if CONFIG_BLE_MESH_SUPPORT_BLE_SCAN
|
|
|
|
esp_err_t esp_ble_mesh_start_ble_scanning(esp_ble_mesh_ble_scan_param_t *param)
|
|
|
|
{
|
|
|
|
btc_ble_mesh_ble_args_t arg = {0};
|
|
|
|
btc_msg_t msg = {0};
|
|
|
|
|
|
|
|
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_BLE_MESH_BLE_COEX;
|
|
|
|
msg.act = BTC_BLE_MESH_ACT_START_BLE_SCAN;
|
|
|
|
|
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_ble_args_t), NULL)
|
|
|
|
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
|
|
|
}
|
|
|
|
|
|
|
|
esp_err_t esp_ble_mesh_stop_ble_scanning(void)
|
|
|
|
{
|
|
|
|
btc_ble_mesh_ble_args_t arg = {0};
|
|
|
|
btc_msg_t msg = {0};
|
|
|
|
|
|
|
|
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
|
|
|
msg.pid = BTC_PID_BLE_MESH_BLE_COEX;
|
|
|
|
msg.act = BTC_BLE_MESH_ACT_STOP_BLE_SCAN;
|
|
|
|
|
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_ble_args_t), NULL)
|
|
|
|
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_SCAN */
|