Skip to content

Commit b06ea40

Browse files
Component/bt: modify set mtu call handler
1 parent 2e33dbf commit b06ea40

File tree

7 files changed

+108
-40
lines changed

7 files changed

+108
-40
lines changed

components/bt/bluedroid/api/esp_gatt_common_api.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "esp_gatt_common_api.h"
1717
#include "esp_bt_main.h"
1818
#include "esp_gatt_defs.h"
19-
#include "btc_main.h"
19+
#include "btc_gatt_common.h"
2020

2121
/**
2222
* @brief This function is called to set local MTU,
@@ -32,7 +32,7 @@
3232
esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu)
3333
{
3434
btc_msg_t msg;
35-
btc_ble_main_args_t arg;
35+
btc_ble_gatt_com_args_t arg;
3636

3737
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
3838

@@ -41,9 +41,9 @@ esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu)
4141
}
4242

4343
msg.sig = BTC_SIG_API_CALL;
44-
msg.pid = BTC_PID_MAIN_INIT;
44+
msg.pid = BTC_PID_GATT_COMMON;
4545
msg.act = BTC_GATT_ACT_SET_LOCAL_MTU;
4646
arg.set_mtu.mtu = mtu;
4747

48-
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_main_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
48+
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatt_com_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
4949
}

components/bt/bluedroid/btc/core/btc_main.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "btc_config.h"
2121
#include "alarm.h"
2222
#include "btc_ble_storage.h"
23-
#include "bta_gatt_common.h"
2423
#include "btc_gap_ble.h"
2524
#include "bta_gattc_int.h"
2625
#include "bta_gatts_int.h"
@@ -88,11 +87,6 @@ static void btc_deinit_bluetooth(void)
8887
future_ready(*btc_main_get_future_p(BTC_MAIN_DEINIT_FUTURE), FUTURE_SUCCESS);
8988
}
9089

91-
static void btc_set_local_mtu(uint16_t mtu)
92-
{
93-
BTA_GATT_SetLocalMTU(mtu);
94-
}
95-
9690
void btc_main_call_handler(btc_msg_t *msg)
9791
{
9892
LOG_DEBUG("%s act %d\n", __func__, msg->act);
@@ -110,12 +104,6 @@ void btc_main_call_handler(btc_msg_t *msg)
110104
case BTC_MAIN_ACT_DISABLE:
111105
btc_disable_bluetooth();
112106
break;
113-
case BTC_GATT_ACT_SET_LOCAL_MTU:
114-
{
115-
btc_ble_main_args_t *arg = (btc_ble_main_args_t *)(msg->arg);
116-
btc_set_local_mtu(arg->set_mtu.mtu);
117-
break;
118-
}
119107
default:
120108
LOG_ERROR("%s UNKNOWN ACT %d\n", __func__, msg->act);
121109
break;

components/bt/bluedroid/btc/core/btc_task.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "btc_dev.h"
2525
#include "btc_gatts.h"
2626
#include "btc_gattc.h"
27+
#include "btc_gatt_common.h"
2728
#include "btc_gap_ble.h"
2829
#include "btc_blufi_prf.h"
2930
#include "btc_dm.h"
@@ -48,33 +49,36 @@ static xTaskHandle xBtcTaskHandle = NULL;
4849
static xQueueHandle xBtcQueue = 0;
4950

5051
static btc_func_t profile_tab[BTC_PID_NUM] = {
51-
[BTC_PID_MAIN_INIT] = {btc_main_call_handler, NULL },
52-
[BTC_PID_DEV] = {btc_dev_call_handler, NULL },
52+
[BTC_PID_MAIN_INIT] = {btc_main_call_handler, NULL },
53+
[BTC_PID_DEV] = {btc_dev_call_handler, NULL },
5354
#if (GATTS_INCLUDED == TRUE)
54-
[BTC_PID_GATTS] = {btc_gatts_call_handler, btc_gatts_cb_handler },
55+
[BTC_PID_GATTS] = {btc_gatts_call_handler, btc_gatts_cb_handler },
5556
#endif ///GATTS_INCLUDED == TRUE
5657
#if (GATTC_INCLUDED == TRUE)
57-
[BTC_PID_GATTC] = {btc_gattc_call_handler, btc_gattc_cb_handler },
58+
[BTC_PID_GATTC] = {btc_gattc_call_handler, btc_gattc_cb_handler },
5859
#endif ///GATTC_INCLUDED == TRUE
59-
[BTC_PID_GAP_BLE] = {btc_gap_ble_call_handler, btc_gap_ble_cb_handler },
60-
[BTC_PID_BLE_HID] = {NULL, NULL},
61-
[BTC_PID_SPPLIKE] = {NULL, NULL},
60+
#if (GATTS_INCLUDED == TRUE || GATTC_INCLUDED == TRUE)
61+
[BTC_PID_GATT_COMMON] = {btc_gatt_com_call_handler, NULL },
62+
#endif //GATTC_INCLUDED == TRUE || GATTS_INCLUDED == TRUE
63+
[BTC_PID_GAP_BLE] = {btc_gap_ble_call_handler, btc_gap_ble_cb_handler },
64+
[BTC_PID_BLE_HID] = {NULL, NULL},
65+
[BTC_PID_SPPLIKE] = {NULL, NULL},
6266
#if (GATTS_INCLUDED == TRUE)
63-
[BTC_PID_BLUFI] = {btc_blufi_call_handler, btc_blufi_cb_handler },
67+
[BTC_PID_BLUFI] = {btc_blufi_call_handler, btc_blufi_cb_handler },
6468
#endif ///GATTS_INCLUDED == TRUE
65-
[BTC_PID_DM_SEC] = {NULL, btc_dm_sec_cb_handler },
66-
[BTC_PID_ALARM] = {btc_alarm_handler, NULL },
69+
[BTC_PID_DM_SEC] = {NULL, btc_dm_sec_cb_handler },
70+
[BTC_PID_ALARM] = {btc_alarm_handler, NULL },
6771
#if CONFIG_CLASSIC_BT_ENABLED
6872
#if (BTC_GAP_BT_INCLUDED == TRUE)
69-
[BTC_PID_GAP_BT] = {btc_gap_bt_call_handler, NULL },
73+
[BTC_PID_GAP_BT] = {btc_gap_bt_call_handler, NULL },
7074
#endif /* (BTC_GAP_BT_INCLUDED == TRUE) */
71-
[BTC_PID_PRF_QUE] = {btc_profile_queue_handler, NULL },
75+
[BTC_PID_PRF_QUE] = {btc_profile_queue_handler, NULL },
7276
#if BTC_AV_INCLUDED
73-
[BTC_PID_A2DP] = {btc_a2dp_call_handler, btc_a2dp_cb_handler },
74-
[BTC_PID_AVRC] = {btc_avrc_call_handler, NULL },
77+
[BTC_PID_A2DP] = {btc_a2dp_call_handler, btc_a2dp_cb_handler },
78+
[BTC_PID_AVRC] = {btc_avrc_call_handler, NULL },
7579
#endif /* #if BTC_AV_INCLUDED */
7680
#if CONFIG_BT_SPP_ENABLED
77-
[BTC_PID_SPP] = {btc_spp_call_handler, btc_spp_cb_handler },
81+
[BTC_PID_SPP] = {btc_spp_call_handler, btc_spp_cb_handler },
7882
#endif /* #if CONFIG_BT_SPP_ENABLED */
7983
#endif /* #if CONFIG_CLASSIC_BT_ENABLED */
8084
};

components/bt/bluedroid/btc/include/btc_main.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ typedef enum {
2626
BTC_MAIN_ACT_DEINIT,
2727
BTC_MAIN_ACT_ENABLE,
2828
BTC_MAIN_ACT_DISABLE,
29-
BTC_GATT_ACT_SET_LOCAL_MTU,
3029
} btc_main_act_t;
3130

3231
typedef enum {
@@ -61,13 +60,5 @@ bt_status_t btc_init_bluetooth(future_t *future);
6160
void btc_deinit_bluetooth(future_t *future);
6261
#endif
6362

64-
/* btc_ble_gattc_args_t */
65-
typedef union {
66-
//BTC_GATT_ACT_SET_LOCAL_MTU,
67-
struct set_mtu_arg {
68-
uint16_t mtu;
69-
} set_mtu;
70-
} btc_ble_main_args_t;
71-
7263
void btc_main_call_handler(btc_msg_t *msg);
7364
#endif /* __BTC_BT_MAIN_H__ */

components/bt/bluedroid/btc/include/btc_task.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ typedef enum {
4141
#if (GATTC_INCLUDED == TRUE)
4242
BTC_PID_GATTC,
4343
#endif ///GATTC_INCLUDED == TRUE
44+
BTC_PID_GATT_COMMON,
4445
BTC_PID_GAP_BLE,
4546
BTC_PID_BLE_HID,
4647
BTC_PID_SPPLIKE,
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "btc_task.h"
16+
#include "btc_main.h"
17+
#include "btc_dm.h"
18+
#include "future.h"
19+
#include "esp_err.h"
20+
#include "btc_config.h"
21+
#include "alarm.h"
22+
#include "btc_ble_storage.h"
23+
#include "btc_gatt_common.h"
24+
#include "bta_gatt_common.h"
25+
26+
27+
static void btc_set_local_mtu(uint16_t mtu)
28+
{
29+
BTA_GATT_SetLocalMTU(mtu);
30+
}
31+
32+
void btc_gatt_com_call_handler(btc_msg_t *msg)
33+
{
34+
LOG_DEBUG("%s act %d\n", __func__, msg->act);
35+
switch (msg->act) {
36+
case BTC_GATT_ACT_SET_LOCAL_MTU:
37+
{
38+
btc_ble_gatt_com_args_t *arg = (btc_ble_gatt_com_args_t *)(msg->arg);
39+
btc_set_local_mtu(arg->set_mtu.mtu);
40+
break;
41+
}
42+
default:
43+
LOG_ERROR("%s UNKNOWN ACT %d\n", __func__, msg->act);
44+
break;
45+
}
46+
}
47+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef __BTC_GATT_COMMON_H__
16+
#define __BTC_GATT_COMMON_H__
17+
18+
#include "future.h"
19+
#include "bt_types.h"
20+
#include "bta_api.h"
21+
#include "btc_main.h"
22+
#include "btc_task.h"
23+
24+
typedef enum {
25+
BTC_GATT_ACT_SET_LOCAL_MTU = 0,
26+
} btc_gatt_com_act_t;
27+
28+
/* btc_ble_gattc_args_t */
29+
typedef union {
30+
//BTC_GATT_ACT_SET_LOCAL_MTU,
31+
struct set_mtu_arg {
32+
uint16_t mtu;
33+
} set_mtu;
34+
} btc_ble_gatt_com_args_t;
35+
36+
void btc_gatt_com_call_handler(btc_msg_t *msg);
37+
#endif /* __BTC_GATT_COMMON_H__ */

0 commit comments

Comments
 (0)