forked from espressif/esp-at
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): update qcloud core version to 965ecb9
- feat: Add some exported header files - feat: Add the function of configuring QCLOUD log
- Loading branch information
Tang Xiang
committed
May 20, 2022
1 parent
792c138
commit d9fd150
Showing
13 changed files
with
380 additions
and
30 deletions.
There are no files selected for viewing
209 changes: 209 additions & 0 deletions
209
components/clouds/qcloud/include/qcloud_iot_export_log.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making IoT Hub | ||
available. | ||
* Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. | ||
* Licensed under the MIT License (the "License"); you may not use this file | ||
except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* http://opensource.org/licenses/MIT | ||
* Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is | ||
* distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, | ||
* either express or implied. See the License for the specific language | ||
governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#ifndef QCLOUD_IOT_EXPORT_LOG_H_ | ||
#define QCLOUD_IOT_EXPORT_LOG_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#include "qcloud_iot_export_variables.h" | ||
|
||
/** | ||
* SDK log print/upload level | ||
*/ | ||
typedef enum { eLOG_DISABLE = 0, eLOG_ERROR = 1, eLOG_WARN = 2, eLOG_INFO = 3, eLOG_DEBUG = 4 } LOG_LEVEL; | ||
|
||
/** | ||
* log print level control, only print logs with level less or equal to this | ||
* variable | ||
*/ | ||
extern LOG_LEVEL g_log_print_level; | ||
|
||
/** | ||
* log upload level control, only upload logs with level less or equal to this | ||
* variable | ||
*/ | ||
extern LOG_LEVEL g_log_upload_level; | ||
|
||
/* user's self defined log handler callback */ | ||
typedef bool (*LogMessageHandler)(const char *message); | ||
|
||
/** | ||
* @brief user callback for saving/reading logs into/from NVS(files/FLASH) after | ||
* upload fail/recover | ||
*/ | ||
// callback for saving logs into NVS(files/FLASH) after upload fail | ||
typedef size_t (*LogSaveFunc)(const char *msg, size_t wLen); | ||
// callback for reading logs from NVS(files/FLASH) when upload ready | ||
typedef size_t (*LogReadFunc)(char *buff, size_t rLen); | ||
// callback for deleting logs in NVS(files/FLASH). return 0 when success | ||
typedef int (*LogDelFunc)(); | ||
// callback for reading the size of logs in NVS(files/FLASH). return 0 when | ||
// nothing exist | ||
typedef size_t (*LogGetSizeFunc)(); | ||
|
||
/** | ||
* @brief data structure to init feature of log upload | ||
*/ | ||
typedef struct { | ||
const char *region; // region | ||
/* device info */ | ||
const char *product_id; | ||
const char *device_name; | ||
/* auth key, use device secret for PSK device and cert file path for cert | ||
* device */ | ||
const char *sign_key; | ||
/* user callback saving/reading logs into/from NVS(files/FLASH) */ | ||
LogSaveFunc save_func; | ||
LogReadFunc read_func; | ||
LogDelFunc del_func; | ||
LogGetSizeFunc get_size_func; | ||
} LogUploadInitParams; | ||
|
||
/** | ||
* @brief Set the global log level of print | ||
* | ||
* @param level | ||
*/ | ||
void IOT_Log_Set_Level(LOG_LEVEL level); | ||
|
||
/** | ||
* @brief Get the global log level of print | ||
* | ||
* @return | ||
*/ | ||
LOG_LEVEL IOT_Log_Get_Level(); | ||
|
||
/** | ||
* @brief Set the global log level of upload | ||
* | ||
* @param level | ||
*/ | ||
void IOT_Log_Set_Upload_Level(LOG_LEVEL level); | ||
|
||
/** | ||
* @brief Get the global log level of upload | ||
* | ||
* @return | ||
*/ | ||
LOG_LEVEL IOT_Log_Get_Upload_Level(); | ||
|
||
/** | ||
* @brief Set user callback to print log into whereever you want | ||
* | ||
* @param handler function pointer of callback | ||
* | ||
*/ | ||
void IOT_Log_Set_MessageHandler(LogMessageHandler handler); | ||
|
||
/** | ||
* @brief Init the resource for log upload | ||
* | ||
* @param init_params init parameter | ||
* @return QCLOUD_RET_SUCCESS when success, or error code when fail | ||
* | ||
*/ | ||
int IOT_Log_Init_Uploader(LogUploadInitParams *init_params); | ||
|
||
/** | ||
* @brief Stop log upload and release the resource | ||
* | ||
* @return | ||
*/ | ||
void IOT_Log_Fini_Uploader(void); | ||
|
||
/** | ||
* @brief Do one log upload | ||
* | ||
* @param force_upload true = upload log at once, false = upload in defined time | ||
* interval | ||
* @return QCLOUD_RET_SUCCESS when success, or error code when fail | ||
*/ | ||
int IOT_Log_Upload(bool force_upload); | ||
|
||
/** | ||
* @brief Generate log for print/upload, call LogMessageHandler if defined | ||
* | ||
* When LOG_UPLOAD is enabled, the log will be uploaded to cloud server | ||
* | ||
* @param file | ||
* @param func | ||
* @param line | ||
* @param level | ||
*/ | ||
void IOT_Log_Gen(const char *file, const char *func, const int line, const int level, const char *fmt, ...); | ||
|
||
/* Simple APIs for log generation in different level */ | ||
#define Log_d(fmt, ...) IOT_Log_Gen(__FILE__, __FUNCTION__, __LINE__, eLOG_DEBUG, fmt, ##__VA_ARGS__) | ||
#define Log_i(fmt, ...) IOT_Log_Gen(__FILE__, __FUNCTION__, __LINE__, eLOG_INFO, fmt, ##__VA_ARGS__) | ||
#define Log_w(fmt, ...) IOT_Log_Gen(__FILE__, __FUNCTION__, __LINE__, eLOG_WARN, fmt, ##__VA_ARGS__) | ||
#define Log_e(fmt, ...) IOT_Log_Gen(__FILE__, __FUNCTION__, __LINE__, eLOG_ERROR, fmt, ##__VA_ARGS__) | ||
|
||
/* Macro for debug mode */ | ||
#ifdef IOT_DEBUG | ||
#define IOT_FUNC_ENTRY \ | ||
{ \ | ||
printf("FUNC_ENTRY: %s L#%d \n", __FUNCTION__, __LINE__); \ | ||
} | ||
#define IOT_FUNC_EXIT \ | ||
{ \ | ||
printf("FUNC_EXIT: %s L#%d \n", __FUNCTION__, __LINE__); \ | ||
return; \ | ||
} | ||
#define IOT_FUNC_EXIT_RC(x) \ | ||
{ \ | ||
printf("FUNC_EXIT: %s L#%d Return Code : %ld \n", __FUNCTION__, __LINE__, (long)(x)); \ | ||
return x; \ | ||
} | ||
#else | ||
#define IOT_FUNC_ENTRY | ||
#define IOT_FUNC_EXIT \ | ||
{ \ | ||
return; \ | ||
} | ||
#define IOT_FUNC_EXIT_RC(x) \ | ||
{ \ | ||
return x; \ | ||
} | ||
#endif | ||
|
||
/* Macro for interval debug */ | ||
//#define LOG_UPLOAD_DEBUG | ||
#ifdef LOG_UPLOAD_DEBUG | ||
#define UPLOAD_DBG(fmt, ...) HAL_Printf(">>LOG-DBG>>%s(%d): " fmt "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__) | ||
#else | ||
#define UPLOAD_DBG(...) | ||
#endif | ||
#define UPLOAD_ERR(fmt, ...) HAL_Printf(">>LOG-ERR>>%s(%d): " fmt "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__) | ||
|
||
#define STRING_PTR_PRINT_SANITY_CHECK(ptr) ((ptr) ? (ptr) : "null") | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* QCLOUD_IOT_EXPORT_LOG_H_ */ |
74 changes: 74 additions & 0 deletions
74
components/clouds/qcloud/include/qcloud_iot_export_variables.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making IoT Hub available. | ||
* Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights reserved. | ||
* Licensed under the MIT License (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* http://opensource.org/licenses/MIT | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is | ||
* distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#ifndef QCLOUD_IOT_EXPORT_VARIABLES_H_ | ||
#define QCLOUD_IOT_EXPORT_VARIABLES_H_ | ||
|
||
/* | ||
* Below variables are dependant on user situation (network status/device memory/application context) | ||
* Adjust the default value to meet your requirement | ||
*/ | ||
|
||
/* default MQTT/CoAP timeout value when connect/pub/sub (unit: ms) */ | ||
#define QCLOUD_IOT_MQTT_COMMAND_TIMEOUT (5 * 1000) | ||
|
||
/* default MQTT keep alive interval (unit: ms) */ | ||
#define QCLOUD_IOT_MQTT_KEEP_ALIVE_INTERNAL (240 * 1000) | ||
|
||
/* default MQTT Tx buffer size, MAX: 16*1024 */ | ||
#define QCLOUD_IOT_MQTT_TX_BUF_LEN (2304) | ||
|
||
/* default MQTT Rx buffer size, MAX: 16*1024 */ | ||
#define QCLOUD_IOT_MQTT_RX_BUF_LEN (2304) | ||
|
||
/* default COAP Tx buffer size, MAX: 1*1024 */ | ||
#define COAP_SENDMSG_MAX_BUFLEN (512) | ||
|
||
/* default COAP Rx buffer size, MAX: 1*1024 */ | ||
#define COAP_RECVMSG_MAX_BUFLEN (512) | ||
|
||
/* MAX MQTT reconnect interval (unit: ms) */ | ||
#define MAX_RECONNECT_WAIT_INTERVAL (60 * 1000) | ||
|
||
/* MAX valid time when connect to MQTT server. 0: always valid */ | ||
/* Use this only if the device has accurate UTC time. Otherwise, set to 0 */ | ||
#define MAX_ACCESS_EXPIRE_TIMEOUT (0) | ||
|
||
/* log print/upload related variables */ | ||
/* MAX size of log buffer for one log item including header and content */ | ||
#define MAX_LOG_MSG_LEN (511) | ||
|
||
#if defined(__linux__) | ||
#undef MAX_LOG_MSG_LEN | ||
#define MAX_LOG_MSG_LEN (1023) | ||
#endif | ||
|
||
/* | ||
* Log upload related params, which will affect the size of device memory/disk consumption | ||
* the default value can be changed for different user situation | ||
*/ | ||
// size of buffer for log upload | ||
#define LOG_UPLOAD_BUFFER_SIZE 5000 | ||
|
||
// Max size of one http log upload. Should not larger than 5000 | ||
#define MAX_HTTP_LOG_POST_SIZE 3000 | ||
|
||
// MAX size for saving log into NVS (files/FLASH) after upload fail | ||
#define MAX_LOG_SAVE_SIZE (3 * LOG_UPLOAD_BUFFER_SIZE) | ||
|
||
// interval of log upload (unit: ms) Decrease this value if LOG_UPLOAD_BUFFER_SIZE is small | ||
#define LOG_UPLOAD_INTERVAL_MS 2000 | ||
|
||
#endif /* QCLOUD_IOT_EXPORT_VARIABLES_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
ESP32: ac31d7c | ||
ESP32C3: ac31d7c | ||
ESP32: 965ecb9 | ||
ESP32C3: 965ecb9 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
-24.5 KB
(97%)
components/clouds/qcloud/lib/libesp32c3_qcloud_core_silence.a
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 28 additions & 6 deletions
34
module_config/module_esp32_qcloud/README.md
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,37 @@ | ||
# QCloud AT Customized partition table | ||
|
||
QCloud AT command set use its own partition table : | ||
1. The Size of App in `partitions_at.csv` is 0x180000 . | ||
2. QCloud App needs several customized partitions in at_customize section , `qcloud_modinfo` , `qcloud_devinfo` , `qcloud_prdinfo` and `qcloud_errlog` , as can be found in at_customize.csv. Please make sure these partitions exist. | ||
1. The Size of App in `partitions_at.csv` is 0x180000. | ||
2. The QCloud App needs to use the QCloud partition `qcloud_errlog` defined in `at_customize.csv`. Please make sure the partition exists. | ||
3. QCloud App also need a FLASH area to do firmware OTA for MCU side. The start address and size of the OTA area is module dependant and can be defined by `AT+TCMODINFOSET` command. | ||
|
||
For QCloud IoT AT commands, please refer to [Customized AT Commands and Firmware](../../docs/en/Customized_AT_Commands_and_Firmware/index.rst) | ||
|
||
## BIN file generation tool | ||
|
||
To facilitate factory production, BIN file generation tools in `bin_gen_tool` folder are provided to convert readable `csv` files into binary files. `qcloud_iot_bin_tool_linux` for Linux and `qcloud_iot_bin_tool_win.exe` for Windows platform ('-h' for the tool help message). Please also check each `sample.csv` file for the parameters: | ||
|
||
1. `ModInfo` bin file is stored in the `qcloud_modinfo` partition which defined in at_customize.csv. And can be query by `AT+TCMODINFOSET?` command. | ||
2. `DevInfo` bin file is stored in the `qcloud_devinfo` partition which defined in at_customize.csv. And can be query by `AT+TCDEVINFOSET?` command. | ||
3. `PrdInfo` bin file is stored in the `qcloud_prdinfo` partition which defined in at_customize.csv. And can be query by `AT+TCPRDINFOSET?` command. | ||
|
||
To prevent security risk, please note the tools are not for public usage and only for dedicated customers. If you want to use it, please contact [Espressif](https://www.espressif.com/en/contact-us/sales-questions). | ||
|
||
# QCloud AT 自定义分区表 | ||
|
||
QCloud AT 命令集使用自定义的分区表: | ||
1. `partitions_at.csv` 中定义的 App 大小为 0x180000 . | ||
2. QCloud App 需要使用在 `at_customize.csv` 中定义的 QCloud 分区 `qcloud_modinfo`, `qcloud_devinfo`, `qcloud_prdinfo` 和 `qcloud_errlog` . 请确保上述分区存在. | ||
3. QCloud App 需要一个 FLASH 区域来为 MCU 端执行 OTA . OTA 的起始地址和大小取决于所用模块,可以通过 `AT+TCMODINFOSET` 命令定义. | ||
1. `partitions_at.csv` 中定义的 App 大小为 0x180000。 | ||
2. QCloud App 需要使用在 `at_customize.csv` 中定义的 QCloud 分区 `qcloud_errlog`。 请确保该分区存在。 | ||
4. QCloud App 需要一个 FLASH 区域来为 MCU 端执行 OTA。 OTA 的起始地址和大小取决于所用模块,可以通过 `AT+TCMODINFOSET` 命令定义。 | ||
|
||
对于 QCloud IoT AT 命令集,请参考 [第三方定制化 AT 命令和固件](../../docs/zh_CN/Customized_AT_Commands_and_Firmware/index.rst) | ||
|
||
## 二进制文件生成工具 | ||
|
||
为了方便工厂生产,提供了 `bin_gen_tool` 目录中的二进制文件生成工具,用于将可读的 `csv` 文件转换成二进制文件。`qcloud_iot_bin_tool_linux` 适用于 Linux 平台,`qcloud_iot_bin_tool_win.exe` 适用于 Windows 平台('-h' 选项用于工具帮助消息)。请检查每个 `sample.csv` 文件的参数: | ||
|
||
1. `ModInfo` 二进制文件存放在 at_customize.csv 中定义的 `qcloud_modinfo` 分区中。可以通过命令 `AT+TCMODINFOSET?` 查询。 | ||
2. `DevInfo` 二进制文件存放在 at_customize.csv 中定义的 `qcloud_devinfo` 分区中。可以通过命令 `AT+TCDEVINFOSET?` 查询。 | ||
3. `PrdInfo` 二进制文件存放在 at_customize.csv 中定义的 `qcloud_prdinfo` 分区中。可以通过命令 `AT+TCPRDINFOSET?` 查询。 | ||
|
||
对于 QCloud IoT AT 命令集, 请参考 [第三方定制化 AT 命令和固件](../../docs/zh_CN/Customized_AT_Commands_and_Firmware/index.rst) | ||
为防止安全风险,请注意这些工具不提供给公众使用,仅供专门客户使用。 如需使用,请联系[乐鑫](https://www.espressif.com/zh-hans/contact-us/sales-questions)。 |
Oops, something went wrong.