diff --git a/components/bt/bluedroid/bta/include/bta_gatt_api.h b/components/bt/bluedroid/bta/include/bta_gatt_api.h index 5ef9ad74c..668f23c16 100755 --- a/components/bt/bluedroid/bta/include/bta_gatt_api.h +++ b/components/bt/bluedroid/bta/include/bta_gatt_api.h @@ -523,7 +523,7 @@ typedef tGATTS_RSP tBTA_GATTS_RSP; typedef tGATT_EXEC_FLAG tBTA_GATT_EXEC_FLAG; /* read request always based on UUID */ -typedef tGATT_READ_REQ tTA_GBATT_READ_REQ; +typedef tGATT_READ_REQ tBTA_GATT_READ_REQ; /* write request data */ typedef tGATT_WRITE_REQ tBTA_GATT_WRITE_REQ; diff --git a/components/bt/bluedroid/profiles/std/include/prf_defs.h b/components/bt/bluedroid/profiles/std/include/prf_defs.h index 351657b6b..807b767d2 100644 --- a/components/bt/bluedroid/profiles/std/include/prf_defs.h +++ b/components/bt/bluedroid/profiles/std/include/prf_defs.h @@ -27,7 +27,7 @@ #define ATT_UUID_32_LEN 0x0004 #define WX_AIRSYNC_CFG 0 -#define BUT_PROFILE_CFG 1 +#define BUT_PROFILE_CFG 0 #define HIDD_LE_PROFILE_CFG 0 /* diff --git a/components/bt/bluedroid/stack/gatt/gatt_api.c b/components/bt/bluedroid/stack/gatt/gatt_api.c index ee140057a..72f9dfd22 100755 --- a/components/bt/bluedroid/stack/gatt/gatt_api.c +++ b/components/bt/bluedroid/stack/gatt/gatt_api.c @@ -1582,7 +1582,7 @@ BOOLEAN GATT_GetConnIdIfConnected(tGATT_IF gatt_if, BD_ADDR bd_addr, UINT16 *p_c status = TRUE; } - GATT_TRACE_API ("GATT_GetConnIdIfConnected status=%d", status); + GATT_TRACE_API ("GATT_GetConnIdIfConnected status=%d\n", status); return status; } diff --git a/examples/06_bluedroid_demos/components/bluedroid_demos/app_core/bt_app.c b/examples/06_bluedroid_demos/components/bluedroid_demos/app_core/bt_app.c index 854dab47a..d3a4b4291 100644 --- a/examples/06_bluedroid_demos/components/bluedroid_demos/app_core/bt_app.c +++ b/examples/06_bluedroid_demos/components/bluedroid_demos/app_core/bt_app.c @@ -29,7 +29,7 @@ ** Returns None ** *******************************************************************************/ - void ESP_AppBleConfigadvData(tESP_BLE_ADV_DATA *adv_data, + void ble_config_adv_data(esp_ble_adv_data_cfg_t *adv_data, tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback) { tBTA_BLE_AD_MASK data_mask = 0; @@ -112,7 +112,7 @@ ** Returns None ** *******************************************************************************/ -void ESP_AppBleSetScanRsp(tESP_BLE_ADV_DATA *scan_rsp_data, +void ble_set_scan_rsp(esp_ble_adv_data_cfg_t *scan_rsp_data, tBTA_SET_ADV_DATA_CMPL_CBACK *p_scan_rsp_data_cback) { tBTA_BLE_AD_MASK data_mask = 0; diff --git a/examples/06_bluedroid_demos/components/bluedroid_demos/app_core/bt_app_api.c b/examples/06_bluedroid_demos/components/bluedroid_demos/app_core/bt_app_api.c index fd4453e24..635a504ad 100644 --- a/examples/06_bluedroid_demos/components/bluedroid_demos/app_core/bt_app_api.c +++ b/examples/06_bluedroid_demos/components/bluedroid_demos/app_core/bt_app_api.c @@ -17,25 +17,25 @@ //#include "btm_ble_int.h" -void API_Ble_AppConfigAdvData(tESP_BLE_ADV_DATA *adv_data, - tAPI_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback) +void esp_ble_config_adv_data (esp_ble_adv_data_cfg_t *adv_data, + esp_ble_set_adv_data_cmpl_cb_t *adv_data_cback) { if(adv_data != NULL) { - ESP_AppBleConfigadvData(adv_data, p_adv_data_cback); + ble_config_adv_data(adv_data, adv_data_cback); }else{ LOG_ERROR("The adv_data is NULL\n"); } if(++adv_data != NULL) { - ESP_AppBleSetScanRsp(adv_data,NULL); + ble_set_scan_rsp(adv_data,NULL); } } -void API_Ble_AppStartAdvertising(tESP_API_BLE_ADV_PARAMS_ALL *ble_adv_params) +void esp_ble_start_advertising (esp_ble_adv_params_all_t *ble_adv_params) { if (!API_BLE_ISVALID_PARAM(ble_adv_params->adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) || !API_BLE_ISVALID_PARAM(ble_adv_params->adv_int_max, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX)) @@ -51,8 +51,8 @@ void API_Ble_AppStartAdvertising(tESP_API_BLE_ADV_PARAMS_ALL *ble_adv_params) return; } - if ((ble_adv_params->adv_filter_policy < API_ADV_NON_CONN) && - (ble_adv_params->adv_filter_policy > API_ADV_DIRECT) ) + if ((ble_adv_params->adv_filter_policy < ADV_ALLOW_SCAN_ANY_CON_ANY) && + (ble_adv_params->adv_filter_policy > ADV_ALLOW_SCAN_WLST_CON_WLST) ) { LOG_ERROR("Invalid advertisting type parameters.\n"); return; @@ -73,8 +73,8 @@ void API_Ble_AppStartAdvertising(tESP_API_BLE_ADV_PARAMS_ALL *ble_adv_params) } -void API_Ble_SetScanParams (tESP_BLE_SCAN_PARAMS *scan_params, tGATT_IF client_if, - tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback) +void esp_ble_set_scan_params (esp_ble_scan_params *scan_params, esp_gattc_if_t client_if, + esp_scan_param_setup_cb_t scan_param_setup_cback) { if (API_BLE_ISVALID_PARAM(scan_params->scan_intv, BTM_BLE_SCAN_INT_MIN, BTM_BLE_SCAN_INT_MAX) && API_BLE_ISVALID_PARAM(scan_params->scan_win, BTM_BLE_SCAN_WIN_MIN, BTM_BLE_SCAN_WIN_MAX) && @@ -91,26 +91,26 @@ void API_Ble_SetScanParams (tESP_BLE_SCAN_PARAMS *scan_params, tGATT_IF client_i } -void API_Ble_StartScanning (UINT8 duration, tBTA_DM_SEARCH_CBACK *p_results_cb) +void esp_ble_start_scanning (UINT8 duration, esp_dm_search_cb_t *results_cb) { - if((duration != 0) && (p_results_cb != NULL)) + if((duration != 0) && (results_cb != NULL)) { ///Start scan the device - BTA_DmBleObserve(true, duration, p_results_cb); + BTA_DmBleObserve(true, duration, results_cb); }else{ LOG_ERROR("The scan duration or p_results_cb invalid\n"); } } -void API_Ble_AppStopAdvertising(void) +void esp_ble_stop_advertising (void) { bool stop_adv = true; BTA_DmBleBroadcast(stop_adv); } -void API_Ble_AppUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int, - UINT16 max_int, UINT16 latency, UINT16 timeout) +void esp_ble_update_conec_params (BD_ADDR bd_addr, uint16_t min_int, + uint16_t max_int, uint16_t latency, uint16_t timeout) { if (min_int > max_int){ min_int = max_int; @@ -125,7 +125,7 @@ void API_Ble_AppUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int, } -void API_Ble_SetPacketDataLength(BD_ADDR remote_device, UINT16 tx_data_length) +void esp_ble_set_pkt_data_len (BD_ADDR remote_device, uint16_t tx_data_length) { if (tx_data_length > BTM_BLE_DATA_SIZE_MAX){ tx_data_length = BTM_BLE_DATA_SIZE_MAX; @@ -137,7 +137,7 @@ void API_Ble_SetPacketDataLength(BD_ADDR remote_device, UINT16 tx_data_length) } -void API_Ble_SetRandAddress(BD_ADDR rand_addr) +void esp_ble_set_rand_addr (BD_ADDR rand_addr) { if (rand_addr != NULL){ BTA_DmSetRandAddress(rand_addr); @@ -146,7 +146,7 @@ void API_Ble_SetRandAddress(BD_ADDR rand_addr) } } -void API_Ble_ConfigLocalPrivacy(BOOLEAN privacy_enable) +void esp_ble_config_local_privacy (BOOLEAN privacy_enable) { BTA_DmBleConfigLocalPrivacy(privacy_enable); } @@ -154,22 +154,22 @@ void API_Ble_ConfigLocalPrivacy(BOOLEAN privacy_enable) -void API_Ble_GattcAppRegister(tBT_UUID *p_app_uuid, tBTA_GATTC_CBACK *p_client_cb) +void esp_ble_gattc_app_register(esp_bt_uuid_t *app_uuid, esp_gattc_cb_t *client_cb) { - if (p_app_uuid != NULL) + if (app_uuid != NULL) { - BTA_GATTC_AppRegister(p_app_uuid, *p_client_cb); + BTA_GATTC_AppRegister(app_uuid, client_cb); }else{ LOG_ERROR("The app uuid invalid.\n"); } } -void API_Ble_GattcAppDeregister(tBTA_GATTC_IF client_if) +void esp_ble_gattc_app_unregister(esp_gattc_if_t client_if) { BTA_GATTC_AppDeregister(client_if); } -void API_Ble_GattcOpen(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, BOOLEAN is_direct) +void esp_ble_gattc_conn(esp_gattc_if_t client_if, BD_ADDR remote_bda, BOOLEAN is_direct) { tBTA_GATT_TRANSPORT transport = BTA_GATT_TRANSPORT_LE; if(remote_bda == NULL ){ @@ -184,7 +184,7 @@ void API_Ble_GattcOpen(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, BOOLEAN is_d } -void API_GattcCancelOpen(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, BOOLEAN is_direct) +void esp_ble_gattc_cancel_conn (esp_gattc_if_t client_if, BD_ADDR remote_bda, BOOLEAN is_direct) { if(remote_bda == NULL ){ LOG_ERROR("Invaild address data \n"); @@ -194,13 +194,13 @@ void API_GattcCancelOpen(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, BOOLEAN is BTA_GATTC_CancelOpen(client_if, remote_bda, is_direct); } -void API_Ble_GattcClose(UINT16 conn_id) +void esp_ble_gattc_close (uint16_t conn_id) { BTA_GATTC_Close(conn_id); } -tGATT_STATUS API_Ble_GattcConfigureMTU (UINT16 conn_id, UINT16 mtu) +tGATT_STATUS esp_ble_gattc_config_mtu (uint16_t conn_id, uint16_t mtu) { if ((mtu < GATT_DEF_BLE_MTU_SIZE) || (mtu > GATT_MAX_MTU_SIZE)){ LOG_ERROR("Invalid MTU parameters\n"); @@ -211,277 +211,279 @@ tGATT_STATUS API_Ble_GattcConfigureMTU (UINT16 conn_id, UINT16 mtu) } -void API_Ble_GattcServiceSearchRequest (UINT16 conn_id, tBT_UUID *p_srvc_uuid) +void esp_ble_gattc_svc_search_req (uint16_t conn_id, esp_bt_uuid_t *srvc_uuid) { - BTA_GATTC_ServiceSearchRequest(conn_id, p_srvc_uuid); + BTA_GATTC_ServiceSearchRequest(conn_id, srvc_uuid); } -tBTA_GATT_STATUS API_Ble_GattcGetFirstChar (UINT16 conn_id, tBTA_GATT_SRVC_ID *p_srvc_id, - tBT_UUID *p_char_uuid_cond, - tBTA_GATTC_CHAR_ID *p_char_result, - tBTA_GATT_CHAR_PROP *p_property) +tBTA_GATT_STATUS esp_ble_gattc_get_first_char (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id, + esp_bt_uuid_t *char_uuid_cond, + esp_gattc_char_id_t *char_result, + esp_gatt_char_prop_t *property) { tBTA_GATT_STATUS status = 0; - if (!p_srvc_id || !p_char_result){ + if (!srvc_id || !char_result){ return BTA_GATT_ILLEGAL_PARAMETER; } - status = BTA_GATTC_GetFirstChar (conn_id, p_srvc_id, p_char_uuid_cond, - p_char_result, p_property); + status = BTA_GATTC_GetFirstChar (conn_id, srvc_id, char_uuid_cond, + char_result, property); return status; } -tBTA_GATT_STATUS API_Ble_GattcGetFirstCharDescr (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id, - tBT_UUID *p_descr_uuid_cond, - tBTA_GATTC_CHAR_DESCR_ID *p_descr_result) +tBTA_GATT_STATUS esp_ble_gattc_get_first_char_descr (uint16_t conn_id, esp_gattc_char_id_t *char_id, + esp_bt_uuid_t *descr_uuid_cond, + esp_gattc_char_descr_id_t *descr_result) { tBTA_GATT_STATUS status; - if (!p_char_id || !p_descr_result){ + if (!char_id || !descr_result){ return BTA_GATT_ILLEGAL_PARAMETER; } - status = BTA_GATTC_GetFirstCharDescr (conn_id, p_char_id, p_descr_uuid_cond, p_descr_result); + status = BTA_GATTC_GetFirstCharDescr (conn_id, char_id, descr_uuid_cond, descr_result); return status; } -tBTA_GATT_STATUS API_Ble_GattcGetNextChar (UINT16 conn_id, - tBTA_GATTC_CHAR_ID *p_start_char_id, - tBT_UUID *p_char_uuid_cond, - tBTA_GATTC_CHAR_ID *p_char_result, - tBTA_GATT_CHAR_PROP *p_property) +tBTA_GATT_STATUS esp_ble_gattc_get_next_char (uint16_t conn_id, + esp_gattc_char_id_t *start_char_id, + esp_bt_uuid_t *char_uuid_cond, + esp_gattc_char_id_t *char_result, + esp_gatt_char_prop_t *property) { tBTA_GATT_STATUS status; - if (!p_start_char_id || !p_char_result){ + if (!start_char_id || !char_result){ return BTA_GATT_ILLEGAL_PARAMETER; } - status = BTA_GATTC_GetNextChar(conn_id, p_start_char_id, p_char_uuid_cond, - p_char_result, p_property); + status = BTA_GATTC_GetNextChar(conn_id, start_char_id, char_uuid_cond, + char_result, property); return status; } -tBTA_GATT_STATUS API_Ble_GattcGetNextCharDescr (UINT16 conn_id, - tBTA_GATTC_CHAR_DESCR_ID *p_start_descr_id, - tBT_UUID *p_descr_uuid_cond, - tBTA_GATTC_CHAR_DESCR_ID *p_descr_result) +tBTA_GATT_STATUS esp_ble_gattc_get_next_char_descr (uint16_t conn_id, + esp_gattc_char_descr_id_t *start_descr_id, + esp_bt_uuid_t *descr_uuid_cond, + esp_gattc_char_descr_id_t *descr_result) { tBTA_GATT_STATUS status; - if (!p_start_descr_id || !p_descr_result){ + if (!start_descr_id || !descr_result){ return BTA_GATT_ILLEGAL_PARAMETER; } - status = BTA_GATTC_GetNextCharDescr (conn_id, p_start_descr_id, p_descr_uuid_cond, p_descr_result); + status = BTA_GATTC_GetNextCharDescr (conn_id, start_descr_id, descr_uuid_cond, descr_result); return status; } -tBTA_GATT_STATUS API_Ble_GattcGetFirstIncludedService(UINT16 conn_id, tBTA_GATT_SRVC_ID *p_srvc_id, - tBT_UUID *p_uuid_cond, tBTA_GATTC_INCL_SVC_ID *p_result) +tBTA_GATT_STATUS esp_ble_gattc_get_first_inclu_srvc (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id, + esp_bt_uuid_t *uuid_cond, esp_gattc_incl_srvc_id_t *result) { tBTA_GATT_STATUS status; - if (!p_srvc_id || !p_result){ + if (!srvc_id || !result){ return BTA_GATT_ILLEGAL_PARAMETER; } - status = BTA_GATTC_GetFirstIncludedService(conn_id, p_srvc_id, p_uuid_cond, p_result); + status = BTA_GATTC_GetFirstIncludedService(conn_id, srvc_id, uuid_cond, result); return status; } -tBTA_GATT_STATUS API_Ble_GattcGetNextIncludedService(UINT16 conn_id, - tBTA_GATTC_INCL_SVC_ID *p_start_id, - tBT_UUID *p_uuid_cond, - tBTA_GATTC_INCL_SVC_ID *p_result) +tBTA_GATT_STATUS esp_ble_gattc_get_next_inclu_srvc (uint16_t conn_id, + esp_gattc_incl_srvc_id_t *start_id, + esp_bt_uuid_t *uuid_cond, + esp_gattc_incl_srvc_id_t *result) { tBTA_GATT_STATUS status; - if (!p_start_id || !p_result){ + if (!start_id || !result){ return BTA_GATT_ILLEGAL_PARAMETER; } - status = BTA_GATTC_GetNextIncludedService(conn_id, p_start_id, p_uuid_cond, p_result); + status = BTA_GATTC_GetNextIncludedService(conn_id, start_id, uuid_cond, result); return status; } -void API_Ble_GattcReadCharacteristic(UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id, - tBTA_GATT_AUTH_REQ auth_req) +void esp_ble_gattc_read_char (uint16_t conn_id, esp_gattc_char_id_t *char_id, + esp_gatt_auth_req_t auth_req) { - BTA_GATTC_ReadCharacteristic(conn_id, p_char_id, auth_req); + BTA_GATTC_ReadCharacteristic(conn_id, char_id, auth_req); } -void API_Ble_GattcReadCharDescr (UINT16 conn_id, - tBTA_GATTC_CHAR_DESCR_ID *p_descr_id, - tBTA_GATT_AUTH_REQ auth_req) +void esp_ble_gattc_read_char_descr (uint16_t conn_id, + esp_gattc_char_descr_id_t *descr_id, + esp_gatt_auth_req_t auth_req) { - BTA_GATTC_ReadCharDescr (conn_id, p_descr_id, auth_req); + BTA_GATTC_ReadCharDescr (conn_id, descr_id, auth_req); } -void API_Ble_GattcReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi, - tBTA_GATT_AUTH_REQ auth_req) +void esp_ble_gattc_read_multi (uint16_t conn_id, esp_gattc_multi_t *read_multi, + esp_gatt_auth_req_t auth_req) { - BTA_GATTC_ReadMultiple(conn_id, p_read_multi, auth_req); + BTA_GATTC_ReadMultiple(conn_id, read_multi, auth_req); } -void API_Ble_GattcWriteCharValue ( UINT16 conn_id, - tBTA_GATTC_CHAR_ID *p_char_id, - tBTA_GATTC_WRITE_TYPE write_type, - UINT16 len, - UINT8 *p_value, - tBTA_GATT_AUTH_REQ auth_req) +void esp_ble_gattc_write_char_val ( uint16_t conn_id, + esp_gattc_char_id_t *char_id, + esp_gattc_write_type_t write_type, + uint16_t len, + uint8_t *value, + esp_gatt_auth_req_t auth_req) { - BTA_GATTC_WriteCharValue (conn_id, p_char_id, write_type, len, p_value, auth_req); -} - -void API_Ble_GattcWriteCharDescr (UINT16 conn_id, - tBTA_GATTC_CHAR_DESCR_ID *p_char_descr_id, - tBTA_GATTC_WRITE_TYPE write_type, - tBTA_GATT_UNFMT *p_data, - tBTA_GATT_AUTH_REQ auth_req) -{ - BTA_GATTC_WriteCharDescr (conn_id, p_char_descr_id, write_type, p_data, auth_req); + BTA_GATTC_WriteCharValue (conn_id, char_id, write_type, len, value, auth_req); } -void API_Ble_GattcPrepareWrite (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id, - UINT16 offset, UINT16 len, UINT8 *p_value, - tBTA_GATT_AUTH_REQ auth_req) +void esp_ble_gattc_write_char_descr (uint16_t conn_id, + esp_gattc_char_descr_id_t *char_descr_id, + esp_gattc_write_type_t write_type, + esp_gatt_unfmt_t *data, + esp_gatt_auth_req_t auth_req) { - BTA_GATTC_PrepareWrite (conn_id, p_char_id, offset, len, p_value, auth_req); + BTA_GATTC_WriteCharDescr (conn_id, char_descr_id, write_type, data, auth_req); } -void API_Ble_GattcExecuteWrite (UINT16 conn_id, BOOLEAN is_execute) + +void esp_ble_gattc_prepa_write (uint16_t conn_id, esp_gattc_char_id_t *char_id, + uint16_t offset, uint16_t len, uint8_t *value, + esp_gatt_auth_req_t auth_req) +{ + BTA_GATTC_PrepareWrite (conn_id, char_id, offset, len, value, auth_req); +} + +void esp_ble_gattc_execu_write (uint16_t conn_id, BOOLEAN is_execute) { BTA_GATTC_ExecuteWrite (conn_id, is_execute); } -void API_Ble_GattcSendIndConfirm (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id) +void esp_ble_gattc_send_ind_cfm (uint16_t conn_id, esp_gattc_char_id_t *char_id) { - BTA_GATTC_SendIndConfirm (conn_id, p_char_id); + BTA_GATTC_SendIndConfirm (conn_id, char_id); } -tBTA_GATT_STATUS API_Ble_GattcRegisterForNotifications (tBTA_GATTC_IF client_if, +tBTA_GATT_STATUS esp_ble_gattc_register_ntf (esp_gattc_if_t client_if, BD_ADDR bda, - tBTA_GATTC_CHAR_ID *p_char_id) + esp_gattc_char_id_t *char_id) { tBTA_GATT_STATUS status = BTA_GATT_ILLEGAL_PARAMETER; - status = BTA_GATTC_RegisterForNotifications (client_if, bda, p_char_id); + status = BTA_GATTC_RegisterForNotifications (client_if, bda, char_id); return status; } -tBTA_GATT_STATUS API_Ble_GattcDeregisterForNotifications (tBTA_GATTC_IF client_if, - BD_ADDR bda, - tBTA_GATTC_CHAR_ID *p_char_id) +tBTA_GATT_STATUS esp_ble_gattc_unregister_ntf (esp_gattc_if_t client_if, + BD_ADDR bda, + esp_gattc_char_id_t *char_id) { tBTA_GATT_STATUS status = BTA_GATT_ILLEGAL_PARAMETER; - status = BTA_GATTC_DeregisterForNotifications (client_if, bda, p_char_id); + status = BTA_GATTC_DeregisterForNotifications (client_if, bda, char_id); return status; } -void API_Ble_GattsDisable(void) +void esp_ble_gatts_disale(void) { BTA_GATTS_Disable(); } -void API_Ble_GattsAppRegister(tBT_UUID *p_app_uuid, tBTA_GATTS_CBACK *p_cback) +void esp_ble_gatts_app_register(esp_bt_uuid_t *app_uuid, esp_gatts_cb_t *cback) { - BTA_GATTS_AppRegister(p_app_uuid, p_cback); + BTA_GATTS_AppRegister(app_uuid, cback); } -void API_Ble_GattsAppDeregister(tBTA_GATTS_IF server_if) +void esp_ble_gatts_app_unregister(esp_gatts_if_t server_if) { BTA_GATTS_AppDeregister(server_if); } -void API_Ble_GattsCreateService(tBTA_GATTS_IF server_if, tBT_UUID *p_service_uuid, UINT8 inst, - UINT16 num_handle, BOOLEAN is_primary) +void esp_ble_gatts_create_srvc(esp_gatts_if_t server_if, esp_bt_uuid_t *service_uuid, uint8_t inst, + uint16_t num_handle, BOOLEAN is_primary) { - BTA_GATTS_CreateService(server_if, p_service_uuid, inst, num_handle, is_primary); + BTA_GATTS_CreateService(server_if, service_uuid, inst, num_handle, is_primary); } -void API_Ble_GattsAddIncludeService(UINT16 service_id, UINT16 included_service_id) +void esp_ble_gatts_add_inclu_srvc (uint16_t service_id, uint16_t included_service_id) { BTA_GATTS_AddIncludeService(service_id, included_service_id); } -void API_Ble_GattsAddCharacteristic (UINT16 service_id, tBT_UUID *p_char_uuid, - tBTA_GATT_PERM perm, tBTA_GATT_CHAR_PROP property) +void esp_ble_gatts_add_char (uint16_t service_id, esp_bt_uuid_t *char_uuid, + esp_gatt_perm_t perm, esp_gatt_char_prop_t property) { - BTA_GATTS_AddCharacteristic (service_id, p_char_uuid, perm, property); + BTA_GATTS_AddCharacteristic (service_id, char_uuid, perm, property); } -void API_Ble_GattsAddCharDescriptor (UINT16 service_id, - tBTA_GATT_PERM perm, - tBT_UUID * p_descr_uuid) +void esp_ble_gatts_add_char_descr (uint16_t service_id, + esp_gatt_perm_t perm, + esp_bt_uuid_t * descr_uuid) { - BTA_GATTS_AddCharDescriptor (service_id, perm, p_descr_uuid); + BTA_GATTS_AddCharDescriptor (service_id, perm, descr_uuid); } -void API_Ble_GattsDeleteService(UINT16 service_id) +void esp_ble_gatts_dele_srvc (uint16_t service_id) { BTA_GATTS_DeleteService(service_id); } -void API_Ble_GattsStartService(UINT16 service_id, tBTA_GATT_TRANSPORT sup_transport) +void esp_ble_gatts_start_srvc(uint16_t service_id) { - BTA_GATTS_StartService(service_id, sup_transport); + tBTA_GATT_TRANSPORT transport = BT_TRANSPORT_LE; + BTA_GATTS_StartService(service_id, transport); } -void API_Ble_GattsStopService(UINT16 service_id) +void esp_ble_gatts_stop_srvc(uint16_t service_id) { BTA_GATTS_StopService(service_id); } -void API_Ble_GattsHandleValueIndication (UINT16 conn_id, UINT16 attr_id, UINT16 data_len, - UINT8 *p_data, BOOLEAN need_confirm) +void esp_ble_gatts_hdl_val_indica (uint16_t conn_id, uint16_t attr_id, uint16_t data_len, + uint8_t *data, BOOLEAN need_confirm) { - BTA_GATTS_HandleValueIndication (conn_id, attr_id, data_len, p_data, need_confirm); + BTA_GATTS_HandleValueIndication (conn_id, attr_id, data_len, data, need_confirm); } -void API_Ble_GattsSendRsp (UINT16 conn_id, UINT32 trans_id, - tBTA_GATT_STATUS status, tBTA_GATTS_RSP *p_msg) +void esp_ble_gatts_send_rsp (uint16_t conn_id, uint32_t trans_id, + esp_gatt_status_t status, esp_gatts_rsp_t *msg) { - BTA_GATTS_SendRsp (conn_id, trans_id, status, p_msg); + BTA_GATTS_SendRsp (conn_id, trans_id, status, msg); } -void API_Ble_GattsOpen(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, BOOLEAN is_direct, - tBTA_GATT_TRANSPORT transport) +void esp_ble_gatts_conn (esp_gatts_if_t server_if, BD_ADDR remote_bda, BOOLEAN is_direct) { + tBTA_GATT_TRANSPORT transport = BT_TRANSPORT_LE; BTA_GATTS_Open(server_if, remote_bda, is_direct, transport); } -void API_Ble_GattsCancelOpen(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, BOOLEAN is_direct) +void esp_ble_gatts_cancel_conn (esp_gatts_if_t server_if, BD_ADDR remote_bda, BOOLEAN is_direct) { BTA_GATTS_CancelOpen(server_if, remote_bda, is_direct); } -void API_Ble_GattsClose(UINT16 conn_id) +void esp_ble_gatts_close(uint16_t conn_id) { BTA_GATTS_Close(conn_id); } diff --git a/examples/06_bluedroid_demos/components/bluedroid_demos/app_profiles/app_sample_button/app_button.c b/examples/06_bluedroid_demos/components/bluedroid_demos/app_profiles/app_sample_button/app_button.c index 825a5647a..c685e8e44 100644 --- a/examples/06_bluedroid_demos/components/bluedroid_demos/app_profiles/app_sample_button/app_button.c +++ b/examples/06_bluedroid_demos/components/bluedroid_demos/app_profiles/app_sample_button/app_button.c @@ -15,6 +15,13 @@ ******************************************************************************* ********* */ + + +#include "prf_defs.h" + +#if (BUT_PROFILE_CFG) + + #include #include #include @@ -76,6 +83,8 @@ BOOLEAN ble_but_prf_hdl_event(BT_HDR *msg_data) +#endif ///BUT_PROFILE_CFG + #if 0 #define GPIO_INUM 8 diff --git a/examples/06_bluedroid_demos/components/bluedroid_demos/app_project/SampleServerProject.c b/examples/06_bluedroid_demos/components/bluedroid_demos/app_project/SampleServerProject.c index 1be9198e1..6c24854dd 100644 --- a/examples/06_bluedroid_demos/components/bluedroid_demos/app_project/SampleServerProject.c +++ b/examples/06_bluedroid_demos/components/bluedroid_demos/app_project/SampleServerProject.c @@ -85,7 +85,7 @@ tBTA_BLE_MANU p_wechat_manu = {sizeof(wechat_manu),wechat_manu}; BD_ADDR rand_ijiazu_addr = {0x00,0x02,0x5B,0x00,0x32,0x55}; -tESP_BLE_ADV_DATA ijiazu_adv_data[ADV_SCAN_IDX_MAX] = +esp_ble_adv_data_cfg_t ijiazu_adv_data[ADV_SCAN_IDX_MAX] = { [BLE_ADV_DATA_IDX] = { .adv_name = "Espressif_007", @@ -126,7 +126,7 @@ tESP_BLE_ADV_DATA ijiazu_adv_data[ADV_SCAN_IDX_MAX] = } }; -tESP_BLE_ADV_DATA wechat_adv_data[ADV_SCAN_IDX_MAX] = +esp_ble_adv_data_cfg_t wechat_adv_data[ADV_SCAN_IDX_MAX] = { [BLE_ADV_DATA_IDX] = { .adv_name = NULL, @@ -279,7 +279,7 @@ void bta_gatts_callback(tBTA_GATTS_EVT event, tBTA_GATTS* p_data) LOG_ERROR("set advertising parameters\n"); //set the advertising data to the btm layer - API_Ble_AppConfigAdvData(&wechat_adv_data[BLE_ADV_DATA_IDX], + esp_ble_config_adv_data(&wechat_adv_data[BLE_ADV_DATA_IDX], bta_gatts_set_adv_data_cback); } @@ -330,7 +330,7 @@ static void ble_server_appRegister(void) btif_to_bta_uuid(&t_uuid, &uuid); LOG_ERROR("register gatts application\n"); - API_Ble_GattsAppRegister(&t_uuid, bta_gatts_callback); + esp_ble_gatts_app_register(&t_uuid, bta_gatts_callback); } void gatts_server_test(void) diff --git a/examples/06_bluedroid_demos/components/bluedroid_demos/include/bt_app_api.h b/examples/06_bluedroid_demos/components/bluedroid_demos/include/bt_app_api.h index d48c17cb4..e0f9e3449 100644 --- a/examples/06_bluedroid_demos/components/bluedroid_demos/include/bt_app_api.h +++ b/examples/06_bluedroid_demos/components/bluedroid_demos/include/bt_app_api.h @@ -16,153 +16,891 @@ #include "bt_app_defs.h" #include "bta_gatt_api.h" -typedef tBTA_SET_ADV_DATA_CMPL_CBACK tAPI_SET_ADV_DATA_CMPL_CBACK ; -typedef tBTA_STATUS tAPI_STATUS; - -extern void API_Ble_AppConfigAdvData (tESP_BLE_ADV_DATA *adv_data, - tAPI_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback); - -extern void API_Ble_SetScanRsp (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg, - tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback); -extern void API_Ble_SetScanParams (tESP_BLE_SCAN_PARAMS *scan_params, tGATT_IF client_if, - tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback); - -extern void API_Ble_StartScanning (UINT8 duration, tBTA_DM_SEARCH_CBACK *p_results_cb); +/******************************************************************************* +** +** @function esp_ble_config_adv_data +** +** @brief This function is called to override the BTA default ADV parameters. +** +** @param[in] adv_data: Pointer to User defined ADV data structure. This +** memory space can not be freed until p_adv_data_cback +** is received. +** @param[in|out] adv_data_cback: set adv data complete callback. +** +** @return None +** +*******************************************************************************/ +void esp_ble_config_adv_data (esp_ble_adv_data_cfg_t *adv_data, + esp_ble_set_adv_data_cmpl_cb_t *adv_data_cback); -extern void API_Ble_AppStartAdvertising (tESP_API_BLE_ADV_PARAMS_ALL *ble_adv_params); -extern void API_Ble_AppStopAdvertising (void); +/******************************************************************************* +** +** @function esp_ble_set_scan_params +** +** @brief This function is called to set scan parameters +** +** @param[in] esp_ble_scan_params: Pointer to User defined scan_params data structure. This +** memory space can not be freed until scan_param_setup_cback +** @param[in] client_if: Client interface ID +** @param[in|out] scan_param_setup_status_cback - Set scan param status callback +** +** @return None +** +*******************************************************************************/ +void esp_ble_set_scan_params (esp_ble_scan_params *scan_params, esp_gattc_if_t client_if, + esp_scan_param_setup_cb_t scan_param_setup_cback); -extern void API_Ble_AppUpdateConnectionParams (BD_ADDR bd_addr, UINT16 min_int, - UINT16 max_int, UINT16 latency, UINT16 timeout); -extern void API_Ble_SetPacketDataLength (BD_ADDR remote_device, UINT16 tx_data_length); +/******************************************************************************* +** +** @function esp_ble_start_scanning +** +** @brief This procedure keep the device scanning the peer device whith advertising on the air +** +** @param[in] duration: Keeping the scaning time, the unit is second. +** @param[in|out] results_cb: The scanning function callback when the peer device has been scan +** which advertising on the air +** +** @return None +** +*******************************************************************************/ +void esp_ble_start_scanning (UINT8 duration, esp_dm_search_cb_t *results_cb); -extern void API_Ble_SetRandAddress (BD_ADDR rand_addr); -extern void API_Ble_ConfigLocalPrivacy (BOOLEAN privacy_enable); -extern void API_Ble_GattcAppRegister (tBT_UUID *p_app_uuid, tBTA_GATTC_CBACK *p_client_cb); +/******************************************************************************* +** +** @function esp_ble_start_advertising +** +** @brief This function is called to start advertising. +** +** @param[in] esp_ble_adv_params_all_t: ointer to User defined adv_params data structure. +** +** @return None +** +*******************************************************************************/ +void esp_ble_start_advertising (esp_ble_adv_params_all_t *ble_adv_params); -extern void API_Ble_GattcAppDeregister (tBTA_GATTC_IF client_if); -extern void API_Ble_GattcOpen (tBTA_GATTC_IF client_if, BD_ADDR remote_bda, BOOLEAN is_direct); -extern void API_GattcCancelOpen (tBTA_GATTC_IF client_if, BD_ADDR remote_bda, BOOLEAN is_direct); +/******************************************************************************* +** +** @function esp_ble_stop_advertising +** +** @brief This function is called to stop advertising. +** +** @param None +** +** @return None +** +*******************************************************************************/ +void esp_ble_stop_advertising (void); -extern void API_Ble_GattcClose (UINT16 conn_id); -extern tGATT_STATUS API_Ble_GattcConfigureMTU (UINT16 conn_id, UINT16 mtu); -extern void API_Ble_GattcServiceSearchRequest (UINT16 conn_id, tBT_UUID *p_srvc_uuid); +/******************************************************************************* +** +** @function esp_ble_update_conec_params +** +** @brief Update connection parameters, can only be used when connection is up. +** +** @param[in] bd_addr - BD address of the peer +** @param[in] min_int - minimum connection interval, [0x0004~ 0x4000] +** @param[in] max_int - maximum connection interval, [0x0004~ 0x4000] +** @param[in] latency - slave latency [0 ~ 500] +** @param[in] timeout - supervision timeout [0x000a ~ 0xc80] +** +** @return None +** +*******************************************************************************/ +void esp_ble_update_conec_params (BD_ADDR bd_addr, uint16_t min_int, + uint16_t max_int, uint16_t latency, uint16_t timeout); -extern tBTA_GATT_STATUS API_Ble_GattcGetFirstChar (UINT16 conn_id, tBTA_GATT_SRVC_ID *p_srvc_id, - tBT_UUID *p_char_uuid_cond, - tBTA_GATTC_CHAR_ID *p_char_result, - tBTA_GATT_CHAR_PROP *p_property); -extern tBTA_GATT_STATUS API_Ble_GattcGetFirstCharDescr (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id, - tBT_UUID *p_descr_uuid_cond, - tBTA_GATTC_CHAR_DESCR_ID *p_descr_result); +/******************************************************************************* +** +** @function esp_ble_set_pkt_data_len +** +** @brief This function is to set maximum LE data packet size +** +** @return None +** +** +*******************************************************************************/ +void esp_ble_set_pkt_data_len (BD_ADDR remote_device, uint16_t tx_data_length); -extern tBTA_GATT_STATUS API_Ble_GattcGetNextIncludedService(UINT16 conn_id, - tBTA_GATTC_INCL_SVC_ID *p_start_id, - tBT_UUID *p_uuid_cond, - tBTA_GATTC_INCL_SVC_ID *p_result); -extern tBTA_GATT_STATUS API_Ble_GattcGetNextChar (UINT16 conn_id, - tBTA_GATTC_CHAR_ID *p_start_char_id, - tBT_UUID *p_char_uuid_cond, - tBTA_GATTC_CHAR_ID *p_char_result, - tBTA_GATT_CHAR_PROP *p_property); -extern tBTA_GATT_STATUS API_Ble_GattcGetNextCharDescr (UINT16 conn_id, - tBTA_GATTC_CHAR_DESCR_ID *p_start_descr_id, - tBT_UUID *p_descr_uuid_cond, - tBTA_GATTC_CHAR_DESCR_ID *p_descr_result); +/******************************************************************************* +** +** @function esp_ble_set_rand_addr +** +** @brief This function set the random address for the appliction +** +** @param[in] rand_addr: the random address whith should be setting +** +** @return None +** +** +*******************************************************************************/ +void esp_ble_set_rand_addr (BD_ADDR rand_addr); -extern tBTA_GATT_STATUS API_Ble_GattcGetFirstIncludedService (UINT16 conn_id, tBTA_GATT_SRVC_ID *p_srvc_id, - tBT_UUID *p_uuid_cond, tBTA_GATTC_INCL_SVC_ID *p_result); -extern void API_Ble_GattcReadCharacteristic (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id, - tBTA_GATT_AUTH_REQ auth_req); -extern void API_Ble_GattcReadCharDescr (UINT16 conn_id, - tBTA_GATTC_CHAR_DESCR_ID *p_descr_id, - tBTA_GATT_AUTH_REQ auth_req); +/******************************************************************************* +** +** @function esp_ble_config_local_privacy +** +** @brief Enable/disable privacy on the local device +** +** @param[in] privacy_enable - enable/disabe privacy on remote device. +** +** @return None +** +*******************************************************************************/ +void esp_ble_config_local_privacy (BOOLEAN privacy_enable); -extern void API_Ble_GattcReadMultiple (UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi, - tBTA_GATT_AUTH_REQ auth_req); -extern void API_Ble_GattcWriteCharValue ( UINT16 conn_id, - tBTA_GATTC_CHAR_ID *p_char_id, - tBTA_GATTC_WRITE_TYPE write_type, - UINT16 len, - UINT8 *p_value, - tBTA_GATT_AUTH_REQ auth_req); -extern void API_Ble_GattcWriteCharDescr (UINT16 conn_id, - tBTA_GATTC_CHAR_DESCR_ID *p_char_descr_id, - tBTA_GATTC_WRITE_TYPE write_type, - tBTA_GATT_UNFMT *p_data, - tBTA_GATT_AUTH_REQ auth_req); +/******************************************************************************* +** @function esp_gattc_disable +** @brief This function is called by application to disable GATTC module +** +** @param NULL +** +** @return None. +** +*******************************************************************************/ +void esp_gattc_disable(void); -extern void API_Ble_GattcPrepareWrite (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id, - UINT16 offset, UINT16 len, UINT8 *p_value, - tBTA_GATT_AUTH_REQ auth_req); -extern void API_Ble_GattcExecuteWrite (UINT16 conn_id, BOOLEAN is_execute); +/******************************************************************************* +** +** @function esp_ble_gattc_app_register +** +** @brief This function is called to register application callbacks +** with GATTC module. +** +** @param[in] app_uuid - applicaiton UUID +** @param[in] client_cb - pointer to the application callback function. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gattc_app_register(esp_bt_uuid_t *app_uuid, esp_gattc_cb_t *client_cb); -extern void API_Ble_GattcSendIndConfirm (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id); -extern tBTA_GATT_STATUS API_Ble_GattcRegisterForNotifications (tBTA_GATTC_IF client_if, +/******************************************************************************* +** +** @function esp_ble_gattc_app_unregister +** +** @brief This function is called to unregister an application +** from GATTC module. +** +** @param[in] client_if - client interface identifier. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gattc_app_unregister(esp_gattc_if_t client_if); + + +/******************************************************************************* +** +** @function esp_ble_gattc_conn +** +** @brief Open a direct connection or add a background auto connection +** bd address +** +** @param[in] client_if: server interface. +** @param[in] remote_bda: remote device BD address. +** @param[in] is_direct: direct connection or background auto connection +** +** @return None +** +*******************************************************************************/ +void esp_ble_gattc_conn(esp_gattc_if_t client_if, BD_ADDR remote_bda, BOOLEAN is_direct); + + + +/******************************************************************************* +** +** @function esp_ble_gattc_cancel_conn +** +** @brief Cancel a direct open connection or remove a background auto connection +** bd address +** +** @param[in] client_if: server interface. +** @param[in] remote_bda: remote device BD address. +** @param[in] is_direct: direct connection or background auto connection +** +** @return None +** +*******************************************************************************/ +void esp_ble_gattc_cancel_conn (esp_gattc_if_t client_if, BD_ADDR remote_bda, BOOLEAN is_direct); + + +/******************************************************************************* +** +** @function esp_ble_gattc_close +** +** @brief Close a connection to a GATT server. +** +** @param[in] conn_id: connectino ID to be closed. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gattc_close (uint16_t conn_id); + + + +/******************************************************************************* +** +** @function esp_ble_gattc_config_mtu +** +** @brief Configure the MTU size in the GATT channel. This can be done +** only once per connection. +** +** @param[in] conn_id: connection ID. +** mtu: desired MTU size to use. +** +** @return Command status code: +** - @ref ESP_GATT_OK: If request succeeds +** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the mtu value invalid +** +*******************************************************************************/ +tGATT_STATUS esp_ble_gattc_config_mtu (uint16_t conn_id, uint16_t mtu); + + +/******************************************************************************* +** +** @function esp_ble_gattc_svc_search_req +** +** @brief This function is called to request a GATT service discovery +** on a GATT server. This function report service search result +** by a callback event, and followed by a service search complete +** event. +** +** @param[in] conn_id: connection ID. +** @param[in] srvc_uuid: a UUID of the service application is interested in. +** If Null, discover for all services. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gattc_svc_search_req (uint16_t conn_id, esp_bt_uuid_t *srvc_uuid); + + +/**************************************************************************************************** +** +** @function esp_ble_gattc_get_first_char +** +** @brief This function is called to find the first characteristic of the +** service on the given server. +** +** @param[in] conn_id: connection ID which identify the server. +** @param[in] srvc_id: the service ID of which the characteristic is belonged to. +** @param[in] char_uuid_cond: Characteristic UUID, if NULL find the first available +** characteristic. +** @param[in] char_result: output parameter which will store the GATT +** characteristic ID. +** @param[in] property: output parameter to carry the characteristic property. +** +** @return Command status code: +** - @ref ESP_GATT_OK: If request succeeds +** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the srvc_id or char_result parameter is NULL. +** +*****************************************************************************************************/ +tBTA_GATT_STATUS esp_ble_gattc_get_first_char (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id, + esp_bt_uuid_t *char_uuid_cond, + esp_gattc_char_id_t *char_result, + esp_gatt_char_prop_t *property); + + +/******************************************************************************* +** +** @function esp_ble_gattc_get_first_char_descr +** +** @brief This function is called to find the first characteristic descriptor of the +** characteristic on the given server. +** +** @param[in] conn_id: connection ID which identify the server. +** @param[in] char_id: the characteristic ID of which the descriptor is belonged to. +** @param[in] descr_uuid_cond: Characteristic Descr UUID, if NULL find the first available +** characteristic. +** @param[in] descr_result: output parameter which will store the GATT +** characteristic descriptor ID. +** +** @return Command status code: +** - @ref ESP_GATT_OK: If request succeeds +** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the char_id or descr_result parameter is NULL. +** +*******************************************************************************/ +tBTA_GATT_STATUS esp_ble_gattc_get_first_char_descr (uint16_t conn_id, esp_gattc_char_id_t *char_id, + esp_bt_uuid_t *descr_uuid_cond, + esp_gattc_char_descr_id_t *descr_result); + + +/******************************************************************************* +** +** @function esp_ble_gattc_get_next_inclu_srvc +** +** @brief This function is called to find the next included service of the +** service on the given server. +** +** @param[in] conn_id: connection ID which identify the server. +** @param[in] start_id: start the search from the next record +** after the one identified by p_start_id. +** @param[in] uuid_cond: Included service UUID, if NULL find the first available +** included service. +** @param[in] result: output parameter which will store the GATT ID +** of the included service found. +** +** @return Command status code: +** - @ref ESP_GATT_OK: If request succeeds +** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the p_char_id or p_descr_result parameter is NULL. + +*******************************************************************************/ +tBTA_GATT_STATUS esp_ble_gattc_get_next_inclu_srvc (uint16_t conn_id, + esp_gattc_incl_srvc_id_t *start_id, + esp_bt_uuid_t *uuid_cond, + esp_gattc_incl_srvc_id_t *result); + + +/******************************************************************************* +** +** @function esp_ble_gattc_get_next_char +** +** @brief This function is called to find the next characteristic of the +** service on the given server. +** +** @param[in] conn_id: connection ID which identify the server. +** @param[in] start_char_id: start the characteristic search from the next record +** after the one identified by char_id. +** @param[in] char_uuid_cond: Characteristic UUID, if NULL find the first available +** characteristic. +** @param[in] char_result: output parameter which will store the GATT +** characteristic ID. +** @param[in] property: output parameter to carry the characteristic property. +** +** @return Command status code: +** - @ref ESP_GATT_OK: If request succeeds +** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the start_char_id or char_result parameter is NULL. +** +*******************************************************************************/ +tBTA_GATT_STATUS esp_ble_gattc_get_next_char (uint16_t conn_id, + esp_gattc_char_id_t *start_char_id, + esp_bt_uuid_t *char_uuid_cond, + esp_gattc_char_id_t *char_result, + esp_gatt_char_prop_t *property); + + +/******************************************************************************* +** +** @function esp_ble_gattc_get_next_char_descr +** +** @brief This function is called to find the next characteristic descriptor +** of the characterisctic. +** +** @param[in] conn_id: connection ID which identify the server. +** @param[in] start_descr_id: start the descriptor search from the next record +** after the one identified by p_start_descr_id. +** @param[in] descr_uuid_cond: Characteristic descriptor UUID, if NULL find +** the first available characteristic descriptor. +** @param[in] descr_result: output parameter which will store the GATT +** characteristic descriptor ID. +** +** @return Command status code: +** - @ref ESP_GATT_OK: If request succeeds +** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the start_descr_id or descr_result parameter is NULL. +** +*******************************************************************************/ +tBTA_GATT_STATUS esp_ble_gattc_get_next_char_descr (uint16_t conn_id, + esp_gattc_char_descr_id_t *start_descr_id, + esp_bt_uuid_t *descr_uuid_cond, + esp_gattc_char_descr_id_t *descr_result); + + +/******************************************************************************* +** +** @function esp_ble_gattc_get_first_inclu_srvc +** +** @brief This function is called to find the first included service of the +** service on the given server. +** +** @param[in] conn_id: connection ID which identify the server. +** @param[in] srvc_id: the service ID of which the characteristic is belonged to. +** @param[in] uuid_cond: Characteristic UUID, if NULL find the first available +** characteristic. +** @param[in] result: output parameter which will store the GATT ID +** of the included service found. +** +** @return Command status code: +** - @ref ESP_GATT_OK: If request succeeds +** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the srvc_id or result parameter is NULL. +** +*******************************************************************************/ +extern tBTA_GATT_STATUS esp_ble_gattc_get_first_inclu_srvc (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id, + esp_bt_uuid_t *uuid_cond, esp_gattc_incl_srvc_id_t *result); + + +/******************************************************************************* +** +** @function esp_ble_gattc_read_char +** +** @brief This function is called to read a service's characteristics of +** the given characteritisc ID. +** +** @param[in] conn_id - connectino ID. +** @param[in] char_id - characteritic ID to read. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gattc_read_char (uint16_t conn_id, esp_gattc_char_id_t *char_id, + esp_gatt_auth_req_t auth_req); + + + +/******************************************************************************* +** +** @function esp_ble_gattc_read_char_descr +** +** @brief This function is called to read a characteristics descriptor. +** +** @param[in] conn_id - connection ID. +** @param[in] descr_id - characteritic descriptor ID to read. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gattc_read_char_descr (uint16_t conn_id, + esp_gattc_char_descr_id_t *descr_id, + esp_gatt_auth_req_t auth_req); + + + +/******************************************************************************* +** +** @function esp_ble_gattc_read_multi +** +** @brief This function is called to read multiple characteristic or +** characteristic descriptors. +** +** @param[in] conn_id - connectino ID. +** @param[in] read_multi - pointer to the read multiple parameter. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gattc_read_multi (uint16_t conn_id, esp_gattc_multi_t *read_multi, + esp_gatt_auth_req_t auth_req); + + + +/******************************************************************************* +** +** @function esp_ble_gattc_write_char_val +** +** @brief This function is called to write characteristic value. +** +** @param[in] conn_id - connection ID. +** @param[in] char_id - characteristic ID to write. +** @param[in] write_type - type of write. +** @param[in] len: length of the data to be written. +** @param[in] value - the value to be written. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gattc_write_char_val ( uint16_t conn_id, + esp_gattc_char_id_t *char_id, + esp_gattc_write_type_t write_type, + uint16_t len, + uint8_t *value, + esp_gatt_auth_req_t auth_req); + + +/******************************************************************************* +** +** @function esp_ble_gattc_write_char_descr +** +** @brief This function is called to write characteristic descriptor value. +** +** @param[in] conn_id - connection ID +** @param[in] char_descr_id - characteristic descriptor ID to write. +** @param[in] write_type - write type. +** @param[in] data - the value to be written. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gattc_write_char_descr (uint16_t conn_id, + esp_gattc_char_descr_id_t *char_descr_id, + esp_gattc_write_type_t write_type, + esp_gatt_unfmt_t *data, + esp_gatt_auth_req_t auth_req); + + + +/******************************************************************************* +** +** @function esp_ble_gattc_prepa_write +** +** @brief This function is called to prepare write a characteristic value. +** +** @param[in] conn_id - connection ID. +** @param[in] char_id - GATT characteritic ID of the service. +** @param[in] offset - offset of the write value. +** @param[in] len: length of the data to be written. +** @param[in] value - the value to be written. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gattc_prepa_write (uint16_t conn_id, esp_gattc_char_id_t *char_id, + uint16_t offset, uint16_t len, uint8_t *value, + esp_gatt_auth_req_t auth_req); + + + +/******************************************************************************* +** +** @function esp_ble_gattc_execu_write +** +** @brief This function is called to execute write a prepare write sequence. +** +** @param[in] conn_id - connection ID. +** @param[in] is_execute - execute or cancel. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gattc_execu_write (uint16_t conn_id, BOOLEAN is_execute); + + + +/******************************************************************************* +** +** @function esp_ble_gattc_send_ind_cfm +** +** @brief This function is called to send handle value confirmation. +** +** @param[in] conn_id - connection ID. +** @param[in] char_id - characteristic ID to confirm. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gattc_send_ind_cfm (uint16_t conn_id, esp_gattc_char_id_t *char_id); + + + + +/******************************************************************************* +** +** @function esp_ble_gattc_register_ntf +** +** @brief This function is called to register for notification of a service. +** +** @param[in] client_if - client interface. +** @param[in] bda - target GATT server. +** @param[in] char_id - pointer to GATT characteristic ID. +** +** @return OK if registration succeed, otherwise failed. +** +*******************************************************************************/ +tBTA_GATT_STATUS esp_ble_gattc_register_ntf (esp_gattc_if_t client_if, BD_ADDR bda, - tBTA_GATTC_CHAR_ID *p_char_id); + esp_gattc_char_id_t *char_id); -extern tBTA_GATT_STATUS API_Ble_GattcDeregisterForNotifications (tBTA_GATTC_IF client_if, + + +/******************************************************************************* +** +** @function esp_ble_gattc_unregister_ntf +** +** @brief This function is called to de-register for notification of a service. +** +** @param[in] client_if - client interface. +** @param[in] bda - target GATT server. +** @param[in] char_id - pointer to GATT characteristic ID. +** +** @return OK if deregistration succeed, otherwise failed. +** +*******************************************************************************/ +tBTA_GATT_STATUS esp_ble_gattc_unregister_ntf (esp_gattc_if_t client_if, BD_ADDR bda, - tBTA_GATTC_CHAR_ID *p_char_id); - -extern void API_Ble_GattsDisable(void); + esp_gattc_char_id_t *char_id); -extern void API_Ble_GattsAppRegister(tBT_UUID *p_app_uuid, tBTA_GATTS_CBACK *p_cback); - -extern void API_Ble_GattsAppDeregister(tBTA_GATTS_IF server_if); - -extern void API_Ble_GattsCreateService(tBTA_GATTS_IF server_if, tBT_UUID *p_service_uuid, UINT8 inst, - UINT16 num_handle, BOOLEAN is_primary); - -extern void API_Ble_GattsAddIncludeService(UINT16 service_id, UINT16 included_service_id); - -extern void API_Ble_GattsAddCharacteristic (UINT16 service_id, tBT_UUID *p_char_uuid, - tBTA_GATT_PERM perm, tBTA_GATT_CHAR_PROP property); +/******************************************************************************* +** +** @function esp_ble_gatts_disale +** +** @brief This function is called to disable GATTS module +** +** @param[in] None. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gatts_disale(void); -extern void API_Ble_GattsAddCharDescriptor (UINT16 service_id, - tBTA_GATT_PERM perm, - tBT_UUID * p_descr_uuid); + + +/******************************************************************************* +** +** @function esp_ble_gatts_app_register +** +** @brief This function is called to register application callbacks +** with BTA GATTS module. +** +** @param[in] app_uuid - applicaiton UUID +** @param[in] cback - pointer to the application callback function. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gatts_app_register(esp_bt_uuid_t *app_uuid, esp_gatts_cb_t *cback); -extern void API_Ble_GattsDeleteService(UINT16 service_id); -extern void API_Ble_GattsStartService(UINT16 service_id, tBTA_GATT_TRANSPORT sup_transport); +/******************************************************************************* +** +** @function esp_ble_gatts_app_unregister +** +** @brief un-register with GATT Server. +** +** @param[in] server_if: service interface id. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gatts_app_unregister(esp_gatts_if_t server_if); -extern void API_Ble_GattsStopService(UINT16 service_id); -extern void API_Ble_GattsHandleValueIndication (UINT16 conn_id, UINT16 attr_id, UINT16 data_len, - UINT8 *p_data, BOOLEAN need_confirm); -extern void API_Ble_GattsSendRsp (UINT16 conn_id, UINT32 trans_id, - tBTA_GATT_STATUS status, tBTA_GATTS_RSP *p_msg); +/******************************************************************************* +** +** @function esp_ble_gatts_create_srvc +** +** @brief Create a service. When service creation is done, a callback +** event BTA_GATTS_CREATE_SRVC_EVT is called to report status +** and service ID to the profile. The service ID obtained in +** the callback function needs to be used when adding included +** service and characteristics/descriptors into the service. +** +** @param[in] server_if: Profile ID this service is belonged to. +** @param[in] service_uuid: service UUID. +** @param[in] inst: instance ID number of this service. +** @param[in] num_handle: numble of handle requessted for this service. +** @param[in] is_primary: is this service a primary one or not. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gatts_create_srvc(esp_gatts_if_t server_if, esp_bt_uuid_t *service_uuid, uint8_t inst, + uint16_t num_handle, BOOLEAN is_primary); -extern void API_Ble_GattsOpen(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, BOOLEAN is_direct, - tBTA_GATT_TRANSPORT transport); -extern void API_Ble_GattsCancelOpen(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, BOOLEAN is_direct); -extern void API_Ble_GattsClose(UINT16 conn_id); +/******************************************************************************* +** +** @function esp_ble_gatts_add_inclu_srvc +** +** @brief This function is called to add an included service. After included +** service is included, a callback event BTA_GATTS_ADD_INCL_SRVC_EVT +** is reported the included service ID. +** +** @param[in] service_id: service ID to which this included service is to +** be added. +** @param[in] included_service_id: the service ID to be included. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gatts_add_inclu_srvc (uint16_t service_id, uint16_t included_service_id); + + + +/******************************************************************************* +** +** @function esp_ble_gatts_add_char +** +** @brief This function is called to add a characteristic into a service. +** +** @param[in] service_id: service ID to which this included service is to +** be added. +** @param[in] char_uuid : Characteristic UUID. +** @param[in] perm : Characteristic value declaration attribute permission. +** @param[in] property : Characteristic Properties +** +** @return None +** +*******************************************************************************/ +void esp_ble_gatts_add_char (uint16_t service_id, esp_bt_uuid_t *char_uuid, + esp_gatt_perm_t perm, esp_gatt_char_prop_t property); + + + + +/******************************************************************************* +** +** @function esp_ble_gatts_add_char_descr +** +** @brief This function is called to add characteristic descriptor. When +** it's done, a callback event BTA_GATTS_ADD_DESCR_EVT is called +** to report the status and an ID number for this descriptor. +** +** @param[in] service_id: service ID to which this charatceristic descriptor is to +** be added. +** @param[in] perm: descriptor access permission. +** @param[in] descr_uuid: descriptor UUID. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gatts_add_char_descr (uint16_t service_id, + esp_gatt_perm_t perm, + esp_bt_uuid_t * descr_uuid); + + + +/******************************************************************************* +** +** @function esp_ble_gatts_dele_srvc +** +** @brief This function is called to delete a service. When this is done, +** a callback event BTA_GATTS_DELETE_EVT is report with the status. +** +** @param[in] service_id: service_id to be deleted. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gatts_dele_srvc (uint16_t service_id); + + + +/******************************************************************************* +** +** @function esp_ble_gatts_start_srvc +** +** @brief This function is called to start a service. +** +** @param[in] service_id: the service ID to be started. +** @param[in] sup_transport: supported trasnport. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gatts_start_srvc(uint16_t service_id); + + + +/******************************************************************************* +** +** @function esp_ble_gatts_stop_srvc +** +** @brief This function is called to stop a service. +** +** @param[in] service_id - service to be topped. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gatts_stop_srvc(uint16_t service_id); + + + +/******************************************************************************* +** +** @function esp_ble_gatts_hdl_val_indica +** +** @brief This function is called to read a characteristics descriptor. +** +** @param[in] bda - remote device bd address to indicate. +** @param[in] attr_id - attribute ID to indicate. +** @param[in] data_len - indicate data length. +** @param[in] data: data to indicate. +** @param[in] need_confirm - if this indication expects a confirmation or not. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gatts_hdl_val_indica (uint16_t conn_id, uint16_t attr_id, uint16_t data_len, + uint8_t *data, BOOLEAN need_confirm); + + +/******************************************************************************* +** +** @function esp_ble_gatts_send_rsp +** +** @brief This function is called to send a response to a request. +** +** @param[in] conn_id - connection identifier. +** @param[in] trans_id - transaction ID. +** @param[in] status - response status +** @param[in] msg - response data. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gatts_send_rsp (uint16_t conn_id, uint32_t trans_id, + esp_gatt_status_t status, esp_gatts_rsp_t *msg); + + +/******************************************************************************* +** +** @function esp_ble_gatts_conn +** +** @brief Open a direct open connection or add a background auto connection +** bd address +** +** @param[in] server_if: server interface. +** @param[in] remote_bda: remote device BD address. +** @param[in] is_direct: direct connection or background auto connection +** +** @return None +** +*******************************************************************************/ +void esp_ble_gatts_conn (esp_gatts_if_t server_if, BD_ADDR remote_bda, BOOLEAN is_direct); + + +/******************************************************************************* +** +** @function esp_ble_gatts_cancel_conn +** +** @brief Cancel a direct open connection or remove a background auto connection +** bd address +** +** @param[in] server_if: server interface. +** @param[in] remote_bda: remote device BD address. +** @param[in] is_direct: direct connection or background auto connection +** +** @return None +** +*******************************************************************************/ +void esp_ble_gatts_cancel_conn (esp_gatts_if_t server_if, BD_ADDR remote_bda, BOOLEAN is_direct); + + +/******************************************************************************* +** +** @function esp_ble_gatts_close +** +** @param[in] Close a connection a remote device. +** +** @param[in] conn_id: connectino ID to be closed. +** +** @return None +** +*******************************************************************************/ +void esp_ble_gatts_close(uint16_t conn_id); diff --git a/examples/06_bluedroid_demos/components/bluedroid_demos/include/bt_app_defs.h b/examples/06_bluedroid_demos/components/bluedroid_demos/include/bt_app_defs.h index 0dd19298a..f2012dca5 100644 --- a/examples/06_bluedroid_demos/components/bluedroid_demos/include/bt_app_defs.h +++ b/examples/06_bluedroid_demos/components/bluedroid_demos/include/bt_app_defs.h @@ -5,18 +5,233 @@ #include "bta_api.h" #include "btm_ble_api.h" +#include "bta_gatt_api.h" -#define API_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */ +#define ESP_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */ -#define API_BLE_ADV_CHNL_MAP (API_BLE_ADV_CHNL_37|API_BLE_ADV_CHNL_38|API_BLE_ADV_CHNL_39) +#define ESP_BLE_ADV_CHNL_MAP (ESP_BLE_ADV_CHNL_37|ESP_BLE_ADV_CHNL_38|ESP_BLE_ADV_CHNL_39) /* advertising channel map */ -#define API_BLE_ADV_CHNL_37 (0x01 << 0) -#define API_BLE_ADV_CHNL_38 (0x01 << 1) -#define API_BLE_ADV_CHNL_39 (0x01 << 2) +#define ESP_BLE_ADV_CHNL_37 (0x01 << 0) +#define ESP_BLE_ADV_CHNL_38 (0x01 << 1) +#define ESP_BLE_ADV_CHNL_39 (0x01 << 2) + +typedef tBTA_GATT_STATUS esp_gatt_status_t; -#define API_BLE_ISVALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == API_BLE_CONN_PARAM_UNDEF)) + + + + +typedef UINT16 gatt_size_t; +typedef tBT_UUID esp_bt_uuid_t; + +typedef tBTA_BLE_AD_MASK esp_ble_ad_mask_t; +typedef tGATT_IF esp_gatt_if_t; +typedef tBTA_GATT_SRVC_ID esp_gatt_srvc_id_t; +typedef tBTA_GATTC_CHAR_ID esp_gattc_char_id_t; +typedef tBTA_GATTC_CHAR_DESCR_ID esp_gattc_char_descr_id_t; +typedef tBTA_GATTC_INCL_SVC_ID esp_gattc_incl_srvc_id_t; +typedef tBTA_GATT_AUTH_REQ esp_gatt_auth_req_t; +typedef tBTA_GATTC_MULTI esp_gattc_multi_t; +typedef tBTA_GATTC_WRITE_TYPE esp_gattc_write_type_t; +typedef tBTA_GATT_UNFMT esp_gatt_unfmt_t; +typedef tBTA_GATT_PERM esp_gatt_perm_t; +typedef tBTA_GATT_CHAR_PROP esp_gatt_char_prop_t; +typedef tBTA_GATTC esp_gattc_t; + +typedef tBTA_GATTC_EVT esp_gattc_evt_t; + +typedef tBTA_GATTC_IF esp_gattc_if_t; + + + +/* Client callback function events */ +#define ESP_GATTC_REG_EVT 0 /* GATT client is registered. */ +#define ESP_GATTC_DEREG_EVT 1 /* GATT client deregistered event */ +#define ESP_GATTC_OPEN_EVT 2 /* GATTC open request status event */ +#define ESP_GATTC_READ_CHAR_EVT 3 /* GATT read characteristic event */ +#define ESP_GATTC_WRITE_CHAR_EVT 4 /* GATT write characteristic or char descriptor event */ +#define ESP_GATTC_CLOSE_EVT 5 /* GATTC close request status event */ +#define ESP_GATTC_SEARCH_CMPL_EVT 6 /* GATT discovery complete event */ +#define ESP_GATTC_SEARCH_RES_EVT 7 /* GATT discovery result event */ +#define ESP_GATTC_READ_DESCR_EVT 8 /* GATT read characterisitc descriptor event */ +#define ESP_GATTC_WRITE_DESCR_EVT 9 /* GATT write characteristic descriptor event */ +#define ESP_GATTC_NOTIF_EVT 10 /* GATT attribute notification event */ +#define ESP_GATTC_PREP_WRITE_EVT 11 /* GATT prepare write event */ +#define ESP_GATTC_EXEC_EVT 12 /* execute write complete event */ +#define ESP_GATTC_ACL_EVT 13 /* ACL up event */ +#define ESP_GATTC_CANCEL_OPEN_EVT 14 /* cancel open event */ +#define ESP_GATTC_SRVC_CHG_EVT 15 /* service change event */ +#define ESP_GATTC_LISTEN_EVT 16 /* listen event */ +#define ESP_GATTC_ENC_CMPL_CB_EVT 17 /* encryption complete callback event */ +#define ESP_GATTC_CFG_MTU_EVT 18 /* configure MTU complete event */ +#define ESP_GATTC_ADV_DATA_EVT 19 /* ADV data event */ +#define ESP_GATTC_MULT_ADV_ENB_EVT 20 /* Enable Multi ADV event */ +#define ESP_GATTC_MULT_ADV_UPD_EVT 21 /* Update parameter event */ +#define ESP_GATTC_MULT_ADV_DATA_EVT 22 /* Multi ADV data event */ +#define ESP_GATTC_MULT_ADV_DIS_EVT 23 /* Disable Multi ADV event */ +#define ESP_GATTC_CONGEST_EVT 24 /* Congestion event */ +#define ESP_GATTC_BTH_SCAN_ENB_EVT 25 /* Enable batch scan event */ +#define ESP_GATTC_BTH_SCAN_CFG_EVT 26 /* Config storage event */ +#define ESP_GATTC_BTH_SCAN_RD_EVT 27 /* Batch scan reports read event */ +#define ESP_GATTC_BTH_SCAN_THR_EVT 28 /* Batch scan threshold event */ +#define ESP_GATTC_BTH_SCAN_PARAM_EVT 29 /* Batch scan param event */ +#define ESP_GATTC_BTH_SCAN_DIS_EVT 30 /* Disable batch scan event */ +#define ESP_GATTC_SCAN_FLT_CFG_EVT 31 /* Scan filter config event */ +#define ESP_GATTC_SCAN_FLT_PARAM_EVT 32 /* Param filter event */ +#define ESP_GATTC_SCAN_FLT_STATUS_EVT 33 /* Filter status event */ +#define ESP_GATTC_ADV_VSC_EVT 34 /* ADV VSC event */ + + +/* GATT Server Data Structure */ +/* Server callback function events */ +#define ESP_GATTS_REG_EVT 0 +#define ESP_GATTS_READ_EVT GATTS_REQ_TYPE_READ /* 1 */ +#define ESP_GATTS_WRITE_EVT GATTS_REQ_TYPE_WRITE /* 2 */ +#define ESP_GATTS_EXEC_WRITE_EVT GATTS_REQ_TYPE_WRITE_EXEC /* 3 */ +#define ESP_GATTS_MTU_EVT GATTS_REQ_TYPE_MTU /* 4 */ +#define ESP_GATTS_CONF_EVT GATTS_REQ_TYPE_CONF /* 5 */ +#define ESP_GATTS_DEREG_EVT 6 +#define ESP_GATTS_CREATE_EVT 7 +#define ESP_GATTS_ADD_INCL_SRVC_EVT 8 +#define ESP_GATTS_ADD_CHAR_EVT 9 +#define ESP_GATTS_ADD_CHAR_DESCR_EVT 10 +#define ESP_GATTS_DELELTE_EVT 11 +#define ESP_GATTS_START_EVT 12 +#define ESP_GATTS_STOP_EVT 13 +#define ESP_GATTS_CONNECT_EVT 14 +#define ESP_GATTS_DISCONNECT_EVT 15 +#define ESP_GATTS_OPEN_EVT 16 +#define ESP_GATTS_CANCEL_OPEN_EVT 17 +#define ESP_GATTS_CLOSE_EVT 18 +#define ESP_GATTS_LISTEN_EVT 19 +#define ESP_GATTS_CONGEST_EVT 20 + +/* Attribute permissions +*/ +#define ESP_GATT_PERM_READ BTA_GATT_PERM_READ /* bit 0 - 0x0001 */ +#define ESP_GATT_PERM_READ_ENCRYPTED BTA_GATT_PERM_READ_ENCRYPTED /* bit 1 - 0x0002 */ +#define ESP_GATT_PERM_READ_ENC_MITM BTA_GATT_PERM_READ_ENC_MITM /* bit 2 - 0x0004 */ +#define ESP_GATT_PERM_WRITE BTA_GATT_PERM_WRITE /* bit 4 - 0x0010 */ +#define ESP_GATT_PERM_WRITE_ENCRYPTED BTA_GATT_PERM_WRITE_ENCRYPTED /* bit 5 - 0x0020 */ +#define ESP_GATT_PERM_WRITE_ENC_MITM BTA_GATT_PERM_WRITE_ENC_MITM /* bit 6 - 0x0040 */ +#define ESP_GATT_PERM_WRITE_SIGNED BTA_GATT_PERM_WRITE_SIGNED /* bit 7 - 0x0080 */ +#define ESP_GATT_PERM_WRITE_SIGNED_MITM BTA_GATT_PERM_WRITE_SIGNED_MITM /* bit 8 - 0x0100 */ + +#define ESP_GATTS_INVALID_APP 0xff + +#define ESP_GATTS_INVALID_IF 0 + +/* definition of characteristic properties */ +#define ESP_GATT_CHAR_PROP_BIT_BROADCAST BTA_GATT_CHAR_PROP_BIT_BROADCAST /* 0x01 */ +#define ESP_GATT_CHAR_PROP_BIT_READ BTA_GATT_CHAR_PROP_BIT_READ /* 0x02 */ +#define ESP_GATT_CHAR_PROP_BIT_WRITE_NR BTA_GATT_CHAR_PROP_BIT_WRITE_NR /* 0x04 */ +#define ESP_GATT_CHAR_PROP_BIT_WRITE BTA_GATT_CHAR_PROP_BIT_WRITE /* 0x08 */ +#define ESP_GATT_CHAR_PROP_BIT_NOTIFY BTA_GATT_CHAR_PROP_BIT_NOTIFY /* 0x10 */ +#define ESP_GATT_CHAR_PROP_BIT_INDICATE BTA_GATT_CHAR_PROP_BIT_INDICATE /* 0x20 */ +#define ESP_GATT_CHAR_PROP_BIT_AUTH BTA_GATT_CHAR_PROP_BIT_AUTH /* 0x40 */ +#define ESP_GATT_CHAR_PROP_BIT_EXT_PROP BTA_GATT_CHAR_PROP_BIT_EXT_PROP /* 0x80 */ + +typedef tBTA_GATTS_EVT esp_gatts_evt_t; +typedef tBTA_GATTS_IF esp_gatts_if_t; + +/* attribute value */ +typedef tBTA_GATT_VALUE esp_gatt_value_t; + +/* attribute response data */ +typedef tBTA_GATTS_RSP esp_gatts_rsp_t; + +typedef tBTA_GATTS esp_gatts_t; + +/* attribute request data from the client */ +#define ESP_GATT_PREP_WRITE_CANCEL 0x00 +#define ESP_GATT_PREP_WRITE_EXEC 0x01 +typedef tBTA_GATT_EXEC_FLAG esp_gatt_exec_flag_t; + +/* read request always based on UUID */ +typedef tBTA_GATT_READ_REQ esp_gatt_read_req_t; + +/* write request data */ +typedef tBTA_GATT_WRITE_REQ esp_gatt_write_req_t; + +/* callback data for server access request from client */ +typedef tBTA_GATTS_REQ_DATA esp_gatts_req_data_t; + + +/* Search callback */ +typedef tBTA_DM_SEARCH_CBACK esp_dm_search_cb_t; + +typedef tBLE_SCAN_PARAM_SETUP_CBACK esp_scan_param_setup_cb_t; + + +typedef tBTA_SET_ADV_DATA_CMPL_CBACK esp_ble_set_adv_data_cmpl_cb_t; + +/* GATTC enable callback function */ +typedef void (esp_gattc_enb_cb_t)(esp_gatt_status_t status); + +/* Client callback function */ +typedef void (esp_gattc_cb_t)(esp_gattc_evt_t event, esp_gattc_t *cb_data); + + +/* GATTS enable callback function */ +typedef void (esp_gatts_enb_cb_t)(esp_gatt_status_t status); + +/* Server callback function */ +typedef void (esp_gatts_cb_t)(esp_gatts_evt_t event, esp_gatts_t *cb_data); + + +/* Success code and error codes */ +#define ESP_GATT_OK BTA_GATT_OK +#define ESP_GATT_INVALID_HANDLE BTA_GATT_INVALID_HANDLE /* 0x0001 */ +#define ESP_GATT_READ_NOT_PERMIT BTA_GATT_READ_NOT_PERMIT /* 0x0002 */ +#define ESP_GATT_WRITE_NOT_PERMIT BTA_GATT_WRITE_NOT_PERMIT /* 0x0003 */ +#define ESP_GATT_INVALID_PDU BTA_GATT_INVALID_PDU /* 0x0004 */ +#define ESP_GATT_INSUF_AUTHENTICATION BTA_GATT_INSUF_AUTHENTICATION /* 0x0005 */ +#define ESP_GATT_REQ_NOT_SUPPORTED BTA_GATT_REQ_NOT_SUPPORTED /* 0x0006 */ +#define ESP_GATT_INVALID_OFFSET BTA_GATT_INVALID_OFFSET /* 0x0007 */ +#define ESP_GATT_INSUF_AUTHORIZATION BTA_GATT_INSUF_AUTHORIZATION /* 0x0008 */ +#define ESP_GATT_PREPARE_Q_FULL BTA_GATT_PREPARE_Q_FULL /* 0x0009 */ +#define ESP_GATT_NOT_FOUND BTA_GATT_NOT_FOUND /* 0x000a */ +#define ESP_GATT_NOT_LONG BTA_GATT_NOT_LONG /* 0x000b */ +#define ESP_GATT_INSUF_KEY_SIZE BTA_GATT_INSUF_KEY_SIZE /* 0x000c */ +#define ESP_GATT_INVALID_ATTR_LEN BTA_GATT_INVALID_ATTR_LEN /* 0x000d */ +#define ESP_GATT_ERR_UNLIKELY BTA_GATT_ERR_UNLIKELY /* 0x000e */ +#define ESP_GATT_INSUF_ENCRYPTION BTA_GATT_INSUF_ENCRYPTION /* 0x000f */ +#define ESP_GATT_UNSUPPORT_GRP_TYPE BTA_GATT_UNSUPPORT_GRP_TYPE /* 0x0010 */ +#define ESP_GATT_INSUF_RESOURCE BTA_GATT_INSUF_RESOURCE /* 0x0011 */ + + +#define ESP_GATT_NO_RESOURCES BTA_GATT_NO_RESOURCES /* 0x80 */ +#define ESP_GATT_INTERNAL_ERROR BTA_GATT_INTERNAL_ERROR /* 0x81 */ +#define ESP_GATT_WRONG_STATE BTA_GATT_WRONG_STATE /* 0x82 */ +#define ESP_GATT_DB_FULL BTA_GATT_DB_FULL /* 0x83 */ +#define ESP_GATT_BUSY BTA_GATT_BUSY /* 0x84 */ +#define ESP_GATT_ERROR BTA_GATT_ERROR /* 0x85 */ +#define ESP_GATT_CMD_STARTED BTA_GATT_CMD_STARTED /* 0x86 */ +#define ESP_GATT_ILLEGAL_PARAMETER BTA_GATT_ILLEGAL_PARAMETER /* 0x87 */ +#define ESP_GATT_PENDING BTA_GATT_PENDING /* 0x88 */ +#define ESP_GATT_AUTH_FAIL BTA_GATT_AUTH_FAIL /* 0x89 */ +#define ESP_GATT_MORE BTA_GATT_MORE /* 0x8a */ +#define ESP_GATT_INVALID_CFG BTA_GATT_INVALID_CFG /* 0x8b */ +#define ESP_GATT_SERVICE_STARTED BTA_GATT_SERVICE_STARTED /* 0x8c */ +#define ESP_GATT_ENCRYPED_MITM BTA_GATT_ENCRYPED_MITM /* GATT_SUCCESS */ +#define ESP_GATT_ENCRYPED_NO_MITM BTA_GATT_ENCRYPED_NO_MITM /* 0x8d */ +#define ESP_GATT_NOT_ENCRYPTED BTA_GATT_NOT_ENCRYPTED /* 0x8e */ +#define ESP_GATT_CONGESTED BTA_GATT_CONGESTED /* 0x8f */ + +#define ESP_GATT_DUP_REG BTA_GATT_DUP_REG /* 0x90 */ +#define ESP_GATT_ALREADY_OPEN BTA_GATT_ALREADY_OPEN /* 0x91 */ +#define ESP_GATT_CANCEL BTA_GATT_CANCEL /* 0x92 */ + + /* 0xE0 ~ 0xFC reserved for future use */ +#define ESP_GATT_CCC_CFG_ERR BTA_GATT_CCC_CFG_ERR /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */ +#define ESP_GATT_PRC_IN_PROGRESS BTA_GATT_PRC_IN_PROGRESS /* 0xFE Procedure Already in progress */ +#define ESP_GATT_OUT_OF_RANGE BTA_GATT_OUT_OF_RANGE /* 0xFFAttribute value out of range */ + + + +#define API_BLE_ISVALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == ESP_BLE_CONN_PARAM_UNDEF)) enum @@ -76,14 +291,14 @@ typedef struct { char *adv_name; //set the device name to be sent on the advertising tBTA_BLE_ADV_DATA ble_adv_data; -}tESP_BLE_ADV_DATA; +}esp_ble_adv_data_cfg_t; typedef struct { UINT16 adv_int_min; UINT16 adv_int_max; tBLE_BD_ADDR *p_dir_bda; -}tESP_BLE_ADV_PARAM; +}esp_ble_adv_params_t; typedef struct { @@ -94,7 +309,7 @@ typedef struct tBTM_BLE_ADV_CHNL_MAP channel_map; tBTM_BLE_AFP adv_filter_policy; tBLE_BD_ADDR *p_dir_bda; -}tESP_API_BLE_ADV_PARAMS_ALL; +}esp_ble_adv_params_all_t; typedef struct { @@ -103,13 +318,13 @@ typedef struct UINT16 scan_win; UINT8 addr_type_own; UINT8 scan_fil_policy; -}tESP_BLE_SCAN_PARAMS; +}esp_ble_scan_params; -extern void ESP_AppBleConfigadvData(tESP_BLE_ADV_DATA *adv_data, +extern void ble_config_adv_data(esp_ble_adv_data_cfg_t *adv_data, tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback); -extern void ESP_AppBleSetScanRsp(tESP_BLE_ADV_DATA *scan_rsp_data, +extern void ble_set_scan_rsp(esp_ble_adv_data_cfg_t *scan_rsp_data, tBTA_SET_ADV_DATA_CMPL_CBACK *p_scan_rsp_data_cback);