WiFi 8 click
WiFi 8 Click is a compact add-on board that contains a wireless combo module. This board features the ATWINC3400-MR210CA, a Bluetooth 5.0 certified module optimized for low power and high-performance mobile applications from Microchip Technology.
click Product page
Click library
- Author : Luka Filipovic
- Date : Jan 2021.
- Type : SPI type
Software Support
We provide a library for the WiFi8 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on mikroE github account.
Library Description
This library contains API for WiFi8 Click driver.
Standard key functions :
wifi8_cfg_setup
Config Object Initialization function.
void wifi8_cfg_setup(wifi8_cfg_t *cfg)
WiFi 8 configuration object setup function.
WiFi 8 Click configuration object.
Definition wifi8.h:127
wifi8_init
Initialization function.
err_t wifi8_init(wifi8_t *ctx, wifi8_cfg_t *cfg)
WiFi 8 initialization function.
WiFi 8 Click context object.
Definition wifi8.h:92
wifi8_default_cfg
Click Default Configuration function.
err_t wifi8_default_cfg(wifi8_t *ctx)
WiFi 8 default configuration function.
Example key functions :
wifi8_init_drv
Synchronous API to initialize the device driver.
err_t wifi8_init_drv(wifi8_t *ctx)
Synchronous API to initialize the device driver.
wifi8_connect
Asynchronous Wi-Fi connection function.
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)
wifi8_m2m_sec_type_t
Definition wifi8_types.h:430
wifi8_socket_bind
Asynchronous bind function associates the provided address and local port to the socket.
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.
Definition wifi8_types.h:772
Example Description
This application showcases capability of the WiFi 8 Click board.
It initializes device, connects to local WiFi. Creates TCP, waits for connection and logs every message it receives for clients when it receives CR or LF flag it returns message back to Client.
The demo application is composed of two sections :
Application Init
Initializes Host logger, and communication module and pins.
Then resets device and initializes devices firmware. If no error occurred it sets callback functions for WiFi and TCP socket, and checks current firmware version. After firmware is read it connects to local WiFi network set by user. When connected it initializes and creates socket.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info(&logger, " Application Init ");
Delay_ms ( 1000 );
if (init_flag == SPI_MASTER_ERROR)
{
log_error(&logger, " Application Init Error. ");
log_info(&logger, " Please, run program again... ");
for (;;);
}
{
log_error(&logger, " Default configuartion. ");
for (;;);
}
wifi8.app_wifi_cb = wifi_cb;
wifi8.app_socket_cb = socket_cb;
{
log_printf(&logger, "Firmware HIF (%u) : %u.%u \n",
log_printf(&logger, "Firmware ver : %u.%u.%u \n",
}
else
{
log_error(&logger, " reading full firmware version ");
for (;;);
}
{
{
log_error(&logger, " Connection");
for (;;);
}
else
{
log_info(&logger, " Connecting... ");
}
}
{
}
log_info(&logger, " Application Task ");
}
#define WIFI8_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition wifi8.h:74
err_t wifi8_handle_events(wifi8_t *ctx)
Synchronous event handler function.
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.
void wifi8_socket_init(wifi8_t *ctx)
The function performs the necessary initializations for the socket library.
#define MAIN_TCP_SERVER_PORT
Definition main.c:45
void application_init(void)
Definition main.c:74
#define MAIN_WLAN_PSK
Definition main.c:44
wifi8_sockaddr_in_t addr
Definition main.c:62
#define MAIN_WLAN_SSID
Definition main.c:42
#define MAIN_WLAN_AUTH
Definition main.c:43
uint32_t s_addr
Definition wifi8_types.h:786
Definition wifi8_types.h:837
uint16_t u16_firmware_hif_info
Definition wifi8_types.h:838
uint8_t u8_firmware_patch
Definition wifi8_types.h:842
uint8_t u8_firmware_major
Definition wifi8_types.h:839
uint8_t build_time[9]
Definition wifi8_types.h:844
uint8_t build_date[12]
Definition wifi8_types.h:843
uint8_t u8_firmware_minor
Definition wifi8_types.h:841
uint16_t sin_port
Definition wifi8_types.h:793
wifi8_in_addr_t sin_addr
Definition wifi8_types.h:794
uint16_t sin_family
Definition wifi8_types.h:792
@ M2M_WIFI_DISCONNECTED
Definition wifi8_types.h:441
@ M2M_WIFI_CONNECTED
Definition wifi8_types.h:442
@ M2M_WIFI_CH_ALL
Definition wifi8_types.h:426
@ WIFI8_OK
Definition wifi8_types.h:573
Application Task
It loops function for handling events. Should notify and log messages when Client
is connected/disconnected to TCP server and returns back when receives CR or LF flag.
{
if (tcp_server_socket < 0)
{
{
log_printf(&logger, "main: failed to create TCP server socket error!\r\n");
}
else
{
}
}
}
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.
void application_task(void)
Definition main.c:160
Definition wifi8_types.h:791
Note
User should set MAIN_WLAN_SSID and MAIN_WLAN_PSK for connecting to local network.
When devices connects to network it will log its IP that user need to connect to. After user connects it should get notification and it can send data to server. Server will return message "WiFi 8 Click" when Client sends CR or LF character in message.
The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on mikroE github account.
Other mikroE Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.WiFi8
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.