1.2.8 Network Sockets and IP
This topic provides information on how to use the built in TCP/IP stack of the WINC devices.
When operating in Socket mode the WINC devices run a small TCP/IP stack to offload the work from the host MCU. This stack is and IPv4 based stack support TCP and UDP sockets with limited DHCP, DNS and NTP support.
The WINC Driver provides interface functions to query and control the stack as well as a Berkeley-like socket interface using functions more familiar to developers such as socket, connect, send and recv.
In addition to stack specified interface function this module also provides some functions for functionality which is only available when the WINC device is operating in Socket mode such as OTA.
ICMP Echo Request
For link check the stack provides a simple ICMP Echo Request client. Using the function WDRV_WINC_ICMPEchoRequest the application can send an ICMP ‘Ping’ packet to a destination IP address. A callback can be provided which will be notified of any response or error.
Dynamic IP Address Allocation
When operating as a Wi-Fi station device the WINC will perform a DHCP Request once connected. The application can use the function WDRV_WINC_IPUseDHCPSet to enable dynamic address requests and provide a callback function to receive DHCP events. Although the default mode of operation is to have DHCP enabled this function should still be called to register the callback, if required.
To determine if the WINC is currently using DHCP to manage its IP address the application can call the function WDRV_WINC_IPUseDHCPGet. Enabling dynamic address behavior must be done before connecting to a BSS.
Static IP Address Allocation
The application may set the IP address of the WINC device when operating as a Wi-Fi station. Calling the function WDRV_WINC_IPAddressSet configures the IP address and netmask to be used by the WINC device. To determine if the WINC is currently using a static IP address the application can call the function WDRV_WINC_IPAddressGet.
In addition to the IP address and netmask the application should also set the DNS server address using the function WDRV_WINC_IPDNSServerAddressSet and the default gateway using the function WDRV_WINC_IPDefaultGatewaySet. Enabling static address behavior must be done before connecting to a BSS.
Link Check
The function WDRV_WINC_IPLinkActive can be used to determine if the IP stack is operational. For dynamic IP address allocation this is true only once and IP address has been received from the DHCP server. For static IP address this is true once the station is connected to the BSS.
Soft AP DHCP Server
When operating as a Soft-AP device the WINC device can be configured to serve IP addresses from a pool. The DHCP server address of the WINC device is configurable using the function WDRV_WINC_IPDHCPServerConfigure.
Socket Event and Resolver Callbacks
Once connected and socket event which occurs is reported back to the application via the Socket Event Callback, this can be registered with the WINC driver using the function WDRV_WINC_SocketRegisterEventCallback. Any DNS request made by the WINC device will result in a response which will be provided to the application via the Resolver Callback which can be registered with the WINC drier using the function WDRV_WINC_SocketRegisterResolverCallback.
OTA
The built-in OTA operation of the WINC device can request an OTA image from a HTTP URL. To request an OTA attempt the application can use the function WDRV_WINC_OTAUpdateFromURL, a callback can be provided to receive updates on the progress of the update. If the application wishes to abort the update operation it can do so by calling the function WDRV_WINC_OTAUpdateAbort.
Once received and validated the new OTA image can be activated by the function WDRV_WINC_SwitchActiveFirmwareImage.