Establish cellular network connectivity using the LTE Cat 1 standard for European data transmission in M2M applications
A
A
Hardware Overview
How does it work?
LTE Cat.1 3 Click (for Europe) is based on the EG91EXGA-128-SGNS, an embedded 4G wireless communication module from Quectel with receive diversity. This module supports multiple wireless communication standards, including LTE-FDD, WCDMA, and GSM, providing reliable data connectivity across various networks. With the ability to also provide voice functionality (the telematics version supporting voice and data functions), this module is designed to meet customers' specific needs. The LTE Cat.1 3 Click supports multiple LTE bands (B1/B3/B7/B8/B20/B28) and RX diversity for bands B1 and B8. Additionally, it offers multi-constellation GNSS support for GPS, GLONASS, BeiDou/Compass, Galileo, and QZSS. It is fully integrated with Internet service protocols such as TCP, UDP, and PPP, making it easy to use with extended AT commands. This Click board™ meets almost all requirements for M2M applications such as automotive, smart metering, tracking systems, security, routers, wireless POS, and many more. Communication between the EG91EXGA-128-SGNS and the host MCU is made through a UART interface, using standard UART RX and TX pins and hardware flow control pins (CTS/RTS/RI - Clear to Send/Ready to Send/Ring Indicator) for efficient data transfer. The module defaults to a communication speed of 115200bps, allowing for seamless data exchange over AT commands. Notably, this telematics version of the module also features an audio interface, which can be accessed via the I2C interface. The LTE Cat.1 3 Click audio interface operates through the MAX9860, a 16-bit mono audio voice codec configurable via the I2C
interface. This setup works with a jack on the back of the board designed for CTIA standard headphones, which are commonly used in modern smartphones and feature a combined audio and microphone connector. This standard ensures compatibility with a wide range of headphones and headsets. Additionally, the audio interface supports advanced features such as echo cancellation and noise suppression, enhancing the clarity and quality of voice communications. The LTE Cat.1 3 Click also includes a USB Type C connector for both power and data transfer, compliant with the USB 2.0 specification (slave only). This interface supports data transfer rates of up to 480Mbps, facilitating AT command communication, data transmission, GNSS NMEA sentence output, software debugging, firmware upgrades, and voice over USB. The board features a USB FW upgrade switch labeled USB BOOT to manage firmware upgrades. This switch has positions 0 for normal operation and 1 for firmware upgrades over USB, ensuring a straightforward upgrade process. In addition, this Click board™ includes several additional functionalities that enhance its usability and control. The PWR button allows users to easily power the module on or off, while the RESET button provides a quick way to reset the module. These functions can also be controlled digitally via the mikroBUS™ pins PWR and RST, offering greater flexibility. Moreover, these controls have dedicated test points for easier debugging and testing. The board also features two visual indicators to provide real-time status updates. The red NET LED offers feedback on network activity: it flickers slowly when searching for a network,
flickers quickly during data transfer, and remains steadily on during voice calls. The yellow STAT LED indicates the module's power status, which stays off when the module is off and turns on when the module is powered on. The board also includes DBG TX/RX interface test points for debug UART communication, simplifying the development and troubleshooting process. The board features three u.Fl connectors for GNSS, LTE, and LTE/WCDMA receive the diversity antenna that MIKROE offers, the LTE Flat Rotation Antenna and Active GPS Antenna combined with an IPEX-SMA cable for flexible and efficient connectivity options. In addition, the user can easily choose the power supply of the GNSS antenna by choosing between 3.3V and 5V on the GNSS ANT jumper. Additionally, the board is equipped with a micro SIM card holder that supports both 1.8V and 3.0V uSIM cards, ensuring compatibility with a wide range of cellular networks and allowing users to select the most appropriate service provider for their particular use case. This Click board™ can operate with both 3.3V and 5V logic voltage levels selected via the VCC SEL jumper. Since the EG91-EX module operates at 3.8V, logic-level translators, the TXB0106 and PCA9306, are also used for proper operation and an accurate signal-level translation. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.
Features overview
Development board
UNI-DS v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports a wide range of microcontrollers, such as different STM32, Kinetis, TIVA, CEC, MSP, PIC, dsPIC, PIC32, and AVR MCUs regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer over WiFi. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, UNI-DS v8 provides a fluid and immersive working experience, allowing access anywhere and under any
circumstances at any time. Each part of the UNI-DS v8 development board contains the components necessary for the most efficient operation of the same board. An advanced integrated CODEGRIP programmer/debugger module offers many valuable programming/debugging options, including support for JTAG, SWD, and SWO Trace (Single Wire Output)), and seamless integration with the Mikroe software environment. Besides, it also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector. Communication options such as USB-UART, USB
HOST/DEVICE, CAN (on the MCU card, if supported), and Ethernet is also included. In addition, it also has the well-established mikroBUS™ standard, a standardized socket for the MCU card (SiBRAIN standard), and two display options for the TFT board line of products and character-based LCD. UNI-DS v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.
Microcontroller Overview
MCU Card / MCU

Type
8th Generation
Architecture
PIC
MCU Memory (KB)
32
Silicon Vendor
Microchip
Pin count
80
RAM (Bytes)
2048
You complete me!
Accessories
Active GPS antenna is designed to enhance the performance of your GPS and GNSS Click boards™. This external antenna boasts a robust construction, making it ideal for various weather conditions. With a frequency range of 1575.42MHz and a 50Ohm impedance, it ensures reliable signal reception. The antenna delivers a gain of greater than -4dBic within a wide angular range, securing over 75% coverage. The bandwidth of +/- 5MHz further guarantees precise data acquisition. Featuring a Right-Hand Circular Polarization (RHCP), this antenna offers stable signal reception. Its compact dimensions of 48.53915mm and a 2-meter cable make it easy to install. The magnetic antenna type with an SMA male connector ensures a secure and convenient connection. If you require a dependable external antenna for your locator device, our active GPS antenna is the perfect solution.
LTE Flat Rotation Antenna is a versatile choice for boosting the performance of 3G/4G LTE devices. With a wide frequency range of 700-2700MHz, it ensures optimal connectivity on major cellular bands worldwide. This flat antenna features an SMA male connector, making it easy to attach directly to your device or SMA module connector. One of its standout features is its adjustable angle, which can be set in 45⁰ increments (0⁰/45⁰/90⁰), allowing you to fine-tune the antenna's orientation for maximum signal reception. With an impedance of 50Ω and a VSW Ratio of <2.0:1, this antenna ensures a reliable and efficient connection. Its 5dB gain, vertical polarization, and omnidirectional radiation pattern enhance signal strength, making it suitable for various applications. Measuring 196mm in length and 38mm in width, this antenna offers a compact yet effective solution for improving your connectivity. With a maximum input power of 50W, it can handle the demands of various devices.
IPEX-SMA cable is a type of RF (radio frequency) cable assembly. "IPEX" refers to the IPEX connector, a miniature coaxial connector commonly used in small electronic devices. "SMA" stands for SubMiniature Version A and is another coaxial connector commonly used in RF applications. An IPEX-SMA cable assembly has an IPEX connector on one end and an SMA connector on the other, allowing it to connect devices or components that use these specific connectors. These cables are often used in applications like WiFi or cellular antennas, GPS modules, and other RF communication systems where a reliable and low-loss connection is required.
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic

Step by step
Project assembly
Track your results in real time
Application Output
1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support
Library Description
This library contains API for LTE Cat.1 3 Click (for Europe) driver.
Key functions:
ltecat13ex_write_register
- This function writes a data byte into the selected register address.ltecat13ex_max9860_cfg
- This function is used to set basic config for MAX9860 of LTE Cat.1 3 click board.ltecat13ex_send_sms_pdu
- This function sends text message to a phone number in PDU mode.
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* @file main.c
* @brief LTE Cat.1 3 EX Click Example.
*
* # Description
* Application example shows device capability of connecting to the network and
* sending SMS, TCP/UDP messages, calling the selected number, or getting GNSS location
* using standard "AT" commands.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Sets the device configuration for sending SMS, TCP/UDP messages, calling the selected number
* or GNSS location.
*
* ## Application Task
* Depending on the selected demo example, it sends an SMS message
* (in PDU or TXT mode) or a TCP/UDP message, calls the selected number or
* gets GNSS location.
*
* ## Additional Function
* - static void ltecat13ex_clear_app_buf ( void )
* - static void ltecat13ex_log_app_buf ( void )
* - static err_t ltecat13ex_process ( ltecat13ex_t *ctx )
* - static void ltecat13ex_error_check( err_t error_flag )
* - static void ltecat13ex_log_app_buf ( void )
* - static err_t ltecat13ex_rsp_check ( uint8_t *rsp )
* - static err_t ltecat13ex_cfg_for_network ( void )
* - static err_t ltecat13ex_check_connection ( void )
* - static err_t ltecat13ex_cfg_for_example ( void )
* - static err_t ltecat13ex_example( void )
* - static void gnss_parser_application ( char *rsp )
*
* @note
* In order for the examples to work, user needs to set the APN and SMSC (SMS PDU mode only)
* of entered SIM card as well as the phone number (SMS mode only) to which he wants to send an SMS.
* Enter valid values for the following macros: SIM_APN, SIM_SMSC and PHONE_NUMBER_TO_MESSAGE.
* Example:
SIM_APN "internet"
SIM_SMSC "+381610401"
PHONE_NUMBER_TO_MESSAGE "+381659999999"
*
* @author Stefan Ilic
*
*/
#include "board.h"
#include "log.h"
#include "ltecat13ex.h"
#include "generic_pointer.h"
#include "conversions.h"
// Example selection macros
#define EXAMPLE_TCP_UDP 0 // Example of sending messages to a TCP/UDP echo server
#define EXAMPLE_SMS 1 // Example of sending SMS to a phone number
#define EXAMPLE_CALL 2 // Example of calling selected phone number
#define EXAMPLE_GNSS 3 // Example of getting GNSS location
#define DEMO_EXAMPLE EXAMPLE_TCP_UDP // Example selection macro
// SIM APN config
#define SIM_APN "internet" // Set valid SIM APN
// SMS/CALL example parameters
#define SIM_SMSC "" // Set valid SMS Service Center Address - only in SMS PDU mode
#define PHONE_NUMBER "" // Set Phone number to message or call
#define SMS_MODE "0" // SMS mode: "0" - PDU, "1" - TXT
// TCP/UDP example parameters
#define REMOTE_IP "77.46.162.162" // TCP/UDP echo server IP address
#define REMOTE_PORT "51111" // TCP/UDP echo server port
// Message content
#define MESSAGE_CONTENT "LTE Cat.1 3 EX click board - demo example."
// Application buffer size
#define APP_BUFFER_SIZE 500
#define PROCESS_BUFFER_SIZE 200
/**
* @brief Example states.
* @details Predefined enum values for application example state.
*/
typedef enum
{
LTECAT13EX_CONFIGURE_FOR_NETWORK = 1,
LTECAT13EX_WAIT_FOR_CONNECTION,
LTECAT13EX_CONFIGURE_FOR_EXAMPLE,
LTECAT13EX_EXAMPLE
} ltecat13ex_example_state_t;
static ltecat13ex_t ltecat13ex;
static log_t logger;
static uint8_t app_buf[ APP_BUFFER_SIZE ] = { 0 };
static uint8_t gnss_info_message[ 200 ] = { 0 };
static int32_t app_buf_len = 0;
static err_t error_flag;
static ltecat13ex_example_state_t example_state;
/**
* @brief LTE Cat.1 3 EX clearing application buffer.
* @details This function clears memory of application buffer and reset its length.
* @note None.
*/
static void ltecat13ex_clear_app_buf ( void );
/**
* @brief LTE Cat.1 3 EX log application buffer.
* @details This function logs data from application buffer to USB UART.
* @note None.
*/
static void ltecat13ex_log_app_buf ( void );
/**
* @brief LTE Cat.1 3 EX data reading function.
* @details This function reads data from device and concatenates data to application buffer.
* @param[in] ctx : Click context object.
* See #ltecat13ex_t object definition for detailed explanation.
* @return @li @c 0 - Read some data.
* @li @c -1 - Nothing is read.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t ltecat13ex_process ( void );
/**
* @brief Check for errors.
* @details This function checks for different types of
* errors and logs them on UART or logs the response if no errors occured.
* @param[in] error_flag Error flag to check.
*/
static void ltecat13ex_error_check( err_t error_flag );
/**
* @brief Logs application buffer.
* @details This function logs data from application buffer.
*/
static void ltecat13ex_log_app_buf ( void );
/**
* @brief Response check.
* @details This function checks for response and
* returns the status of response.
* @param[in] rsp Expected response.
* @return @li @c 0 - OK response.
* @li @c -2 - Timeout error.
* @li @c -3 - Command error.
* @li @c -4 - Unknown error.
* See #err_t definition for detailed explanation.
*/
static err_t ltecat13ex_rsp_check ( uint8_t *rsp );
/**
* @brief Configure device for connection to the network.
* @details Sends commands to configure and enable
* connection to the specified network.
* @return @li @c 0 - OK response.
* @li @c -2 - Timeout error.
* @li @c -3 - Command error.
* @li @c -4 - Unknown error.
* See #err_t definition for detailed explanation.
*/
static err_t ltecat13ex_cfg_for_network ( void );
/**
* @brief Wait for connection signal.
* @details Wait for connection signal from CREG URC.
* @return @li @c 0 - OK response.
* @li @c -2 - Timeout error.
* @li @c -3 - Command error.
* @li @c -4 - Unknown error.
* See #err_t definition for detailed explanation.
*/
static err_t ltecat13ex_check_connection ( void );
/**
* @brief Configure device for example.
* @details Configure device for the specified example.
* @return @li @c 0 - OK response.
* @li @c -2 - Timeout error.
* @li @c -3 - Command error.
* @li @c -4 - Unknown error.
* See #err_t definition for detailed explanation.
*/
static err_t ltecat13ex_cfg_for_example ( void );
/**
* @brief Execute example.
* @details This function executes SMS, TCP/UDP or CALL example depending on the DEMO_EXAMPLE macro.
* @return @li @c 0 - OK response.
* @li @c -2 - Timeout error.
* @li @c -3 - Command error.
* @li @c -4 - Unknown error.
* See #err_t definition for detailed explanation.
*/
static err_t ltecat13ex_example( void );
/**
* @brief GNSS parser application.
* @details This function logs GNSS data on the USB UART and stores data in gnss_info_message buffer.
* @param rsp Response buffer.
* @note None.
*/
static void gnss_parser_application ( char *rsp ) ;
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
ltecat13ex_cfg_t ltecat13ex_cfg; /**< Click config object. */
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
ltecat13ex_cfg_setup( <ecat13ex_cfg );
LTECAT13EX_MAP_MIKROBUS( ltecat13ex_cfg, MIKROBUS_1 );
if ( UART_ERROR == ltecat13ex_init( <ecat13ex, <ecat13ex_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
ltecat13ex_process( );
ltecat13ex_clear_app_buf( );
Delay_ms ( 1000 );
if ( 0 == ltecat13ex_get_ri_pin( <ecat13ex ) )
{
ltecat13ex_start_up( <ecat13ex );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_RDY );
ltecat13ex_error_check( error_flag );
}
// Restart device
#define MIN_FUN_DEVICE "0"
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_CFUN, MIN_FUN_DEVICE );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
ltecat13ex_error_check( error_flag );
#define FULL_FUN_DEVICE "1"
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_CFUN, FULL_FUN_DEVICE );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
ltecat13ex_error_check( error_flag );
// Check communication
ltecat13ex_send_cmd( <ecat13ex, LTECAT13EX_CMD_AT );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
ltecat13ex_error_check( error_flag );
log_info( &logger, " Application Task " );
example_state = LTECAT13EX_CONFIGURE_FOR_NETWORK;
}
void application_task ( void )
{
switch ( example_state )
{
case LTECAT13EX_CONFIGURE_FOR_NETWORK:
{
if ( LTECAT13EX_OK == ltecat13ex_cfg_for_network( ) )
{
example_state = LTECAT13EX_WAIT_FOR_CONNECTION;
}
break;
}
case LTECAT13EX_WAIT_FOR_CONNECTION:
{
if ( LTECAT13EX_OK == ltecat13ex_check_connection( ) )
{
example_state = LTECAT13EX_CONFIGURE_FOR_EXAMPLE;
}
break;
}
case LTECAT13EX_CONFIGURE_FOR_EXAMPLE:
{
if ( LTECAT13EX_OK == ltecat13ex_cfg_for_example( ) )
{
example_state = LTECAT13EX_EXAMPLE;
}
break;
}
case LTECAT13EX_EXAMPLE:
{
ltecat13ex_example( );
break;
}
default:
{
log_error( &logger, " Example state." );
break;
}
}
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
static void ltecat13ex_clear_app_buf ( void )
{
memset( app_buf, 0, app_buf_len );
app_buf_len = 0;
}
static void ltecat13ex_log_app_buf ( void )
{
for ( int32_t buf_cnt = 0; buf_cnt < app_buf_len; buf_cnt++ )
{
log_printf( &logger, "%c", app_buf[ buf_cnt ] );
}
log_printf( &logger, "============================\r\n" );
}
static err_t ltecat13ex_process ( void )
{
uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
int32_t overflow_bytes = 0;
int32_t rx_cnt = 0;
int32_t rx_size = ltecat13ex_generic_read( <ecat13ex, rx_buf, PROCESS_BUFFER_SIZE );
if ( ( rx_size > 0 ) && ( rx_size <= APP_BUFFER_SIZE ) )
{
if ( ( app_buf_len + rx_size ) > APP_BUFFER_SIZE )
{
overflow_bytes = ( app_buf_len + rx_size ) - APP_BUFFER_SIZE;
app_buf_len = APP_BUFFER_SIZE - rx_size;
memmove ( app_buf, &app_buf[ overflow_bytes ], app_buf_len );
memset ( &app_buf[ app_buf_len ], 0, overflow_bytes );
}
for ( rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ )
{
if ( rx_buf[ rx_cnt ] )
{
app_buf[ app_buf_len++ ] = rx_buf[ rx_cnt ];
}
}
return LTECAT13EX_OK;
}
return LTECAT13EX_ERROR;
}
static err_t ltecat13ex_rsp_check ( uint8_t *rsp )
{
uint32_t timeout_cnt = 0;
uint32_t timeout = 10000;
err_t error_flag = ltecat13ex_process( );
if ( ( LTECAT13EX_OK != error_flag ) && ( LTECAT13EX_ERROR != error_flag ) )
{
return error_flag;
}
while ( ( 0 == strstr( app_buf, rsp ) ) &&
( 0 == strstr( app_buf, LTECAT13EX_RSP_ERROR ) ) )
{
error_flag = ltecat13ex_process( );
if ( ( LTECAT13EX_OK != error_flag ) && ( LTECAT13EX_ERROR != error_flag ) )
{
return error_flag;
}
if ( timeout_cnt++ > timeout )
{
ltecat13ex_clear_app_buf( );
return LTECAT13EX_ERROR_TIMEOUT;
}
Delay_ms ( 1 );
}
if ( strstr( app_buf, rsp ) )
{
return LTECAT13EX_OK;
}
else if ( strstr( app_buf, LTECAT13EX_RSP_ERROR ) )
{
return LTECAT13EX_ERROR_CMD;
}
else
{
return LTECAT13EX_ERROR_UNKNOWN;
}
}
static void ltecat13ex_error_check( err_t error_flag )
{
switch ( error_flag )
{
case LTECAT13EX_OK:
{
ltecat13ex_log_app_buf( );
break;
}
case LTECAT13EX_ERROR:
{
log_error( &logger, " Overflow!" );
break;
}
case LTECAT13EX_ERROR_TIMEOUT:
{
log_error( &logger, " Timeout!" );
break;
}
case LTECAT13EX_ERROR_CMD:
{
ltecat13ex_send_cmd( <ecat13ex, LTECAT13EX_CMD_QIGETERROR );
ltecat13ex_log_app_buf( );
break;
}
case LTECAT13EX_ERROR_UNKNOWN:
default:
{
log_error( &logger, " Unknown!" );
break;
}
}
ltecat13ex_clear_app_buf( );
Delay_ms ( 500 );
}
static err_t ltecat13ex_cfg_for_network( void )
{
err_t func_error = LTECAT13EX_OK;
#if ( ( DEMO_EXAMPLE == EXAMPLE_TCP_UDP ) || ( DEMO_EXAMPLE == EXAMPLE_SMS ) || ( DEMO_EXAMPLE == EXAMPLE_CALL ) || ( DEMO_EXAMPLE == EXAMPLE_GNSS ) )
// Deregister from network
#define DEREGISTER_FROM_NETWORK "2"
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_COPS, DEREGISTER_FROM_NETWORK );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
ltecat13ex_error_check( error_flag );
// Set SIM APN
ltecat13ex_set_sim_apn( <ecat13ex, SIM_APN );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
ltecat13ex_error_check( error_flag );
// Enable full functionality
#define FULL_FUNCTIONALITY "1"
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_CFUN, FULL_FUNCTIONALITY );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
ltecat13ex_error_check( error_flag );
// Enable network registartion
#define ENABLE_REG "2"
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_CREG, ENABLE_REG );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
ltecat13ex_error_check( error_flag );
// Automatic registration
#define AUTOMATIC_REGISTRATION "0"
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_COPS, AUTOMATIC_REGISTRATION );
#endif
return func_error;
}
static err_t ltecat13ex_check_connection( void )
{
#if ( ( DEMO_EXAMPLE == EXAMPLE_TCP_UDP ) || ( DEMO_EXAMPLE == EXAMPLE_SMS ) || ( DEMO_EXAMPLE == EXAMPLE_CALL ) )
#define CONNECTED_HOME "+CREG: 2,1"
#define CONNECTED_ROAMING "+CREG: 2,5"
ltecat13ex_send_cmd_check( <ecat13ex, LTECAT13EX_CMD_CREG );
ltecat13ex_process( );
if ( strstr( app_buf, CONNECTED_HOME ) || strstr( app_buf, CONNECTED_ROAMING ) )
{
Delay_ms ( 100 );
ltecat13ex_process( );
ltecat13ex_log_app_buf( );
log_printf( &logger, "\r\n" );
ltecat13ex_clear_app_buf( );
// Check signal quality
ltecat13ex_send_cmd( <ecat13ex, LTECAT13EX_CMD_CSQ );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
ltecat13ex_error_check( error_flag );
return error_flag;
}
return LTECAT13EX_ERROR;
Delay_ms ( 500 );
#endif
return LTECAT13EX_OK;
}
static err_t ltecat13ex_cfg_for_example ( void )
{
err_t func_error = LTECAT13EX_OK;
#if ( DEMO_EXAMPLE == EXAMPLE_TCP_UDP )
#define ACTIVATE_CONTEXT "1"
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_QIACT, ACTIVATE_CONTEXT );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
ltecat13ex_error_check( error_flag );
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_QICSGP, ACTIVATE_CONTEXT );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
ltecat13ex_error_check( error_flag );
#elif ( DEMO_EXAMPLE == EXAMPLE_SMS )
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_CMGF, SMS_MODE );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
ltecat13ex_error_check( error_flag );
#define DEFAULT_ALPHABET "\"GSM\""
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_CSCS, DEFAULT_ALPHABET );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
ltecat13ex_error_check( error_flag );
#elif ( DEMO_EXAMPLE == EXAMPLE_CALL )
if ( LTECAT13EX_OK != ltecat13ex_max9860_cfg( <ecat13ex ) )
{
log_error( &logger, " MAX9860 configuration." );
for ( ; ; );
}
#elif ( DEMO_EXAMPLE == EXAMPLE_GNSS )
#define TURN_ON_GPS "1"
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_QGPS, TURN_ON_GPS );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
ltecat13ex_error_check( error_flag );
#else
#error "No demo example selected"
#endif
return func_error;
}
static err_t ltecat13ex_example ( void )
{
err_t func_error = LTECAT13EX_OK;
#if ( DEMO_EXAMPLE == EXAMPLE_TCP_UDP )
uint8_t txt_end[ ] = "\032";
uint8_t cmd_buf[ 100 ] = { 0 };
#define CONTEXT_ID "1"
#define CONNECT_ID_TCP "1"
#define SEVICE_TYPE_TCP "\"TCP\""
#define LOCAL_PORT "0"
#define ACCESS_MODE "0"
#define MAX_READ_SIZE "1500"
// Open TCP socket
strcpy( cmd_buf, CONTEXT_ID );
strcat( cmd_buf, "," );
strcat( cmd_buf, CONNECT_ID_TCP );
strcat( cmd_buf, "," );
strcat( cmd_buf, SEVICE_TYPE_TCP );
strcat( cmd_buf, ",\"" );
strcat( cmd_buf, REMOTE_IP );
strcat( cmd_buf, "\"," );
strcat( cmd_buf, REMOTE_PORT );
strcat( cmd_buf, "," );
strcat( cmd_buf, LOCAL_PORT );
strcat( cmd_buf, "," );
strcat( cmd_buf, ACCESS_MODE );
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_QIOPEN, cmd_buf );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
ltecat13ex_error_check( error_flag );
// Send data to TCP socket
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_QISEND, CONNECT_ID_TCP );
strcpy( cmd_buf, MESSAGE_CONTENT );
strcat( cmd_buf, txt_end );
ltecat13ex_rsp_check( ">" );
ltecat13ex_send_cmd( <ecat13ex, cmd_buf );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_SEND_OK );
func_error |= error_flag;
ltecat13ex_error_check( error_flag );
// Read TCP socket data
strcpy( cmd_buf, CONNECT_ID_TCP );
strcat( cmd_buf, "," );
strcat( cmd_buf, MAX_READ_SIZE );
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_QIRD, cmd_buf );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
ltecat13ex_error_check( error_flag );
// Close TCP socket
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_QICLOSE, CONNECT_ID_TCP );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
Delay_ms ( 1000 );
Delay_ms ( 1000 );
#define CONNECT_ID_UDP "2"
#define SEVICE_TYPE_UDP "\"UDP\""
// Open UDP socket
strcpy( cmd_buf, CONTEXT_ID );
strcat( cmd_buf, "," );
strcat( cmd_buf, CONNECT_ID_UDP );
strcat( cmd_buf, "," );
strcat( cmd_buf, SEVICE_TYPE_UDP );
strcat( cmd_buf, ",\"" );
strcat( cmd_buf, REMOTE_IP );
strcat( cmd_buf, "\"," );
strcat( cmd_buf, REMOTE_PORT );
strcat( cmd_buf, "," );
strcat( cmd_buf, LOCAL_PORT );
strcat( cmd_buf, "," );
strcat( cmd_buf, ACCESS_MODE );
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_QIOPEN, cmd_buf );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
ltecat13ex_error_check( error_flag );
// Send data to UDP socket
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_QISEND, CONNECT_ID_UDP );
strcpy( cmd_buf, MESSAGE_CONTENT );
strcat( cmd_buf, txt_end );
ltecat13ex_rsp_check( ">" );
ltecat13ex_send_cmd( <ecat13ex, cmd_buf );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_SEND_OK );
func_error |= error_flag;
ltecat13ex_error_check( error_flag );
// Read UDP socket data
strcpy( cmd_buf, CONNECT_ID_UDP );
strcat( cmd_buf, "," );
strcat( cmd_buf, MAX_READ_SIZE );
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_QIRD, cmd_buf );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
ltecat13ex_error_check( error_flag );
// Close UDP socket
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_QICLOSE, CONNECT_ID_UDP );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
Delay_ms ( 1000 );
Delay_ms ( 1000 );
#elif ( DEMO_EXAMPLE == EXAMPLE_SMS )
// Check SMS mode
#define CMGF_PDU "+CMGF: 0"
#define CMGF_TXT "+CMGF: 1"
ltecat13ex_send_cmd_check( <ecat13ex, LTECAT13EX_CMD_CMGF );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
if ( strstr( app_buf, CMGF_PDU ) )
{
ltecat13ex_error_check( error_flag );
// Send SMS in PDU mode
ltecat13ex_send_sms_pdu( <ecat13ex, SIM_SMSC, PHONE_NUMBER, MESSAGE_CONTENT );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
}
else if ( strstr( app_buf, CMGF_TXT ) )
{
ltecat13ex_error_check( error_flag );
// Send SMS in TXT mode
ltecat13ex_send_sms_text ( <ecat13ex, PHONE_NUMBER, MESSAGE_CONTENT );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
}
ltecat13ex_error_check( error_flag );
// 30 seconds delay
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
#elif ( DEMO_EXAMPLE == EXAMPLE_CALL )
uint8_t cmd_buf[ 100 ] = { 0 };
strcpy( cmd_buf, LTECAT13EX_CMD_ATD );
ltecat13ex_clear_app_buf( );
strcat( cmd_buf, PHONE_NUMBER );
strcat( cmd_buf, ";" );
log_printf( &logger, " Calling selected number \r\n" );
ltecat13ex_send_cmd( <ecat13ex, cmd_buf );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
ltecat13ex_error_check( error_flag );
ltecat13ex_clear_app_buf( );
log_printf( &logger, "Dialing \r\n" );
#define CHECK_DIALING "+CLCC: 1,0,2"
ltecat13ex_send_cmd( <ecat13ex, LTECAT13EX_CMD_CLCC );
error_flag = ltecat13ex_rsp_check( CHECK_DIALING );
func_error |= error_flag;
ltecat13ex_error_check( error_flag );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
#define CHECK_ANSWERED "+CLCC: 1,0,0"
ltecat13ex_send_cmd( <ecat13ex, LTECAT13EX_CMD_CLCC );
error_flag = ltecat13ex_rsp_check( CHECK_ANSWERED );
while ( LTECAT13EX_OK != error_flag )
{
ltecat13ex_send_cmd( <ecat13ex, LTECAT13EX_CMD_CLCC );
error_flag = ltecat13ex_rsp_check( CHECK_ANSWERED );
}
log_printf( &logger, "Answered \r\n" );
ltecat13ex_error_check( error_flag );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
log_printf( &logger, "Hanging up \r\n" );
ltecat13ex_send_cmd( <ecat13ex, LTECAT13EX_CMD_CHUP );
ltecat13ex_clear_app_buf( );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
ltecat13ex_error_check( error_flag );
ltecat13ex_clear_app_buf( );
// 10 seconds delay
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
#elif ( DEMO_EXAMPLE == EXAMPLE_GNSS )
#define GPS_NEMA_GGA "\"GGA\""
ltecat13ex_send_cmd_with_params( <ecat13ex, LTECAT13EX_CMD_QGPSGNMEA, GPS_NEMA_GGA );
error_flag = ltecat13ex_rsp_check( LTECAT13EX_RSP_OK );
func_error |= error_flag;
gnss_parser_application( app_buf );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
#else
#error "No demo example selected"
#endif
return func_error;
}
static void gnss_parser_application ( char *rsp )
{
char element_buf[ 100 ] = { 0 };
if ( LTECAT13EX_OK == ltecat13ex_parse_gpgga( rsp, LTECAT13EX_GPGGA_LATITUDE, element_buf ) )
{
memset( gnss_info_message, 0, 200 );
if ( strlen( element_buf ) > 0 )
{
strcpy( gnss_info_message, "GNSS info\n\r" );
strcat( gnss_info_message, "Latitude: " );
strncat( gnss_info_message, element_buf, 2 );
strcat( gnss_info_message, " deg, " );
strcat( gnss_info_message, &element_buf[ 2 ] );
strcat( gnss_info_message, " min" );
ltecat13ex_parse_gpgga( rsp, LTECAT13EX_GPGGA_LONGITUDE, element_buf );
strcat( gnss_info_message, "\n\rLongitude: " );
strncat( gnss_info_message, element_buf, 3 );
strcat( gnss_info_message, " deg, " );
strcat( gnss_info_message, &element_buf[ 3 ] );
strcat( gnss_info_message, " min" );
memset( element_buf, 0, sizeof( element_buf ) );
ltecat13ex_parse_gpgga( rsp, LTECAT13EX_GPGGA_ALTITUDE, element_buf );
strcat( gnss_info_message, "\n\rAltitude: " );
strcat( gnss_info_message, element_buf );
strcat( gnss_info_message, " m" );
log_printf( &logger, "%s\r\n", gnss_info_message );
}
else
{
log_printf( &logger, " Waiting for the position fix...\r\n" );
}
log_printf( &logger, "\r\n-----------------------------------\r\n" );
ltecat13ex_clear_app_buf();
}
}
// ------------------------------------------------------------------------ END