Skip to content
GitLab
LSCloud-logo1
Created with Sketch.
LSCloud-logo2
Created with Sketch.
项目
项目组
代码片段
帮助
正在加载...
帮助
关于聆思
登录
切换导航
D
duomotai_ap
项目概览
项目概览
详情
动态
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
合并请求
11
合并请求
11
CI / CD
CI / CD
流水线
作业
计划
小工具
烧录包信息打印
烧录包校验
烧录包打包
生成LPK包
收起侧边栏
关闭侧边栏
动态
分支图
作业
提交
打开侧边栏
Duomotai
duomotai_ap
提交
8ac5c13d
提交
8ac5c13d
编写于
1年前
作者:
徐宪辉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
aiui: Adapt new server.
* Adapt new server staging-api.iflyos.cn Signed-off-by:
徐宪辉
<
xhxu@listenai.com
>
上级
6b680172
变更
5
展开全部
Hide whitespace changes
内联
并排
5 个文件被修改
(
363 行新增
以及
133 行删除
)
+363
-133
apps/audio_recognition_online/prj.conf
apps/audio_recognition_online/prj.conf
+1
-0
apps/audio_recognition_online/src/main.c
apps/audio_recognition_online/src/main.c
+12
-3
components/aiui_inter_conn/aiui_conn.c
components/aiui_inter_conn/aiui_conn.c
+319
-110
components/aiui_inter_conn/aiui_conn.h
components/aiui_inter_conn/aiui_conn.h
+1
-0
components/csk_websocket_client/csk_websocket_client.c
components/csk_websocket_client/csk_websocket_client.c
+30
-20
未找到文件。
apps/audio_recognition_online/prj.conf
浏览文件 @
8ac5c13d
...
...
@@ -42,6 +42,7 @@ CONFIG_LOG_BACKEND_SHOW_COLOR=y
CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP
=
y
CONFIG_LOG_BACKEND_UART
=
y
CONFIG_LOG_BACKEND_UART_OUTPUT_TEXT
=
y
# CONFIG_NET_WEBSOCKET_LOG_LEVEL_INF=y
### NEWLIBC ###
CONFIG_NEWLIB_LIBC
=
y
...
...
This diff is collapsed.
Click to expand it.
apps/audio_recognition_online/src/main.c
浏览文件 @
8ac5c13d
...
...
@@ -41,12 +41,21 @@ static K_SEM_DEFINE(m_sem_spd_pause_completed, 0, 1);
extern
void
spd_resume_complete_handle
(
void
);
extern
void
led_indication_state_set
(
uint32_t
state
);
const
int
max_send_size
=
1024
;
void
wakeup_stream_data_process
(
uint8_t
*
data
,
size_t
len
)
{
int
reminds_size
=
len
;
int
send_size
=
0
;
if
(
is_wakeup_waiting_done
)
{
aiui_audio_send_data
(
aiui_handle
,
data
,
len
);
k_yield
();
uint8_t
*
ptr
=
data
;
do
{
send_size
=
(
reminds_size
>
max_send_size
)
?
max_send_size
:
reminds_size
;
// LOG_INF("aiui_audio_send_data, send_size: %d", send_size);
aiui_audio_send_data
(
aiui_handle
,
ptr
,
send_size
);
reminds_size
-=
send_size
;
ptr
+=
send_size
;
}
while
(
reminds_size
>
0
);
}
}
...
...
This diff is collapsed.
Click to expand it.
components/aiui_inter_conn/aiui_conn.c
浏览文件 @
8ac5c13d
此差异已折叠。
点击以展开。
components/aiui_inter_conn/aiui_conn.h
浏览文件 @
8ac5c13d
...
...
@@ -7,6 +7,7 @@ typedef enum {
AIUI_ZBUS_DISCONNECTED
=
BIT
(
1
),
AIUI_ZBUS_GOT_VAD
=
BIT
(
2
),
AIUI_ZBUS_TTS_PLAY
=
BIT
(
3
),
AIUI_ZBUS_AUDIO_STARTED
=
BIT
(
4
),
AIUI_ZBUS_EVT_MAX
=
BIT
(
31
),
}
aiui_zbus_event_e
;
...
...
This diff is collapsed.
Click to expand it.
components/csk_websocket_client/csk_websocket_client.c
浏览文件 @
8ac5c13d
...
...
@@ -8,7 +8,7 @@
#include "csk_websocket_client.h"
LOG_MODULE_REGISTER
(
csk_websocket_client
,
CONFIG_NET_WEBSOCKET_LOG_LEVEL
);
LOG_MODULE_REGISTER
(
csk_websocket_client
,
LOG_LEVEL_INF
);
#define WS_CHECK_GOTO(cond, label, format, ...) ({ \
if (!(cond)) { \
...
...
@@ -32,6 +32,7 @@ LOG_MODULE_REGISTER(csk_websocket_client, CONFIG_NET_WEBSOCKET_LOG_LEVEL);
#define WS_THREAD_NAME "csk_websocket_client"
typedef
struct
{
int
ws_sockfd
;
int
http_sockfd
;
...
...
@@ -70,6 +71,8 @@ typedef struct ws_client_node {
#define DEFAULT_NET_DELAYTIME_MSEC 10
#define DEFAULT_PING_INTERVAL_SEC 10
#define DEFAULT_DNS_QURRY_CNT 5
#define WS_SEND_MSG_TIMEOUT_MS 1000
#define WS_GET_MUTEX_TIMEOUT_MS 1000
#define WS_CONNECTED_BIT BIT(0)
...
...
@@ -110,7 +113,7 @@ static int create_http_socket(const char *server, int port)
}
char
buf
[
NET_IPV4_ADDR_LEN
];
LOG_
DBG
(
"host ip address: %s"
,
net_addr_ntop
(
AF_INET
,
&
addr
.
sin_addr
,
buf
,
sizeof
(
buf
)));
LOG_
INF
(
"host ip address: %s"
,
net_addr_ntop
(
AF_INET
,
&
addr
.
sin_addr
,
buf
,
sizeof
(
buf
)));
int
sockfd
=
socket
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
...
...
@@ -140,7 +143,7 @@ fail:
static
int
connect_cb
(
int
sock
,
struct
http_request
*
req
,
void
*
user_data
)
{
ws_client_handle_t
*
ws_client
=
user_data
;
LOG_
DBG
(
"Websocket %d for %p connected.
\n
"
,
sock
,
user_data
);
LOG_
INF
(
"Websocket %d for %p connected.
\n
"
,
sock
,
user_data
);
if
(
ws_client
->
user_cb
->
connected_handler
)
{
ws_client
->
user_cb
->
connected_handler
(
ws_client
->
user_cb
->
connected_arg
);
}
...
...
@@ -169,7 +172,11 @@ static int ws_client_send_raw(int *sockfd, enum websocket_opcode opcode,
int
remind
=
data_len
;
int
ret
;
uint8_t
*
data_ptr
=
data
;
k_mutex_lock
(
ws_client
->
mutex
,
K_FOREVER
);
ret
=
k_mutex_lock
(
ws_client
->
mutex
,
K_MSEC
(
WS_GET_MUTEX_TIMEOUT_MS
));
if
(
ret
!=
0
)
{
LOG_ERR
(
"get ws_client->mutex failed, ret: %d"
,
ret
);
return
ret
;
}
do
{
int
send_size
=
remind
>
ws_client
->
max_send_size
?
ws_client
->
max_send_size
:
remind
;
bool
is_fin
=
(
send_size
==
remind
)
?
true
:
false
;
...
...
@@ -201,11 +208,11 @@ static void ping_work_handler(struct k_work *work)
{
struct
k_work_delayable
*
dwork
=
k_work_delayable_from_work
(
work
);
ws_client_handle_t
*
ws_client
=
CONTAINER_OF
(
dwork
,
ws_client_handle_t
,
ping_work
);
LOG_
DBG
(
"Send websocket ping"
);
LOG_
INF
(
"Send websocket ping"
);
k_mutex_lock
(
ws_client
->
mutex
,
K_FOREVER
);
int
send_ret
=
websocket_send_msg
(
ws_client
->
ws_sockfd
,
NULL
,
0
,
WEBSOCKET_OPCODE_PING
,
true
,
true
,
SYS_FOREVER
_MS
);
true
,
true
,
WS_SEND_MSG_TIMEOUT
_MS
);
k_mutex_unlock
(
ws_client
->
mutex
);
if
(
send_ret
!=
0
)
{
csk_ws_client_disconnect
(
ws_client
);
...
...
@@ -247,12 +254,15 @@ static void ws_thread_entry(void *arg1, void *arg2, void *arg3)
ret
,
ws_client
->
user_cb
->
message_arg
);
}
}
else
if
(
message_type
&
WEBSOCKET_FLAG_PONG
)
{
LOG_
DBG
(
"Got pong msg with payload"
);
LOG_
INF
(
"Got pong msg with payload"
);
LOG_HEXDUMP_INF
(
ws_client
->
recv_buf
,
ret
,
"pong data"
);
}
else
if
(
message_type
&
WEBSOCKET_FLAG_PING
)
{
LOG_DBG
(
"Got ping msg with payload"
);
LOG_INF
(
"Got ping msg with payload"
);
}
else
if
(
message_type
&
WEBSOCKET_FLAG_CLOSE
)
{
LOG_INF
(
"Got close msg with payload"
);
// csk_ws_client_disconnect(ws_client);
}
else
{
LOG_ERR
(
"unknown msg with payload
"
);
LOG_ERR
(
"unknown msg with payload
%d"
,
message_type
);
}
}
else
{
memcpy
(
&
temp_buf
[
temp_buf_len
],
ws_client
->
recv_buf
,
ret
);
...
...
@@ -267,7 +277,7 @@ static void ws_thread_entry(void *arg1, void *arg2, void *arg3)
}
continue
;
}
else
{
LOG_
DBG
(
"restruct frame, ret: %d
\n
"
,
ret
);
LOG_
INF
(
"restruct frame, ret: %d
\n
"
,
ret
);
if
(
!
is_fragment
)
{
//first frame
__ASSERT
(
temp_buf
==
NULL
,
"invalid pointer"
);
temp_buf
=
k_malloc
(
remaining
+
ret
);
...
...
@@ -289,14 +299,14 @@ static void ws_thread_entry(void *arg1, void *arg2, void *arg3)
csk_ws_client_disconnect
(
ws_client
);
continue
;
}
else
if
(
message_type
&
WEBSOCKET_FLAG_PONG
)
{
LOG_
DBG
(
"Got pong msg"
);
LOG_
INF
(
"Got pong msg"
);
ws_client
->
wait_for_pong_resp
=
false
;
k_work_reschedule
(
&
ws_client
->
ping_work
,
K_SECONDS
(
ws_client
->
pingpong_interval_sec
));
}
else
if
(
message_type
&
WEBSOCKET_FLAG_PING
)
{
LOG_
DBG
(
"Got ping msg"
);
LOG_
INF
(
"Got ping msg"
);
}
else
{
if
(
message_type
&
WEBSOCKET_FLAG_CLOSE
)
{
LOG_
DBG
(
"Got close msg, disconnected"
);
LOG_
INF
(
"Got close msg, disconnected"
);
}
else
{
LOG_WRN
(
"Got unknown msg, errno: %d"
,
errno
);
//Fixme: some server has other data type
...
...
@@ -307,8 +317,8 @@ static void ws_thread_entry(void *arg1, void *arg2, void *arg3)
}
}
else
{
LOG_ERR
(
"recv failed errno %d, ret: %d"
,
-
errno
,
ret
);
csk_ws_client_disconnect
(
ws_client
);
LOG_ERR
(
"recv failed errno %d"
,
-
errno
);
continue
;
}
}
...
...
@@ -377,9 +387,9 @@ static int ws_client_config_req(ws_client_handle_t *ws_client, csk_ws_client_con
}
else
{
ws_client
->
port
=
config
->
port
;
}
LOG_
DBG
(
"scheme: %s
\n
"
,
ws_client
->
scheme
);
LOG_
DBG
(
"host: %s
\n
"
,
ws_client
->
host
);
LOG_
DBG
(
"path: %s
\n
"
,
ws_client
->
path
);
LOG_
INF
(
"scheme: %s
\n
"
,
ws_client
->
scheme
);
LOG_
INF
(
"host: %s
\n
"
,
ws_client
->
host
);
LOG_
INF
(
"path: %s
\n
"
,
ws_client
->
path
);
ws_client
->
ws_req
->
host
=
ws_client
->
host
;
ws_client
->
ws_req
->
url
=
ws_client
->
path
?
ws_client
->
path
:
"/"
;
ws_client
->
ws_req
->
optional_headers
=
config
->
optional_headers
;
...
...
@@ -502,7 +512,7 @@ int csk_ws_client_connect(csk_ws_client_handle_t ws_handle)
ws_client
->
http_sockfd
=
http_sockfd
;
int
ws_sockfd
=
websocket_connect
(
ws_client
->
http_sockfd
,
ws_client
->
ws_req
,
SYS_FOREVER
_MS
,
ws_client
);
WS_SEND_MSG_TIMEOUT
_MS
,
ws_client
);
// printk("[%s %d]ws_sockfd %d\n",__FUNCTION__,__LINE__,ws_sockfd);
if
(
ws_client
->
ws_sockfd
<
0
)
{
...
...
@@ -543,7 +553,7 @@ int csk_ws_client_send_text(csk_ws_client_handle_t ws_handle, char *text_msg)
}
int
ret
=
ws_client_send_raw
(
&
ws_client
->
ws_sockfd
,
WEBSOCKET_OPCODE_DATA_TEXT
,
text_msg
,
strlen
(
text_msg
),
SYS_FOREVER
_MS
);
strlen
(
text_msg
),
WS_SEND_MSG_TIMEOUT
_MS
);
return
ret
;
}
...
...
@@ -556,7 +566,7 @@ int csk_ws_client_send_bin(csk_ws_client_handle_t ws_handle, uint8_t *data, int
}
int
ret
=
ws_client_send_raw
(
&
ws_client
->
ws_sockfd
,
WEBSOCKET_OPCODE_DATA_BINARY
,
data
,
data_len
,
SYS_FOREVER
_MS
);
data
,
data_len
,
WS_SEND_MSG_TIMEOUT
_MS
);
return
ret
;
}
...
...
This diff is collapsed.
Click to expand it.
编辑
预览
支持
Markdown
0%
请重试
or
添加新附件
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录