// Copyright 2015-2016 Espressif Systems (Shanghai) PTE 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 __BLUFI_INT_H__ #define __BLUFI_INT_H__ #define BTC_BLUFI_GREAT_VER 0x01 //Version + Subversion #define BTC_BLUFI_SUB_VER 0x02 //Version + Subversion #define BTC_BLUFI_VERSION ((BTC_BLUFI_GREAT_VER<<8)|BTC_BLUFI_SUB_VER) //Version + Subversion /* service engine control block */ typedef struct { /* Protocol reference */ tGATT_IF gatt_if; UINT8 srvc_inst; UINT16 handle_srvc; UINT16 handle_char_p2e; UINT16 handle_char_e2p; UINT16 handle_descr_e2p; UINT16 conn_id; BOOLEAN is_connected; BD_ADDR remote_bda; UINT32 trans_id; UINT8 congest; UINT16 frag_size; #define BLUFI_PREPAIR_BUF_MAX_SIZE 1024 uint8_t *prepare_buf; int prepare_len; /* Control reference */ esp_blufi_callbacks_t *cbs; BOOLEAN enabled; uint8_t send_seq; uint8_t recv_seq; uint8_t sec_mode; uint8_t *aggr_buf; uint16_t total_len; uint16_t offset; } tBLUFI_ENV; /* BLUFI protocol */ struct blufi_hdr{ uint8_t type; uint8_t fc; uint8_t seq; uint8_t data_len; uint8_t data[0]; }; typedef struct blufi_hdr blufi_hd_t; struct blufi_frag_hdr { uint8_t type; uint8_t fc; uint8_t seq; uint8_t data_len; uint16_t total_len; uint8_t content[0]; }; typedef struct blufi_frag_hdr blufi_frag_hdr_t; #define BLUFI_DATA_SEC_MODE_CHECK_MASK 0x01 #define BLUFI_DATA_SEC_MODE_ENC_MASK 0x02 #define BLUFI_CTRL_SEC_MODE_CHECK_MASK 0x10 #define BLUFI_CTRL_SEC_MODE_ENC_MASK 0x20 // packet type #define BLUFI_TYPE_MASK 0x03 #define BLUFI_TYPE_SHIFT 0 #define BLUFI_SUBTYPE_MASK 0xFC #define BLUFI_SUBTYPE_SHIFT 2 #define BLUFI_GET_TYPE(type) ((type) & BLUFI_TYPE_MASK) #define BLUFI_GET_SUBTYPE(type) (((type) & BLUFI_SUBTYPE_MASK) >>BLUFI_SUBTYPE_SHIFT) #define BLUFI_BUILD_TYPE(type, subtype) (((type) & BLUFI_TYPE_MASK) | ((subtype)<