1 // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef __BTC_BLUFI_PRF_H__ 16 #define __BTC_BLUFI_PRF_H__ 17 18 #include "blufi_int.h" 19 #include "btc/btc_task.h" 20 #include "esp_blufi_api.h" 21 #include "esp_err.h" 22 23 #ifdef CONFIG_BT_BLUEDROID_ENABLED 24 #include "stack/gatt_api.h" 25 #define ESP_BLUFI_ERROR GATT_ERROR 26 #define ESP_BLUFI_SUCCESS GATT_SUCCESS 27 #else 28 #define ESP_BLUFI_ERROR 0x85 29 #define ESP_BLUFI_SUCCESS 0x00 30 #endif 31 32 #define BT_BD_ADDR_STR "%02x:%02x:%02x:%02x:%02x:%02x" 33 #define BT_BD_ADDR_HEX(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] 34 35 #define GATT_UUID_CHAR_CLIENT_CONFIG 0x2902 /* Client Characteristic Configuration */ 36 //define the blufi serivce uuid 37 #define BLUFI_SERVICE_UUID 0xFFFF 38 //define the blufi Char uuid (PHONE to ESP32) 39 #define BLUFI_CHAR_P2E_UUID 0xFF01 40 //define the blufi Char uuid (ESP32 to PHONE) 41 #define BLUFI_CHAR_E2P_UUID 0xFF02 42 //define the blufi Descriptor uuid (ESP32 to PHONE) 43 #define BLUFI_DESCR_E2P_UUID GATT_UUID_CHAR_CLIENT_CONFIG 44 //define the blufi APP ID 45 #define BLUFI_APP_UUID 0xFFFF 46 47 #define BLUFI_HDL_NUM 6 48 49 struct pkt_info{ 50 uint8_t *pkt; 51 int pkt_len; 52 }; 53 54 static const tBT_UUID blufi_srvc_uuid = {LEN_UUID_16, {BLUFI_SERVICE_UUID}}; 55 static const tBT_UUID blufi_char_uuid_p2e = {LEN_UUID_16, {BLUFI_CHAR_P2E_UUID}}; 56 static const tBT_UUID blufi_char_uuid_e2p = {LEN_UUID_16, {BLUFI_CHAR_E2P_UUID}}; 57 static const tBT_UUID blufi_descr_uuid_e2p = {LEN_UUID_16, {BLUFI_DESCR_E2P_UUID}}; 58 static const tBT_UUID blufi_app_uuid = {LEN_UUID_16, {BLUFI_APP_UUID}}; 59 60 typedef enum { 61 BTC_BLUFI_ACT_INIT = 0, 62 BTC_BLUFI_ACT_DEINIT, 63 BTC_BLUFI_ACT_SEND_CFG_REPORT, 64 BTC_BLUFI_ACT_SEND_WIFI_LIST, 65 BTC_BLUFI_ACT_SEND_ERR_INFO, 66 BTC_BLUFI_ACT_SEND_CUSTOM_DATA, 67 } btc_blufi_act_t; 68 69 typedef union { 70 struct blufi_cfg_report { 71 wifi_mode_t opmode; 72 esp_blufi_sta_conn_state_t sta_conn_state; 73 uint8_t softap_conn_num; 74 esp_blufi_extra_info_t *extra_info; 75 int extra_info_len; 76 } wifi_conn_report; 77 /* 78 BTC_BLUFI_ACT_SEND_WIFI_LIST 79 */ 80 struct blufi_wifi_list { 81 uint16_t apCount; 82 esp_blufi_ap_record_t *list; 83 } wifi_list; 84 /* 85 BTC_BLUFI_ACT_SEND_ERR_INFO 86 */ 87 struct blufi_error_infor { 88 esp_blufi_error_state_t state; 89 } blufi_err_infor; 90 /* 91 BTC_BLUFI_ACT_SEND_CUSTOM_DATA 92 */ 93 struct blufi_custom_data { 94 uint8_t *data; 95 uint32_t data_len; 96 } custom_data; 97 } btc_blufi_args_t; 98 99 void btc_blufi_cb_to_app(esp_blufi_cb_event_t event, esp_blufi_cb_param_t *param); 100 void btc_blufi_cb_handler(btc_msg_t *msg); 101 void btc_blufi_call_handler(btc_msg_t *msg); 102 void btc_blufi_set_callbacks(esp_blufi_callbacks_t *callbacks); 103 104 void btc_blufi_recv_handler(uint8_t *data, int len); 105 void btc_blufi_send_notify(uint8_t *pkt, int pkt_len); 106 void btc_blufi_call_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); 107 void btc_blufi_call_deep_free(btc_msg_t *msg); 108 109 uint16_t btc_blufi_get_version(void); 110 111 #endif /* __BTC_BLUFI_PRF_H__ */ 112