中级
30 分钟

借助SARA-R412M和STM32F031K6重新定义您连接物联网生态系统的方式

探索新的前景

LTE IoT 6 Click with Nucleo 32 with STM32F031K6 MCU

已发布 10月 01, 2024

点击板

LTE IoT 6 Click

开发板

Nucleo 32 with STM32F031K6 MCU

编译器

NECTO Studio

微控制器单元

STM32F031K6

发现一种更智能的物联网连接方式,使用LTE物联网技术,在CAT M1和NB1技术的协同作用下,让您的设备高效、有效地进行通信。

A

A

硬件概览

它是如何工作的?

LTE IoT 6 Click基于SARA-R412M,这是一个超紧凑的LTE Cat M1/NB1和EGPRS模块,具有多区域覆盖,数据通信速度高达1200 kbit/s,由u-Blox提供。它通过安全通信协议确保应用之间的数据完整性,包括客户端和服务器之间的双向认证,这种策略常用于云服务。u-Blox的嵌套设计原则使SARA模块与其他u-Blox产品系列兼容,便于从2G、3G和4G的轻松迁移。SARA-R412M模块旨在实现长寿命、低维护、低功耗和延长电池寿命的应用。它是关键任务物联网解决方案的理想选择,因为它们包含唯一且不可变的信任根。该模块需要3.8V的电源。因此,Click板™集成了由德州仪器(Texas Instruments)标记为TPS7A7002的低压差(LDO)稳压器。该IC可以输出高达3A的电流,保持卓越的调节性能。其任务是提供稳定的3.8V电源,能够在高电流峰值出现时(通常在设备启动时)减轻输入电压下降的影响。SARA-R412M使用常用的UART RX和TX

引脚以及硬件流控制引脚UART CTS、RTS、RI(Clear to Send、Ready to Send和Ring Indicator)通过UART接口与MCU通信。它支持自动波特率检测,默认配置为115200 bps,用于数据传输和与主机MCU交换AT命令。此Click板™还符合USB 2.0标准,配备了USB Type C连接器,最大480 Mbit/s的数据速率仅用于诊断目的。该模块作为USB设备,可以连接到任何带有兼容驱动程序的USB主机。板载标记为PWR的按钮连接到mikroBUS™插槽上的AN引脚,表示点火(电源开)按钮,其功能可以通过标记为STAT的黄色LED来显示,指示设备的操作状态。如果设备已通电,在此引脚上持续1.5秒的低脉冲将关闭模块。也可以通过发出AT+CPWROFF命令或通过mikroBUS™插槽上的RST引脚上的复位功能,通过在此引脚上发送持续10秒的有效低输入,导致强制断电(强制断电)来关闭模块。除了STAT LED外,此Click板™还有一个额外的LED指示灯,

一个标记为TX的红色LED用于指示网络状态。LTE IoT 6 Click有一个阻抗为50Ω的SMA天线连接器,可以用来连接MIKROE提供的适当天线。除了LTE SMA连接器外,此Click板™还有一个nano-SIM卡插槽,提供多种连接和接口选项。未焊接的标记为J1的插针允许您访问SARA模块的可配置GPIO和EXT中断引脚,而标记为TP1到TP6的测试点则允许您轻松进行FW升级和模块测试。客户可以通过空中固件更新来保障他们的解决方案,得益于uFOTA客户端/服务器解决方案,该解决方案利用LWM2M,这是一种轻便且紧凑的协议,非常适合物联网。我们还提供了直接连接到TxD和RxD引脚的可访问测试点,用于FW升级目的。此Click板™可以与3.3V和5V的MCU接口,可以通过标记为VCC SEL的跳线设置,因为适当的电压电平转换器会执行适当的逻辑电压电平转换,而板载LDO则确保模块由推荐的电压水平供电。

LTE IoT 6 Click hardware overview image

功能概述

开发板

Nucleo 32开发板搭载STM32F031K6 MCU,提供了一种经济且灵活的平台,适用于使用32引脚封装的STM32微控制器进行实验。该开发板具有Arduino™ Nano连接性,便于通过专用扩展板进行功能扩展,并且支持mbed,使其能够无缝集成在线资源。板载集成

ST-LINK/V2-1调试器/编程器,支持通过USB重新枚举,提供三种接口:虚拟串口(Virtual Com port)、大容量存储和调试端口。该开发板的电源供应灵活,可通过USB VBUS或外部电源供电。此外,还配备了三个LED指示灯(LD1用于USB通信,LD2用于电源

指示,LD3为用户可控LED)和一个复位按钮。STM32 Nucleo-32开发板支持多种集成开发环境(IDEs),如IAR™、Keil®和基于GCC的IDE(如AC6 SW4STM32),使其成为开发人员的多功能工具。

Nucleo 32 with STM32F031K6 MCU double side image

微控制器概述 

MCU卡片 / MCU

default

建筑

ARM Cortex-M0

MCU 内存 (KB)

32

硅供应商

STMicroelectronics

引脚数

32

RAM (字节)

4096

你完善了我!

配件

Click Shield for Nucleo-32是扩展您的开发板功能的理想选择,专为STM32 Nucleo-32引脚布局设计。Click Shield for Nucleo-32提供了两个mikroBUS™插座,可以添加来自我们不断增长的Click板™系列中的任何功能。从传感器和WiFi收发器到电机控制和音频放大器,我们应有尽有。Click Shield for Nucleo-32与STM32 Nucleo-32开发板兼容,为用户提供了一种经济且灵活的方式,使用任何STM32微控制器快速创建原型,并尝试各种性能、功耗和功能的组合。STM32 Nucleo-32开发板无需任何独立的探针,因为它集成了ST-LINK/V2-1调试器/编程器,并随附STM32全面的软件HAL库和各种打包的软件示例。这个开发平台为用户提供了一种简便且通用的方式,将STM32 Nucleo-32兼容开发板与他们喜欢的Click板™结合,应用于即将开展的项目中。

Click Shield for Nucleo-32 accessories 1 image

LTE平板旋转天线是一种多功能选择,可以提升3G/4G LTE设备的性能。其宽频率范围为700-2700MHz,确保在全球主要蜂窝频段上实现最佳连接。这款平板天线配备SMA公头连接器,可以轻松直接连接到您的设备或SMA模块连接器。其突出特点之一是可调角度,可以以45度增量(0度/45度/90度)进行设置,让您微调天线的方向以获得最大信号接收。该天线的阻抗为50Ω,电压驻波比(VSW比)小于2.0:1,确保可靠高效的连接。5dB增益、垂直极化和全向辐射模式增强了信号强度,使其适用于各种应用。天线长度为196毫米,宽度为38毫米,提供紧凑但有效的解决方案来改善您的连接。其最大输入功率为50W,能够应对各种设备的需求。

LTE IoT 6 Click accessories image

使用的MCU引脚

mikroBUS™映射器

Power-On
PA0
AN
Reset
PA11
RST
UART RTS
PA4
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
UART RI
PA8
PWM
UART CTS
PA12
INT
UART TX
PA10
TX
UART RX
PA9
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

LTE IoT 6 Click Schematic schematic

一步一步来

项目组装

Click Shield for Nucleo-144 front image hardware assembly

从选择您的开发板和Click板™开始。以Nucleo 32 with STM32F031K6 MCU作为您的开发板开始。

Click Shield for Nucleo-144 front image hardware assembly
Nucleo 144 with STM32L4A6ZG MCU front image hardware assembly
Stepper 22 Click front image hardware assembly
Prog-cut hardware assembly
Stepper 22 Click complete accessories setup image hardware assembly
Board mapper by product8 hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
STM32 M4 Clicker HA MCU/Select Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

实时跟踪您的结果

应用程序输出

1. 应用程序输出 - 在调试模式下,“应用程序输出”窗口支持实时数据监控,直接提供执行结果的可视化。请按照提供的教程正确配置环境,以确保数据正确显示。

2. UART 终端 - 使用UART Terminal通过USB to UART converter监视数据传输,实现Click board™与开发系统之间的直接通信。请根据项目需求配置波特率和其他串行设置,以确保正常运行。有关分步设置说明,请参考提供的教程

3. Plot 输出 - Plot功能提供了一种强大的方式来可视化实时传感器数据,使趋势分析、调试和多个数据点的对比变得更加直观。要正确设置,请按照提供的教程,其中包含使用Plot功能显示Click board™读数的分步示例。在代码中使用Plot功能时,请使用以下函数:plot(insert_graph_name, variable_name);。这是一个通用格式,用户需要将“insert_graph_name”替换为实际图表名称,并将“variable_name”替换为要显示的参数。

软件支持

库描述

该库包含 LTE IoT 6 Click 驱动程序的 API。

关键功能:

  • lteiot6_send_cmd - 发送命令功能

  • lteiot6_set_sim_apn - 设置SIM卡的APN

  • lteiot6_send_sms_pdu - 以PDU模式发送短信到指定号码

开源

代码示例

完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio 应用程序代码也可以在MIKROE的GitHub账户中找到。

/*!
 * @file main.c
 * @brief LTE IoT 6 Click Example.
 *
 * # Description
 * Application example shows device capability to connect 
 * network and send SMS messages using standard "AT" commands.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes driver and wake-up module and test communication.
 *
 * ## Application Task
 * Application taks is split in few stages:
 *  - LTEIOT6_CONFIGURE_FOR_CONNECTION: 
 * Sets configuration to device to be able to connect to newtork.
 * 
 *  - LTEIOT6_WAIT_FOR_CONNECTION: 
 * Checks device response untill device sends information 
 * that it is connected to network.
 * 
 *  - LTEIOT6_CHECK_CONNECTION:
 * Checks device connection status parameters.
 * 
 *  - LTEIOT6_CONFIGURE_FOR_MESSAGES:
 * Sets configuration to device to send SMS messages.
 * 
 *  - LTEIOT6_MESSAGES:
 * Sends message in selected mode (PDU/TXT).
 *
 *
 * ## Additional Function
 * - static void lteiot6_clear_app_buf ( void )
 * - static err_t lteiot6_process ( void )
 * - static void lteiot6_error_check( err_t error_flag )
 * - static void lteiot6_log_app_buf ( void )
 * - static err_t lteiot6_rsp_check ( void )
 * - static err_t lteiot6_configure_for_connection( void )
 * - static err_t lteiot6_check_connection( void )
 * - static err_t lteiot6_check_connection_parameters( void )
 * - static err_t lteiot6_configure_for_meesages( void )
 * - static err_t lteiot6_send_meesage( void )
 * - 
 *
 * @note
 * In order for the example to work, user needs to set the phone number to which he wants 
 * to send an SMS, and also will need to set an APN and SMSC of entered SIM card.
 * Enter valid data for the following macros: SIM_APN, SIM_SMSC and PHONE_NUMBER_TO_MESSAGE.
 * E.g. 
 * SIM_APN                     "vip.iot"
 * SMSC_ADDRESS_CSCA           "\"+381999999\",145"
 * SMSC_ADDRESS_PDU            "+381999999\" 
 * PHONE_NUMBER_TO_MESSAGE     "+381659999999"
 *
 * @author Luka Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "lteiot6.h"

//Set valid SIM APN
#define SIM_APN                     ""
//Set Phone number to message
#define PHONE_NUMBER_TO_MESSAGE     "+381659999999"
//Messege content 
#define MESSAGE_CONTENT             "LTE IoT 6 Click"
//Set valid SMSC fro SIM
#define SMSC_ADDRESS_CSCA           "\"+381999999\",145" 
#define SMSC_ADDRESS_PDU            "+381999999" 

#define PROCESS_BUFFER_SIZE         300

/**
 * @brief Example states.
 * @details Predefined enum values for application example state.
 */
typedef enum
{
   LTEIOT6_CONFIGURE_FOR_CONNECTION = 1,
   LTEIOT6_WAIT_FOR_CONNECTION,
   LTEIOT6_CHECK_CONNECTION,
   LTEIOT6_CONFIGURE_FOR_MESSAGES,
   LTEIOT6_MESSAGES

} lteiot6_example_state_t;

static lteiot6_t lteiot6;
static log_t logger;

/**
 * @brief Application example variables.
 * @details Variables used in application example.
 */
static char app_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;
static int32_t app_buf_cnt = 0;
static err_t error_flag;
static lteiot6_example_state_t example_state;


/**
 * @brief Clearing application buffer.
 * @details This function clears memory of application 
 * buffer and reset it's length and counter.
 */
static void lteiot6_clear_app_buf ( void );

/**
 * @brief Data reading function.
 * @details This function reads data from device and 
 * appends data to application buffer.
 *
 * @return @li @c  0 - Read some data.
 *         @li @c -1 - Nothing is read.
 *         @li @c -2 - Application buffer overflow.
 *
 * See #err_t definition for detailed explanation.
 */
static err_t lteiot6_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.
 */
static void lteiot6_error_check( err_t error_flag );

/**
 * @brief Logs application buffer.
 * @details This function logs data from application buffer.
 */
static void lteiot6_log_app_buf ( void );

/**
 * @brief Response check.
 * @details This function checks for response and 
 * returns the status of response.
 * 
 * @return application status.
 * See #err_t definition for detailed explanation.
 */
static err_t lteiot6_rsp_check ( void );

/**
 * @brief Configure device for connection to the network.
 * @details Sends commands to configure and enable 
 * connection to the secifide network.
 */
static err_t lteiot6_configure_for_connection( void );

/**
 * @brief Whait for connection signal.
 * @details Wait for connection signal from CREG command.
 */
static err_t lteiot6_check_connection( void );

/**
 * @brief Check connection parameters.
 * @details This function checks connection parameters.
 */
static err_t lteiot6_check_connection_parameters( void );

/**
 * @brief Configure device for sending messages.
 * @details Configure device to send txt mode 
 * messages and SMSC of the SIM card.
 */
static err_t lteiot6_configure_for_meesages( void );

/**
 * @brief Sending text message.
 * @details This function sends text messages to predefined number.
 */
static err_t lteiot6_send_meesage( void );

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    lteiot6_cfg_t lteiot6_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 );
    Delay_ms ( 1000 );
    log_info( &logger, " Application Init " );
    Delay_ms ( 1000 );

    // Click initialization.
    lteiot6_cfg_setup( &lteiot6_cfg );
    LTEIOT6_MAP_MIKROBUS( lteiot6_cfg, MIKROBUS_1 );
    err_t init_flag  = lteiot6_init( &lteiot6, &lteiot6_cfg );
    if ( init_flag == UART_ERROR ) 
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }
    lteiot6_process();
    lteiot6_clear_app_buf(); 
    app_buf_len = 0;
    app_buf_cnt = 0;
    
    lteiot6_reset( &lteiot6 );
    lteiot6_power_on( &lteiot6 );
    
    //Check communication
    lteiot6_send_cmd( &lteiot6, LTEIOT6_CMD_AT );
    error_flag = lteiot6_rsp_check();
    lteiot6_error_check( error_flag );
    
    //Check fw version
    lteiot6_send_cmd( &lteiot6, LTEIOT6_CMD_ATI );
    error_flag = lteiot6_rsp_check();
    lteiot6_error_check( error_flag );
    
    log_info( &logger, " Application Task " );
    example_state = LTEIOT6_CONFIGURE_FOR_CONNECTION;
}

void application_task ( void ) 
{
    switch ( example_state )
    {
        case LTEIOT6_CONFIGURE_FOR_CONNECTION:
        {
            if ( LTEIOT6_OK == lteiot6_configure_for_connection( ) )
            {
                example_state = LTEIOT6_WAIT_FOR_CONNECTION;
            }
            break;
        }
        case LTEIOT6_WAIT_FOR_CONNECTION:
        {
            if ( LTEIOT6_OK == lteiot6_check_connection( ) )
            {
                example_state = LTEIOT6_CHECK_CONNECTION;
            }
            break;
        }
        case LTEIOT6_CHECK_CONNECTION:
        {
            Delay_ms ( 1000 );
            if ( LTEIOT6_OK == lteiot6_check_connection_parameters( ) )
            {
                example_state = LTEIOT6_CONFIGURE_FOR_MESSAGES;
            }
            Delay_ms ( 1000 );
            break;
        }
        case LTEIOT6_CONFIGURE_FOR_MESSAGES:
        {
            if ( LTEIOT6_OK == lteiot6_configure_for_meesages( ) )
            {
                example_state = LTEIOT6_MESSAGES;
            }
            Delay_ms ( 1000 );
            break;
        }
        case LTEIOT6_MESSAGES:
        {
            lteiot6_send_meesage();
            Delay_ms ( 1000 );
            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 lteiot6_clear_app_buf ( void ) 
{
    memset( app_buf, 0, app_buf_len );
    app_buf_len = 0;
    app_buf_cnt = 0;
}

static err_t lteiot6_process ( void ) 
{
    int32_t rx_size;
    char rx_buff[ PROCESS_BUFFER_SIZE ] = { 0 };

    rx_size = lteiot6_generic_read( &lteiot6, rx_buff, PROCESS_BUFFER_SIZE );

    if ( rx_size > 0 ) 
    {
        int32_t buf_cnt = 0;

        if ( app_buf_len + rx_size >= PROCESS_BUFFER_SIZE ) 
        {
           lteiot6_clear_app_buf(  );
            return LTEIOT6_ERROR;
        } 
        else 
        {
            buf_cnt = app_buf_len;
            app_buf_len += rx_size;
        }

        for ( int32_t rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ ) 
        {
            if ( rx_buff[ rx_cnt ] != 0 ) 
            {
                app_buf[ ( buf_cnt + rx_cnt ) ] = rx_buff[ rx_cnt ];
            }
            else
            {
                app_buf_len--;
                buf_cnt--;
            }

        }
        return LTEIOT6_OK;
    }
    return LTEIOT6_ERROR;
}

static err_t lteiot6_rsp_check ( void )
{
    uint16_t timeout_cnt = 0;
    uint16_t timeout = 50000;
    
    err_t error_flag = lteiot6_process(  );
    if ( ( error_flag != 0 ) && ( error_flag != -1 ) )
    {
        return error_flag;
    }
    
    while ( ( 0 == strstr( app_buf, LTEIOT6_RSP_OK ) ) && 
            ( 0 == strstr( app_buf, LTEIOT6_RSP_ERROR ) ) )
    {
        error_flag = lteiot6_process(  );
        if ( ( error_flag != 0 ) && ( error_flag != -1 ) )
        {
            return error_flag;
        }
        
        timeout_cnt++;
        if ( timeout_cnt > timeout )
        {
            lteiot6_clear_app_buf(  );
            return LTEIOT6_ERROR_TIMEOUT;
        }
        
        Delay_ms ( 1 );
    }
    
    if ( 0 != strstr( app_buf, LTEIOT6_RSP_OK ) )
    {
        return LTEIOT6_OK;
    }
    else if ( 0 == strstr( app_buf, LTEIOT6_RSP_ERROR ) )
    {
        return LTEIOT6_ERROR_CMD;
    }
    else
    {
        return LTEIOT6_ERROR_UNKNOWN;
    }
}

static void lteiot6_error_check( err_t error_flag )
{
    switch ( error_flag )
    {
        case LTEIOT6_OK:
        {
            lteiot6_log_app_buf( );
            break;
        }
        case LTEIOT6_ERROR:
        {
            log_error( &logger, " Overflow!" );
            break;
        }
        case LTEIOT6_ERROR_TIMEOUT:
        {
            log_error( &logger, " Timeout!" );
            break;
        }
        case LTEIOT6_ERROR_CMD:
        {
            log_error( &logger, " CMD!" );
            break;
        }
        case LTEIOT6_ERROR_UNKNOWN:
        default:
        {
            log_error( &logger, " Unknown!" );
            break;
        }
    }
    lteiot6_clear_app_buf(  );
    Delay_ms ( 500 );
}

static void lteiot6_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 lteiot6_configure_for_connection( void )
{
    err_t func_error = LTEIOT6_OK;
    
    //Disconnect
    #define DISCONNECT "2"
    lteiot6_send_cmd_with_parameter( &lteiot6, LTEIOT6_CMD_COPS, DISCONNECT );
    error_flag = lteiot6_rsp_check(); 
    func_error |= error_flag;
    lteiot6_error_check( error_flag );
    
    //Airplane mode
    #define AIRPLANE_MODE "4"
    lteiot6_send_cmd_with_parameter( &lteiot6, LTEIOT6_CMD_CFUN, AIRPLANE_MODE );
    error_flag = lteiot6_rsp_check();
    func_error |= error_flag;
    lteiot6_error_check( error_flag );
    
    //Set SIM APN
    lteiot6_set_sim_apn( &lteiot6, SIM_APN );
    error_flag = lteiot6_rsp_check();
    func_error |= error_flag;
    lteiot6_error_check( error_flag );
    
    //Enable full functionality
    #define FULL_FUNCTIONALITY "1"
    lteiot6_send_cmd_with_parameter( &lteiot6, LTEIOT6_CMD_CFUN, FULL_FUNCTIONALITY );
    error_flag = lteiot6_rsp_check();
    func_error |= error_flag;
    lteiot6_error_check( error_flag );
    
    //Automatic configure cops
    #define AUTOMATIC "0"
    lteiot6_send_cmd_with_parameter( &lteiot6, LTEIOT6_CMD_COPS, AUTOMATIC );
    error_flag = lteiot6_rsp_check(); 
    func_error |= error_flag;
    lteiot6_error_check( error_flag );
    
    //Enable network registartion
    #define ENABLE_REG "2"
    lteiot6_send_cmd_with_parameter( &lteiot6, LTEIOT6_CMD_CREG, ENABLE_REG );
    error_flag = lteiot6_rsp_check();
    func_error |= error_flag;
    lteiot6_error_check( error_flag );
    
    return func_error;
}

static err_t lteiot6_check_connection( void )
{
    #define CONNECTED "+CREG: 1"
    lteiot6_process();
    if ( 0 != strstr(app_buf, CONNECTED ) )
    {
        Delay_ms ( 100 );
        lteiot6_process();
        lteiot6_log_app_buf( );
        lteiot6_clear_app_buf(  );
        return LTEIOT6_OK;
    }
    
    return LTEIOT6_ERROR;
}

static err_t lteiot6_check_connection_parameters( void )
{
    err_t func_error = LTEIOT6_OK;
    
    //Check if connected
    lteiot6_send_cmd_check( &lteiot6, LTEIOT6_CMD_CGATT );
    error_flag = lteiot6_rsp_check();
    func_error |= error_flag;
    lteiot6_error_check( error_flag );
    
    //Check registration
    lteiot6_send_cmd_check( &lteiot6, LTEIOT6_CMD_CREG );
    error_flag = lteiot6_rsp_check();
    func_error |= error_flag;
    lteiot6_error_check( error_flag );
    
    //Check signal quality
    lteiot6_send_cmd( &lteiot6, LTEIOT6_CMD_CSQ );
    error_flag = lteiot6_rsp_check();
    func_error |= error_flag;
    lteiot6_error_check( error_flag );
    
    return func_error;
}

static err_t lteiot6_configure_for_meesages( void )
{
    err_t func_error = LTEIOT6_OK;
    
    //Set message mode
    #define PDU_MESSAGE_MODE "0"
    #define TXT_MESSAGE_MODE "1"
    lteiot6_send_cmd_with_parameter( &lteiot6, LTEIOT6_CMD_CMGF, PDU_MESSAGE_MODE );
    error_flag = lteiot6_rsp_check();
    func_error |= error_flag;
    lteiot6_error_check( error_flag );
    
    //Set SMSC for SIM card
    lteiot6_send_cmd_with_parameter( &lteiot6, LTEIOT6_CMD_CSCA, SMSC_ADDRESS_CSCA );
    error_flag = lteiot6_rsp_check();
    func_error |= error_flag;
    lteiot6_error_check( error_flag );

    return func_error;
}

static err_t lteiot6_send_meesage( void )
{
    #define CMGF_PDU "+CMGF: 0"
    #define CMGF_TXT "+CMGF: 1"
    
    //Sendind message  
    lteiot6_send_cmd_check( &lteiot6, LTEIOT6_CMD_CMGF );
    error_flag = lteiot6_rsp_check();
    
    if ( 0 != strstr( app_buf, CMGF_PDU ) )
    {
        lteiot6_clear_app_buf(  );
        lteiot6_send_sms_pdu( &lteiot6, SMSC_ADDRESS_PDU, PHONE_NUMBER_TO_MESSAGE, MESSAGE_CONTENT );
        error_flag = lteiot6_rsp_check();
        lteiot6_error_check( error_flag );
    }
    else if ( 0 != strstr( app_buf, CMGF_TXT ) )
    {
        lteiot6_clear_app_buf(  );
        lteiot6_send_text_message( &lteiot6, PHONE_NUMBER_TO_MESSAGE, MESSAGE_CONTENT );
        error_flag = lteiot6_rsp_check();
        lteiot6_error_check( error_flag );
    }
    
    return error_flag;
}


// ------------------------------------------------------------------------ END

额外支持

资源

喜欢这个项目吗?

'购买此套件' 按钮会直接带您进入购物车,您可以在购物车中轻松添加或移除产品。