(1)提示音改成数组的方式,格式wav(2)修复使用数组播放时候有bug(3)增加相关提示音数组(4)拜拜时修改添加发送close,在close中stop rtc(5)唤醒词时判断wifi状态,没有连接就提示,有连接才允许打断或者重连(5)连接发送hello,start,iot的注释等级修改成I

This commit is contained in:
dianke3yu 2025-05-27 18:00:54 +08:00
parent 8e28595128
commit 99ee61b8c9
9 changed files with 7063 additions and 342 deletions

View File

@ -1434,6 +1434,7 @@ void websocket_client_task(beken_thread_arg_t *thread_param)
ws_disconnect(client);//zhanyu ws_disconnect(client);//zhanyu
bk_websocket_client_dispatch_event(client, WEBSOCKET_EVENT_CLOSED, NULL, 0, -1);
// int ret = ws_poll_connection_closed(&(client->sockfd), 1000); // int ret = ws_poll_connection_closed(&(client->sockfd), 1000);
// if (ret == 0) { // if (ret == 0) {
// // still waiting // // still waiting

View File

@ -3977,9 +3977,11 @@ static bk_err_t aud_tras_drv_prompt_tone_play_open(url_info_t *prompt_tone)
#else //array #else //array
#if CONFIG_PROMPT_TONE_CODEC_MP3 #if CONFIG_PROMPT_TONE_CODEC_MP3
//TODO //TODO
prompt_tone_play_cfg_t config = DEFAULT_ARRAY_MP3_PROMPT_TONE_PLAY_CONFIG();//zhanyu
#endif #endif
#if CONFIG_PROMPT_TONE_CODEC_WAV #if CONFIG_PROMPT_TONE_CODEC_WAV
//TODO //TODO
prompt_tone_play_cfg_t config = DEFAULT_ARRAY_WAV_PROMPT_TONE_PLAY_CONFIG();//zhanyu
#endif #endif
#if CONFIG_PROMPT_TONE_CODEC_PCM #if CONFIG_PROMPT_TONE_CODEC_PCM
prompt_tone_play_cfg_t config = DEFAULT_ARRAY_PCM_PROMPT_TONE_PLAY_CONFIG(); prompt_tone_play_cfg_t config = DEFAULT_ARRAY_PCM_PROMPT_TONE_PLAY_CONFIG();

File diff suppressed because it is too large Load Diff

View File

@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef __PROMPT_TONE_PLAY_H__ #ifndef __PROMPT_TONE_PLAY_H__
#define __PROMPT_TONE_PLAY_H__ #define __PROMPT_TONE_PLAY_H__
#ifdef __cplusplus #ifdef __cplusplus
@ -62,13 +62,52 @@ struct prompt_tone_play
typedef struct prompt_tone_play *prompt_tone_play_handle_t; typedef struct prompt_tone_play *prompt_tone_play_handle_t;
#define DEFAULT_ARRAY_MP3_PROMPT_TONE_PLAY_CONFIG() { \
.source_type = AUDIO_SOURCE_ARRAY, \
.source_cfg = { \
.url = NULL, \
.frame_size = DEFAULT_FRAME_SIZE, \
.data_handle = NULL, \
.notify = NULL, \
.usr_data = NULL, \
}, \
.codec_type = AUDIO_CODEC_MP3, \
.codec_cfg = { \
.chunk_size = DEFAULT_CHUNK_SIZE, \
.pool_size = DEFAULT_POOL_SIZE, \
.data_handle = NULL, \
.empty_cb = NULL, \
.usr_data = NULL, \
}, \
}
typedef struct prompt_tone_play *prompt_tone_play_handle_t;
#define DEFAULT_ARRAY_WAV_PROMPT_TONE_PLAY_CONFIG() { \
.source_type = AUDIO_SOURCE_ARRAY, \
.source_cfg = { \
.url = NULL, \
.frame_size = DEFAULT_FRAME_SIZE, \
.data_handle = NULL, \
.notify = NULL, \
.usr_data = NULL, \
}, \
.codec_type = AUDIO_CODEC_WAV, \
.codec_cfg = { \
.chunk_size = DEFAULT_CHUNK_SIZE, \
.pool_size = DEFAULT_POOL_SIZE, \
.data_handle = NULL, \
.empty_cb = NULL, \
.usr_data = NULL, \
}, \
}
#define DEFAULT_ARRAY_PCM_PROMPT_TONE_PLAY_CONFIG() { \ #define DEFAULT_ARRAY_PCM_PROMPT_TONE_PLAY_CONFIG() { \
.source_type = AUDIO_SOURCE_ARRAY, \ .source_type = AUDIO_SOURCE_ARRAY, \
.source_cfg = { \ .source_cfg = { \
.url = NULL, \ .url = NULL, \
.frame_size = DEFAULT_FRAME_SIZE, \ .frame_size = DEFAULT_FRAME_SIZE, \
.data_handle = NULL, \ .data_handle = NULL, \
.notify = NULL, \ .notify = NULL, \
.usr_data = NULL, \ .usr_data = NULL, \
}, \ }, \
.codec_type = AUDIO_CODEC_PCM, \ .codec_type = AUDIO_CODEC_PCM, \
@ -84,10 +123,10 @@ typedef struct prompt_tone_play *prompt_tone_play_handle_t;
#define DEFAULT_VFS_PCM_PROMPT_TONE_PLAY_CONFIG() { \ #define DEFAULT_VFS_PCM_PROMPT_TONE_PLAY_CONFIG() { \
.source_type = AUDIO_SOURCE_VFS, \ .source_type = AUDIO_SOURCE_VFS, \
.source_cfg = { \ .source_cfg = { \
.url = NULL, \ .url = NULL, \
.frame_size = DEFAULT_FRAME_SIZE, \ .frame_size = DEFAULT_FRAME_SIZE, \
.data_handle = NULL, \ .data_handle = NULL, \
.notify = NULL, \ .notify = NULL, \
.usr_data = NULL, \ .usr_data = NULL, \
}, \ }, \
.codec_type = AUDIO_CODEC_PCM, \ .codec_type = AUDIO_CODEC_PCM, \
@ -103,10 +142,10 @@ typedef struct prompt_tone_play *prompt_tone_play_handle_t;
#define DEFAULT_VFS_WAV_PROMPT_TONE_PLAY_CONFIG() { \ #define DEFAULT_VFS_WAV_PROMPT_TONE_PLAY_CONFIG() { \
.source_type = AUDIO_SOURCE_VFS, \ .source_type = AUDIO_SOURCE_VFS, \
.source_cfg = { \ .source_cfg = { \
.url = NULL, \ .url = NULL, \
.frame_size = DEFAULT_FRAME_SIZE, \ .frame_size = DEFAULT_FRAME_SIZE, \
.data_handle = NULL, \ .data_handle = NULL, \
.notify = NULL, \ .notify = NULL, \
.usr_data = NULL, \ .usr_data = NULL, \
}, \ }, \
.codec_type = AUDIO_CODEC_WAV, \ .codec_type = AUDIO_CODEC_WAV, \
@ -122,10 +161,10 @@ typedef struct prompt_tone_play *prompt_tone_play_handle_t;
#define DEFAULT_VFS_MP3_PROMPT_TONE_PLAY_CONFIG() { \ #define DEFAULT_VFS_MP3_PROMPT_TONE_PLAY_CONFIG() { \
.source_type = AUDIO_SOURCE_VFS, \ .source_type = AUDIO_SOURCE_VFS, \
.source_cfg = { \ .source_cfg = { \
.url = NULL, \ .url = NULL, \
.frame_size = DEFAULT_FRAME_SIZE, \ .frame_size = DEFAULT_FRAME_SIZE, \
.data_handle = NULL, \ .data_handle = NULL, \
.notify = NULL, \ .notify = NULL, \
.usr_data = NULL, \ .usr_data = NULL, \
}, \ }, \
.codec_type = AUDIO_CODEC_MP3, \ .codec_type = AUDIO_CODEC_MP3, \
@ -138,109 +177,109 @@ typedef struct prompt_tone_play *prompt_tone_play_handle_t;
}, \ }, \
} }
/** /**
* @brief Create prompt tone player with config * @brief Create prompt tone player with config
* *
* This API create prompt tone player handle according to config. * This API create prompt tone player handle according to config.
* This API should be called before other api. * This API should be called before other api.
* *
* @param[in] config Prompt tone play config * @param[in] config Prompt tone play config
* *
* @return * @return
* - Not NULL: success * - Not NULL: success
* - NULL: failed * - NULL: failed
*/ */
prompt_tone_play_handle_t prompt_tone_play_create( prompt_tone_play_cfg_t *config); prompt_tone_play_handle_t prompt_tone_play_create( prompt_tone_play_cfg_t *config);
/** /**
* @brief Destroy prompt tone player * @brief Destroy prompt tone player
*
* This API Destroy prompt tone player according to prompt tone player handle.
* *
* * This API Destroy prompt tone player according to prompt tone player handle.
* @param[in] handle The prompt tone player handle *
* *
* @return * @param[in] handle The prompt tone player handle
* - BK_OK: success *
* - Others: failed * @return
* - BK_OK: success
* - Others: failed
*/ */
bk_err_t prompt_tone_play_destroy(prompt_tone_play_handle_t handle); bk_err_t prompt_tone_play_destroy(prompt_tone_play_handle_t handle);
/** /**
* @brief Open prompt tone player * @brief Open prompt tone player
*
* This API open prompt tone player.
* *
* * This API open prompt tone player.
* @param[in] handle The prompt tone player handle *
* *
* @return * @param[in] handle The prompt tone player handle
* - BK_OK: success *
* - Others: failed * @return
* - BK_OK: success
* - Others: failed
*/ */
bk_err_t prompt_tone_play_open(prompt_tone_play_handle_t handle); bk_err_t prompt_tone_play_open(prompt_tone_play_handle_t handle);
/** /**
* @brief Close prompt tone player * @brief Close prompt tone player
*
* This API close prompt tone player
* *
* * This API close prompt tone player
* @param[in] handle The prompt tone player handle *
* @param[in] wait_play_finish The flag to declare whether waiting play finish *
* * @param[in] handle The prompt tone player handle
* @return * @param[in] wait_play_finish The flag to declare whether waiting play finish
* - BK_OK: success *
* - Others: failed * @return
* - BK_OK: success
* - Others: failed
*/ */
bk_err_t prompt_tone_play_close(prompt_tone_play_handle_t handle, bool wait_play_finish); bk_err_t prompt_tone_play_close(prompt_tone_play_handle_t handle, bool wait_play_finish);
/** /**
* @brief Set url information of prompt tone * @brief Set url information of prompt tone
*
* This API set url information of prompt tone
* *
* * This API set url information of prompt tone
* @param[in] handle The prompt tone player handle *
* @param[in] wait_play_finish The flag to declare whether waiting play finish *
* * @param[in] handle The prompt tone player handle
* @return * @param[in] wait_play_finish The flag to declare whether waiting play finish
* - BK_OK: success *
* - Others: failed * @return
* - BK_OK: success
* - Others: failed
*/ */
bk_err_t prompt_tone_play_set_url(prompt_tone_play_handle_t handle, url_info_t *url_info); bk_err_t prompt_tone_play_set_url(prompt_tone_play_handle_t handle, url_info_t *url_info);
/** /**
* @brief Start playing prompt tone * @brief Start playing prompt tone
*
* This API start playing prompt tone
* *
* * This API start playing prompt tone
* @param[in] handle The prompt tone player handle *
* *
* @return * @param[in] handle The prompt tone player handle
* - BK_OK: success *
* - Others: failed * @return
* - BK_OK: success
* - Others: failed
*/ */
bk_err_t prompt_tone_play_start(prompt_tone_play_handle_t handle); bk_err_t prompt_tone_play_start(prompt_tone_play_handle_t handle);
/** /**
* @brief Stop playing prompt tone * @brief Stop playing prompt tone
*
* This API stop playing prompt tone
* *
* * This API stop playing prompt tone
* @param[in] handle The prompt tone player handle *
* *
* @return * @param[in] handle The prompt tone player handle
* - BK_OK: success *
* - Others: failed * @return
* - BK_OK: success
* - Others: failed
*/ */
bk_err_t prompt_tone_play_stop(prompt_tone_play_handle_t handle); bk_err_t prompt_tone_play_stop(prompt_tone_play_handle_t handle);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* __PROMPT_TONE_PLAY_H__ */ #endif /* __PROMPT_TONE_PLAY_H__ */

View File

@ -15,17 +15,17 @@
#include <common/bk_include.h> #include <common/bk_include.h>
#include <os/os.h> #include <os/os.h>
#include <os/mem.h> #include <os/mem.h>
#include <os/str.h> #include <os/str.h>
#include "source_array.h" #include "source_array.h"
#define ARRAY_SOURCE_TAG "ary_src" #define ARRAY_SOURCE_TAG "ary_src"
#define LOGI(...) BK_LOGI(ARRAY_SOURCE_TAG, ##__VA_ARGS__) #define LOGI(...) BK_LOGI(ARRAY_SOURCE_TAG, ##__VA_ARGS__)
#define LOGW(...) BK_LOGW(ARRAY_SOURCE_TAG, ##__VA_ARGS__) #define LOGW(...) BK_LOGW(ARRAY_SOURCE_TAG, ##__VA_ARGS__)
#define LOGE(...) BK_LOGE(ARRAY_SOURCE_TAG, ##__VA_ARGS__) #define LOGE(...) BK_LOGE(ARRAY_SOURCE_TAG, ##__VA_ARGS__)
#define LOGD(...) BK_LOGD(ARRAY_SOURCE_TAG, ##__VA_ARGS__) #define LOGD(...) BK_LOGD(ARRAY_SOURCE_TAG, ##__VA_ARGS__)
#define ARRAY_SOURCE_CHECK_NULL(ptr) do {\ #define ARRAY_SOURCE_CHECK_NULL(ptr) do {\
if (ptr == NULL) {\ if (ptr == NULL) {\
@ -49,21 +49,21 @@ typedef struct
typedef struct array_source_priv_s typedef struct array_source_priv_s
{ {
uint32_t array_total_len; uint32_t array_total_len;
uint32_t array_read_offset; uint32_t array_read_offset;
uint32_t read_buff_size; /**< read pool size, unit byte */ uint32_t read_buff_size; /**< read pool size, unit byte */
uint8_t *read_buff; /**< the read pool buffer save speaker data need to play */ uint8_t *read_buff; /**< the read pool buffer save speaker data need to play */
beken_thread_t array_data_read_task_hdl; beken_thread_t array_data_read_task_hdl;
beken_queue_t array_data_read_msg_que; beken_queue_t array_data_read_msg_que;
beken_semaphore_t sem; beken_semaphore_t sem;
bool running; bool running;
audio_source_cfg_t config; audio_source_cfg_t config;
} array_source_priv_t; } array_source_priv_t;
static bk_err_t array_data_read_send_msg(beken_queue_t queue, array_data_read_op_t op, void *param) static bk_err_t array_data_read_send_msg(beken_queue_t queue, array_data_read_op_t op, void *param)
{ {
bk_err_t ret; bk_err_t ret;
@ -86,7 +86,7 @@ static bk_err_t array_data_read_send_msg(beken_queue_t queue, array_data_read_op
return BK_OK; return BK_OK;
} }
static void array_data_read_task_main(beken_thread_arg_t param_data) static void array_data_read_task_main(beken_thread_arg_t param_data)
{ {
bk_err_t ret = BK_OK; bk_err_t ret = BK_OK;
@ -107,18 +107,18 @@ static void array_data_read_task_main(beken_thread_arg_t param_data)
switch (msg.op) switch (msg.op)
{ {
case ARRAY_DATA_READ_IDLE: case ARRAY_DATA_READ_IDLE:
LOGD("%s, %d, ARRAY_DATA_READ_IDLE\n", __func__, __LINE__); LOGD("%s, %d, ARRAY_DATA_READ_IDLE\n", __func__, __LINE__);
array_source_priv->running = false; array_source_priv->running = false;
wait_time = BEKEN_WAIT_FOREVER; wait_time = BEKEN_WAIT_FOREVER;
break; break;
case ARRAY_DATA_READ_EXIT: case ARRAY_DATA_READ_EXIT:
LOGD("%s, %d, ARRAY_DATA_READ_EXIT\n", __func__, __LINE__); LOGD("%s, %d, ARRAY_DATA_READ_EXIT\n", __func__, __LINE__);
goto array_data_read_exit; goto array_data_read_exit;
break; break;
case ARRAY_DATA_READ_START: case ARRAY_DATA_READ_START:
LOGD("%s, %d, ARRAY_DATA_READ_START\n", __func__, __LINE__); LOGD("%s, %d, ARRAY_DATA_READ_START\n", __func__, __LINE__);
array_source_priv->running = true; array_source_priv->running = true;
wait_time = 0; wait_time = 0;
break; break;
@ -131,26 +131,26 @@ static void array_data_read_task_main(beken_thread_arg_t param_data)
/* read speaker data and write to dac fifo */ /* read speaker data and write to dac fifo */
if (array_source_priv->running) if (array_source_priv->running)
{ {
LOGD("%s, %d, array_read_offset: %d, array_total_len: %d\n", __func__, __LINE__, array_source_priv->array_read_offset, array_source_priv->array_total_len); LOGD("%s, %d, array_read_offset: %d, array_total_len: %d\n", __func__, __LINE__, array_source_priv->array_read_offset, array_source_priv->array_total_len);
/* read speaker data from ringbuffer, and write to dac fifo */ /* read speaker data from ringbuffer, and write to dac fifo */
if (array_source_priv->array_read_offset < array_source_priv->array_total_len) if (array_source_priv->array_read_offset < array_source_priv->array_total_len)
{ {
uint32_t r_len = 0; uint32_t r_len = 0;
if ((array_source_priv->array_total_len - array_source_priv->array_read_offset) >= array_source_priv->config.frame_size) if ((array_source_priv->array_total_len - array_source_priv->array_read_offset) >= array_source_priv->config.frame_size)
{ {
r_len = array_source_priv->config.frame_size; r_len = array_source_priv->config.frame_size;
} }
else else
{ {
r_len = array_source_priv->array_total_len - array_source_priv->array_read_offset; r_len = array_source_priv->array_total_len - array_source_priv->array_read_offset;
} }
os_memcpy(array_source_priv->read_buff, &array_source_priv->config.url[array_source_priv->array_read_offset], r_len); os_memcpy(array_source_priv->read_buff, &array_source_priv->config.url[array_source_priv->array_read_offset], r_len);
LOGD("%s, %d, data_handle: %p\n", __func__, __LINE__, array_source_priv->config.data_handle); LOGD("%s, %d, data_handle: %p\n", __func__, __LINE__, array_source_priv->config.data_handle);
if (array_source_priv->config.data_handle) if (array_source_priv->config.data_handle)
{ {
array_source_priv->config.data_handle((char *)array_source_priv->read_buff, r_len, array_source_priv->config.usr_data); array_source_priv->config.data_handle((char *)array_source_priv->read_buff, r_len, array_source_priv->config.usr_data);
} }
array_source_priv->array_read_offset += r_len; array_source_priv->array_read_offset += r_len;
} }
else else
{ {
@ -159,9 +159,9 @@ static void array_data_read_task_main(beken_thread_arg_t param_data)
{ {
array_source_priv->config.notify(array_source_priv, AUDIO_SOURCE_EVENT_EMPTY); array_source_priv->config.notify(array_source_priv, AUDIO_SOURCE_EVENT_EMPTY);
} }
/* set array read task to idle state */ /* set array read task to idle state */
array_data_read_send_msg(array_source_priv->array_data_read_msg_que, ARRAY_DATA_READ_IDLE, NULL); array_data_read_send_msg(array_source_priv->array_data_read_msg_que, ARRAY_DATA_READ_IDLE, NULL);
} }
} }
} }
@ -227,7 +227,7 @@ static bk_err_t array_data_read_task_init(array_source_priv_t *array_source_priv
} }
rtos_get_semaphore(&array_source_priv->sem, BEKEN_NEVER_TIMEOUT); rtos_get_semaphore(&array_source_priv->sem, BEKEN_NEVER_TIMEOUT);
array_data_read_send_msg(array_source_priv->array_data_read_msg_que, ARRAY_DATA_READ_START, NULL); array_data_read_send_msg(array_source_priv->array_data_read_msg_que, ARRAY_DATA_READ_START, NULL);
LOGI("init array data read task complete\n"); LOGI("init array data read task complete\n");
@ -280,7 +280,7 @@ bk_err_t array_data_read_task_deinit(array_source_priv_t *array_source_priv)
if (array_source_priv->read_buff) if (array_source_priv->read_buff)
{ {
psram_free(array_source_priv->read_buff); psram_free(array_source_priv->read_buff);
array_source_priv->read_buff = NULL; array_source_priv->read_buff = NULL;
} }
LOGD("deinit array data read complete\n"); LOGD("deinit array data read complete\n");
@ -288,218 +288,222 @@ bk_err_t array_data_read_task_deinit(array_source_priv_t *array_source_priv)
return BK_OK; return BK_OK;
} }
static int array_source_open(audio_source_t *source, audio_source_cfg_t *config) static int array_source_open(audio_source_t *source, audio_source_cfg_t *config)
{ {
array_source_priv_t *temp_array_source = NULL; array_source_priv_t *temp_array_source = NULL;
bk_err_t ret = BK_OK; bk_err_t ret = BK_OK;
if (!source || !config) if (!source || !config)
{ {
LOGE("%s, %d, params error, source: %p, config: %p\n", __func__, __LINE__, source, config); LOGE("%s, %d, params error, source: %p, config: %p\n", __func__, __LINE__, source, config);
return BK_FAIL; return BK_FAIL;
} }
LOGI("%s\n", __func__); LOGI("%s\n", __func__);
array_source_priv_t *array_source = (array_source_priv_t *)source->source_ctx; array_source_priv_t *array_source = (array_source_priv_t *)source->source_ctx;
if (array_source != NULL) if (array_source != NULL)
{ {
LOGE("%s, %d, array_source: %p already open\n", __func__, __LINE__, array_source); LOGE("%s, %d, array_source: %p already open\n", __func__, __LINE__, array_source);
goto fail; goto fail;
} }
temp_array_source = psram_malloc(sizeof(array_source_priv_t)); temp_array_source = psram_malloc(sizeof(array_source_priv_t));
if (!temp_array_source) if (!temp_array_source)
{ {
LOGE("%s, %d, os_malloc temp_array_source: %d fail\n", __func__, __LINE__, sizeof(array_source_priv_t)); LOGE("%s, %d, os_malloc temp_array_source: %d fail\n", __func__, __LINE__, sizeof(array_source_priv_t));
goto fail; goto fail;
} }
os_memset(temp_array_source, 0, sizeof(array_source_priv_t)); os_memset(temp_array_source, 0, sizeof(array_source_priv_t));
source->source_ctx = temp_array_source; source->source_ctx = temp_array_source;
temp_array_source->read_buff_size = config->frame_size; temp_array_source->read_buff_size = config->frame_size;
temp_array_source->array_total_len = config->total_size; temp_array_source->array_total_len = config->total_size;
os_memcpy(&temp_array_source->config, config, sizeof(audio_source_cfg_t)); os_memcpy(&temp_array_source->config, config, sizeof(audio_source_cfg_t));
ret = array_data_read_task_init(source->source_ctx); ret = array_data_read_task_init(source->source_ctx);
if (ret != BK_OK) if (ret != BK_OK)
{ {
LOGE("%s, %d, array_data_read_task_init fail\n", __func__, __LINE__); LOGE("%s, %d, array_data_read_task_init fail\n", __func__, __LINE__);
goto fail; goto fail;
} }
LOGD("array source open complete\n"); LOGD("array source open complete\n");
return BK_OK; return BK_OK;
fail: fail:
if (source->source_ctx) if (source->source_ctx)
{ {
psram_free(source->source_ctx); psram_free(source->source_ctx);
source->source_ctx = NULL; source->source_ctx = NULL;
} }
return BK_FAIL; return BK_FAIL;
} }
static int array_source_close(audio_source_t *source) static int array_source_close(audio_source_t *source)
{ {
ARRAY_SOURCE_CHECK_NULL(source); ARRAY_SOURCE_CHECK_NULL(source);
array_source_priv_t *array_source = (array_source_priv_t *)source->source_ctx; array_source_priv_t *array_source = (array_source_priv_t *)source->source_ctx;
if (!array_source) if (!array_source)
{ {
LOGD("%s, %d, array source already close\n", __func__, __LINE__); LOGD("%s, %d, array source already close\n", __func__, __LINE__);
return BK_OK; return BK_OK;
} }
LOGI("%s \n", __func__); LOGI("%s \n", __func__);
array_data_read_task_deinit(array_source); array_data_read_task_deinit(array_source);
if (array_source) if (array_source)
{ {
psram_free(array_source); psram_free(array_source);
source->source_ctx = NULL; source->source_ctx = NULL;
} }
LOGD("array source close complete\n"); LOGD("array source close complete\n");
return BK_OK; return BK_OK;
} }
static int array_source_seek(audio_source_t *source, int offset, uint32_t whence) static int array_source_seek(audio_source_t *source, int offset, uint32_t whence)
{ {
ARRAY_SOURCE_CHECK_NULL(source); ARRAY_SOURCE_CHECK_NULL(source);
array_source_priv_t *array_source = (array_source_priv_t *)source->source_ctx; array_source_priv_t *array_source = (array_source_priv_t *)source->source_ctx;
ARRAY_SOURCE_CHECK_NULL(array_source); ARRAY_SOURCE_CHECK_NULL(array_source);
LOGI("%s \n", __func__); LOGI("%s \n", __func__);
if (whence == 0) //SEEK_SET if (whence == 0) //SEEK_SET
{ {
if (offset < 0) if (offset < 0)
{ {
LOGE("%s, %d, offset: %d is invalid when whence is SEEK_SET\n", __func__, __LINE__, offset); LOGE("%s, %d, offset: %d is invalid when whence is SEEK_SET\n", __func__, __LINE__, offset);
return BK_FAIL; return BK_FAIL;
} }
if (offset > array_source->array_total_len) if (offset > array_source->array_total_len)
{ {
LOGE("%s, %d, offset: %d out of range (0 ~ %d) when whence is SEEK_SET\n", __func__, __LINE__, offset, array_source->array_total_len); LOGE("%s, %d, offset: %d out of range (0 ~ %d) when whence is SEEK_SET\n", __func__, __LINE__, offset, array_source->array_total_len);
return BK_FAIL; return BK_FAIL;
} }
array_source->array_read_offset = offset; array_source->array_read_offset = offset;
} }
else if (whence == 1) //SEEK_CUR else if (whence == 1) //SEEK_CUR
{ {
if ((array_source->array_read_offset + offset) > array_source->array_total_len) if ((array_source->array_read_offset + offset) > array_source->array_total_len)
{ {
LOGE("%s, %d, offset: %d out of range (0 ~ -%d) when whence is SEEK_CUR\n", __func__, __LINE__, offset, array_source->array_total_len - array_source->array_read_offset); LOGE("%s, %d, offset: %d out of range (0 ~ -%d) when whence is SEEK_CUR\n", __func__, __LINE__, offset, array_source->array_total_len - array_source->array_read_offset);
return BK_FAIL; return BK_FAIL;
} }
array_source->array_read_offset = array_source->array_total_len + offset; array_source->array_read_offset = array_source->array_total_len + offset;
} }
else if (whence == 2) //SEEK_END else if (whence == 2) //SEEK_END
{ {
if (offset > 0) if (offset > 0)
{ {
LOGE("%s, %d, offset: %d is invalid when whence is SEEK_END\n", __func__, __LINE__, offset); LOGE("%s, %d, offset: %d is invalid when whence is SEEK_END\n", __func__, __LINE__, offset);
return BK_FAIL; return BK_FAIL;
} }
if ((offset + array_source->array_total_len) < 0) if ((offset + array_source->array_total_len) < 0)
{ {
LOGE("%s, %d, offset: %d out of range (0 ~ -%d) when whence is SEEK_END\n", __func__, __LINE__, offset, array_source->array_total_len); LOGE("%s, %d, offset: %d out of range (0 ~ -%d) when whence is SEEK_END\n", __func__, __LINE__, offset, array_source->array_total_len);
return BK_FAIL; return BK_FAIL;
} }
array_source->array_read_offset = array_source->array_total_len + offset; array_source->array_read_offset = array_source->array_total_len + offset;
} }
else else
{ {
LOGE("%s, %d, whence: %d is invalid\n", __func__, __LINE__, whence); LOGE("%s, %d, whence: %d is invalid\n", __func__, __LINE__, whence);
return BK_FAIL; return BK_FAIL;
} }
return BK_OK; return BK_OK;
} }
static int array_source_set_url(audio_source_t *source, url_info_t *url_info) static int array_source_set_url(audio_source_t *source, url_info_t *url_info)
{ {
ARRAY_SOURCE_CHECK_NULL(url_info); ARRAY_SOURCE_CHECK_NULL(url_info);
ARRAY_SOURCE_CHECK_NULL(url_info->url); ARRAY_SOURCE_CHECK_NULL(url_info->url);
ARRAY_SOURCE_CHECK_NULL(source); ARRAY_SOURCE_CHECK_NULL(source);
array_source_priv_t *array_source = (array_source_priv_t *)source->source_ctx; array_source_priv_t *array_source = (array_source_priv_t *)source->source_ctx;
ARRAY_SOURCE_CHECK_NULL(array_source); ARRAY_SOURCE_CHECK_NULL(array_source);
LOGI("%s, url: %s \n", __func__, url_info->url); LOGI("%s, url: %s \n", __func__, url_info->url);
/* update new url */ /* update new url */
array_source->config.url = url_info->url; array_source->config.url = url_info->url;
array_source->config.total_size = url_info->total_len; array_source->config.total_size = url_info->total_len;
return BK_OK;
array_source->array_total_len = url_info->total_len;//fix bug
array_source->array_read_offset = 0;
return BK_OK;
} }
static int array_source_ctrl(audio_source_t *source, audio_source_ctrl_op_t op, void *params) static int array_source_ctrl(audio_source_t *source, audio_source_ctrl_op_t op, void *params)
{ {
ARRAY_SOURCE_CHECK_NULL(source); ARRAY_SOURCE_CHECK_NULL(source);
array_source_priv_t *array_source = (array_source_priv_t *)source->source_ctx; array_source_priv_t *array_source = (array_source_priv_t *)source->source_ctx;
ARRAY_SOURCE_CHECK_NULL(array_source); ARRAY_SOURCE_CHECK_NULL(array_source);
bk_err_t ret = BK_FAIL; bk_err_t ret = BK_FAIL;
LOGD("%s, op: %d \n", __func__, op); LOGD("%s, op: %d \n", __func__, op);
switch (op) switch (op)
{ {
case AUDIO_SOURCE_CTRL_START: case AUDIO_SOURCE_CTRL_START:
ret = array_data_read_send_msg(array_source->array_data_read_msg_que, ARRAY_DATA_READ_IDLE, NULL); ret = array_data_read_send_msg(array_source->array_data_read_msg_que, ARRAY_DATA_READ_IDLE, NULL);
if (ret != BK_OK) if (ret != BK_OK)
{ {
LOGE("%s, %d, send msg to stop read old array data fail\n", __func__, __LINE__); LOGE("%s, %d, send msg to stop read old array data fail\n", __func__, __LINE__);
break; break;
} }
ret = array_data_read_send_msg(array_source->array_data_read_msg_que, ARRAY_DATA_READ_START, NULL); ret = array_data_read_send_msg(array_source->array_data_read_msg_que, ARRAY_DATA_READ_START, NULL);
if (ret != BK_OK) if (ret != BK_OK)
{ {
LOGE("%s, %d, send msg to start read new array data fail\n", __func__, __LINE__); LOGE("%s, %d, send msg to start read new array data fail\n", __func__, __LINE__);
} }
break; break;
case AUDIO_SOURCE_CTRL_STOP: case AUDIO_SOURCE_CTRL_STOP:
ret = array_data_read_send_msg(array_source->array_data_read_msg_que, ARRAY_DATA_READ_IDLE, NULL); ret = array_data_read_send_msg(array_source->array_data_read_msg_que, ARRAY_DATA_READ_IDLE, NULL);
if (ret != BK_OK) if (ret != BK_OK)
{ {
LOGE("%s, %d, send msg to stop read old array data fail\n", __func__, __LINE__); LOGE("%s, %d, send msg to stop read old array data fail\n", __func__, __LINE__);
break; break;
} }
break; break;
default: default:
ret = BK_FAIL; ret = BK_FAIL;
break; break;
} }
return ret; return ret;
} }
audio_source_ops_t array_source_ops = audio_source_ops_t array_source_ops =
{ {
.audio_source_open = array_source_open, .audio_source_open = array_source_open,
.audio_source_seek = array_source_seek, .audio_source_seek = array_source_seek,
.audio_source_close = array_source_close, .audio_source_close = array_source_close,
.audio_source_set_url = array_source_set_url, .audio_source_set_url = array_source_set_url,
.audio_source_ctrl = array_source_ctrl, .audio_source_ctrl = array_source_ctrl,
}; };
audio_source_ops_t *get_array_source_ops(void) audio_source_ops_t *get_array_source_ops(void)
{ {
return &array_source_ops; return &array_source_ops;
} }

View File

@ -42,7 +42,8 @@ CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE=y
CONFIG_AI_ASR_MODE_CPU2=y CONFIG_AI_ASR_MODE_CPU2=y
CONFIG_AEC_VERSION_V2=y CONFIG_AEC_VERSION_V2=y
CONFIG_AEC_ECHO_COLLECT_MODE_HARDWARE=y CONFIG_AEC_ECHO_COLLECT_MODE_HARDWARE=y
CONFIG_PROMPT_TONE_SOURCE_VFS=y #CONFIG_PROMPT_TONE_SOURCE_VFS=y
CONFIG_PROMPT_TONE_SOURCE_ARRAY=y
CONFIG_PROMPT_TONE_CODEC_WAV=y CONFIG_PROMPT_TONE_CODEC_WAV=y
# #

View File

@ -27,6 +27,7 @@
#include "bk_ota_private.h" #include "bk_ota_private.h"
#define TAG "app_evt" #define TAG "app_evt"
#include "spi_led.h" //zhanyu #include "spi_led.h" //zhanyu
#define LOGI(...) BK_LOGI(TAG, ##__VA_ARGS__) #define LOGI(...) BK_LOGI(TAG, ##__VA_ARGS__)
#define LOGW(...) BK_LOGW(TAG, ##__VA_ARGS__) #define LOGW(...) BK_LOGW(TAG, ##__VA_ARGS__)
#define LOGE(...) BK_LOGE(TAG, ##__VA_ARGS__) #define LOGE(...) BK_LOGE(TAG, ##__VA_ARGS__)
@ -72,17 +73,38 @@ extern bk_err_t audio_tras_init(void);
void app_event_asr_evt_callback(media_app_evt_type_t event, uint32_t param) void app_event_asr_evt_callback(media_app_evt_type_t event, uint32_t param)
{ {
LOGD("asr event callback: %x\n", event); LOGD("asr event callback: %x\n", event);
wifi_link_state_t currentWifiState;
wifi_link_status_t link_status = {0};
/*Do not do anything blocking here */ /*Do not do anything blocking here */
switch (event) switch (event)
{ {
case MEDIA_APP_EVT_ASR_WAKEUP_IND: case MEDIA_APP_EVT_ASR_WAKEUP_IND:
ws2812_led_asr_wakeup(); // ws2812_led_asr_wakeup();//zhanyu
bk_printf("MEDIA_APP_EVT_ASR_WAKEUP_IND_sent_abort_msg\n");
os_memset(&link_status, 0x0, sizeof(link_status));
bk_wifi_sta_get_link_status(&link_status);
currentWifiState = link_status.state;
bk_printf("currentWifiState = %d\n", currentWifiState);
if (currentWifiState == WIFI_LINKSTATE_STA_DISCONNECTED)
{
app_event_send_msg(APP_EVT_NETWORK_PROVISIONING_FAIL, 0);
return;
}
if (link_status.state != WIFI_LINKSTATE_STA_GOT_IP)
{
// bk_printf("WiFi在STA模式下已获取IP");
}
if (g_connected_flag) if (g_connected_flag)
{ // zhanyu { // zhanyu
bk_printf("MEDIA_APP_EVT_ASR_WAKEUP_IND_sent_abort_msg\n");
sent_abort_msg(); sent_abort_msg();
} }
else else
@ -90,7 +112,7 @@ void app_event_asr_evt_callback(media_app_evt_type_t event, uint32_t param)
bk_printf("beken_rtc_start~~~audio_tras_init\n"); bk_printf("beken_rtc_start~~~audio_tras_init\n");
beken_auto_run(); beken_auto_run();
// audio_tras_init(); // audio_tras_init();
} }
app_event_send_msg(APP_EVT_ASR_WAKEUP, 0); app_event_send_msg(APP_EVT_ASR_WAKEUP, 0);
@ -333,16 +355,16 @@ static void app_event_thread(beken_thread_arg_t data)
is_standby = 0; is_standby = 0;
indicates_state &= ~((1 << INDICATES_STANDBY) | (1 << INDICATES_AGENT_CONNECT)); indicates_state &= ~((1 << INDICATES_STANDBY) | (1 << INDICATES_AGENT_CONNECT));
s_active_tickets &= ~(1 << COUNTDOWN_TICKET_STANDBY); s_active_tickets &= ~(1 << COUNTDOWN_TICKET_STANDBY);
LOGI("APP_EVT_ASR_WAKEUP\n"); LOGE("APP_EVT_ASR_WAKEUP\n");
#if CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE #if CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE
bk_aud_intf_voc_play_prompt_tone(AUD_INTF_VOC_ASR_WAKEUP); bk_aud_intf_voc_play_prompt_tone(AUD_INTF_VOC_ASR_WAKEUP);
#endif #endif
bk_pm_module_vote_cpu_freq(PM_DEV_ID_AUDIO, PM_CPU_FRQ_480M); bk_pm_module_vote_cpu_freq(PM_DEV_ID_AUDIO, PM_CPU_FRQ_480M);
bk_wifi_sta_pm_disable(); bk_wifi_sta_pm_disable();
lvgl_app_init(); // lvgl_app_init();
if (!is_network_provisioning) if (!is_network_provisioning)
{ {
led_app_set(LED_OFF_GREEN, 0); // led_app_set(LED_OFF_GREEN, 0);
} }
break; break;
case APP_EVT_ASR_STANDBY: // byebye armino case APP_EVT_ASR_STANDBY: // byebye armino
@ -366,7 +388,7 @@ static void app_event_thread(beken_thread_arg_t data)
* If network retore event APP_EVT_AGENT_JOINED comes, it means all of the network abnormal event can be stop * If network retore event APP_EVT_AGENT_JOINED comes, it means all of the network abnormal event can be stop
*/ */
case APP_EVT_NETWORK_PROVISIONING: case APP_EVT_NETWORK_PROVISIONING:
LOGI("APP_EVT_NETWORK_PROVISIONING\n"); LOGE("APP_EVT_NETWORK_PROVISIONING\n");
is_network_provisioning = 1; is_network_provisioning = 1;
// <20><><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD> // <20><><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD>
s_active_tickets &= ~(1 << COUNTDOWN_TICKET_NETWORK_ERROR); s_active_tickets &= ~(1 << COUNTDOWN_TICKET_NETWORK_ERROR);
@ -384,14 +406,14 @@ static void app_event_thread(beken_thread_arg_t data)
warning_state &= ~(1 << WARNING_PROVIOSION_FAIL); warning_state &= ~(1 << WARNING_PROVIOSION_FAIL);
s_active_tickets &= ~(1 << COUNTDOWN_TICKET_PROVISIONING); s_active_tickets &= ~(1 << COUNTDOWN_TICKET_PROVISIONING);
// s_active_tickets |= (1 << COUNTDOWN_TICKET_STANDBY); // s_active_tickets |= (1 << COUNTDOWN_TICKET_STANDBY);
LOGI("APP_EVT_NETWORK_PROVISIONING_SUCCESS\n"); LOGE("APP_EVT_NETWORK_PROVISIONING_SUCCESS\n");
#if CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE #if CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE
bk_aud_intf_voc_play_prompt_tone(AUD_INTF_VOC_NETWORK_PROVISION_SUCCESS); bk_aud_intf_voc_play_prompt_tone(AUD_INTF_VOC_NETWORK_PROVISION_SUCCESS);
#endif #endif
break; break;
case APP_EVT_NETWORK_PROVISIONING_FAIL: case APP_EVT_NETWORK_PROVISIONING_FAIL:
LOGI("APP_EVT_NETWORK_PROVISIONING_FAIL\n"); LOGE("APP_EVT_NETWORK_PROVISIONING_FAIL\n");
// network_err = 1; // network_err = 1;
s_active_tickets &= ~(1 << COUNTDOWN_TICKET_PROVISIONING); s_active_tickets &= ~(1 << COUNTDOWN_TICKET_PROVISIONING);
s_active_tickets |= (1 << COUNTDOWN_TICKET_NETWORK_ERROR); s_active_tickets |= (1 << COUNTDOWN_TICKET_NETWORK_ERROR);
@ -425,7 +447,7 @@ static void app_event_thread(beken_thread_arg_t data)
indicates_state |= (1 << INDICATES_STANDBY); indicates_state |= (1 << INDICATES_STANDBY);
} }
} }
LOGI("APP_EVT_RECONNECT_NETWORK_SUCCESS\n"); LOGE("APP_EVT_RECONNECT_NETWORK_SUCCESS\n");
#if CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE #if CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE
bk_aud_intf_voc_play_prompt_tone(AUD_INTF_VOC_RECONNECT_NETWORK_SUCCESS); bk_aud_intf_voc_play_prompt_tone(AUD_INTF_VOC_RECONNECT_NETWORK_SUCCESS);
#endif #endif
@ -433,7 +455,7 @@ static void app_event_thread(beken_thread_arg_t data)
case APP_EVT_RECONNECT_NETWORK_FAIL: case APP_EVT_RECONNECT_NETWORK_FAIL:
s_active_tickets |= (1 << COUNTDOWN_TICKET_NETWORK_ERROR); s_active_tickets |= (1 << COUNTDOWN_TICKET_NETWORK_ERROR);
LOGI("APP_EVT_RECONNECT_NETWORK_FAIL\n"); LOGE("APP_EVT_RECONNECT_NETWORK_FAIL\n");
// network_err = 1; // network_err = 1;
warning_state |= 1 << WARNING_WIFI_FAIL; warning_state |= 1 << WARNING_WIFI_FAIL;
indicates_state &= ~(1 << INDICATES_WIFI_RECONNECT); indicates_state &= ~(1 << INDICATES_WIFI_RECONNECT);
@ -456,7 +478,7 @@ static void app_event_thread(beken_thread_arg_t data)
s_active_tickets &= ~(1 << COUNTDOWN_TICKET_NETWORK_ERROR); s_active_tickets &= ~(1 << COUNTDOWN_TICKET_NETWORK_ERROR);
indicates_state &= ~(1 << INDICATES_POWER_ON); indicates_state &= ~(1 << INDICATES_POWER_ON);
warning_state &= ~((1 << WARNING_RTC_CONNECT_LOST) | (1 << WARNING_AGENT_OFFLINE) | (1 << WARNING_WIFI_FAIL)); warning_state &= ~((1 << WARNING_RTC_CONNECT_LOST) | (1 << WARNING_AGENT_OFFLINE) | (1 << WARNING_WIFI_FAIL));
LOGI("APP_EVT_AGENT_JOINED \n"); LOGE("APP_EVT_AGENT_JOINED \n");
is_network_provisioning = 0; is_network_provisioning = 0;
indicates_state &= ~(1 << INDICATES_PROVISIONING); indicates_state &= ~(1 << INDICATES_PROVISIONING);
if (is_standby) // mie if (is_standby) // mie
@ -464,13 +486,13 @@ static void app_event_thread(beken_thread_arg_t data)
indicates_state |= (1 << INDICATES_STANDBY); indicates_state |= (1 << INDICATES_STANDBY);
} }
#if CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE #if CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE
bk_aud_intf_voc_play_prompt_tone(AUD_INTF_VOC_AGENT_JOINED); // bk_aud_intf_voc_play_prompt_tone(AUD_INTF_VOC_AGENT_JOINED); zhanyu
#endif #endif
break; break;
case APP_EVT_AGENT_OFFLINE: case APP_EVT_AGENT_OFFLINE:
// network_err = 1; // network_err = 1;
s_active_tickets |= (1 << COUNTDOWN_TICKET_NETWORK_ERROR); s_active_tickets |= (1 << COUNTDOWN_TICKET_NETWORK_ERROR);
LOGI("APP_EVT_AGENT_OFFLINE\n"); LOGE("APP_EVT_AGENT_OFFLINE\n");
indicates_state &= ~(1 << INDICATES_AGENT_CONNECT); indicates_state &= ~(1 << INDICATES_AGENT_CONNECT);
warning_state |= 1 << WARNING_AGENT_OFFLINE; warning_state |= 1 << WARNING_AGENT_OFFLINE;
#if CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE #if CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE

View File

@ -935,7 +935,7 @@ int rtc_websocket_send_text(transport web_socket, void *str, enum MsgType msgtyp
// <20><> cJSON <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> // <20><> cJSON <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
char *jsonString = cJSON_Print(startMessage); char *jsonString = cJSON_Print(startMessage);
BK_LOGE("WebSocket", "Sending: %s\r\n", jsonString); BK_LOGI("WebSocket", "Sending: %s\r\n", jsonString);
websocket_client_send_text(web_socket, jsonString, strlen(jsonString), 10*1000); websocket_client_send_text(web_socket, jsonString, strlen(jsonString), 10*1000);
// ɾ<><C9BE> cJSON <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ڴ<EFBFBD> // ɾ<><C9BE> cJSON <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ڴ<EFBFBD>
cJSON_Delete(startMessage); cJSON_Delete(startMessage);
@ -975,7 +975,7 @@ int rtc_websocket_send_text(transport web_socket, void *str, enum MsgType msgtyp
// <20><> cJSON <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> // <20><> cJSON <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
char *jsonString = cJSON_Print(helloMessage); char *jsonString = cJSON_Print(helloMessage);
BK_LOGE("WebSocket", "Sending: %s\r\n", jsonString); BK_LOGI("WebSocket", "Sending: %s\r\n", jsonString);
websocket_client_send_text(web_socket, jsonString, strlen(jsonString), 10*1000); websocket_client_send_text(web_socket, jsonString, strlen(jsonString), 10*1000);
// ɾ<><C9BE> cJSON <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ڴ<EFBFBD> // ɾ<><C9BE> cJSON <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ڴ<EFBFBD>
@ -1000,7 +1000,7 @@ int rtc_websocket_send_text(transport web_socket, void *str, enum MsgType msgtyp
cJSON_Delete(iot_desc); cJSON_Delete(iot_desc);
return -1; return -1;
} }
LOGE("iot -->(len:%d) %s\n",strlen(message),message); LOGI("iot -->(len:%d) %s\n",strlen(message),message);
int ret = websocket_client_send_text(web_socket, message, strlen(message), 10*1000); int ret = websocket_client_send_text(web_socket, message, strlen(message), 10*1000);
LOGE("send iot desc ret:%d \n",ret); LOGE("send iot desc ret:%d \n",ret);
cJSON_Delete(iot_desc); cJSON_Delete(iot_desc);

View File

@ -523,7 +523,7 @@ void rtc_websocket_msg_handle(char *json_text, unsigned int size)
LOGE("Error: Failed to parse JSON text:%s\n", json_text); LOGE("Error: Failed to parse JSON text:%s\n", json_text);
return; return;
} }
//bk_printf("rtc_websocket_msg_handle json_text : %s \n",json_text);
cJSON *type = cJSON_GetObjectItem(root, "type"); cJSON *type = cJSON_GetObjectItem(root, "type");
if (type == NULL) if (type == NULL)
{ {
@ -541,6 +541,9 @@ void rtc_websocket_msg_handle(char *json_text, unsigned int size)
int ret = 200; int ret = 200;
if (ret == 200) if (ret == 200)
{ {
if(g_connected_flag){//zhanyu
return;
}
g_connected_flag = true; g_connected_flag = true;
network_reconnect_stop_timeout_check(); network_reconnect_stop_timeout_check();
app_event_send_msg(APP_EVT_AGENT_JOINED, 0); app_event_send_msg(APP_EVT_AGENT_JOINED, 0);
@ -780,9 +783,17 @@ void rtc_websocket_event_handler(void *event_handler_arg, char *event_base, int3
} }
beken_rtc_stop();//zhanyu // beken_rtc_stop();//zhanyu
//audio_tras_deinit(); //audio_tras_deinit();
break; break;
case WEBSOCKET_EVENT_CLOSED:
bk_printf("WEBSOCKET_EVENT_CLOSED~~~~\n");
beken_rtc_stop();//zhanyu
//audio_tras_deinit();
break;
case WEBSOCKET_EVENT_DATA: case WEBSOCKET_EVENT_DATA:
LOGD("data from WebSocket server, len:%d op:%d\r\n", data->data_len, data->op_code); LOGD("data from WebSocket server, len:%d op:%d\r\n", data->data_len, data->op_code);
if (data->op_code == WS_TRANSPORT_OPCODES_BINARY) if (data->op_code == WS_TRANSPORT_OPCODES_BINARY)