mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-20 19:41:58 +00:00
Better detect CMSIS UID_BASE
This commit is contained in:
1 parent
493de5cf52
commit
f85f550f16
2 files changed
+15
-9
No files matched your search
+9
-7
@@ -9903,10 +9903,8 @@ void mg_tcpip_mapip(struct mg_connection *c, struct mg_addr *ip) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Scannable version tag embedded in every firmware binary, for server-side
|
// Scannable version tag embedded in every firmware binary, for server-side
|
||||||
// version extraction. __attribute__((used)) prevents --gc-sections from
|
// version extraction. The version string starts after the 11-char "MG_VERSION:" prefix.
|
||||||
// stripping it. The version string starts after the 11-char "MG_VERSION:" prefix.
|
static const char mg_fw_version[] = "MG_VERSION:" MG_OTA_FIRMWARE_VERSION;
|
||||||
static const char mg_fw_version[] __attribute__((used)) =
|
|
||||||
"MG_VERSION:" MG_OTA_FIRMWARE_VERSION;
|
|
||||||
|
|
||||||
static bool s_autocommit_ok; // True after OTA server confirms "same version"
|
static bool s_autocommit_ok; // True after OTA server confirms "same version"
|
||||||
|
|
||||||
@@ -9924,7 +9922,10 @@ static void s_firmware_fn(struct mg_connection *c, int ev, void *ev_data);
|
|||||||
#if MG_ENABLE_CUSTOM_DEVICE_ID
|
#if MG_ENABLE_CUSTOM_DEVICE_ID
|
||||||
#else
|
#else
|
||||||
void mg_ota_device_id(char *buf, size_t len) {
|
void mg_ota_device_id(char *buf, size_t len) {
|
||||||
#if MG_ARCH == MG_ARCH_CUBE && defined(UID_BASE)
|
#if defined(UID_BASE) && \
|
||||||
|
(defined(__SYSTEM_STM32F4XX_H) || defined(__SYSTEM_STM32F7XX_H) || \
|
||||||
|
defined(SYSTEM_STM32H5XX_H) || defined(SYSTEM_STM32H7XX_H) || \
|
||||||
|
defined(SYSTEM_STM32N6XX_H) || defined(SYSTEM_STM32U5XX_H))
|
||||||
mg_snprintf(buf, len, "%M", mg_print_hex, 12, (uint8_t *) UID_BASE);
|
mg_snprintf(buf, len, "%M", mg_print_hex, 12, (uint8_t *) UID_BASE);
|
||||||
#else
|
#else
|
||||||
mg_snprintf(buf, len, "%d", 0);
|
mg_snprintf(buf, len, "%d", 0);
|
||||||
@@ -9981,7 +9982,7 @@ static void s_version_fn(struct mg_connection *c, int ev, void *ev_data) {
|
|||||||
mg_free(s_ota);
|
mg_free(s_ota);
|
||||||
s_ota = NULL;
|
s_ota = NULL;
|
||||||
} else {
|
} else {
|
||||||
*(uint64_t *) fc->data = mg_millis() + 300 * 1000; // Set expiration
|
*(uint64_t *) fc->data = mg_millis() + 5 * 1000; // Set expiration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c->is_closing = 1;
|
c->is_closing = 1;
|
||||||
@@ -10014,6 +10015,7 @@ static void s_firmware_fn(struct mg_connection *c, int ev, void *ev_data) {
|
|||||||
"Host: %.*s\r\n"
|
"Host: %.*s\r\n"
|
||||||
"Connection: close\r\n\r\n",
|
"Connection: close\r\n\r\n",
|
||||||
mg_url_uri(s_ota->url), (int) host.len, host.buf);
|
mg_url_uri(s_ota->url), (int) host.len, host.buf);
|
||||||
|
*(uint64_t *) c->data = mg_millis() + 300 * 1000; // Set expiration
|
||||||
} else if (ev == MG_EV_HTTP_HDRS) {
|
} else if (ev == MG_EV_HTTP_HDRS) {
|
||||||
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||||
int status = mg_http_status(hm);
|
int status = mg_http_status(hm);
|
||||||
@@ -10061,7 +10063,7 @@ void mg_ota_poll(struct mg_mgr *mgr) {
|
|||||||
static uint64_t feed_timer; // Advances by 500ms per tick; tracks elapsed time
|
static uint64_t feed_timer; // Advances by 500ms per tick; tracks elapsed time
|
||||||
if (MG_OTA_STATE_GET() == MG_OTA_TESTING &&
|
if (MG_OTA_STATE_GET() == MG_OTA_TESTING &&
|
||||||
mg_timer_expired(&feed_timer, 500, mg_millis())) {
|
mg_timer_expired(&feed_timer, 500, mg_millis())) {
|
||||||
if (feed_timer < (uint64_t) MG_OTA_ROLLBACK_TIMEOUT_SECONDS * 1000ULL) {
|
if (feed_timer < (uint64_t) MG_OTA_ROLLBACK_TIMEOUT_SECONDS * 1000) {
|
||||||
MG_OTA_ROLLBACK_TIMER_FEED(); // Feed watchdog every 500ms
|
MG_OTA_ROLLBACK_TIMER_FEED(); // Feed watchdog every 500ms
|
||||||
} else if (s_autocommit_ok) {
|
} else if (s_autocommit_ok) {
|
||||||
MG_INFO(("Auto-committing firmware"));
|
MG_INFO(("Auto-committing firmware"));
|
||||||
|
|||||||
@@ -30,7 +30,10 @@ static void s_firmware_fn(struct mg_connection *c, int ev, void *ev_data);
|
|||||||
#if MG_ENABLE_CUSTOM_DEVICE_ID
|
#if MG_ENABLE_CUSTOM_DEVICE_ID
|
||||||
#else
|
#else
|
||||||
void mg_ota_device_id(char *buf, size_t len) {
|
void mg_ota_device_id(char *buf, size_t len) {
|
||||||
#if MG_ARCH == MG_ARCH_CUBE && defined(UID_BASE)
|
#if defined(UID_BASE) && \
|
||||||
|
(defined(__SYSTEM_STM32F4XX_H) || defined(__SYSTEM_STM32F7XX_H) || \
|
||||||
|
defined(SYSTEM_STM32H5XX_H) || defined(SYSTEM_STM32H7XX_H) || \
|
||||||
|
defined(SYSTEM_STM32N6XX_H) || defined(SYSTEM_STM32U5XX_H))
|
||||||
mg_snprintf(buf, len, "%M", mg_print_hex, 12, (uint8_t *) UID_BASE);
|
mg_snprintf(buf, len, "%M", mg_print_hex, 12, (uint8_t *) UID_BASE);
|
||||||
#else
|
#else
|
||||||
mg_snprintf(buf, len, "%d", 0);
|
mg_snprintf(buf, len, "%d", 0);
|
||||||
@@ -87,7 +90,7 @@ static void s_version_fn(struct mg_connection *c, int ev, void *ev_data) {
|
|||||||
mg_free(s_ota);
|
mg_free(s_ota);
|
||||||
s_ota = NULL;
|
s_ota = NULL;
|
||||||
} else {
|
} else {
|
||||||
*(uint64_t *) fc->data = mg_millis() + 300 * 1000; // Set expiration
|
*(uint64_t *) fc->data = mg_millis() + 5 * 1000; // Set expiration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c->is_closing = 1;
|
c->is_closing = 1;
|
||||||
@@ -120,6 +123,7 @@ static void s_firmware_fn(struct mg_connection *c, int ev, void *ev_data) {
|
|||||||
"Host: %.*s\r\n"
|
"Host: %.*s\r\n"
|
||||||
"Connection: close\r\n\r\n",
|
"Connection: close\r\n\r\n",
|
||||||
mg_url_uri(s_ota->url), (int) host.len, host.buf);
|
mg_url_uri(s_ota->url), (int) host.len, host.buf);
|
||||||
|
*(uint64_t *) c->data = mg_millis() + 300 * 1000; // Set expiration
|
||||||
} else if (ev == MG_EV_HTTP_HDRS) {
|
} else if (ev == MG_EV_HTTP_HDRS) {
|
||||||
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||||
int status = mg_http_status(hm);
|
int status = mg_http_status(hm);
|
||||||
|
|||||||
Reference in new issue
Block a user