Add esp32s2 support

This commit is contained in:
2026-04-12 21:25:01 +03:00
parent 98cc0db107
commit 818a84bf4f
10 changed files with 176 additions and 91 deletions

View File

@@ -1,18 +1,36 @@
#pragma once
#include "cJSON.h"
#include <string>
struct ProtocolMessage {
int v;
std::string id;
std::string type;
uint64_t ts;
std::string deviceId; // C++ строка
cJSON* payload;
};
#include <stdint.h>
#include <stddef.h>
// Создание JSON из структуры
cJSON* protocol_message_to_json(const ProtocolMessage *msg);
#ifdef __cplusplus
extern "C" {
#endif
// Разбор JSON в структуру
int protocol_json_to_message(const char *json_str, ProtocolMessage *msg);
int build_telemetry_single(
char* buf,
size_t buf_size,
const char* id,
const char* device_id,
int64_t ts_ms,
const char* metric,
double value,
const char* unit, // optional (NULL)
const char* source, // optional (NULL)
int64_t m_ts_ms // optional (0 = нет)
);
int build_event(
char* buf,
size_t buf_size,
const char* id,
const char* device_id,
int64_t ts_ms,
const char* name,
const char* severity, // optional
const char* message // optional
);
#ifdef __cplusplus
}
#endif