mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
Merge branch 'feat/support_ble_debug_with_gpio_v5.2' into 'release/v5.2'
Support change HID task size by Kconfig in HID example (v5.2) See merge request espressif/esp-idf!36997
This commit is contained in:
commit
d309e7c38a
@ -723,8 +723,6 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s, malloc failed", __func__);
|
||||
}
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s, incorrect length", __func__);
|
||||
}
|
||||
(*p_rcb->p_cback)(BTA_GATTS_CONF_EVT, &cb_data);
|
||||
if (cb_data.req_data.value != NULL) {
|
||||
@ -733,7 +731,7 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
APPL_TRACE_ERROR("Not an registered servce attribute ID: 0x%04x",
|
||||
APPL_TRACE_ERROR("Not a registered service attribute ID: 0x%04x",
|
||||
p_msg->api_indicate.attr_id);
|
||||
}
|
||||
}
|
||||
@ -923,7 +921,7 @@ void bta_gatts_listen(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
**
|
||||
** Function bta_gatts_show_local_database
|
||||
**
|
||||
** Description print loacl service database
|
||||
** Description print local service database
|
||||
**
|
||||
** Returns none.
|
||||
**
|
||||
|
@ -200,7 +200,7 @@ static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status,
|
||||
*p++ = GATT_RSP_READ_MULTI;
|
||||
p_buf->len = 1;
|
||||
|
||||
/* Now walk through the buffers puting the data into the response in order */
|
||||
/* Now walk through the buffers putting the data into the response in order */
|
||||
list_t *list = NULL;
|
||||
const list_node_t *node = NULL;
|
||||
if (! fixed_queue_is_empty(p_cmd->multi_rsp_q)) {
|
||||
@ -321,7 +321,7 @@ static BOOLEAN process_read_multi_var_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS sta
|
||||
*p++ = GATT_RSP_READ_MULTI_VAR;
|
||||
p_buf->len = 1;
|
||||
|
||||
/* Now walk through the buffers puting the data into the response in order */
|
||||
/* Now walk through the buffers putting the data into the response in order */
|
||||
list_t *list = NULL;
|
||||
const list_node_t *node = NULL;
|
||||
if (! fixed_queue_is_empty(p_cmd->multi_rsp_q)) {
|
||||
@ -735,7 +735,7 @@ static tGATT_STATUS gatt_build_primary_service_rsp (BT_HDR *p_msg, tGATT_TCB *p_
|
||||
handle_len = 4 + p_uuid->len;
|
||||
}
|
||||
|
||||
/* get the length byte in the repsonse */
|
||||
/* get the length byte in the response */
|
||||
if (p_msg->offset == 0) {
|
||||
*p ++ = op_code + 1;
|
||||
p_msg->len ++;
|
||||
@ -788,7 +788,7 @@ static tGATT_STATUS gatt_build_primary_service_rsp (BT_HDR *p_msg, tGATT_TCB *p_
|
||||
** buffer.
|
||||
**
|
||||
** Returns TRUE: if data filled successfully.
|
||||
** FALSE: packet full, or format mismatch.
|
||||
** FALSE: packet full.
|
||||
**
|
||||
*******************************************************************************/
|
||||
static tGATT_STATUS gatt_build_find_info_rsp(tGATT_SR_REG *p_rcb, BT_HDR *p_msg, UINT16 *p_len,
|
||||
@ -831,10 +831,9 @@ static tGATT_STATUS gatt_build_find_info_rsp(tGATT_SR_REG *p_rcb, BT_HDR *p_msg,
|
||||
gatt_convert_uuid32_to_uuid128(p, ((tGATT_ATTR32 *) p_attr)->uuid);
|
||||
p += LEN_UUID_128;
|
||||
} else {
|
||||
GATT_TRACE_ERROR("format mismatch");
|
||||
status = GATT_NO_RESOURCES;
|
||||
// UUID format mismatch in sequential attributes
|
||||
// A new request will be sent with the starting handle of the next attribute
|
||||
break;
|
||||
/* format mismatch */
|
||||
}
|
||||
p_msg->len += info_pair_len[p_msg->offset - 1];
|
||||
len -= info_pair_len[p_msg->offset - 1];
|
||||
@ -889,7 +888,7 @@ static tGATT_STATUS gatts_validate_packet_format(UINT8 op_code, UINT16 *p_len,
|
||||
/* parse uuid now */
|
||||
if (gatt_parse_uuid_from_cmd (p_uuid_filter, uuid_len, &p) == FALSE ||
|
||||
p_uuid_filter->len == 0) {
|
||||
GATT_TRACE_DEBUG("UUID filter does not exsit");
|
||||
GATT_TRACE_DEBUG("UUID filter does not exist");
|
||||
reason = GATT_INVALID_PDU;
|
||||
} else {
|
||||
len -= p_uuid_filter->len;
|
||||
@ -1042,7 +1041,7 @@ static void gatts_process_find_info(tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len,
|
||||
**
|
||||
** Function gatts_process_mtu_req
|
||||
**
|
||||
** Description This function is called to process excahnge MTU request.
|
||||
** Description This function is called to process exchange MTU request.
|
||||
** Only used on LE.
|
||||
**
|
||||
** Returns void
|
||||
@ -1055,7 +1054,7 @@ static void gatts_process_mtu_req (tGATT_TCB *p_tcb, UINT16 len, UINT8 *p_data)
|
||||
BT_HDR *p_buf;
|
||||
UINT16 conn_id;
|
||||
|
||||
/* BR/EDR conenction, send error response */
|
||||
/* BR/EDR connection, send error response */
|
||||
if (p_tcb->att_lcid != L2CAP_ATT_CID) {
|
||||
gatt_send_error_rsp (p_tcb, GATT_REQ_NOT_SUPPORTED, GATT_REQ_MTU, 0, FALSE);
|
||||
} else if (len < GATT_MTU_REQ_MIN_LEN) {
|
||||
@ -1081,7 +1080,7 @@ static void gatts_process_mtu_req (tGATT_TCB *p_tcb, UINT16 len, UINT8 *p_data)
|
||||
attp_send_sr_msg (p_tcb, p_buf);
|
||||
|
||||
/* Notify all registered application with new MTU size. Us a transaction ID */
|
||||
/* of 0, as no response is allowed from applcations */
|
||||
/* of 0, as no response is allowed from applications */
|
||||
|
||||
for (i = 0; i < GATT_MAX_APPS; i ++) {
|
||||
if (gatt_cb.cl_rcb[i].in_use ) {
|
||||
@ -1448,7 +1447,7 @@ void gatt_attr_process_prepare_write (tGATT_TCB *p_tcb, UINT8 i_rcb, UINT16 hand
|
||||
}
|
||||
|
||||
if ((prepare_record->error_code_app == GATT_SUCCESS)
|
||||
// update prepare write status for excute write request
|
||||
// update prepare write status for execute write request
|
||||
&& (status == GATT_INVALID_OFFSET || status == GATT_INVALID_ATTR_LEN || status == GATT_REQ_NOT_SUPPORTED)) {
|
||||
prepare_record->error_code_app = status;
|
||||
}
|
||||
@ -1855,7 +1854,7 @@ void gatt_server_handle_client_req (tGATT_TCB *p_tcb, UINT8 op_code,
|
||||
gatts_process_primary_service_req (p_tcb, op_code, len, p_data);
|
||||
break;
|
||||
|
||||
case GATT_REQ_FIND_INFO: /* discover char descrptor */
|
||||
case GATT_REQ_FIND_INFO: /* discover char descriptor */
|
||||
gatts_process_find_info(p_tcb, op_code, len, p_data);
|
||||
break;
|
||||
|
||||
|
17
components/esp_hid/Kconfig
Normal file
17
components/esp_hid/Kconfig
Normal file
@ -0,0 +1,17 @@
|
||||
menu "ESP HID"
|
||||
config ESPHID_TASK_SIZE_BT
|
||||
int "Task stack size for ESP HID BR/EDR"
|
||||
range 2048 10240
|
||||
default 2048
|
||||
help
|
||||
This is the stack size for the BT HID task.
|
||||
Default is 2048 bytes.
|
||||
|
||||
config ESPHID_TASK_SIZE_BLE
|
||||
int "Task stack size for ESP HID BLE"
|
||||
range 2048 10240
|
||||
default 4096
|
||||
help
|
||||
This is the stack size for the BLE HID task.
|
||||
Default is 4096 bytes.
|
||||
endmenu
|
@ -1,16 +1,8 @@
|
||||
// Copyright 2017-2019 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.
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@ -94,6 +86,19 @@ extern "C" {
|
||||
#define ESP_HID_CCC_NOTIFICATIONS_ENABLED 0x01 // Notifications enabled
|
||||
#define ESP_HID_CCC_INDICATIONS_ENABLED 0x02 // Indications enabled
|
||||
|
||||
/* HID Task Size configuration */
|
||||
#ifdef CONFIG_ESPHID_TASK_SIZE_BT
|
||||
#define BT_HID_DEVICE_TASK_SIZE_BT CONFIG_ESPHID_TASK_SIZE_BT
|
||||
#else
|
||||
#define BT_HID_DEVICE_TASK_SIZE_BT 2048
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPHID_TASK_SIZE_BLE
|
||||
#define BT_HID_DEVICE_TASK_SIZE_BLE CONFIG_ESPHID_TASK_SIZE_BLE
|
||||
#else
|
||||
#define BT_HID_DEVICE_TASK_SIZE_BLE 4096
|
||||
#endif
|
||||
|
||||
/* HID Transports */
|
||||
typedef enum {
|
||||
ESP_HID_TRANSPORT_BT,
|
||||
@ -203,8 +208,8 @@ esp_hid_report_map_t *esp_hid_parse_report_map(const uint8_t *hid_rm, size_t hid
|
||||
void esp_hid_free_report_map(esp_hid_report_map_t *map);
|
||||
|
||||
/**
|
||||
* @brief Calculate the HID Device usage type from the BLE Apperance
|
||||
* @param appearance : BLE Apperance value
|
||||
* @brief Calculate the HID Device usage type from the BLE Appearance
|
||||
* @param appearance : BLE Appearance value
|
||||
*
|
||||
* @return: the hid usage type
|
||||
*/
|
||||
|
@ -976,7 +976,7 @@ esp_err_t esp_ble_hidd_dev_init(esp_hidd_dev_t *dev_p, const esp_hid_device_conf
|
||||
.queue_size = 5,
|
||||
.task_name = "ble_hidd_events",
|
||||
.task_priority = uxTaskPriorityGet(NULL),
|
||||
.task_stack_size = 4096,
|
||||
.task_stack_size = BT_HID_DEVICE_TASK_SIZE_BLE,
|
||||
.task_core_id = tskNO_AFFINITY
|
||||
};
|
||||
ret = esp_event_loop_create(&event_task_args, &s_dev->event_loop_handle);
|
||||
|
@ -810,7 +810,7 @@ esp_err_t esp_bt_hidd_dev_init(esp_hidd_dev_t *dev_p, const esp_hid_device_confi
|
||||
.queue_size = 5,
|
||||
.task_name = "bt_hidd_events",
|
||||
.task_priority = uxTaskPriorityGet(NULL),
|
||||
.task_stack_size = 2048,
|
||||
.task_stack_size = BT_HID_DEVICE_TASK_SIZE_BT,
|
||||
.task_core_id = tskNO_AFFINITY
|
||||
};
|
||||
ret = esp_event_loop_create(&event_task_args, &s_hidd_param.dev->event_loop_handle);
|
||||
|
@ -249,7 +249,7 @@ static esp_err_t esp_core_dump_get_regs_from_stack(void* stack_addr,
|
||||
for (int i = 0; i < XT_SOL_AR_NUM; i++) {
|
||||
regs->ar[i] = stack_arr[XT_SOL_AR_START + i];
|
||||
}
|
||||
regs->pc = (regs->pc & 0x3fffffff);
|
||||
|
||||
if (regs->pc & 0x80000000) {
|
||||
regs->pc = (regs->pc & 0x3fffffff);
|
||||
}
|
||||
|
@ -441,6 +441,46 @@ static const esp_gatts_attr_db_t heart_rate_gatt_db[HRS_IDX_NB] =
|
||||
};
|
||||
```
|
||||
|
||||
### 128-bit UUID
|
||||
|
||||
To add characteristics with 128-bit UUIDs, a similar approach is used, but with minor differences.
|
||||
|
||||
Let's suppose we have the following UUID: `12345678-a1b2-c3d4-e5f6-9fafd205e457` and we want to assign it to
|
||||
the `HRS_IDX_128_BIT_LEN_UUID_CHAR` characteristic we also have.
|
||||
|
||||
Here is an example of how this can be done:
|
||||
|
||||
- First, let's declare our UUID
|
||||
|
||||
```c
|
||||
static const uint8_t our_128_bit_uuid_characteristic_uuid[ESP_UUID_LEN_128] = { // ESP_UUID_LEN_128 defined as 16
|
||||
0x57, 0xe4, 0x05, 0xd2, 0xaf, 0x9f, 0xf6, 0xe5, 0xd4, 0xc3, 0xb2, 0xa1, 0x78, 0x56, 0x34, 0x12
|
||||
};
|
||||
```
|
||||
|
||||
> ##### `0x57 0xe4 0x05 0xd2 0xaf 0x9f 0xf6 0xe5 0xd4 0xc3 0xb2 0xa1 0x78 0x56 0x34 0x12` - reversed version of the original UUID represented by uuid_byte_array.
|
||||
|
||||
- Now, all we need is to set `uuid_length` to `ESP_UUID_LEN_128` in the *Characteristic Value* setup.
|
||||
|
||||
> ##### Not to be confused with the *Characteristic Declaration*!
|
||||
|
||||
```c
|
||||
static const esp_gatts_attr_db_t heart_rate_gatt_db[HRS_IDX_NB] =
|
||||
{
|
||||
<...>
|
||||
// 128-bit UUID Characteristic Declaration
|
||||
[HRS_IDX_128_BIT_LEN_UUID_CHAR] =
|
||||
{{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_declaration_uuid, ESP_GATT_PERM_READ,
|
||||
CHAR_DECLARATION_SIZE,CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_notify}},
|
||||
|
||||
// 128-bit UUID Characteristic Value
|
||||
[HRS_IDX_128_BIT_LEN_UUID_VAL] =
|
||||
{{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)&our_128_bit_uuid_characteristic_uuid, ESP_GATT_PERM_READ,
|
||||
THIS_CHAR_VAL_MAX_LEN,0, NULL}},
|
||||
<...>
|
||||
};
|
||||
```
|
||||
|
||||
## Starting the Service
|
||||
When the attribute table is created, an ``ESP_GATTS_CREAT_ATTR_TAB_EVT`` event is triggered. This event has the following parameters:
|
||||
|
||||
@ -495,4 +535,3 @@ struct gatts_profile_inst {
|
||||
This document explains the work flow of the GATT Server Service Table example code that implements a Heart Rate Profile. This example begins by defining a table of attributes which include all the services and characteristics of the server, then it registers the Application Profile which triggers events that are used to configure GAP parameters and to create the service table. A service table is initialized with all the parameters required for each attribute and the service is started. This example shows a practical way of defining the server attributes by using a table instead of adding characteristic one by one.
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user