anynet2g 2.0.0.0
Main Page

AnyNet 2G click

‍AnyNet 2G Click is a cellular to AWS gateway device, which provides developers with the complete solution for various IoT applications, by using the AWS IoT and Cloud Storage services for the data storage, analyzing and processing.

click Product page


Click library

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

Software Support

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

Standard key functions :

Example key functions :

  • anynet2g_send_cmd This function sends a specified command to the click module.
    void anynet2g_send_cmd ( anynet2g_t *ctx, uint8_t *cmd );
    void anynet2g_send_cmd(anynet2g_t *ctx, uint8_t *cmd)
    Send command function.
  • anynet2g_send_cmd_with_par This function sends a command with specified parameter to the click module.
    void anynet2g_send_cmd_with_par ( anynet2g_t *ctx, uint8_t *at_cmd_buf, uint8_t *param_buf );
    void anynet2g_send_cmd_with_par(anynet2g_t *ctx, uint8_t *at_cmd_buf, uint8_t *param_buf)
    Send command function with parameter.
  • anynet2g_send_cmd_check This function checks the command status.
    void anynet2g_send_cmd_check ( anynet2g_t *ctx, uint8_t *at_cmd_buf );
    void anynet2g_send_cmd_check(anynet2g_t *ctx, uint8_t *at_cmd_buf)
    Check the sent command.

Example Description

‍This example demonstrates the use of AnyNet 2G click board.

The demo application is composed of two sections :

Application Init

‍Initializes the driver and sends a few AT commands to test the communication and configure the click board.

void application_init ( void )
{
log_cfg_t log_cfg;
anynet2g_cfg_t anynet2g_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
anynet2g_cfg_setup( &anynet2g_cfg );
ANYNET2G_MAP_MIKROBUS( anynet2g_cfg, MIKROBUS_1 );
if ( UART_ERROR == anynet2g_init( &anynet2g, &anynet2g_cfg ) )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
anynet2g_process( );
anynet2g_clear_app_buf( );
// Check communication
error_flag = anynet2g_rsp_check( ANYNET2G_RSP_OK );
anynet2g_error_check( error_flag );
// Query VERSION info for the AnyNet AWS IoT code
error_flag = anynet2g_rsp_check( ANYNET2G_RSP_OK );
anynet2g_error_check( error_flag );
// Query IMEI of the modem on the board
error_flag = anynet2g_rsp_check( ANYNET2G_RSP_OK );
anynet2g_error_check( error_flag );
// Query ICCID of the SIM
error_flag = anynet2g_rsp_check( ANYNET2G_RSP_OK );
anynet2g_error_check( error_flag );
// Check AWS State
error_flag = anynet2g_rsp_check( ANYNET2G_RSP_OK );
anynet2g_error_check( error_flag );
// Open AWS topic
#define AWS_TOPIC_OPEN "0,\"MY_TOPIC_OPEN\""
error_flag = anynet2g_rsp_check( ANYNET2G_RSP_OK );
anynet2g_error_check( error_flag );
// Subscribe to AWS topic
#define AWS_TOPIC_SUBSCRIBE "0,\"MY_TOPIC_SUBSCRIBE\""
error_flag = anynet2g_rsp_check( ANYNET2G_RSP_OK );
anynet2g_error_check( error_flag );
anynet2g_clear_app_buf( );
log_info( &logger, " Application Task " );
}
#define ANYNET2G_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition anynet2g.h:119
#define ANYNET2G_CMD_QCCID
Definition anynet2g.h:74
#define ANYNET2G_CMD_AWSSUBOPEN
Definition anynet2g.h:82
#define ANYNET2G_CMD_AT
AnyNet 2G control commands.
Definition anynet2g.h:73
#define ANYNET2G_CMD_AWSPUBOPEN
Definition anynet2g.h:80
#define ANYNET2G_RSP_OK
AnyNet 2G device response for AT commands.
Definition anynet2g.h:89
#define ANYNET2G_CMD_AWSVER
Definition anynet2g.h:76
#define ANYNET2G_CMD_AWSSTATE
Definition anynet2g.h:78
#define ANYNET2G_CMD_GSN
Definition anynet2g.h:75
void application_init(void)
Definition main.c:91
#define AWS_TOPIC_OPEN
#define AWS_TOPIC_SUBSCRIBE

Application Task

‍Reads all the received data and logs them to the USB UART.

void application_task ( void )
{
anynet2g_process( );
anynet2g_log_app_buf( );
anynet2g_clear_app_buf( );
}
void application_task(void)
Definition main.c:163

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

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.