中级
30 分钟

使用SARA-U201和STM32F031K6为功能丰富的Click Cloud平台提供无缝连接

随时随地通过3.75G UMTS/HSPA访问Click Cloud

Go to Cloud (G2C) 3G Click with Nucleo 32 with STM32F031K6 MCU

已发布 10月 01, 2024

点击板

Go to Cloud (G2C) 3G Click

开发板

Nucleo 32 with STM32F031K6 MCU

编译器

NECTO Studio

微控制器单元

STM32F031K6

连接到Click Cloud从未如此简单。我们的解决方案旨在作为您的Click Cloud连接点,通过3.75G UMTS/HSPA网络的速度和效率增强,确保为企业提供优化的云体验。

A

A

硬件概览

它是如何工作的?

G2C 3G Click基于u-blox的SARA-U201 HSPA模块,支持2G回退,可以通过3.75G UMTS/HSPA网络连接到功能丰富的Click Cloud平台。G2C 3G Click的设计旨在让用户能够轻松添加云连接,并仅使用一组简单的AT命令开发基于云的应用程序,而无需深入了解与网页、硬件和通信相关的复杂开发。由于这种简化的方法,所有人都可以从G2C 3G Click中受益,因为这个Click板™已经在其固件中实现了所有必要的协议和通信设置。这节省了本来会浪费在固件开发和适应第三方解决方案上的时间。此外,这种努力还需要嵌入式和网页编程的熟练程度以及其他几种工程技能。另一方面,G2C 3G Click可以立即与

Click Cloud解决方案无缝协作。G2C 3G Click执行了连接到Click Cloud平台所需的几项任务。通过使用SIM卡访问本地UMTS/HSPA网络来建立连接。为了获得可靠的3G(UMTS/HSPA)网络连接,Click板™使用了可以全球使用的u-Blox SARA U-201模块。Click板™使用一个强大的MCU来管理连接参数、初始化SARA U-201模块并与Click Cloud平台建立连接。这允许您通过发出简短的AT命令(如SSID、密码、设备ID等)在几个简单步骤中设置连接。每个AT命令及其响应的详细解释可以在AT命令手册中找到。除了用于设置基本连接参数的AT命令外,还有允许存储连接参数的AT命令,包括连接密

码、网络SSID、设备ID和其他相关连接数据。这些参数可以存储在G2C 3G Click的非易失性存储器中,可以通过一个宏命令恢复,从而简化连接过程。G2C 3G Click的功能将不断改进。因此,G2C 3G Click支持通过板载USB连接器升级其固件。固件更新过程很简单,使用MikroElektronika熟悉的“HID Bootloader”软件工具。G2C 3G Click配备了五个LED指示灯,指示电源供应的存在、UMTS/HSPA连接、USB连接、数据传输流量和与Click Cloud解决方案的连接。这些LED提供了关于G2C 3G Click状态的视觉反馈。此Click板™仅需5V电源轨即可正常运行。

Go to Cloud (G2C) 3G 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

GPS/3G外部天线是我们GPS/GSM/3G Click boards™的理想选择。它在提供强大的GSM和3G信号接收以及出色的GPS定位能力方面表现出色。其坚固的设计具有螺钉安装和粘贴底座,确保牢固的固定和最佳的性能。该天线具有用于GPS、GSM和3G的独立线路,是需要可靠通信和精确定位的应用的多功能选择。其广泛的频率范围覆盖850/900/1800/1900/2100MHz和50Ω阻抗,保证了在各种网络频段的连接性。其2:1的VSW比和1到1.5dBic(取决于频率)的峰值增益进一步增强了信号强度。天线提供超过10MHz的带宽,确保一致的接收能力,同时其线性极化和全向方位覆盖提供全面的信号可及性。

Go to Cloud (G2C) 3G Click accessories image

使用的MCU引脚

mikroBUS™映射器

General-Purpose I/O
PA0
AN
Hardware Reset
PA11
RST
UART CTS
PA4
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
NC
NC
3.3V
Ground
GND
GND
General-Purpose I/O
PA8
PWM
UART RTS
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™ 原理图

Go to Cloud (G2C) 3G 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
Nucleo-32 with STM32 MCU Access MB 1 - upright/background 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”替换为要显示的参数。

软件支持

库描述

该库包含 G2C 3G Click 驱动程序的 API。

关键功能:

  • g2c3g_reset_device - 此功能通过切换RST引脚来重置设备

  • g2c3g_set_net_creds - 此功能设置输入的SIM卡的APN、用户名和密码

  • g2c3g_set_broker_creds - 此功能设置经纪人凭据(设备密钥和密码)。

开源

代码示例

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

/*!
 * @file main.c
 * @brief G2C 3G Click Example.
 *
 * # Description
 * This example shows the device capability of connecting to the cloud and
 * updating the sensor data on the cloud and receiving data from actuators.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver, restarts the device, and after that tests
 * the communication by sending "AT" command.
 *
 * ## Application Task
 * Application task is split in few stages:
 *  - G2C3G_CONNECT_TO_NETWORK:
 * Sends commands to configure device to connect to the specified network.
 *
 *  - G2C3G_CONNECT_TO_CLOUD:
 * Sends commands to configure device to connect to the specified device on the cloud.
 *
 *  - G2C3G_EXAMPLE:
 * This function executes example which updates sensor data on the cloud and displays
 * all data received from the module (ex. the actuator switch state change received
 * from the cloud).
 *
 * ## Additional Function
 * - static void g2c3g_clear_app_buf ( void )
 * - static err_t g2c3g_process ( void )
 * - static void g2c3g_error_check( err_t error_flag )
 * - static void g2c3g_log_app_buf ( void )
 * - static err_t g2c3g_rsp_check ( uint8_t *rsp )
 * - static err_t g2c3g_connect_to_network( void )
 * - static err_t g2c3g_connect_to_cloud( void )
 * - static err_t g2c3g_example( void )
 *
 * @note
 * In order for the example to work, user needs to set the SIM card and the cloud device parameters.
 * Enter valid values for the following macros: 
 * SIM_APN, SIM_USERNAME, SIM_PASSWORD, DEVICE_KEY, DEVICE_PASSWORD, DEVICE_SENSOR_REF.
 * Example:
 * SIM_APN              "internet"
 * SIM_USERNAME         "internet"
 * SIM_PASSWORD         "internet"
 * DEVICE_KEY           "xxxxxxxxxxxxxxxx"
 * DEVICE_PASSWORD      "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
 * DEVICE_SENSOR_REF    "TEMP_SEN_R"
 * 
 * DEVICE_KEY and DEVICE_PASSWORD strings should match the device credentials which
 * were generated during the Click Cloud device creation step.
 * DEVICE_SENSOR_REF is expected to be a reference to a temperature sensor with a data
 * range from -20 to +80 degrees Celsius.
 * For more information about the registration on the Click Cloud and creating the device
 * refer to the following user guide:
 * https://download.mikroe.com/documents/click-cloud/guide-to-click-cloud.pdf
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "g2c3g.h"
#include "conversions.h"

// SIM card config parameters
#define SIM_APN                             ""  // Set valid SIM APN
#define SIM_USERNAME                        ""  // Set valid SIM username
#define SIM_PASSWORD                        ""  // Set valid SIM password

// Cloud device config parameters
#define DEVICE_KEY                          ""  // Cloud device key
#define DEVICE_PASSWORD                     ""  // Cloud device password
#define DEVICE_SENSOR_REF                   ""  // Cloud device sensor reference

// Application buffer size
#define APP_BUFFER_SIZE                     300
#define PROCESS_BUFFER_SIZE                 300

/**
 * @brief Example states.
 * @details Predefined enum values for application example state.
 */
typedef enum
{
    G2C3G_CONNECT_TO_NETWORK = 1,
    G2C3G_CONNECT_TO_CLOUD,
    G2C3G_EXAMPLE

} g2c3g_example_state_t;

static g2c3g_t g2c3g;
static log_t logger;

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

/**
 * @brief G2C 3G clearing application buffer.
 * @details This function clears memory of application buffer and reset its length.
 * @note None.
 */
static void g2c3g_clear_app_buf ( void );

/**
 * @brief G2C 3G data reading function.
 * @details This function reads data from device and concatenates data to application buffer. 
 * @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 g2c3g_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 g2c3g_error_check ( err_t error_flag );

/**
 * @brief Logs application buffer.
 * @details This function logs data from application buffer.
 */
static void g2c3g_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 g2c3g_rsp_check ( uint8_t *rsp );

/**
 * @brief Configure device to connect to the network.
 * @details Sends commands to configure device to connect 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 g2c3g_connect_to_network ( void );

/**
 * @brief Configure device to connect to the cloud.
 * @details Sends commands to configure device to connect to the specified device on the cloud.
 * @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 g2c3g_connect_to_cloud ( void );

/**
 * @brief Execute example.
 * @details This function executes example which updates sensor data on the cloud and displays
 * all data received from the module (ex. the actuator state change received from the cloud).
 * @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 g2c3g_example ( void );

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    g2c3g_cfg_t g2c3g_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.
    g2c3g_cfg_setup( &g2c3g_cfg );
    G2C3G_MAP_MIKROBUS( g2c3g_cfg, MIKROBUS_1 );
    if ( UART_ERROR == g2c3g_init( &g2c3g, &g2c3g_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    // Clear RX buffer
    g2c3g_process( );   
    g2c3g_clear_app_buf( );
    Delay_ms ( 100 );
    
    // Reset device
    g2c3g_reset_device ( &g2c3g );
    error_flag = g2c3g_rsp_check( G2C3G_RSP_DEVICE_READY );
    g2c3g_error_check( error_flag );
    
    // Check communication
    g2c3g_send_cmd( &g2c3g, G2C3G_CMD_AT );
    error_flag = g2c3g_rsp_check( G2C3G_RSP_OK );
    g2c3g_error_check( error_flag );
    
    log_info( &logger, " Application Task " );
    example_state = G2C3G_CONNECT_TO_NETWORK;
}

void application_task ( void ) 
{
    switch ( example_state )
    {
        case G2C3G_CONNECT_TO_NETWORK:
        {
            if ( G2C3G_OK == g2c3g_connect_to_network( ) )
            {
                example_state = G2C3G_CONNECT_TO_CLOUD;
            }
            break;
        }
        case G2C3G_CONNECT_TO_CLOUD:
        {
            if ( G2C3G_OK == g2c3g_connect_to_cloud( ) )
            {
                example_state = G2C3G_EXAMPLE;
            }
            break;
        }
        case G2C3G_EXAMPLE:
        {
            g2c3g_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 g2c3g_clear_app_buf ( void ) 
{
    memset( app_buf, 0, app_buf_len );
    app_buf_len = 0;
}

static err_t g2c3g_process ( void ) 
{
    uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
    int32_t rx_size = 0;
    rx_size = g2c3g_generic_read( &g2c3g, rx_buf, PROCESS_BUFFER_SIZE );
    if ( rx_size > 0 ) 
    {
        int32_t buf_cnt = app_buf_len;
        if ( ( ( app_buf_len + rx_size ) > PROCESS_BUFFER_SIZE ) && ( app_buf_len > 0 ) ) 
        {
            buf_cnt = PROCESS_BUFFER_SIZE - ( ( app_buf_len + rx_size ) - PROCESS_BUFFER_SIZE );
            memmove ( app_buf, &app_buf[ PROCESS_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 < PROCESS_BUFFER_SIZE )
                {
                    app_buf_len++;
                }
            }
        }
        return G2C3G_OK;
    }
    return G2C3G_ERROR;
}

static err_t g2c3g_rsp_check ( uint8_t *rsp )
{
    uint32_t timeout_cnt = 0;
    uint32_t timeout = 120000;
    g2c3g_clear_app_buf( );
    g2c3g_process( );
    while ( ( 0 == strstr( app_buf, rsp ) ) &&
            ( 0 == strstr( app_buf, G2C3G_RSP_ERROR ) ) )
    {
        g2c3g_process( );
        if ( timeout_cnt++ > timeout )
        {
            g2c3g_clear_app_buf( );
            return G2C3G_ERROR_TIMEOUT;
        }
        Delay_ms ( 1 );
    }
    Delay_ms ( 100 );
    g2c3g_process( );
    if ( strstr( app_buf, rsp ) )
    {
        return G2C3G_OK;
    }
    else if ( strstr( app_buf, G2C3G_RSP_ERROR ) )
    {
        return G2C3G_ERROR_CMD;
    }
    else
    {
        return G2C3G_ERROR_UNKNOWN;
    }
}

static void g2c3g_error_check ( err_t error_flag )
{
    switch ( error_flag )
    {
        case G2C3G_OK:
        {
            g2c3g_log_app_buf( );
            break;
        }
        case G2C3G_ERROR:
        {
            log_error( &logger, " Overflow!" );
            break;
        }
        case G2C3G_ERROR_TIMEOUT:
        {
            log_error( &logger, " Timeout!" );
            break;
        }
        case G2C3G_ERROR_CMD:
        {
            log_error( &logger, " CMD!" );
            break;
        }
        case G2C3G_ERROR_UNKNOWN:
        default:
        {
            log_error( &logger, " Unknown!" );
            break;
        }
    }
    Delay_ms ( 500 );
}

static void g2c3g_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 g2c3g_connect_to_network ( void )
{
    err_t func_error = G2C3G_OK;
    uint32_t timeout_cnt = 0;
    uint32_t timeout = 120000;
    Delay_ms ( 500 );
    
    // Enable connector module
    #define ENABLE_CONNECTOR_MODULE "1"
    g2c3g_send_cmd_with_par( &g2c3g, G2C3G_CMD_CEN, ENABLE_CONNECTOR_MODULE );
    error_flag = g2c3g_rsp_check( G2C3G_RSP_OK );
    func_error |= error_flag;
    g2c3g_error_check( error_flag );
    
    // Set network credentials
    g2c3g_set_net_creds( &g2c3g, SIM_APN, SIM_USERNAME, SIM_PASSWORD );
    error_flag = g2c3g_rsp_check( G2C3G_RSP_OK );
    func_error |= error_flag;
    g2c3g_error_check( error_flag );
    
    // Connect to network
    #define CONNECT_TO_NETWORK "1"
    g2c3g_send_cmd_with_par( &g2c3g, G2C3G_CMD_NWC, CONNECT_TO_NETWORK );
    error_flag = g2c3g_rsp_check( G2C3G_RSP_OK );
    func_error |= error_flag;
    g2c3g_error_check( error_flag );
    
    // Check for the network connect indication pin
    while ( !g2c3g_get_gp1_pin ( &g2c3g ) )
    {
        if ( timeout_cnt++ > timeout )
        {
            g2c3g_clear_app_buf( );
            func_error = G2C3G_ERROR_TIMEOUT;
            break;
        }
        Delay_ms ( 1 );
    }
    
    return func_error;
}

static err_t g2c3g_connect_to_cloud ( void )
{
    err_t func_error = G2C3G_OK;
    uint32_t timeout_cnt = 0;
    uint32_t timeout = 120000;
    Delay_ms ( 500 );
    
    g2c3g_set_broker_creds( &g2c3g, DEVICE_KEY, DEVICE_PASSWORD );
    error_flag = g2c3g_rsp_check( G2C3G_RSP_OK );
    func_error |= error_flag;
    g2c3g_error_check( error_flag );
    
    // Connect to broker
    #define CONNECT_TO_BROKER "1"
    g2c3g_send_cmd_with_par( &g2c3g, G2C3G_CMD_BRC, CONNECT_TO_BROKER );
    error_flag = g2c3g_rsp_check( G2C3G_RSP_OK );
    func_error |= error_flag;
    g2c3g_error_check( error_flag );
    
    // Check for the cloud connect indication pin
    while ( !g2c3g_get_gp0_pin ( &g2c3g ) )
    {
        if ( timeout_cnt++ > timeout )
        {
            g2c3g_clear_app_buf( );
            func_error = G2C3G_ERROR_TIMEOUT;
            break;
        }
        Delay_ms ( 1 );
    }
    return func_error;
}

static err_t g2c3g_example ( void )
{
    err_t func_error = G2C3G_OK;
    
    #define ACTUATOR_WAIT_TIME_MS   10000 // This setting also affects the sensor data update rate
    #define TEMPERATURE_MIN        -20
    #define TEMPERATURE_MAX         80
    #define TEMPERATURE_STEP        5
    static int8_t temperature = TEMPERATURE_MIN;
    uint8_t cmd_buf[ 100 ] = { 0 };
    uint8_t temperature_buf[ 10 ] = { 0 };
    uint8_t cmd_separator[ 2 ] = { ',', 0 };
    uint8_t quote_mark[ 2 ] = { '\"', 0 };
    
    int8_to_str( temperature, temperature_buf );
    l_trim( temperature_buf );
    r_trim( temperature_buf );

    // Store data to the internal memory.
    strcpy( cmd_buf, quote_mark );
    strcat( cmd_buf, DEVICE_SENSOR_REF );
    strcat( cmd_buf, quote_mark );
    strcat( cmd_buf, cmd_separator );
    strcat( cmd_buf, quote_mark );
    strcat( cmd_buf, temperature_buf );
    strcat( cmd_buf, quote_mark );
    g2c3g_send_cmd_with_par( &g2c3g, G2C3G_CMD_DSET, cmd_buf );
    error_flag = g2c3g_rsp_check( G2C3G_RSP_OK );
    func_error |= error_flag;
    g2c3g_error_check( error_flag );
    Delay_ms ( 500 );
    
    // Publish data to the cloud
    g2c3g_send_cmd( &g2c3g, G2C3G_CMD_PUB );
    error_flag = g2c3g_rsp_check( G2C3G_RSP_OK );
    func_error |= error_flag;
    g2c3g_error_check( error_flag );
    g2c3g_clear_app_buf( );
    
    temperature += TEMPERATURE_STEP;
    if ( temperature > TEMPERATURE_MAX )
    {
        temperature = TEMPERATURE_MIN;
    }
    
    // Check for the actuator response
    for ( uint32_t act_wait_cnt = 0; act_wait_cnt < ACTUATOR_WAIT_TIME_MS; act_wait_cnt++ )
    {
        g2c3g_process ( );
        if ( app_buf_len )
        {
            g2c3g_log_app_buf ( );
            g2c3g_clear_app_buf ( );
        }
        Delay_1ms ( );
    }
    
    return func_error;
}

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

额外支持

资源

喜欢这个项目吗?

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