mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-09-14 23:26:38 +00:00
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.
22 lines
624 B
C++
22 lines
624 B
C++
#pragma once
|
|
|
|
#include <Utils.h>
|
|
#include <cstdlib>
|
|
#include <ctime>
|
|
|
|
// mesh::RNG implementation for the native sim build. Not cryptographically
|
|
// strong (rand() under the hood) -- fine for a terminal demo; a real
|
|
// two-device-messaging phase (Phase 3 of the sim plan) may want to swap
|
|
// this for something seeded from the OS CSPRNG.
|
|
class SimRNG : public mesh::RNG {
|
|
public:
|
|
SimRNG() { }
|
|
void begin() {
|
|
unsigned seed = (unsigned)time(NULL) ^ (unsigned)(uintptr_t)this;
|
|
srand(seed);
|
|
}
|
|
void random(uint8_t* dest, size_t sz) override {
|
|
for (size_t i = 0; i < sz; i++) dest[i] = (uint8_t)rand();
|
|
}
|
|
};
|