1 /* 2 * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef __BTC_BLUFI_PRF_H__ 8 #define __BTC_BLUFI_PRF_H__ 9 10 #include "blufi_int.h" 11 #include "btc/btc_task.h" 12 #include "esp_blufi_api.h" 13 #include "esp_err.h" 14 15 #ifdef CONFIG_BT_BLUEDROID_ENABLED 16 #include "stack/gatt_api.h" 17 #define ESP_BLUFI_ERROR GATT_ERROR 18 #define ESP_BLUFI_SUCCESS GATT_SUCCESS 19 #else 20 #define ESP_BLUFI_ERROR 0x85 21 #define ESP_BLUFI_SUCCESS 0x00 22 #endif 23 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 #define BT_BD_ADDR_STR "%02x:%02x:%02x:%02x:%02x:%02x" 30 #define BT_BD_ADDR_HEX(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] 31 32 #define GATT_UUID_CHAR_CLIENT_CONFIG 0x2902 /* Client Characteristic Configuration */ 33 //define the blufi serivce uuid 34 #define BLUFI_SERVICE_UUID 0xFFFF 35 //define the blufi Char uuid (PHONE to ESP32) 36 #define BLUFI_CHAR_P2E_UUID 0xFF01 37 //define the blufi Char uuid (ESP32 to PHONE) 38 #define BLUFI_CHAR_E2P_UUID 0xFF02 39 //define the blufi Descriptor uuid (ESP32 to PHONE) 40 #define BLUFI_DESCR_E2P_UUID GATT_UUID_CHAR_CLIENT_CONFIG 41 //define the blufi APP ID 42 #define BLUFI_APP_UUID 0xFFFF 43 44 #define BLUFI_HDL_NUM 6 45 46 struct pkt_info{ 47 uint8_t *pkt; 48 int pkt_len; 49 }; 50 51 static const tBT_UUID blufi_srvc_uuid = {LEN_UUID_16, {BLUFI_SERVICE_UUID}}; 52 static const tBT_UUID blufi_char_uuid_p2e = {LEN_UUID_16, {BLUFI_CHAR_P2E_UUID}}; 53 static const tBT_UUID blufi_char_uuid_e2p = {LEN_UUID_16, {BLUFI_CHAR_E2P_UUID}}; 54 static const tBT_UUID blufi_descr_uuid_e2p = {LEN_UUID_16, {BLUFI_DESCR_E2P_UUID}}; 55 static const tBT_UUID blufi_app_uuid = {LEN_UUID_16, {BLUFI_APP_UUID}}; 56 57 typedef enum { 58 BTC_BLUFI_ACT_INIT = 0, 59 BTC_BLUFI_ACT_DEINIT, 60 BTC_BLUFI_ACT_SEND_CFG_REPORT, 61 BTC_BLUFI_ACT_SEND_WIFI_LIST, 62 BTC_BLUFI_ACT_SEND_ERR_INFO, 63 BTC_BLUFI_ACT_SEND_CUSTOM_DATA, 64 } btc_blufi_act_t; 65 66 typedef union { 67 struct blufi_cfg_report { 68 wifi_mode_t opmode; 69 esp_blufi_sta_conn_state_t sta_conn_state; 70 uint8_t softap_conn_num; 71 esp_blufi_extra_info_t *extra_info; 72 int extra_info_len; 73 } wifi_conn_report; 74 /* 75 BTC_BLUFI_ACT_SEND_WIFI_LIST 76 */ 77 struct blufi_wifi_list { 78 uint16_t apCount; 79 esp_blufi_ap_record_t *list; 80 } wifi_list; 81 /* 82 BTC_BLUFI_ACT_SEND_ERR_INFO 83 */ 84 struct blufi_error_infor { 85 esp_blufi_error_state_t state; 86 } blufi_err_infor; 87 /* 88 BTC_BLUFI_ACT_SEND_CUSTOM_DATA 89 */ 90 struct blufi_custom_data { 91 uint8_t *data; 92 uint32_t data_len; 93 } custom_data; 94 } btc_blufi_args_t; 95 96 void btc_blufi_cb_to_app(esp_blufi_cb_event_t event, esp_blufi_cb_param_t *param); 97 void btc_blufi_cb_handler(btc_msg_t *msg); 98 void btc_blufi_call_handler(btc_msg_t *msg); 99 void btc_blufi_set_callbacks(esp_blufi_callbacks_t *callbacks); 100 101 void btc_blufi_recv_handler(uint8_t *data, int len); 102 void btc_blufi_send_notify(uint8_t *pkt, int pkt_len); 103 void btc_blufi_call_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); 104 void btc_blufi_call_deep_free(btc_msg_t *msg); 105 106 uint16_t btc_blufi_get_version(void); 107 108 #ifdef __cplusplus 109 } 110 #endif 111 #endif /* __BTC_BLUFI_PRF_H__ */ 112