struct gatts_conf_evt_param {
esp_gatt_status_t status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
+ uint16_t len; /*!< The indication or notification value length, len is valid when send notification or indication failed */
+ uint8_t *value; /*!< The indication or notification value , value is valid when send notification or indication failed */
} conf; /*!< Gatt server callback param of ESP_GATTS_CONF_EVT (confirm) */
/**
cb_data.req_data.status = status;
cb_data.req_data.conn_id = p_msg->api_indicate.hdr.layer_specific;
+ cb_data.req_data.value =(uint8_t *)osi_malloc(p_msg->api_indicate.len);
+ if (cb_data.req_data.value != NULL){
+ memset(cb_data.req_data.value, 0, p_msg->api_indicate.len);
+ cb_data.req_data.data_len = p_msg->api_indicate.len;
+ memcpy(cb_data.req_data.value, p_msg->api_indicate.value, p_msg->api_indicate.len);
+ }else{
+ cb_data.req_data.data_len = 0;
+ APPL_TRACE_ERROR("%s, malloc failed", __func__);
+ }
(*p_rcb->p_cback)(BTA_GATTS_CONF_EVT, &cb_data);
}
} else {
UINT32 trans_id;
UINT16 conn_id;
tBTA_GATTS_REQ_DATA *p_data;
+ UINT16 data_len;
+ UINT8 *value;
} tBTA_GATTS_REQ;
typedef struct {
osi_free(p_data->req_data.p_data);
}
break;
+ case BTA_GATTS_CONF_EVT:
+ if (p_data && p_data->req_data.value){
+ osi_free(p_data->req_data.value);
+ }
+ break;
default:
break;
}
param.conf.conn_id = BTC_GATT_GET_CONN_ID(p_data->req_data.conn_id);
param.conf.status = p_data->req_data.status;
+ if (p_data->req_data.status != ESP_GATT_OK && p_data->req_data.value){
+ param.conf.len = p_data->req_data.data_len;
+ param.conf.value = p_data->req_data.value;
+ }else{
+ param.conf.len = 0;
+ }
btc_gatts_cb_to_app(ESP_GATTS_CONF_EVT, gatts_if, ¶m);
break;
case BTA_GATTS_CREATE_EVT:
tGATT_VALUE indication;
BT_HDR *p_msg;
- tGATT_VALUE *p_buf;
tGATT_IF gatt_if = GATT_GET_GATT_IF(conn_id);
UINT8 tcb_idx = GATT_GET_TCB_IDX(conn_id);
tGATT_REG *p_reg = gatt_get_regcb(gatt_if);
indication.auth_req = GATT_AUTH_REQ_NONE;
if (GATT_HANDLE_IS_VALID(p_tcb->indicate_handle)) {
+ /* TODO: need to further check whether deleting pending queue here cause reducing transport performance */
+ /*
GATT_TRACE_DEBUG ("Add a pending indication");
if ((p_buf = gatt_add_pending_ind(p_tcb, &indication)) != NULL) {
cmd_status = GATT_SUCCESS;
} else {
cmd_status = GATT_NO_RESOURCES;
}
+ */
+ return GATT_BUSY;
} else {
if ( (p_msg = attp_build_sr_msg (p_tcb, GATT_HANDLE_VALUE_IND, (tGATT_SR_MSG *)&indication)) != NULL) {
break;
}
case ESP_GATTC_NOTIFY_EVT:
- ESP_LOGI(GATTC_TAG, "ESP_GATTC_NOTIFY_EVT, receive notify value:");
+ if (p_data->notify.is_notify){
+ ESP_LOGI(GATTC_TAG, "ESP_GATTC_NOTIFY_EVT, receive notify value:");
+ }else{
+ ESP_LOGI(GATTC_TAG, "ESP_GATTC_NOTIFY_EVT, receive indicate value:");
+ }
esp_log_buffer_hex(GATTC_TAG, p_data->notify.value, p_data->notify.value_len);
break;
case ESP_GATTC_WRITE_DESCR_EVT:
case ESP_GATTS_MTU_EVT:
ESP_LOGI(GATTS_TAG, "ESP_GATTS_MTU_EVT, MTU %d", param->mtu.mtu);
break;
- case ESP_GATTS_CONF_EVT:
case ESP_GATTS_UNREG_EVT:
break;
case ESP_GATTS_CREATE_EVT:
ESP_LOGI(GATTS_TAG, "ESP_GATTS_DISCONNECT_EVT");
esp_ble_gap_start_advertising(&adv_params);
break;
+ case ESP_GATTS_CONF_EVT:
+ ESP_LOGI(GATTS_TAG, "ESP_GATTS_CONF_EVT, status %d", param->conf.status);
+ if (param->conf.status != ESP_GATT_OK){
+ esp_log_buffer_hex(GATTS_TAG, param->conf.value, param->conf.len);
+ }
+ break;
case ESP_GATTS_OPEN_EVT:
case ESP_GATTS_CANCEL_OPEN_EVT:
case ESP_GATTS_CLOSE_EVT:
case ESP_GATTS_MTU_EVT:
ESP_LOGI(GATTS_TAG, "ESP_GATTS_MTU_EVT, MTU %d", param->mtu.mtu);
break;
- case ESP_GATTS_CONF_EVT:
case ESP_GATTS_UNREG_EVT:
break;
case ESP_GATTS_CREATE_EVT:
param->connect.is_connected);
gl_profile_tab[PROFILE_B_APP_ID].conn_id = param->connect.conn_id;
break;
+ case ESP_GATTS_CONF_EVT:
+ ESP_LOGI(GATTS_TAG, "ESP_GATTS_CONF_EVT status %d", param->conf.status);
+ if (param->conf.status != ESP_GATT_OK){
+ esp_log_buffer_hex(GATTS_TAG, param->conf.value, param->conf.len);
+ }
+ break;
case ESP_GATTS_DISCONNECT_EVT:
case ESP_GATTS_OPEN_EVT:
case ESP_GATTS_CANCEL_OPEN_EVT: