Merge branch 'feature/btdm_add_set_local_MTU_API_for_gatt' into 'master'

component/bt: add set local MTU API

See merge request !1152
This commit is contained in:
Jiang Jiang Jian 2017-09-04 21:32:23 +08:00
commit f254555a41
24 changed files with 249 additions and 39 deletions

View file

@ -0,0 +1,49 @@
// Copyright 2015-2017 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.
#include <string.h>
#include "esp_gatt_common_api.h"
#include "esp_bt_main.h"
#include "esp_gatt_defs.h"
#include "btc_main.h"
/**
* @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)
{
btc_msg_t msg;
btc_ble_main_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if ((mtu < ESP_GATT_DEF_BLE_MTU_SIZE) || (mtu > ESP_GATT_MAX_MTU_SIZE)) {
return ESP_GATT_ILLEGAL_PARAMETER;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_MAIN_INIT;
msg.act = BTC_GATT_ACT_SET_LOCAL_MTU;
arg.set_mtu.mtu = mtu;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_main_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}

View file

@ -99,22 +99,17 @@ esp_err_t esp_ble_gattc_close (esp_gatt_if_t gattc_if, uint16_t conn_id)
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gattc_config_mtu (esp_gatt_if_t gattc_if, uint16_t conn_id, uint16_t mtu)
esp_err_t esp_ble_gattc_send_mtu_req (esp_gatt_if_t gattc_if, uint16_t conn_id)
{
btc_msg_t msg;
btc_ble_gattc_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if ((mtu < ESP_GATT_DEF_BLE_MTU_SIZE) || (mtu > ESP_GATT_MAX_MTU_SIZE)) {
return ESP_GATT_ILLEGAL_PARAMETER;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_CFG_MTU;
arg.cfg_mtu.conn_id = BTC_GATT_CREATE_CONN_ID(gattc_if, conn_id);
arg.cfg_mtu.mtu = mtu;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}

View file

@ -0,0 +1,46 @@
// Copyright 2015-2017 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.
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
#include "esp_bt_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
// Maximum Transmission Unit used in GATT
#define ESP_GATT_DEF_BLE_MTU_SIZE 23 /* relate to GATT_DEF_BLE_MTU_SIZE in gatt_api.h */
// Maximum Transmission Unit allowed in GATT
#define ESP_GATT_MAX_MTU_SIZE 517 /* relate to GATT_MAX_MTU_SIZE in gatt_api.h */
/**
* @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
*
*/
extern esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu);
#ifdef __cplusplus
}
#endif

View file

@ -68,11 +68,6 @@ typedef enum {
ESP_GATTC_DISCONNECT_EVT = 41, /*!< When the ble physical connection disconnected, the event comes */
} esp_gattc_cb_event_t;
/// Maximum Transmission Unit used in GATT
#define ESP_GATT_DEF_BLE_MTU_SIZE 23
/// Maximum Transmission Unit allowed in GATT
#define ESP_GATT_MAX_MTU_SIZE 517
/**
* @brief Gatt client callback parameters union
@ -355,18 +350,19 @@ esp_err_t esp_ble_gattc_close (esp_gatt_if_t gattc_if, uint16_t conn_id);
/**
* @brief Configure the MTU size in the GATT channel. This can be done
* only once per connection.
* only once per connection. Before using, use esp_ble_gatt_set_local_mtu()
* to configure the local MTU size.
*
*
* @param[in] gattc_if: Gatt client access interface.
* @param[in] conn_id: connection ID.
* @param[in] mtu: desired MTU size to use.
*
* @return
* - ESP_OK: success
* - other: failed
*
*/
esp_err_t esp_ble_gattc_config_mtu (esp_gatt_if_t gattc_if, uint16_t conn_id, uint16_t mtu);
esp_err_t esp_ble_gattc_send_mtu_req (esp_gatt_if_t gattc_if, uint16_t conn_id);
/**

View file

@ -53,7 +53,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
bta_dm_set_visibility, /* 3 BTA_DM_API_SET_VISIBILITY_EVT */
bta_dm_acl_change, /* 8 BTA_DM_ACL_CHANGE_EVT */
bta_dm_add_device, /* 9 BTA_DM_API_ADD_DEVICE_EVT */
bta_dm_close_acl, /* 10 BTA_DM_API_ADD_DEVICE_EVT */
bta_dm_close_acl, /* 10 BTA_DM_API_REMOVE_ACL_EVT */
#if (SMP_INCLUDED == TRUE)
/* security API events */
bta_dm_bond, /* 11 BTA_DM_API_BOND_EVT */

View file

@ -0,0 +1,30 @@
/******************************************************************************
* Copyright 2015-2017 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.
******************************************************************************/
/******************************************************************************
*
* This file contains the action functions for gatts and gattc.
*
*
******************************************************************************/
#include "bta_gatt_common.h"
#include "gatt_int.h"
void BTA_GATT_SetLocalMTU(uint16_t mtu)
{
gatt_set_local_mtu(mtu);
}

View file

@ -901,7 +901,7 @@ void bta_gattc_cfg_mtu(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
tBTA_GATT_STATUS status;
if (bta_gattc_enqueue(p_clcb, p_data)) {
status = GATTC_ConfigureMTU (p_clcb->bta_conn_id, p_data->api_mtu.mtu);
status = GATTC_ConfigureMTU (p_clcb->bta_conn_id);
/* if failed, return callback here */
if (status != GATT_SUCCESS && status != GATT_CMD_STARTED) {

View file

@ -228,7 +228,7 @@ void BTA_GATTC_Close(UINT16 conn_id)
** Returns void
**
*******************************************************************************/
void BTA_GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu)
void BTA_GATTC_ConfigureMTU (UINT16 conn_id)
{
tBTA_GATTC_API_CFG_MTU *p_buf;
@ -236,8 +236,6 @@ void BTA_GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu)
p_buf->hdr.event = BTA_GATTC_API_CFG_MTU_EVT;
p_buf->hdr.layer_specific = conn_id;
p_buf->mtu = mtu;
bta_sys_sendmsg(p_buf);
}
return;

View file

@ -1157,12 +1157,12 @@ extern void BTA_GATTC_Broadcast(tBTA_GATTC_IF client_if, BOOLEAN start);
** only once per connection.
**
** Parameters conn_id: connection ID.
** mtu: desired MTU size to use.
**
**
** Returns void
**
*******************************************************************************/
extern void BTA_GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu);
extern void BTA_GATTC_ConfigureMTU (UINT16 conn_id);
/*******************************************************************************
** BTA GATT Server API

View file

@ -0,0 +1,36 @@
/******************************************************************************
* Copyright 2015-2017 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.
******************************************************************************/
/******************************************************************************
*
* This file contains the action functions for gatts and gattc.
*
*
******************************************************************************/
#include "bt_types.h"
#ifdef __cplusplus
extern "C"
{
#endif
extern void BTA_GATT_SetLocalMTU(uint16_t mtu);
#ifdef __cplusplus
}
#endif

View file

@ -184,7 +184,6 @@ typedef struct {
typedef struct {
BT_HDR hdr;
UINT16 mtu;
} tBTA_GATTC_API_CFG_MTU;
typedef struct {

View file

@ -20,6 +20,7 @@
#include "btc_config.h"
#include "alarm.h"
#include "btc_ble_storage.h"
#include "bta_gatt_common.h"
static future_t *main_future[BTC_MAIN_FUTURE_NUM];
@ -73,6 +74,11 @@ static void btc_deinit_bluetooth(void)
future_ready(*btc_main_get_future_p(BTC_MAIN_DEINIT_FUTURE), FUTURE_SUCCESS);
}
static void btc_set_local_mtu(uint16_t mtu)
{
BTA_GATT_SetLocalMTU(mtu);
}
void btc_main_call_handler(btc_msg_t *msg)
{
LOG_DEBUG("%s act %d\n", __func__, msg->act);
@ -90,6 +96,12 @@ void btc_main_call_handler(btc_msg_t *msg)
case BTC_MAIN_ACT_DISABLE:
btc_disable_bluetooth();
break;
case BTC_GATT_ACT_SET_LOCAL_MTU:
{
btc_ble_main_args_t *arg = (btc_ble_main_args_t *)(msg->arg);
btc_set_local_mtu(arg->set_mtu.mtu);
break;
}
default:
LOG_ERROR("%s UNKNOWN ACT %d\n", __func__, msg->act);
break;

View file

@ -26,6 +26,7 @@ typedef enum {
BTC_MAIN_ACT_DEINIT,
BTC_MAIN_ACT_ENABLE,
BTC_MAIN_ACT_DISABLE,
BTC_GATT_ACT_SET_LOCAL_MTU,
} btc_main_act_t;
typedef enum {
@ -60,5 +61,13 @@ bt_status_t btc_init_bluetooth(future_t *future);
void btc_deinit_bluetooth(future_t *future);
#endif
/* btc_ble_gattc_args_t */
typedef union {
//BTC_GATT_ACT_SET_LOCAL_MTU,
struct set_mtu_arg {
uint16_t mtu;
} set_mtu;
} btc_ble_main_args_t;
void btc_main_call_handler(btc_msg_t *msg);
#endif /* __BTC_BT_MAIN_H__ */

View file

@ -181,7 +181,7 @@ static void btc_gattc_close(btc_ble_gattc_args_t *arg)
static void btc_gattc_cfg_mtu(btc_ble_gattc_args_t *arg)
{
BTA_GATTC_ConfigureMTU (arg->cfg_mtu.conn_id, arg->cfg_mtu.mtu);
BTA_GATTC_ConfigureMTU (arg->cfg_mtu.conn_id);
}
static void btc_gattc_search_service(btc_ble_gattc_args_t *arg)

View file

@ -68,7 +68,6 @@ typedef union {
//BTC_GATTC_ACT_CFG_MTU,
struct cfg_mtu_arg {
uint16_t conn_id;
uint16_t mtu;
} cfg_mtu;
//BTC_GATTC_ACT_SEARCH_SERVICE,
struct search_srvc_arg {

View file

@ -791,7 +791,7 @@ tGATT_STATUS GATTS_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 *
** Returns GATT_SUCCESS if command started successfully.
**
*******************************************************************************/
tGATT_STATUS GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu)
tGATT_STATUS GATTC_ConfigureMTU (UINT16 conn_id)
{
UINT8 ret = GATT_NO_RESOURCES;
tGATT_IF gatt_if = GATT_GET_GATT_IF(conn_id);
@ -800,6 +800,7 @@ tGATT_STATUS GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu)
tGATT_REG *p_reg = gatt_get_regcb(gatt_if);
tGATT_CLCB *p_clcb;
uint16_t mtu = gatt_get_local_mtu();
GATT_TRACE_API ("GATTC_ConfigureMTU conn_id=%d mtu=%d", conn_id, mtu );

View file

@ -79,6 +79,8 @@ static const tL2CAP_APPL_INFO dyn_info = {
tGATT_CB gatt_cb;
#endif
tGATT_DEFAULT gatt_default;
/*******************************************************************************
**
** Function gatt_init
@ -136,7 +138,8 @@ void gatt_init (void)
#if (GATTS_INCLUDED == TRUE)
gatt_profile_db_init();
#endif ///GATTS_INCLUDED == TRUE
//init local MTU size
gatt_default.local_mtu = GATT_MAX_MTU_SIZE;
}
@ -596,7 +599,7 @@ static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 lcid, UINT16
/* Send L2CAP config req */
memset(&cfg, 0, sizeof(tL2CAP_CFG_INFO));
cfg.mtu_present = TRUE;
cfg.mtu = GATT_MAX_MTU_SIZE;
cfg.mtu = gatt_default.local_mtu;
L2CA_ConfigReq(lcid, &cfg);
}
@ -632,7 +635,7 @@ static void gatt_l2cif_connect_cfm_cback(UINT16 lcid, UINT16 result)
/* Send L2CAP config req */
memset(&cfg, 0, sizeof(tL2CAP_CFG_INFO));
cfg.mtu_present = TRUE;
cfg.mtu = GATT_MAX_MTU_SIZE;
cfg.mtu = gatt_default.local_mtu;
L2CA_ConfigReq(lcid, &cfg);
}
/* else initiating connection failure */
@ -1169,4 +1172,14 @@ tGATT_CH_STATE gatt_get_ch_state(tGATT_TCB *p_tcb)
return ch_state;
}
uint16_t gatt_get_local_mtu(void)
{
return gatt_default.local_mtu;
}
void gatt_set_local_mtu(uint16_t mtu)
{
gatt_default.local_mtu = mtu;
}
#endif /* BLE_INCLUDED */

View file

@ -941,14 +941,12 @@ static void gatts_process_mtu_req (tGATT_TCB *p_tcb, UINT16 len, UINT8 *p_data)
/* mtu must be greater than default MTU which is 23/48 */
if (mtu < GATT_DEF_BLE_MTU_SIZE) {
p_tcb->payload_size = GATT_DEF_BLE_MTU_SIZE;
} else if (mtu > GATT_MAX_MTU_SIZE) {
p_tcb->payload_size = GATT_MAX_MTU_SIZE;
} else if (mtu > gatt_default.local_mtu) {
p_tcb->payload_size = gatt_default.local_mtu;
} else {
p_tcb->payload_size = mtu;
}
GATT_TRACE_ERROR("MTU request PDU with MTU size %d\n", p_tcb->payload_size);
l2cble_set_fixed_channel_tx_data_length(p_tcb->peer_bda, L2CAP_ATT_CID, p_tcb->payload_size);
if ((p_buf = attp_build_sr_msg(p_tcb, GATT_RSP_MTU, (tGATT_SR_MSG *) &p_tcb->payload_size)) != NULL) {

View file

@ -537,6 +537,9 @@ typedef struct {
} tGATT_CB;
typedef struct{
UINT16 local_mtu;
} tGATT_DEFAULT;
#define GATT_SIZE_OF_SRV_CHG_HNDL_RANGE 4
@ -544,6 +547,8 @@ typedef struct {
extern "C" {
#endif
extern tGATT_DEFAULT gatt_default;
/* Global GATT data */
#if GATT_DYNAMIC_MEMORY == FALSE
extern tGATT_CB gatt_cb;
@ -741,4 +746,6 @@ extern void gatts_update_srv_list_elem(UINT8 i_sreg, UINT16 handle, BOOLEAN is_p
extern tBT_UUID *gatts_get_service_uuid (tGATT_SVC_DB *p_db);
extern void gatt_reset_bgdev_list(void);
extern uint16_t gatt_get_local_mtu(void);
extern void gatt_set_local_mtu(uint16_t mtu);
#endif

View file

@ -943,7 +943,7 @@ tGATT_STATUS GATTS_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 *
** Returns GATT_SUCCESS if command started successfully.
**
*******************************************************************************/
extern tGATT_STATUS GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu);
extern tGATT_STATUS GATTC_ConfigureMTU (UINT16 conn_id);
/*******************************************************************************
**

View file

@ -36,6 +36,7 @@
#include "esp_gattc_api.h"
#include "esp_gatt_defs.h"
#include "esp_bt_main.h"
#include "esp_gatt_common_api.h"
#define GATTC_TAG "GATTC_DEMO"
#define REMOTE_SERVICE_UUID 0x00FF
@ -117,7 +118,7 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
ESP_LOGE(GATTC_TAG, "set scan params error, error code = %x", scan_ret);
}
break;
case ESP_GATTC_CONNECT_EVT:
case ESP_GATTC_CONNECT_EVT:{
//p_data->connect.status always be ESP_GATT_OK
ESP_LOGI(GATTC_TAG, "ESP_GATTC_CONNECT_EVT conn_id %d, if %d, status %d", conn_id, gattc_if, p_data->connect.status);
conn_id = p_data->connect.conn_id;
@ -125,11 +126,12 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
memcpy(gl_profile_tab[PROFILE_A_APP_ID].remote_bda, p_data->connect.remote_bda, sizeof(esp_bd_addr_t));
ESP_LOGI(GATTC_TAG, "REMOTE BDA:");
esp_log_buffer_hex(GATTC_TAG, gl_profile_tab[PROFILE_A_APP_ID].remote_bda, sizeof(esp_bd_addr_t));
esp_err_t mtu_ret = esp_ble_gattc_config_mtu (gattc_if, conn_id, 200);
esp_err_t mtu_ret = esp_ble_gattc_send_mtu_req (gattc_if, conn_id);
if (mtu_ret){
ESP_LOGE(GATTC_TAG, "config MTU error, error code = %x", mtu_ret);
}
break;
}
case ESP_GATTC_OPEN_EVT:
if (param->open.status != ESP_GATT_OK){
ESP_LOGE(GATTC_TAG, "open failed, status %d", p_data->open.status);
@ -404,6 +406,10 @@ void app_main()
if (ret){
ESP_LOGE(GATTC_TAG, "%s gattc app register failed, error code = %x\n", __func__, ret);
}
esp_err_t local_mtu_ret = esp_ble_gatt_set_local_mtu(500);
if (local_mtu_ret){
ESP_LOGE(GATTC_TAG, "set local MTU failed, error code = %x", local_mtu_ret);
}
}

View file

@ -35,6 +35,7 @@
#include "esp_gattc_api.h"
#include "esp_gatt_defs.h"
#include "esp_bt_main.h"
#include "esp_gatt_common_api.h"
#define GATTC_TAG "SEC_GATTC_DEMO"
#define REMOTE_SERVICE_UUID 0x1809
@ -164,7 +165,7 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
memcpy(gl_profile_tab[PROFILE_A_APP_ID].remote_bda, p_data->open.remote_bda, sizeof(esp_bd_addr_t));
ESP_LOGI(GATTC_TAG, "REMOTE BDA:");
esp_log_buffer_hex(GATTC_TAG, gl_profile_tab[PROFILE_A_APP_ID].remote_bda, sizeof(esp_bd_addr_t));
esp_err_t mtu_ret = esp_ble_gattc_config_mtu (gattc_if, conn_id, 200);
esp_err_t mtu_ret = esp_ble_gattc_send_mtu_req (gattc_if, conn_id);
if (mtu_ret){
ESP_LOGE(GATTC_TAG, "config MTU error, error code = %x", mtu_ret);
}
@ -455,6 +456,10 @@ void app_main()
if (ret){
ESP_LOGE(GATTC_TAG, "%s gattc app register error, error code = %x\n", __func__, ret);
}
ret = esp_ble_gatt_set_local_mtu(200);
if (ret){
ESP_LOGE(GATTC_TAG, "set local MTU failed, error code = %x", ret);
}
}

View file

@ -38,6 +38,7 @@
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "esp_bt_main.h"
#include "esp_gatt_common_api.h"
#include "sdkconfig.h"
@ -722,6 +723,10 @@ void app_main()
ESP_LOGE(GATTS_TAG, "gatts app register error, error code = %x", ret);
return;
}
esp_err_t local_mtu_ret = esp_ble_gatt_set_local_mtu(500);
if (local_mtu_ret){
ESP_LOGE(GATTS_TAG, "set local MTU failed, error code = %x", local_mtu_ret);
}
return;
}

View file

@ -39,6 +39,7 @@
#include "esp_gattc_api.h"
#include "esp_gatt_defs.h"
#include "esp_bt_main.h"
#include "esp_gatt_common_api.h"
#define GATTC_TAG "GATTC_MULTIPLE_DEMO"
#define REMOTE_SERVICE_UUID 0x00FF
@ -166,7 +167,7 @@ static void gattc_profile_a_event_handler(esp_gattc_cb_event_t event, esp_gatt_i
ESP_LOGI(GATTC_TAG, "ESP_GATTC_OPEN_EVT conn_id %d, if %d, status %d, mtu %d", p_data->open.conn_id, gattc_if, p_data->open.status, p_data->open.mtu);
ESP_LOGI(GATTC_TAG, "REMOTE BDA:");
esp_log_buffer_hex(GATTC_TAG, p_data->open.remote_bda, sizeof(esp_bd_addr_t));
esp_err_t mtu_ret = esp_ble_gattc_config_mtu (gattc_if, p_data->open.conn_id, 200);
esp_err_t mtu_ret = esp_ble_gattc_send_mtu_req (gattc_if, p_data->open.conn_id);
if (mtu_ret){
ESP_LOGE(GATTC_TAG, "config MTU error, error code = %x", mtu_ret);
}
@ -306,7 +307,7 @@ static void gattc_profile_b_event_handler(esp_gattc_cb_event_t event, esp_gatt_i
ESP_LOGI(GATTC_TAG, "ESP_GATTC_OPEN_EVT conn_id %d, if %d, status %d, mtu %d", p_data->open.conn_id, gattc_if, p_data->open.status, p_data->open.mtu);
ESP_LOGI(GATTC_TAG, "REMOTE BDA:");
esp_log_buffer_hex(GATTC_TAG, p_data->open.remote_bda, sizeof(esp_bd_addr_t));
esp_err_t mtu_ret = esp_ble_gattc_config_mtu (gattc_if, p_data->open.conn_id, 200);
esp_err_t mtu_ret = esp_ble_gattc_send_mtu_req (gattc_if, p_data->open.conn_id);
if (mtu_ret){
ESP_LOGE(GATTC_TAG, "config MTU error, error code = %x", mtu_ret);
}
@ -439,7 +440,7 @@ static void gattc_profile_c_event_handler(esp_gattc_cb_event_t event, esp_gatt_i
ESP_LOGI(GATTC_TAG, "ESP_GATTC_OPEN_EVT conn_id %d, if %d, status %d, mtu %d", p_data->open.conn_id, gattc_if, p_data->open.status, p_data->open.mtu);
ESP_LOGI(GATTC_TAG, "REMOTE BDA:");
esp_log_buffer_hex(GATTC_TAG, p_data->open.remote_bda, sizeof(esp_bd_addr_t));
esp_err_t mtu_ret = esp_ble_gattc_config_mtu (gattc_if, p_data->open.conn_id, 200);
esp_err_t mtu_ret = esp_ble_gattc_send_mtu_req (gattc_if, p_data->open.conn_id);
if (mtu_ret){
ESP_LOGE(GATTC_TAG, "config MTU error, error code = %x", mtu_ret);
}
@ -748,6 +749,11 @@ void app_main()
ESP_LOGE(GATTC_TAG, "gattc app register error, error code = %x", ret);
return;
}
ret = esp_ble_gatt_set_local_mtu(200);
if (ret){
ESP_LOGE(GATTC_TAG, "set local MTU failed, error code = %x", ret);
}
}