fix: add bounded lwip connect waits and link status helper
This commit is contained in:
@@ -1395,7 +1395,13 @@ lwip_netconn_do_connect(void *m)
|
||||
#if LWIP_TCPIP_CORE_LOCKING
|
||||
LWIP_ASSERT("state!", msg->conn->state == NETCONN_CONNECT);
|
||||
UNLOCK_TCPIP_CORE();
|
||||
sys_arch_sem_wait(LWIP_API_MSG_SEM(msg), 0);
|
||||
if (sys_arch_sem_wait(LWIP_API_MSG_SEM(msg), msg->conn->recv_timeout) == SYS_ARCH_TIMEOUT) {
|
||||
if (msg->conn->state == NETCONN_CONNECT) {
|
||||
msg->conn->current_msg = NULL;
|
||||
msg->conn->state = NETCONN_NONE;
|
||||
msg->err = ERR_TIMEOUT;
|
||||
}
|
||||
}
|
||||
LOCK_TCPIP_CORE();
|
||||
LWIP_ASSERT("state!", msg->conn->state != NETCONN_CONNECT);
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
|
||||
@@ -24,6 +24,7 @@ err_t ethernetif_init(struct netif *netif);
|
||||
void ethernetif_input(struct netif *netif);
|
||||
void lwip_netif_init(const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw);
|
||||
void ethernetif_check_link(void);
|
||||
uint8_t ethernetif_link_is_up(void);
|
||||
void ethernetif_poll(void);
|
||||
|
||||
void print_netif(struct netif *netif);
|
||||
|
||||
@@ -457,6 +457,8 @@ void ethernetif_diag_poll_status(void)
|
||||
*/
|
||||
static void ethernetif_update_link(uint8_t link_status)
|
||||
{
|
||||
LOCK_TCPIP_CORE();
|
||||
|
||||
if (link_status)
|
||||
{
|
||||
if (!netif_is_link_up(&ch390_netif))
|
||||
@@ -464,9 +466,7 @@ static void ethernetif_update_link(uint8_t link_status)
|
||||
netif_set_link_up(&ch390_netif);
|
||||
if ((s_garp_sent == 0u) && netif_is_up(&ch390_netif))
|
||||
{
|
||||
LOCK_TCPIP_CORE();
|
||||
etharp_gratuitous(&ch390_netif);
|
||||
UNLOCK_TCPIP_CORE();
|
||||
s_garp_sent = 1u;
|
||||
}
|
||||
}
|
||||
@@ -479,6 +479,8 @@ static void ethernetif_update_link(uint8_t link_status)
|
||||
s_garp_sent = 0u;
|
||||
}
|
||||
}
|
||||
|
||||
UNLOCK_TCPIP_CORE();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -561,3 +563,8 @@ void ethernetif_check_link(void)
|
||||
|
||||
ethernetif_update_link(link_status);
|
||||
}
|
||||
|
||||
uint8_t ethernetif_link_is_up(void)
|
||||
{
|
||||
return netif_is_link_up(&ch390_netif) ? 1u : 0u;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,12 @@ void ethernetif_diag_poll_status(void);
|
||||
*/
|
||||
void ethernetif_check_link(void);
|
||||
|
||||
/**
|
||||
* @brief Query whether physical Ethernet link is currently up
|
||||
* @return 1 if link is up, 0 otherwise
|
||||
*/
|
||||
uint8_t ethernetif_link_is_up(void);
|
||||
|
||||
/**
|
||||
* @brief Process all pending RX packets
|
||||
* @note Call this from the LwIP task when RX interrupt occurs
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +0,0 @@
|
||||
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
|
||||
Build target 'TCP2UART'
|
||||
compiling tcp_client.c...
|
||||
linking...
|
||||
Program Size: Code=84560 RO-data=2496 RW-data=432 ZI-data=47056
|
||||
FromELF: creating hex file...
|
||||
"TCP2UART\TCP2UART.axf" - 0 Error(s), 0 Warning(s).
|
||||
Build Time Elapsed: 00:00:01
|
||||
Reference in New Issue
Block a user