mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-09-14 15:16:40 +00:00
Merge upstream companion-v1.17.0 (CAD) into power-saving
Adopts hardware Channel Activity Detection (wired into RadioLibWrapper::isChannelActive() alongside our RSSI-threshold check and RX duty-cycle power-save), MCU temperature telemetry, LR2021 standby workaround, DISPLAY_SCALE/FLIP overrides, NRF52Board shutdownPeripherals() refactor, and misc upstream fixes. Declines upstream's ConfigSerializer-based NodePrefs rewrite, MultiSerialInterface/interface_manager, and UIColor palette system — each would have broken large parts of the Solo-specific feature set (NodePrefs fields, per-variant single serial_interface, enum-based DisplayDriver::Color). Flagged as candidate follow-up migrations, not permanent no's. Also fixes several pre-existing bugs surfaced while chasing silent merge breaks (stale newMsg() override signature in ui-tiny/ui-orig, dead UIEventType::newContactMessage case, missing ContactsIterator init), bumps FIRMWARE_VERSION/MESHCORE_VERSION to 1.17, and fixes a missing <cstdlib> include that broke the native ConfigSerializer unit tests. Verified via 13+ pio run builds across ESP32/nRF52, all 3 companion UI variants, and 7 display drivers, plus the full native unit test suite (33/33 passing). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include "Stream.h"
|
||||
|
||||
inline uint32_t g_mock_millis = 0;
|
||||
|
||||
using std::isnan;
|
||||
|
||||
inline uint32_t millis() {
|
||||
return g_mock_millis;
|
||||
}
|
||||
|
||||
inline void delay(uint32_t ms) {
|
||||
g_mock_millis += ms;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
class CayenneLPP {
|
||||
public:
|
||||
explicit CayenneLPP(size_t) {}
|
||||
const uint8_t* getBuffer() const { return nullptr; }
|
||||
uint16_t getSize() const { return 0; }
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include "Utils.h"
|
||||
|
||||
namespace mesh {
|
||||
|
||||
class Identity {
|
||||
public:
|
||||
uint8_t pub_key[PUB_KEY_SIZE];
|
||||
|
||||
Identity() {
|
||||
std::memset(pub_key, 0, sizeof(pub_key));
|
||||
}
|
||||
|
||||
explicit Identity(const uint8_t* src) {
|
||||
std::memcpy(pub_key, src, PUB_KEY_SIZE);
|
||||
}
|
||||
|
||||
bool verify(const uint8_t*, const uint8_t*, int) const {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class LocalIdentity : public Identity {
|
||||
public:
|
||||
LocalIdentity() : Identity() {}
|
||||
|
||||
void sign(uint8_t* sig, const uint8_t*, int) const {
|
||||
std::memset(sig, 0x5A, SIGNATURE_SIZE);
|
||||
}
|
||||
|
||||
void calcSharedSecret(uint8_t* secret, const uint8_t*) const {
|
||||
std::memset(secret, 0x11, PUB_KEY_SIZE);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace mesh {
|
||||
|
||||
class Radio {
|
||||
public:
|
||||
virtual ~Radio() = default;
|
||||
virtual bool isReceiving() { return false; }
|
||||
virtual uint32_t getEstAirtimeFor(uint16_t) { return 10; }
|
||||
virtual bool startSendRaw(const uint8_t*, uint16_t) { return true; }
|
||||
virtual bool isSendComplete() { return true; }
|
||||
virtual void onSendFinished() {}
|
||||
virtual int16_t getNoiseFloor() { return -120; }
|
||||
};
|
||||
|
||||
class MainBoard {
|
||||
public:
|
||||
virtual ~MainBoard() = default;
|
||||
virtual uint16_t getBattMilliVolts() { return 4200; }
|
||||
virtual float getMCUTemperature() { return 25.0f; }
|
||||
virtual const char* getManufacturerName() { return "mock-board"; }
|
||||
virtual void reboot() {}
|
||||
};
|
||||
|
||||
}
|
||||
+25
-4
@@ -3,12 +3,33 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
// Mock SHA256 class for testing
|
||||
// Provides minimal interface to allow Utils.cpp to compile
|
||||
// Mock SHA256 for native testing — deterministic but not cryptographic.
|
||||
// finalize() writes real (non-garbage) output so calculatePacketHash() produces
|
||||
// distinguishable results for packets with different payloads.
|
||||
#include <string.h>
|
||||
|
||||
class SHA256 {
|
||||
uint8_t _state[32];
|
||||
size_t _len;
|
||||
public:
|
||||
void update(const uint8_t* data, size_t len) {}
|
||||
void finalize(uint8_t* hash, size_t hashLen) {}
|
||||
SHA256() : _len(0) { memset(_state, 0, sizeof(_state)); }
|
||||
|
||||
void update(const void* data, size_t len) {
|
||||
const uint8_t* bytes = static_cast<const uint8_t*>(data);
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
uint8_t b = bytes[i];
|
||||
_state[_len % 32] ^= b;
|
||||
_state[(_len + 1) % 32] += (uint8_t)((b >> 1) | (b << 7));
|
||||
_len++;
|
||||
}
|
||||
}
|
||||
|
||||
void finalize(uint8_t* hash, size_t hashLen) {
|
||||
for (size_t i = 0; i < hashLen; i++) {
|
||||
hash[i] = _state[i % 32];
|
||||
}
|
||||
}
|
||||
|
||||
void resetHMAC(const uint8_t* key, size_t keyLen) {}
|
||||
void finalizeHMAC(const uint8_t* key, size_t keyLen, uint8_t* hash, size_t hashLen) {}
|
||||
};
|
||||
|
||||
+66
-3
@@ -1,10 +1,73 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
// Mock Stream class for native testing
|
||||
// Provides minimal interface needed by Utils.h
|
||||
|
||||
class Stream {
|
||||
#define DEC 10
|
||||
#define HEX 16
|
||||
#define OCT 8
|
||||
#define BIN 2
|
||||
|
||||
class Print
|
||||
{
|
||||
public:
|
||||
virtual void print(char c) {}
|
||||
virtual void print(const char* str) {}
|
||||
virtual size_t write(uint8_t b) { return 1; }
|
||||
size_t write(const char *str)
|
||||
{
|
||||
if(str == NULL) {
|
||||
return 0;
|
||||
}
|
||||
return write((const uint8_t *) str, strlen(str));
|
||||
}
|
||||
virtual size_t write(const uint8_t *buffer, size_t size) {
|
||||
size_t t = 0;
|
||||
for (int i = 0; i < size; i++) { t += write(buffer[i]); }
|
||||
return t;
|
||||
}
|
||||
size_t write(const char *buffer, size_t size)
|
||||
{
|
||||
return write((const uint8_t *) buffer, size);
|
||||
}
|
||||
|
||||
virtual size_t print(unsigned char b, int r = DEC) { return 0; }
|
||||
virtual size_t print(int v, int r = DEC) { return 0; }
|
||||
virtual size_t print(unsigned int v, int r = DEC) { return 0; }
|
||||
virtual size_t print(long v, int r = DEC) { return 0; }
|
||||
virtual size_t print(unsigned long v, int r = DEC) { return 0; }
|
||||
virtual size_t print(long long v, int r = DEC) { return 0; }
|
||||
virtual size_t print(unsigned long long v, int r = DEC) { return 0; }
|
||||
virtual size_t print(double v, int p = 2) { return 0; }
|
||||
|
||||
size_t print(char c) { return write(c); }
|
||||
size_t print(const char* str) { return write(str); }
|
||||
|
||||
//size_t println(void) { return 0; }
|
||||
|
||||
virtual void flush() { /* Empty implementation for backward compatibility */ }
|
||||
};
|
||||
|
||||
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 0; }
|
||||
|
||||
virtual size_t readBytes(char *buffer, size_t length) {
|
||||
size_t i = 0;
|
||||
while (i < length && available()) {
|
||||
buffer[i++] = read();
|
||||
}
|
||||
return i;
|
||||
}
|
||||
virtual size_t readBytes(uint8_t *buffer, size_t length)
|
||||
{
|
||||
return readBytes((char *) buffer, length);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
|
||||
#define PUB_KEY_SIZE 32
|
||||
#define PRV_KEY_SIZE 64
|
||||
#define SIGNATURE_SIZE 64
|
||||
#define CIPHER_MAC_SIZE 16
|
||||
|
||||
namespace mesh {
|
||||
|
||||
class RNG {
|
||||
public:
|
||||
virtual ~RNG() = default;
|
||||
virtual void random(uint8_t* dest, size_t sz) = 0;
|
||||
};
|
||||
|
||||
class Utils {
|
||||
public:
|
||||
static void sha256(uint8_t* hash, size_t hash_len, const uint8_t*, int) {
|
||||
std::memset(hash, 0, hash_len);
|
||||
}
|
||||
|
||||
static int encryptThenMAC(const uint8_t*, uint8_t* dest, const uint8_t* src, int src_len) {
|
||||
int out_len = src_len + CIPHER_MAC_SIZE;
|
||||
std::memset(dest, 0xAA, CIPHER_MAC_SIZE);
|
||||
std::memcpy(dest + CIPHER_MAC_SIZE, src, src_len);
|
||||
return out_len;
|
||||
}
|
||||
|
||||
static int MACThenDecrypt(const uint8_t*, uint8_t* dest, const uint8_t* src, int src_len) {
|
||||
if (src_len < CIPHER_MAC_SIZE) {
|
||||
return 0;
|
||||
}
|
||||
int out_len = src_len - CIPHER_MAC_SIZE;
|
||||
std::memcpy(dest, src + CIPHER_MAC_SIZE, out_len);
|
||||
return out_len;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include "CayenneLPP.h"
|
||||
|
||||
class SensorManager {
|
||||
public:
|
||||
virtual ~SensorManager() = default;
|
||||
virtual bool querySensors(uint8_t, CayenneLPP&) { return false; }
|
||||
};
|
||||
Reference in New Issue
Block a user