wifi8 2.0.0.0
WiFi 8 Click Driver

API for configuring and manipulating WiFi 8 Click driver. More...

Topics

 WiFi 8 MikroBUS Map
 MikroBUS pin mapping of WiFi 8 Click driver.
 

Functions

void wifi8_cfg_setup (wifi8_cfg_t *cfg)
 WiFi 8 configuration object setup function.
 
err_t wifi8_init (wifi8_t *ctx, wifi8_cfg_t *cfg)
 WiFi 8 initialization function.
 
err_t wifi8_default_cfg (wifi8_t *ctx)
 WiFi 8 default configuration function.
 
err_t wifi8_generic_write (wifi8_t *ctx, uint8_t *data_in, uint8_t len)
 Generic writing function.
 
err_t wifi8_generic_read (wifi8_t *ctx, uint8_t *data_out, uint8_t len)
 Generic reading function.
 
err_t wifi8_reg_write (wifi8_t *ctx, uint32_t addr, uint32_t data_in)
 Write data to register address.
 
err_t wifi8_reg_read (wifi8_t *ctx, uint32_t addr, uint32_t *data_out)
 Read data from register address.
 
err_t wifi8_block_read (wifi8_t *ctx, uint32_t addr, uint8_t *data_buf, uint16_t buf_len)
 Read blocks of data from register address.
 
err_t wifi8_block_write (wifi8_t *ctx, uint32_t addr, uint8_t *data_buf, uint16_t buf_len)
 Write blocks of data to register address.
 
err_t wifi8_init_drv (wifi8_t *ctx)
 Synchronous API to initialize the device driver.
 
uint32_t wifi8_chip_id (wifi8_t *ctx)
 Get device ID.
 
err_t wifi8_get_full_firmware_version (wifi8_t *ctx, wifi8_m2m_rev_t *fw_version)
 Synchronous API to obtain the firmware version currently running on the device.
 
err_t wifi8_get_ota_firmware_version (wifi8_t *ctx, wifi8_m2m_rev_t *fw_version)
 Synchronous API to obtain the firmware version of the device.
 
err_t wifi8_connect (wifi8_t *ctx, char *pc_ssid, uint8_t u8_ssid_len, wifi8_m2m_sec_type_t u8_sec_type, void *pv_auth_info, uint16_t u16_ch)
 
err_t wifi8_get_connection_info (wifi8_t *ctx)
 
err_t wifi8_start_ap (wifi8_t *ctx, wifi8_m2m_ap_config_t *pstr_m2m_ap_config)
 Asynchronous API to enable access point (AKA "hot-spot") mode on the device.
 
err_t wifi8_req_scan_result (wifi8_t *ctx, uint8_t scan_request_index)
 Asynchronous API to request the information of an access point discovered via scanning.
 
err_t wifi8_request_scan (wifi8_t *ctx, uint8_t channel)
 Asynchronous API to request the WINC to scan for networks.
 
err_t wifi8_handle_events (wifi8_t *ctx)
 Synchronous event handler function.
 
err_t wifi8_ble_api_send (wifi8_t *ctx, uint8_t *msg, uint32_t len)
 Asynchronous API to send an encapsulated BLE message.
 
void wifi8_socket_init (wifi8_t *ctx)
 The function performs the necessary initializations for the socket library.
 
err_t wifi8_socket_create (wifi8_t *ctx, uint16_t u16_domain, uint8_t u8_type, uint8_t u8_flags)
 Synchronous socket allocation function based on the specified socket type.
 
err_t wifi8_socket_bind (wifi8_t *ctx, int8_t sock, wifi8_sockaddr_t *pstr_addr, uint8_t u8_addr_len)
 Asynchronous bind function associates the provided address and local port to the socket.
 
int8_t wifi8_socket_listen (wifi8_t *ctx, int8_t sock, uint8_t backlog)
 Asynchronous listen function.
 
err_t wifi8_socket_connect (wifi8_t *ctx, int8_t sock, wifi8_sockaddr_t *pstr_addr, uint8_t u8_addr_len)
 Asynchronous connect function.
 
err_t wifi8_socket_send (wifi8_t *ctx, int8_t sock, void *pv_send_buffer, uint16_t u16_send_length)
 Asynchronous sending function.
 
err_t wifi8_socket_send_to (wifi8_t *ctx, int8_t sock, void *pv_send_buffer, uint16_t u16_send_length, wifi8_sockaddr_t *pstr_dest_addr, uint8_t u8_addr_len)
 Asynchronous sending function.
 
err_t wifi8_socket_receive (wifi8_t *ctx, int8_t sock, void *pv_recv_buf, uint16_t u16_buf_len, uint32_t u32_timeoutmsec)
 Asynchronous receive function.
 
err_t wifi8_socket_receive_from (wifi8_t *ctx, int8_t sock, void *pv_recv_buf, uint16_t u16_buf_len, uint32_t u32_timeoutmsec)
 Asynchronous receive function.
 
err_t wifi8_socket_close (wifi8_t *ctx, int8_t sock)
 Synchronous close function.
 

Detailed Description

API for configuring and manipulating WiFi 8 Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ wifi8_ble_api_send()

err_t wifi8_ble_api_send ( wifi8_t * ctx,
uint8_t * msg,
uint32_t len )

Asynchronous API to send an encapsulated BLE message.

Asynchronous API to send an encapsulated BLE message over the Wifi Host Interface.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]msg: Pointer to the start of the BLE message to transfer down to the device.
[in]len: The length of the message in octets.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ wifi8_block_read()

err_t wifi8_block_read ( wifi8_t * ctx,
uint32_t addr,
uint8_t * data_buf,
uint16_t buf_len )

Read blocks of data from register address.

This function reads data from register address by using SPI serial interface.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]addr: Register address.
[out]data_buf: Read data.
[in]buf_len: Number of bytes to read.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ wifi8_block_write()

err_t wifi8_block_write ( wifi8_t * ctx,
uint32_t addr,
uint8_t * data_buf,
uint16_t buf_len )

Write blocks of data to register address.

This function writes data to register address by using SPI serial interface.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]addr: Register address.
[in]data_buf: Data to write.
[in]buf_len: Number of bytes to write.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ wifi8_cfg_setup()

void wifi8_cfg_setup ( wifi8_cfg_t * cfg)

WiFi 8 configuration object setup function.

This function initializes click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See wifi8_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ wifi8_chip_id()

uint32_t wifi8_chip_id ( wifi8_t * ctx)

Get device ID.

Reads and returns device ID.

Parameters
[out]ctx: Click context object. See wifi8_t object definition for detailed explanation.
Returns
Device ID.

◆ wifi8_connect()

err_t wifi8_connect ( wifi8_t * ctx,
char * pc_ssid,
uint8_t u8_ssid_len,
wifi8_m2m_sec_type_t u8_sec_type,
void * pv_auth_info,
uint16_t u16_ch )

@brie Asynchronous Wi-Fi connection function.

Asynchronous API to request connection to a specified access point.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]pc_ssid: A buffer holding the SSID corresponding to the requested AP.
[in]u8_ssid_len: Length of the given SSID (not including any NULL termination).
[in]u8_sec_type: Wi-Fi security type security for the network.
[in]pv_auth_info: Authentication parameters required for completing the connection.
[in]u16_ch: Wi-Fi channel number as defined in tenuM2mScanCh enumeration.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ wifi8_default_cfg()

err_t wifi8_default_cfg ( wifi8_t * ctx)

WiFi 8 default configuration function.

This function executes a default configuration of WiFi 8 click board.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ wifi8_generic_read()

err_t wifi8_generic_read ( wifi8_t * ctx,
uint8_t * data_out,
uint8_t len )

Generic reading function.

This function reads a desired number of data bytes by using SPI serial interface.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[out]data_out: Output read data.
[in]len: Number of bytes to be read.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ wifi8_generic_write()

err_t wifi8_generic_write ( wifi8_t * ctx,
uint8_t * data_in,
uint8_t len )

Generic writing function.

This function writes a desired number of data bytes by using SPI serial interface.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]data_in: Data to be written.
[in]len: Number of bytes to be written.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ wifi8_get_connection_info()

err_t wifi8_get_connection_info ( wifi8_t * ctx)

@brie Asynchronous API for retrieving the device connection status.

Requests the connection status from the device including information regarding any access point to which it is currently connected, or any non-AP station that is connected to the device. All information will be returned to the application via the Wi-Fi notification callback through the event M2M_WIFI_RESP_CONN_INFO.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ wifi8_get_full_firmware_version()

err_t wifi8_get_full_firmware_version ( wifi8_t * ctx,
wifi8_m2m_rev_t * fw_version )

Synchronous API to obtain the firmware version currently running on the device.

Read the firmware version currently running on the device.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[out]fw_version: Firmware object data.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ wifi8_get_ota_firmware_version()

err_t wifi8_get_ota_firmware_version ( wifi8_t * ctx,
wifi8_m2m_rev_t * fw_version )

Synchronous API to obtain the firmware version of the device.

Synchronous API to obtain the firmware version of the device image that is stored in the inactive flash partition.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[out]fw_version: Firmware object data.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ wifi8_handle_events()

err_t wifi8_handle_events ( wifi8_t * ctx)

Synchronous event handler function.

This function is responsible for handling interrupts received from the device firmware. Applications should call this function periodically in-order to receive the events that are to be handled by the callback functions implemented by the application.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ wifi8_init()

err_t wifi8_init ( wifi8_t * ctx,
wifi8_cfg_t * cfg )

WiFi 8 initialization function.

This function initializes all necessary pins and peripherals used for this click board.

Parameters
[out]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See wifi8_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ wifi8_init_drv()

err_t wifi8_init_drv ( wifi8_t * ctx)

Synchronous API to initialize the device driver.

This function initializes the device driver by registering the callback function for the M2M_WIFI layer handling of the events received, in response to the asynchronous Wi-Fi operations.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
Enables funtionality of driver should be called at the start of the appliction example after communication initialization.

◆ wifi8_reg_read()

err_t wifi8_reg_read ( wifi8_t * ctx,
uint32_t addr,
uint32_t * data_out )

Read data from register address.

This function reads data from register address by using SPI serial interface.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]addr: Register address.
[out]data_out: Data to be read.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ wifi8_reg_write()

err_t wifi8_reg_write ( wifi8_t * ctx,
uint32_t addr,
uint32_t data_in )

Write data to register address.

This function writes data to register address by using SPI serial interface.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]addr: Register address.
[in]data_in: Data to be written.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ wifi8_req_scan_result()

err_t wifi8_req_scan_result ( wifi8_t * ctx,
uint8_t scan_request_index )

Asynchronous API to request the information of an access point discovered via scanning.

This function allows the information of any discovered access point to be retrieved. When a scan is completed, the application is informed of the number of networks (access points) discovered. Calling this function with an index, N, will return the information for the Nth access point. The information will be returned to the application via a M2M_WIFI_RESP_SCAN_RESULT event.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]scan_request_index: Index for the requested result, the index range start from 0 till number of AP's found.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ wifi8_request_scan()

err_t wifi8_request_scan ( wifi8_t * ctx,
uint8_t channel )

Asynchronous API to request the WINC to scan for networks.

Scan statuses are delivered to the application via the Wi-Fi event callback in three stages. The first step involves the event M2M_WIFI_RESP_SCAN_DONE which, if successful, of access points via multiple calls to the asynchronous wifi8_req_scan_result API. For M2M_WIFI_RESP_SCAN_RESULT.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]channel: RF Channel ID for SCAN operation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ wifi8_socket_bind()

err_t wifi8_socket_bind ( wifi8_t * ctx,
int8_t sock,
wifi8_sockaddr_t * pstr_addr,
uint8_t u8_addr_len )

Asynchronous bind function associates the provided address and local port to the socket.

The asynchronous bind function associates the provided address and local port to the socket.The function can be used with both TCP and UDP sockets. Upon socket bind completion, the application will receive a SOCKET_MSG_BIND message in the socket callback.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]sock: Socket ID, must hold a non negative value.
[in]pstr_addr:Pointer to socket address structure.
[in]u8_addr_len: Size of the given socket address structure in bytes.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ wifi8_socket_close()

err_t wifi8_socket_close ( wifi8_t * ctx,
int8_t sock )

Synchronous close function.

The synchronous close function, releases all the socket assigned resources.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]sock: Socket ID, must hold a non negative value.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ wifi8_socket_connect()

err_t wifi8_socket_connect ( wifi8_t * ctx,
int8_t sock,
wifi8_sockaddr_t * pstr_addr,
uint8_t u8_addr_len )

Asynchronous connect function.

The asynchronous connect function must be called after receiving a valid socket ID from the wifi8_socket_create function. The application socket callback function is notified of the result of the connection attempt through the event SOCKET_MSG_CONNECT.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]sock: Socket ID, must hold a non negative value.
[in]pstr_addr: Address of the remote server.
[in]u8_addr_len: Size of the given socket address structure in bytes.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ wifi8_socket_create()

err_t wifi8_socket_create ( wifi8_t * ctx,
uint16_t u16_domain,
uint8_t u8_type,
uint8_t u8_flags )

Synchronous socket allocation function based on the specified socket type.

Synchronous socket allocation function based on the specified socket type. Created sockets are non-blocking and their possible types are either TCP or a UDP sockets.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]u16_domain: Socket family.
[in]u8_type:Socket type.
[in]u8_flags: Used to specify the socket creation flags.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ wifi8_socket_init()

void wifi8_socket_init ( wifi8_t * ctx)

The function performs the necessary initializations for the socket library.

The function performs the necessary initializations for the socket library through the following steps:

  • Check made to ensuring that initialization for sockets is performed only once.
  • Zero initializations to the global socket array (socets), which holds the list of TCP sockets.
  • Registers the socket (Host Interface)hif callback function through the call to the hif_register_cb function.
    Parameters
    [in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
    Returns
    • 0 - Success,
    • -1 - Error.
    See #err_t definition for detailed explanation.
    Note
    This initialization function must be invoked before any socket operation is performed.

◆ wifi8_socket_listen()

int8_t wifi8_socket_listen ( wifi8_t * ctx,
int8_t sock,
uint8_t backlog )

Asynchronous listen function.

The asynchronous listen function, response is received through the event SOCKET_MSG_LISTEN in the socket callback.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]sock: Socket ID, must hold a non negative value.
[in]backlog: Not used by the current implementation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
After successfully binding a socket to an IP address and port on the system, start listening passively for incoming connections. The socket must be bound on a local port or the listen operation fails.

◆ wifi8_socket_receive()

err_t wifi8_socket_receive ( wifi8_t * ctx,
int8_t sock,
void * pv_recv_buf,
uint16_t u16_buf_len,
uint32_t u32_timeoutmsec )

Asynchronous receive function.

The asynchronous receive function, used to retrieve data from a TCP stream.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]sock: Socket ID, must hold a non negative value.
[in]pv_recv_buf: Pointer to a buffer that will hold the received data.
[in]u16_buf_len: The buffer size in bytes.
[in]u32_timeoutmsec: Timeout for the recv function in milli-seconds.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
Before calling the recv function, a successful socket connection status must have been received through any of the two socket events SOCKET_MSG_CONNECT or SOCKET_MSG_ACCEPT , from the socket callback. Hence, indicating that the socket is already connected to a remote host.

◆ wifi8_socket_receive_from()

err_t wifi8_socket_receive_from ( wifi8_t * ctx,
int8_t sock,
void * pv_recv_buf,
uint16_t u16_buf_len,
uint32_t u32_timeoutmsec )

Asynchronous receive function.

The asynchronous recvfrom function is used to retrieve data from a UDP socket.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]sock: Socket ID, must hold a non negative value.
[in]pv_recv_buf: Pointer to a buffer that will hold the received data.
[in]u16_buf_len: The buffer size in bytes.
[in]u32_timeoutmsec: Timeout for the recv function in milli-seconds.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
The socket must already be bound to a local port before a call to the recvfrom function is made (i.e message SOCKET_MSG_BIND is received with successful status in the socket callback).

◆ wifi8_socket_send()

err_t wifi8_socket_send ( wifi8_t * ctx,
int8_t sock,
void * pv_send_buffer,
uint16_t u16_send_length )

Asynchronous sending function.

The asynchronous sending function, used to send data on a TCP/UDP socket.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]sock: Socket ID, must hold a non negative value.
[in]pv_send_buffer: Pointer to a buffer holding data to be transmitted.
[in]u16_send_length: The buffer size in bytes.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
Called by the application code when there is outgoing data available required to be sent on a specific socket handler.

◆ wifi8_socket_send_to()

err_t wifi8_socket_send_to ( wifi8_t * ctx,
int8_t sock,
void * pv_send_buffer,
uint16_t u16_send_length,
wifi8_sockaddr_t * pstr_dest_addr,
uint8_t u8_addr_len )

Asynchronous sending function.

The asynchronous sending function, used to send data on a UDP socket.

Parameters
[in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
[in]sock: Socket ID, must hold a non negative value.
[in]pv_send_buffer: Pointer to a buffer holding data to be transmitted.
[in]u16_send_length: The buffer size in bytes.
[in]pstr_dest_addr: The destination address.
[in]u8_addr_len: Destination address length in bytes.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
Called by the application code when there is data required to be sent on a UDP socket.

◆ wifi8_start_ap()

err_t wifi8_start_ap ( wifi8_t * ctx,
wifi8_m2m_ap_config_t * pstr_m2m_ap_config )

Asynchronous API to enable access point (AKA "hot-spot") mode on the device.

The WINC supports the ability to operate as an access point with the following limitations:

  • Only 1 station may be associated at any given time.
  • Open system and WEP are the only security suites supported.
    Parameters
    [in]ctx: Click context object. See wifi8_t object definition for detailed explanation.
    [in]pstr_m2map_config: A structure holding the AP configurations.
    Returns
    • 0 - Success,
    • -1 - Error.
    See #err_t definition for detailed explanation.