mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-09-14 15:16:40 +00:00
feat(sim): add variants/sim/ — real companion_radio firmware on native + Emscripten
New board variant compiling the unmodified MyMesh/UITask/DataStore app logic against real mesh::Radio/MainBoard/RTCClock/RNG interfaces, for running the actual firmware outside embedded hardware: - Native (plain g++, platform = native): ASCII-art display over stdout, stdin-driven input, local-disk-backed DataStore/IdentityStore. - Emscripten/WASM (variants/sim/build_wasm.sh, since PlatformIO's native platform force-overrides any CC/CXX toolchain override back to system clang++): canvas-backed display, IDBFS-backed persistence across page reloads, JS-callable input via sim_enqueue_key(), emscripten_set_main_loop. Real rweather/Crypto (AES128/SHA256/Ed25519) vendored unmodified and proven working on both targets. variants/sim/web/index.html is a bare verification harness, not the polished website embed.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
// Minimal native stand-in for Adafruit's RTClib.h. Real hardware boards pull
|
||||
// this in transitively for helpers/AutoDiscoverRTCClock.h (not used by the
|
||||
// sim build -- SimRTCClock.h reads the host wall clock directly) and for
|
||||
// DateTime, which src/helpers/CommonCLI.cpp's "clock"/"clock sync"/"time"
|
||||
// CLI commands genuinely construct and call hour()/minute()/day()/month()/
|
||||
// year() on. Nothing in companion_radio (root files or ui-new/) uses
|
||||
// DateTime, but CommonCLI.cpp (built for every board, including the sim) does.
|
||||
//
|
||||
// Implemented via the real C library's gmtime_r() (UTC calendar breakdown)
|
||||
// rather than hand-rolling RTClib's own unixtime<->y/m/d/h/m/s conversion --
|
||||
// same result, zero risk of a transcription bug in that math.
|
||||
#include <ctime>
|
||||
#include <cstdint>
|
||||
|
||||
class DateTime {
|
||||
uint32_t _unixtime;
|
||||
public:
|
||||
DateTime(uint32_t t = 0) : _unixtime(t) { }
|
||||
|
||||
uint16_t year() const { return 1900 + tmFields().tm_year; }
|
||||
uint8_t month() const { return (uint8_t)(tmFields().tm_mon + 1); }
|
||||
uint8_t day() const { return (uint8_t)tmFields().tm_mday; }
|
||||
uint8_t hour() const { return (uint8_t)tmFields().tm_hour; }
|
||||
uint8_t minute() const { return (uint8_t)tmFields().tm_min; }
|
||||
uint8_t second() const { return (uint8_t)tmFields().tm_sec; }
|
||||
uint32_t unixtime() const { return _unixtime; }
|
||||
|
||||
private:
|
||||
struct tm tmFields() const {
|
||||
time_t t = (time_t)_unixtime;
|
||||
struct tm out;
|
||||
gmtime_r(&t, &out);
|
||||
return out;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user