成功启动

This commit is contained in:
2026-07-21 22:24:47 +08:00
parent 6d404d136e
commit 75cf4c9fbf
4 changed files with 316 additions and 99 deletions

View File

@@ -106,8 +106,8 @@ int net_init(const char *ip, const char *mask, const char *gateway) {
ch395f_reset();
DBG_INFO("net_init: set_fun_para...");
/* 启用 TCP Server 多连接模式bit1=1 */
ch395f_set_fun_para(0x02);
/* 启用单连接模式:每个 Socket 独立工作,支持多监听 SocketFTP PASV 需要 */
ch395f_set_fun_para(0x00);
DBG_INFO("net_init: set_tcp_mss...");
/* 设置 TCP MSS */
@@ -353,7 +353,7 @@ void net_process_messages(void) {
break;
}
xTaskNotifyGive(msg.caller);
xTaskNotify(msg.caller, (uint32_t)msg.result, eSetValueWithOverwrite);
}
}
@@ -569,7 +569,11 @@ int net_listen(int sockfd, int backlog) {
return -1;
}
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
{
uint32_t s_notified;
xTaskNotifyWait(0, 0, &s_notified, portMAX_DELAY);
msg.result = (int)s_notified;
}
if (msg.result < 0) {
s_net_errno = NET_ERR;
@@ -666,7 +670,11 @@ int net_accept(int sockfd, struct net_sockaddr *addr, int *addrlen) {
return -1;
}
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
{
uint32_t s_notified;
xTaskNotifyWait(0, 0, &s_notified, portMAX_DELAY);
msg.result = (int)s_notified;
}
if (addrlen != NULL && addr != NULL) {
*addrlen = sizeof(struct net_sockaddr_in);
@@ -889,7 +897,11 @@ int net_send(int sockfd, const void *buf, int len, int flags) {
return -1;
}
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
{
uint32_t s_notified;
xTaskNotifyWait(0, 0, &s_notified, portMAX_DELAY);
msg.result = (int)s_notified;
}
if (msg.result < 0) {
s_net_errno = NET_ERR;
@@ -935,7 +947,11 @@ int net_recv(int sockfd, void *buf, int len, int flags) {
return -1;
}
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
{
uint32_t s_notified;
xTaskNotifyWait(0, 0, &s_notified, portMAX_DELAY);
msg.result = (int)s_notified;
}
if (msg.result < 0) {
s_net_errno = NET_ERR;
@@ -975,13 +991,18 @@ int net_close(int sockfd) {
return -1;
}
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
{
uint32_t s_notified;
xTaskNotifyWait(0, 0, &s_notified, portMAX_DELAY);
msg.result = (int)s_notified;
}
if (msg.result < 0) {
s_net_errno = NET_ERR;
}
return msg.result;
}
/*
* 函数功能:发送 UDP 数据报(含目标地址)
* 入口参数sockfd - Socket 描述符 int >= 0 && < NET_MAX_SOCKETS