2021-11-16 22:36:36 -05:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2017-08-24 07:54:41 -04:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include "esp_gatt_common_api.h"
|
|
|
|
#include "esp_bt_main.h"
|
|
|
|
#include "esp_gatt_defs.h"
|
2018-01-25 04:34:10 -05:00
|
|
|
#include "btc_gatt_common.h"
|
2017-08-24 07:54:41 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function is called to set local MTU,
|
|
|
|
* the function is called before BLE connection.
|
|
|
|
*
|
|
|
|
* @param[in] mtu: the size of MTU.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* - ESP_OK: success
|
|
|
|
* - other: failed
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu)
|
|
|
|
{
|
2021-11-16 22:36:36 -05:00
|
|
|
btc_msg_t msg = {0};
|
2018-01-25 04:34:10 -05:00
|
|
|
btc_ble_gatt_com_args_t arg;
|
2017-08-24 07:54:41 -04:00
|
|
|
|
|
|
|
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
|
|
|
|
|
|
|
if ((mtu < ESP_GATT_DEF_BLE_MTU_SIZE) || (mtu > ESP_GATT_MAX_MTU_SIZE)) {
|
2017-09-11 05:30:50 -04:00
|
|
|
return ESP_ERR_INVALID_SIZE;
|
2017-08-24 07:54:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
msg.sig = BTC_SIG_API_CALL;
|
2018-01-25 04:34:10 -05:00
|
|
|
msg.pid = BTC_PID_GATT_COMMON;
|
2017-08-24 07:54:41 -04:00
|
|
|
msg.act = BTC_GATT_ACT_SET_LOCAL_MTU;
|
|
|
|
arg.set_mtu.mtu = mtu;
|
|
|
|
|
2022-08-09 02:16:30 -04:00
|
|
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatt_com_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
2020-01-10 03:32:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#if (BLE_INCLUDED == TRUE)
|
2020-05-11 07:24:09 -04:00
|
|
|
extern UINT16 L2CA_GetFreePktBufferNum_LE(void);
|
2020-01-10 03:32:47 -05:00
|
|
|
|
2020-06-15 06:02:34 -04:00
|
|
|
/**
|
|
|
|
* @brief This function is called to get currently sendable packets number on controller,
|
2020-06-15 06:52:48 -04:00
|
|
|
* the function is called only in BLE running core and single connection now.
|
2020-06-15 06:02:34 -04:00
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* sendable packets number on controller
|
|
|
|
*
|
|
|
|
*/
|
2020-11-10 02:40:01 -05:00
|
|
|
|
2020-05-11 07:24:09 -04:00
|
|
|
uint16_t esp_ble_get_sendable_packets_num (void)
|
2020-01-10 03:32:47 -05:00
|
|
|
{
|
|
|
|
return L2CA_GetFreePktBufferNum_LE();
|
|
|
|
}
|
2020-05-11 07:24:09 -04:00
|
|
|
|
2020-06-15 06:52:48 -04:00
|
|
|
/**
|
|
|
|
* @brief This function is used to query the number of available buffers for the current connection.
|
|
|
|
* When you need to query the current available buffer number, it is recommended to use this API.
|
|
|
|
* @param[in] conn_id: current connection id.
|
2020-11-10 02:40:01 -05:00
|
|
|
*
|
2020-06-15 06:52:48 -04:00
|
|
|
* @return
|
|
|
|
* Number of available buffers for the current connection
|
|
|
|
*
|
|
|
|
*/
|
2020-11-10 02:40:01 -05:00
|
|
|
|
2020-05-11 07:24:09 -04:00
|
|
|
extern UINT16 L2CA_GetCurFreePktBufferNum_LE(UINT16 conn_id);
|
|
|
|
uint16_t esp_ble_get_cur_sendable_packets_num (uint16_t connid)
|
|
|
|
{
|
|
|
|
return L2CA_GetCurFreePktBufferNum_LE(connid);
|
|
|
|
}
|
2020-11-10 02:40:01 -05:00
|
|
|
#endif
|