g2c  2.0.0.0
Main Page

G2C click

Go to Cloud (G2C) click is a gateway Click boardâ„¢ which provides a simple and reliable connection to the Click Cloud platform.

click Product page


Click library

  • Author : MikroE Team
  • Date : Apr 2020.
  • Type : UART GSM/IOT type

Software Support

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

Standard key functions :

  • Config Object Initialization function.

    void g2c_cfg_setup ( g2c_cfg_t *cfg );

  • Initialization function.

    G2C_RETVAL g2c_init ( g2c_t *ctx, g2c_cfg_t *cfg );

Example key functions :

Examples Description

This example reads and processes data from G2C clicks.

The demo application is composed of two sections :

Application Init

Initializes driver and power module.

void application_init ( void )
{
log_cfg_t log_cfg;
g2c_cfg_t cfg;
// Logger initialization.
LOG_MAP_USB_UART( log_cfg );
log_cfg.level = LOG_LEVEL_DEBUG;
log_cfg.baud = 57600;
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
g2c_cfg_setup( &cfg );
G2C_MAP_MIKROBUS( cfg, MIKROBUS_1 );
g2c_init( &g2c, &cfg );
// Power module.
g2c_module_power( &g2c, true, 0 );
g2c_reset( &g2c );
// Send command.
log_printf( &logger, ">> ATE \r\n" );
Delay_ms( 3000 );
g2c_process( );
log_printf( &logger, ">> AT \r\n" );
g2c_send_command( &g2c, AT );
Delay_ms( 3000 );
g2c_process( );
log_printf( &logger, ">> AT_CEN \r\n" );
g2c_process( );
log_printf( &logger, ">> NETWORK \r\n" );
g2c_process( );
log_printf( &logger, ">> AT NWC \r\n" );
g2c_process( );
log_printf( &logger, ">> DEVICE \r\n" );
g2c_process( );
log_printf( &logger, ">> AT BRC \r\n" );
g2c_process( );
Delay_ms( 3000 );
}

Application Task

Reads the received data and parses it.

void application_task ( void )
{
g2c_process( );
actuator_demo( current_parser_buf );
if ( send_data_cnt == 5 )
{
log_printf( &logger, ">> ACTUATOR REF \r\n" );
g2c_send_data_ref( &g2c, ACTUATOR_STR_REF, data_buf );
g2c_process( );
log_printf( &logger, ">> AT PUB \r\n" );
g2c_process( );
send_data_cnt = 0;
}
send_data_cnt++;
}

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

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.


AT_CEN
#define AT_CEN
Definition: main.c:42
g2c_send_broker_cfg
void g2c_send_broker_cfg(g2c_t *ctx, char *brc_key, char *brc_password)
Broker configuration.
g2c_cfg_setup
void g2c_cfg_setup(g2c_cfg_t *cfg)
Config Object Initialization function.
DEVICE_PASSWORD
#define DEVICE_PASSWORD
Definition: main.c:62
g2c_init
G2C_RETVAL g2c_init(g2c_t *ctx, g2c_cfg_t *cfg)
Initialization function.
g2c_reset
void g2c_reset(g2c_t *ctx)
Reset module.
g2c_send_operator_cfg
void g2c_send_operator_cfg(g2c_t *ctx, char *op_username, char *op_password)
Operater ( Network ) configuration.
application_task
void application_task(void)
Definition: main.c:208
AT
#define AT
Definition: main.c:41
NETWORK_PASSWORD
#define NETWORK_PASSWORD
Definition: main.c:58
g2c_module_power
void g2c_module_power(g2c_t *ctx, uint8_t power_state, uint8_t bootloader)
Power module.
NETWORK_USERNAME
#define NETWORK_USERNAME
Definition: main.c:57
DEVICE_KEY
#define DEVICE_KEY
Definition: main.c:61
AT_NWC
#define AT_NWC
Definition: main.c:44
G2C_MAP_MIKROBUS
#define G2C_MAP_MIKROBUS(cfg, mikrobus)
Definition: g2c.h:52
ATE
#define ATE
Definition: main.c:40
g2c_send_command
void g2c_send_command(g2c_t *ctx, char *command)
Function for send command.
AT_PUB
#define AT_PUB
Definition: main.c:48
application_init
void application_init(void)
Definition: main.c:149
AT_BRC
#define AT_BRC
Definition: main.c:46
g2c_send_data_ref
void g2c_send_data_ref(g2c_t *ctx, char *reference_buf, char *data_buf)
Send data reference.
ACTUATOR_STR_REF
#define ACTUATOR_STR_REF
Definition: main.c:52
g2c_cfg_t
Click configuration structure definition.
Definition: g2c.h:138