Merge branch 'bugfix/btdm_xQueueGenericSend_assertion' into 'master'
component/bt: Fix xQueueGenericSend assertion See merge request idf/esp-idf!2130
This commit is contained in:
commit
713529e464
2 changed files with 23 additions and 17 deletions
|
@ -160,9 +160,11 @@ int btc_init(void)
|
||||||
{
|
{
|
||||||
xBtcQueue = xQueueCreate(BTC_TASK_QUEUE_LEN, sizeof(btc_msg_t));
|
xBtcQueue = xQueueCreate(BTC_TASK_QUEUE_LEN, sizeof(btc_msg_t));
|
||||||
xTaskCreatePinnedToCore(btc_task, "Btc_task", BTC_TASK_STACK_SIZE, NULL, BTC_TASK_PRIO, &xBtcTaskHandle, BTC_TASK_PINNED_TO_CORE);
|
xTaskCreatePinnedToCore(btc_task, "Btc_task", BTC_TASK_STACK_SIZE, NULL, BTC_TASK_PRIO, &xBtcTaskHandle, BTC_TASK_PINNED_TO_CORE);
|
||||||
|
if (xBtcTaskHandle == NULL || xBtcQueue == 0){
|
||||||
|
return BT_STATUS_NOMEM;
|
||||||
|
}
|
||||||
btc_gap_callback_init();
|
btc_gap_callback_init();
|
||||||
/* TODO: initial the profile_tab */
|
/* TODO: initial the profile_tab */
|
||||||
|
|
||||||
return BT_STATUS_SUCCESS;
|
return BT_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,11 +68,11 @@ int osi_alarm_delete_mux(void)
|
||||||
osi_mutex_free(&alarm_mutex);
|
osi_mutex_free(&alarm_mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void osi_alarm_init(void)
|
void osi_alarm_init(void)
|
||||||
{
|
{
|
||||||
assert(alarm_mutex != NULL);
|
assert(alarm_mutex != NULL);
|
||||||
|
|
||||||
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||||
if (alarm_state != ALARM_STATE_IDLE) {
|
if (alarm_state != ALARM_STATE_IDLE) {
|
||||||
LOG_WARN("%s, invalid state %d\n", __func__, alarm_state);
|
LOG_WARN("%s, invalid state %d\n", __func__, alarm_state);
|
||||||
|
@ -80,7 +80,7 @@ void osi_alarm_init(void)
|
||||||
}
|
}
|
||||||
memset(alarm_cbs, 0x00, sizeof(alarm_cbs));
|
memset(alarm_cbs, 0x00, sizeof(alarm_cbs));
|
||||||
alarm_state = ALARM_STATE_OPEN;
|
alarm_state = ALARM_STATE_OPEN;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
osi_mutex_unlock(&alarm_mutex);
|
osi_mutex_unlock(&alarm_mutex);
|
||||||
}
|
}
|
||||||
|
@ -88,13 +88,13 @@ end:
|
||||||
void osi_alarm_deinit(void)
|
void osi_alarm_deinit(void)
|
||||||
{
|
{
|
||||||
assert(alarm_mutex != NULL);
|
assert(alarm_mutex != NULL);
|
||||||
|
|
||||||
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||||
if (alarm_state != ALARM_STATE_OPEN) {
|
if (alarm_state != ALARM_STATE_OPEN) {
|
||||||
LOG_WARN("%s, invalid state %d\n", __func__, alarm_state);
|
LOG_WARN("%s, invalid state %d\n", __func__, alarm_state);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < ALARM_CBS_NUM; i++) {
|
for (int i = 0; i < ALARM_CBS_NUM; i++) {
|
||||||
if (alarm_cbs[i].alarm_hdl != NULL) {
|
if (alarm_cbs[i].alarm_hdl != NULL) {
|
||||||
alarm_free(&alarm_cbs[i]);
|
alarm_free(&alarm_cbs[i]);
|
||||||
|
@ -123,6 +123,10 @@ static struct alarm_t *alarm_cbs_lookfor_available(void)
|
||||||
static void alarm_cb_handler(struct alarm_t *alarm)
|
static void alarm_cb_handler(struct alarm_t *alarm)
|
||||||
{
|
{
|
||||||
LOG_DEBUG("TimerID %p\n", alarm);
|
LOG_DEBUG("TimerID %p\n", alarm);
|
||||||
|
if (alarm_state != ALARM_STATE_OPEN) {
|
||||||
|
LOG_WARN("%s, invalid state %d\n", __func__, alarm_state);
|
||||||
|
return;
|
||||||
|
}
|
||||||
btc_msg_t msg;
|
btc_msg_t msg;
|
||||||
btc_alarm_args_t arg;
|
btc_alarm_args_t arg;
|
||||||
msg.sig = BTC_SIG_API_CALL;
|
msg.sig = BTC_SIG_API_CALL;
|
||||||
|
@ -137,14 +141,14 @@ osi_alarm_t *osi_alarm_new(const char *alarm_name, osi_alarm_callback_t callback
|
||||||
assert(alarm_mutex != NULL);
|
assert(alarm_mutex != NULL);
|
||||||
|
|
||||||
struct alarm_t *timer_id = NULL;
|
struct alarm_t *timer_id = NULL;
|
||||||
|
|
||||||
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||||
if (alarm_state != ALARM_STATE_OPEN) {
|
if (alarm_state != ALARM_STATE_OPEN) {
|
||||||
LOG_ERROR("%s, invalid state %d\n", __func__, alarm_state);
|
LOG_ERROR("%s, invalid state %d\n", __func__, alarm_state);
|
||||||
timer_id = NULL;
|
timer_id = NULL;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
timer_id = alarm_cbs_lookfor_available();
|
timer_id = alarm_cbs_lookfor_available();
|
||||||
|
|
||||||
if (!timer_id) {
|
if (!timer_id) {
|
||||||
|
@ -162,7 +166,7 @@ osi_alarm_t *osi_alarm_new(const char *alarm_name, osi_alarm_callback_t callback
|
||||||
timer_id->cb = callback;
|
timer_id->cb = callback;
|
||||||
timer_id->cb_data = data;
|
timer_id->cb_data = data;
|
||||||
timer_id->deadline_us = 0;
|
timer_id->deadline_us = 0;
|
||||||
|
|
||||||
esp_err_t stat = esp_timer_create(&tca, &timer_id->alarm_hdl);
|
esp_err_t stat = esp_timer_create(&tca, &timer_id->alarm_hdl);
|
||||||
if (stat != ESP_OK) {
|
if (stat != ESP_OK) {
|
||||||
LOG_ERROR("%s failed to create timer, err 0x%x\n", __func__, stat);
|
LOG_ERROR("%s failed to create timer, err 0x%x\n", __func__, stat);
|
||||||
|
@ -181,13 +185,13 @@ static osi_alarm_err_t alarm_free(osi_alarm_t *alarm)
|
||||||
LOG_ERROR("%s null\n", __func__);
|
LOG_ERROR("%s null\n", __func__);
|
||||||
return OSI_ALARM_ERR_INVALID_ARG;
|
return OSI_ALARM_ERR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
|
esp_timer_stop(alarm->alarm_hdl);
|
||||||
esp_err_t stat = esp_timer_delete(alarm->alarm_hdl);
|
esp_err_t stat = esp_timer_delete(alarm->alarm_hdl);
|
||||||
if (stat != ESP_OK) {
|
if (stat != ESP_OK) {
|
||||||
LOG_ERROR("%s failed to delete timer, err 0x%x\n", __func__, stat);
|
LOG_ERROR("%s failed to delete timer, err 0x%x\n", __func__, stat);
|
||||||
return OSI_ALARM_ERR_FAIL;
|
return OSI_ALARM_ERR_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(alarm, 0, sizeof(osi_alarm_t));
|
memset(alarm, 0, sizeof(osi_alarm_t));
|
||||||
return OSI_ALARM_ERR_PASS;
|
return OSI_ALARM_ERR_PASS;
|
||||||
}
|
}
|
||||||
|
@ -195,7 +199,7 @@ static osi_alarm_err_t alarm_free(osi_alarm_t *alarm)
|
||||||
void osi_alarm_free(osi_alarm_t *alarm)
|
void osi_alarm_free(osi_alarm_t *alarm)
|
||||||
{
|
{
|
||||||
assert(alarm_mutex != NULL);
|
assert(alarm_mutex != NULL);
|
||||||
|
|
||||||
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||||
if (alarm_state != ALARM_STATE_OPEN) {
|
if (alarm_state != ALARM_STATE_OPEN) {
|
||||||
LOG_ERROR("%s, invalid state %d\n", __func__, alarm_state);
|
LOG_ERROR("%s, invalid state %d\n", __func__, alarm_state);
|
||||||
|
@ -211,7 +215,7 @@ end:
|
||||||
static osi_alarm_err_t alarm_set(osi_alarm_t *alarm, period_ms_t timeout, bool is_periodic)
|
static osi_alarm_err_t alarm_set(osi_alarm_t *alarm, period_ms_t timeout, bool is_periodic)
|
||||||
{
|
{
|
||||||
assert(alarm_mutex != NULL);
|
assert(alarm_mutex != NULL);
|
||||||
|
|
||||||
osi_alarm_err_t ret = OSI_ALARM_ERR_PASS;
|
osi_alarm_err_t ret = OSI_ALARM_ERR_PASS;
|
||||||
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||||
if (alarm_state != ALARM_STATE_OPEN) {
|
if (alarm_state != ALARM_STATE_OPEN) {
|
||||||
|
@ -219,7 +223,7 @@ static osi_alarm_err_t alarm_set(osi_alarm_t *alarm, period_ms_t timeout, bool i
|
||||||
ret = OSI_ALARM_ERR_INVALID_STATE;
|
ret = OSI_ALARM_ERR_INVALID_STATE;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!alarm || alarm->alarm_hdl == NULL) {
|
if (!alarm || alarm->alarm_hdl == NULL) {
|
||||||
LOG_ERROR("%s null\n", __func__);
|
LOG_ERROR("%s null\n", __func__);
|
||||||
ret = OSI_ALARM_ERR_INVALID_ARG;
|
ret = OSI_ALARM_ERR_INVALID_ARG;
|
||||||
|
@ -239,7 +243,7 @@ static osi_alarm_err_t alarm_set(osi_alarm_t *alarm, period_ms_t timeout, bool i
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
alarm->deadline_us = is_periodic ? 0 : (timeout_us + esp_timer_get_time());
|
alarm->deadline_us = is_periodic ? 0 : (timeout_us + esp_timer_get_time());
|
||||||
|
|
||||||
end:
|
end:
|
||||||
osi_mutex_unlock(&alarm_mutex);
|
osi_mutex_unlock(&alarm_mutex);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -264,7 +268,7 @@ osi_alarm_err_t osi_alarm_cancel(osi_alarm_t *alarm)
|
||||||
ret = OSI_ALARM_ERR_INVALID_STATE;
|
ret = OSI_ALARM_ERR_INVALID_STATE;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!alarm || alarm->alarm_hdl == NULL) {
|
if (!alarm || alarm->alarm_hdl == NULL) {
|
||||||
LOG_ERROR("%s null\n", __func__);
|
LOG_ERROR("%s null\n", __func__);
|
||||||
ret = OSI_ALARM_ERR_INVALID_ARG;
|
ret = OSI_ALARM_ERR_INVALID_ARG;
|
||||||
|
@ -286,7 +290,7 @@ period_ms_t osi_alarm_get_remaining_ms(const osi_alarm_t *alarm)
|
||||||
{
|
{
|
||||||
assert(alarm_mutex != NULL);
|
assert(alarm_mutex != NULL);
|
||||||
int64_t dt_us = 0;
|
int64_t dt_us = 0;
|
||||||
|
|
||||||
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||||
dt_us = alarm->deadline_us - esp_timer_get_time();
|
dt_us = alarm->deadline_us - esp_timer_get_time();
|
||||||
osi_mutex_unlock(&alarm_mutex);
|
osi_mutex_unlock(&alarm_mutex);
|
||||||
|
|
Loading…
Reference in a new issue