text
stringlengths
1
9.98k
__index_level_0__
int64
0
4.17k
NULL : genie_slist_get_not_empty(list); } /** */ static inline void genie_slist_remove(genie_slist_t *list, genie_snode_t *prev_node, genie_snode_t *node) { if (!prev_node) { list->head = node->next; /* Was node also the tail? */ if (list->tail == node) { list->tail = list->head; } } else { prev_node->next = node->next; /* Was node the tail? */ if (list->tail == node) { list->tail = prev_node; } } node->next = NULL; } /** */ static inline bool genie_slist_find_and_remove(genie_slist_t *list, genie_snode_t *node) { genie_snode_t *prev = NULL; genie_snode_t *test; GENIE_SLIST_FOR_EACH_NODE(list, test) { if (test == node) { genie_slist_remove(list, prev, node); return true; } prev = test; } return false; } #ifdef __cplusplus } #endif #endif /* _GENIE_SLIST_H_ */
4,034
// Copyright (C) 2018-2020 Alibaba Group Holding Limited // Adaptations to ESP-IDF Copyright (c) 2020 Espressif Systems (Shanghai) Co. 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 _GENIE_TIMER_H_ #define _GENIE_TIMER_H_ #ifdef __cplusplus extern "C" { #endif /**< __cplusplus */ // #define GENIE_VENDOR_TIMER_STORE 1 // store timing data/operation #define GENIE_STORE_VENDOR_TIMER "vendor_timer" #pragma pack(1) typedef struct { uint16_t type; uint8_t para; } genie_timer_attr_data_t; #pragma pack() typedef struct { volatile uint16_t year; // 2019+ volatile uint8_t month; // 0-11 volatile uint8_t day; // 1-31 volatile uint8_t seconds; // 0-59 volatile uint8_t minutes; // 0-59 volatile uint8_t hour; // 0-23 volatile uint8_t weekday; // 0 means sunday } utc_time_t; typedef enum { GENIE_TIMER_ERR_OK = 0, GENIE_TIMER_ERR_INIT, GENIE_TIMER_ERR_LOCALTIME_NOTSET, GENIE_TIMER_ERR_INDEX, GENIE_TIMER_ERR_PARAM, GENIE_TIMER_ERR_NORESOURCE, GENIE_TIMER_ERR_OTHER, } genie_timer_error_t; typedef enum { GENIE_TIME_EVT_TIMEOUT = 0, GENIE_TIME_EVT_TIMING_SYNC = 1, } genie_timer_event_t; /** typedef void *genie_timer_handle_t; /** typedef int (*genie_timer_event_func_t)(uint8_t event, uint8_t index, genie_timer_attr_data_t *data); /** */ int genie_timer_init(genie_timer_event_func_t cb); /** */ int genie_timer_local_time_update(uint32_t unix_time); /** */ uint32_t genie_timer_local_unixtime_get(void); /** */ int genie_timer_timezone_update(int8_t timezone); /** */ int8_t genie_timer_timezone_get(void); /** */ int genie_timer_time_sync_get(uint16_t *period_time, uint8_t *retry_delay, uint8_t *retry_times); /** */ int genie_timer_time_sync_set(uint16_t period_time, uint8_t retry_delay, uint8_t retry_times); /** */ int genie_timer_start(uint8_t index, uint32_t unix_time, genie_timer_attr_data_t *attr_data); /** */ int genie_timer_periodic_start(uint8_t index, uint16_t periodic_time, uint8_t schedule, genie_timer_attr_data_t *attr_data); /** */ int genie_timer_remove(uint8_t index); /** void genie_timer_local_time_show(void); #ifdef __cplusplus } #endif /**< __cplusplus */ #endif /* _GENIE_TIMER_H_ */
4,035
/* */ #ifndef _BOARD_H_ #define _BOARD_H_ #ifdef __cplusplus extern "C" { #endif /**< __cplusplus */ #include "driver/gpio.h" #include "lightbulb.h" #define LED_ON 1 #define LED_OFF 0 #define POWERUP_KEY "powerup" /** */ void board_init(void); /** */ void board_led_hsl(uint8_t elem_index, uint16_t hue, uint16_t saturation, uint16_t lightness); /** */ void board_led_temperature(uint8_t elem_index, uint16_t temperature); /** */ void board_led_lightness(uint8_t elem_index, uint16_t actual); /** */ void board_led_switch(uint8_t elem_index, uint8_t onoff); /** */ uint16_t convert_lightness_actual_to_linear(uint16_t actual); /** */ uint16_t convert_lightness_linear_to_actual(uint16_t linear); /** */ int16_t convert_temperature_to_level(uint16_t temp, uint16_t min, uint16_t max); /** */ uint16_t covert_level_to_temperature(int16_t level, uint16_t min, uint16_t max); /** */ void swap_buf(uint8_t *dst, const uint8_t *src, int len); /** */ uint8_t *mac_str2hex(const char *mac_str, uint8_t *mac_hex); #ifdef __cplusplus } #endif /**< __cplusplus */ #endif /* _BOARD_H_ */
4,036
/* */ #ifndef _BOARD_H_ #define _BOARD_H_ #ifdef __cplusplus extern "C" { #endif /**< __cplusplus */ #include "sdkconfig.h" #include "driver/gpio.h" #include "esp_ble_mesh_defs.h" #ifdef CONFIG_BLE_MESH_ESP_WROOM_32 #define LED_R GPIO_NUM_25 #define LED_G GPIO_NUM_26 #define LED_B GPIO_NUM_27 #elif defined(CONFIG_BLE_MESH_ESP_WROVER) #define LED_R GPIO_NUM_0 #define LED_G GPIO_NUM_2 #define LED_B GPIO_NUM_4 #elif defined(CONFIG_BLE_MESH_ESP32C3_DEV) #define LED_R GPIO_NUM_8 #define LED_G GPIO_NUM_8 #define LED_B GPIO_NUM_8 #elif defined(CONFIG_BLE_MESH_ESP32S3_DEV) #define LED_R GPIO_NUM_47 #define LED_G GPIO_NUM_47 #define LED_B GPIO_NUM_47 #elif defined(CONFIG_BLE_MESH_ESP32C6_DEV) #define LED_R GPIO_NUM_8 #define LED_G GPIO_NUM_8 #define LED_B GPIO_NUM_8 #elif defined(CONFIG_BLE_MESH_ESP32H2_DEV) #define LED_R GPIO_NUM_8 #define LED_G GPIO_NUM_8 #define LED_B GPIO_NUM_8 #endif struct _led_state { uint8_t current; uint8_t previous; uint8_t pin; char *name; }; void board_output_number(esp_ble_mesh_output_action_t action, uint32_t number); void board_prov_complete(void); void board_led_operation(uint8_t pin, uint8_t onoff); esp_err_t board_init(void); #ifdef __cplusplus } #endif /**< __cplusplus */ #endif
4,037
/* */ #ifndef _BLE_MESH_FAST_PROV_COMMON_H_ #define _BLE_MESH_FAST_PROV_COMMON_H_ #ifdef __cplusplus extern "C" { #endif #include "esp_ble_mesh_defs.h" #include "esp_ble_mesh_config_model_api.h" #define LED_OFF 0x00 #define LED_ON 0x01 #define CID_ESP 0x02E5 /* Fast Prov Model ID */ #define ESP_BLE_MESH_VND_MODEL_ID_FAST_PROV_CLI 0x0000 #define ESP_BLE_MESH_VND_MODEL_ID_FAST_PROV_SRV 0x0001 /* Fast Prov Message Opcode */ #define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_INFO_SET ESP_BLE_MESH_MODEL_OP_3(0x00, CID_ESP) #define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_INFO_STATUS ESP_BLE_MESH_MODEL_OP_3(0x01, CID_ESP) #define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NET_KEY_ADD ESP_BLE_MESH_MODEL_OP_3(0x02, CID_ESP) #define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NET_KEY_STATUS ESP_BLE_MESH_MODEL_OP_3(0x03, CID_ESP) #define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_ADDR ESP_BLE_MESH_MODEL_OP_3(0x04, CID_ESP) #define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_ADDR_ACK ESP_BLE_MESH_MODEL_OP_3(0x05, CID_ESP) #define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_ADDR_GET ESP_BLE_MESH_MODEL_OP_3(0x06, CID_ESP) #define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_ADDR_STATUS ESP_BLE_MESH_MODEL_OP_3(0x07, CID_ESP) #define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_GROUP_ADD ESP_BLE_MESH_MODEL_OP_3(0x08, CID_ESP) #define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_GROUP_DELETE ESP_BLE_MESH_MODEL_OP_3(0x09, CID_ESP) typedef struct { uint16_t net_idx; uint16_t app_idx; uint16_t dst; int32_t timeout; esp_ble_mesh_dev_role_t role; } example_msg_common_info_t; typedef struct { uint16_t net_idx; uint16_t app_idx; uint8_t app_key[16]; uint16_t node_addr_cnt; /* Number of BLE Mesh nodes in the network */ uint16_t unicast_min; /* Minimum unicast address to be assigned to the nodes in the network */ uint16_t unicast_max; /* Maximum unicast address to be assigned to the nodes in the network */ uint16_t group_addr; /* Group address which will be subscribed by the nodes in the network */ uint8_t match_val[16]; /* Match value used by Fast Provisoning Provisioner */ uint8_t match_len; uint8_t max_node_num; /* Maximum number of nodes can be provisioned by the client */ } __attribute__((packed)) example_prov_info_t; /* Fast Prov Info Set Message Context */ typedef struct { uint16_t ctx_flags; /* Flags indicate which part of context exists */ uint16_t node_addr_cnt; /* Number of the nodes going to be provisioned */ uint16_t unicast_min; /* Assigned minimum unicast address */ uint16_t unicast_max; /* Assigned maximum unicast address */ uint8_t flags; /* Flags used for provisioning data */ uint32_t iv_index; /* IV_index used for provisioning data */ uint16_t net_idx; /* Netkey index used for provisioning data */ uint16_t group_addr; /* Group address going to be added to model */ uint16_t prov_addr; /* Primary Provisioner address */ uint8_t match_val[16]; /* Match value used for provisioning */ uint8_t match_len; uint8_t action; /* Action used to enbale/disable Provisioner functionality */ } __attribute__((packed)) example_fast_prov_info_set_t; typedef struct { /* The following is the basic information of a node */ bool reprov; uint8_t uuid[16]; uint16_t unicast_addr; uint8_t element_num; uint16_t net_idx; uint16_t app_idx; uint8_t onoff; /* The following is the information which will be/has been sent to the node */ bool lack_of_addr; uint16_t node_addr_cnt; uint16_t unicast_min; uint16_t unicast_max; uint8_t flags; uint32_t iv_index; uint16_t fp_net_idx; uint16_t group_addr; uint16_t prov_addr; uint8_t match_val[16]; uint8_t match_len; uint8_t action; } __attribute__((packed)) example_node_info_t; typedef struct { uint8_t net_key[16]; /* Network key going to be added */ } example_fast_prov_net_key_add_t; typedef struct { uint8_t status_key; /* Indicate the result of adding network key */ uint8_t status_act; /* Indicate the result of action */ } example_fast_prov_net_key_status_t; #ifdef __cplusplus } #endif #endif /* _BLE_MESH_FAST_PROV_COMMON_H_ */
4,038
/* */ #ifndef _BLE_MESH_FAST_PROV_SERVER_MODEL_H_ #define _BLE_MESH_FAST_PROV_SERVER_MODEL_H_ #ifdef __cplusplus extern "C" { #endif #include "ble_mesh_fast_prov_common.h" #define DISABLE_FAST_PROV_TIMEOUT K_SECONDS(10) #define GATT_PROXY_ENABLE_TIMEOUT K_SECONDS(10) #define FAST_PROV_NODE_COUNT_MIN 0x01 enum { DISABLE_FAST_PROV_START, /* Flag indicates the timer used to disable fast provisioning has been started */ GATT_PROXY_ENABLE_START, /* Flag indicates the timer used to enable Mesh GATT Proxy has been started */ RELAY_PROXY_DISABLED, /* Flag indicates if relay & proxy_adv are enabled or disabled */ SRV_MAX_FLAGS, }; enum { STATE_IDLE, STATE_PEND, STATE_ACTIVE, STATE_MAX, }; struct fast_prov_info_set { bool set_succeed; uint16_t node_addr_cnt; uint16_t unicast_min; uint16_t unicast_max; uint8_t flags; uint32_t iv_index; uint16_t net_idx; uint16_t group_addr; uint16_t pri_prov_addr; uint8_t match_val[16]; uint8_t match_len; uint8_t action; }; typedef struct { esp_ble_mesh_model_t *model; /* Fast Prov Server model pointer */ BLE_MESH_ATOMIC_DEFINE(srv_flags, SRV_MAX_FLAGS); bool primary_role; /* Indicate if the device is a Primary Provisioner */ uint8_t max_node_num; /* The maximum number of devices can be provisioned by the Provisioner */ uint8_t prov_node_cnt; /* Number of self-provisioned nodes */ uint16_t app_idx; /* AppKey index of the application key added by other Provisioner */ uint16_t top_address; /* Address of the device(e.
4,039
g. phone) which triggers fast provisioning */ esp_ble_mesh_msg_ctx_t ctx; /* the context stored for sending fast prov status message */ struct fast_prov_info_set *set_info; /* Used to store received fast prov info set context */ uint16_t node_addr_cnt; /* Number of node address shall be received */ uint16_t unicast_min; /* Minimum unicast address can be send to other nodes */ uint16_t unicast_max; /* Maximum unicast address can be send to other nodes */ uint16_t unicast_cur; /* Current unicast address can be assigned */ uint16_t unicast_step; /* Unicast address change step */ uint8_t flags; /* Flags state */ uint32_t iv_index; /* Iv_index state */ uint16_t net_idx; /* Netkey index state */ uint16_t group_addr; /* Subscribed group address */ uint16_t prim_prov_addr; /* Unicast address of Primary Provisioner */ uint8_t match_val[16]; /* Match value to be compared with unprovisioned device UUID */ uint8_t match_len; /* Length of match value to be compared */ uint8_t pend_act; /* Pending action to be performed */ uint8_t state; /* Fast prov state -> 0: idle, 1: pend, 2: active */ struct k_delayed_work disable_fast_prov_timer; /* Used to disable fast provisioning */ struct k_delayed_work gatt_proxy_enable_timer; /* Used to enable Mesh GATT Proxy functionality */ } __attribute__((packed)) example_fast_prov_server_t; esp_err_t example_store_remote_node_address(uint16_t node_addr); esp_err_t example_fast_prov_server_recv_msg(esp_ble_mesh_model_t *model, esp_ble_mesh_msg_ctx_t *ctx, struct net_buf_simple *buf); esp_err_t example_handle_fast_prov_info_set_comp_evt(esp_ble_mesh_model_t *model, uint8_t status_unicast, uint8_t status_net_idx, uint8_t status_match); esp_err_t example_handle_fast_prov_action_set_comp_evt(esp_ble_mesh_model_t *model, uint8_t status_action); esp_err_t example_handle_fast_prov_status_send_comp_evt(int err_code, uint32_t opcode, esp_ble_mesh_model_t *model, esp_ble_mesh_msg_ctx_t *ctx); esp_err_t example_fast_prov_server_init(esp_ble_mesh_model_t *model); #ifdef __cplusplus } #endif #endif /* _BLE_MESH_FAST_PROV_SERVER_MODEL_H_ */
4,039
/* */ #ifndef _BLE_MESH_FAST_PROV_OPERATION_H_ #define _BLE_MESH_FAST_PROV_OPERATION_H_ #ifdef __cplusplus extern "C" { #endif #include "ble_mesh_fast_prov_common.h" esp_err_t example_store_node_info(const uint8_t uuid[16], uint16_t node_addr, uint8_t elem_num, uint16_t net_idx, uint16_t app_idx, uint8_t onoff); example_node_info_t *example_get_node_info(uint16_t node_addr); bool example_is_node_exist(const uint8_t uuid[16]); uint16_t example_get_node_address(int node_idx); esp_ble_mesh_model_t *example_find_model(uint16_t element_addr, uint16_t model_id, uint16_t company_id); esp_err_t example_handle_config_app_key_add_evt(uint16_t app_idx); esp_err_t example_add_fast_prov_group_address(uint16_t model_id, uint16_t group_addr); esp_err_t example_delete_fast_prov_group_address(uint16_t model_id, uint16_t group_addr); esp_err_t example_send_config_appkey_add(esp_ble_mesh_model_t *model, example_msg_common_info_t *info, esp_ble_mesh_cfg_app_key_add_t *add_key); esp_err_t example_send_generic_onoff_get(esp_ble_mesh_model_t *model, example_msg_common_info_t *info); esp_err_t example_send_generic_onoff_set(esp_ble_mesh_model_t *model, example_msg_common_info_t *info, uint8_t onoff, uint8_t tid, bool need_ack); esp_err_t example_send_fast_prov_info_set(esp_ble_mesh_model_t *model, example_msg_common_info_t *info, example_fast_prov_info_set_t *set); esp_err_t example_send_fast_prov_net_key_add(esp_ble_mesh_model_t *model, example_msg_common_info_t *info, uint8_t net_key[16]); esp_err_t example_send_fast_prov_self_prov_node_addr(esp_ble_mesh_model_t *model, example_msg_common_info_t *info, struct net_buf_simple *node_addr); esp_err_t example_send_fast_prov_all_node_addr_get(esp_ble_mesh_model_t *model, example_msg_common_info_t *info); esp_err_t example_send_fast_prov_status_msg(esp_ble_mesh_model_t *model, esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode, struct net_buf_simple *msg); #ifdef __cplusplus } #endif #endif /* _BLE_MESH_FAST_PROV_OPERATION_H_ */
4,040
/* */ #ifndef _BLE_MESH_FAST_PROV_CLIENT_MODEL_H_ #define _BLE_MESH_FAST_PROV_CLIENT_MODEL_H_ #ifdef __cplusplus extern "C" { #endif #include "esp_ble_mesh_defs.h" enum { SEND_SELF_PROV_NODE_ADDR_START, /* Flag indicates the timer used to send self-provisioned node addresses has been started */ CLI_MAX_FLAGS, }; #define SEND_SELF_PROV_NODE_ADDR_TIMEOUT K_SECONDS(5) void example_send_self_prov_node_addr(struct k_work *work); esp_err_t example_fast_prov_client_recv_timeout(uint32_t opcode, esp_ble_mesh_model_t *model, esp_ble_mesh_msg_ctx_t *ctx); esp_err_t example_fast_prov_client_recv_status(esp_ble_mesh_model_t *model, esp_ble_mesh_msg_ctx_t *ctx, uint16_t len, const uint8_t *data); #ifdef __cplusplus } #endif #endif /* _BLE_MESH_FAST_PROV_CLIENT_MODEL_H_ */
4,041
/* */ #ifndef _BLE_MESH_EXAMPLE_INIT_H_ #define _BLE_MESH_EXAMPLE_INIT_H_ #ifdef __cplusplus extern "C" { #endif /**< __cplusplus */ #include "esp_err.h" void ble_mesh_get_dev_uuid(uint8_t *dev_uuid); esp_err_t bluetooth_init(void); #ifdef __cplusplus } #endif /**< __cplusplus */ #endif /* _BLE_MESH_EXAMPLE_INIT_H_ */
4,042
/* */ #ifndef _BLE_MESH_EXAMPLE_NVS_H_ #define _BLE_MESH_EXAMPLE_NVS_H_ #ifdef __cplusplus extern "C" { #endif /** #include "esp_err.h" #include "nvs_flash.h" esp_err_t ble_mesh_nvs_open(nvs_handle_t *handle); esp_err_t ble_mesh_nvs_store(nvs_handle_t handle, const char *key, const void *data, size_t length); esp_err_t ble_mesh_nvs_get_length(nvs_handle_t handle, const char *key, size_t *length); esp_err_t ble_mesh_nvs_restore(nvs_handle_t handle, const char *key, void *data, size_t length, bool *exist); esp_err_t ble_mesh_nvs_erase(nvs_handle_t handle, const char *key); #ifdef __cplusplus } #endif /**< __cplusplus */ #endif /* _BLE_MESH_EXAMPLE_NVS_H_ */
4,043
/* */ #ifndef _IOT_BUTTON_H_ #define _IOT_BUTTON_H_ #ifdef __cplusplus extern "C" { #endif #include "driver/gpio.h" #include "freertos/FreeRTOS.h" typedef void (* button_cb)(void*); typedef void* button_handle_t; typedef enum { BUTTON_ACTIVE_HIGH = 1, /*!add_cb(BUTTON_CB_PUSH, button_tap_cb, (void*) push, 50 / portTICK_PERIOD_MS); */ class CButton { private: button_handle_t m_btn_handle; /** */ CButton(const CButton&); CButton& operator = (const CButton&); public: /** */ CButton(gpio_num_t gpio_num, button_active_t active_level = BUTTON_ACTIVE_LOW); ~CButton(); /** */ esp_err_t set_evt_cb(button_cb_type_t type, button_cb cb, void* arg); /** */ esp_err_t set_serial_cb(button_cb cb, void* arg, TickType_t interval_tick, uint32_t start_after_sec); /** */ esp_err_t add_custom_cb(uint32_t press_sec, button_cb cb, void* arg); /** */ esp_err_t rm_cb(button_cb_type_t type); }; #endif #endif
4,044
/* board.h - Board-specific hooks */ /* */ #ifndef _BOARD_H_ #define _BOARD_H_ #ifdef __cplusplus extern "C" { #endif /**< __cplusplus */ void board_init(void); #ifdef __cplusplus } #endif /**< __cplusplus */ #endif /* _BOARD_H_ */
4,045
/* board.h - Board-specific hooks */ /* */ #ifndef _BOARD_H_ #define _BOARD_H_ #ifdef __cplusplus extern "C" { #endif /**< __cplusplus */ #include "driver/gpio.h" #if defined(CONFIG_BLE_MESH_ESP_WROOM_32) #define LED_R GPIO_NUM_25 #define LED_G GPIO_NUM_26 #define LED_B GPIO_NUM_27 #elif defined(CONFIG_BLE_MESH_ESP_WROVER) #define LED_R GPIO_NUM_0 #define LED_G GPIO_NUM_2 #define LED_B GPIO_NUM_4 #elif defined(CONFIG_BLE_MESH_ESP32C3_DEV) #define LED_R GPIO_NUM_8 #define LED_G GPIO_NUM_8 #define LED_B GPIO_NUM_8 #elif defined(CONFIG_BLE_MESH_ESP32S3_DEV) #define LED_R GPIO_NUM_47 #define LED_G GPIO_NUM_47 #define LED_B GPIO_NUM_47 #elif defined(CONFIG_BLE_MESH_ESP32C6_DEV) #define LED_R GPIO_NUM_8 #define LED_G GPIO_NUM_8 #define LED_B GPIO_NUM_8 #elif defined(CONFIG_BLE_MESH_ESP32H2_DEV) #define LED_R GPIO_NUM_8 #define LED_G GPIO_NUM_8 #define LED_B GPIO_NUM_8 #endif #define LED_ON 1 #define LED_OFF 0 struct _led_state { uint8_t current; uint8_t previous; uint8_t pin; char *name; }; void board_led_operation(uint8_t pin, uint8_t onoff); void board_init(void); #ifdef __cplusplus } #endif /**< __cplusplus */ #endif /* _BOARD_H_ */
4,046
/* */ #ifndef __ESP_HIDD_API_H__ #define __ESP_HIDD_API_H__ #include "esp_bt_defs.h" #include "esp_gatt_defs.h" #include "esp_err.h" #ifdef __cplusplus extern "C" { #endif typedef enum { ESP_HIDD_EVENT_REG_FINISH = 0, ESP_BAT_EVENT_REG, ESP_HIDD_EVENT_DEINIT_FINISH, ESP_HIDD_EVENT_BLE_CONNECT, ESP_HIDD_EVENT_BLE_DISCONNECT, ESP_HIDD_EVENT_BLE_VENDOR_REPORT_WRITE_EVT, ESP_HIDD_EVENT_BLE_LED_REPORT_WRITE_EVT, } esp_hidd_cb_event_t; /// HID config status typedef enum { ESP_HIDD_STA_CONN_SUCCESS = 0x00, ESP_HIDD_STA_CONN_FAIL = 0x01, } esp_hidd_sta_conn_state_t; /// HID init status typedef enum { ESP_HIDD_INIT_OK = 0, ESP_HIDD_INIT_FAILED = 1, } esp_hidd_init_state_t; /// HID deinit status typedef enum { ESP_HIDD_DEINIT_OK = 0, ESP_HIDD_DEINIT_FAILED = 0, } esp_hidd_deinit_state_t; #define LEFT_CONTROL_KEY_MASK (1 << 0) #define LEFT_SHIFT_KEY_MASK (1 << 1) #define LEFT_ALT_KEY_MASK (1 << 2) #define LEFT_GUI_KEY_MASK (1 << 3) #define RIGHT_CONTROL_KEY_MASK (1 << 4) #define RIGHT_SHIFT_KEY_MASK (1 << 5) #define RIGHT_ALT_KEY_MASK (1 << 6) #define RIGHT_GUI_KEY_MASK (1 << 7) typedef uint8_t key_mask_t; /** */ typedef union { /** */ struct hidd_init_finish_evt_param { esp_hidd_init_state_t state; /*!
4,047
< Initial status */ esp_gatt_if_t gatts_if; } init_finish; /*!< HID callback param of ESP_HIDD_EVENT_INIT_FINISH */ /** */ struct hidd_deinit_finish_evt_param { esp_hidd_deinit_state_t state; /*!< De-initial status */ } deinit_finish; /*!< HID callback param of ESP_HIDD_EVENT_DEINIT_FINISH */ /** */ struct hidd_connect_evt_param { uint16_t conn_id; esp_bd_addr_t remote_bda; /*!< HID Remote bluetooth connection index */ } connect; /*!< HID callback param of ESP_HIDD_EVENT_CONNECT */ /** */ struct hidd_disconnect_evt_param { esp_bd_addr_t remote_bda; /*!< HID Remote bluetooth device address */ } disconnect; /*!< HID callback param of ESP_HIDD_EVENT_DISCONNECT */ /** */ struct hidd_vendor_write_evt_param { uint16_t conn_id; /*!< HID connection index */ uint16_t report_id; /*!
4,047
< HID report index */ uint16_t length; /*!< data length */ uint8_t *data; /*!< The pointer to the data */ } vendor_write; /*!< HID callback param of ESP_HIDD_EVENT_BLE_VENDOR_REPORT_WRITE_EVT */ /** */ struct hidd_led_write_evt_param { uint16_t conn_id; uint8_t report_id; uint8_t length; uint8_t *data; } led_write; } esp_hidd_cb_param_t; /** */ typedef void (*esp_hidd_event_cb_t) (esp_hidd_cb_event_t event, esp_hidd_cb_param_t *param); /** esp_err_t esp_hidd_register_callbacks(esp_hidd_event_cb_t callbacks); /** esp_err_t esp_hidd_profile_init(void); /** esp_err_t esp_hidd_profile_deinit(void); /** uint16_t esp_hidd_get_version(void); void esp_hidd_send_consumer_value(uint16_t conn_id, uint8_t key_cmd, bool key_pressed); void esp_hidd_send_keyboard_value(uint16_t conn_id, key_mask_t special_key_mask, uint8_t *keyboard_cmd, uint8_t num_key); void esp_hidd_send_mouse_value(uint16_t conn_id, uint8_t mouse_button, int8_t mickeys_x, int8_t mickeys_y); #ifdef __cplusplus } #endif #endif /* __ESP_HIDD_API_H__ */
4,047
/* */ #ifndef HID_DEV_H__ #define HID_DEV_H__ #include "hidd_le_prf_int.h" #ifdef __cplusplus extern "C" { #endif /* HID Report type */ #define HID_TYPE_INPUT 1 #define HID_TYPE_OUTPUT 2 #define HID_TYPE_FEATURE 3 // HID Keyboard/Keypad Usage IDs (subset of the codes available in the USB HID Usage Tables spec) #define HID_KEY_RESERVED 0 // No event inidicated #define HID_KEY_A 4 // Keyboard a and A #define HID_KEY_B 5 // Keyboard b and B #define HID_KEY_C 6 // Keyboard c and C #define HID_KEY_D 7 // Keyboard d and D #define HID_KEY_E 8 // Keyboard e and E #define HID_KEY_F 9 // Keyboard f and F #define HID_KEY_G 10 // Keyboard g and G #define HID_KEY_H 11 // Keyboard h and H #define HID_KEY_I 12 // Keyboard i and I #define HID_KEY_J 13 // Keyboard j and J #define HID_KEY_K 14 // Keyboard k and K #define HID_KEY_L 15 // Keyboard l and L #define HID_KEY_M 16 // Keyboard m and M #define HID_KEY_N 17 // Keyboard n and N #define HID_KEY_O 18 // Keyboard o and O #define HID_KEY_P 19 // Keyboard p and p #define HID_KEY_Q 20 // Keyboard q and Q #define HID_KEY_R 21 // Keyboard r and R #define HID_KEY_S 22 // Keyboard s and S #define HID_KEY_T 23 // Keyboard t and T #define HID_KEY_U 24 // Keyboard u and U #define HID_KEY_V 25 // Keyboard v and V #define HID_KEY_W 26 // Keyboard w and W #define HID_KEY_X 27 // Keyboard x and X #define HID_KEY_Y 28 // Keyboard y and Y #define HID_KEY_Z 29 // Keyboard z and Z #define HID_KEY_1 30 // Keyboard 1 and !
4,048
#define HID_KEY_2 31 // Keyboard 2 and @ #define HID_KEY_3 32 // Keyboard 3 and # #define HID_KEY_4 33 // Keyboard 4 and % #define HID_KEY_5 34 // Keyboard 5 and % #define HID_KEY_6 35 // Keyboard 6 and ^ #define HID_KEY_7 36 // Keyboard 7 and & #define HID_KEY_8 37 // Keyboard 8 and * #define HID_KEY_9 38 // Keyboard 9 and ( #define HID_KEY_0 39 // Keyboard 0 and ) #define HID_KEY_RETURN 40 // Keyboard Return (ENTER) #define HID_KEY_ESCAPE 41 // Keyboard ESCAPE #define HID_KEY_DELETE 42 // Keyboard DELETE (Backspace) #define HID_KEY_TAB 43 // Keyboard Tab #define HID_KEY_SPACEBAR 44 // Keyboard Spacebar #define HID_KEY_MINUS 45 // Keyboard - and (underscore) #define HID_KEY_EQUAL 46 // Keyboard = and + #define HID_KEY_LEFT_BRKT 47 // Keyboard [ and { #define HID_KEY_RIGHT_BRKT 48 // Keyboard ] and } #define HID_KEY_BACK_SLASH 49 // Keyboard \ and | #define HID_KEY_SEMI_COLON 51 // Keyboard ; and : #define HID_KEY_SGL_QUOTE 52 // Keyboard ' and " #define HID_KEY_GRV_ACCENT 53 // Keyboard Grave Accent and Tilde #define HID_KEY_COMMA 54 // Keyboard , and #define HID_KEY_FWD_SLASH 56 // Keyboard / and ?
4,048
#define HID_KEY_CAPS_LOCK 57 // Keyboard Caps Lock #define HID_KEY_F1 58 // Keyboard F1 #define HID_KEY_F2 59 // Keyboard F2 #define HID_KEY_F3 60 // Keyboard F3 #define HID_KEY_F4 61 // Keyboard F4 #define HID_KEY_F5 62 // Keyboard F5 #define HID_KEY_F6 63 // Keyboard F6 #define HID_KEY_F7 64 // Keyboard F7 #define HID_KEY_F8 65 // Keyboard F8 #define HID_KEY_F9 66 // Keyboard F9 #define HID_KEY_F10 67 // Keyboard F10 #define HID_KEY_F11 68 // Keyboard F11 #define HID_KEY_F12 69 // Keyboard F12 #define HID_KEY_PRNT_SCREEN 70 // Keyboard Print Screen #define HID_KEY_SCROLL_LOCK 71 // Keyboard Scroll Lock #define HID_KEY_PAUSE 72 // Keyboard Pause #define HID_KEY_INSERT 73 // Keyboard Insert #define HID_KEY_HOME 74 // Keyboard Home #define HID_KEY_PAGE_UP 75 // Keyboard PageUp #define HID_KEY_DELETE_FWD 76 // Keyboard Delete Forward #define HID_KEY_END 77 // Keyboard End #define HID_KEY_PAGE_DOWN 78 // Keyboard PageDown #define HID_KEY_RIGHT_ARROW 79 // Keyboard RightArrow #define HID_KEY_LEFT_ARROW 80 // Keyboard LeftArrow #define HID_KEY_DOWN_ARROW 81 // Keyboard DownArrow #define HID_KEY_UP_ARROW 82 // Keyboard UpArrow #define HID_KEY_NUM_LOCK 83 // Keypad Num Lock and Clear #define HID_KEY_DIVIDE 84 // Keypad / #define HID_KEY_MULTIPLY 85 // Keypad * #define HID_KEY_SUBTRACT 86 // Keypad - #define HID_KEY_ADD 87 // Keypad + #define HID_KEY_ENTER 88 // Keypad ENTER #define HID_KEYPAD_1 89 // Keypad 1 and End #define HID_KEYPAD_2 90 // Keypad 2 and Down Arrow #define HID_KEYPAD_3 91 // Keypad 3 and PageDn #define HID_KEYPAD_4 92 // Keypad 4 and Lfet Arrow #define HID_KEYPAD_5 93 // Keypad 5 #define HID_KEYPAD_6 94 // Keypad 6 and Right Arrow #define HID_KEYPAD_7 95 // Keypad 7 and Home #define HID_KEYPAD_8 96 // Keypad 8 and Up Arrow #define HID_KEYPAD_9 97 // Keypad 9 and PageUp #define HID_KEYPAD_0 98 // Keypad 0 and Insert #define HID_KEYPAD_DOT 99 // Keypad .
4,048
and Delete #define HID_KEY_MUTE 127 // Keyboard Mute #define HID_KEY_VOLUME_UP 128 // Keyboard Volume up #define HID_KEY_VOLUME_DOWN 129 // Keyboard Volume down #define HID_KEY_LEFT_CTRL 224 // Keyboard LeftContorl #define HID_KEY_LEFT_SHIFT 225 // Keyboard LeftShift #define HID_KEY_LEFT_ALT 226 // Keyboard LeftAlt #define HID_KEY_LEFT_GUI 227 // Keyboard LeftGUI #define HID_KEY_RIGHT_CTRL 228 // Keyboard RightContorl #define HID_KEY_RIGHT_SHIFT 229 // Keyboard RightShift #define HID_KEY_RIGHT_ALT 230 // Keyboard RightAlt #define HID_KEY_RIGHT_GUI 231 // Keyboard RightGUI typedef uint8_t keyboard_cmd_t; #define HID_MOUSE_LEFT 253 #define HID_MOUSE_MIDDLE 254 #define HID_MOUSE_RIGHT 255 typedef uint8_t mouse_cmd_t; // HID Consumer Usage IDs (subset of the codes available in the USB HID Usage Tables spec) #define HID_CONSUMER_POWER 48 // Power #define HID_CONSUMER_RESET 49 // Reset #define HID_CONSUMER_SLEEP 50 // Sleep #define HID_CONSUMER_MENU 64 // Menu #define HID_CONSUMER_SELECTION 128 // Selection #define HID_CONSUMER_ASSIGN_SEL 129 // Assign Selection #define HID_CONSUMER_MODE_STEP 130 // Mode Step #define HID_CONSUMER_RECALL_LAST 131 // Recall Last #define HID_CONSUMER_QUIT 148 // Quit #define HID_CONSUMER_HELP 149 // Help #define HID_CONSUMER_CHANNEL_UP 156 // Channel Increment #define HID_CONSUMER_CHANNEL_DOWN 157 // Channel Decrement #define HID_CONSUMER_PLAY 176 // Play #define HID_CONSUMER_PAUSE 177 // Pause #define HID_CONSUMER_RECORD 178 // Record #define HID_CONSUMER_FAST_FORWARD 179 // Fast Forward #define HID_CONSUMER_REWIND 180 // Rewind #define HID_CONSUMER_SCAN_NEXT_TRK 181 // Scan Next Track #define HID_CONSUMER_SCAN_PREV_TRK 182 // Scan Previous Track #define HID_CONSUMER_STOP 183 // Stop #define HID_CONSUMER_EJECT 184 // Eject #define HID_CONSUMER_RANDOM_PLAY 185 // Random Play #define HID_CONSUMER_SELECT_DISC 186 // Select Disk #define HID_CONSUMER_ENTER_DISC 187 // Enter Disc #define HID_CONSUMER_REPEAT 188 // Repeat #define HID_CONSUMER_STOP_EJECT 204 // Stop/Eject #define HID_CONSUMER_PLAY_PAUSE 205 // Play/Pause #define HID_CONSUMER_PLAY_SKIP 206 // Play/Skip #define HID_CONSUMER_VOLUME 224 // Volume #define HID_CONSUMER_BALANCE 225 // Balance #define HID_CONSUMER_MUTE 226 // Mute #define HID_CONSUMER_BASS 227 // Bass #define HID_CONSUMER_VOLUME_UP 233 // Volume Increment #define HID_CONSUMER_VOLUME_DOWN 234 // Volume Decrement typedef uint8_t consumer_cmd_t; #define HID_CC_RPT_MUTE 1 #define HID_CC_RPT_POWER 2 #define HID_CC_RPT_LAST 3 #define HID_CC_RPT_ASSIGN_SEL 4 #define HID_CC_RPT_PLAY 5 #define HID_CC_RPT_PAUSE 6 #define HID_CC_RPT_RECORD 7 #define HID_CC_RPT_FAST_FWD 8 #define HID_CC_RPT_REWIND 9 #define HID_CC_RPT_SCAN_NEXT_TRK 10 #define HID_CC_RPT_SCAN_PREV_TRK 11 #define HID_CC_RPT_STOP 12 #define HID_CC_RPT_CHANNEL_UP 0x01 #define HID_CC_RPT_CHANNEL_DOWN 0x03 #define HID_CC_RPT_VOLUME_UP 0x40 #define HID_CC_RPT_VOLUME_DOWN 0x80 // HID Consumer Control report bitmasks #define HID_CC_RPT_NUMERIC_BITS 0xF0 #define HID_CC_RPT_CHANNEL_BITS 0xCF #define HID_CC_RPT_VOLUME_BITS 0x3F #define HID_CC_RPT_BUTTON_BITS 0xF0 #define HID_CC_RPT_SELECTION_BITS 0xCF // Macros for the HID Consumer Control 2-byte report #define HID_CC_RPT_SET_NUMERIC(s, x) (s)[0] &= HID_CC_RPT_NUMERIC_BITS; \ (s)[0] = (x) #define HID_CC_RPT_SET_CHANNEL(s, x) (s)[0] &= HID_CC_RPT_CHANNEL_BITS; \ (s)[0] |= ((x) & 0x03) << 4 #define HID_CC_RPT_SET_VOLUME_UP(s) (s)[0] &= HID_CC_RPT_VOLUME_BITS; \ (s)[0] |= 0x40 #define HID_CC_RPT_SET_VOLUME_DOWN(s) (s)[0] &= HID_CC_RPT_VOLUME_BITS; \ (s)[0] |= 0x80 #define HID_CC_RPT_SET_BUTTON(s, x) (s)[1] &= HID_CC_RPT_BUTTON_BITS; \ (s)[1] |= (x) #define HID_CC_RPT_SET_SELECTION(s, x) (s)[1] &= HID_CC_RPT_SELECTION_BITS; \ (s)[1] |= ((x) & 0x03) << 4 // HID report mapping table typedef struct { uint16_t handle; // Handle of report characteristic uint16_t cccdHandle; // Handle of CCCD for report characteristic uint8_t id; // Report ID uint8_t type; // Report type uint8_t mode; // Protocol mode (report or boot) } hid_report_map_t; // HID dev configuration structure typedef struct { uint32_t idleTimeout; // Idle timeout in milliseconds uint8_t hidFlags; // HID feature flags } hid_dev_cfg_t; void hid_dev_register_reports(uint8_t num_reports, hid_report_map_t *p_report); void hid_dev_send_report(esp_gatt_if_t gatts_if, uint16_t conn_id, uint8_t id, uint8_t type, uint8_t length, uint8_t *data); void hid_consumer_build_report(uint8_t *buffer, consumer_cmd_t cmd); void hid_keyboard_build_report(uint8_t *buffer, keyboard_cmd_t cmd); void hid_mouse_build_report(uint8_t *buffer, mouse_cmd_t cmd); #ifdef __cplusplus } // extern "C" #endif #endif /* HID_DEV_H__ */
4,048
/* */ #ifndef __HID_DEVICE_LE_PRF__ #define __HID_DEVICE_LE_PRF__ #include #include "esp_gatts_api.h" #include "esp_gatt_defs.h" #include "esp_hidd_prf_api.h" #include "esp_gap_ble_api.h" #include "hid_dev.h" #define SUPPORT_REPORT_VENDOR false //HID BLE profile log tag #define HID_LE_PRF_TAG "HID_LE_PRF" /// Maximal number of HIDS that can be added in the DB #ifndef USE_ONE_HIDS_INSTANCE #define HIDD_LE_NB_HIDS_INST_MAX (2) #else #define HIDD_LE_NB_HIDS_INST_MAX (1) #endif #define HIDD_GREAT_VER 0x01 //Version + Subversion #define HIDD_SUB_VER 0x00 //Version + Subversion #define HIDD_VERSION ((HIDD_GREAT_VER<<8)|HIDD_SUB_VER) //Version + Subversion #define HID_MAX_APPS 1 // Number of HID reports defined in the service #define HID_NUM_REPORTS 9 // HID Report IDs for the service #define HID_RPT_ID_MOUSE_IN 1 // Mouse input report ID #define HID_RPT_ID_KEY_IN 2 // Keyboard input report ID #define HID_RPT_ID_CC_IN 3 //Consumer Control input report ID #define HID_RPT_ID_VENDOR_OUT 4 // Vendor output report ID #define HID_RPT_ID_LED_OUT 2 // LED output report ID #define HID_RPT_ID_FEATURE 0 // Feature report ID #define HIDD_APP_ID 0x1812//ATT_SVC_HID #define BATTRAY_APP_ID 0x180f #define ATT_SVC_HID 0x1812 /// Maximal number of Report Char.
4,049
that can be added in the DB for one HIDS - Up to 11 #define HIDD_LE_NB_REPORT_INST_MAX (5) /// Maximal length of Report Char. Value #define HIDD_LE_REPORT_MAX_LEN (255) /// Maximal length of Report Map Char. Value #define HIDD_LE_REPORT_MAP_MAX_LEN (512) /// Length of Boot Report Char. Value Maximal Length #define HIDD_LE_BOOT_REPORT_MAX_LEN (8) /// Boot KB Input Report Notification Configuration Bit Mask #define HIDD_LE_BOOT_KB_IN_NTF_CFG_MASK (0x40) /// Boot KB Input Report Notification Configuration Bit Mask #define HIDD_LE_BOOT_MOUSE_IN_NTF_CFG_MASK (0x80) /// Boot Report Notification Configuration Bit Mask #define HIDD_LE_REPORT_NTF_CFG_MASK (0x20) /* HID information flags */ #define HID_FLAGS_REMOTE_WAKE 0x01 // RemoteWake #define HID_FLAGS_NORMALLY_CONNECTABLE 0x02 // NormallyConnectable /* Control point commands */ #define HID_CMD_SUSPEND 0x00 // Suspend #define HID_CMD_EXIT_SUSPEND 0x01 // Exit Suspend /* HID protocol mode values */ #define HID_PROTOCOL_MODE_BOOT 0x00 // Boot Protocol Mode #define HID_PROTOCOL_MODE_REPORT 0x01 // Report Protocol Mode /* Attribute value lengths */ #define HID_PROTOCOL_MODE_LEN 1 // HID Protocol Mode #define HID_INFORMATION_LEN 4 // HID Information #define HID_REPORT_REF_LEN 2 // HID Report Reference Descriptor #define HID_EXT_REPORT_REF_LEN 2 // External Report Reference Descriptor // HID feature flags #define HID_KBD_FLAGS HID_FLAGS_REMOTE_WAKE /* HID Report type */ #define HID_REPORT_TYPE_INPUT 1 #define HID_REPORT_TYPE_OUTPUT 2 #define HID_REPORT_TYPE_FEATURE 3 /// HID Service Attributes Indexes enum { HIDD_LE_IDX_SVC, // Included Service HIDD_LE_IDX_INCL_SVC, // HID Information HIDD_LE_IDX_HID_INFO_CHAR, HIDD_LE_IDX_HID_INFO_VAL, // HID Control Point HIDD_LE_IDX_HID_CTNL_PT_CHAR, HIDD_LE_IDX_HID_CTNL_PT_VAL, // Report Map HIDD_LE_IDX_REPORT_MAP_CHAR, HIDD_LE_IDX_REPORT_MAP_VAL, HIDD_LE_IDX_REPORT_MAP_EXT_REP_REF, // Protocol Mode HIDD_LE_IDX_PROTO_MODE_CHAR, HIDD_LE_IDX_PROTO_MODE_VAL, // Report mouse input HIDD_LE_IDX_REPORT_MOUSE_IN_CHAR, HIDD_LE_IDX_REPORT_MOUSE_IN_VAL, HIDD_LE_IDX_REPORT_MOUSE_IN_CCC, HIDD_LE_IDX_REPORT_MOUSE_REP_REF, //Report Key input HIDD_LE_IDX_REPORT_KEY_IN_CHAR, HIDD_LE_IDX_REPORT_KEY_IN_VAL, HIDD_LE_IDX_REPORT_KEY_IN_CCC, HIDD_LE_IDX_REPORT_KEY_IN_REP_REF, ///Report Led output HIDD_LE_IDX_REPORT_LED_OUT_CHAR, HIDD_LE_IDX_REPORT_LED_OUT_VAL, HIDD_LE_IDX_REPORT_LED_OUT_REP_REF, #if (SUPPORT_REPORT_VENDOR == true) /// Report Vendor HIDD_LE_IDX_REPORT_VENDOR_OUT_CHAR, HIDD_LE_IDX_REPORT_VENDOR_OUT_VAL, HIDD_LE_IDX_REPORT_VENDOR_OUT_REP_REF, #endif HIDD_LE_IDX_REPORT_CC_IN_CHAR, HIDD_LE_IDX_REPORT_CC_IN_VAL, HIDD_LE_IDX_REPORT_CC_IN_CCC, HIDD_LE_IDX_REPORT_CC_IN_REP_REF, // Boot Keyboard Input Report HIDD_LE_IDX_BOOT_KB_IN_REPORT_CHAR, HIDD_LE_IDX_BOOT_KB_IN_REPORT_VAL, HIDD_LE_IDX_BOOT_KB_IN_REPORT_NTF_CFG, // Boot Keyboard Output Report HIDD_LE_IDX_BOOT_KB_OUT_REPORT_CHAR, HIDD_LE_IDX_BOOT_KB_OUT_REPORT_VAL, // Boot Mouse Input Report HIDD_LE_IDX_BOOT_MOUSE_IN_REPORT_CHAR, HIDD_LE_IDX_BOOT_MOUSE_IN_REPORT_VAL, HIDD_LE_IDX_BOOT_MOUSE_IN_REPORT_NTF_CFG, // Report HIDD_LE_IDX_REPORT_CHAR, HIDD_LE_IDX_REPORT_VAL, HIDD_LE_IDX_REPORT_REP_REF, //HIDD_LE_IDX_REPORT_NTF_CFG, HIDD_LE_IDX_NB, }; /// Attribute Table Indexes enum { HIDD_LE_INFO_CHAR, HIDD_LE_CTNL_PT_CHAR, HIDD_LE_REPORT_MAP_CHAR, HIDD_LE_REPORT_CHAR, HIDD_LE_PROTO_MODE_CHAR, HIDD_LE_BOOT_KB_IN_REPORT_CHAR, HIDD_LE_BOOT_KB_OUT_REPORT_CHAR, HIDD_LE_BOOT_MOUSE_IN_REPORT_CHAR, HIDD_LE_CHAR_MAX //= HIDD_LE_REPORT_CHAR + HIDD_LE_NB_REPORT_INST_MAX, }; ///att read event table Indexs enum { HIDD_LE_READ_INFO_EVT, HIDD_LE_READ_CTNL_PT_EVT, HIDD_LE_READ_REPORT_MAP_EVT, HIDD_LE_READ_REPORT_EVT, HIDD_LE_READ_PROTO_MODE_EVT, HIDD_LE_BOOT_KB_IN_REPORT_EVT, HIDD_LE_BOOT_KB_OUT_REPORT_EVT, HIDD_LE_BOOT_MOUSE_IN_REPORT_EVT, HID_LE_EVT_MAX }; /// Client Characteristic Configuration Codes enum { HIDD_LE_DESC_MASK = 0x10, HIDD_LE_BOOT_KB_IN_REPORT_CFG = HIDD_LE_BOOT_KB_IN_REPORT_CHAR | HIDD_LE_DESC_MASK, HIDD_LE_BOOT_MOUSE_IN_REPORT_CFG = HIDD_LE_BOOT_MOUSE_IN_REPORT_CHAR | HIDD_LE_DESC_MASK, HIDD_LE_REPORT_CFG = HIDD_LE_REPORT_CHAR | HIDD_LE_DESC_MASK, }; /// Features Flag Values enum { HIDD_LE_CFG_KEYBOARD = 0x01, HIDD_LE_CFG_MOUSE = 0x02, HIDD_LE_CFG_PROTO_MODE = 0x04, HIDD_LE_CFG_MAP_EXT_REF = 0x08, HIDD_LE_CFG_BOOT_KB_WR = 0x10, HIDD_LE_CFG_BOOT_MOUSE_WR = 0x20, }; /// Report Char.
4,049
Configuration Flag Values enum { HIDD_LE_CFG_REPORT_IN = 0x01, HIDD_LE_CFG_REPORT_OUT = 0x02, //HOGPD_CFG_REPORT_FEAT can be used as a mask to check Report type HIDD_LE_CFG_REPORT_FEAT = 0x03, HIDD_LE_CFG_REPORT_WR = 0x10, }; /// Pointer to the connection clean-up function #define HIDD_LE_CLEANUP_FNCT (NULL) /* */ /// HIDD Features structure typedef struct { /// Service Features uint8_t svc_features; /// Number of Report Char. instances to add in the database uint8_t report_nb; /// Report Char. Configuration uint8_t report_char_cfg[HIDD_LE_NB_REPORT_INST_MAX]; } hidd_feature_t; typedef struct { bool in_use; bool congest; uint16_t conn_id; bool connected; esp_bd_addr_t remote_bda; uint32_t trans_id; uint8_t cur_srvc_id; } hidd_clcb_t; // HID report mapping table typedef struct { uint16_t handle; // Handle of report characteristic uint16_t cccdHandle; // Handle of CCCD for report characteristic uint8_t id; // Report ID uint8_t type; // Report type uint8_t mode; // Protocol mode (report or boot) } hidRptMap_t; typedef struct { /// hidd profile id uint8_t app_id; /// Notified handle uint16_t ntf_handle; ///Attribute handle Table uint16_t att_tbl[HIDD_LE_IDX_NB]; /// Supported Features hidd_feature_t hidd_feature[HIDD_LE_NB_HIDS_INST_MAX]; /// Current Protocol Mode uint8_t proto_mode[HIDD_LE_NB_HIDS_INST_MAX]; /// Number of HIDS added in the database uint8_t hids_nb; uint8_t pending_evt; uint16_t pending_hal; } hidd_inst_t; /// Report Reference structure typedef struct { ///Report ID uint8_t report_id; ///Report Type uint8_t report_type; }hids_report_ref_t; /// HID Information structure typedef struct { /// bcdHID uint16_t bcdHID; /// bCountryCode uint8_t bCountryCode; /// Flags uint8_t flags; }hids_hid_info_t; /* service engine control block */ typedef struct { hidd_clcb_t hidd_clcb[HID_MAX_APPS]; /* connection link*/ esp_gatt_if_t gatt_if; bool enabled; bool is_take; bool is_primery; hidd_inst_t hidd_inst; esp_hidd_event_cb_t hidd_cb; uint8_t inst_id; } hidd_le_env_t; extern hidd_le_env_t hidd_le_env; extern uint8_t hidProtocolMode; void hidd_clcb_alloc (uint16_t conn_id, esp_bd_addr_t bda); bool hidd_clcb_dealloc (uint16_t conn_id); void hidd_le_create_service(esp_gatt_if_t gatts_if); void hidd_set_attr_value(uint16_t handle, uint16_t val_len, const uint8_t *value); void hidd_get_attr_value(uint16_t handle, uint16_t *length, uint8_t **value); esp_err_t hidd_register_cb(void); #endif ///__HID_DEVICE_LE_PRF__
4,049
/* */ #include #include #include /* */ #define HRPS_HT_MEAS_MAX_LEN (13) #define HRPS_MANDATORY_MASK (0x0F) #define HRPS_BODY_SENSOR_LOC_MASK (0x30) #define HRPS_HR_CTNL_PT_MASK (0xC0) ///Attributes State Machine enum { HRS_IDX_SVC, HRS_IDX_HR_MEAS_CHAR, HRS_IDX_HR_MEAS_VAL, HRS_IDX_HR_MEAS_NTF_CFG, HRS_IDX_BOBY_SENSOR_LOC_CHAR, HRS_IDX_BOBY_SENSOR_LOC_VAL, HRS_IDX_HR_CTNL_PT_CHAR, HRS_IDX_HR_CTNL_PT_VAL, HRS_IDX_NB, };
4,050
/* */ #include #include #include /* Attributes State Machine */ enum { IDX_SVC, IDX_CHAR_A, IDX_CHAR_VAL_A, IDX_CHAR_CFG_A, IDX_CHAR_B, IDX_CHAR_VAL_B, IDX_CHAR_CFG_B, IDX_CHAR_C, IDX_CHAR_VAL_C, IDX_CHAR_CFG_C, IDX_CHAR_CFG_C_2, HRS_IDX_NB, };
4,051
/* */ #ifndef __ESP_EDDYSTONE_API_H__ #define __ESP_EDDYSTONE_API_H__ typedef struct { struct { uint8_t flags; /*<! AD flags data */ uint16_t srv_uuid; /*<! complete list of 16-bit service uuid*/ uint16_t srv_data_type; /*<! service data type */ uint8_t frame_type; /*<! Eddystone UID, URL or TLM */ } common; union { struct { /*<! Eddystone-UID */ int8_t ranging_data; /*<! calibrated Tx power at 0m */ uint8_t namespace_id[10]; uint8_t instance_id[6]; } uid; struct { /*<! Eddystone-URL */ int8_t tx_power; /*<! calibrated Tx power at 0m */ char url[EDDYSTONE_URL_MAX_LEN]; /*<! the decoded URL */ } url; struct { /*<! Eddystone-TLM */ uint8_t version; /*<! TLM version,0x00 for now */ uint16_t battery_voltage; /*<! battery voltage in mV */ float temperature; /*<!
4,052
beacon temperature in degrees Celsius */ uint32_t adv_count; /*<! adv pdu count since power-up */ uint32_t time; /*<! time since power-up, a 0.1 second resolution counter */ } tlm; } inform; } esp_eddystone_result_t; /* utils */ static inline uint16_t little_endian_read_16(const uint8_t *buffer, uint8_t pos) { return ((uint16_t)buffer[pos]) | (((uint16_t)buffer[(pos)+1]) << 8); } static inline uint16_t big_endian_read_16(const uint8_t *buffer, uint8_t pos) { return (((uint16_t)buffer[pos]) << 8) | ((uint16_t)buffer[(pos)+1]); } static inline uint32_t big_endian_read_32(const uint8_t *buffer, uint8_t pos) { return (((uint32_t)buffer[pos]) << 24) | (((uint32_t)buffer[(pos)+1]) << 16) | (((uint32_t)buffer[(pos)+2]) << 8) | ((uint32_t)buffer[(pos)+3]); } /* esp_err_t esp_eddystone_decode(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res); //bool esp_eddystone_is_eddystone_packet(.....); #endif /* __ESP_EDDYSTONE_API_H__ */
4,052
/* */ #ifndef __ESP_EDDYSTONE_PROTOCOL_H__ #define __ESP_EDDYSTONE_PROTOCOL_H__ #include "stdbool.h" #include "stdint.h" /* Eddystone definitions */ #define EDDYSTONE_SERVICE_UUID 0xFEAA #define EDDYSTONE_FRAME_TYPE_UID 0x00 #define EDDYSTONE_FRAME_TYPE_URL 0x10 #define EDDYSTONE_FRAME_TYPE_TLM 0x20 #define EDDYSTONE_FRAME_TYPE_EID 0x30 //UID #define EDDYSTONE_UID_RANG_DATA_LEN 1 #define EDDYSTONE_UID_NAMESPACE_LEN 10 #define EDDYSTONE_UID_INSTANCE_LEN 6 #define EDDYSTONE_UID_RFU_LEN 2 #define EDDYSTONE_UID_DATA_LEN (EDDYSTONE_UID_RANG_DATA_LEN + EDDYSTONE_UID_NAMESPACE_LEN + EDDYSTONE_UID_INSTANCE_LEN) //TLM #define EDDYSTONE_TLM_VERSION_LEN 1 #define EDDYSTONE_TLM_BATTERY_VOLTAGE_LEN 2 #define EDDYSTONE_TLM_TEMPERATURE_LEN 2 #define EDDYSTONE_TLM_ADV_COUNT_LEN 4 #define EDDYSTONE_TLM_TIME_LEN 4 #define EDDYSTONE_TLM_DATA_LEN (EDDYSTONE_TLM_VERSION_LEN + EDDYSTONE_TLM_BATTERY_VOLTAGE_LEN + \ EDDYSTONE_TLM_TEMPERATURE_LEN + EDDYSTONE_TLM_ADV_COUNT_LEN + EDDYSTONE_TLM_TIME_LEN) //URL #define EDDYSTONE_URL_SCHEME_LEN 1 #define EDDYSTONE_URL_ENCODED_MAX_LEN 17 #define EDDYSTONE_URL_MAX_LEN (EDDYSTONE_URL_SCHEME_LEN + EDDYSTONE_URL_ENCODED_MAX_LEN) #define EDDYSTONE_URL_TX_POWER_LEN 1 /* Eddystone UID frame */ typedef struct { int8_t ranging_data; /*= 0x00 && ch = 0x7f && ch <= 0xff); } #endif /* __ESP_EDDYSTONE_PROTOCOL_H__ */
4,053
/* */ #include #include #include /* */ //#define SUPPORT_HEARTBEAT //#define SPP_DEBUG_MODE #define spp_sprintf(s,...) sprintf((char*)(s), ##__VA_ARGS__) #define SPP_DATA_MAX_LEN (512) #define SPP_CMD_MAX_LEN (20) #define SPP_STATUS_MAX_LEN (20) #define SPP_DATA_BUFF_MAX_LEN (2*1024) ///Attributes State Machine enum{ SPP_IDX_SVC, SPP_IDX_SPP_DATA_RECV_CHAR, SPP_IDX_SPP_DATA_RECV_VAL, SPP_IDX_SPP_DATA_NOTIFY_CHAR, SPP_IDX_SPP_DATA_NTY_VAL, SPP_IDX_SPP_DATA_NTF_CFG, SPP_IDX_SPP_COMMAND_CHAR, SPP_IDX_SPP_COMMAND_VAL, SPP_IDX_SPP_STATUS_CHAR, SPP_IDX_SPP_STATUS_VAL, SPP_IDX_SPP_STATUS_CFG, #ifdef SUPPORT_HEARTBEAT SPP_IDX_SPP_HEARTBEAT_CHAR, SPP_IDX_SPP_HEARTBEAT_VAL, SPP_IDX_SPP_HEARTBEAT_CFG, #endif SPP_IDX_NB, };
4,054
/* */ / #include #include #include #include #include "esp_gap_ble_api.h" #include "esp_gattc_api.h" #define IBEACON_SENDER 0 #define IBEACON_RECEIVER 1 #define IBEACON_MODE CONFIG_IBEACON_MODE /* Major and Minor part are stored in big endian mode in iBeacon packet, #define ENDIAN_CHANGE_U16(x) ((((x)&0xFF00)>>8) + (((x)&0xFF)<<8)) /* Espressif WeChat official account can be found using WeChat "Yao Yi Yao Zhou Bian", #define ESP_UUID {0xFD, 0xA5, 0x06, 0x93, 0xA4, 0xE2, 0x4F, 0xB1, 0xAF, 0xCF, 0xC6, 0xEB, 0x07, 0x64, 0x78, 0x25} #define ESP_MAJOR 10167 #define ESP_MINOR 61958 typedef struct { uint8_t flags[3]; uint8_t length; uint8_t type; uint16_t company_id; uint16_t beacon_type; }__attribute__((packed)) esp_ble_ibeacon_head_t; typedef struct { uint8_t proximity_uuid[16]; uint16_t major; uint16_t minor; int8_t measured_power; }__attribute__((packed)) esp_ble_ibeacon_vendor_t; typedef struct { esp_ble_ibeacon_head_t ibeacon_head; esp_ble_ibeacon_vendor_t ibeacon_vendor; }__attribute__((packed)) esp_ble_ibeacon_t; /* For iBeacon packet format, please refer to Apple "Proximity Beacon Specification" doc */ /* Constant part of iBeacon data */ extern esp_ble_ibeacon_head_t ibeacon_common_head; bool esp_ble_is_ibeacon_packet (uint8_t *adv_data, uint8_t adv_data_len); esp_err_t esp_ble_config_ibeacon_data (esp_ble_ibeacon_vendor_t *vendor_config, esp_ble_ibeacon_t *ibeacon_adv_data);
4,055
/* */ #include #include #include //EventID values typedef enum { EventIDNotificationAdded = 0, EventIDNotificationModified = 1, EventIDNotificationRemoved = 2, //Reserved EventID values = 3–255 } esp_EventID; //EventFlags typedef enum { EventFlagSilent = (1 << 0), EventFlagImportant = (1 << 1), EventFlagPreExisting = (1 << 2), EventFlagPositiveAction = (1 << 3), EventFlagNegativeAction = (1 << 4), //Reserved EventFlags = (1 << 5)–(1 << 7 }esp_EventFlags; // CategoryID values typedef enum { CategoryIDOther = 0, CategoryIDIncomingCall = 1, CategoryIDMissedCall = 2, CategoryIDVoicemail = 3, CategoryIDSocial = 4, CategoryIDSchedule = 5, CategoryIDEmail = 6, CategoryIDNews = 7, CategoryIDHealthAndFitness = 8, CategoryIDBusinessAndFinance = 9, CategoryIDLocation = 10, CategoryIDEntertainment = 11, //Reserved CategoryID values = 12–255 } esp_CategoryID; //CommandID values typedef enum { CommandIDGetNotificationAttributes = 0, CommandIDGetAppAttributes = 1, CommandIDPerformNotificationAction = 2, //Reserved CommandID values = 3–255 } esp_CommandID; //NotificationAttributeID typedef enum { NotificationAttributeIDAppIdentifier = 0, NotificationAttributeIDTitle = 1, //(Needs to be followed by a 2-bytes max length parameter) NotificationAttributeIDSubtitle = 2, //(Needs to be followed by a 2-bytes max length parameter) NotificationAttributeIDMessage = 3, //(Needs to be followed by a 2-bytes max length parameter) NotificationAttributeIDMessageSize = 4, NotificationAttributeIDDate = 5, NotificationAttributeIDPositiveActionLabel = 6, NotificationAttributeIDNegativeActionLabel = 7, //Reserved NotificationAttributeID values = 8–255 } esp_NotificationAttributeID; /* Note: The format of the NotificationAttributeIDMessageSize constant is a string that represents the integral value of the message size.
4,056
The format of the NotificationAttributeIDDate constant is a string that uses the Unicode Technical Standard (UTS) #35 date format pattern yyyyMMdd'T'HHmmSS. The format of all the other constants in Table 3-5 are UTF-8 strings. */ //ActionID values typedef enum { ActionIDPositive = 0, ActionIDNegative = 1, //Reserved ActionID values = 2–255 } esp_ActionID; //AppAttributeID Values typedef enum { AppAttributeIDDisplayName = 0, //Reserved AppAttributeID values = 1–255 } esp_AppAttributeID; typedef struct { uint8_t noti_attribute_id; uint16_t attribute_len; } esp_noti_attr_list_t; typedef enum { Unknown_command = (0xA0), //The commandID was not recognized by the NP. Invalid_command = (0xA1), //The command was improperly formatted. Invalid_parameter = (0xA2), // One of the parameters (for example, the NotificationUID) does not refer to an existing object on the NP. Action_failed = (0xA3), //The action was not performed } esp_error_code; typedef enum { attr_appidentifier_index = 0, //The commandID was not recognized by the NP.
4,056
attr_title_index, attr_subtitle_index, attr_message_index, attr_messagesize_index, attr_date_index, attr_positiveactionlabel_index, attr_negativeactionlabel_index, } esp_attr_index; #define ESP_NOTIFICATIONUID_LEN 4 char *EventID_to_String(uint8_t EventID); char *CategoryID_to_String(uint8_t CategoryID); void esp_receive_apple_notification_source(uint8_t *message, uint16_t message_len); void esp_receive_apple_data_source(uint8_t *message, uint16_t message_len); char *Errcode_to_String(uint16_t status);
4,056
/* */ #include #include #include /* Attributes State Machine */ enum { IDX_SVC, IDX_CHAR_A, IDX_CHAR_VAL_A, IDX_CHAR_CFG_A, IDX_CHAR_B, IDX_CHAR_VAL_B, IDX_CHAR_C, IDX_CHAR_VAL_C, HRS_IDX_NB, };
4,057
/* */ #ifndef __BT_APP_CORE_H__ #define __BT_APP_CORE_H__ #include #include #include /* log tag */ #define BT_APP_CORE_TAG "BT_APP_CORE" /* signal for `bt_app_work_dispatch` */ #define BT_APP_SIG_WORK_DISPATCH (0x01) /** */ typedef void (* bt_app_cb_t) (uint16_t event, void *param); /* message to be sent */ typedef struct { uint16_t sig; /*!< signal to bt_app_task */ uint16_t event; /*!< message event id */ bt_app_cb_t cb; /*!< context switch callback */ void *param; /*!< parameter area needs to be last */ } bt_app_msg_t; /** */ typedef void (* bt_app_copy_cb_t) (void *p_dest, void *p_src, int len); /** */ bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback); /** */ void bt_app_task_start_up(void); /** */ void bt_app_task_shut_down(void); /** */ void bt_i2s_task_start_up(void); /** */ void bt_i2s_task_shut_down(void); /** */ size_t write_ringbuf(const uint8_t *data, size_t size); #endif /* __BT_APP_CORE_H__ */
4,058
/* */ #ifndef __BT_APP_AV_H__ #define __BT_APP_AV_H__ #include #include "esp_a2dp_api.h" #include "esp_avrc_api.h" /* log tags */ #define BT_AV_TAG "BT_AV" #define BT_RC_TG_TAG "RC_TG" #define BT_RC_CT_TAG "RC_CT" /** */ void bt_app_a2d_cb(esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param); /** */ void bt_app_a2d_data_cb(const uint8_t *data, uint32_t len); /** */ void bt_app_rc_ct_cb(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t *param); /** */ void bt_app_rc_tg_cb(esp_avrc_tg_cb_event_t event, esp_avrc_tg_cb_param_t *param); #endif /* __BT_APP_AV_H__*/
4,059
/* */ #include #include #include /* Attributes State Machine */ enum { IDX_SVC, IDX_CHAR_A, IDX_CHAR_VAL_A, IDX_CHAR_CFG_A, IDX_CHAR_B, IDX_CHAR_VAL_B, IDX_CHAR_C, IDX_CHAR_VAL_C, HRS_IDX_NB, };
4,060
/* */ #ifndef __APP_HF_MSG_SET_H__ #define __APP_HF_MSG_SET_H__ #define HF_MSG_ARGS_MAX (8) typedef int (* hf_cmd_handler)(int argn, char **argv); typedef struct { const char *str; hf_cmd_handler handler; } hf_msg_hdl_t; void register_hfp_ag(void); #endif /* __APP_HF_MSG_SET_H__*/
4,061
/* */ #ifndef __GPIO_PCM_CONFIG_H__ #define __GPIO_PCM_CONFIG_H__ #define ACOUSTIC_ECHO_CANCELLATION_ENABLE 1 void app_gpio_pcm_io_cfg(void); #if ACOUSTIC_ECHO_CANCELLATION_ENABLE void app_gpio_aec_io_cfg(void); #endif /* ACOUSTIC_ECHO_CANCELLATION_ENABLE */ #endif /* #define __GPIO_PCM_CONFIG_H__ */
4,062
/* */ #ifndef __BT_APP_CORE_H__ #define __BT_APP_CORE_H__ #include #include #include #define BT_APP_CORE_TAG "BT_APP_CORE" #define BT_APP_SIG_WORK_DISPATCH (0x01) /** */ typedef void (* bt_app_cb_t) (uint16_t event, void *param); /* message to be sent */ typedef struct { uint16_t sig; /*!< signal to bt_app_task */ uint16_t event; /*!< message event id */ bt_app_cb_t cb; /*!< context switch callback */ void *param; /*!< parameter area needs to be last */ } bt_app_msg_t; /** */ typedef void (* bt_app_copy_cb_t) (bt_app_msg_t *msg, void *p_dest, void *p_src); /** */ bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback); void bt_app_task_start_up(void); void bt_app_task_shut_down(void); #endif /* __BT_APP_CORE_H__ */
4,063
/* */ #ifndef __BT_APP_HF_H__ #define __BT_APP_HF_H__ #include #include "esp_hf_ag_api.h" #include "esp_bt_defs.h" extern esp_bd_addr_t hf_peer_addr; // Declaration of peer device bdaddr #define BT_HF_TAG "BT_APP_HF" /** */ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param); #endif /* __BT_APP_HF_H__*/
4,064
/* */ #ifndef __APP_HF_MSG_SET_H__ #define __APP_HF_MSG_SET_H__ #define HF_MSG_ARGS_MAX (5) typedef int (* hf_cmd_handler)(int argn, char **argv); typedef struct { const char *str; hf_cmd_handler handler; } hf_msg_hdl_t; void register_hfp_hf(void); #endif /* __APP_HF_MSG_SET_H__*/
4,065
/* */ #ifndef __GPIO_PCM_CONFIG_H__ #define __GPIO_PCM_CONFIG_H__ #define ACOUSTIC_ECHO_CANCELLATION_ENABLE 1 void app_gpio_pcm_io_cfg(void); #if ACOUSTIC_ECHO_CANCELLATION_ENABLE void app_gpio_aec_io_cfg(void); #endif /* ACOUSTIC_ECHO_CANCELLATION_ENABLE */ #endif /* #define __GPIO_PCM_CONFIG_H__ */
4,066
/* */ #ifndef __BT_APP_CORE_H__ #define __BT_APP_CORE_H__ #include #include #include #define BT_APP_CORE_TAG "BT_APP_CORE" #define BT_APP_SIG_WORK_DISPATCH (0x01) /** */ typedef void (* bt_app_cb_t) (uint16_t event, void *param); /* message to be sent */ typedef struct { uint16_t sig; /*!< signal to bt_app_task */ uint16_t event; /*!< message event id */ bt_app_cb_t cb; /*!< context switch callback */ void *param; /*!< parameter area needs to be the last */ } bt_app_msg_t; /** */ typedef void (* bt_app_copy_cb_t) (bt_app_msg_t *msg, void *p_dest, void *p_src); /** */ bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback); void bt_app_task_start_up(void); void bt_app_task_shut_down(void); #endif /* __BT_APP_CORE_H__ */
4,067
/* */ #ifndef __BT_APP_HF_H__ #define __BT_APP_HF_H__ #include #include "esp_hf_client_api.h" #define BT_HF_TAG "BT_HF" /** */ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_t *param); #endif /* __BT_APP_HF_H__*/
4,068
/* */ #ifndef __SPP_TASK_H__ #define __SPP_TASK_H__ #include #include #include #define SPP_TASK_TAG "SPP_TASK" #define SPP_TASK_SIG_WORK_DISPATCH (0x01) /** */ typedef void (* spp_task_cb_t) (uint16_t event, void *param); /* message to be sent */ typedef struct { uint16_t sig; /*!< signal to spp_task_task */ uint16_t event; /*!< message event id */ spp_task_cb_t cb; /*!< context switch callback */ void *param; /*!< parameter area needs to be last */ } spp_task_msg_t; /** */ typedef void (* spp_task_copy_cb_t) (spp_task_msg_t *msg, void *p_dest, void *p_src); /** */ bool spp_task_work_dispatch(spp_task_cb_t p_cback, uint16_t event, void *p_params, int param_len, spp_task_copy_cb_t p_copy_cback); void spp_task_task_start_up(void); void spp_task_task_shut_down(void); /** */ typedef void (* spp_wr_task_cb_t) (void *fd); void spp_wr_task_start_up(spp_wr_task_cb_t p_cback, int fd); void spp_wr_task_shut_down(void); #endif ///__SPP_TASK_H__
4,069
/* */ #ifndef __BT_APP_CORE_H__ #define __BT_APP_CORE_H__ #include #include #include /* log tag */ #define BT_APP_CORE_TAG "BT_APP_CORE" /* signal for `bt_app_work_dispatch` */ #define BT_APP_SIG_WORK_DISPATCH (0x01) /** */ typedef void (* bt_app_cb_t) (uint16_t event, void *param); /** */ typedef void (* l2cap_wr_task_cb_t) (void *fd); /* message to be sent */ typedef struct { uint16_t sig; /*!< signal to bt_app_task */ uint16_t event; /*!< message event id */ bt_app_cb_t cb; /*!< context switch callback */ void *param; /*!< parameter area needs to be last */ } bt_app_msg_t; /** */ typedef void (* bt_app_copy_cb_t) (void *p_dest, void *p_src, int len); /** */ bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback); /** */ void bt_app_task_start_up(void); /** */ void bt_app_task_shut_down(void); void l2cap_wr_task_start_up(l2cap_wr_task_cb_t p_cback, int fd); void l2cap_wr_task_shut_down(void); #endif /* __BT_APP_CORE_H__ */
4,070
/* */ #ifndef __BT_APP_CORE_H__ #define __BT_APP_CORE_H__ #include #include #include /* log tag */ #define BT_APP_CORE_TAG "BT_APP_CORE" /* signal for `bt_app_work_dispatch` */ #define BT_APP_SIG_WORK_DISPATCH (0x01) /** */ typedef void (* bt_app_cb_t) (uint16_t event, void *param); /* message to be sent */ typedef struct { uint16_t sig; /*!< signal to bt_app_task */ uint16_t event; /*!< message event id */ bt_app_cb_t cb; /*!< context switch callback */ void *param; /*!< parameter area needs to be last */ } bt_app_msg_t; /** */ typedef void (* bt_app_copy_cb_t) (void *p_dest, void *p_src, int len); /** */ bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback); /** */ void bt_app_task_start_up(void); /** */ void bt_app_task_shut_down(void); /** */ void bt_i2s_task_start_up(void); /** */ void bt_i2s_task_shut_down(void); /** */ size_t write_ringbuf(const uint8_t *data, size_t size); #endif /* __BT_APP_CORE_H__ */
4,071
/* */ #ifndef __BT_APP_AV_H__ #define __BT_APP_AV_H__ #include #include "esp_a2dp_api.h" #include "esp_avrc_api.h" /* log tags */ #define BT_AV_TAG "BT_AV" #define BT_RC_TG_TAG "RC_TG" #define BT_RC_CT_TAG "RC_CT" /** */ void bt_app_a2d_cb(esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param); /** */ void bt_app_a2d_data_cb(const uint8_t *data, uint32_t len); /** */ void bt_app_rc_ct_cb(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t *param); /** */ void bt_app_rc_tg_cb(esp_avrc_tg_cb_event_t event, esp_avrc_tg_cb_param_t *param); #endif /* __BT_APP_AV_H__*/
4,072
/* */ #ifndef __SPP_TASK_H__ #define __SPP_TASK_H__ #include #include #include #define SPP_TASK_TAG "SPP_TASK" #define SPP_TASK_SIG_WORK_DISPATCH (0x01) /** */ typedef void (* spp_task_cb_t) (uint16_t event, void *param); /* message to be sent */ typedef struct { uint16_t sig; /*!< signal to spp_task_task */ uint16_t event; /*!< message event id */ spp_task_cb_t cb; /*!< context switch callback */ void *param; /*!< parameter area needs to be last */ } spp_task_msg_t; /** */ typedef void (* spp_task_copy_cb_t) (spp_task_msg_t *msg, void *p_dest, void *p_src); /** */ bool spp_task_work_dispatch(spp_task_cb_t p_cback, uint16_t event, void *p_params, int param_len, spp_task_copy_cb_t p_copy_cback); void spp_task_task_start_up(void); void spp_task_task_shut_down(void); /** */ typedef void (* spp_wr_task_cb_t) (void *fd); void spp_wr_task_start_up(spp_wr_task_cb_t p_cback, int fd); void spp_wr_task_shut_down(void); #endif ///__SPP_TASK_H__
4,073
/* */ #ifndef __APP_SPP_MSG_PRS_H__ #define __APP_SPP_MSG_PRS_H__ typedef enum { SPP_MSG_PRS_ERR_OK = 0, // a complete message is finished SPP_MSG_PRS_ERR_IN_PROGRESS, // message parsing is in progress SPP_MSG_PRS_ERR_HDR_UNDETECTED, // header not detected SPP_MSG_PRS_ERR_HDR_SYNC_FAILED, // failed to sync header SPP_MSG_PRS_ERR_BUF_OVERFLOW, // exceeds the buffer size: SPP_MSG_LEN_MAX } spp_msg_prs_err_t; typedef enum { SPP_MSG_PRS_IDLE = 0, SPP_MSG_PRS_HDR, SPP_MSG_PRS_PAYL, } spp_msg_prs_state_t; typedef void (*spp_msg_callback)(char *buf, int len); #define SPP_MSG_LEN_MAX (128) typedef struct { spp_msg_prs_state_t state; char buf[SPP_MSG_LEN_MAX + 1]; int cnt; int h_idx; int t_idx; spp_msg_callback callback; } spp_msg_prs_cb_t; void spp_msg_parser_reset_state(spp_msg_prs_cb_t *prs); void spp_msg_parser_register_callback(spp_msg_prs_cb_t *prs, spp_msg_callback cb); spp_msg_prs_err_t spp_msg_parse(char c, spp_msg_prs_cb_t *prs); void spp_msg_show_usage(void); #endif /* __APP_SPP_MSG_PRS_H__*/
4,074
/* */ #ifndef __APP_SPP_MSG_SET_H__ #define __APP_SPP_MSG_SET_H__ #define SPP_MSG_ARGS_MAX (5) typedef void (* spp_cmd_handler)(int argn, char **argv); typedef struct { uint16_t opcode; const char *str; spp_cmd_handler handler; } spp_msg_hdl_t; extern spp_msg_hdl_t *spp_get_cmd_tbl(void); extern size_t spp_get_cmd_tbl_size(void); void spp_msg_show_usage(void); #endif /* __APP_SPP_MSG_SET_H__*/
4,075
/* */ #ifndef __CONSOLE_UART_H__ #define __CONSOLE_UART_H__ #define TAG_CNSL "CNSL" /** */ esp_err_t console_uart_init(void); #endif /* __CONSOLE_UART_H__ */
4,076
/* */ #ifndef __BT_APP_CORE_H__ #define __BT_APP_CORE_H__ #include #include #include /* log tag */ #define BT_APP_CORE_TAG "BT_APP_CORE" /* signal for dispatcher */ #define BT_APP_SIG_WORK_DISPATCH (0x01) /** */ typedef void (* bt_app_cb_t) (uint16_t event, void *param); /* message to be sent */ typedef struct { uint16_t sig; /*!< signal to bt_app_task */ uint16_t event; /*!< message event id */ bt_app_cb_t cb; /*!< context switch callback */ void *param; /*!< parameter area needs to be last */ } bt_app_msg_t; /** */ typedef void (* bt_app_copy_cb_t) (void *p_dest, void *p_src, int len); /** */ bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback); /** */ void bt_app_task_start_up(void); /** */ void bt_app_task_shut_down(void); #endif /* __BT_APP_CORE_H__ */
4,077
/* */ #ifndef __BT_APP_CORE_H__ #define __BT_APP_CORE_H__ #include #include #include /* log tag */ #define BT_APP_CORE_TAG "BT_APP_CORE" /* signal for `bt_app_work_dispatch` */ #define BT_APP_SIG_WORK_DISPATCH (0x01) /** */ typedef void (* bt_app_cb_t) (uint16_t event, void *param); /** */ typedef void (* l2cap_wr_task_cb_t) (void *fd); /* message to be sent */ typedef struct { uint16_t sig; /*!< signal to bt_app_task */ uint16_t event; /*!< message event id */ bt_app_cb_t cb; /*!< context switch callback */ void *param; /*!< parameter area needs to be last */ } bt_app_msg_t; /** */ typedef void (* bt_app_copy_cb_t) (void *p_dest, void *p_src, int len); /** */ bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback); /** */ void bt_app_task_start_up(void); /** */ void bt_app_task_shut_down(void); void l2cap_wr_task_start_up(l2cap_wr_task_cb_t p_cback, int fd); void l2cap_wr_task_shut_down(void); #endif /* __BT_APP_CORE_H__ */
4,078
/* */ #ifndef __UART_DRIVER_H__ #define __UART_DRIVER_H__ #include #include #include "esp_bluedroid_hci.h" /** */ void hci_uart_open(void); /** */ void hci_uart_close(void); /** */ void hci_uart_send(uint8_t *data, uint16_t len); /** */ bool hci_check_send_available(void); /** */ esp_err_t hci_register_host_callback(const esp_bluedroid_hci_driver_callbacks_t *callback); #endif /* __UART_DRIVER_H__ */
4,079
/* */ #ifndef H_BLEPRPH_ #define H_BLEPRPH_ #include #include "nimble/ble.h" #include "modlog/modlog.h" #include "esp_peripheral.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_cfg; struct ble_gatt_register_ctxt; /** GATT server. */ #define GATT_SVR_SVC_ALERT_UUID 0x1811 #define GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID 0x2A47 #define GATT_SVR_CHR_NEW_ALERT 0x2A46 #define GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID 0x2A48 #define GATT_SVR_CHR_UNR_ALERT_STAT_UUID 0x2A45 #define GATT_SVR_CHR_ALERT_NOT_CTRL_PT 0x2A44 void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg); int gatt_svr_init(void); #ifdef __cplusplus } #endif #endif
4,080
/* */ #ifndef H_BLE_CTS_CENT_ #define H_BLE_CTS_CENT_ #include "modlog/modlog.h" #include "esp_central.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_adv_fields; struct ble_gap_conn_desc; struct ble_hs_cfg; union ble_store_value; union ble_store_key; /* 16 BIT CCCD UUID */ #define BLE_SVC_CTS_DSC_CLT_CFG_UUID16 0x2902 #ifdef __cplusplus } #endif #endif
4,081
/* */ #ifndef H_BLE_CTS_PRPH_ #define H_BLE_CTS_PRPH_ #include "nimble/ble.h" #include "modlog/modlog.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_cfg; struct ble_gatt_register_ctxt; void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg); int gatt_svr_init(void); #ifdef __cplusplus } #endif #endif
4,082
/* */ #ifndef H_PHY_PRPH_ #define H_PHY_PRPH_ #include #include "nimble/ble.h" #include "modlog/modlog.h" #include "esp_peripheral.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_cfg; struct ble_gatt_register_ctxt; /** Making sure client connects to server having LE PHY UUID */ #define LE_PHY_UUID16 0xABF2 #define LE_PHY_CHR_UUID16 0xABF3 void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg); int gatt_svr_init_le_phy(void); #ifdef __cplusplus } #endif #endif
4,083
/* */ #ifndef H_PHY_CENT_ #define H_PHY_CENT_ #include "modlog/modlog.h" #include "esp_central.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_adv_fields; struct ble_gap_conn_desc; struct ble_hs_cfg; union ble_store_value; union ble_store_key; #define LE_PHY_UUID16 0xABF2 #define LE_PHY_CHR_UUID16 0xABF3 #ifdef __cplusplus } #endif #endif
4,084
// Copyright 2015-2020 The Apache Software Foundation // Modifications Copyright 2017-2020 Espressif Systems (Shanghai) CO., LTD. // // Portions of this software were developed at Runtime Inc, copyright 2015. // // 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 H_BLEPRPH_ #define H_BLEPRPH_ #include #include "nimble/ble.h" #include "modlog/modlog.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_cfg; struct ble_gatt_register_ctxt; /** GATT server. */ #define GATT_SVR_SVC_ALERT_UUID 0x1811 void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg); int gatt_svr_init(void); #ifdef __cplusplus } #endif #endif
4,085
/* */ #ifndef H_BLESPPSERVER_ #define H_BLESPPSERVER_ #include #include "nimble/ble.h" #include "modlog/modlog.h" #include "esp_peripheral.h" #ifdef __cplusplus extern "C" { #endif /* 16 Bit SPP Service UUID */ #define BLE_SVC_SPP_UUID16 0xABF0 /* 16 Bit SPP Service Characteristic UUID */ #define BLE_SVC_SPP_CHR_UUID16 0xABF1 struct ble_hs_cfg; struct ble_gatt_register_ctxt; #ifdef __cplusplus } #endif #endif
4,086
/* */ #ifndef H_BLESPPCLIENT_ #define H_BLESPPCLIENT_ #include "modlog/modlog.h" #include "esp_central.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_adv_fields; struct ble_gap_conn_desc; struct ble_hs_cfg; union ble_store_value; union ble_store_key; /* 16 Bit SPP Service UUID */ #define GATT_SPP_SVC_UUID 0xABF0 /* 16 Bit SPP Service Characteristic UUID */ #define GATT_SPP_CHR_UUID 0xABF1 #ifdef __cplusplus } #endif #endif
4,087
/* */ #ifndef H_ENC_ADV_DATA_PRPH_ #define H_ENC_ADV_DATA_PRPH_ #if CONFIG_EXAMPLE_ENC_ADV_DATA #include #include "nimble/ble.h" #include "modlog/modlog.h" #include "esp_peripheral.h" #include "host/ble_ead.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_cfg; struct ble_gatt_register_ctxt; void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg); int gatt_svr_init(void); #ifdef __cplusplus } #endif #endif #endif
4,088
/* */ #ifndef H_ENC_ADV_DATA_CENT_ #define H_ENC_ADV_DATA_CENT_ #if CONFIG_EXAMPLE_ENC_ADV_DATA #include "modlog/modlog.h" #include "esp_central.h" #include "host/ble_ead.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_adv_fields; struct ble_gap_conn_desc; struct ble_hs_cfg; union ble_store_value; union ble_store_key; #define BLE_SVC_GAP_UUID16 0x1800 #define BLE_SVC_GAP_CHR_UUID16_DEVICE_NAME 0x2a00 #define BLE_SVC_GAP_CHR_UUID16_KEY_MATERIAL 0x2B88 struct km_peer { bool key_material_exist; uint8_t peer_addr[PEER_ADDR_VAL_SIZE]; }; #ifdef __cplusplus } #endif #endif #endif
4,089
/* */ #ifndef H_COC_BLEPRPH_ #define H_COC_BLEPRPH_ #include #include "nimble/ble.h" #include "modlog/modlog.h" #include "esp_peripheral.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_cfg; struct ble_gatt_register_ctxt; /** Making sure client connects to server having L2CAP COC UUID */ #define L2CAP_COC_UUID 0x1812 void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg); int gatt_svr_init(void); #ifdef __cplusplus } #endif #endif
4,090
/* */ #ifndef H_COC_BLECENT_ #define H_COC_BLECENT_ #include "modlog/modlog.h" #include "esp_central.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_adv_fields; struct ble_gap_conn_desc; struct ble_hs_cfg; union ble_store_value; union ble_store_key; #ifdef __cplusplus } #endif #endif
4,091
/* */ #ifndef H_BLEPRPH_ #define H_BLEPRPH_ #include #include "nimble/ble.h" #include "modlog/modlog.h" #include "esp_peripheral.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_cfg; struct ble_gatt_register_ctxt; /** GATT server. */ #define GATT_SVR_SVC_ALERT_UUID 0x1811 #define GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID 0x2A47 #define GATT_SVR_CHR_NEW_ALERT 0x2A46 #define GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID 0x2A48 #define GATT_SVR_CHR_UNR_ALERT_STAT_UUID 0x2A45 #define GATT_SVR_CHR_ALERT_NOT_CTRL_PT 0x2A44 void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg); int gatt_svr_init(void); #ifdef __cplusplus } #endif #endif
4,092
/* */ #ifndef H_BLE_HTP_PRPH_ #define H_BLE_HTP_PRPH_ #include "nimble/ble.h" #include "modlog/modlog.h" #include "services/htp/ble_svc_htp.h" #ifdef __cplusplus extern "C" { #endif /* 16 Bit Device Information Service Characteristic UUIDs */ #define GATT_DIS_DEVICE_INFO_UUID 0x180A #define GATT_DIS_CHR_UUID16_SYS_ID 0x2A23 #define GATT_DIS_CHR_UUID16_MODEL_NO 0x2A24 #define GATT_DIS_CHR_UUID16_MFC_NAME 0x2A29 struct ble_hs_cfg; struct ble_gatt_register_ctxt; void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg); int gatt_svr_init(void); #ifdef __cplusplus } #endif #endif
4,093
/* */ #ifndef H_BLE_HTP_CENT_ #define H_BLE_HTP_CENT_ #include "modlog/modlog.h" #include "esp_central.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_adv_fields; struct ble_gap_conn_desc; struct ble_hs_cfg; union ble_store_value; union ble_store_key; /* 16 Bit Health Thermometer Service UUID */ #define BLE_SVC_HTP_UUID16 0x1809 /* 16 Bit Health Thermometer Service Characteristic UUIDs */ #define BLE_SVC_HTP_CHR_UUID16_TEMP_MEASUREMENT 0x2A1C #define BLE_SVC_HTP_CHR_UUID16_TEMP_TYPE 0x2A1D #define BLE_SVC_HTP_CHR_UUID16_INTERMEDIATE_TEMP 0x2A1E #define BLE_SVC_HTP_CHR_UUID16_MEASUREMENT_ITVL 0x2A21 /* 16 Bit Device Information Service Characteristic UUIDs */ #define GATT_DIS_DEVICE_INFO_UUID 0x180A #define GATT_DIS_CHR_UUID16_SYS_ID 0x2A23 #define GATT_DIS_CHR_UUID16_MODEL_NO 0x2A24 #define GATT_DIS_CHR_UUID16_MFC_NAME 0x2A29 /* 16 BIT CCCD UUID */ #define BLE_SVC_HTP_DSC_CLT_CFG_UUID16 0x2902 #ifdef __cplusplus } #endif #endif
4,094
/* */ #ifndef H_BLEPRPH_ #define H_BLEPRPH_ #include #include "nimble/ble.h" #include "modlog/modlog.h" #include "esp_peripheral.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_cfg; struct ble_gatt_register_ctxt; /** GATT server. */ #define GATT_SVR_SVC_ALERT_UUID 0x1811 #define GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID 0x2A47 #define GATT_SVR_CHR_NEW_ALERT 0x2A46 #define GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID 0x2A48 #define GATT_SVR_CHR_UNR_ALERT_STAT_UUID 0x2A45 #define GATT_SVR_CHR_ALERT_NOT_CTRL_PT 0x2A44 void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg); int gatt_svr_init(void); #ifdef __cplusplus } #endif #endif
4,095
/* */ #ifndef __UART_DRIVER_H__ #define __UART_DRIVER_H__ #include #include /** */ void hci_uart_open(void); /** */ void hci_uart_close(void); /** */ void hci_uart_send(uint8_t *data, uint16_t len); #endif /* __UART_DRIVER_H__ */
4,096
/* */ #ifndef H_BLECENT_ #define H_BLECENT_ #include "modlog/modlog.h" #include "esp_central.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_adv_fields; struct ble_gap_conn_desc; struct ble_hs_cfg; union ble_store_value; union ble_store_key; #define BLECENT_SVC_ALERT_UUID 0x1811 #define BLECENT_CHR_SUP_NEW_ALERT_CAT_UUID 0x2A47 #define BLECENT_CHR_NEW_ALERT 0x2A46 #define BLECENT_CHR_SUP_UNR_ALERT_CAT_UUID 0x2A48 #define BLECENT_CHR_UNR_ALERT_STAT_UUID 0x2A45 #define BLECENT_CHR_ALERT_NOT_CTRL_PT 0x2A44 #ifdef __cplusplus } #endif #endif
4,097
/* */ #ifndef H_BLE_PERIODIC_ADV_ #define H_BLE_PERIODIC_ADV_ #include #include "nimble/ble.h" #include "modlog/modlog.h" #include "esp_peripheral.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_cfg; struct ble_gatt_register_ctxt; #ifdef __cplusplus } #endif #endif
4,099
/* */ #pragma once #ifdef __cplusplus extern "C" { #endif // Register system functions void register_system(void); #ifdef __cplusplus } #endif
4,100
/* */ #ifndef H_BLECENT_ #define H_BLECENT_ #pragma once #include "modlog/modlog.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_adv_fields; struct ble_gap_conn_desc; struct ble_hs_cfg; union ble_store_value; union ble_store_key; #define BLECENT_SVC_ALERT_UUID 0x1811 #define BLECENT_CHR_SUP_NEW_ALERT_CAT_UUID 0x2A47 #define BLECENT_CHR_NEW_ALERT 0x2A46 #define BLECENT_CHR_SUP_UNR_ALERT_CAT_UUID 0x2A48 #define BLECENT_CHR_UNR_ALERT_STAT_UUID 0x2A45 #define BLECENT_CHR_ALERT_NOT_CTRL_PT 0x2A44 /** Misc. */ void print_bytes(const uint8_t *bytes, int len); void print_mbuf(const struct os_mbuf *om); char *addr_str(const void *addr); void print_uuid(const ble_uuid_t *uuid); void print_conn_desc(const struct ble_gap_conn_desc *desc); void print_adv_fields(const struct ble_hs_adv_fields *fields); /** Peer. */ struct peer_dsc { SLIST_ENTRY(peer_dsc) next; struct ble_gatt_dsc dsc; }; SLIST_HEAD(peer_dsc_list, peer_dsc); struct peer_chr { SLIST_ENTRY(peer_chr) next; struct ble_gatt_chr chr; struct peer_dsc_list dscs; }; SLIST_HEAD(peer_chr_list, peer_chr); struct peer_svc { SLIST_ENTRY(peer_svc) next; struct ble_gatt_svc svc; struct peer_chr_list chrs; }; SLIST_HEAD(peer_svc_list, peer_svc); struct peer; typedef void peer_disc_fn(const struct peer *peer, int status, void *arg); struct peer { SLIST_ENTRY(peer) next; uint16_t conn_handle; /** List of discovered GATT services.
4,101
*/ struct peer_svc_list svcs; /** Keeps track of where we are in the service discovery process. */ uint16_t disc_prev_chr_val; struct peer_svc *cur_svc; /** Callback that gets executed when service discovery completes. */ peer_disc_fn *disc_cb; void *disc_cb_arg; }; int peer_disc_all(uint16_t conn_handle, peer_disc_fn *disc_cb, void *disc_cb_arg); const struct peer_dsc * peer_dsc_find_uuid(const struct peer *peer, const ble_uuid_t *svc_uuid, const ble_uuid_t *chr_uuid, const ble_uuid_t *dsc_uuid); const struct peer_chr * peer_chr_find_uuid(const struct peer *peer, const ble_uuid_t *svc_uuid, const ble_uuid_t *chr_uuid); const struct peer_svc * peer_svc_find_uuid(const struct peer *peer, const ble_uuid_t *uuid); int peer_delete(uint16_t conn_handle); int peer_add(uint16_t conn_handle); int peer_init(int max_peers, int max_svcs, int max_chrs, int max_dscs); struct peer * peer_find(uint16_t conn_handle); /* Console */ int scli_init(void); void ble_register_cli(void); int scli_receive_key(int *key); int cli_receive_key(int *key); int scli_receive_yesno(bool *key); void scli_reset_queue(void); #ifdef __cplusplus } #endif #endif
4,101
/* */ #ifndef H_GATTS_SENS_ #define H_GATTS_SENS_ #include "nimble/ble.h" #include "modlog/modlog.h" #ifdef __cplusplus extern "C" { #endif extern uint16_t notify_handle; struct ble_hs_cfg; struct ble_gatt_register_ctxt; void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg); int gatt_svr_init(void); #ifdef __cplusplus } #endif #endif
4,102
/* */ #ifndef H_ESP_CENTRAL_ #define H_ESP_CENTRAL_ #include "modlog/modlog.h" #ifdef __cplusplus extern "C" { #endif #define PEER_ADDR_VAL_SIZE 6 /** Misc. */ void print_bytes(const uint8_t *bytes, int len); void print_mbuf(const struct os_mbuf *om); void print_mbuf_data(const struct os_mbuf *om); char *addr_str(const void *addr); void print_uuid(const ble_uuid_t *uuid); void print_conn_desc(const struct ble_gap_conn_desc *desc); void print_adv_fields(const struct ble_hs_adv_fields *fields); void ext_print_adv_report(const void *param); /** Peer. */ struct peer_dsc { SLIST_ENTRY(peer_dsc) next; struct ble_gatt_dsc dsc; }; SLIST_HEAD(peer_dsc_list, peer_dsc); struct peer_chr { SLIST_ENTRY(peer_chr) next; struct ble_gatt_chr chr; struct peer_dsc_list dscs; }; SLIST_HEAD(peer_chr_list, peer_chr); struct peer_svc { SLIST_ENTRY(peer_svc) next; struct ble_gatt_svc svc; struct peer_chr_list chrs; }; SLIST_HEAD(peer_svc_list, peer_svc); struct peer; typedef void peer_disc_fn(const struct peer *peer, int status, void *arg); /** typedef int peer_traverse_fn(const struct peer *peer, void *arg); struct peer { SLIST_ENTRY(peer) next; uint16_t conn_handle; uint8_t peer_addr[PEER_ADDR_VAL_SIZE]; /** List of discovered GATT services.
4,103
*/ struct peer_svc_list svcs; /** Keeps track of where we are in the service discovery process. */ uint16_t disc_prev_chr_val; struct peer_svc *cur_svc; /** Callback that gets executed when service discovery completes. */ peer_disc_fn *disc_cb; void *disc_cb_arg; }; void peer_traverse_all(peer_traverse_fn *trav_cb, void *arg); int peer_disc_svc_by_uuid(uint16_t conn_handle, const ble_uuid_t *uuid, peer_disc_fn *disc_cb, void *disc_cb_arg); int peer_disc_all(uint16_t conn_handle, peer_disc_fn *disc_cb, void *disc_cb_arg); const struct peer_dsc * peer_dsc_find_uuid(const struct peer *peer, const ble_uuid_t *svc_uuid, const ble_uuid_t *chr_uuid, const ble_uuid_t *dsc_uuid); const struct peer_chr * peer_chr_find_uuid(const struct peer *peer, const ble_uuid_t *svc_uuid, const ble_uuid_t *chr_uuid); const struct peer_svc * peer_svc_find_uuid(const struct peer *peer, const ble_uuid_t *uuid); int peer_delete(uint16_t conn_handle); int peer_add(uint16_t conn_handle); int peer_init(int max_peers, int max_svcs, int max_chrs, int max_dscs); struct peer * peer_find(uint16_t conn_handle); #if MYNEWT_VAL(ENC_ADV_DATA) int peer_set_addr(uint16_t conn_handle, uint8_t *peer_addr); #endif #ifdef __cplusplus } #endif #endif
4,103
/* */ #ifndef H_ESP_PERIPHERAL_ #define H_ESP_PERIPHERAL_ #include #include "nimble/ble.h" #include "modlog/modlog.h" #ifdef __cplusplus extern "C" { #endif /* Console */ int scli_init(void); int scli_receive_key(int *key); /** Misc. */ void print_bytes(const uint8_t *bytes, int len); void print_addr(const void *addr); char *addr_str(const void *addr); void print_mbuf(const struct os_mbuf *om); #ifdef __cplusplus } #endif #endif
4,104
/* */ #ifndef H_BLE_DYNAMIC_SERVICE_ #define H_BLE_DYNAMIC_SERVICE_ #include #include "nimble/ble.h" #include "modlog/modlog.h" #include "esp_peripheral.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_cfg; struct ble_gatt_register_ctxt; /** GATT server. */ #define GATT_SVR_SVC_ALERT_UUID 0x1811 #define GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID 0x2A47 #define GATT_SVR_CHR_NEW_ALERT 0x2A46 #define GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID 0x2A48 #define GATT_SVR_CHR_UNR_ALERT_STAT_UUID 0x2A45 #define GATT_SVR_CHR_ALERT_NOT_CTRL_PT 0x2A44 void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg); int gatt_svr_init(void); int dynamic_service(const uint8_t operation, const struct ble_gatt_svc_def *svcs, const ble_uuid_t *uuid); #ifdef __cplusplus } #endif #endif
4,105
/* */ #ifndef H_BLEHR_SENSOR_ #define H_BLEHR_SENSOR_ #include "nimble/ble.h" #include "modlog/modlog.h" #ifdef __cplusplus extern "C" { #endif /* Heart-rate configuration */ #define GATT_HRS_UUID 0x180D #define GATT_HRS_MEASUREMENT_UUID 0x2A37 #define GATT_HRS_BODY_SENSOR_LOC_UUID 0x2A38 #define GATT_DEVICE_INFO_UUID 0x180A #define GATT_MANUFACTURER_NAME_UUID 0x2A29 #define GATT_MODEL_NUMBER_UUID 0x2A24 extern uint16_t hrs_hrm_handle; struct ble_hs_cfg; struct ble_gatt_register_ctxt; void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg); int gatt_svr_init(void); #ifdef __cplusplus } #endif #endif
4,106
/* */ #ifndef H_BLE_PROX_PRPH_ #define H_BLE_PROX_PRPH_ #include "nimble/ble.h" #include "modlog/modlog.h" #include "services/prox/ble_svc_prox.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_cfg; struct ble_gatt_register_ctxt; #ifdef __cplusplus } #endif #endif
4,107
/* */ #ifndef H_BLE_PROX_CENT_ #define H_BLE_PROX_CENT_ #include "modlog/modlog.h" #include "esp_central.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_adv_fields; struct ble_gap_conn_desc; struct ble_hs_cfg; union ble_store_value; union ble_store_key; /* 16 Bit Proximity Sensor Service UUID */ #define BLE_SVC_IMMEDIATE_ALERT_UUID16 0x1802 #define BLE_SVC_LINK_LOSS_UUID16 0x1803 #define BLE_SVC_TX_POWER_UUID16 0x1804 /* 16 Bit Proximity Sensor Service Characteristic UUIDs */ #define BLE_SVC_PROX_CHR_UUID16_ALERT_LVL 0x2A06 #define BLE_SVC_PROX_CHR_UUID16_TX_PWR_LVL 0x2A07 #define BLE_ADDR_LEN 6 struct ble_prox_cent_conn_peer { uint16_t val_handle; bool calc_path_loss; }; struct ble_prox_cent_link_lost_peer { uint8_t *addr; bool link_lost; }; #ifdef __cplusplus } #endif #endif
4,108
/* */ #ifndef H_BLECENT_ #define H_BLECENT_ #include "esp_central.h" #ifdef __cplusplus extern "C" { #endif int gatt_svr_init(void); #ifdef __cplusplus } #endif #endif
4,109
/* */ #ifndef H_BLEPRPH_ #define H_BLEPRPH_ #include #include "nimble/ble.h" #include "modlog/modlog.h" #include "esp_peripheral.h" #ifdef __cplusplus extern "C" { #endif void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg); int gatt_svr_init(void); #ifdef __cplusplus } #endif #endif
4,110
/* */ #ifndef H_BLE_MULTI_ADV_ #define H_BLE_MULTI_ADV_ #include #include "nimble/ble.h" #include "modlog/modlog.h" #include "esp_peripheral.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_cfg; struct ble_gatt_register_ctxt; typedef int ble_instance_cb_fn(uint16_t instance); struct ble_instance_cb_register { ble_addr_t addr; ble_instance_cb_fn *cb; }; void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg); int gatt_svr_init(void); #ifdef __cplusplus } #endif #endif
4,111
/* */ #ifndef H_BLE_PERIODIC_SYNC_ #define H_BLE_PERIODIC_SYNC_ #include "modlog/modlog.h" #include "esp_central.h" #ifdef __cplusplus extern "C" { #endif struct ble_hs_adv_fields; struct ble_gap_conn_desc; struct ble_hs_cfg; union ble_store_value; union ble_store_key; #ifdef __cplusplus } #endif #endif
4,112
/* */ #include "esp_zigbee_core.h" #define ESP_ZB_DEFAULT_RADIO_CONFIG() \ { \ .radio_mode = RADIO_MODE_NATIVE, \ } #define ESP_ZB_DEFAULT_HOST_CONFIG() \ { \ .host_connection_mode = HOST_CONNECTION_MODE_RCP_UART, \ .host_uart_config = { \ .port = 0, \ .uart_config = \ { \ .baud_rate = 115200, \ .data_bits = UART_DATA_8_BITS, \ .parity = UART_PARITY_DISABLE, \ .stop_bits = UART_STOP_BITS_1, \ .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, \ .
4,113
rx_flow_ctrl_thresh = 0, \ .source_clk = UART_SCLK_DEFAULT, \ }, \ .rx_pin = UART_PIN_NO_CHANGE, \ .tx_pin = UART_PIN_NO_CHANGE, \ }, \ }
4,113
/* */ #pragma once #include #ifdef __cplusplus extern "C" { #endif /* light intensity level */ #define LIGHT_DEFAULT_ON 1 #define LIGHT_DEFAULT_OFF 0 /* LED strip configuration */ #define CONFIG_EXAMPLE_STRIP_LED_GPIO 8 #define CONFIG_EXAMPLE_STRIP_LED_NUMBER 1 /** */ void light_driver_set_power(bool power); /** */ void light_driver_init(bool power); #ifdef __cplusplus } // extern "C" #endif
4,114
/* */ #include "esp_zigbee_core.h" #include "light_driver.h" /* Zigbee configuration */ #define INSTALLCODE_POLICY_ENABLE false /* enable the install code policy for security */ #define ED_AGING_TIMEOUT ESP_ZB_ED_AGING_TIMEOUT_64MIN #define ED_KEEP_ALIVE 3000 /* 3000 millisecond */ #define HA_ESP_LIGHT_ENDPOINT 10 /* esp light bulb device endpoint, used to process light controlling commands */ #define ESP_ZB_PRIMARY_CHANNEL_MASK ESP_ZB_TRANSCEIVER_ALL_CHANNELS_MASK /* Zigbee primary channel mask use in the example */ #define ESP_ZB_ZED_CONFIG() \ { \ .esp_zb_role = ESP_ZB_DEVICE_TYPE_ED, \ .install_code_policy = INSTALLCODE_POLICY_ENABLE, \ .nwk_cfg.zed_cfg = { \ .ed_timeout = ED_AGING_TIMEOUT, \ .
4,115
keep_alive = ED_KEEP_ALIVE, \ }, \ } #define ESP_ZB_DEFAULT_RADIO_CONFIG() \ { \ .radio_mode = RADIO_MODE_NATIVE, \ } #define ESP_ZB_DEFAULT_HOST_CONFIG() \ { \ .host_connection_mode = HOST_CONNECTION_MODE_NONE, \ }
4,115
/* */ #pragma once #include "driver/gpio.h" #ifdef __cplusplus extern "C" { #endif /* user should configure which I/O port as toggle switch input, default is GPIO9 */ #define GPIO_INPUT_IO_TOGGLE_SWITCH GPIO_NUM_9 /* config button level depends on the pull up/down setting push button level is on level = 1 when pull-down enable push button level is on level = 0 when pull-up enable */ #define GPIO_INPUT_LEVEL_ON 0 #define ESP_INTR_FLAG_DEFAULT 0 #define PAIR_SIZE(TYPE_STR_PAIR) (sizeof(TYPE_STR_PAIR) / sizeof(TYPE_STR_PAIR[0])) typedef enum { SWITCH_IDLE, SWITCH_PRESS_ARMED, SWITCH_PRESS_DETECTED, SWITCH_PRESSED, SWITCH_RELEASE_DETECTED, } switch_state_t; typedef enum { SWITCH_ON_CONTROL, SWITCH_OFF_CONTROL, SWITCH_ONOFF_TOGGLE_CONTROL, SWITCH_LEVEL_UP_CONTROL, SWITCH_LEVEL_DOWN_CONTROL, SWITCH_LEVEL_CYCLE_CONTROL, SWITCH_COLOR_CONTROL, } switch_func_t; typedef struct { uint32_t pin; switch_func_t func; } switch_func_pair_t; typedef void (*esp_switch_callback_t)(switch_func_pair_t *param); /** */ bool switch_driver_init(switch_func_pair_t *button_func_pair, uint8_t button_num, esp_switch_callback_t cb); #ifdef __cplusplus } // extern "C" #endif
4,116
/* */ #include "esp_zigbee_core.h" #include "switch_driver.h" /* Zigbee configuration */ #define MAX_CHILDREN 10 /* the max amount of connected devices */ #define INSTALLCODE_POLICY_ENABLE false /* enable the install code policy for security */ #define HA_ONOFF_SWITCH_ENDPOINT 1 /* esp light switch device endpoint */ #define ESP_ZB_PRIMARY_CHANNEL_MASK (1l << 13) /* Zigbee primary channel mask use in the example */ #define ESP_ZB_ZC_CONFIG() \ { \ .esp_zb_role = ESP_ZB_DEVICE_TYPE_COORDINATOR, \ .install_code_policy = INSTALLCODE_POLICY_ENABLE, \ .nwk_cfg.zczr_cfg = { \ .max_children = MAX_CHILDREN, \ }, \ } #define ESP_ZB_DEFAULT_RADIO_CONFIG() \ { \ .
4,117
radio_mode = RADIO_MODE_NATIVE, \ } #define ESP_ZB_DEFAULT_HOST_CONFIG() \ { \ .host_connection_mode = HOST_CONNECTION_MODE_NONE, \ }
4,117
/* */ #include "esp_err.h" #include "esp_zigbee_core.h" /* Zigbee Configuration */ #define MAX_CHILDREN 10 /* the max amount of connected devices */ #define INSTALLCODE_POLICY_ENABLE false /* enable the install code policy for security */ #define ESP_ZB_PRIMARY_CHANNEL_MASK (1l << 13) /* Zigbee primary channel mask use in the example */ #define ESP_ZB_ZC_CONFIG() \ { \ .esp_zb_role = ESP_ZB_DEVICE_TYPE_COORDINATOR, \ .install_code_policy = INSTALLCODE_POLICY_ENABLE, \ .nwk_cfg.zczr_cfg = { \ .max_children = MAX_CHILDREN, \ }, \ } #if CONFIG_ZB_RADIO_NATIVE #define ESP_ZB_DEFAULT_RADIO_CONFIG() \ { \ .
4,118