Port Functions

group group_lwip_whd_port_functions

Typedefs

typedef void (*cy_network_activity_event_callback_t)(bool callback_arg)

Network activity callback function prototype Callback function which can be registered/unregistered for any network activity needs to be of this prototype.

typedef void (*cy_lwip_ip_change_callback_t)(void *data)

IP change callback function prototype Callback function which can be registered to receive IP changes needs to be of this prototype.

Functions

cy_rslt_t cy_lwip_add_interface(cy_lwip_nw_interface_t *iface, ip_static_addr_t *ipaddr)

Adds a network interface to LwIP and brings it up, a network interface contains a WHD Wi-Fi Interface and role such as STA, AP.

This is the entry point in this file. This function takes network interface adds to LwIP, configures the optional static IP address and registers to IP change callback.

note

static IP address is mandatory for AP interface.

Return

CY_RESULT_SUCCESS for successful addition to LwIP or error otherwise.

Parameters
  • [in] iface: Network interface to be added.

  • [in] ipaddr: IPv4/IPv6 address information associated with the interface.

cy_rslt_t cy_lwip_remove_interface(cy_lwip_nw_interface_t *iface)

Removes a network interface from LwIP.

Return

CY_RSLT_SUCCESS if successful, failure code otherwise.

Parameters
  • [in] iface: Network interface to be removed.

struct netif *cy_lwip_get_interface(cy_lwip_nw_interface_role_t role)

Return the LwIP network interface for the given network interface role.

Return

netif structure of the WHD interface, null if the interface type passed is invalid.

Parameters
  • [in] role: Interface role.

cy_rslt_t cy_lwip_network_up(cy_lwip_nw_interface_t *iface)

This function brings up the network link layer and and starts DHCP if required.

Return

CY_RSLT_SUCCESS on successful network bring up, failure code otherwise.

Parameters
  • [in] iface: Network interface to be brought up.

cy_rslt_t cy_lwip_network_down(cy_lwip_nw_interface_t *iface)

This function brings down the network interface, brings down the network link layer and stops DHCP.

Return

CY_RSLT_SUCCESS on successful tear down of the network, failure code otherwise.

Parameters
  • [in] iface: LwIP Interface.

void cy_network_process_ethernet_data(whd_interface_t iface, whd_buffer_t buf)

This function takes packets from the radio driver and passes them into the lwIP stack.

If the stack is not initialized, or if the LwIP stack does not accept the packet, the packet is freed (dropped). This function will be registered as part of the whd_netif_funcs defined in whd.h of the Wi-Fi Host Driver.

Parameters
  • [in] iface: WiFi interface.

  • [in] buf: Packet received from the radio driver.

void cy_network_activity_register_cb(cy_network_activity_event_callback_t cb)

This function helps to register/unregister callback fn for any TX/RX packets.

Passing “NULL” as cb will deregister the activity callback

Parameters
  • [in] cb: Network activity callback function

cy_rslt_t cy_network_activity_notify(cy_network_activity_type_t activity_type)

This function notifies network activity to Low Power Assistant(LPA) module.

Return

CY_RSLT_SUCCESS if successful, failure code otherwise.

Parameters

void cy_lwip_register_ip_change_cb(cy_lwip_ip_change_callback_t cb)

This function helps to register/unregister for any IP changes from LwIP.

Passing “NULL” as callback will deregister the IP changes callback

Parameters
  • [in] cb: IP change callback function