component/bt: For unity, Change all the associat & associa to abbreviated form(assoc).

This commit is contained in:
Yulong 2018-04-20 02:16:33 -04:00
parent b940abca0e
commit 2c7182c59f
11 changed files with 108 additions and 101 deletions

View file

@ -547,7 +547,7 @@ esp_err_t esp_ble_gattc_cache_refresh(esp_bd_addr_t remote_bda)
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
} }
esp_err_t esp_ble_gattc_cache_associat(esp_gatt_if_t gattc_if, esp_bd_addr_t src_addr, esp_bd_addr_t ass_addr, bool is_associat) esp_err_t esp_ble_gattc_cache_assoc(esp_gatt_if_t gattc_if, esp_bd_addr_t src_addr, esp_bd_addr_t assoc_addr, bool is_assoc)
{ {
btc_msg_t msg; btc_msg_t msg;
btc_ble_gattc_args_t arg; btc_ble_gattc_args_t arg;
@ -556,11 +556,11 @@ esp_err_t esp_ble_gattc_cache_associat(esp_gatt_if_t gattc_if, esp_bd_addr_t src
msg.sig = BTC_SIG_API_CALL; msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC; msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_CACHE_ASSOCIAT; msg.act = BTC_GATTC_ACT_CACHE_ASSOC;
arg.cache_associat.is_associat = is_associat; arg.cache_assoc.is_assoc = is_assoc;
arg.cache_associat.gattc_if = gattc_if; arg.cache_assoc.gattc_if = gattc_if;
memcpy(arg.cache_associat.src_addr, src_addr, sizeof(esp_bd_addr_t)); memcpy(arg.cache_assoc.src_addr, src_addr, sizeof(esp_bd_addr_t));
memcpy(arg.cache_associat.ass_addr, ass_addr, sizeof(esp_bd_addr_t)); memcpy(arg.cache_assoc.assoc_addr, assoc_addr, sizeof(esp_bd_addr_t));
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
} }

View file

@ -65,7 +65,7 @@ typedef enum {
ESP_GATTC_DISCONNECT_EVT = 41, /*!< When the ble physical connection disconnected, the event comes */ ESP_GATTC_DISCONNECT_EVT = 41, /*!< When the ble physical connection disconnected, the event comes */
ESP_GATTC_READ_MULTIPLE_EVT = 42, /*!< When the ble characteristic or descriptor multiple complete, the event comes */ ESP_GATTC_READ_MULTIPLE_EVT = 42, /*!< When the ble characteristic or descriptor multiple complete, the event comes */
ESP_GATTC_QUEUE_FULL_EVT = 43, /*!< When the gattc command queue full, the event comes */ ESP_GATTC_QUEUE_FULL_EVT = 43, /*!< When the gattc command queue full, the event comes */
ESP_GATTC_SET_ASSOCIAT_EVT = 44, /*!< When the ble gattc set the associat address complete, the event comes */ ESP_GATTC_SET_ASSOC_EVT = 44, /*!< When the ble gattc set the associated address complete, the event comes */
ESP_GATTC_GET_ADDR_LIST_EVT = 45, /*!< When the ble get gattc address list in cache finish, the event comes */ ESP_GATTC_GET_ADDR_LIST_EVT = 45, /*!< When the ble get gattc address list in cache finish, the event comes */
} esp_gattc_cb_event_t; } esp_gattc_cb_event_t;
@ -218,11 +218,11 @@ typedef union {
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
} disconnect; /*!< Gatt client callback param of ESP_GATTC_DISCONNECT_EVT */ } disconnect; /*!< Gatt client callback param of ESP_GATTC_DISCONNECT_EVT */
/** /**
* @brief ESP_GATTC_SET_ASSOCIAT_EVT * @brief ESP_GATTC_SET_ASSOC_EVT
*/ */
struct gattc_set_ass_addr_cmp_evt_param { struct gattc_set_assoc_addr_cmp_evt_param {
esp_gatt_status_t status; /*!< Operation status */ esp_gatt_status_t status; /*!< Operation status */
} set_ass_cmp; /*!< Gatt client callback param of ESP_GATTC_SET_ASSOCIAT_EVT */ } set_assoc_cmp; /*!< Gatt client callback param of ESP_GATTC_SET_ASSOC_EVT */
/** /**
* @brief ESP_GATTC_GET_ADDR_LIST_EVT * @brief ESP_GATTC_GET_ADDR_LIST_EVT
*/ */
@ -802,18 +802,25 @@ esp_err_t esp_ble_gattc_cache_refresh(esp_bd_addr_t remote_bda);
/** /**
* @brief Add or delete the associated address with the source address. * @brief Add or delete the associated address with the source address.
* Note: The role of this API is mainly when the client side has stored a server-side database,
* when it needs to connect another device, but the device's attribute database is the same
* as the server database stored on the client-side, calling this API can use the database
* that the device has stored used as the peer server database to reduce the attribute
* database search and discovery process and speed up the connection time.
* The associated address mains that device want to used the database has stored in the local cache.
* The source address mains that device want to share the database to the associated address device.
* *
* @param[in] gattc_if: Gatt client access interface. * @param[in] gattc_if: Gatt client access interface.
* @param[in] src_addr: the source address which provide the attribute table. * @param[in] src_addr: the source address which provide the attribute table.
* @param[in] ass_addr: the associated device address which went to share the attribute table with the source address. * @param[in] assoc_addr: the associated device address which went to share the attribute table with the source address.
* @param[in] is_associat: true add the associated device address, false remove the associated device address. * @param[in] is_assoc: true add the associated device address, false remove the associated device address.
* @return * @return
* - ESP_OK: success * - ESP_OK: success
* - other: failed * - other: failed
* *
*/ */
esp_err_t esp_ble_gattc_cache_associat(esp_gatt_if_t gattc_if, esp_bd_addr_t src_addr, esp_err_t esp_ble_gattc_cache_assoc(esp_gatt_if_t gattc_if, esp_bd_addr_t src_addr,
esp_bd_addr_t ass_addr, bool is_associat); esp_bd_addr_t assoc_addr, bool is_assoc);
/** /**
* @brief Get the address list which has store the attribute table in the gattc cache. There will * @brief Get the address list which has store the attribute table in the gattc cache. There will
* callback ESP_GATTC_GET_ADDR_LIST_EVT event when get address list complete. * callback ESP_GATTC_GET_ADDR_LIST_EVT event when get address list complete.

View file

@ -1768,49 +1768,49 @@ void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
bta_gattc_cache_reset(p_msg->api_conn.remote_bda); bta_gattc_cache_reset(p_msg->api_conn.remote_bda);
} }
void bta_gattc_process_api_cache_associat(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg) void bta_gattc_process_api_cache_assoc(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
{ {
tBTA_GATTC gattc_cb = {0}; tBTA_GATTC gattc_cb = {0};
gattc_cb.set_associa.client_if = p_msg->api_associa.client_if; gattc_cb.set_assoc.client_if = p_msg->api_assoc.client_if;
BOOLEAN state = FALSE; BOOLEAN state = FALSE;
tBTA_GATTC_CLCB *p_ass_clcb = bta_gattc_find_clcb_by_cif(p_msg->api_associa.client_if, tBTA_GATTC_CLCB *p_assoc_clcb = bta_gattc_find_clcb_by_cif(p_msg->api_assoc.client_if,
p_msg->api_associa.ass_addr, BTA_TRANSPORT_LE); p_msg->api_assoc.assoc_addr, BTA_TRANSPORT_LE);
tBTA_GATTC_RCB *p_clrcb = bta_gattc_cl_get_regcb(p_msg->api_associa.client_if); tBTA_GATTC_RCB *p_clrcb = bta_gattc_cl_get_regcb(p_msg->api_assoc.client_if);
if (p_ass_clcb != NULL) { if (p_assoc_clcb != NULL) {
if (p_ass_clcb->state == BTA_GATTC_CONN_ST || p_ass_clcb->state == BTA_GATTC_DISCOVER_ST) { if (p_assoc_clcb->state == BTA_GATTC_CONN_ST || p_assoc_clcb->state == BTA_GATTC_DISCOVER_ST) {
gattc_cb.set_associa.status = BTA_GATT_BUSY; gattc_cb.set_assoc.status = BTA_GATT_BUSY;
if (p_clrcb != NULL) { if (p_clrcb != NULL) {
(*p_clrcb->p_cback)(BTA_GATTC_ASSOCIAT_EVT, &gattc_cb); (*p_clrcb->p_cback)(BTA_GATTC_ASSOC_EVT, &gattc_cb);
return; return;
} }
} }
} }
if (p_msg->api_associa.is_associa) { if (p_msg->api_assoc.is_assoc) {
if ((state = bta_gattc_co_cache_append_ass_addr(p_msg->api_associa.src_addr, p_msg->api_associa.ass_addr)) == TRUE) { if ((state = bta_gattc_co_cache_append_assoc_addr(p_msg->api_assoc.src_addr, p_msg->api_assoc.assoc_addr)) == TRUE) {
gattc_cb.set_associa.status = BTA_GATT_OK; gattc_cb.set_assoc.status = BTA_GATT_OK;
} else { } else {
gattc_cb.set_associa.status = BTA_GATT_ERROR; gattc_cb.set_assoc.status = BTA_GATT_ERROR;
if (p_clrcb != NULL) { if (p_clrcb != NULL) {
(*p_clrcb->p_cback)(BTA_GATTC_ASSOCIAT_EVT, &gattc_cb); (*p_clrcb->p_cback)(BTA_GATTC_ASSOC_EVT, &gattc_cb);
return; return;
} }
} }
} else { } else {
if (( state = bta_gattc_co_cache_remove_ass_addr(p_msg->api_associa.src_addr, p_msg->api_associa.ass_addr)) == TRUE) { if (( state = bta_gattc_co_cache_remove_assoc_addr(p_msg->api_assoc.src_addr, p_msg->api_assoc.assoc_addr)) == TRUE) {
gattc_cb.set_associa.status = BTA_GATT_OK; gattc_cb.set_assoc.status = BTA_GATT_OK;
} else { } else {
gattc_cb.set_associa.status = BTA_GATT_ERROR; gattc_cb.set_assoc.status = BTA_GATT_ERROR;
if (p_clrcb != NULL) { if (p_clrcb != NULL) {
(*p_clrcb->p_cback)(BTA_GATTC_ASSOCIAT_EVT, &gattc_cb); (*p_clrcb->p_cback)(BTA_GATTC_ASSOC_EVT, &gattc_cb);
return; return;
} }
} }
} }
if (p_clrcb != NULL) { if (p_clrcb != NULL) {
(*p_clrcb->p_cback)(BTA_GATTC_ASSOCIAT_EVT, &gattc_cb); (*p_clrcb->p_cback)(BTA_GATTC_ASSOC_EVT, &gattc_cb);
} }
return; return;

View file

@ -929,16 +929,16 @@ void BTA_GATTC_Refresh(BD_ADDR remote_bda)
return; return;
} }
void BTA_GATTC_CacheAssociat(tBTA_GATTC_IF client_if, BD_ADDR src_addr, BD_ADDR ass_addr, BOOLEAN is_associa) void BTA_GATTC_CacheAssoc(tBTA_GATTC_IF client_if, BD_ADDR src_addr, BD_ADDR assoc_addr, BOOLEAN is_assoc)
{ {
tBTA_GATTC_API_CACHE_ASSO *p_buf; tBTA_GATTC_API_CACHE_ASSOC *p_buf;
if ((p_buf = (tBTA_GATTC_API_CACHE_ASSO *)osi_malloc(sizeof(tBTA_GATTC_API_CACHE_ASSO))) != NULL) { if ((p_buf = (tBTA_GATTC_API_CACHE_ASSOC *)osi_malloc(sizeof(tBTA_GATTC_API_CACHE_ASSOC))) != NULL) {
p_buf->hdr.event = BTA_GATTC_API_CACHE_ASSOCIAT_EVT; p_buf->hdr.event = BTA_GATTC_API_CACHE_ASSOC_EVT;
p_buf->is_associa = is_associa; p_buf->is_assoc = is_assoc;
p_buf->client_if = client_if; p_buf->client_if = client_if;
memcpy(p_buf->src_addr, src_addr, sizeof(BD_ADDR)); memcpy(p_buf->src_addr, src_addr, sizeof(BD_ADDR));
memcpy(p_buf->ass_addr, ass_addr, sizeof(BD_ADDR)); memcpy(p_buf->assoc_addr, assoc_addr, sizeof(BD_ADDR));
bta_sys_sendmsg(p_buf); bta_sys_sendmsg(p_buf);

View file

@ -356,8 +356,8 @@ BOOLEAN bta_gattc_hdl_event(BT_HDR *p_msg)
case BTA_GATTC_API_REFRESH_EVT: case BTA_GATTC_API_REFRESH_EVT:
bta_gattc_process_api_refresh(p_cb, (tBTA_GATTC_DATA *) p_msg); bta_gattc_process_api_refresh(p_cb, (tBTA_GATTC_DATA *) p_msg);
break; break;
case BTA_GATTC_API_CACHE_ASSOCIAT_EVT: case BTA_GATTC_API_CACHE_ASSOC_EVT:
bta_gattc_process_api_cache_associat(p_cb, (tBTA_GATTC_DATA *)p_msg); bta_gattc_process_api_cache_assoc(p_cb, (tBTA_GATTC_DATA *)p_msg);
break; break;
case BTA_GATTC_API_CACHE_GET_ADDR_LIST_EVT: case BTA_GATTC_API_CACHE_GET_ADDR_LIST_EVT:
bta_gattc_process_api_cache_get_addr_list(p_cb, (tBTA_GATTC_DATA *)p_msg); bta_gattc_process_api_cache_get_addr_list(p_cb, (tBTA_GATTC_DATA *)p_msg);

View file

@ -183,7 +183,7 @@ typedef UINT8 tBTA_GATT_STATUS;
#define BTA_GATTC_DISCONNECT_EVT 36 /* GATTC DISCONNECT event */ #define BTA_GATTC_DISCONNECT_EVT 36 /* GATTC DISCONNECT event */
#define BTA_GATTC_READ_MULTIPLE_EVT 37 /* GATTC Read mutiple event */ #define BTA_GATTC_READ_MULTIPLE_EVT 37 /* GATTC Read mutiple event */
#define BTA_GATTC_QUEUE_FULL_EVT 38 /* GATTC queue full event */ #define BTA_GATTC_QUEUE_FULL_EVT 38 /* GATTC queue full event */
#define BTA_GATTC_ASSOCIAT_EVT 39 /* GATTC association address event */ #define BTA_GATTC_ASSOC_EVT 39 /* GATTC association address event */
#define BTA_GATTC_GET_ADDR_LIST_EVT 40 /* GATTC get address list in the cache event */ #define BTA_GATTC_GET_ADDR_LIST_EVT 40 /* GATTC get address list in the cache event */
typedef UINT8 tBTA_GATTC_EVT; typedef UINT8 tBTA_GATTC_EVT;
@ -369,7 +369,7 @@ typedef struct {
typedef struct { typedef struct {
tBTA_GATT_STATUS status; tBTA_GATT_STATUS status;
tBTA_GATTC_IF client_if; tBTA_GATTC_IF client_if;
} tBTA_GATTC_SET_ASSOCIAT; } tBTA_GATTC_SET_ASSOC;
typedef struct { typedef struct {
tBTA_GATT_STATUS status; tBTA_GATT_STATUS status;
@ -427,7 +427,7 @@ typedef union {
tBTA_GATTC_CONGEST congest; tBTA_GATTC_CONGEST congest;
tBTA_GATTC_QUEUE_FULL queue_full; tBTA_GATTC_QUEUE_FULL queue_full;
tBTA_GATTC_SERVICE_CHANGE srvc_chg; /* service change event */ tBTA_GATTC_SERVICE_CHANGE srvc_chg; /* service change event */
tBTA_GATTC_SET_ASSOCIAT set_associa; tBTA_GATTC_SET_ASSOC set_assoc;
tBTA_GATTC_GET_ADDR_LIST get_addr_list; tBTA_GATTC_GET_ADDR_LIST get_addr_list;
} tBTA_GATTC; } tBTA_GATTC;
@ -1101,7 +1101,7 @@ extern void BTA_GATTC_ReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_mult
*******************************************************************************/ *******************************************************************************/
extern void BTA_GATTC_Refresh(BD_ADDR remote_bda); extern void BTA_GATTC_Refresh(BD_ADDR remote_bda);
extern void BTA_GATTC_CacheAssociat(tBTA_GATTC_IF client_if, BD_ADDR src_addr, BD_ADDR ass_addr, BOOLEAN is_associa); extern void BTA_GATTC_CacheAssoc(tBTA_GATTC_IF client_if, BD_ADDR src_addr, BD_ADDR assoc_addr, BOOLEAN is_assoc);
extern void BTA_GATTC_CacheGetAddrList(tBTA_GATTC_IF client_if); extern void BTA_GATTC_CacheGetAddrList(tBTA_GATTC_IF client_if);

View file

@ -125,14 +125,14 @@ extern void bta_gattc_co_get_addr_list(BD_ADDR *addr_list);
extern void bta_gattc_co_cache_addr_save(BD_ADDR bd_addr, coap_key_t hash_key); extern void bta_gattc_co_cache_addr_save(BD_ADDR bd_addr, coap_key_t hash_key);
extern BOOLEAN bta_gattc_co_cache_new_ass_list(BD_ADDR src_addr, uint8_t index); extern BOOLEAN bta_gattc_co_cache_new_assoc_list(BD_ADDR src_addr, uint8_t index);
extern BOOLEAN bta_gattc_co_cache_append_ass_addr(BD_ADDR src_addr, BD_ADDR ass_addr); extern BOOLEAN bta_gattc_co_cache_append_assoc_addr(BD_ADDR src_addr, BD_ADDR assoc_addr);
extern BOOLEAN bta_gattc_co_cache_remove_ass_addr(BD_ADDR src_addr, BD_ADDR ass_addr); extern BOOLEAN bta_gattc_co_cache_remove_assoc_addr(BD_ADDR src_addr, BD_ADDR assoc_addr);
uint8_t* bta_gattc_co_cache_find_src_addr(BD_ADDR ass_addr, uint8_t *index); uint8_t* bta_gattc_co_cache_find_src_addr(BD_ADDR assoc_addr, uint8_t *index);
extern BOOLEAN bta_gattc_co_cache_clear_ass_addr(BD_ADDR src_addr); extern BOOLEAN bta_gattc_co_cache_clear_assoc_addr(BD_ADDR src_addr);
#endif /* BTA_GATT_CO_H */ #endif /* BTA_GATT_CO_H */

View file

@ -66,7 +66,7 @@ enum {
BTA_GATTC_API_BROADCAST_EVT, BTA_GATTC_API_BROADCAST_EVT,
BTA_GATTC_API_DISABLE_EVT, BTA_GATTC_API_DISABLE_EVT,
BTA_GATTC_ENC_CMPL_EVT, BTA_GATTC_ENC_CMPL_EVT,
BTA_GATTC_API_CACHE_ASSOCIAT_EVT, BTA_GATTC_API_CACHE_ASSOC_EVT,
BTA_GATTC_API_CACHE_GET_ADDR_LIST_EVT, BTA_GATTC_API_CACHE_GET_ADDR_LIST_EVT,
}; };
typedef UINT16 tBTA_GATTC_INT_EVT; typedef UINT16 tBTA_GATTC_INT_EVT;
@ -192,9 +192,9 @@ typedef struct {
BT_HDR hdr; BT_HDR hdr;
tBTA_GATTC_IF client_if; tBTA_GATTC_IF client_if;
BD_ADDR src_addr; BD_ADDR src_addr;
BD_ADDR ass_addr; BD_ADDR assoc_addr;
BOOLEAN is_associa; BOOLEAN is_assoc;
} tBTA_GATTC_API_CACHE_ASSO; } tBTA_GATTC_API_CACHE_ASSOC;
typedef struct { typedef struct {
BT_HDR hdr; BT_HDR hdr;
@ -230,7 +230,7 @@ typedef union {
tBTA_GATTC_API_EXEC api_exec; tBTA_GATTC_API_EXEC api_exec;
tBTA_GATTC_API_READ_MULTI api_read_multi; tBTA_GATTC_API_READ_MULTI api_read_multi;
tBTA_GATTC_API_CFG_MTU api_mtu; tBTA_GATTC_API_CFG_MTU api_mtu;
tBTA_GATTC_API_CACHE_ASSO api_associa; tBTA_GATTC_API_CACHE_ASSOC api_assoc;
tBTA_GATTC_API_GET_ADDR api_get_addr; tBTA_GATTC_API_GET_ADDR api_get_addr;
tBTA_GATTC_OP_CMPL op_cmpl; tBTA_GATTC_OP_CMPL op_cmpl;
tBTA_GATTC_INT_CONN int_conn; tBTA_GATTC_INT_CONN int_conn;
@ -464,7 +464,7 @@ extern void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, BD_ADDR remot
extern void bta_gattc_send_disconnect_cback( tBTA_GATTC_RCB *p_clreg, tGATT_DISCONN_REASON reason, extern void bta_gattc_send_disconnect_cback( tBTA_GATTC_RCB *p_clreg, tGATT_DISCONN_REASON reason,
BD_ADDR remote_bda, UINT16 conn_id); BD_ADDR remote_bda, UINT16 conn_id);
extern void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg); extern void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
extern void bta_gattc_process_api_cache_associat(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg); extern void bta_gattc_process_api_cache_assoc(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
extern void bta_gattc_process_api_cache_get_addr_list(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg); extern void bta_gattc_process_api_cache_get_addr_list(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
extern void bta_gattc_cfg_mtu(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); extern void bta_gattc_cfg_mtu(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
#if BLE_INCLUDED == TRUE #if BLE_INCLUDED == TRUE

View file

@ -739,11 +739,11 @@ void btc_gattc_call_handler(btc_msg_t *msg)
case BTC_GATTC_ACT_CACHE_REFRESH: case BTC_GATTC_ACT_CACHE_REFRESH:
BTA_GATTC_Refresh(arg->cache_refresh.remote_bda); BTA_GATTC_Refresh(arg->cache_refresh.remote_bda);
break; break;
case BTC_GATTC_ACT_CACHE_ASSOCIAT: case BTC_GATTC_ACT_CACHE_ASSOC:
BTA_GATTC_CacheAssociat(arg->cache_associat.gattc_if, BTA_GATTC_CacheAssoc(arg->cache_assoc.gattc_if,
arg->cache_associat.src_addr, arg->cache_assoc.src_addr,
arg->cache_associat.ass_addr, arg->cache_assoc.assoc_addr,
arg->cache_associat.is_associat); arg->cache_assoc.is_assoc);
break; break;
case BTC_GATTC_ATC_CACHE_GET_ADDR_LIST: case BTC_GATTC_ATC_CACHE_GET_ADDR_LIST:
BTA_GATTC_CacheGetAddrList(arg->get_addr_list.gattc_if); BTA_GATTC_CacheGetAddrList(arg->get_addr_list.gattc_if);
@ -955,10 +955,10 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
btc_gattc_cb_to_app(ESP_GATTC_QUEUE_FULL_EVT, gattc_if, &param); btc_gattc_cb_to_app(ESP_GATTC_QUEUE_FULL_EVT, gattc_if, &param);
break; break;
} }
case BTA_GATTC_ASSOCIAT_EVT: { case BTA_GATTC_ASSOC_EVT: {
gattc_if = arg->set_associa.client_if; gattc_if = arg->set_assoc.client_if;
param.set_ass_cmp.status = arg->set_associa.status; param.set_assoc_cmp.status = arg->set_assoc.status;
btc_gattc_cb_to_app(ESP_GATTC_SET_ASSOCIAT_EVT, gattc_if, &param); btc_gattc_cb_to_app(ESP_GATTC_SET_ASSOC_EVT, gattc_if, &param);
break; break;
} }
case BTA_GATTC_GET_ADDR_LIST_EVT: { case BTA_GATTC_GET_ADDR_LIST_EVT: {

View file

@ -38,7 +38,7 @@ typedef enum {
BTC_GATTC_ACT_REG_FOR_NOTIFY, BTC_GATTC_ACT_REG_FOR_NOTIFY,
BTC_GATTC_ACT_UNREG_FOR_NOTIFY, BTC_GATTC_ACT_UNREG_FOR_NOTIFY,
BTC_GATTC_ACT_CACHE_REFRESH, BTC_GATTC_ACT_CACHE_REFRESH,
BTC_GATTC_ACT_CACHE_ASSOCIAT, BTC_GATTC_ACT_CACHE_ASSOC,
BTC_GATTC_ATC_CACHE_GET_ADDR_LIST, BTC_GATTC_ATC_CACHE_GET_ADDR_LIST,
} btc_gattc_act_t; } btc_gattc_act_t;
@ -169,13 +169,13 @@ typedef union {
struct cache_refresh_arg { struct cache_refresh_arg {
esp_bd_addr_t remote_bda; esp_bd_addr_t remote_bda;
} cache_refresh; } cache_refresh;
//BTC_GATTC_ACT_CACHE_ASSOCIAT //BTC_GATTC_ACT_CACHE_ASSOC
struct cache_associat_arg { struct cache_assoc_arg {
esp_gatt_if_t gattc_if; esp_gatt_if_t gattc_if;
esp_bd_addr_t src_addr; esp_bd_addr_t src_addr;
esp_bd_addr_t ass_addr; esp_bd_addr_t assoc_addr;
bool is_associat; bool is_assoc;
} cache_associat; } cache_assoc;
//BTC_GATTC_ATC_CACHE_GET_ADDR_LIST //BTC_GATTC_ATC_CACHE_GET_ADDR_LIST
struct cache_get_addr_list_arg { struct cache_get_addr_list_arg {
esp_gatt_if_t gattc_if; esp_gatt_if_t gattc_if;

View file

@ -84,7 +84,7 @@ typedef struct {
BOOLEAN is_open; BOOLEAN is_open;
BD_ADDR addr; BD_ADDR addr;
coap_key_t hash_key; coap_key_t hash_key;
list_t *ass_addr; list_t *assoc_addr;
}cache_addr_info_t; }cache_addr_info_t;
typedef struct { typedef struct {
@ -118,11 +118,11 @@ static bool cacheOpen(BD_ADDR bda, bool to_save, UINT8 *index)
{ {
UNUSED(to_save); UNUSED(to_save);
char fname[255] = {0}; char fname[255] = {0};
UINT8 *ass_addr = NULL; UINT8 *assoc_addr = NULL;
esp_err_t status = ESP_FAIL; esp_err_t status = ESP_FAIL;
coap_key_t hash_key = {0}; coap_key_t hash_key = {0};
if (((*index = bta_gattc_co_find_addr_in_cache(bda)) != INVALID_ADDR_NUM) || if (((*index = bta_gattc_co_find_addr_in_cache(bda)) != INVALID_ADDR_NUM) ||
((ass_addr = bta_gattc_co_cache_find_src_addr(bda, index)) != NULL)) { ((assoc_addr = bta_gattc_co_cache_find_src_addr(bda, index)) != NULL)) {
if (cache_env.cache_addr[*index].is_open) { if (cache_env.cache_addr[*index].is_open) {
return TRUE; return TRUE;
} else { } else {
@ -146,7 +146,7 @@ static void cacheReset(BD_ADDR bda)
//cache_env.cache_addr //cache_env.cache_addr
if ((index = bta_gattc_co_find_addr_in_cache(bda)) != INVALID_ADDR_NUM) { if ((index = bta_gattc_co_find_addr_in_cache(bda)) != INVALID_ADDR_NUM) {
//clear the association address pending in the source address. //clear the association address pending in the source address.
bta_gattc_co_cache_clear_ass_addr(bda); bta_gattc_co_cache_clear_assoc_addr(bda);
if (cache_env.cache_addr[index].is_open) { if (cache_env.cache_addr[index].is_open) {
nvs_erase_all(cache_env.cache_addr[index].cache_fp); nvs_erase_all(cache_env.cache_addr[index].cache_fp);
nvs_close(cache_env.cache_addr[index].cache_fp); nvs_close(cache_env.cache_addr[index].cache_fp);
@ -346,7 +346,7 @@ void bta_gattc_co_cache_addr_init(void)
cache_env.cache_addr[i].addr[3], cache_env.cache_addr[i].addr[4], cache_env.cache_addr[i].addr[5]); cache_env.cache_addr[i].addr[3], cache_env.cache_addr[i].addr[4], cache_env.cache_addr[i].addr[5]);
APPL_TRACE_DEBUG("hash_key[%x] = %x%x%x%x", i, cache_env.cache_addr[i].hash_key[0], cache_env.cache_addr[i].hash_key[1], APPL_TRACE_DEBUG("hash_key[%x] = %x%x%x%x", i, cache_env.cache_addr[i].hash_key[0], cache_env.cache_addr[i].hash_key[1],
cache_env.cache_addr[i].hash_key[2], cache_env.cache_addr[i].hash_key[3]); cache_env.cache_addr[i].hash_key[2], cache_env.cache_addr[i].hash_key[3]);
bta_gattc_co_cache_new_ass_list(cache_env.cache_addr[i].addr, i); bta_gattc_co_cache_new_assoc_list(cache_env.cache_addr[i].addr, i);
} }
} else { } else {
APPL_TRACE_ERROR("%s, Line = %d, nvs flash open fail, err_code = %x", __func__, __LINE__, err_code); APPL_TRACE_ERROR("%s, Line = %d, nvs flash open fail, err_code = %x", __func__, __LINE__, err_code);
@ -471,45 +471,45 @@ void bta_gattc_co_cache_addr_save(BD_ADDR bd_addr, coap_key_t hash_key)
} }
BOOLEAN bta_gattc_co_cache_new_ass_list(BD_ADDR src_addr, UINT8 index) BOOLEAN bta_gattc_co_cache_new_assoc_list(BD_ADDR src_addr, UINT8 index)
{ {
cache_addr_info_t *addr_info = &cache_env.cache_addr[index]; cache_addr_info_t *addr_info = &cache_env.cache_addr[index];
addr_info->ass_addr = list_new(osi_free_func); addr_info->assoc_addr = list_new(osi_free_func);
return (addr_info->ass_addr != NULL ? TRUE : FALSE); return (addr_info->assoc_addr != NULL ? TRUE : FALSE);
} }
BOOLEAN bta_gattc_co_cache_append_ass_addr(BD_ADDR src_addr, BD_ADDR ass_addr) BOOLEAN bta_gattc_co_cache_append_assoc_addr(BD_ADDR src_addr, BD_ADDR assoc_addr)
{ {
UINT8 addr_index = 0; UINT8 addr_index = 0;
cache_addr_info_t *addr_info; cache_addr_info_t *addr_info;
UINT8 *p_ass_buf = osi_malloc(sizeof(BD_ADDR)); UINT8 *p_assoc_buf = osi_malloc(sizeof(BD_ADDR));
memcpy(p_ass_buf, ass_addr, sizeof(BD_ADDR)); memcpy(p_assoc_buf, assoc_addr, sizeof(BD_ADDR));
if ((addr_index = bta_gattc_co_find_addr_in_cache(src_addr)) != INVALID_ADDR_NUM) { if ((addr_index = bta_gattc_co_find_addr_in_cache(src_addr)) != INVALID_ADDR_NUM) {
addr_info = &cache_env.cache_addr[addr_index]; addr_info = &cache_env.cache_addr[addr_index];
if (addr_info->ass_addr == NULL) { if (addr_info->assoc_addr == NULL) {
addr_info->ass_addr =list_new(NULL); addr_info->assoc_addr =list_new(NULL);
} }
return list_append(addr_info->ass_addr, p_ass_buf); return list_append(addr_info->assoc_addr, p_assoc_buf);
} }
return FALSE; return FALSE;
} }
BOOLEAN bta_gattc_co_cache_remove_ass_addr(BD_ADDR src_addr, BD_ADDR ass_addr) BOOLEAN bta_gattc_co_cache_remove_assoc_addr(BD_ADDR src_addr, BD_ADDR assoc_addr)
{ {
UINT8 addr_index = 0; UINT8 addr_index = 0;
cache_addr_info_t *addr_info; cache_addr_info_t *addr_info;
if ((addr_index = bta_gattc_co_find_addr_in_cache(src_addr)) != INVALID_ADDR_NUM) { if ((addr_index = bta_gattc_co_find_addr_in_cache(src_addr)) != INVALID_ADDR_NUM) {
addr_info = &cache_env.cache_addr[addr_index]; addr_info = &cache_env.cache_addr[addr_index];
if (addr_info->ass_addr != NULL) { if (addr_info->assoc_addr != NULL) {
for (list_node_t *sn = list_begin(addr_info->ass_addr); for (list_node_t *sn = list_begin(addr_info->assoc_addr);
sn != list_end(addr_info->ass_addr); sn = list_next(sn)) { sn != list_end(addr_info->assoc_addr); sn = list_next(sn)) {
void *addr = list_node(sn); void *addr = list_node(sn);
if (!memcmp(addr, ass_addr, sizeof(BD_ADDR))) { if (!memcmp(addr, assoc_addr, sizeof(BD_ADDR))) {
return list_remove(addr_info->ass_addr, addr); return list_remove(addr_info->assoc_addr, addr);
} }
} }
//return list_remove(addr_info->ass_addr, ass_addr); //return list_remove(addr_info->assoc_addr, assoc_addr);
} else { } else {
return FALSE; return FALSE;
} }
@ -518,29 +518,29 @@ BOOLEAN bta_gattc_co_cache_remove_ass_addr(BD_ADDR src_addr, BD_ADDR ass_addr)
return FALSE; return FALSE;
} }
UINT8* bta_gattc_co_cache_find_src_addr(BD_ADDR ass_addr, UINT8 *index) UINT8* bta_gattc_co_cache_find_src_addr(BD_ADDR assoc_addr, UINT8 *index)
{ {
UINT8 num = cache_env.num_addr; UINT8 num = cache_env.num_addr;
cache_addr_info_t *addr_info = &cache_env.cache_addr[0]; cache_addr_info_t *addr_info = &cache_env.cache_addr[0];
UINT8 *addr_data; UINT8 *addr_data;
//Check the ass_addr list is NULL or not //Check the assoc_addr list is NULL or not
if (addr_info->ass_addr == NULL) { if (addr_info->assoc_addr == NULL) {
*index = INVALID_ADDR_NUM; *index = INVALID_ADDR_NUM;
return NULL; return NULL;
} }
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
for (const list_node_t *node = list_begin(addr_info->ass_addr); node != list_end(addr_info->ass_addr); for (const list_node_t *node = list_begin(addr_info->assoc_addr); node != list_end(addr_info->assoc_addr);
node = list_next(node)) { node = list_next(node)) {
addr_data = (UINT8 *)list_node(node); addr_data = (UINT8 *)list_node(node);
if (!memcmp(addr_data, ass_addr, sizeof(BD_ADDR))) { if (!memcmp(addr_data, assoc_addr, sizeof(BD_ADDR))) {
*index = i; *index = i;
return (UINT8 *)addr_info->addr; return (UINT8 *)addr_info->addr;
} }
} }
addr_info++; addr_info++;
if (addr_info->ass_addr == NULL) { if (addr_info->assoc_addr == NULL) {
*index = INVALID_ADDR_NUM; *index = INVALID_ADDR_NUM;
return NULL; return NULL;
} }
@ -550,14 +550,14 @@ UINT8* bta_gattc_co_cache_find_src_addr(BD_ADDR ass_addr, UINT8 *index)
return NULL; return NULL;
} }
BOOLEAN bta_gattc_co_cache_clear_ass_addr(BD_ADDR src_addr) BOOLEAN bta_gattc_co_cache_clear_assoc_addr(BD_ADDR src_addr)
{ {
UINT8 addr_index = 0; UINT8 addr_index = 0;
cache_addr_info_t *addr_info; cache_addr_info_t *addr_info;
if ((addr_index = bta_gattc_co_find_addr_in_cache(src_addr)) != INVALID_ADDR_NUM) { if ((addr_index = bta_gattc_co_find_addr_in_cache(src_addr)) != INVALID_ADDR_NUM) {
addr_info = &cache_env.cache_addr[addr_index]; addr_info = &cache_env.cache_addr[addr_index];
if (addr_info->ass_addr != NULL) { if (addr_info->assoc_addr != NULL) {
list_clear(addr_info->ass_addr); list_clear(addr_info->assoc_addr);
} else { } else {
return FALSE; return FALSE;
} }