core: restore upstream shape for the shared mesh core

- Mesh, Dispatcher, Packet, packet pool and the core headers rebuilt from
  Arduino MeshCore's text; ZephCore changes re-applied, each fenced
  `// ZEPHCORE:` (diff vs upstream: 4540 -> 1147 lines)
- upstream header layout; MainBoard gains handleCommand/loop and the other
  upstream members; RNG::nextInt back in Utils.cpp
- packet logging moved to the roles' log hooks (helpers/PacketLog.h)
- zero-hop direct ACKs deduplicated and length-checked as upstream
- RadioIncludes.h -> src/, LoRaConfig.h -> helpers/
- .editorconfig: shared files keep upstream formatting

Verified: 10 role builds, per-function disassembly review, bench DM/ACK
regression (T1000-E, Wio L1, XIAO S3 on 1.17.4) incl. via live repeater.
This commit is contained in:
liquidraver
2026-09-23 13:39:48 +02:00
parent 2e2d852f29
commit a7d073900e
44 changed files with 2551 additions and 2488 deletions
+20
View File
@@ -14,6 +14,16 @@ LOG_MODULE_REGISTER(zephcore_utils, CONFIG_ZEPHCORE_MAIN_LOG_LEVEL);
namespace mesh {
uint32_t RNG::nextInt(uint32_t _min, uint32_t _max)
{
uint32_t num;
random((uint8_t *)&num, sizeof(num));
if (_max <= _min) { /* ZEPHCORE: no modulo by zero */
return _min;
}
return (num % (_max - _min)) + _min;
}
static uint8_t hexVal(char c)
{
if (c >= 'A' && c <= 'F') return c - 'A' + 10;
@@ -258,6 +268,16 @@ bool Utils::fromHex(uint8_t *dest, int dest_size, const char *src_hex)
return true;
}
bool Utils::isZeroes(const uint8_t *buf, size_t len)
{
while (len > 0) {
if (*buf != 0) return false;
buf++;
len--;
}
return true;
}
bool Utils::isHexChar(char c)
{
return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');