/// GATT maximum attribute length
#define ESP_GATT_MAX_ATTR_LEN 600 //as same as GATT_MAX_ATTR_LEN
+typedef enum {
+ ESP_GATT_SERVICE_FROM_REMOTE_DEVICE = 0, /* relate to BTA_GATTC_SERVICE_INFO_FROM_REMOTE_DEVICE in bta_gattc_int.h */
+ ESP_GATT_SERVICE_FROM_NVS_FLASH = 1, /* relate to BTA_GATTC_SERVICE_INFO_FROM_NVS_FLASH in bta_gattc_int.h */
+ ESP_GATT_SERVICE_FROM_UNKNOWN = 2, /* relate to BTA_GATTC_SERVICE_INFO_FROM_UNKNOWN in bta_gattc_int.h */
+} esp_service_source_t;
/**
* @brief Attribute description (used to create database)
* @brief ESP_GATTC_SEARCH_CMPL_EVT
*/
struct gattc_search_cmpl_evt_param {
- esp_gatt_status_t status; /*!< Operation status */
- uint16_t conn_id; /*!< Connection id */
- } search_cmpl; /*!< Gatt client callback param of ESP_GATTC_SEARCH_CMPL_EVT */
+ esp_gatt_status_t status; /*!< Operation status */
+ uint16_t conn_id; /*!< Connection id */
+ esp_service_source_t searched_service_source; /*!< The source of the service information */
+ } search_cmpl; /*!< Gatt client callback param of ESP_GATTC_SEARCH_CMPL_EVT */
/**
* @brief ESP_GATTC_SEARCH_RES_EVT
} else {
p_clcb->disc_active = TRUE;
}
+ p_clcb->searched_service_source = BTA_GATTC_SERVICE_INFO_FROM_REMOTE_DEVICE;
} else {
APPL_TRACE_ERROR("unknown device, can not start discovery");
}
}
cb_data.search_cmpl.status = status;
cb_data.search_cmpl.conn_id = p_clcb->bta_conn_id;
+ cb_data.search_cmpl.searched_service_source = p_clcb->searched_service_source;
/* end of search or no server cache available */
( *p_clcb->p_rcb->p_cback)(BTA_GATTC_SEARCH_CMPL_EVT, &cb_data);
APPL_TRACE_DEBUG("%s(), gattc cache load fail, status = %x", __func__, status);
return false;
}
-
+ p_clcb->searched_service_source = BTA_GATTC_SERVICE_INFO_FROM_NVS_FLASH;
bta_gattc_rebuild_cache(p_clcb->p_srcb, num_attr, attr);
//free the attr buffer after used.
osi_free(attr);
p_clcb->status = BTA_GATT_OK;
p_clcb->transport = transport;
bdcpy(p_clcb->bda, remote_bda);
-
+ p_clcb->searched_service_source = BTA_GATTC_SERVICE_INFO_FROM_UNKNOWN;
p_clcb->p_rcb = bta_gattc_cl_get_regcb(client_if);
if (p_clcb->p_cmd_list == NULL) {
p_clcb->p_cmd_list = list_new(osi_free_func);
#define BTA_GATTC_SERVICE_CHANGED_LEN 4
+typedef enum {
+ BTA_GATTC_SERVICE_INFO_FROM_REMOTE_DEVICE = 0,
+ BTA_GATTC_SERVICE_INFO_FROM_NVS_FLASH = 1,
+ BTA_GATTC_SERVICE_INFO_FROM_UNKNOWN = 2,
+} tBTA_SERVICE_SOURCE_t;
+
/* max client application GATTC can support */
#ifndef BTA_GATTC_CL_MAX
#if (GATT_MAX_PHY_CHANNEL > 3)
tBTA_GATTC_STATE state;
tBTA_GATT_STATUS status;
UINT16 reason;
+ UINT8 searched_service_source;
} tBTA_GATTC_CLCB;
/* background connection tracking information */
typedef struct {
UINT16 conn_id;
tBTA_GATT_STATUS status;
+ UINT8 searched_service_source;
} tBTA_GATTC_SEARCH_CMPL;
typedef struct {
gattc_if = BTC_GATT_GET_GATT_IF(search_cmpl->conn_id);
param.search_cmpl.conn_id = BTC_GATT_GET_CONN_ID(search_cmpl->conn_id);
param.search_cmpl.status = search_cmpl->status;
+ param.search_cmpl.searched_service_source = search_cmpl->searched_service_source;
btc_gattc_cb_to_app(ESP_GATTC_SEARCH_CMPL_EVT, gattc_if, ¶m);
break;
}
ESP_LOGE(GATTC_TAG, "search service failed, error status = %x", p_data->search_cmpl.status);
break;
}
+ if(p_data->search_cmpl.searched_service_source == ESP_GATT_SERVICE_FROM_REMOTE_DEVICE) {
+ ESP_LOGI(GATTC_TAG, "Get service information from remote device");
+ } else if (p_data->search_cmpl.searched_service_source == ESP_GATT_SERVICE_FROM_NVS_FLASH) {
+ ESP_LOGI(GATTC_TAG, "Get service information from flash");
+ } else {
+ ESP_LOGI(GATTC_TAG, "unknown service source");
+ }
ESP_LOGI(GATTC_TAG, "ESP_GATTC_SEARCH_CMPL_EVT");
if (get_server){
uint16_t count = 0;
ESP_LOGE(GATTC_TAG, "search service failed, error status = %x", p_data->search_cmpl.status);
break;
}
+ if(p_data->search_cmpl.searched_service_source == ESP_GATT_SERVICE_FROM_REMOTE_DEVICE) {
+ ESP_LOGI(GATTC_TAG, "Get service information from remote device");
+ } else if (p_data->search_cmpl.searched_service_source == ESP_GATT_SERVICE_FROM_NVS_FLASH) {
+ ESP_LOGI(GATTC_TAG, "Get service information from flash");
+ } else {
+ ESP_LOGI(GATTC_TAG, "unknown service source");
+ }
if (get_service){
uint16_t count = 0;
uint16_t offset = 0;