forked from espressif/esp-idf
refactor(esp_hid): Format the code with astyle
This commit is contained in:
@@ -141,7 +141,6 @@ struct esp_ble_hidd_dev_s {
|
|||||||
esp_hid_device_config_t config;
|
esp_hid_device_config_t config;
|
||||||
uint16_t appearance;
|
uint16_t appearance;
|
||||||
|
|
||||||
|
|
||||||
bool connected;
|
bool connected;
|
||||||
uint16_t conn_id;
|
uint16_t conn_id;
|
||||||
esp_bd_addr_t remote_bda;
|
esp_bd_addr_t remote_bda;
|
||||||
@@ -158,7 +157,6 @@ struct esp_ble_hidd_dev_s {
|
|||||||
uint16_t bat_level_handle;
|
uint16_t bat_level_handle;
|
||||||
uint16_t bat_ccc_handle;
|
uint16_t bat_ccc_handle;
|
||||||
|
|
||||||
|
|
||||||
uint8_t pnp[7];
|
uint8_t pnp[7];
|
||||||
|
|
||||||
hidd_dev_map_t *devices;
|
hidd_dev_map_t *devices;
|
||||||
@@ -173,7 +171,6 @@ static const uint8_t hidInfo[4] = {
|
|||||||
ESP_HID_FLAGS_REMOTE_WAKE | ESP_HID_FLAGS_NORMALLY_CONNECTABLE // Flags
|
ESP_HID_FLAGS_REMOTE_WAKE | ESP_HID_FLAGS_NORMALLY_CONNECTABLE // Flags
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define WAIT_CB(d) xSemaphoreTake(d->sem, portMAX_DELAY)
|
#define WAIT_CB(d) xSemaphoreTake(d->sem, portMAX_DELAY)
|
||||||
#define SEND_CB(d) xSemaphoreGive(d->sem)
|
#define SEND_CB(d) xSemaphoreGive(d->sem)
|
||||||
|
|
||||||
@@ -335,7 +332,6 @@ static esp_err_t create_hid_db(esp_ble_hidd_dev_t *dev, int device_index)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void link_report_handles(hidd_dev_map_t *dev, uint16_t *handles)
|
static void link_report_handles(hidd_dev_map_t *dev, uint16_t *handles)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -971,7 +967,6 @@ esp_err_t esp_ble_hidd_dev_init(esp_hidd_dev_t *dev_p, const esp_hid_device_conf
|
|||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_event_loop_args_t event_task_args = {
|
esp_event_loop_args_t event_task_args = {
|
||||||
.queue_size = 5,
|
.queue_size = 5,
|
||||||
.task_name = "ble_hidd_events",
|
.task_name = "ble_hidd_events",
|
||||||
|
@@ -396,7 +396,6 @@ void esp_hidh_gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gatt
|
|||||||
SEND_CB();//return from open
|
SEND_CB();//return from open
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case ESP_GATTC_READ_CHAR_EVT:
|
case ESP_GATTC_READ_CHAR_EVT:
|
||||||
case ESP_GATTC_READ_DESCR_EVT: {
|
case ESP_GATTC_READ_DESCR_EVT: {
|
||||||
dev = esp_hidh_dev_get_by_conn_id(p_data->read.conn_id);
|
dev = esp_hidh_dev_get_by_conn_id(p_data->read.conn_id);
|
||||||
|
@@ -43,8 +43,7 @@ typedef struct {
|
|||||||
uint8_t devices_len;
|
uint8_t devices_len;
|
||||||
} esp_bt_hidd_dev_t;
|
} esp_bt_hidd_dev_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
osi_mutex_t mutex;
|
osi_mutex_t mutex;
|
||||||
esp_bt_hidd_dev_t *dev;
|
esp_bt_hidd_dev_t *dev;
|
||||||
esp_hidd_app_param_t app_param;
|
esp_hidd_app_param_t app_param;
|
||||||
|
@@ -55,7 +55,8 @@ static const char *s_esp_hh_status_names[] = {"OK",
|
|||||||
"NO_DATA",
|
"NO_DATA",
|
||||||
"NEED_INIT",
|
"NEED_INIT",
|
||||||
"NEED_DEINIT",
|
"NEED_DEINIT",
|
||||||
"NO_CONNECTION"};
|
"NO_CONNECTION"
|
||||||
|
};
|
||||||
|
|
||||||
static esp_hidh_dev_t *hidh_dev_ctor(esp_bd_addr_t bda);
|
static esp_hidh_dev_t *hidh_dev_ctor(esp_bd_addr_t bda);
|
||||||
|
|
||||||
|
@@ -45,7 +45,6 @@ typedef enum {
|
|||||||
PARSE_WAIT_USAGE_PAGE, PARSE_WAIT_USAGE, PARSE_WAIT_COLLECTION_APPLICATION, PARSE_WAIT_END_COLLECTION
|
PARSE_WAIT_USAGE_PAGE, PARSE_WAIT_USAGE, PARSE_WAIT_COLLECTION_APPLICATION, PARSE_WAIT_END_COLLECTION
|
||||||
} s_parse_step_t;
|
} s_parse_step_t;
|
||||||
|
|
||||||
|
|
||||||
static s_parse_step_t s_parse_step = PARSE_WAIT_USAGE_PAGE;
|
static s_parse_step_t s_parse_step = PARSE_WAIT_USAGE_PAGE;
|
||||||
static uint8_t s_collection_depth = 0;
|
static uint8_t s_collection_depth = 0;
|
||||||
static hid_report_params_t s_report_params = {0,};
|
static hid_report_params_t s_report_params = {0,};
|
||||||
@@ -192,7 +191,6 @@ static int handle_report(hid_report_params_t *report, bool first)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int parse_cmd(const uint8_t *data, size_t len, size_t index, hid_report_cmd_t **out)
|
static int parse_cmd(const uint8_t *data, size_t len, size_t index, hid_report_cmd_t **out)
|
||||||
{
|
{
|
||||||
if (index == len) {
|
if (index == len) {
|
||||||
@@ -334,7 +332,6 @@ static int handle_cmd(hid_report_cmd_t *cmd)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_hid_report_map_t *esp_hid_parse_report_map(const uint8_t *hid_rm, size_t hid_rm_len)
|
esp_hid_report_map_t *esp_hid_parse_report_map(const uint8_t *hid_rm, size_t hid_rm_len)
|
||||||
{
|
{
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
|
@@ -37,7 +37,6 @@ static inline void unlock_devices(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Public Functions
|
* Public Functions
|
||||||
* */
|
* */
|
||||||
@@ -504,7 +503,6 @@ esp_err_t esp_hidh_dev_report_maps_get(esp_hidh_dev_t *dev, size_t *num_maps, es
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Private Functions
|
* Private Functions
|
||||||
* */
|
* */
|
||||||
|
@@ -32,7 +32,6 @@
|
|||||||
static const char *TAG = "NIMBLE_HIDD";
|
static const char *TAG = "NIMBLE_HIDD";
|
||||||
#define BLE_SVC_BAS_UUID16 0x180F
|
#define BLE_SVC_BAS_UUID16 0x180F
|
||||||
|
|
||||||
|
|
||||||
typedef struct esp_ble_hidd_dev_s esp_ble_hidd_dev_t;
|
typedef struct esp_ble_hidd_dev_s esp_ble_hidd_dev_t;
|
||||||
// there can be only one BLE HID device
|
// there can be only one BLE HID device
|
||||||
static esp_ble_hidd_dev_t *s_dev = NULL;
|
static esp_ble_hidd_dev_t *s_dev = NULL;
|
||||||
@@ -48,8 +47,6 @@ typedef struct {
|
|||||||
uint16_t hid_protocol_handle;
|
uint16_t hid_protocol_handle;
|
||||||
} hidd_dev_map_t;
|
} hidd_dev_map_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct esp_ble_hidd_dev_s {
|
struct esp_ble_hidd_dev_s {
|
||||||
esp_hidd_dev_t *dev;
|
esp_hidd_dev_t *dev;
|
||||||
esp_event_loop_handle_t event_loop_handle;
|
esp_event_loop_handle_t event_loop_handle;
|
||||||
@@ -135,8 +132,8 @@ static int create_hid_db(int device_index)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ble_hid_create_info_db()
|
||||||
static int ble_hid_create_info_db() {
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = 0;
|
rc = 0;
|
||||||
@@ -273,7 +270,8 @@ static int ble_hid_free_config(esp_ble_hidd_dev_t *dev)
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nimble_hidd_dev_deinit(void *devp) {
|
static int nimble_hidd_dev_deinit(void *devp)
|
||||||
|
{
|
||||||
esp_ble_hidd_dev_t *dev = (esp_ble_hidd_dev_t *)devp;
|
esp_ble_hidd_dev_t *dev = (esp_ble_hidd_dev_t *)devp;
|
||||||
if (!s_dev) {
|
if (!s_dev) {
|
||||||
ESP_LOGE(TAG, "HID device profile already uninitialized");
|
ESP_LOGE(TAG, "HID device profile already uninitialized");
|
||||||
@@ -322,7 +320,8 @@ static int nimble_hidd_dev_battery_set(void *devp, uint8_t level)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* if mode is NULL, find the first matching report */
|
/* if mode is NULL, find the first matching report */
|
||||||
static hidd_le_report_item_t* find_report(uint8_t id, uint8_t type, uint8_t *mode) {
|
static hidd_le_report_item_t* find_report(uint8_t id, uint8_t type, uint8_t *mode)
|
||||||
|
{
|
||||||
hidd_le_report_item_t *rpt;
|
hidd_le_report_item_t *rpt;
|
||||||
for (uint8_t d = 0; d < s_dev->devices_len; d++) {
|
for (uint8_t d = 0; d < s_dev->devices_len; d++) {
|
||||||
for (uint8_t i = 0; i < s_dev->devices[d].reports_len; i++) {
|
for (uint8_t i = 0; i < s_dev->devices[d].reports_len; i++) {
|
||||||
@@ -334,7 +333,8 @@ static hidd_le_report_item_t* find_report(uint8_t id, uint8_t type, uint8_t *mod
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
static hidd_le_report_item_t* find_report_by_usage_and_type(uint8_t usage, uint8_t type, uint8_t *mode) {
|
static hidd_le_report_item_t* find_report_by_usage_and_type(uint8_t usage, uint8_t type, uint8_t *mode)
|
||||||
|
{
|
||||||
hidd_le_report_item_t *rpt;
|
hidd_le_report_item_t *rpt;
|
||||||
for (uint8_t d = 0; d < s_dev->devices_len; d++) {
|
for (uint8_t d = 0; d < s_dev->devices_len; d++) {
|
||||||
for (uint8_t i = 0; i < s_dev->devices[d].reports_len; i++) {
|
for (uint8_t i = 0; i < s_dev->devices[d].reports_len; i++) {
|
||||||
@@ -621,7 +621,8 @@ static void nimble_gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, voi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nimble_host_synced(void) {
|
static void nimble_host_synced(void)
|
||||||
|
{
|
||||||
esp_event_post_to(s_dev->event_loop_handle, ESP_HIDD_EVENTS, ESP_HIDD_START_EVENT, NULL, 0, portMAX_DELAY);
|
esp_event_post_to(s_dev->event_loop_handle, ESP_HIDD_EVENTS, ESP_HIDD_START_EVENT, NULL, 0, portMAX_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -459,8 +459,7 @@ static void read_device_services(esp_hidh_dev_t *dev)
|
|||||||
uint16_t chr_end_handle;
|
uint16_t chr_end_handle;
|
||||||
if (c + 1 < ccount) {
|
if (c + 1 < ccount) {
|
||||||
chr_end_handle = char_result[c + 1].def_handle;
|
chr_end_handle = char_result[c + 1].def_handle;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
chr_end_handle = service_result[s].end_handle;
|
chr_end_handle = service_result[s].end_handle;
|
||||||
}
|
}
|
||||||
rc = ble_gattc_disc_all_dscs(dev->ble.conn_id, char_result[c].val_handle,
|
rc = ble_gattc_disc_all_dscs(dev->ble.conn_id, char_result[c].val_handle,
|
||||||
@@ -883,7 +882,8 @@ static void esp_ble_hidh_event_handler_wrapper(void *event_handler_arg, esp_even
|
|||||||
esp_hidh_post_process_event_handler(event_handler_arg, event_base, event_id, event_data);
|
esp_hidh_post_process_event_handler(event_handler_arg, event_base, event_id, event_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nimble_host_synced(void) {
|
static void nimble_host_synced(void)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
no need to perform anything here
|
no need to perform anything here
|
||||||
*/
|
*/
|
||||||
|
@@ -55,7 +55,6 @@ components_not_formatted_temporary:
|
|||||||
- "/components/esp_coex/"
|
- "/components/esp_coex/"
|
||||||
- "/components/esp_eth/"
|
- "/components/esp_eth/"
|
||||||
- "/components/esp_gdbstub/"
|
- "/components/esp_gdbstub/"
|
||||||
- "/components/esp_hid/"
|
|
||||||
- "/components/esp_http_client/"
|
- "/components/esp_http_client/"
|
||||||
- "/components/esp_http_server/"
|
- "/components/esp_http_server/"
|
||||||
- "/components/esp_https_ota/"
|
- "/components/esp_https_ota/"
|
||||||
|
Reference in New Issue
Block a user