diff --git a/components/bt/bluedroid/api/esp_blufi_api.c b/components/bt/bluedroid/api/esp_blufi_api.c index 5493824d2..094fbfae5 100644 --- a/components/bt/bluedroid/api/esp_blufi_api.c +++ b/components/bt/bluedroid/api/esp_blufi_api.c @@ -71,4 +71,8 @@ esp_err_t esp_blufi_profile_deinit(void) return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } +uint16_t esp_blufi_get_version(void) +{ + return btc_blufi_get_version(); +} diff --git a/components/bt/bluedroid/api/include/esp_blufi_api.h b/components/bt/bluedroid/api/include/esp_blufi_api.h index 5490fec05..6da651216 100644 --- a/components/bt/bluedroid/api/include/esp_blufi_api.h +++ b/components/bt/bluedroid/api/include/esp_blufi_api.h @@ -344,6 +344,15 @@ esp_err_t esp_blufi_profile_deinit(void); */ esp_err_t esp_blufi_send_wifi_conn_report(wifi_mode_t opmode, esp_blufi_sta_conn_state_t sta_conn_state, uint8_t softap_conn_num, esp_blufi_extra_info_t *extra_info); +/** + * + * @brief Get BLUFI profile version + * + * @return Most 8bit significant is Great version, Least 8bit is Sub version + * + */ +uint16_t esp_blufi_get_version(void); + #ifdef __cplusplus } #endif diff --git a/components/bt/bluedroid/bta/gatt/bta_gatts_act.c b/components/bt/bluedroid/bta/gatt/bta_gatts_act.c index aa00bf287..04bb3ee7c 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gatts_act.c +++ b/components/bt/bluedroid/bta/gatt/bta_gatts_act.c @@ -233,8 +233,6 @@ void bta_gatts_register(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg) if (p_msg->api_reg.p_cback) { (*p_msg->api_reg.p_cback)(BTA_GATTS_REG_EVT, &cb_data); } - - LOG_ERROR("status=%x\n", status); } diff --git a/components/bt/bluedroid/btc/profile/esp/blufi/blufi_prf.c b/components/bt/bluedroid/btc/profile/esp/blufi/blufi_prf.c index d48035045..c126273a7 100644 --- a/components/bt/bluedroid/btc/profile/esp/blufi/blufi_prf.c +++ b/components/bt/bluedroid/btc/profile/esp/blufi/blufi_prf.c @@ -895,3 +895,7 @@ void btc_blufi_set_callbacks(esp_blufi_callbacks_t *callbacks) blufi_env.cbs = callbacks; } +uint16_t btc_blufi_get_version(void) +{ + return BTC_BLUFI_VERSION; +} diff --git a/components/bt/bluedroid/btc/profile/esp/blufi/blufi_protocol.c b/components/bt/bluedroid/btc/profile/esp/blufi/blufi_protocol.c index 2f92a4380..d4d617f00 100644 --- a/components/bt/bluedroid/btc/profile/esp/blufi/blufi_protocol.c +++ b/components/bt/bluedroid/btc/profile/esp/blufi/blufi_protocol.c @@ -90,6 +90,15 @@ void btc_blufi_protocol_handler(uint8_t type, uint8_t *data, int len) btc_transfer_context(&msg, NULL, 0, NULL); break; + case BLUFI_TYPE_CTRL_SUBTYPE_GET_VERSION: { + uint8_t type = BLUFI_BUILD_TYPE(BLUFI_TYPE_DATA, BLUFI_TYPE_DATA_SUBTYPE_REPLY_VERSION); + uint8_t data[2]; + + data[0] = BTC_BLUFI_GREAT_VER; + data[1] = BTC_BLUFI_SUB_VER; + btc_blufi_send_encap(type, &data[0], sizeof(data)); + break; + } default: LOG_ERROR("%s Unkown Ctrl pkt %02x\n", __func__, type); break; diff --git a/components/bt/bluedroid/btc/profile/esp/blufi/include/blufi_int.h b/components/bt/bluedroid/btc/profile/esp/blufi/include/blufi_int.h index 0de66b8e7..c21b41c4c 100644 --- a/components/bt/bluedroid/btc/profile/esp/blufi/include/blufi_int.h +++ b/components/bt/bluedroid/btc/profile/esp/blufi/include/blufi_int.h @@ -15,6 +15,10 @@ #ifndef __BLUFI_INT_H__ #define __BLUFI_INT_H__ +#define BTC_BLUFI_GREAT_VER 0x01 //Version + Subversion +#define BTC_BLUFI_SUB_VER 0x00 //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 */ @@ -85,7 +89,8 @@ typedef struct blufi_frag_hdr blufi_frag_hdr_t; #define BLUFI_TYPE_CTRL_SUBTYPE_CONN_TO_AP 0x03 #define BLUFI_TYPE_CTRL_SUBTYPE_DISCONN_FROM_AP 0x04 #define BLUFI_TYPE_CTRL_SUBTYPE_GET_WIFI_STATUS 0x05 -#define BLUFI_TYPE_CTRL_SUBTYPE_DEAUTHENTICATE_STA 0x06 +#define BLUFI_TYPE_CTRL_SUBTYPE_DEAUTHENTICATE_STA 0x06 +#define BLUFI_TYPE_CTRL_SUBTYPE_GET_VERSION 0x07 #define BLUFI_TYPE_DATA 0x1 #define BLUFI_TYPE_DATA_SUBTYPE_NEG 0x00 @@ -104,7 +109,7 @@ typedef struct blufi_frag_hdr blufi_frag_hdr_t; #define BLUFI_TYPE_DATA_SUBTYPE_CLIENT_PRIV_KEY 0x0d #define BLUFI_TYPE_DATA_SUBTYPE_SERVER_PRIV_KEY 0x0e #define BLUFI_TYPE_DATA_SUBTYPE_WIFI_REP 0x0f - +#define BLUFI_TYPE_DATA_SUBTYPE_REPLY_VERSION 0x10 #define BLUFI_TYPE_IS_CTRL(type) (BLUFI_GET_TYPE((type)) == BLUFI_TYPE_CTRL) #define BLUFI_TYPE_IS_DATA(type) (BLUFI_GET_TYPE((type)) == BLUFI_TYPE_DATA) @@ -115,7 +120,8 @@ typedef struct blufi_frag_hdr blufi_frag_hdr_t; #define BLUFI_TYPE_IS_CTRL_CONN_WIFI(type) (BLUFI_TYPE_IS_CTRL((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_CTRL_SUBTYPE_CONN_TO_AP) #define BLUFI_TYPE_IS_CTRL_DISCONN_WIFI(type) (BLUFI_TYPE_IS_CTRL((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_CTRL_SUBTYPE_DISCONN_FROM_AP) #define BLUFI_TYPE_IS_CTRL_GET_WIFI_STATUS(type) (BLUFI_TYPE_IS_CTRL((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_CTRL_SUBTYPE_GET_WIFI_STATUS) -#define BLUFI_TYPE_IS_CTRL_DEAUTHENTICATE_STA(type) (BLUFI_TYPE_IS_CTRL((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_CTRL_SUBTYPE_DEAUTHENTICATE_STA) +#define BLUFI_TYPE_IS_CTRL_DEAUTHENTICATE_STA(type) (BLUFI_TYPE_IS_CTRL((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_CTRL_SUBTYPE_DEAUTHENTICATE_STA) +#define BLUFI_TYPE_IS_CTRL_GET_VERSION(type) (BLUFI_TYPE_IS_CTRL((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_CTRL_SUBTYPE_GET_VERSION) #define BLUFI_TYPE_IS_DATA_NEG(type) (BLUFI_TYPE_IS_DATA((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_DATA_SUBTYPE_NEG) #define BLUFI_TYPE_IS_DATA_STA_BSSID(type) (BLUFI_TYPE_IS_DATA((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_DATA_SUBTYPE_STA_BSSID) diff --git a/components/bt/bluedroid/btc/profile/esp/include/btc_blufi_prf.h b/components/bt/bluedroid/btc/profile/esp/include/btc_blufi_prf.h index eb909e3a2..1d82d0c9a 100644 --- a/components/bt/bluedroid/btc/profile/esp/include/btc_blufi_prf.h +++ b/components/bt/bluedroid/btc/profile/esp/include/btc_blufi_prf.h @@ -41,4 +41,7 @@ void btc_blufi_set_callbacks(esp_blufi_callbacks_t *callbacks); void btc_blufi_call_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); void btc_blufi_call_deep_free(btc_msg_t *msg); + +uint16_t btc_blufi_get_version(void); + #endif /* __BTC_BLUFI_PRF_H__ */ diff --git a/docs/api/esp_blufi.rst b/docs/api/esp_blufi.rst index 1ffb67bec..f620edeb8 100644 --- a/docs/api/esp_blufi.rst +++ b/docs/api/esp_blufi.rst @@ -125,4 +125,5 @@ Functions .. doxygenfunction:: esp_blufi_profile_init .. doxygenfunction:: esp_blufi_profile_deinit .. doxygenfunction:: esp_blufi_send_wifi_conn_report +.. doxygenfunction:: esp_blufi_get_version diff --git a/examples/12_blufi/main/blufi_main.c b/examples/12_blufi/main/blufi_main.c index 3f5cd3dcc..9e2b1da0a 100644 --- a/examples/12_blufi/main/blufi_main.c +++ b/examples/12_blufi/main/blufi_main.c @@ -328,6 +328,8 @@ void app_main() return; } + BLUFI_INFO("BLUFI VERSION %04x\n", esp_blufi_get_version()); + blufi_security_init(); esp_ble_gap_register_callback(gap_event_handler);