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,33 @@
|
||||
#pragma once
|
||||
|
||||
// Minimal native stand-in for Arduino's Stream class. src/Utils.h includes
|
||||
// <Stream.h> directly (mesh::Utils::printHex(Stream&, ...)), and
|
||||
// src/Identity.cpp's readFrom/writeTo/printTo take a Stream& -- both real
|
||||
// hardware File objects (fs::File, Adafruit_LittleFS's File) and our own
|
||||
// SimFile (variants/sim/SimFS.h) derive from this, exactly like on real
|
||||
// boards.
|
||||
|
||||
#include "Print.h"
|
||||
|
||||
class Stream : public Print {
|
||||
public:
|
||||
virtual ~Stream() = default;
|
||||
|
||||
virtual int available() { return 0; }
|
||||
virtual int availableForWrite() { return 0; }
|
||||
virtual int read() { return -1; }
|
||||
virtual int peek() { return -1; }
|
||||
|
||||
virtual size_t readBytes(char *buffer, size_t length) {
|
||||
size_t i = 0;
|
||||
while (i < length) {
|
||||
int c = read();
|
||||
if (c < 0) break;
|
||||
buffer[i++] = (char)c;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
size_t readBytes(uint8_t *buffer, size_t length) {
|
||||
return readBytes((char *)buffer, length);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user