JXCT Soil Sensor 7-in-1 v3.4.9 (June 2025)
Professional IoT soil monitoring system with ESP32, Modbus RTU, MQTT, and advanced compensation algorithms
Загрузка...
Поиск...
Не найдено
Файл ota_manager.cpp
#include "ota_manager.h"
#include <Update.h>
#include "logger.h"
#include "jxct_config_vars.h"
#include <HTTPClient.h>
#include <ArduinoJson.h>
#include <mbedtls/sha256.h>
#include <esp_ota_ops.h>
#include <strings.h>
#include "version.h"
#include <Arduino.h>
#include <esp_task_wdt.h>

См. исходные тексты.

Функции

static void _printGuard (const char *name, const char *tag, const char *current)
 
void checkGuard (const char *tag)
 
const char * getOtaStatus ()
 
void setupOTA (const char *manifestUrl, WiFiClient &client)
 
static bool verifySha256 (const uint8_t *calcDigest, const char *expectedHex)
 
static bool initializeDownload (HTTPClient &http, const String &binUrl, int &contentLen)
 
static bool downloadData (HTTPClient &http, int contentLen, mbedtls_sha256_context &shaCtx)
 
static bool downloadAndUpdate (const String &binUrl, const char *expectedSha256)
 
void triggerOtaCheck ()
 
void triggerOtaInstall ()
 
void handleOTA ()
 

Переменные

static char statusBuf [128] = "Ожидание"
 
static char guardGap [8] = "BEFORE"
 
static char manifestUrlGlobal [512] = ""
 
static WiFiClient * clientPtr = nullptr
 
static bool urlInitialized = false
 
static bool updateAvailable = false
 
static String pendingUpdateUrl = ""
 
static String pendingUpdateSha256 = ""
 
static String pendingUpdateVersion = ""
 
static char guardSentinel [8] = "GUARD!"
 

Функции

◆ _printGuard()

static void _printGuard ( const char * name,
const char * tag,
const char * current )
static

См. определение в файле ota_manager.cpp строка 30

Перекрестные ссылки logError().

Используется в checkGuard().

◆ checkGuard()

void checkGuard ( const char * tag)

См. определение в файле ota_manager.cpp строка 34

Перекрестные ссылки _printGuard(), guardGap и guardSentinel.

Используется в setupOTA().

◆ downloadAndUpdate()

static bool downloadAndUpdate ( const String & binUrl,
const char * expectedSha256 )
static

См. определение в файле ota_manager.cpp строка 303

Перекрестные ссылки downloadData(), initializeDownload(), logError(), logSystem(), statusBuf и verifySha256().

Используется в triggerOtaInstall().

◆ downloadData()

static bool downloadData ( HTTPClient & http,
int contentLen,
mbedtls_sha256_context & shaCtx )
static

См. определение в файле ota_manager.cpp строка 186

Перекрестные ссылки logError(), logSystem() и statusBuf.

Используется в downloadAndUpdate().

◆ getOtaStatus()

const char * getOtaStatus ( )

См. определение в файле ota_manager.cpp строка 45

Перекрестные ссылки statusBuf.

Используется в handleMQTT() и sendOtaStatusJson().

◆ handleOTA()

void handleOTA ( )

См. определение в файле ota_manager.cpp строка 455

Перекрестные ссылки clientPtr, JXCT_VERSION_STRING, logError(), logSystem(), manifestUrlGlobal, pendingUpdateSha256, pendingUpdateUrl, pendingUpdateVersion, statusBuf, updateAvailable и urlInitialized.

Используется в handleMqttCommand(), loop() и triggerOtaCheck().

◆ initializeDownload()

static bool initializeDownload ( HTTPClient & http,
const String & binUrl,
int & contentLen )
static

См. определение в файле ota_manager.cpp строка 109

Перекрестные ссылки clientPtr, logError(), logSystem() и statusBuf.

Используется в downloadAndUpdate().

◆ setupOTA()

void setupOTA ( const char * manifestUrl,
WiFiClient & client )

См. определение в файле ota_manager.cpp строка 47

Перекрестные ссылки checkGuard(), clientPtr, logError(), logSuccess(), logSystem(), logWarn(), manifestUrlGlobal, pendingUpdateSha256, pendingUpdateUrl, pendingUpdateVersion, statusBuf, updateAvailable и urlInitialized.

Используется в setup().

◆ triggerOtaCheck()

void triggerOtaCheck ( )

См. определение в файле ota_manager.cpp строка 407

Перекрестные ссылки handleOTA(), logSystem() и logWarn().

Используется в handleMqttCommand() и setupOtaRoutes().

◆ triggerOtaInstall()

void triggerOtaInstall ( )

См. определение в файле ota_manager.cpp строка 423

Перекрестные ссылки downloadAndUpdate(), logError(), logSystem(), pendingUpdateSha256, pendingUpdateUrl, pendingUpdateVersion, statusBuf и updateAvailable.

Используется в setupOtaRoutes().

◆ verifySha256()

static bool verifySha256 ( const uint8_t * calcDigest,
const char * expectedHex )
static

См. определение в файле ota_manager.cpp строка 100

Используется в downloadAndUpdate().

Переменные

◆ clientPtr

WiFiClient* clientPtr = nullptr
static

См. определение в файле ota_manager.cpp строка 19

Используется в handleOTA(), initializeDownload() и setupOTA().

◆ guardGap

char guardGap[8] = "BEFORE"
static

См. определение в файле ota_manager.cpp строка 17

Используется в checkGuard().

◆ guardSentinel

char guardSentinel[8] = "GUARD!"
static

См. определение в файле ota_manager.cpp строка 28

Используется в checkGuard().

◆ manifestUrlGlobal

char manifestUrlGlobal[512] = ""
static

См. определение в файле ota_manager.cpp строка 18

Используется в handleOTA() и setupOTA().

◆ pendingUpdateSha256

String pendingUpdateSha256 = ""
static

См. определение в файле ota_manager.cpp строка 25

Используется в handleOTA(), setupOTA() и triggerOtaInstall().

◆ pendingUpdateUrl

String pendingUpdateUrl = ""
static

См. определение в файле ota_manager.cpp строка 24

Используется в handleOTA(), setupOTA() и triggerOtaInstall().

◆ pendingUpdateVersion

String pendingUpdateVersion = ""
static

См. определение в файле ota_manager.cpp строка 26

Используется в handleOTA(), setupOTA() и triggerOtaInstall().

◆ statusBuf

char statusBuf[128] = "Ожидание"
static

См. определение в файле ota_manager.cpp строка 16

Используется в downloadAndUpdate(), downloadData(), getOtaStatus(), handleOTA(), initializeDownload(), setupOTA() и triggerOtaInstall().

◆ updateAvailable

bool updateAvailable = false
static

См. определение в файле ota_manager.cpp строка 23

Используется в handleOTA(), setupOTA() и triggerOtaInstall().

◆ urlInitialized

bool urlInitialized = false
static

См. определение в файле ota_manager.cpp строка 20

Используется в handleOTA() и setupOTA().