mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/btdm_add_service_source_param_for_ESP_GATTC_SEARCH_CMPL_EVT' into 'master'
Component/bt: add “service from” param for ESP_GATTC_SEARCH_CMPL_EVT See merge request idf/esp-idf!3399
This commit is contained in:
commit
7014c14537
@ -289,6 +289,11 @@ typedef uint8_t esp_gatt_char_prop_t;
|
|||||||
/// GATT maximum attribute length
|
/// GATT maximum attribute length
|
||||||
#define ESP_GATT_MAX_ATTR_LEN 600 //as same as GATT_MAX_ATTR_LEN
|
#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 Attribute description (used to create database)
|
||||||
|
@ -117,6 +117,7 @@ typedef union {
|
|||||||
struct gattc_search_cmpl_evt_param {
|
struct gattc_search_cmpl_evt_param {
|
||||||
esp_gatt_status_t status; /*!< Operation status */
|
esp_gatt_status_t status; /*!< Operation status */
|
||||||
uint16_t conn_id; /*!< Connection id */
|
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 */
|
} search_cmpl; /*!< Gatt client callback param of ESP_GATTC_SEARCH_CMPL_EVT */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -983,6 +983,7 @@ void bta_gattc_start_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
|||||||
} else {
|
} else {
|
||||||
p_clcb->disc_active = TRUE;
|
p_clcb->disc_active = TRUE;
|
||||||
}
|
}
|
||||||
|
p_clcb->searched_service_source = BTA_GATTC_SERVICE_INFO_FROM_REMOTE_DEVICE;
|
||||||
} else {
|
} else {
|
||||||
APPL_TRACE_ERROR("unknown device, can not start discovery");
|
APPL_TRACE_ERROR("unknown device, can not start discovery");
|
||||||
}
|
}
|
||||||
@ -1471,6 +1472,7 @@ void bta_gattc_search(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
|||||||
}
|
}
|
||||||
cb_data.search_cmpl.status = status;
|
cb_data.search_cmpl.status = status;
|
||||||
cb_data.search_cmpl.conn_id = p_clcb->bta_conn_id;
|
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 */
|
/* end of search or no server cache available */
|
||||||
( *p_clcb->p_rcb->p_cback)(BTA_GATTC_SEARCH_CMPL_EVT, &cb_data);
|
( *p_clcb->p_rcb->p_cback)(BTA_GATTC_SEARCH_CMPL_EVT, &cb_data);
|
||||||
|
@ -2116,7 +2116,7 @@ bool bta_gattc_cache_load(tBTA_GATTC_CLCB *p_clcb)
|
|||||||
APPL_TRACE_DEBUG("%s(), gattc cache load fail, status = %x", __func__, status);
|
APPL_TRACE_DEBUG("%s(), gattc cache load fail, status = %x", __func__, status);
|
||||||
return false;
|
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);
|
bta_gattc_rebuild_cache(p_clcb->p_srcb, num_attr, attr);
|
||||||
//free the attr buffer after used.
|
//free the attr buffer after used.
|
||||||
osi_free(attr);
|
osi_free(attr);
|
||||||
|
@ -229,7 +229,7 @@ tBTA_GATTC_CLCB *bta_gattc_clcb_alloc(tBTA_GATTC_IF client_if, BD_ADDR remote_bd
|
|||||||
p_clcb->status = BTA_GATT_OK;
|
p_clcb->status = BTA_GATT_OK;
|
||||||
p_clcb->transport = transport;
|
p_clcb->transport = transport;
|
||||||
bdcpy(p_clcb->bda, remote_bda);
|
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);
|
p_clcb->p_rcb = bta_gattc_cl_get_regcb(client_if);
|
||||||
if (p_clcb->p_cmd_list == NULL) {
|
if (p_clcb->p_cmd_list == NULL) {
|
||||||
p_clcb->p_cmd_list = list_new(osi_free_func);
|
p_clcb->p_cmd_list = list_new(osi_free_func);
|
||||||
|
@ -73,6 +73,12 @@ typedef UINT16 tBTA_GATTC_INT_EVT;
|
|||||||
|
|
||||||
#define BTA_GATTC_SERVICE_CHANGED_LEN 4
|
#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 */
|
/* max client application GATTC can support */
|
||||||
#ifndef BTA_GATTC_CL_MAX
|
#ifndef BTA_GATTC_CL_MAX
|
||||||
#if (GATT_MAX_PHY_CHANNEL > 3)
|
#if (GATT_MAX_PHY_CHANNEL > 3)
|
||||||
@ -343,6 +349,7 @@ typedef struct {
|
|||||||
tBTA_GATTC_STATE state;
|
tBTA_GATTC_STATE state;
|
||||||
tBTA_GATT_STATUS status;
|
tBTA_GATT_STATUS status;
|
||||||
UINT16 reason;
|
UINT16 reason;
|
||||||
|
UINT8 searched_service_source;
|
||||||
} tBTA_GATTC_CLCB;
|
} tBTA_GATTC_CLCB;
|
||||||
|
|
||||||
/* background connection tracking information */
|
/* background connection tracking information */
|
||||||
|
@ -315,6 +315,7 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
UINT16 conn_id;
|
UINT16 conn_id;
|
||||||
tBTA_GATT_STATUS status;
|
tBTA_GATT_STATUS status;
|
||||||
|
UINT8 searched_service_source;
|
||||||
} tBTA_GATTC_SEARCH_CMPL;
|
} tBTA_GATTC_SEARCH_CMPL;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -826,6 +826,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
|
|||||||
gattc_if = BTC_GATT_GET_GATT_IF(search_cmpl->conn_id);
|
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.conn_id = BTC_GATT_GET_CONN_ID(search_cmpl->conn_id);
|
||||||
param.search_cmpl.status = search_cmpl->status;
|
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);
|
btc_gattc_cb_to_app(ESP_GATTC_SEARCH_CMPL_EVT, gattc_if, ¶m);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -150,6 +150,13 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
|
|||||||
ESP_LOGE(GATTC_TAG, "search service failed, error status = %x", p_data->search_cmpl.status);
|
ESP_LOGE(GATTC_TAG, "search service failed, error status = %x", p_data->search_cmpl.status);
|
||||||
break;
|
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");
|
ESP_LOGI(GATTC_TAG, "ESP_GATTC_SEARCH_CMPL_EVT");
|
||||||
if (get_server){
|
if (get_server){
|
||||||
uint16_t count = 0;
|
uint16_t count = 0;
|
||||||
|
@ -173,6 +173,13 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
|
|||||||
ESP_LOGE(GATTC_TAG, "search service failed, error status = %x", p_data->search_cmpl.status);
|
ESP_LOGE(GATTC_TAG, "search service failed, error status = %x", p_data->search_cmpl.status);
|
||||||
break;
|
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){
|
if (get_service){
|
||||||
uint16_t count = 0;
|
uint16_t count = 0;
|
||||||
uint16_t offset = 0;
|
uint16_t offset = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user