Merge branch 'bugfix/btdm_modify_set_mtu_call_handler' into 'master'

Component/bt: modify set mtu call handler

See merge request idf/esp-idf!1850
This commit is contained in:
Jiang Jiang Jian 2018-02-01 20:19:52 +08:00
commit 9ecd718f72
7 changed files with 108 additions and 40 deletions

View file

@ -16,7 +16,7 @@
#include "esp_gatt_common_api.h"
#include "esp_bt_main.h"
#include "esp_gatt_defs.h"
#include "btc_main.h"
#include "btc_gatt_common.h"
/**
* @brief This function is called to set local MTU,
@ -32,7 +32,7 @@
esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu)
{
btc_msg_t msg;
btc_ble_main_args_t arg;
btc_ble_gatt_com_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
@ -41,9 +41,9 @@ esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu)
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_MAIN_INIT;
msg.pid = BTC_PID_GATT_COMMON;
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);
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatt_com_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}

View file

@ -20,7 +20,6 @@
#include "btc_config.h"
#include "alarm.h"
#include "btc_ble_storage.h"
#include "bta_gatt_common.h"
#include "btc_gap_ble.h"
#include "bta_gattc_int.h"
#include "bta_gatts_int.h"
@ -88,11 +87,6 @@ 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);
@ -110,12 +104,6 @@ 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

@ -24,6 +24,7 @@
#include "btc_dev.h"
#include "btc_gatts.h"
#include "btc_gattc.h"
#include "btc_gatt_common.h"
#include "btc_gap_ble.h"
#include "btc_blufi_prf.h"
#include "btc_dm.h"
@ -48,33 +49,36 @@ static xTaskHandle xBtcTaskHandle = NULL;
static xQueueHandle xBtcQueue = 0;
static btc_func_t profile_tab[BTC_PID_NUM] = {
[BTC_PID_MAIN_INIT] = {btc_main_call_handler, NULL },
[BTC_PID_DEV] = {btc_dev_call_handler, NULL },
[BTC_PID_MAIN_INIT] = {btc_main_call_handler, NULL },
[BTC_PID_DEV] = {btc_dev_call_handler, NULL },
#if (GATTS_INCLUDED == TRUE)
[BTC_PID_GATTS] = {btc_gatts_call_handler, btc_gatts_cb_handler },
[BTC_PID_GATTS] = {btc_gatts_call_handler, btc_gatts_cb_handler },
#endif ///GATTS_INCLUDED == TRUE
#if (GATTC_INCLUDED == TRUE)
[BTC_PID_GATTC] = {btc_gattc_call_handler, btc_gattc_cb_handler },
[BTC_PID_GATTC] = {btc_gattc_call_handler, btc_gattc_cb_handler },
#endif ///GATTC_INCLUDED == TRUE
[BTC_PID_GAP_BLE] = {btc_gap_ble_call_handler, btc_gap_ble_cb_handler },
[BTC_PID_BLE_HID] = {NULL, NULL},
[BTC_PID_SPPLIKE] = {NULL, NULL},
#if (GATTS_INCLUDED == TRUE || GATTC_INCLUDED == TRUE)
[BTC_PID_GATT_COMMON] = {btc_gatt_com_call_handler, NULL },
#endif //GATTC_INCLUDED == TRUE || GATTS_INCLUDED == TRUE
[BTC_PID_GAP_BLE] = {btc_gap_ble_call_handler, btc_gap_ble_cb_handler },
[BTC_PID_BLE_HID] = {NULL, NULL},
[BTC_PID_SPPLIKE] = {NULL, NULL},
#if (GATTS_INCLUDED == TRUE)
[BTC_PID_BLUFI] = {btc_blufi_call_handler, btc_blufi_cb_handler },
[BTC_PID_BLUFI] = {btc_blufi_call_handler, btc_blufi_cb_handler },
#endif ///GATTS_INCLUDED == TRUE
[BTC_PID_DM_SEC] = {NULL, btc_dm_sec_cb_handler },
[BTC_PID_ALARM] = {btc_alarm_handler, NULL },
[BTC_PID_DM_SEC] = {NULL, btc_dm_sec_cb_handler },
[BTC_PID_ALARM] = {btc_alarm_handler, NULL },
#if CONFIG_CLASSIC_BT_ENABLED
#if (BTC_GAP_BT_INCLUDED == TRUE)
[BTC_PID_GAP_BT] = {btc_gap_bt_call_handler, NULL },
[BTC_PID_GAP_BT] = {btc_gap_bt_call_handler, NULL },
#endif /* (BTC_GAP_BT_INCLUDED == TRUE) */
[BTC_PID_PRF_QUE] = {btc_profile_queue_handler, NULL },
[BTC_PID_PRF_QUE] = {btc_profile_queue_handler, NULL },
#if BTC_AV_INCLUDED
[BTC_PID_A2DP] = {btc_a2dp_call_handler, btc_a2dp_cb_handler },
[BTC_PID_AVRC] = {btc_avrc_call_handler, NULL },
[BTC_PID_A2DP] = {btc_a2dp_call_handler, btc_a2dp_cb_handler },
[BTC_PID_AVRC] = {btc_avrc_call_handler, NULL },
#endif /* #if BTC_AV_INCLUDED */
#if CONFIG_BT_SPP_ENABLED
[BTC_PID_SPP] = {btc_spp_call_handler, btc_spp_cb_handler },
[BTC_PID_SPP] = {btc_spp_call_handler, btc_spp_cb_handler },
#endif /* #if CONFIG_BT_SPP_ENABLED */
#endif /* #if CONFIG_CLASSIC_BT_ENABLED */
};

View file

@ -26,7 +26,6 @@ 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 {
@ -61,13 +60,5 @@ 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

@ -41,6 +41,7 @@ typedef enum {
#if (GATTC_INCLUDED == TRUE)
BTC_PID_GATTC,
#endif ///GATTC_INCLUDED == TRUE
BTC_PID_GATT_COMMON,
BTC_PID_GAP_BLE,
BTC_PID_BLE_HID,
BTC_PID_SPPLIKE,

View file

@ -0,0 +1,47 @@
// 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.
#include "btc_task.h"
#include "btc_main.h"
#include "btc_dm.h"
#include "future.h"
#include "esp_err.h"
#include "btc_config.h"
#include "alarm.h"
#include "btc_ble_storage.h"
#include "btc_gatt_common.h"
#include "bta_gatt_common.h"
static void btc_set_local_mtu(uint16_t mtu)
{
BTA_GATT_SetLocalMTU(mtu);
}
void btc_gatt_com_call_handler(btc_msg_t *msg)
{
LOG_DEBUG("%s act %d\n", __func__, msg->act);
switch (msg->act) {
case BTC_GATT_ACT_SET_LOCAL_MTU:
{
btc_ble_gatt_com_args_t *arg = (btc_ble_gatt_com_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

@ -0,0 +1,37 @@
// 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.
#ifndef __BTC_GATT_COMMON_H__
#define __BTC_GATT_COMMON_H__
#include "future.h"
#include "bt_types.h"
#include "bta_api.h"
#include "btc_main.h"
#include "btc_task.h"
typedef enum {
BTC_GATT_ACT_SET_LOCAL_MTU = 0,
} btc_gatt_com_act_t;
/* btc_ble_gattc_args_t */
typedef union {
//BTC_GATT_ACT_SET_LOCAL_MTU,
struct set_mtu_arg {
uint16_t mtu;
} set_mtu;
} btc_ble_gatt_com_args_t;
void btc_gatt_com_call_handler(btc_msg_t *msg);
#endif /* __BTC_GATT_COMMON_H__ */