tkl_lwip | lwIP Network Stack
The tkl_lwip.c
file includes the initialization of the underlying Ethernet interface and the implementation of packet transmission and reception functionalities, which depends on the lwIP network stack. This file is automatically generated and maintained by the Tuya Smart OS, and developers can add their own implementation code between user-defined "BEGIN" and "END" comments. This design ensures that user custom changes are retained during the execution of the Tuya Smart OS version and verification tools, while other parts are overwritten by automatically generated updates.
Note: The interfaces in this file only need to be adapted when ENABLE_LIBLWIP
is enabled.
API Descriptionâ
tkl_ethernetif_initâ
OPERATE_RET tkl_ethernetif_init(TKL_NETIF_HANDLE netif);
Functionâ
Initializes the Ethernet interface hardware.
Parametersâ
netif
: Pointer to the network interface structure, which will be used to send packets.
Return Valueâ
err_t
: Seeerr_enum_t
inlwip/err.h
, returnsERR_OK
on success, or other error codes on failure.
tkl_ethernetif_outputâ
OPERATE_RET tkl_ethernetif_output(TKL_NETIF_HANDLE netif, TKL_PBUF_HANDLE p);
Functionâ
Sends a packet in pbuf format through the Ethernet interface.
Parametersâ
netif
: Pointer to the network interface, which will be used to send packets.p
: The packet to be sent represented in pbuf format.
Return Valueâ
err_t
: Seeerr_enum_t
inlwip/err.h
, returnsERR_OK
on success, or other error codes on failure.
tkl_ethernetif_recvâ
OPERATE_RET tkl_ethernetif_recv(TKL_NETIF_HANDLE netif, TKL_PBUF_HANDLE p);
Functionâ
Receives a packet from the Ethernet interface.
Parametersâ
netif
: Pointer to the network interface, which will be used to receive packets.p
: The pbuf structure representing the received data.
Return Valueâ
err_t
: Seeerr_enum_t
inlwip/err.h
, returnsERR_OK
on success, or other error codes on failure.