if (p_data != NULL) {
/* execute pending operation of link block still present */
if (l2cu_find_lcb_by_bd_addr(p_clcb->p_srcb->server_bda, BT_TRANSPORT_LE) != NULL) {
+ if (p_data->hdr.event == BTA_GATTC_API_WRITE_EVT) {
+ APPL_TRACE_ERROR("%s(), p_data = %d", __func__, p_data->api_write.p_value[0]);
+ }
// The data to be sent to the gattc state machine for processing
if(bta_gattc_sm_execute(p_clcb, p_data->hdr.event, p_data)) {
list_remove(p_clcb->p_cmd_list, (void *)p_data);
*******************************************************************************/
void bta_gattc_free_command_data(tBTA_GATTC_CLCB *p_clcb)
{
+ assert(p_clcb->p_cmd_list);
//Check the list is empty or not.
if (!list_is_empty(p_clcb->p_cmd_list)) {
/* Traversal the command queue, check the p_q_cmd is point to the queue data or not, if the p_q_cmd point to the
static const BD_ADDR dummy_bda = {0, 0, 0, 0, 0, 0};
+#define GATTC_COMMAND_QUEUE_SIZE_MAX 30
+
/*******************************************************************************
**
** Function bta_gatt_convert_uuid16_to_uuid128
return FALSE;
}
else if (p_clcb->p_cmd_list) {
- void *cmd_data = osi_malloc(sizeof(tBTA_GATTC_DATA));
- if (cmd_data) {
+ UINT16 len = 0;
+ tBTA_GATTC_DATA *cmd_data = NULL;
+ if (list_length(p_clcb->p_cmd_list) >= GATTC_COMMAND_QUEUE_SIZE_MAX) {
+ //APPL_TRACE_ERROR("%s(), the gattc command queue is full." __func__);
+ return FALSE;
+ }
+
+ if (p_data->hdr.event == BTA_GATTC_API_WRITE_EVT) {
+ len = p_data->api_write.len;
+ cmd_data = (tBTA_GATTC_DATA *)osi_malloc(sizeof(tBTA_GATTC_DATA) + len);
+
+ cmd_data->api_write.p_value = (UINT8 *)(cmd_data + 1);
+ memcpy(cmd_data, p_data, sizeof(tBTA_GATTC_DATA));
+ memcpy(cmd_data->api_write.p_value, p_data->api_write.p_value, len);
+ } else {
+ cmd_data = (tBTA_GATTC_DATA *)osi_malloc(sizeof(tBTA_GATTC_DATA));
memset(cmd_data, 0, sizeof(tBTA_GATTC_DATA));
memcpy(cmd_data, p_data, sizeof(tBTA_GATTC_DATA));
- //store the command to the command list.
- list_append(p_clcb->p_cmd_list, cmd_data);
}
+
+ //store the command to the command list.
+ list_append(p_clcb->p_cmd_list, (void *)cmd_data);
return FALSE;
}
}
case ESP_GATT_DB_DESCRIPTOR: {
esp_gattc_descr_elem_t *descr_result = (esp_gattc_descr_elem_t *)result;
- for (int i = 0; i < (num - offset); i++) {
+ for (int i = 0; i < db_size; i++) {
descr_result->handle = db[offset + i].attribute_handle;
btc128_to_bta_uuid(&bta_uuid, db[offset + i].uuid.uu);
bta_to_btc_uuid(&descr_result->uuid, &bta_uuid);