wifi9  2.0.0.0
Main Page

WiFi 9 Click

WiFi 9 Click is fully embedded stand-alone Wi-Fi module, equipped with the PAN9420 a 2.4 GHz ISM band Wi-Fi-embedded module which includes a wireless radio and an MCU for easy integration of Wi-Fi connectivity into various electronic devices.

Click Product page


Click library

  • Author : MikroE Team
  • Date : Jun 2020.
  • Type : UART type

Software Support

We provide a library for the Wifi9 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 form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

This library contains API for Wifi9 Click driver.

Standard key functions :

Example key functions :

Examples Description

This application showcases capability of the WiFi 9 Click board.

It initializes device, connects to local WiFi. Creates TCP server, waits for connection, and logs every message it receives from clients and returns back those messages as an echo response.

The demo application is composed of two sections :

Application Init

Initializes driver and wifi communication, then connects to the desired WiFi network

and creates TCP server on the IP address assigned to the Click board.

void application_init ( void )
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
wifi9_cfg_setup( &cfg );
WIFI9_MAP_MIKROBUS( cfg, MIKROBUS_1 );
wifi9_init( &wifi9, &cfg );
wifi9_reset_device( &wifi9 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
wifi9_process( );
wifi9_clear_app_buf( );
log_printf( &logger, "---------------------\r\n" );
log_printf( &logger, "---- System Info ----\r\n" );
log_printf( &logger, "---------------------\r\n" );
wifi9_rsp_check( WIFI9_CMD_GET_SYSTEM_FIRMWARE );
wifi9_log_app_buf( );
wifi9_rsp_check( WIFI9_CMD_GET_SYSTEM_MAC_ADDR );
wifi9_log_app_buf( );
wifi9_rsp_check( WIFI9_CMD_GET_SYSTEM_SERIAL_NUM );
wifi9_log_app_buf( );
wifi9_rsp_check( WIFI9_CMD_GET_SYSTEM_RADIO_VER );
wifi9_log_app_buf( );
wifi9_rsp_check( WIFI9_CMD_GET_SYSTEM_BOOTL_VER );
wifi9_log_app_buf( );
wifi9_rsp_check( WIFI9_CMD_GET_SYSTEM_HW_REV );
wifi9_log_app_buf( );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
log_printf( &logger, "--------------------------\r\n" );
log_printf( &logger, "---- Start NETCAT app ----\r\n" );
log_printf( &logger, "--------------------------\r\n" );
log_printf( &logger, "\r\nSet Station to ON status: " );
wifi9_rsp_check( WIFI9_CMD_SET_WLAN_STATE );
wifi9_log_app_buf( );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
log_printf( &logger, "\r\nSet Station SSID and PASSWORD: " );
strcpy( app_buf, WIFI9_CMD_SET_WLAN_CFG_STA );
strcat( app_buf, " \"" );
strcat( app_buf, EXAMPLE_SSID );
strcat( app_buf, "\" \"" );
strcat( app_buf, EXAMPLE_PASSWORD );
strcat( app_buf, "\" 4" );
wifi9_send_command( &wifi9, app_buf );
wifi9_rsp_check( WIFI9_CMD_SET_WLAN_CFG );
wifi9_log_app_buf( );
Delay_ms ( 500 );
log_printf( &logger, "\r\nTurn ON - Netcat module: " );
wifi9_rsp_check( WIFI9_CMD_SET_NETCAT_STATE );
wifi9_log_app_buf( );
Delay_ms ( 500 );
log_printf( &logger, "\r\nExclude Netcat authentication: " );
wifi9_rsp_check( WIFI9_CMD_SET_NETCAT_AUTH );
wifi9_log_app_buf( );
Delay_ms ( 500 );
log_printf( &logger, "\r\nSet the Netcat module server port: " );
strcpy( app_buf, WIFI9_CMD_SET_NETCAT_CFG_SERVER );
strcat( app_buf, " " );
strcat( app_buf, EXAMPLE_SERVER_PORT );
wifi9_send_command( &wifi9, app_buf );
wifi9_rsp_check( WIFI9_CMD_SET_NETCAT_CFG );
wifi9_log_app_buf( );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
log_printf( &logger, "\r\nWaiting for an IP address assignment from DHCP server...\r\n" );
for ( ; ; )
{
log_printf( &logger, "\r\nGet IP address: " );
wifi9_rsp_check( WIFI9_CMD_GET_NET_CFG );
wifi9_log_app_buf( );
if ( !strstr ( app_buf, "0.0.0.0" ) )
{
break;
}
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
wifi9_clear_app_buf( );
Delay_ms ( 1000 );
log_printf( &logger, "\r\nNow you can connect to the TCP server listed above via a TCP client app\r\n" );
log_printf( &logger, "The module is transferred to BIN-UART - for data collection\r\n" );
log_info( &logger, " Application Task " );
Delay_ms ( 1000 );
}

Application Task

All data received from the TCP clients will be logger to USB UART and echoed back to the clients.

void application_task ( void )
{
wifi9_process( );
if ( app_buf_len )
{
wifi9_log_app_buf( );
wifi9_generic_write( &wifi9, app_buf, app_buf_len );
wifi9_clear_app_buf( );
Delay_ms ( 100 );
}
}

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Wifi9

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.


wifi9_t
Click ctx object definition.
Definition: wifi9.h:147
WIFI9_CMD_SET_WLAN_STATE_STA_ON
#define WIFI9_CMD_SET_WLAN_STATE_STA_ON
Definition: wifi9.h:115
wifi9_cfg_t
Click configuration structure definition.
Definition: wifi9.h:169
wifi9_reset_device
void wifi9_reset_device(wifi9_t *ctx)
Module reset.
wifi9_send_command
void wifi9_send_command(wifi9_t *ctx, uint8_t *command)
Send Command function.
wifi9_init
err_t wifi9_init(wifi9_t *ctx, wifi9_cfg_t *cfg)
Initialization function.
WIFI9_CMD_SET_NETCAT_STATE_ON
#define WIFI9_CMD_SET_NETCAT_STATE_ON
Definition: wifi9.h:120
WIFI9_CMD_GET_NET_CFG_STA
#define WIFI9_CMD_GET_NET_CFG_STA
Definition: wifi9.h:126
WIFI9_MAP_MIKROBUS
#define WIFI9_MAP_MIKROBUS(cfg, mikrobus)
Definition: wifi9.h:67
WIFI9_CMD_SET_WLAN_CFG
#define WIFI9_CMD_SET_WLAN_CFG
Definition: wifi9.h:116
wifi9_cfg_setup
void wifi9_cfg_setup(wifi9_cfg_t *cfg)
Config Object Initialization function.
application_task
void application_task(void)
Definition: main.c:232
wifi9_select_uart
void wifi9_select_uart(wifi9_t *ctx, uint8_t uart_select)
Switch to a command or binary uart.
EXAMPLE_SERVER_PORT
#define EXAMPLE_SERVER_PORT
Definition: main.c:38
WIFI9_CMD_GET_SYSTEM_MAC_ADDR
#define WIFI9_CMD_GET_SYSTEM_MAC_ADDR
Definition: wifi9.h:107
WIFI9_CMD_SET_NETCAT_CFG_SERVER
#define WIFI9_CMD_SET_NETCAT_CFG_SERVER
Definition: wifi9.h:122
WIFI9_CMD_SET_NETCAT_AUTH
#define WIFI9_CMD_SET_NETCAT_AUTH
Definition: wifi9.h:123
WIFI9_CMD_SET_NETCAT_STATE
#define WIFI9_CMD_SET_NETCAT_STATE
Definition: wifi9.h:118
WIFI9_CMD_GET_NET_CFG
#define WIFI9_CMD_GET_NET_CFG
Definition: wifi9.h:125
WIFI9_SELECT_BIN_UART
#define WIFI9_SELECT_BIN_UART
Definition: wifi9.h:99
EXAMPLE_SSID
#define EXAMPLE_SSID
Definition: main.c:36
WIFI9_CMD_SET_NETCAT_AUTH_OFF
#define WIFI9_CMD_SET_NETCAT_AUTH_OFF
Definition: wifi9.h:124
wifi9_generic_write
void wifi9_generic_write(wifi9_t *ctx, uint8_t *data_buf, uint16_t len)
Generic write function.
WIFI9_SELECT_CMD_UART
#define WIFI9_SELECT_CMD_UART
Definition: wifi9.h:98
WIFI9_CMD_GET_SYSTEM_HW_REV
#define WIFI9_CMD_GET_SYSTEM_HW_REV
Definition: wifi9.h:111
WIFI9_CMD_SET_WLAN_CFG_STA
#define WIFI9_CMD_SET_WLAN_CFG_STA
Definition: wifi9.h:117
application_init
void application_init(void)
Definition: main.c:93
WIFI9_CMD_GET_SYSTEM_SERIAL_NUM
#define WIFI9_CMD_GET_SYSTEM_SERIAL_NUM
Definition: wifi9.h:108
WIFI9_CMD_SET_WLAN_STATE
#define WIFI9_CMD_SET_WLAN_STATE
Definition: wifi9.h:114
EXAMPLE_PASSWORD
#define EXAMPLE_PASSWORD
Definition: main.c:37
WIFI9_CMD_GET_SYSTEM_RADIO_VER
#define WIFI9_CMD_GET_SYSTEM_RADIO_VER
Definition: wifi9.h:109
WIFI9_CMD_SET_NETCAT_CFG
#define WIFI9_CMD_SET_NETCAT_CFG
Definition: wifi9.h:121
WIFI9_CMD_GET_SYSTEM_BOOTL_VER
#define WIFI9_CMD_GET_SYSTEM_BOOTL_VER
Definition: wifi9.h:110
WIFI9_CMD_GET_SYSTEM_FIRMWARE
#define WIFI9_CMD_GET_SYSTEM_FIRMWARE
Definition: wifi9.h:106