lpwifi  2.0.0.0
Main Page

LP WiFi click

LP WiFi Click is a compact add-on board that represents an ultra-low-power Wi-Fi solution. This board features the DA16200, a fully integrated Wi-Fi module with ultra-low power consumption, best RF performance, and a comfortable development environment from Dialog Semiconductor.

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : May 2021.
  • Type : UART type

Software Support

We provide a library for the LPWiFi 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 LPWiFi Click driver.

Standard key functions :

Example key functions :

Example Description

This example reads and processes data from LP WiFi clicks.

The demo application is composed of two sections :

Application Init

Initializes the driver and powers up the module, then connects to the desired AP and creates TCP and UDP servers on the desired local port.

void application_init ( void )
{
log_cfg_t log_cfg;
lpwifi_cfg_t lpwifi_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
Delay_ms( 100 );
// Click initialization.
lpwifi_cfg_setup( &lpwifi_cfg );
LPWIFI_MAP_MIKROBUS( lpwifi_cfg, MIKROBUS_1 );
err_t init_flag = lpwifi_init( &lpwifi, &lpwifi_cfg );
if ( UART_ERROR == init_flag )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
lpwifi_default_cfg( &lpwifi );
Delay_ms( 500 );
// Initiate the communication
Delay_ms( 1000 );
// Dummy read
lpwifi_process( );
lpwifi_clear_app_buf( );
log_printf( &logger, "\r\n --- Factory reset --- \r\n" );
Delay_ms( 500 );
// Enable Echo
app_error_flag = lpwifi_rsp_check( );
lpwifi_error_check( app_error_flag );
Delay_ms( 500 );
log_printf( &logger, " ----------------------------------------------- \r\n" );
log_printf( &logger, "\r\n --- Connecting to the access point --- \r\n" );
// Connect to AP
app_error_flag = lpwifi_rsp_check( );
lpwifi_error_check( app_error_flag );
lpwifi_check_connection();
while ( CONNECTED_TO_AP != app_connection_status )
{
lpwifi_check_connection();
if ( NOT_CONNECTED_TO_AP == app_connection_status )
{
Delay_ms( 500 );
app_connection_status = WAIT_FOR_CONNECTION;
// Connect to AP
app_error_flag = lpwifi_rsp_check( );
lpwifi_error_check( app_error_flag );
}
}
log_printf( &logger, " ----------------------------------------------- \r\n" );
log_printf( &logger, "\r\n --- Creating a TCP server --- \r\n" );
// Create TCP Server
app_error_flag = lpwifi_rsp_check( );
lpwifi_error_check( app_error_flag );
Delay_ms( 500 );
log_printf( &logger, " ----------------------------------------------- \r\n" );
log_printf( &logger, "\r\n --- Creating a UDP socket --- \r\n" );
// Create UDP socket
app_error_flag = lpwifi_rsp_check( );
lpwifi_error_check( app_error_flag );
Delay_ms( 500 );
log_printf( &logger, " ----------------------------------------------- \r\n" );
log_printf( &logger, " TCP server and UDP socket are available at: \r\n" );
log_printf( &logger, " SSID: \"%s\"\r\n IP: %s\r\n Port: %u", ( char * ) AP_SSID,
( char * ) assigned_ip_address,
( uint16_t ) LOCAL_PORT );
log_printf( &logger, "\r\n ----------------------------------------------- \r\n" );
log_printf( &logger, " You can connect to it via a TCP/UDP client." );
log_printf( &logger, "\r\n ----------------------------------------------- \r\n" );
}

Application Task

Logs all the data received from TCP/UDP clients on the USB UART.

void application_task ( void )
{
lpwifi_process( );
lpwifi_log_app_buf( );
}

Note

In order for the example to work, user needs to set the AP SSID, password, and Local port on which the TCP server and UDP socket will be created. Enter valid data for the following macros: AP_SSID, AP_PASSWORD and LOCAL_PORT.

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.LPWiFi

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. UART terminal is available in all MikroElektronika compilers.


lpwifi_connect_to_ap
void lpwifi_connect_to_ap(lpwifi_t *ctx, char *ssid, char *password)
Connect to AP function.
NOT_CONNECTED_TO_AP
#define NOT_CONNECTED_TO_AP
Definition: main.c:61
CONNECTED_TO_AP
#define CONNECTED_TO_AP
Definition: main.c:60
LPWIFI_MAP_MIKROBUS
#define LPWIFI_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: lpwifi.h:135
LPWIFI_CMD_ATE
#define LPWIFI_CMD_ATE
Definition: lpwifi.h:60
lpwifi_t
LP WiFi Click context object.
Definition: lpwifi.h:149
lpwifi_factory_reset_device
void lpwifi_factory_reset_device(lpwifi_t *ctx)
Device factory reset function.
application_task
void application_task(void)
Definition: main.c:227
WAIT_FOR_CONNECTION
#define WAIT_FOR_CONNECTION
Definition: main.c:59
LOCAL_PORT
#define LOCAL_PORT
Definition: main.c:47
lpwifi_send_cmd
void lpwifi_send_cmd(lpwifi_t *ctx, char *cmd)
Send command function.
lpwifi_cfg_setup
void lpwifi_cfg_setup(lpwifi_cfg_t *cfg)
LP WiFi configuration object setup function.
LPWIFI_CMD_AT
#define LPWIFI_CMD_AT
LP WiFi - Basic AT commands.
Definition: lpwifi.h:58
AP_SSID
#define AP_SSID
Definition: main.c:41
lpwifi_default_cfg
void lpwifi_default_cfg(lpwifi_t *ctx)
LP WiFi default configuration function.
lpwifi_cfg_t
LP WiFi Click configuration object.
Definition: lpwifi.h:175
AP_PASSWORD
#define AP_PASSWORD
Definition: main.c:44
application_init
void application_init(void)
Definition: main.c:128
lpwifi_create_tcp_server
void lpwifi_create_tcp_server(lpwifi_t *ctx, uint16_t port)
Create TCP server function.
lpwifi_init
err_t lpwifi_init(lpwifi_t *ctx, lpwifi_cfg_t *cfg)
LP WiFi initialization function.
lpwifi_create_udp_socket
void lpwifi_create_udp_socket(lpwifi_t *ctx, uint16_t port)
Create UDP socket function.