#include "l2c_int.h"
#include "gatt_int.h"
#include "allocator.h"
+#include "mutex.h"
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
#include "bta_hh_int.h"
#if GATTC_INCLUDED == TRUE && BLE_INCLUDED == TRUE
+static osi_mutex_t write_ccc_mutex;
+
/*****************************************************************************
** Constants
*****************************************************************************/
/* initialize control block */
memset(&bta_gattc_cb, 0, sizeof(tBTA_GATTC_CB));
p_cb->state = BTA_GATTC_STATE_ENABLED;
+ // Create a write ccc mutex when the gatt client enable
+ osi_mutex_new(&write_ccc_mutex);
} else {
APPL_TRACE_DEBUG("GATTC is arelady enabled");
}
APPL_TRACE_ERROR("not enabled or disable in pogress");
return;
}
+ // Free the write ccc mutex when the gatt client disable
+ osi_mutex_free(&write_ccc_mutex);
for (i = 0; i < BTA_GATTC_CL_MAX; i ++) {
if (p_cb->cl_rcb[i].in_use) {
else if ((transport == BT_TRANSPORT_LE) && (connected == FALSE) && (p_conn != NULL)){
p_conn->service_change_ccc_written = FALSE;
if (p_conn->ccc_timer_used == TRUE){
+ assert(write_ccc_mutex != NULL);
+ osi_mutex_lock(&write_ccc_mutex, OSI_MUTEX_MAX_TIMEOUT);
+
if (p_conn->service_change_ccc_timer.param != 0) {
osi_free((void *)p_conn->service_change_ccc_timer.param);
p_conn->service_change_ccc_timer.param = (TIMER_PARAM_TYPE)0;
}
bta_sys_stop_timer(&(p_conn->service_change_ccc_timer));
p_conn->ccc_timer_used = FALSE;
+ osi_mutex_unlock(&write_ccc_mutex);
}
}
BOOLEAN start_ccc_timer = FALSE;
UINT32 new_timeout;
+ assert(write_ccc_mutex != NULL);
+ osi_mutex_lock(&write_ccc_mutex, OSI_MUTEX_MAX_TIMEOUT);
+
tBTA_GATTC_WAIT_CCC_TIMER *p_timer_param = (tBTA_GATTC_WAIT_CCC_TIMER*) p_tle->param;
if (p_timer_param == NULL){
APPL_TRACE_ERROR("p_timer_param is NULL in %s\n", __func__);
osi_free(p_timer_param);
p_tle->param = (TIMER_PARAM_TYPE)0;
+ osi_mutex_unlock(&write_ccc_mutex);
}
#endif