OTA pipeline working

This commit is contained in:
2026-04-25 22:27:17 +03:00
parent 90037587c0
commit 8f15fe0f1d
19 changed files with 458 additions and 112 deletions

View File

@@ -3,6 +3,8 @@
#include <stdio.h>
#include <stdarg.h>
#include <inttypes.h>
#include "esp_wifi.h"
#include "esp_netif.h"
#define PROTOCOL_VERSION 1
@@ -195,16 +197,45 @@ uint32_t protocol_next_id()
void protocol_send_event_hb(int64_t ts)
{
// формируешь JSON строго по контракту
char buf[256];
// пример:
char buf[128];
wifi_ap_record_t ap;
esp_wifi_sta_get_ap_info(&ap);
int rssi = ap.rssi;
const char *ssid = (const char *)ap.ssid;
esp_netif_ip_info_t ip_info;
esp_netif_t *netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
esp_netif_get_ip_info(netif, &ip_info);
uint32_t ip = ip_info.ip.addr;
size_t heap_free = heap_caps_get_free_size(MALLOC_CAP_DEFAULT);
size_t heap_largest = heap_caps_get_largest_free_block(MALLOC_CAP_DEFAULT);
uint32_t id = protocol_next_id();
snprintf(buf, sizeof(buf),
"{\"v\":1,\"id\":%" PRIu32 ",\"t\":\"e\",\"ts\":%" PRIu64 ",\"d\":%u,\"p\":{\"type\":\"hb\"}}",
id, ts, CONFIG_DEVICE_ID);
"{\"v\":1,\"id\":%" PRIu32 ",\"t\":\"e\",\"ts\":%" PRIu64 ",\"d\":%u,"
"\"p\":{"
"\"t\":\"hb\","
"\"v\":%u,"
"\"hp\":%u,"
"\"hl\":%u,"
"\"rs\":%d,"
"\"ip\":%" PRIu32 ","
"\"si\":\"%s\""
"}}",
id, ts, CONFIG_DEVICE_ID,
FW_VERSION,
heap_free,
heap_largest,
rssi,
ip,
ssid
);
ws_send(buf);
}