我们的 LTE 物联网解决方案将您带入未来的连接时代。通过我们的创新,体验设备、智能和数据的无缝集成,塑造物联网的未来。
A
A
硬件概览
它是如何工作的?
LTE IoT 3 Click 基于 EXS82-W,这是一个低功耗广域(LPWA)无线物联网模块,支持连接到 Thales 的 LTE CAT-M1、CAT NB1/2 和 2G 网络。EXS82 物联网模块支持所有 LTE 频段,并提供高效架构,具备 PSM 和 eDRX 功能以及嵌入式处理能力。EXS82 还包括一个模块服务引擎,支持互联网服务和优化操作。先进的安全功能保护设备和数据,并提供安全的云平台注册,增强物联网生态系统的信任。模块的简化电源设计和高级管理系统延长了电池寿命,降低了总拥有成本。集成的 GNSS 接收器通过 ASC0 接口支持 NMEA 协议,代表了各种电子设备之间(包括 GNSS 接收器)的电气和数据通信规格。默认情况下,GNSS 接收器处于关闭状态,需要使用 AT 命令打开和配置。此 Click board™ 配备了一个 USB Type C 接口,允许模块通过个人计算机(PC)使用
FT230X 供电和配置。FT230X 是一个紧凑的 USB 到基本串行 UART 接口设备,设计为尽可能高效地与 USB 主机控制器一起工作,使用的 USB 带宽尽可能少。UART 接口以 115200 bps 的速率运行,与主机交换 AT 命令、数据传输和固件更新。它还具有 RX/TX LED 指示灯,用于指示桥接处于 RX 还是 TX 功能。LTE IoT 3 Click 可以电池供电并用作独立设备。它还具有 MC34671,这是一个全集成的锂离子或锂聚合物电池充电器,允许在 Click board™ 插入 mikroBUS™ 插座或插入 USB 端口时充电。充电中的 CHG LED 指示灯将在充电完成后熄灭。Click board™ 背面的 Nano SIM 卡插槽用于安装 Nano SIM 卡。两个阻抗为 50Ω 的 SMA 天线连接器用于连接合适的天线。一个 SMA 连接器用于 LTE 天线,另一个用于 GNSS 天线,支持使用 3V 或 5V 供电的有源
天线,供电电压可通过相应的跳线(J2 或 J3)选择。标有 STAT 的黄色 LED 用于直观地指示模块的不同工作模式。另一个指示灯 PWI LED 指示模块的电源状态,显示其是否处于活动状态或掉电模式。板载标有 ON 的按钮连接到 mikroBUS™ 上的 RST 引脚,代表点火按钮。此 Click Board™ 使用 UART 通信接口,但用户也可以使用其他接口,例如 SPI 和 I2C,如果用户希望将模块配置为 SPI 或 I2C 主机并自行编写库。通过在板背面填充适当的跳线(J4 – J9),可以实现所需的通信。此 Click board™ 可以与 3.3V 和 5V MCU 接口,因为适当的电压电平转换器执行适当的逻辑电压电平转换,而板载 LDO 确保模块由推荐的电压电平供电。
功能概述
开发板
Clicker 2 for Kinetis 是一款紧凑型入门开发板,它将 Click 板™的灵活性带给您喜爱的微控制器,使其成为实现您想法的完美入门套件。它配备了一款板载 32 位 ARM Cortex-M4F 微控制器,NXP 半导体公司的 MK64FN1M0VDC12,两个 mikroBUS™ 插槽用于 Click 板™连接,一个 USB 连接器,LED 指示灯,按钮,一个 JTAG 程序员连接器以及两个 26 针头用于与外部电子设备的接口。其紧凑的设计和清晰、易识别的丝网标记让您能够迅速构建具有独特功能和特性
的小工具。Clicker 2 for Kinetis 开发套件的每个部分 都包含了使同一板块运行最高效的必要组件。除了可以选择 Clicker 2 for Kinetis 的编程方式,使用 USB HID mikroBootloader 或外部 mikroProg 连接器进行 Kinetis 编程外,Clicker 2 板还包括一个干净且调节过的开发套件电源供应模块。它提供了两种供电方式;通过 USB Micro-B 电缆,其中板载电压调节器为板上每个组件提供适当的电压水平,或使用锂聚合物 电池通过板载电池连接器供电。所有 mikroBUS™ 本
身支持的通信方法都在这块板上,包括已经建立良好的 mikroBUS™ 插槽、重置按钮和几个用户可配置的按钮及 LED 指示灯。Clicker 2 for Kinetis 是 Mikroe 生态系统的一个组成部分,允许您在几分钟内创建新的应用程序。它由 Mikroe 软件工具原生支持,得益于大量不同的 Click 板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作的许多方面。
微控制器概述
MCU卡片 / MCU

建筑
ARM Cortex-M4
MCU 内存 (KB)
1024
硅供应商
NXP
引脚数
121
RAM (字节)
262144
你完善了我!
配件
LTE Flat Rotation Antenna 是增强 3G/4G LTE 设备性能的多功能选择。其宽频率范围为 700-2700MHz,确保在全球主要蜂窝频段上实现最佳连接。这款平板天线具有 SMA 公接头,便于直接连接到您的设备或 SMA 模块接头。其显著特点之一是其可调角度,可按 45° 的增量设置(0°/45°/90°),允许您微调天线的方向以实现最大信号接收。该天线具有 50Ω 的阻抗和 <2.0:1 的 VSW 比率,确保可靠和高效的连接。凭借 5dB 增益、垂直极化和全向辐射模式,它增强了信号强度,适用于各种应用。天线尺寸为 196mm 长,38mm 宽,提供紧凑且有效的连接改进解决方案。其最大输入功率为 50W,能够满足各种设备的需求。
使用的MCU引脚
mikroBUS™映射器
“仔细看看!”
Click board™ 原理图

一步一步来
项目组装
软件支持
库描述
该库包含 LTE IoT 3 Click 驱动程序的 API。
关键功能:
lteiot3_set_sim_apn- 设置 SIM 卡 APN 的功能lteiot3_send_sms_text- 发送短信到手机号码的功能lteiot3_parse_gga- 解析读取响应缓冲区中的 GGA 数据的功能
开源
代码示例
完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio。 应用程序代码也可以在MIKROE的GitHub账户中找到。
/*!
* @file main.c
* @brief LTE IoT 3 Click Example.
*
* # Description
* Application example shows device capability of connecting to the network and
* sending SMS or TCP/UDP messages, or retrieving data from GNSS using standard "AT" commands.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver, tests the communication by sending "AT" command, and after that restarts the device.
*
* ## Application Task
* Application task is split in few stages:
* - LTEIOT3_CONFIGURE_FOR_NETWORK:
* Sets configuration to device to be able to connect to the network. (used only for SMS or TCP/UDP demo examples).
*
* - LTEIOT3_WAIT_FOR_CONNECTION:
* Waits for the network registration indicated via CREG URC event and then checks
* the connection status (used only for SMS or TCP/UDP demo examples).
*
* - LTEIOT3_CONFIGURE_FOR_EXAMPLE:
* Sets the device configuration for sending SMS or TCP/UDP messages or for retrieving data from GNSS
* depending on the selected demo example.
*
* - LTEIOT3_EXAMPLE:
* Depending on the selected demo example, it sends an SMS message (in PDU or TXT mode) or TCP/UDP message or
* waits for the GPS fix to retrieve location info from GNSS.
*
* By default, the TCP/UDP example is selected.
*
* ## Additional Function
* - static void lteiot3_clear_app_buf ( void )
* - static err_t lteiot3_process ( void )
* - static void lteiot3_error_check( err_t error_flag )
* - static void lteiot3_log_app_buf ( void )
* - static err_t lteiot3_rsp_check ( uint8_t *rsp )
* - static err_t lteiot3_configure_for_connection( void )
* - static err_t lteiot3_check_connection( void )
* - static err_t lteiot3_configure_for_messages( void )
* - static err_t lteiot3_send_message( void )
*
* @note
* In order for the examples to work (except GNSS example), 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 Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "lteiot3.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_GNSS 2 // Example of retrieving location info from GNSS
#define DEMO_EXAMPLE EXAMPLE_TCP_UDP // Example selection macro
// SIM APN config
#define SIM_APN "" // Set valid SIM APN
// SMS example parameters
#define SIM_SMSC "" // Set valid SMS Service Center Address - only in SMS PDU mode
#define PHONE_NUMBER_TO_MESSAGE "" // Set Phone number to message
#define SMS_MODE "1" // 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 IoT 3 Click board - demo example."
// Application buffer size
#define APP_BUFFER_SIZE 256
#define PROCESS_BUFFER_SIZE 256
/**
* @brief Example states.
* @details Predefined enum values for application example state.
*/
typedef enum
{
LTEIOT3_CONFIGURE_FOR_NETWORK = 1,
LTEIOT3_WAIT_FOR_CONNECTION,
LTEIOT3_CONFIGURE_FOR_EXAMPLE,
LTEIOT3_EXAMPLE
} lteiot3_example_state_t;
static lteiot3_t lteiot3;
static log_t logger;
/**
* @brief Application example variables.
* @details Variables used in application example.
*/
static uint8_t app_buf[ APP_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;
static err_t error_flag;
static lteiot3_example_state_t example_state;
/**
* @brief Clearing application buffer.
* @details This function clears memory of application
* buffer and reset its length and counter.
*/
static void lteiot3_clear_app_buf ( void );
/**
* @brief Data reading function.
* @details This function reads data from device and
* appends it to the application buffer.
* @return @li @c 0 - Some data is read.
* @li @c -1 - Nothing is read.
* See #err_t definition for detailed explanation.
*/
static err_t lteiot3_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 lteiot3_error_check( err_t error_flag );
/**
* @brief Logs application buffer.
* @details This function logs data from application buffer.
*/
static void lteiot3_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 lteiot3_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 lteiot3_configure_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 lteiot3_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 lteiot3_configure_for_example( void );
/**
* @brief Execute example.
* @details This function executes SMS, TCP/UDP or GNSS 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 lteiot3_example( void );
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
lteiot3_cfg_t lteiot3_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.
lteiot3_cfg_setup( <eiot3_cfg );
LTEIOT3_MAP_MIKROBUS( lteiot3_cfg, MIKROBUS_1 );
if ( UART_ERROR == lteiot3_init( <eiot3, <eiot3_cfg ) )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
lteiot3_process( );
lteiot3_clear_app_buf( );
// Check communication
lteiot3_send_cmd( <eiot3, LTEIOT3_CMD_AT );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
lteiot3_error_check( error_flag );
// Restart device
#define RESTART_DEVICE "1,1"
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_CFUN, RESTART_DEVICE );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_SYSSTART );
lteiot3_error_check( error_flag );
log_info( &logger, " Application Task " );
example_state = LTEIOT3_CONFIGURE_FOR_NETWORK;
}
void application_task ( void )
{
switch ( example_state )
{
case LTEIOT3_CONFIGURE_FOR_NETWORK:
{
if ( LTEIOT3_OK == lteiot3_configure_for_network( ) )
{
example_state = LTEIOT3_WAIT_FOR_CONNECTION;
}
break;
}
case LTEIOT3_WAIT_FOR_CONNECTION:
{
if ( LTEIOT3_OK == lteiot3_check_connection( ) )
{
example_state = LTEIOT3_CONFIGURE_FOR_EXAMPLE;
}
break;
}
case LTEIOT3_CONFIGURE_FOR_EXAMPLE:
{
if ( LTEIOT3_OK == lteiot3_configure_for_example( ) )
{
example_state = LTEIOT3_EXAMPLE;
}
break;
}
case LTEIOT3_EXAMPLE:
{
lteiot3_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 lteiot3_clear_app_buf ( void )
{
memset( app_buf, 0, app_buf_len );
app_buf_len = 0;
}
static err_t lteiot3_process ( void )
{
uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
int32_t rx_size = 0;
rx_size = lteiot3_generic_read( <eiot3, rx_buf, PROCESS_BUFFER_SIZE );
if ( rx_size > 0 )
{
int32_t buf_cnt = app_buf_len;
if ( ( ( app_buf_len + rx_size ) > APP_BUFFER_SIZE ) && ( app_buf_len > 0 ) )
{
buf_cnt = APP_BUFFER_SIZE - ( ( app_buf_len + rx_size ) - APP_BUFFER_SIZE );
memmove ( app_buf, &app_buf[ APP_BUFFER_SIZE - buf_cnt ], buf_cnt );
}
for ( int32_t rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ )
{
if ( rx_buf[ rx_cnt ] )
{
app_buf[ buf_cnt++ ] = rx_buf[ rx_cnt ];
if ( app_buf_len < APP_BUFFER_SIZE )
{
app_buf_len++;
}
}
}
return LTEIOT3_OK;
}
return LTEIOT3_ERROR;
}
static err_t lteiot3_rsp_check ( uint8_t *rsp )
{
uint32_t timeout_cnt = 0;
uint32_t timeout = 120000;
err_t error_flag = lteiot3_process( );
if ( ( LTEIOT3_OK != error_flag ) && ( LTEIOT3_ERROR != error_flag ) )
{
return error_flag;
}
while ( ( 0 == strstr( app_buf, rsp ) ) &&
( 0 == strstr( app_buf, LTEIOT3_RSP_ERROR ) ) )
{
error_flag = lteiot3_process( );
if ( ( LTEIOT3_OK != error_flag ) && ( LTEIOT3_ERROR != error_flag ) )
{
return error_flag;
}
if ( timeout_cnt++ > timeout )
{
lteiot3_clear_app_buf( );
return LTEIOT3_ERROR_TIMEOUT;
}
Delay_ms ( 1 );
}
if ( strstr( app_buf, rsp ) )
{
return LTEIOT3_OK;
}
else if ( strstr( app_buf, LTEIOT3_RSP_ERROR ) )
{
return LTEIOT3_ERROR_CMD;
}
else
{
return LTEIOT3_ERROR_UNKNOWN;
}
}
static void lteiot3_error_check( err_t error_flag )
{
switch ( error_flag )
{
case LTEIOT3_OK:
{
lteiot3_log_app_buf( );
break;
}
case LTEIOT3_ERROR:
{
log_error( &logger, " Overflow!" );
break;
}
case LTEIOT3_ERROR_TIMEOUT:
{
log_error( &logger, " Timeout!" );
break;
}
case LTEIOT3_ERROR_CMD:
{
log_error( &logger, " CMD!" );
break;
}
case LTEIOT3_ERROR_UNKNOWN:
default:
{
log_error( &logger, " Unknown!" );
break;
}
}
lteiot3_clear_app_buf( );
Delay_ms ( 500 );
}
static void lteiot3_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 ] );
}
}
static err_t lteiot3_configure_for_network( void )
{
err_t func_error = LTEIOT3_OK;
#if ( ( DEMO_EXAMPLE == EXAMPLE_TCP_UDP ) || ( DEMO_EXAMPLE == EXAMPLE_SMS ) )
// Deregister from network
#define DEREGISTER_FROM_NETWORK "2"
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_COPS, DEREGISTER_FROM_NETWORK );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
// Set SIM APN
lteiot3_set_sim_apn( <eiot3, SIM_APN );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
// Enable full functionality
#define FULL_FUNCTIONALITY "1"
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_CFUN, FULL_FUNCTIONALITY );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
// Enable network registartion
#define ENABLE_REG "2"
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_CREG, ENABLE_REG );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
// Automatic registration
#define AUTOMATIC_REGISTRATION "0"
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_COPS, AUTOMATIC_REGISTRATION );
#endif
return func_error;
}
static err_t lteiot3_check_connection( void )
{
#if ( ( DEMO_EXAMPLE == EXAMPLE_TCP_UDP ) || ( DEMO_EXAMPLE == EXAMPLE_SMS ) )
#define CONNECTED "+CREG: 1"
lteiot3_process( );
if ( strstr( app_buf, CONNECTED ) )
{
Delay_ms ( 100 );
lteiot3_process( );
lteiot3_log_app_buf( );
log_printf( &logger, "\r\n" );
lteiot3_clear_app_buf( );
// Check signal quality
lteiot3_send_cmd( <eiot3, LTEIOT3_CMD_CESQ );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
lteiot3_error_check( error_flag );
return error_flag;
}
return LTEIOT3_ERROR;
#endif
return LTEIOT3_OK;
}
static err_t lteiot3_configure_for_example( void )
{
err_t func_error = LTEIOT3_OK;
#if ( DEMO_EXAMPLE == EXAMPLE_TCP_UDP )
#define ACTIVATE_PDP_CONTEXT "1,1"
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SICA, ACTIVATE_PDP_CONTEXT );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
#define REQ_DYNAMIC_IP "1"
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_CGPADDR, REQ_DYNAMIC_IP );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
#elif ( DEMO_EXAMPLE == EXAMPLE_SMS )
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_CMGF, SMS_MODE );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
#elif ( DEMO_EXAMPLE == EXAMPLE_GNSS )
#define GNNS_START_MODE_EN "\"Engine/StartMode\",0"
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SGPSC, GNNS_START_MODE_EN );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
#define GNNS_START_GPS "\"Nmea/GPS\",\"on\""
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SGPSC, GNNS_START_GPS );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
#define GNSS_POWER_UP "\"Engine\",3"
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SGPSC, GNSS_POWER_UP );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
#else
#error "No demo example selected"
#endif
return func_error;
}
static err_t lteiot3_example( void )
{
err_t func_error = LTEIOT3_OK;
#if ( DEMO_EXAMPLE == EXAMPLE_TCP_UDP )
uint8_t cmd_buf[ 100 ] = { 0 };
uint8_t tcp_socket_num[ 2 ] = { '0', 0 };
uint8_t udp_socket_num[ 2 ] = { '1', 0 };
// Select service type Socket.
#define SRVTYPE_SOCKET ",srvtype,\"socket\""
strcpy( cmd_buf, tcp_socket_num );
strcat( cmd_buf, SRVTYPE_SOCKET );
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SISS, cmd_buf );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
strcpy( cmd_buf, udp_socket_num );
strcat( cmd_buf, SRVTYPE_SOCKET );
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SISS, cmd_buf );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
// Select connection profile.
#define CONN_PROFILE ",conid,\"1\""
strcpy( cmd_buf, tcp_socket_num );
strcat( cmd_buf, CONN_PROFILE );
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SISS, cmd_buf );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
strcpy( cmd_buf, udp_socket_num );
strcat( cmd_buf, CONN_PROFILE );
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SISS, cmd_buf );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
// Choose ASCII alphabet.
#define ASCII_ALPHABET ",alphabet,1"
strcpy( cmd_buf, tcp_socket_num );
strcat( cmd_buf, ASCII_ALPHABET );
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SISS, cmd_buf );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
strcpy( cmd_buf, udp_socket_num );
strcat( cmd_buf, ASCII_ALPHABET );
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SISS, cmd_buf );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
// Specify the TCP remote IP and port
#define ADDRESS_TCP ",address,\"socktcp://"
strcpy( cmd_buf, tcp_socket_num );
strcat( cmd_buf, ADDRESS_TCP );
strcat( cmd_buf, REMOTE_IP );
strcat( cmd_buf, ":" );
strcat( cmd_buf, REMOTE_PORT );
strcat( cmd_buf, "\"" );
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SISS, cmd_buf );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
// Specify the UDP remote IP and port
#define ADDRESS_UDP ",address,\"sockudp://"
strcpy( cmd_buf, udp_socket_num );
strcat( cmd_buf, ADDRESS_UDP );
strcat( cmd_buf, REMOTE_IP );
strcat( cmd_buf, ":" );
strcat( cmd_buf, REMOTE_PORT );
strcat( cmd_buf, "\"" );
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SISS, cmd_buf );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
// Open TCP socket
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SISO, tcp_socket_num );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
// Open UDP socket
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SISO, udp_socket_num );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
// Get message length
uint8_t message_len_buf[ 10 ] = { 0 };
uint16_t message_len = strlen( MESSAGE_CONTENT );
uint16_to_str( message_len, message_len_buf );
l_trim( message_len_buf );
r_trim( message_len_buf );
// Write message to TCP socket and read response
strcpy( cmd_buf, tcp_socket_num );
strcat( cmd_buf, "," );
strcat( cmd_buf, message_len_buf );
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SISW, cmd_buf );
Delay_ms ( 100 );
lteiot3_generic_write ( <eiot3, MESSAGE_CONTENT, message_len );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
Delay_ms ( 1000 );
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SISR, cmd_buf );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
// Write message to UDP socket and read response
strcpy( cmd_buf, udp_socket_num );
strcat( cmd_buf, "," );
strcat( cmd_buf, message_len_buf );
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SISW, cmd_buf );
Delay_ms ( 100 );
lteiot3_generic_write ( <eiot3, MESSAGE_CONTENT, message_len );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
Delay_ms ( 1000 );
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SISR, cmd_buf );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
// Close TCP socket
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SISC, tcp_socket_num );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
// Close UDP socket
lteiot3_send_cmd_with_parameter( <eiot3, LTEIOT3_CMD_SISC, udp_socket_num );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
lteiot3_error_check( error_flag );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
#elif ( DEMO_EXAMPLE == EXAMPLE_SMS )
// Check SMS mode
#define CMGF_PDU "+CMGF: 0"
#define CMGF_TXT "+CMGF: 1"
lteiot3_send_cmd_check( <eiot3, LTEIOT3_CMD_CMGF );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
if ( strstr( app_buf, CMGF_PDU ) )
{
lteiot3_error_check( error_flag );
// Send SMS in PDU mode
lteiot3_send_sms_pdu( <eiot3, SIM_SMSC, PHONE_NUMBER_TO_MESSAGE, MESSAGE_CONTENT );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
}
else if ( strstr( app_buf, CMGF_TXT ) )
{
lteiot3_error_check( error_flag );
// Send SMS in TXT mode
lteiot3_send_sms_text ( <eiot3, PHONE_NUMBER_TO_MESSAGE, MESSAGE_CONTENT );
error_flag = lteiot3_rsp_check( LTEIOT3_RSP_OK );
func_error |= error_flag;
}
lteiot3_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_GNSS )
lteiot3_process ( );
if ( app_buf_len > ( sizeof ( LTEIOT3_RSP_GGA ) + LTEIOT3_GGA_ELEMENT_SIZE ) )
{
uint8_t element_buf[ 100 ] = { 0 };
if ( LTEIOT3_OK == lteiot3_parse_gga( app_buf, LTEIOT3_GGA_LATITUDE, element_buf ) )
{
static uint8_t wait_for_fix_cnt = 0;
if ( strlen( element_buf ) > 0 )
{
log_printf( &logger, "\r\n Latitude: %.2s degrees, %s minutes \r\n", element_buf, &element_buf[ 2 ] );
lteiot3_parse_gga( app_buf, LTEIOT3_GGA_LONGITUDE, element_buf );
log_printf( &logger, " Longitude: %.3s degrees, %s minutes \r\n", element_buf, &element_buf[ 3 ] );
memset( element_buf, 0, sizeof( element_buf ) );
lteiot3_parse_gga( app_buf, LTEIOT3_GGA_ALTITUDE, element_buf );
log_printf( &logger, " Altitude: %s m \r\n", element_buf );
wait_for_fix_cnt = 0;
}
else
{
if ( wait_for_fix_cnt % 5 == 0 )
{
log_printf( &logger, " Waiting for the position fix...\r\n\n" );
wait_for_fix_cnt = 0;
}
wait_for_fix_cnt++;
}
lteiot3_clear_app_buf( );
}
}
#else
#error "No demo example selected"
#endif
return func_error;
}
// ------------------------------------------------------------------------ END
额外支持
资源
类别:LTE 物联网


































