This commit is contained in:
mitchellcairns 2024-09-27 19:34:49 -07:00 committed by GitHub
commit 57986173b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 122 additions and 11 deletions

View File

@ -144,6 +144,13 @@ config BT_HID_DEVICE_ENABLED
help
This enables the BT HID Device
config BT_HID_DEVICE_TASK_SIZE
int "Bluetooth HID event (callback to application) task stack size"
depends on BT_HID_DEVICE_ENABLED
default 4096
help
This selects the esp_hid task size
config BT_BLE_ENABLED
bool "Bluetooth Low Energy"
depends on BT_BLUEDROID_ENABLED

View File

@ -98,6 +98,12 @@ typedef struct {
uint8_t subclass; /*!< HID device subclass */
uint8_t *desc_list; /*!< HID descriptor list */
int desc_list_len; /*!< size in bytes of HID descriptor list */
// DID Profile SDP
uint16_t vendor_id; /*!< HID Vendor ID */
uint16_t product_id; /*!< HID Product ID */
uint16_t version; /*!< HID Product Version */
uint8_t vendor_id_source; /*!< HID Country Code */
} esp_hidd_app_param_t;
/**

View File

@ -175,6 +175,16 @@ void bta_hd_register_act(tBTA_HD_DATA *p_data)
p_app_data->subclass, p_app_data->d_len, p_app_data->d_data);
bta_sys_add_uuid(UUID_SERVCLASS_HUMAN_INTERFACE);
// Set DID Profile SDP Record
tBTA_DI_RECORD bqb_device_info;
bqb_device_info.vendor = p_app_data->vendor_id;
bqb_device_info.vendor_id_source = p_app_data->vendor_id_source;
bqb_device_info.product = p_app_data->product_id;
bqb_device_info.version = p_app_data->version;
bqb_device_info.primary_record = TRUE;
BTA_DmSetLocalDiRecord(&bqb_device_info, &bta_hd_cb.sdp_handle);
HID_DevSetIncomingQos(p_app_data->in_qos.service_type, p_app_data->in_qos.token_rate,
p_app_data->in_qos.token_bucket_size, p_app_data->in_qos.peak_bandwidth,
p_app_data->in_qos.access_latency, p_app_data->in_qos.delay_variation);

View File

@ -114,6 +114,13 @@ extern void BTA_HdRegisterApp(tBTA_HD_APP_INFO *p_app_info, tBTA_HD_QOS_INFO *p_
p_buf->subclass = p_app_info->subclass;
p_buf->d_len = p_app_info->descriptor.dl_len;
memcpy(p_buf->d_data, p_app_info->descriptor.dsc_list, p_app_info->descriptor.dl_len);
// copy DID profile SDP info
p_buf->vendor_id = p_app_info->vendor_id;
p_buf->product_id = p_app_info->product_id;
p_buf->version = p_app_info->version;
p_buf->vendor_id_source = p_app_info->vendor_id_source;
// copy qos data as-is
memcpy(&p_buf->in_qos, p_in_qos, sizeof(tBTA_HD_QOS_INFO));
memcpy(&p_buf->out_qos, p_out_qos, sizeof(tBTA_HD_QOS_INFO));

View File

@ -75,6 +75,13 @@ typedef struct {
uint8_t subclass;
uint16_t d_len;
uint8_t d_data[BTA_HD_APP_DESCRIPTOR_LEN];
// DID SDP Information (Device Information)
uint16_t vendor_id;
uint16_t product_id;
uint16_t version;
uint8_t vendor_id_source;
tBTA_HD_QOS_INFO in_qos;
tBTA_HD_QOS_INFO out_qos;
} tBTA_HD_REGISTER_APP;

View File

@ -69,6 +69,13 @@ typedef struct {
char *p_description;
char *p_provider;
uint8_t subclass;
// SDP Idenification info
uint16_t vendor_id; // 0x0201
uint16_t product_id; // 0x0202
uint16_t version; // 0x0203
uint8_t vendor_id_source; // 0x0205
tBTA_HD_DEV_DESCR descriptor;
} tBTA_HD_APP_INFO;

View File

@ -341,6 +341,13 @@ static void btc_hd_register_app(esp_hidd_app_param_t *p_app_param, esp_hidd_qos_
btc_hd_cb.out_qos.access_latency = p_out_qos->access_latency;
btc_hd_cb.out_qos.delay_variation = p_out_qos->delay_variation;
// Copy SDP record information for DID (Device Identification Profile)
btc_hd_cb.app_info.vendor_id = p_app_param->vendor_id;
btc_hd_cb.app_info.product_id = p_app_param->product_id;
btc_hd_cb.app_info.version = p_app_param->version;
btc_hd_cb.app_info.vendor_id_source = p_app_param->vendor_id_source;
BTA_HdRegisterApp(&btc_hd_cb.app_info, &btc_hd_cb.in_qos, &btc_hd_cb.out_qos);
} while(0);

View File

@ -1503,7 +1503,8 @@
#endif
#ifndef SDP_MAX_PAD_LEN
#define SDP_MAX_PAD_LEN 300
// HHL Custom Code we have to increase this to 500 to fit the full procon descriptor
#define SDP_MAX_PAD_LEN 500
#endif
/* The maximum length, in bytes, of an attribute. */

View File

@ -199,15 +199,20 @@ tBTM_STATUS BTM_SetPowerMode (UINT8 pm_id, BD_ADDR remote_bda, tBTM_PM_PWR_MD *p
}
p_cb = p_acl_cb->p_pm_mode_db;
if (mode != BTM_PM_MD_ACTIVE) {
/* check if the requested mode is supported */
ind = mode - BTM_PM_MD_HOLD; /* make it base 0 */
p_features = BTM_ReadLocalFeatures();
if ( !(p_features[ btm_pm_mode_off[ind] ] & btm_pm_mode_msk[ind] ) ) {
//#if BTM_PM_DEBUG == TRUE
BTM_TRACE_DEBUG( "BTM_SetPowerMode: Unsupported BTM Mode");
//#endif
return BTM_MODE_UNSUPPORTED;
}
}
if (mode == p_cb->state) { /* the requested mode is current mode */
/* already in the requested mode and the current interval has less latency than the max */
if ( (mode == BTM_PM_MD_ACTIVE) ||
@ -228,18 +233,18 @@ tBTM_STATUS BTM_SetPowerMode (UINT8 pm_id, BD_ADDR remote_bda, tBTM_PM_PWR_MD *p
(btm_cb.pm_reg_db[pm_id].mask & BTM_PM_REG_SET))
|| ((pm_id == BTM_PM_SET_ONLY_ID)
&& (btm_cb.pm_pend_link_hdl != BTM_INVALID_HANDLE)) ) {
#if BTM_PM_DEBUG == TRUE
//#if BTM_PM_DEBUG == TRUE
BTM_TRACE_DEBUG( "BTM_SetPowerMode: Saving cmd acl handle %d temp_pm_id %d", p_acl_cb->hci_handle, temp_pm_id);
#endif // BTM_PM_DEBUG
//#endif // BTM_PM_DEBUG
/* Make sure mask is set to BTM_PM_REG_SET */
btm_cb.pm_reg_db[temp_pm_id].mask |= BTM_PM_REG_SET;
*(&p_cb->req_mode[temp_pm_id]) = *((tBTM_PM_PWR_MD *)p_mode);
p_cb->chg_ind = TRUE;
}
#if BTM_PM_DEBUG == TRUE
//#if BTM_PM_DEBUG == TRUE
BTM_TRACE_DEBUG( "btm_pm state:0x%x, pm_pend_link_hdl: %d", p_cb->state, btm_cb.pm_pend_link_hdl);
#endif // BTM_PM_DEBUG
//#endif // BTM_PM_DEBUG
/* if mode == hold or pending, return */
if ( (p_cb->state == BTM_PM_STS_HOLD) ||
(p_cb->state == BTM_PM_STS_PENDING) ||
@ -739,6 +744,16 @@ void btm_pm_proc_cmd_status(UINT8 status)
btm_pm_check_stored();
}
__attribute__((weak))
void btm_hcif_mode_change_cb(BOOLEAN succeeded, UINT16 hci_handle, UINT8 mode, UINT16 interval)
{
// This is the weak implementation, which will be overwritten
(void) succeeded;
(void) hci_handle;
(void) mode;
(void) interval;
}
/*******************************************************************************
**
** Function btm_process_mode_change
@ -755,6 +770,12 @@ void btm_pm_proc_cmd_status(UINT8 status)
*******************************************************************************/
void btm_pm_proc_mode_change (UINT8 hci_status, UINT16 hci_handle, UINT8 mode, UINT16 interval)
{
bool success = (hci_status == HCI_SUCCESS) ? true : false;
/* Custom HHL Code Callback */
btm_hcif_mode_change_cb(success, hci_handle, mode, interval);
// test not using the rest
return;
tACL_CONN *p;
tBTM_PM_MCB *p_cb = NULL;
int yy;

View File

@ -1089,6 +1089,11 @@ BOOLEAN btm_acl_notif_conn_collision (BD_ADDR bda);
void btm_pm_reset(void);
tBTM_PM_MCB *btm_pm_sm_alloc(void);
void btm_pm_proc_cmd_status(UINT8 status);
// Custom code
void btm_hcif_mode_change_interval(UINT8 mode, UINT16 interval);
// end custom code
void btm_pm_proc_mode_change (UINT8 hci_status, UINT16 hci_handle, UINT8 mode,
UINT16 interval);
void btm_pm_proc_ssr_evt (UINT8 *p, UINT16 evt_len);

View File

@ -749,6 +749,15 @@ BOOLEAN btsnd_hcic_hold_mode (UINT16 handle, UINT16 max_hold_period,
return (TRUE);
}
__attribute__((weak))
void btsnd_hcic_sniff_mode_cb(BOOLEAN sniff, UINT16 tx_lat, UINT16 rx_lat)
{
// This is the weak implementation, which will be overwritten
(void) sniff;
(void) tx_lat;
(void) rx_lat;
}
BOOLEAN btsnd_hcic_sniff_mode (UINT16 handle, UINT16 max_sniff_period,
UINT16 min_sniff_period, UINT16 sniff_attempt,
UINT16 sniff_timeout)
@ -774,6 +783,12 @@ BOOLEAN btsnd_hcic_sniff_mode (UINT16 handle, UINT16 max_sniff_period,
UINT16_TO_STREAM (pp, sniff_attempt);
UINT16_TO_STREAM (pp, sniff_timeout);
// HHL Custom Code
btsnd_hcic_sniff_mode_cb(true, min_sniff_period, max_sniff_period);
// Try ignoring the commands for now
return (TRUE);
// End custom code
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
HCI_TRACE_WARNING("hci cmd send: sniff: hdl 0x%x, intv(%d %d)",
handle, min_sniff_period, max_sniff_period);
@ -801,6 +816,10 @@ BOOLEAN btsnd_hcic_exit_sniff_mode (UINT16 handle)
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
HCI_TRACE_WARNING("hci cmd send: unsniff: hdl 0x%x", handle);
// HHL Custom Code
btsnd_hcic_sniff_mode_cb(false, 0, 0);
return TRUE;
}

View File

@ -23,6 +23,11 @@ extern "C" {
#include <stdbool.h>
#include <stdio.h>
/* HID BT Task Size Def */
#ifndef BT_HID_DEVICE_TASK_SIZE
#define BT_HID_DEVICE_TASK_SIZE 4096
#endif
/* HID Report Map Values */
#define HID_RM_INPUT 0x80
#define HID_RM_OUTPUT 0x90

View File

@ -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,
.task_core_id = tskNO_AFFINITY
};
ret = esp_event_loop_create(&event_task_args, &s_dev->event_loop_handle);

View File

@ -282,6 +282,12 @@ static void bt_hidd_init_app(void)
s_hidd_param.app_param.subclass = get_subclass_by_appearance(s_hidd_param.dev->appearance);
s_hidd_param.app_param.desc_list = (uint8_t *)s_hidd_param.dev->devices[0].reports_map.data;
s_hidd_param.app_param.desc_list_len = s_hidd_param.dev->devices[0].reports_map.len;
// Information SDP
s_hidd_param.app_param.vendor_id = p_config->vendor_id;
s_hidd_param.app_param.product_id = p_config->product_id;
s_hidd_param.app_param.version = p_config->version;
s_hidd_param.app_param.vendor_id_source = s_hidd_param.app_param.vendor_id_source;
}
static void bt_hidd_init_qos(void)
@ -637,7 +643,7 @@ void bt_hidd_cb(esp_hidd_cb_event_t event, esp_hidd_cb_param_t *param)
p_rpt = get_report_by_id_and_type(s_hidd_param.dev, param->get_report.report_id, param->get_report.report_type,
&map_index);
if (p_rpt == NULL) {
ESP_LOGE(TAG, "Can not find report!");
ESP_LOGE(TAG, "Can not find report EVT: %d", param->get_report.report_id);
esp_bt_hid_device_report_error(ESP_HID_PAR_HANDSHAKE_RSP_ERR_INVALID_REP_ID);
break;
}
@ -678,7 +684,7 @@ void bt_hidd_cb(esp_hidd_cb_event_t event, esp_hidd_cb_param_t *param)
p_rpt = get_report_by_id_and_type(s_hidd_param.dev, param->set_report.report_id, param->set_report.report_type,
&map_index);
if (p_rpt == NULL) {
ESP_LOGE(TAG, "Can not find report!");
ESP_LOGE(TAG, "Can not find report SET: %d", param->set_report.report_type);
esp_bt_hid_device_report_error(ESP_HID_PAR_HANDSHAKE_RSP_ERR_INVALID_REP_ID);
break;
}
@ -715,6 +721,9 @@ void bt_hidd_cb(esp_hidd_cb_event_t event, esp_hidd_cb_param_t *param)
break;
}
case ESP_HIDD_SET_PROTOCOL_EVT: {
ESP_LOGI(TAG, "Ignoring protocol mode change.");
break;
if (param->set_protocol.protocol_mode != ESP_HIDD_UNSUPPORTED_MODE) {
osi_mutex_lock(&s_hidd_param.mutex, OSI_MUTEX_MAX_TIMEOUT);
s_hidd_param.dev->protocol_mode =
@ -722,7 +731,7 @@ void bt_hidd_cb(esp_hidd_cb_event_t event, esp_hidd_cb_param_t *param)
osi_mutex_unlock(&s_hidd_param.mutex);
cb_param.protocol_mode.dev = s_hidd_param.dev->dev;
cb_param.protocol_mode.protocol_mode = s_hidd_param.dev->protocol_mode;
cb_param.protocol_mode.map_index = 0;
//cb_param.protocol_mode.map_index = 0;
esp_event_post_to(s_hidd_param.dev->event_loop_handle, ESP_HIDD_EVENTS, ESP_HIDD_PROTOCOL_MODE_EVENT,
&cb_param, sizeof(esp_hidd_event_data_t), portMAX_DELAY);
} else {
@ -735,7 +744,7 @@ void bt_hidd_cb(esp_hidd_cb_event_t event, esp_hidd_cb_param_t *param)
p_rpt = get_report_by_id_and_type(s_hidd_param.dev, param->intr_data.report_id, ESP_HID_REPORT_TYPE_OUTPUT,
&map_index);
if (p_rpt == NULL) {
ESP_LOGE(TAG, "Can not find report!");
ESP_LOGE(TAG, "Can not find report INTR: %d", param->intr_data.report_id);
break;
}
@ -810,7 +819,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,
.task_core_id = tskNO_AFFINITY
};
ret = esp_event_loop_create(&event_task_args, &s_hidd_param.dev->event_loop_handle);