Network helper functions

group group_nwhelper_func

This is a collection of network helper functions which would be used by various Cypress Middleware libraries.

Functions

void cy_nw_ip_initialize_status_change_callback(cy_nw_ip_status_change_callback_t *info, cy_nw_ip_status_change_callback_func_t *cbf, void *arg)

Initialize status change callback.

Initialize cy_nw_ip_status_change_callback_t instead of directly manipulating the callback struct.

Return

none

Parameters
  • [inout] info: : Pointer to network IP status change callback information structure which would be filled upon return

  • [in] cbf: : Pointer to callback function to be invoked during network status change

  • [in] arg: : User data object to be sent sent in the callback function

bool cy_nw_ip_get_ipv4_address(cy_nw_ip_interface_t iface, cy_nw_ip_address_t *addr)

Retrieves the IPv4 address for an interface.

Retrieves the IPv4 address for an interface (AP or STA) if it exists.

Return

true : if IP address is present

Return

false : otherwise

Parameters
  • [in] iface: : Pointer to network interface object

  • [out] addr: : Pointer to the IP information sturcture in which the results to be stored

int cy_nw_str_to_ipv4(const char *ip_str, cy_nw_ip_address_t *address)

Convert IPv4 string to an IP address structure.

Return

0 : if successful

Return

-1 : if failed

Parameters
  • [in] ip_str: : IPv4 address string.

  • [out] address: : Pointer to the IP info structure in which the IPv4 address to be stored

void cy_nw_ip_register_status_change_callback(cy_nw_ip_interface_t iface, cy_nw_ip_status_change_callback_t *info)

Registers for callback function to be invoked during IP status change.

Return

none

Parameters
  • [in] iface: : Pointer to network interface object

  • [in] info: : Pointer to the status change information structure

void cy_nw_ip_unregister_status_change_callback(cy_nw_ip_interface_t iface, cy_nw_ip_status_change_callback_t *info)

Un-registers IP status change callback.

Return

none

Parameters
  • [in] iface: : Pointer to network interface object

  • [in] info: : Pointer to the status change information structure

int cy_nw_host_arp_cache_clear(cy_nw_ip_interface_t iface)

Clears the ARP cache for the interface NOTE: in LwIP, we need the netif (NetworkInterface) to do things, we can find using wifi interface.

Return

0 : success 1 : fail

Parameters
  • [in] iface: : Pointer to network interface object

int cy_nw_host_arp_cache_get_list(cy_nw_ip_interface_t iface, cy_nw_arp_cache_entry_t *list, uint32_t count, uint32_t *filled)

Gets the ARP cache list for the interface.

Return

0 : success 1 : fail

Parameters
  • [in] iface: : Pointer to network interface object

  • [inout] list: : Pointer to cy_nw_arp_cache_entry_t array

  • [in] count: : Number of entries in the array passed in list

  • [inout] filled: : Pointer to get the number of entries filled in the array pointed by ‘list’

int cy_nw_host_send_arp_request(cy_nw_ip_interface_t iface, const char *ip_string)

Send ARP request NOTE: in LwIP, we need the netif (NetworkInterface) to do things, we can find using wifi interface.

Return

0 : success 1 : failed to send ARP request

Parameters
  • [in] iface: : Pointer to network interface object

  • [in] ip_string: : Pointer to the IPv4 address string (Ex: “192.168.1.1”) to which the ARP request to be sent

uint32_t cy_nw_get_time(void)

GET time in milliseconds.

Return

time in milliseconds