mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
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:
commit
9ecd718f72
@ -16,7 +16,7 @@
|
|||||||
#include "esp_gatt_common_api.h"
|
#include "esp_gatt_common_api.h"
|
||||||
#include "esp_bt_main.h"
|
#include "esp_bt_main.h"
|
||||||
#include "esp_gatt_defs.h"
|
#include "esp_gatt_defs.h"
|
||||||
#include "btc_main.h"
|
#include "btc_gatt_common.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function is called to set local MTU,
|
* @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)
|
esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu)
|
||||||
{
|
{
|
||||||
btc_msg_t msg;
|
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);
|
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.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;
|
msg.act = BTC_GATT_ACT_SET_LOCAL_MTU;
|
||||||
arg.set_mtu.mtu = 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);
|
||||||
}
|
}
|
@ -20,7 +20,6 @@
|
|||||||
#include "btc_config.h"
|
#include "btc_config.h"
|
||||||
#include "alarm.h"
|
#include "alarm.h"
|
||||||
#include "btc_ble_storage.h"
|
#include "btc_ble_storage.h"
|
||||||
#include "bta_gatt_common.h"
|
|
||||||
#include "btc_gap_ble.h"
|
#include "btc_gap_ble.h"
|
||||||
#include "bta_gattc_int.h"
|
#include "bta_gattc_int.h"
|
||||||
#include "bta_gatts_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);
|
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)
|
void btc_main_call_handler(btc_msg_t *msg)
|
||||||
{
|
{
|
||||||
LOG_DEBUG("%s act %d\n", __func__, msg->act);
|
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:
|
case BTC_MAIN_ACT_DISABLE:
|
||||||
btc_disable_bluetooth();
|
btc_disable_bluetooth();
|
||||||
break;
|
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:
|
default:
|
||||||
LOG_ERROR("%s UNKNOWN ACT %d\n", __func__, msg->act);
|
LOG_ERROR("%s UNKNOWN ACT %d\n", __func__, msg->act);
|
||||||
break;
|
break;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "btc_dev.h"
|
#include "btc_dev.h"
|
||||||
#include "btc_gatts.h"
|
#include "btc_gatts.h"
|
||||||
#include "btc_gattc.h"
|
#include "btc_gattc.h"
|
||||||
|
#include "btc_gatt_common.h"
|
||||||
#include "btc_gap_ble.h"
|
#include "btc_gap_ble.h"
|
||||||
#include "btc_blufi_prf.h"
|
#include "btc_blufi_prf.h"
|
||||||
#include "btc_dm.h"
|
#include "btc_dm.h"
|
||||||
@ -56,6 +57,9 @@ static btc_func_t profile_tab[BTC_PID_NUM] = {
|
|||||||
#if (GATTC_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
|
#endif ///GATTC_INCLUDED == TRUE
|
||||||
|
#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_GAP_BLE] = {btc_gap_ble_call_handler, btc_gap_ble_cb_handler },
|
||||||
[BTC_PID_BLE_HID] = {NULL, NULL},
|
[BTC_PID_BLE_HID] = {NULL, NULL},
|
||||||
[BTC_PID_SPPLIKE] = {NULL, NULL},
|
[BTC_PID_SPPLIKE] = {NULL, NULL},
|
||||||
|
@ -26,7 +26,6 @@ typedef enum {
|
|||||||
BTC_MAIN_ACT_DEINIT,
|
BTC_MAIN_ACT_DEINIT,
|
||||||
BTC_MAIN_ACT_ENABLE,
|
BTC_MAIN_ACT_ENABLE,
|
||||||
BTC_MAIN_ACT_DISABLE,
|
BTC_MAIN_ACT_DISABLE,
|
||||||
BTC_GATT_ACT_SET_LOCAL_MTU,
|
|
||||||
} btc_main_act_t;
|
} btc_main_act_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -61,13 +60,5 @@ bt_status_t btc_init_bluetooth(future_t *future);
|
|||||||
void btc_deinit_bluetooth(future_t *future);
|
void btc_deinit_bluetooth(future_t *future);
|
||||||
#endif
|
#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);
|
void btc_main_call_handler(btc_msg_t *msg);
|
||||||
#endif /* __BTC_BT_MAIN_H__ */
|
#endif /* __BTC_BT_MAIN_H__ */
|
||||||
|
@ -41,6 +41,7 @@ typedef enum {
|
|||||||
#if (GATTC_INCLUDED == TRUE)
|
#if (GATTC_INCLUDED == TRUE)
|
||||||
BTC_PID_GATTC,
|
BTC_PID_GATTC,
|
||||||
#endif ///GATTC_INCLUDED == TRUE
|
#endif ///GATTC_INCLUDED == TRUE
|
||||||
|
BTC_PID_GATT_COMMON,
|
||||||
BTC_PID_GAP_BLE,
|
BTC_PID_GAP_BLE,
|
||||||
BTC_PID_BLE_HID,
|
BTC_PID_BLE_HID,
|
||||||
BTC_PID_SPPLIKE,
|
BTC_PID_SPPLIKE,
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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__ */
|
Loading…
x
Reference in New Issue
Block a user