纳入固件源码、屏幕组件、nand_xfer 工具和文档。忽略本机构建产物、sdkconfig,以及含本机路径的依赖锁。 Co-authored-by: Cursor <cursoragent@cursor.com>
55 lines
1.8 KiB
C
55 lines
1.8 KiB
C
#ifndef MQTT_H
|
|
#define MQTT_H
|
|
|
|
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include "nvs_flash.h"
|
|
#include "esp_netif.h"
|
|
#include "protocol_examples_common.h"
|
|
#include "mqtt_client.h"
|
|
#include "cjson.h"
|
|
|
|
#include "esp_timer.h"
|
|
|
|
#define DEVICE_FIRMWARE_VERSION "v1.0.3"//原为V1.0.0
|
|
|
|
|
|
void handle_received_data(const char* topic, int topic_len, const char* data, int data_len);
|
|
void handle_event(const char* data, int data_len);
|
|
void report_firmware_version(char* event_time);
|
|
void handle_ota_command(const char* data);
|
|
void ota_timeout_handler(void *arg);
|
|
void setup_ota_timeout_timer(void);
|
|
void clear_ota_timeout_timer(void);
|
|
static esp_mqtt_client_handle_t esp_mqtt_client_get_handle(void);
|
|
static void handle_version_query_manual(const char* data, int data_len);
|
|
static void find_field_manually(cJSON *root, const char* field_name);
|
|
static void print_json_structure_recursive(cJSON *item, int depth);
|
|
void mqtt_main(void);
|
|
/** 停止并销毁 MQTT 客户端,释放 TLS/TCP 任务与缓冲;下次 mqtt_main() 会重新创建 */
|
|
void mqtt_client_shutdown(void);
|
|
esp_err_t subscribe_ota();
|
|
static cJSON* create_data(char* service_id, char* event_type);
|
|
esp_err_t publish_json_download(char* filename);
|
|
|
|
|
|
bool Get_MQTT_FLAG(void);
|
|
extern bool mqtt_connected;
|
|
static char current_request_id[64] = {0};
|
|
static esp_timer_handle_t ota_timeout_timer;
|
|
static bool ota_command_received = false;
|
|
static esp_mqtt_client_handle_t client = NULL;
|
|
static esp_mqtt_client_handle_t client_http = NULL;
|
|
static char time_event[64] = {0};
|
|
extern char object_device_id[70];
|
|
static char version[64] = {0};
|
|
extern char custom_info[32];
|
|
void trigger_ota_upgrade(char* url);
|
|
void check_ota_progress(void);
|
|
void transmit_ota_success(void);
|
|
#define ota_upgrade 1
|
|
#define ota_flash_upgrade 2
|
|
static int ota_type = 0;
|
|
void get_object_device_id(char *product_id);
|
|
#endif // MQTT_H
|