🏆 Join the TuyaOpen AI Hardware Contest! 100 days to build the future of AI devicesLearn More →
Skip to main content

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: See err_enum_t in lwip/err.h, returns ERR_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: See err_enum_t in lwip/err.h, returns ERR_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: See err_enum_t in lwip/err.h, returns ERR_OK on success, or other error codes on failure.