Compare commits

...
Author SHA1 Message Date
upstream-sync-bot 95be305143 Merge upstream/dev (2 commits) [upstream-sync]
pub-release / release (push) Successful in 32m59s
2026-11-22 05:05:36 +00:00
ripplebiz 0d72bcd44c Merge pull request #3892 from meshcore-dev/repeater-telem-push
Repeater telemetry push
2026-11-22 10:23:36 +11:00
Scott Powell e3c54039fe * copied sensor telemetry push 2026-11-21 20:59:42 +11:00
tthandClaude Opus 5.5 9652199464 Merge upstream/dev (16 commits): UITask moved to src/helpers/ui
pub-release / release (push) Successful in 37m52s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 12:39:13 +01:00
fdlamotte cbb830b2b3 Merge pull request #3882 from meshcore-dev/common-prefs-fix
* removed various copied 'dirty' members
2026-11-19 20:25:58 -04:00
ripplebiz 66a01a227f Merge pull request #3881 from meshcore-dev/ui-task-refactor
UI task refactor
2026-11-20 11:17:26 +11:00
Scott Powell 19728e43a5 * removed various copied 'dirty' members 2026-11-20 11:07:37 +11:00
Scott Powell 6ec03df241 * unit test fix 2026-11-20 11:02:45 +11:00
tthandClaude Opus 5.5 b30cda7936 Repeater, room server, sensor (nRF52): get chip tells the silicon and whether SWD can read the flash
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 20:42:59 +01:00
upstream-sync-bot ac49cd6621 Merge upstream/dev (2 commits) [upstream-sync]
pub-release / release (push) Successful in 33m10s
2026-11-19 17:05:35 +00:00
tthandClaude Opus 5.5 1f9bbc71d8 CI, tools: DFU packages signed for the locked bootloader, and LOCKED_NODE releases
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 17:50:56 +01:00
fdlamotte 6e47ba6fa6 Merge pull request #3776 from Blake-Latchford/docs/stats-core-error-flags
docs: describe stats-core output and its error flags
2026-11-19 12:42:00 -04:00
tthandClaude Opus 5.5 b7249f449a Repeater, room server, sensor, companion: build flag LOCKED_NODE for a node that keeps its secrets from whoever holds it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 17:21:29 +01:00
tthandClaude Opus 5.5 769139999d Companion: the private key and the BLE PIN are again refused over USB, UART and WiFi -- only paired BLE gets them
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 17:09:12 +01:00
tthandClaude Opus 5.5 cac3249e41 README: the companion's public BLE PIN, and what physical access to a node gives away
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 16:07:23 +01:00
tthandClaude Opus 5.5 dcf10d1c86 Repeater, room server, sensor: a long unknown get no longer overruns the reply buffer
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 15:56:28 +01:00
Scott Powell ad701588d7 * final fix 2026-11-19 18:32:36 +11:00
Scott Powell dad7186c5b * more fixes 2026-11-19 18:19:26 +11:00
Scott Powell 54a88a307a * misc fixes 2026-11-19 17:56:59 +11:00
Scott Powell 6c45b94783 * 2nd round of .ini refactors 2026-11-19 17:18:54 +11:00
Scott Powell ce02d5a787 * lotsa super boring refactoring 2026-11-19 15:22:23 +11:00
Scott Powell 98f9e81681 * thinknode_m5: simplified the target.* modules 2026-11-19 12:05:14 +11:00
Scott Powell 69b335d700 Merge commit 'b72fd0dd5e784e6f903380b05287de0652f49819' into ui-task-refactor 2026-11-19 11:54:54 +11:00
Scott Powell 1ad8ca230a * UITask constructors now with same params, so don't have to have separate target-* modules/dirs 2026-11-19 11:54:24 +11:00
fdlamotte b72fd0dd5e ui-task: apply refactoring on thinknode_m5 (#3869) 2026-11-18 11:40:11 -04:00
Scott Powell 26ae484af8 * interface manager now injected via begin() 2026-11-18 23:31:08 +11:00
tthandClaude Opus 5.5 961547c7d2 README, docs: replay floor for admins only (de92ca9b), capped wrong passwords and the blank-login floor (dbdae145) -- LOGIN_FAIL_MAX/SECS, upstream candidates
pub-release / release (push) Successful in 38m32s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 13:04:29 +01:00
tthandClaude Opus 5.5 dbdae14566 Repeater, room server, sensor: passwords can no longer be guessed over the air at full speed, and a replayed login no longer floods a reply
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 13:03:59 +01:00
tthandClaude Opus 5.5 de92ca9ba2 Repeater, room server, sensor: guests no longer cause a flash write per request
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 12:57:53 +01:00
Scott Powell d05ed2122c * companion UI's moved/refactored to src/helpers/ui
* only select variants .ini config refactored so far (Heltec V3, MeshTracker V1, LilyGo T-Echo Card)
2026-11-18 22:00:04 +11:00
tthandClaude Opus 5.5 84f6fa03b2 CI: release notes list firmware changes first, fold docs/tools/CI, and take a curated "Changelog:" line
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 11:12:48 +01:00
Scott Powell 0b38bfd81a * refactored UITask from repeater/room/sensor to /helpers/ui/server
* added BaseUITask for common behaviours
* ui_task now instantiated in one of the variant's target-*.cpp modules
2026-11-18 18:18:06 +11:00
Blake LatchfordandClaude Opus 5.5 7d5499e9eb docs: describe stats-core output and its error flags
Document the stats-core output fields and decode the `errors` bitmask
(shown as "Debug flags" in the app), from the ERR_EVENT_* flags in
Dispatcher.h, and note that the flags stay set until reboot or
`clear stats`.

Fixes #3039

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 21:19:12 -05:00
283 changed files with 2128 additions and 962 deletions

No files matched your search

+36 -9
View File
@@ -19,8 +19,9 @@
# body the version the node reports (`ver`: v1.18.0-tth<sha>). Until 12. 11.
# 2026 the tags were tth-<sha8>; pruning and the changelog know both;
# the newest KEEP releases stay, older ones are deleted. The body is a
# changelog since the previous release: our own commits, then the upstream
# PRs the upstream merges brought in.
# changelog since the previous release: our own firmware commits, our docs /
# tools / CI commits folded, then the upstream PRs the upstream merges brought
# in. A "Changelog: <text>" line in a commit body replaces its subject there.
# nRF52: .uf2 (drag onto the bootloader drive) and .zip (DFU over BLE or
# serial); ESP32: -merged.bin (fresh install at 0x0) and .bin (update).
#
@@ -333,18 +334,36 @@ jobs:
# ours: commits on our main itself (first parent); a merge of one of
# our own branches (feat/...) is unfolded into the branch's commits,
# an upstream merge is left to the upstream list below
fmt="- %s ([%h]($web/commit/%H))"
ours=""
ourc=()
for c in $(git log --first-parent --format=%H "$base..$SHA"); do
if git rev-parse -q --verify "$c^2" >/dev/null; then
git log -1 --format=%s "$c" | grep -q '^Merge upstream' && continue
# ^base: a merge of main into a branch carries what is released already
ours+=$(git log --no-merges --format="$fmt" "$c^1..$c^2" "^$base")$'\n'
mapfile -t -O "${#ourc[@]}" ourc < <(git log --no-merges --format=%H "$c^1..$c^2" "^$base")
else
ours+=$(git log -1 --format="$fmt" "$c")$'\n'
ourc+=("$c")
fi
done
ours=${ours%$'\n'}
# Firmware changes first; docs, CI, tools and tests folded away. Sorted
# by the files a commit touches, so it holds even for a poor subject.
# A "Changelog: <text>" line in the body replaces the subject in the
# notes ("Changelog: -" leaves the commit out), so the subject can stay
# technical while the notes say what changes for the node.
fw="" other="" nother=0
for c in "${ourc[@]}"; do
line=$(git log -1 --format=%b "$c" | sed -n 's/^Changelog: *//p' | head -1)
[ "$line" = "-" ] && continue
[ -n "$line" ] || line=$(git log -1 --format=%s "$c")
line="- $line ([${c:0:8}]($web/commit/$c))"
if git diff-tree --no-commit-id --name-only -r "$c" |
grep -qE '^(src|examples|variants|lib|boards|arch)/|^platformio\.ini$'; then
fw+="$line"$'\n'
else
other+="$line"$'\n'
nother=$((nother + 1))
fi
done
fw=${fw%$'\n'} other=${other%$'\n'}
# upstream: the first-parent line of each merged upstream branch,
# PR merges as their title, direct commits as their subject
declare -A seen=()
@@ -375,9 +394,17 @@ jobs:
echo "Od předchozího vydání · since [$prev]($web/releases/tag/$(jq -rn --arg s "$prev" '$s|@uri'))"
echo
fi
echo "### Změny forku · fork changes"
echo "${ours:-- žádné · none}"
echo "### Změny firmwaru · firmware changes"
echo "${fw:-- žádné · none}"
echo
if [ "$nother" -gt 0 ]; then
echo "<details><summary>Dokumentace, nástroje, CI · docs, tools, CI ($nother)</summary>"
echo
echo "$other"
echo
echo "</details>"
echo
fi
echo "### Z upstreamu MeshCore · from upstream ($n)"
[ "$n" -gt 0 ] && printf '%s\n' "${ups[@]:0:$max}" || echo "- žádné · none"
[ "$n" -le "$max" ] || echo "- … a dalších $((n - max)) · and $((n - max)) more"
+53 -7
View File
@@ -114,7 +114,17 @@ Repeater navíc:
než příkaz provedou (`/s_acl_ts0|1`, střídavě s kontrolním součtem, takže
ho nesmaže ani výpadek napájení při zápisu). Timestamp víc než den před
hodinami uzlu (`ACL_TS_MAX_AHEAD`) se přijme, ale neuloží, aby companion
s rozhozenými hodinami nezamkl admina. Klientů se to nijak netýká.
s rozhozenými hodinami nezamkl admina. Ukládá se jen u adminů: host smí
jen číst a s prázdným guest heslem se jím stane kdokoli, takže by každý
jeho dotaz znamenal zápis do flash. Klientů se to nijak netýká.
* **Hesla nejde hádat přes éter plnou rychlostí.** Upstream kontroluje každý
login bez omezení a na špatné heslo ani neodpoví. Po 4 špatných heslech
během 3 minut (`LOGIN_FAIL_MAX`, `LOGIN_FAIL_SECS`) se hesla do konce okna
nekontrolují. Klient, který už je v ACL jako admin, projde vždy – login
jeho jménem nikdo jiný poslat nedokáže, takže útok adminy nezamkne.
* **Přehraný login bez hesla už nevyvolá flood odpověď.** Login klienta z ACL
s prázdným heslem neměl ochranu proti přehrání; útočník tím nic nezískal,
ale každá kopie donutila uzel poslat odpověď floodem přes celý mesh.
* TRACE už nepřipisuje cestu za konec payloadu; parsování TRACE/PATH
a `Packet::readFrom` hlídají meze.
* `markSeen` je zase idempotentní (odesílací cesta ujídala okno deduplikace).
@@ -159,9 +169,12 @@ Repeater navíc:
patch pro INA219: Alkel Brostl). Čipy INA se rozlišují podle ID, takže
INA226 už se nedetekuje jako INA219. Odpor bočníku se nastavuje za běhu
a ukládá se: `sensor set ina.shunt <mΩ>`.
* Companion: `gps duty` přežije reboot, export klíče a PIN jsou na
neověřeném USB spojení zamčené, kopie data sestavení má hlídanou délku.
KISS modem: oprava o jedna vedle při zkracování jména.
* Companion: `gps duty` přežije reboot, kopie data sestavení má hlídanou
délku. Export privátního klíče, čtení BLE PINu a jeho změna (i přes CLI
`set pin`) jdou jen přes spárované BLE, ne přes USB, UART ani WiFi/TCP,
a odpověď s klíčem či PINem jde jen tam, odkud přišel dotaz. (Merge v1.17
tu kontrolu potichu vyřadil; build bez BLE bere své jediné rozhraní dál
jako důvěryhodné.) KISS modem: oprava o jedna vedle při zkracování jména.
### Veřejné buildy: výchozí nastavení pro český mesh
@@ -183,6 +196,15 @@ Platí jen pro uzel bez uloženého nastavení (nový nebo po `erase`): nové
nahrání ponechá, co už uzel má, a regiony, které jsi smazal a uložil,
zůstanou smazané. Jméno a admin heslo si nastav sám.
**BLE PIN companionu je veřejný `123456`** (desky s displejem si losují
vlastní a ukážou ho). Kdo se s ním spáruje, má companion celý: zprávy,
kontakty, export privátního klíče. Po prvním spárování ho proto změň
v aplikaci. A s deskou v ruce nechrání nic ani PIN, ani heslo: flash není
zamčená a bootloader přijme jakýkoli firmware. Ztracený nebo ukradený uzel
ber jako vyzrazený – u repeateru změň admin heslo všude, kde bylo stejné,
a vyhoď jeho klíč z ACL; u companionu ber kanály, které na něm byly, jako
známé.
Varianty observer (`*_repeater-observer-*`) nRF52 repeaterů (XIAO, SenseCAP
Solar, RAK4631, T1000-E, Heltec T114) přidávají buffery `nodes` / `rxlog` /
`pktlog` a textovou konzoli přes BLE, aby šel repeater číst přes USB nebo BLE
@@ -410,7 +432,18 @@ The repeater also has:
command (`/s_acl_ts0|1`, alternating with a checksum, so a power cut mid-write
does not lose it). A timestamp more than a day ahead of the node's clock
(`ACL_TS_MAX_AHEAD`) is accepted but not stored, so a companion with a runaway
clock cannot lock its admin out. Nothing changes for clients.
clock cannot lock its admin out. Only admins are stored: a guest can only
read, and with the empty guest password anybody is one, so its every
request would be a flash write. Nothing changes for clients.
* **Passwords can no longer be guessed over the air at full speed.** Upstream
checks every login without a limit and does not even answer a wrong one.
After 4 wrong passwords within 3 minutes (`LOGIN_FAIL_MAX`,
`LOGIN_FAIL_SECS`) no password is checked until the window ends. A client
that is already an admin in the ACL always gets through -- nobody else can
send a login in its name, so the attack cannot lock the admins out.
* **A replayed blank-password login no longer floods a reply.** A login from a
client in the ACL with an empty password had no replay check; replayed, it
gained nothing, but every copy made the node flood its reply over the mesh.
* TRACE no longer appends its path past the end of the payload; TRACE/PATH
parsing and `Packet::readFrom` are bounds-checked.
* `markSeen` is idempotent again (the send path was eating the dedup window).
@@ -455,8 +488,12 @@ The repeater also has:
and first INA219 patch: Alkel Brostl). INA chips are told apart by their ID,
so an INA226 is no longer taken for an INA219. The shunt is set at runtime
and saved: `sensor set ina.shunt <mOhm>`.
* Companion: `gps duty` persists, key export / PIN gated on an unauthenticated
USB link, bounded build-date copy. KISS modem: off-by-one in the name clamp.
* Companion: `gps duty` persists, bounded build-date copy. Private key
export, reading the BLE PIN and changing it (CLI `set pin` included) work
only over paired BLE, never over USB, a UART or WiFi/TCP, and the reply that
carries the key or PIN goes back only where the request came from. (The
v1.17 merge had silently disabled that gate; a build without BLE still
trusts its one transport.) KISS modem: off-by-one in the name clamp.
### Public builds: Czech mesh defaults
@@ -478,6 +515,15 @@ They apply only to a node with no saved settings (new, or after an erase):
a reflash keeps whatever the node already has, and regions you removed and
saved stay removed. Set a name and an admin password yourself.
**The companion's BLE PIN is the public `123456`** (boards with a display
draw their own and show it). Whoever pairs with it owns the companion:
messages, contacts, private key export. So change it in the app after the
first pairing. And with the board in hand neither the PIN nor a password
protects anything: the flash is not locked and the bootloader takes any
firmware. Treat a lost or stolen node as compromised -- for a repeater,
change the admin password wherever it was the same and drop its key from
ACLs; for a companion, treat the channels it held as known.
Observer variants (`*_repeater-observer-*`) of the nRF52 repeaters (XIAO,
SenseCAP Solar, RAK4631, T1000-E, Heltec T114) add the `nodes` / `rxlog` /
`pktlog` rings and a text console over BLE, for reading the repeater over
+12
View File
@@ -177,6 +177,18 @@ in order of preference:
**Serial Only:** Yes
**Note:** Output format: `{"battery_mv":<mV>,"uptime_secs":<secs>,"errors":<flags>,"queue_len":<count>}`
**Note:** `errors` is a bitmask shown as "Debug flags" in the app's repeater status.
| Value | Flag | Meaning |
|-------|------|---------|
| 1 | `ERR_EVENT_FULL` | A packet failed to send because the memory pool was full. |
| 2 | `ERR_EVENT_CAD_TIMEOUT` | After waiting 4 seconds for a gap, a packet was transmitted into a busy network. |
| 4 | `ERR_EVENT_STARTRX_TIMEOUT` | The radio was out of receive mode for more than 8 seconds. |
Flags stay set until the node reboots or `clear stats` is run.
---
### Radio Stats - Noise floor, Last RSSI/SNR, Airtime, Receive errors
+3
View File
@@ -113,6 +113,7 @@ stall watchdog", "Reboot into the bootloader" and "Why the board last reset".
| `blink [n]` / `blink on\|off` | repeater | flash a spare LED (not the BLE or TX one) `n` times (default 6, max 999), or until `blink off` (gives up after 10 min); finds a board on a bench or a node on a mast |
| `txpwr [dBm]` | repeater | LoRa output power until reboot, with RadioLib's status (`set tx` saves and says OK even when the radio refused) |
| `i2c` | all | scan the I2C bus |
| `get chip` | nRF52 (repeater, room server, sensor) | the silicon (`nRF52840 AAD0`; variant `xxF0` and later = rev3) and `UICR.APPROTECT`: `open` means SWD can read the whole flash, keys included ([locked-bootloader.md](locked-bootloader.md)) |
| `dio1` | own build: `PIN_DIAG` | has the SX1262 raise TX_DONE and compares its IRQ register with the level on the DIO1 pin -- which end of a dead IRQ line is broken |
| `radiostat` | own build: `RADIO_DIAG` | receiver state, interrupt and RX counters, without touching the radio |
| `radiokick rx\|clrirq\|standby\|agc` | own build: `RADIO_DIAG` | one recovery step, gentlest first: re-arm RX, clear latched IRQs, standby + RX, AGC reset; the first that brings `recv` back names the broken layer |
@@ -189,6 +190,8 @@ The ones that change what a node does; set in `platformio.ini` /
| `FW_OTA` | `-ota` images | admin-pushed firmware update |
| `PATH_HASH_MODE_DEFAULT` | `1` (2 B per hop) | path hash width for a node without prefs |
| `ACL_TS_MAX_AHEAD` | `86400` (s) | a client timestamp further ahead of the node's clock is not stored as the replay floor |
| `LOCKED_NODE` | unset | a node that keeps its secrets from whoever holds it: `get prv.key`, `get guest.password` and `get bridge.secret` answer `Error: locked build` to everyone (USB and BLE console, an admin over the mesh); a companion serves only paired BLE (USB, UART and WiFi get the device info and nothing else) and its rescue CLI refuses `set pin`. Only half of it: [locked-bootloader.md](locked-bootloader.md) |
| `LOGIN_FAIL_MAX`, `LOGIN_FAIL_SECS` | `4`, `180` (s) | after that many wrong passwords in the window no password is checked until it ends (an admin already in the ACL always gets in) |
Prefs saved on the node override the build defaults: a reflash keeps what a
node already has; only a new node or one after `erase` takes them.
+1 -1
View File
@@ -3,7 +3,7 @@
#include <helpers/IdentityStore.h>
#include <helpers/ContactInfo.h>
#include <helpers/ChannelDetails.h>
#include "NodePrefs.h"
#include <helpers/CompanionNodePrefs.h>
class DataStoreHost {
public:
+22 -32
View File
@@ -392,20 +392,6 @@ void MyMesh::onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path
if (!is_new) dirty_contacts_expiry = futureMillis(LAZY_CONTACTS_WRITE_DELAY); // only schedule lazy write for contacts that are in contacts[]
}
static int sort_by_recent(const void *a, const void *b) {
return ((AdvertPath *) b)->recv_timestamp - ((AdvertPath *) a)->recv_timestamp;
}
int MyMesh::getRecentlyHeard(AdvertPath dest[], int max_num) {
if (max_num > ADVERT_PATH_TABLE_SIZE) max_num = ADVERT_PATH_TABLE_SIZE;
qsort(advert_paths, ADVERT_PATH_TABLE_SIZE, sizeof(advert_paths[0]), sort_by_recent);
for (int i = 0; i < max_num; i++) {
dest[i] = advert_paths[i];
}
return max_num;
}
void MyMesh::onContactPathUpdated(const ContactInfo &contact) {
out_frame[0] = PUSH_CODE_PATH_UPDATED;
memcpy(&out_frame[1], contact.id.pub_key, PUB_KEY_SIZE);
@@ -1070,6 +1056,16 @@ void MyMesh::startInterface(BaseSerialInterface &serial) {
}
void MyMesh::handleCmdFrame(size_t len) {
#ifdef LOCKED_NODE
// CUSTOM (TeTeHacko): a locked companion serves only paired BLE. USB, a UART
// and WiFi/TCP get the device info (so an app sees what it talks to) and
// nothing else: no contacts, channels, messages or settings for whoever holds
// the board or sits on the LAN. docs/locked-bootloader.md, point 4.
if (!_serial->isConnectionSecure() && cmd_frame[0] != CMD_DEVICE_QUERY) {
writeDisabledFrame();
return;
}
#endif
if (cmd_frame[0] == CMD_DEVICE_QUERY && len >= 2) { // sent when app establishes connection
app_target_ver = cmd_frame[1]; // which version of protocol does app understand
@@ -1098,7 +1094,7 @@ void MyMesh::handleCmdFrame(size_t len) {
i += 20;
out_frame[i++] = _prefs.isRepeatEn() ? 1 : 0; // v9+
out_frame[i++] = _prefs.path_hash_mode; // v10+
_serial->writeFrame(out_frame, i);
_serial->writeReplyFrame(out_frame, i); // carries the PIN: never to the other transports
} else if (cmd_frame[0] == CMD_APP_START &&
len >= 8) { // sent when app establishes connection, respond with node ID
// cmd_frame[1..7] reserved future
@@ -1148,7 +1144,11 @@ void MyMesh::handleCmdFrame(size_t len) {
text[tlen] = 0; // ensure null
reply_buf[0] = 0;
if (!handleCommand(text, 0, reply_buf)) {
if (memcmp(text, "set pin ", 8) == 0 && !_serial->isConnectionSecure()) {
// CUSTOM (TeTeHacko): the same gate as CMD_SET_DEVICE_PIN -- through the
// CLI, USB set the PIN it may not set directly, then paired over BLE
strcpy(reply_buf, "Error: set pin only over paired BLE");
} else if (!handleCommand(text, 0, reply_buf)) {
strcat(reply_buf, "Unknown command"); // reply_buf may have cmd prefix from 'text'
}
out_frame[0] = RESP_CODE_CLI_REPLY;
@@ -1569,7 +1569,7 @@ void MyMesh::handleCmdFrame(size_t len) {
uint8_t reply[65];
reply[0] = RESP_CODE_PRIVATE_KEY;
self_id.writeTo(&reply[1], 64);
_serial->writeFrame(reply, 65);
_serial->writeReplyFrame(reply, 65); // only back to the paired BLE peer, not out on USB too
}
#else
writeDisabledFrame();
@@ -2488,6 +2488,11 @@ void MyMesh::checkCLIRescueCmd() {
cli_command[len - 1] = 0; // replace newline with C string null terminator
reply_buf[0] = 0;
#ifdef LOCKED_NODE
if (memcmp(cli_command, "set pin ", 8) == 0) { // CUSTOM (TeTeHacko): a known PIN = pair and read it all
Serial.println(" Error: locked build");
} else
#endif
if (handleCommand(cli_command, 0, reply_buf)) {
// command was handled, print reply output
Serial.print(" "); Serial.print(reply_buf); Serial.println();
@@ -2685,21 +2690,6 @@ void MyMesh::loop() {
}
}
bool MyMesh::advert() {
mesh::Packet* pkt;
if (_prefs.advert_loc_policy == ADVERT_LOC_NONE) {
pkt = createSelfAdvert(_prefs.node_name);
} else {
pkt = createSelfAdvert(_prefs.node_name, sensors.node_lat, sensors.node_lon);
}
if (pkt) {
sendZeroHop(pkt);
return true;
} else {
return false;
}
}
// To check if there is pending work
bool MyMesh::hasPendingWork() const {
return _mgr->getOutboundTotal() > 0 || dirty_contacts_expiry != 0;
+11 -36
View File
@@ -23,7 +23,7 @@
#endif
#include "DataStore.h"
#include "NodePrefs.h"
#include <helpers/CompanionNodePrefs.h>
#include <RTClib.h>
#include <helpers/ArduinoHelpers.h>
@@ -68,6 +68,7 @@
#include <helpers/BaseChatMesh.h>
#include <helpers/TransportKeyStore.h>
#include <helpers/MeshEventListener.h>
/* -------------------------------------------------------------------------------------- */
@@ -75,10 +76,6 @@
#define REQ_TYPE_KEEP_ALIVE 0x02
#define REQ_TYPE_GET_TELEMETRY_DATA 0x03
// Copied from simple_repeater
#define CTL_TYPE_NODE_DISCOVER_REQ 0x80
#define CTL_TYPE_NODE_DISCOVER_RESP 0x90
struct AdvertPath {
uint8_t pubkey_prefix[7];
uint8_t path_len;
@@ -89,30 +86,11 @@ struct AdvertPath {
class MyMesh : public BaseChatMesh, public DataStoreHost {
public:
class Listener {
public:
virtual void onMessageRecv(mesh::Packet *pkt, const ContactInfo &from, uint8_t txt_type, uint32_t sender_timestamp, const char* text) = 0;
virtual void onChannelMessageRecv(mesh::Packet *pkt, ChannelDetails& channel_details, const char* text) = 0;
virtual void onQueueSizeChanged(int msgcount) = 0;
virtual void onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path_len, const uint8_t* path) { }
virtual void onControlDataRecv(const mesh::Packet* pkt) { }
virtual void onChannelDataRecv(mesh::Packet *pkt, const mesh::GroupChannel &channel, uint16_t data_type,
const uint8_t *data, size_t data_len) { }
virtual void onACKRecv(uint32_t ack_crc) { }
virtual uint8_t onUnhandledRequest(const ContactInfo &contact, uint32_t sender_timestamp, const uint8_t *data,
uint8_t len, uint8_t *reply) { return 0; /* unknown request type */ }
virtual bool onUnhandledResponse(const ContactInfo &from, uint32_t tag, const uint8_t* data, uint8_t len) { return false; /* not handled */ }
virtual void onTraceRecv(mesh::Packet *pkt, uint32_t tag, uint32_t auth_code, uint8_t flags,
const uint8_t *path_snrs, const uint8_t *path_hashes, uint8_t path_len) { }
virtual void onRawDataRecv(mesh::Packet *pkt) { }
virtual ~Listener() { }
};
MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMeshTables &tables, DataStore& store);
void begin();
void startInterface(BaseSerialInterface &serial);
void setListener(Listener* listener) { _listener = listener; }
void setListener(MeshEventListener* listener) { _listener = listener; }
const char *getNodeName();
NodePrefs *getNodePrefs();
@@ -121,10 +99,14 @@ public:
void loop();
void handleCmdFrame(size_t len);
bool advert();
void enterCLIRescue();
int getRecentlyHeard(AdvertPath dest[], int max_num);
void enterCLIRescue() override;
void savePrefs() override {
_prefs.node_lat = sensors.node_lat;
_prefs.node_lon = sensors.node_lon;
_store->savePrefs(_prefs);
_prefs.clearDirty();
}
protected:
float getAirtimeBudgetFactor() const override;
@@ -199,13 +181,6 @@ protected:
}
public:
void savePrefs() {
_prefs.node_lat = sensors.node_lat;
_prefs.node_lon = sensors.node_lon;
_store->savePrefs(_prefs);
_prefs.clearDirty();
}
#if ENV_INCLUDE_GPS == 1
void applyGpsPrefs() {
if (_prefs.gps_interval > 0 &&
@@ -255,7 +230,7 @@ private:
uint32_t pending_telemetry, pending_discovery; // pending _TELEMETRY_REQ
uint32_t pending_req; // pending _BINARY_REQ
BaseSerialInterface *_serial;
Listener* _listener;
MeshEventListener* _listener;
ContactsIterator _iter;
uint32_t _iter_filter_since;
+1 -6
View File
@@ -112,11 +112,6 @@ MultiSerialInterface interface_manager;
#endif
/* GLOBAL OBJECTS */
#ifdef DISPLAY_CLASS
#include "UITask.h"
UITask ui_task(&board, &interface_manager);
#endif
StdRNG fast_rng;
SimpleMeshTables tables;
MyMesh the_mesh(radio_driver, fast_rng, rtc_clock, tables, store);
@@ -328,7 +323,7 @@ void setup() {
sensors.applyInaShunt(the_mesh.getNodePrefs()->ina_shunt_mohm); // CUSTOM (TeTeHacko)
#ifdef DISPLAY_CLASS
ui_task.begin(disp, &sensors, the_mesh.getNodePrefs()); // still want to pass this in as dependency, as prefs might be moved
ui_task.begin(disp, &sensors, the_mesh.getNodePrefs(), &interface_manager, &the_mesh, the_mesh.getBLEPin(), FIRMWARE_VERSION, FIRMWARE_BUILD_DATE);
the_mesh.setListener(&ui_task);
#ifdef EINK_REFRESH_LOOP
if (disp != NULL) disp->setBusyHook(loopDuringDisplayRefresh);
+175 -2
View File
@@ -1,5 +1,6 @@
#include "MyMesh.h"
#include <algorithm>
#include <helpers/sensors/LPPDataHelpers.h>
/* ------------------------------ Config -------------------------------- */
@@ -41,6 +42,14 @@
#define TXT_ACK_DELAY 200
#endif
#ifndef SENSOR_READ_INTERVAL_SECS
#define SENSOR_READ_INTERVAL_SECS 60
#endif
#ifndef TELEM_SUBSCRIBE_MAX_SECS
#define TELEM_SUBSCRIBE_MAX_SECS 3600
#endif
#define FIRMWARE_VER_LEVEL 2
#define REQ_TYPE_GET_STATUS 0x01 // same as _GET_STATS
@@ -50,6 +59,9 @@
#define REQ_TYPE_GET_NEIGHBOURS 0x06
#define REQ_TYPE_GET_OWNER_INFO 0x07 // FIRMWARE_VER_LEVEL >= 2
#define REQ_TYPE_SUBSCRIBE 0x08
#define REQ_TYPE_UNSUBSCRIBE 0x09
#define RESP_SERVER_LOGIN_OK 0 // response to ANON_REQ
#define ANON_REQ_TYPE_REGIONS 0x01
@@ -359,10 +371,19 @@ uint8_t MyMesh::handleLoginReq(const mesh::Identity& sender, const uint8_t* secr
#if MESH_DEBUG
MESH_DEBUG_PRINTLN("Login, sender not in ACL");
#endif
} else {
// CUSTOM (TeTeHacko): a blank login has a replay floor too -- replayed, it
// gained nothing, but each copy made us flood a reply over the mesh.
if (sender_timestamp <= client->last_timestamp) return 0;
acl.persistTimestamp(client, sender_timestamp, getRTCClock()->getCurrentTime());
client->last_timestamp = sender_timestamp;
}
}
if (client == NULL) {
uint8_t perms;
// CUSTOM (TeTeHacko): capped wrong passwords (LoginGuard.h); a known admin is never locked out
ClientInfo* known = acl.getClient(sender.pub_key, PUB_KEY_SIZE);
if (login_guard.locked(millis()) && !(known && known->isAdmin())) return 0;
if (strcmp((char *)data, _prefs.password) == 0) { // check for valid admin password
perms = PERM_ACL_ADMIN;
} else if (strcmp((char *)data, _prefs.guest_password) == 0) { // check guest password
@@ -371,6 +392,7 @@ uint8_t MyMesh::handleLoginReq(const mesh::Identity& sender, const uint8_t* secr
#if MESH_DEBUG
MESH_DEBUG_PRINTLN("Invalid password: %s", data);
#endif
login_guard.failed(millis()); // CUSTOM (TeTeHacko)
return 0;
}
@@ -379,13 +401,12 @@ uint8_t MyMesh::handleLoginReq(const mesh::Identity& sender, const uint8_t* secr
MESH_DEBUG_PRINTLN("Possible login replay attack!");
return 0; // FATAL: client table is full -OR- replay attack
}
acl.persistTimestamp(client, sender_timestamp, getRTCClock()->getCurrentTime()); // CUSTOM (TeTeHacko): before acting
MESH_DEBUG_PRINTLN("Login success!");
client->last_timestamp = sender_timestamp;
client->last_activity = getRTCClock()->getCurrentTime();
client->permissions &= ~0x03;
client->permissions |= perms;
acl.persistTimestamp(client, sender_timestamp, getRTCClock()->getCurrentTime()); // CUSTOM (TeTeHacko): admin only, so after the role
memcpy(client->shared_secret, secret, PUB_KEY_SIZE);
if (perms != PERM_ACL_GUEST) { // keep number of FS writes to a minimum
@@ -473,6 +494,67 @@ uint8_t MyMesh::handleAnonClockReq(const mesh::Identity& sender, uint32_t sender
return 0;
}
/* --------------------- Cayenne LPP helpers ----------------------------*/
static float findTelemValue(const uint8_t* buf, uint8_t size, uint8_t channel, uint8_t type, float def_value) {
uint8_t i = 0;
while (i + 2 < size) {
// Get channel #
uint8_t ch = buf[i++];
// Get data type
uint8_t t = buf[i++];
uint8_t sz = LPPData::getDataSize(t);
if (ch == channel && t == type) {
return LPPData::getFloat(&buf[i], sz, LPPData::getMultiplier(t), LPPData::isSigned(t));
}
i += sz; // skip
}
return def_value; // not found
}
/* ------------------ end Cayenne LPP helpers ----------------------*/
bool MyMesh::telemHasChanged(ClientInfo* c) {
auto buf = telemetry.getBuffer();
uint8_t size = telemetry.getSize();
uint8_t i = 0;
bool changed = false;
while (i + 2 < c->extra.sensor.min_deltas_len) {
uint8_t ch = c->extra.sensor.min_deltas[i]; // Get channel #
uint8_t t = c->extra.sensor.min_deltas[i + 1]; // Get data type
uint8_t sz = LPPData::getDataSize(t);
float min_delta = LPPData::getFloat(&c->extra.sensor.min_deltas[i + 2], sz, LPPData::getMultiplier(t), LPPData::isSigned(t));
float pv = LPPData::getFloat(&c->extra.sensor.prev_telem[i + 2], sz, LPPData::getMultiplier(t), LPPData::isSigned(t));
float v = findTelemValue(buf, size, ch, t, 0.0f);
if (abs(v - pv) > min_delta) changed = true; // Yes, has changed
i += 2 + sz; // skip
}
if (changed) {
// take snapshot of all _monitored_ telem values, for next cycle
i = 0;
while (i + 2 < c->extra.sensor.min_deltas_len) {
uint8_t ch = c->extra.sensor.min_deltas[i]; // Get channel #
uint8_t t = c->extra.sensor.min_deltas[i + 1]; // Get data type
uint8_t sz = LPPData::getDataSize(t);
c->extra.sensor.prev_telem[i] = ch;
c->extra.sensor.prev_telem[i + 1] = t;
float v = findTelemValue(buf, size, ch, t, 0.0f);
LPPData::putFloat(&c->extra.sensor.prev_telem[i + 2], v, sz, LPPData::getMultiplier(t), LPPData::isSigned(t));
i += 2 + sz; // skip
}
}
return changed;
}
int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t *payload, size_t payload_len) {
// uint32_t now = getRTCClock()->getCurrentTimeUnique();
// memcpy(reply_data, &now, 4); // response packets always prefixed with timestamp
@@ -651,6 +733,53 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t
sprintf((char *) &reply_data[4], "%s\n%s\n%s", FIRMWARE_VERSION, _prefs.node_name, _prefs.owner_info);
return 4 + strlen((char *) &reply_data[4]);
}
return payload_len > 0 ? handleRequest(sender, sender_timestamp, payload[0], &payload[1], payload_len - 1) : 0;
}
int MyMesh::handleRequest(ClientInfo *from, uint32_t sender_timestamp, uint8_t req_type, uint8_t *payload, size_t payload_len) {
uint8_t perms = from->isAdmin() ? 0xFF : from->permissions;
if (req_type == REQ_TYPE_SUBSCRIBE && payload_len >= 8 && (perms & PERM_ACL_ROLE_MASK) >= PERM_ACL_READ_ONLY) {
memcpy(&from->extra.sensor.push_tag, &payload[0], 4);
uint16_t timeout_secs;
memcpy(&timeout_secs, &payload[4], 2);
uint8_t reserved = payload[6];
uint8_t min_deltas_len = payload[7];
RegionEntry* r;
if (recv_pkt_region && !recv_pkt_region->isWildcard()) { // use request scope
r = recv_pkt_region;
} else { // use default scope
r = region_map.getDefaultRegion();
}
uint8_t reply_len;
if (r && min_deltas_len >= 3 && min_deltas_len <= sizeof(from->extra.sensor.min_deltas)) {
if (timeout_secs > TELEM_SUBSCRIBE_MAX_SECS) timeout_secs = TELEM_SUBSCRIBE_MAX_SECS; // impose max
from->extra.sensor.scope_region_id = r->id;
from->extra.sensor.expiry_timestamp = getRTCClock()->getCurrentTime() + timeout_secs;
from->extra.sensor.min_deltas_len = min_deltas_len;
memcpy(from->extra.sensor.min_deltas, &payload[8], min_deltas_len);
// reply with actual expiry seconds (we could modify/impose restriction)
memcpy(&reply_data[4], &timeout_secs, 2);
memset(&reply_data[6], 0, 2); // reserved
strcpy((char *)&reply_data[8], r ? r->name : ""); // reply with name of scope that will be used
reply_len = 8 + strlen((char *)&reply_data[8]);
} else {
memset(&reply_data[4], 0, 4); // expiry secs (0 for error)
reply_len = 8;
}
return reply_len;
}
if (req_type == REQ_TYPE_UNSUBSCRIBE && (perms & PERM_ACL_ROLE_MASK) >= PERM_ACL_READ_ONLY) {
from->extra.sensor.scope_region_id = 0;
from->extra.sensor.push_tag = 0;
from->extra.sensor.expiry_timestamp = 0;
from->extra.sensor.min_deltas_len = 0;
// REVISIT: maybe return some stats, eg total number of telemetry pushes since SUBSCRIBE?
memset(&reply_data[4], 0, 8); // success
getRNG()->random(&reply_data[12], 2); // just some entropy for better packet-hash uniqueness
return 12 + 2;
}
return 0; // unknown command
}
@@ -1331,6 +1460,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
next_local_advert = next_flood_advert = 0;
next_fair_sender_normal_refill = next_fair_sender_low_refill = next_fair_group_refill = 0;
dirty_contacts_expiry = 0;
last_read_time = 0;
set_radio_at = revert_radio_at = 0;
_logging = false;
region_load_active = false;
@@ -1970,6 +2100,49 @@ void MyMesh::loop() {
MESH_DEBUG_PRINTLN("Radio params restored");
}
uint32_t curr = getRTCClock()->getCurrentTime();
if (curr >= last_read_time + SENSOR_READ_INTERVAL_SECS) {
telemetry.reset();
telemetry.addVoltage(TELEM_CHANNEL_SELF, (float)board.getBattMilliVolts() / 1000.0f);
// query other sensors -- target specific
sensors.querySensors(0xFF, telemetry); // allow all telemetry permissions
// This MCU temperature will be overridden by external sensors (if any)
float temperature = board.getMCUTemperature();
if (!isnan(temperature)) { // Supported boards with built-in temperature sensor. ESP32-C3 may return NAN
telemetry.addTemperature(TELEM_CHANNEL_SELF, temperature); // Built-in MCU Temperature
}
// compare with previous telemetry, check if any deltas are greater than subscriber minimums
for (int i = 0; i < acl.getNumClients(); i++) {
auto c = acl.getClientByIdx(i);
if (c->permissions == 0 || c->extra.sensor.scope_region_id == 0 || c->extra.sensor.min_deltas_len == 0) continue; // skip deleted entries, or Not subscribed to deltas
RegionEntry* r = region_map.findById(c->extra.sensor.scope_region_id);
if (r == NULL) continue; // unknown region scope
if (curr > c->extra.sensor.expiry_timestamp) continue; // subscription now expired
if (telemHasChanged(c)) {
TransportKey scope;
if (region_map.getTransportKeysFor(*r, &scope, 1) > 0) {
uint8_t tlen = telemetry.getSize();
memcpy(reply_data, &c->extra.sensor.push_tag, 4);
uint32_t timestamp = getRTCClock()->getCurrentTimeUnique();
memcpy(&reply_data[4], &timestamp, 4);
memcpy(&reply_data[8], telemetry.getBuffer(), tlen);
mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, c->id, c->shared_secret, reply_data, 8 + tlen);
if (reply) {
if (c->out_path_len != OUT_PATH_UNKNOWN) { // we have an out_path, so send DIRECT
sendDirect(reply, c->out_path, c->out_path_len, 0);
} else {
sendFloodScoped(scope, reply, 0, _prefs.path_hash_mode + 1);
}
}
}
}
}
last_read_time = curr;
}
// is pending dirty contacts write needed?
if (dirty_contacts_expiry && millisHasNowPassed(dirty_contacts_expiry)) {
acl.save(_fs);
+6 -3
View File
@@ -27,6 +27,7 @@
#include <helpers/AdvertDataHelpers.h>
#include <helpers/ArduinoHelpers.h>
#include <helpers/ClientACL.h>
#include <helpers/LoginGuard.h> // CUSTOM (TeTeHacko)
#include <helpers/CommonCLI.h>
#include <helpers/IdentityStore.h>
#include <helpers/SimpleMeshTables.h>
@@ -185,8 +186,6 @@ struct PktFeedRec {
#define FIRMWARE_VERSION "v1.18.0"
#endif
#define FIRMWARE_ROLE "repeater"
#define PACKET_LOG_FILE "/packet_log"
class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
@@ -197,6 +196,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
bool _logging;
NodePrefs _prefs;
ClientACL acl;
LoginGuard login_guard; // CUSTOM (TeTeHacko)
CommonCLI _cli;
uint8_t reply_data[MAX_PACKET_PAYLOAD];
uint8_t reply_path[MAX_PATH_SIZE];
@@ -206,6 +206,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
RegionEntry* load_stack[8];
RegionEntry* recv_pkt_region;
TransportKey default_scope;
uint32_t last_read_time;
RateLimiter discover_limiter, anon_limiter;
// CUSTOM (TeTeHacko): token-bucket limiter over FORWARDED traffic (port of
// upstream proposal #1502). Kill switch: _prefs.fairness_enabled.
@@ -351,10 +352,12 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
uint8_t handleAnonOwnerReq(const mesh::Identity& sender, uint32_t sender_timestamp, const uint8_t* data);
uint8_t handleAnonClockReq(const mesh::Identity& sender, uint32_t sender_timestamp, const uint8_t* data);
int handleRequest(ClientInfo* sender, uint32_t sender_timestamp, uint8_t* payload, size_t payload_len);
int handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t req_type, uint8_t *payload, size_t payload_len);
mesh::Packet* createSelfAdvert();
File openAppend(const char* fname);
bool isLooped(const mesh::Packet* packet, const uint8_t max_counters[]);
bool telemHasChanged(ClientInfo* c);
protected:
float getAirtimeBudgetFactor() const override {
@@ -448,7 +451,7 @@ public:
void sendNodeDiscoverReq();
const char* getFirmwareVer() override { return FIRMWARE_VERSION; }
const char* getBuildDate() override { return FIRMWARE_BUILD_DATE; }
const char* getRole() override { return FIRMWARE_ROLE; }
const char* getRole() override { return "repeater"; }
const char* getNodeName() { return _prefs.node_name; }
NodePrefs* getNodePrefs() {
return &_prefs;
-22
View File
@@ -1,22 +0,0 @@
#pragma once
#include <helpers/ui/DisplayDriver.h>
#include <helpers/CommonCLI.h>
class UITask {
mesh::MainBoard* _board;
DisplayDriver* _display;
unsigned long _next_read, _next_refresh, _auto_off;
int _prevBtnState;
NodePrefs* _node_prefs;
char _version_info[32];
unsigned long _powering_off_at = 0;
unsigned long _started_at = 0;
void renderCurrScreen();
public:
UITask(mesh::MainBoard& board, DisplayDriver& display) : _board(&board), _display(&display) { _next_read = _next_refresh = 0; }
void begin(NodePrefs* node_prefs, const char* build_date, const char* firmware_version);
void loop();
};
+1 -6
View File
@@ -598,11 +598,6 @@ bool identHandleCommand(const char* command, char* reply) {
}
#endif
#ifdef DISPLAY_CLASS
#include "UITask.h"
static UITask ui_task(board, display);
#endif
#ifdef ETHERNET_ENABLED
#define ETHERNET_CLI_BANNER "MeshCore Repeater CLI"
#include <helpers/nrf52/EthernetCLI.h>
@@ -894,7 +889,7 @@ void setup() {
maint.begin(fs, the_mesh.getNodePrefs(), &the_mesh); // CUSTOM (TeTeHacko): needs the prefs loaded by begin()
#ifdef DISPLAY_CLASS
ui_task.begin(the_mesh.getNodePrefs(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION);
ui_task.begin(the_mesh.getNodePrefs(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION, "< Repeater >");
#endif
#ifdef ETHERNET_ENABLED
+11 -2
View File
@@ -350,10 +350,19 @@ void MyMesh::onAnonDataRecv(mesh::Packet *packet, const uint8_t *secret, const m
#if MESH_DEBUG
MESH_DEBUG_PRINTLN("Login, sender not in ACL");
#endif
} else {
// CUSTOM (TeTeHacko): a blank login has a replay floor too -- replayed, it
// gained nothing, but each copy made us flood a reply over the mesh.
if (sender_timestamp <= client->last_timestamp) return;
acl.persistTimestamp(client, sender_timestamp, getRTCClock()->getCurrentTime());
client->last_timestamp = sender_timestamp;
}
}
if (client == NULL) {
uint8_t perm;
// CUSTOM (TeTeHacko): capped wrong passwords (LoginGuard.h); a known admin is never locked out
ClientInfo* known = acl.getClient(sender.pub_key, PUB_KEY_SIZE);
if (login_guard.locked(millis()) && !(known && known->isAdmin())) return;
if (strcmp((char *)&data[8], _prefs.password) == 0) { // check for valid admin password
perm = PERM_ACL_ADMIN;
} else {
@@ -363,6 +372,7 @@ void MyMesh::onAnonDataRecv(mesh::Packet *packet, const uint8_t *secret, const m
perm = PERM_ACL_GUEST;
} else {
MESH_DEBUG_PRINTLN("Incorrect room password");
login_guard.failed(millis()); // CUSTOM (TeTeHacko)
return; // no response. Client will timeout
}
}
@@ -372,8 +382,6 @@ void MyMesh::onAnonDataRecv(mesh::Packet *packet, const uint8_t *secret, const m
MESH_DEBUG_PRINTLN("possible replay attack!");
return;
}
acl.persistTimestamp(client, sender_timestamp, getRTCClock()->getCurrentTime()); // CUSTOM (TeTeHacko): before acting
MESH_DEBUG_PRINTLN("Login success!");
client->last_timestamp = sender_timestamp;
client->extra.room.sync_since = sender_sync_since;
@@ -383,6 +391,7 @@ void MyMesh::onAnonDataRecv(mesh::Packet *packet, const uint8_t *secret, const m
client->last_activity = getRTCClock()->getCurrentTime();
client->permissions &= ~0x03;
client->permissions |= perm;
acl.persistTimestamp(client, sender_timestamp, getRTCClock()->getCurrentTime()); // CUSTOM (TeTeHacko): admin only, so after the role
memcpy(client->shared_secret, secret, PUB_KEY_SIZE);
dirty_contacts_expiry = futureMillis(LAZY_CONTACTS_WRITE_DELAY);
+3 -3
View File
@@ -20,6 +20,7 @@
#include <helpers/CommonCLI.h>
#include <helpers/StatsFormatHelper.h>
#include <helpers/ClientACL.h>
#include <helpers/LoginGuard.h> // CUSTOM (TeTeHacko)
#include <helpers/RegionMap.h>
#include <helpers/RoutingPolicy.h>
#include <RTClib.h>
@@ -77,8 +78,6 @@
#define TXT_ACK_DELAY 200
#endif
#define FIRMWARE_ROLE "room_server"
#define PACKET_LOG_FILE "/packet_log"
#define MAX_POST_TEXT_LEN (160-9)
@@ -100,6 +99,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
TransportKeyStore key_store;
RegionMap region_map, temp_map;
ClientACL acl;
LoginGuard login_guard; // CUSTOM (TeTeHacko)
CommonCLI _cli;
unsigned long dirty_contacts_expiry;
uint8_t reply_data[MAX_PACKET_PAYLOAD];
@@ -194,7 +194,7 @@ public:
const char* getFirmwareVer() override { return FIRMWARE_VERSION; }
const char* getBuildDate() override { return FIRMWARE_BUILD_DATE; }
const char* getRole() override { return FIRMWARE_ROLE; }
const char* getRole() override { return "room_server"; }
const char* getNodeName() { return _prefs.node_name; }
NodePrefs* getNodePrefs() {
return &_prefs;
-125
View File
@@ -1,125 +0,0 @@
#include "UITask.h"
#include <Arduino.h>
#include <helpers/CommonCLI.h>
#ifndef USER_BTN_PRESSED
#define USER_BTN_PRESSED LOW
#endif
#define AUTO_OFF_MILLIS 20000 // 20 seconds
#define BOOT_SCREEN_MILLIS 4000 // 4 seconds
// 'meshcore', 128x13px
static const uint8_t meshcore_logo [] PROGMEM = {
0x3c, 0x01, 0xe3, 0xff, 0xc7, 0xff, 0x8f, 0x03, 0x87, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe,
0x3c, 0x03, 0xe3, 0xff, 0xc7, 0xff, 0x8e, 0x03, 0x8f, 0xfe, 0x3f, 0xfe, 0x1f, 0xff, 0x1f, 0xfe,
0x3e, 0x03, 0xc3, 0xff, 0x8f, 0xff, 0x0e, 0x07, 0x8f, 0xfe, 0x7f, 0xfe, 0x1f, 0xff, 0x1f, 0xfc,
0x3e, 0x07, 0xc7, 0x80, 0x0e, 0x00, 0x0e, 0x07, 0x9e, 0x00, 0x78, 0x0e, 0x3c, 0x0f, 0x1c, 0x00,
0x3e, 0x0f, 0xc7, 0x80, 0x1e, 0x00, 0x0e, 0x07, 0x1e, 0x00, 0x70, 0x0e, 0x38, 0x0f, 0x3c, 0x00,
0x7f, 0x0f, 0xc7, 0xfe, 0x1f, 0xfc, 0x1f, 0xff, 0x1c, 0x00, 0x70, 0x0e, 0x38, 0x0e, 0x3f, 0xf8,
0x7f, 0x1f, 0xc7, 0xfe, 0x0f, 0xff, 0x1f, 0xff, 0x1c, 0x00, 0xf0, 0x0e, 0x38, 0x0e, 0x3f, 0xf8,
0x7f, 0x3f, 0xc7, 0xfe, 0x0f, 0xff, 0x1f, 0xff, 0x1c, 0x00, 0xf0, 0x1e, 0x3f, 0xfe, 0x3f, 0xf0,
0x77, 0x3b, 0x87, 0x00, 0x00, 0x07, 0x1c, 0x0f, 0x3c, 0x00, 0xe0, 0x1c, 0x7f, 0xfc, 0x38, 0x00,
0x77, 0xfb, 0x8f, 0x00, 0x00, 0x07, 0x1c, 0x0f, 0x3c, 0x00, 0xe0, 0x1c, 0x7f, 0xf8, 0x38, 0x00,
0x73, 0xf3, 0x8f, 0xff, 0x0f, 0xff, 0x1c, 0x0e, 0x3f, 0xf8, 0xff, 0xfc, 0x70, 0x78, 0x7f, 0xf8,
0xe3, 0xe3, 0x8f, 0xff, 0x1f, 0xfe, 0x3c, 0x0e, 0x3f, 0xf8, 0xff, 0xfc, 0x70, 0x3c, 0x7f, 0xf8,
0xe3, 0xe3, 0x8f, 0xff, 0x1f, 0xfc, 0x3c, 0x0e, 0x1f, 0xf8, 0xff, 0xf8, 0x70, 0x3c, 0x7f, 0xf8,
};
void UITask::begin(NodePrefs* node_prefs, const char* build_date, const char* firmware_version) {
_prevBtnState = HIGH;
_auto_off = millis() + AUTO_OFF_MILLIS;
_node_prefs = node_prefs;
_display->turnOn();
// strip off dash and commit hash by changing dash to null terminator
// e.g: v1.2.3-abcdef -> v1.2.3
char *version = strdup(firmware_version);
char *dash = strchr(version, '-');
if(dash){
*dash = 0;
}
// v1.2.3 (1 Jan 2025)
snprintf(_version_info, sizeof(_version_info), "%s (%s)", version, build_date);
free(version);
}
void UITask::renderCurrScreen() {
char tmp[80];
if (millis() < BOOT_SCREEN_MILLIS) { // boot screen
// meshcore logo
_display->setColor(UIColor::corp_blue);
int logoWidth = 128;
_display->drawXbm((_display->width() - logoWidth) / 2, 3, meshcore_logo, logoWidth, 13);
// meshcore website
const char* website = "https://meshcore.io";
_display->setColor(UIColor::primary_txt);
_display->setTextSize(1);
uint16_t websiteWidth = _display->getTextWidth(website);
_display->setCursor((_display->width() - websiteWidth) / 2, 22);
_display->print(website);
// version info
_display->setTextSize(1);
uint16_t versionWidth = _display->getTextWidth(_version_info);
_display->setCursor((_display->width() - versionWidth) / 2, 35);
_display->print(_version_info);
// node type
const char* node_type = "< Room Server >";
uint16_t typeWidth = _display->getTextWidth(node_type);
_display->setCursor((_display->width() - typeWidth) / 2, 48);
_display->print(node_type);
} else { // home screen
// node name
_display->setCursor(0, 0);
_display->setTextSize(1);
_display->setColor(UIColor::primary_txt);
_display->print(_node_prefs->node_name);
// freq / sf
_display->setCursor(0, 20);
sprintf(tmp, "FREQ: %06.3f SF%d", _node_prefs->freq, _node_prefs->sf);
_display->print(tmp);
// bw / cr
_display->setCursor(0, 30);
sprintf(tmp, "BW: %03.2f CR: %d", _node_prefs->bw, _node_prefs->cr);
_display->print(tmp);
}
}
void UITask::loop() {
#ifdef PIN_USER_BTN
if (millis() >= _next_read) {
int btnState = digitalRead(PIN_USER_BTN);
if (btnState != _prevBtnState) {
if (btnState == USER_BTN_PRESSED) { // pressed?
if (_display->isOn()) {
// TODO: any action ?
} else {
_display->turnOn();
}
_auto_off = millis() + AUTO_OFF_MILLIS; // extend auto-off timer
}
_prevBtnState = btnState;
}
_next_read = millis() + 200; // 5 reads per second
}
#endif
if (_display->isOn()) {
if (millis() >= _next_refresh) {
_display->startFrame();
renderCurrScreen();
_display->endFrame();
_next_refresh = millis() + 1000; // refresh every second
}
if (millis() > _auto_off) {
_display->turnOff();
}
}
}
-19
View File
@@ -1,19 +0,0 @@
#pragma once
#include <helpers/ui/DisplayDriver.h>
#include <helpers/CommonCLI.h>
class UITask {
DisplayDriver* _display;
unsigned long _next_read, _next_refresh, _auto_off;
int _prevBtnState;
NodePrefs* _node_prefs;
char _version_info[32];
void renderCurrScreen();
public:
UITask(DisplayDriver& display) : _display(&display) { _next_read = _next_refresh = 0; }
void begin(NodePrefs* node_prefs, const char* build_date, const char* firmware_version);
void loop();
};
+1 -6
View File
@@ -9,11 +9,6 @@
#include <helpers/nrf52/EthernetCLI.h>
#endif
#ifdef DISPLAY_CLASS
#include "UITask.h"
static UITask ui_task(display);
#endif
StdRNG fast_rng;
SimpleMeshTables tables;
MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables);
@@ -102,7 +97,7 @@ void setup() {
maint.begin(fs, the_mesh.getNodePrefs(), &the_mesh);
#ifdef DISPLAY_CLASS
ui_task.begin(the_mesh.getNodePrefs(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION);
ui_task.begin(the_mesh.getNodePrefs(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION, "< Room Server >");
#endif
#ifdef ETHERNET_ENABLED
+10 -2
View File
@@ -374,11 +374,20 @@ uint8_t SensorMesh::handleLoginReq(const mesh::Identity& sender, const uint8_t*
#endif
return 0;
}
// CUSTOM (TeTeHacko): a blank login has a replay floor too -- replayed, it
// gained nothing, but each copy made us send a reply.
if (sender_timestamp <= client->last_timestamp) return 0;
acl.persistTimestamp(client, sender_timestamp, getRTCClock()->getCurrentTime());
client->last_timestamp = sender_timestamp;
} else {
// CUSTOM (TeTeHacko): capped wrong passwords (LoginGuard.h); a known admin is never locked out
ClientInfo* known = acl.getClient(sender.pub_key, PUB_KEY_SIZE);
if (login_guard.locked(millis()) && !(known && known->isAdmin())) return 0;
if (strcmp((char *) data, _prefs.password) != 0) { // check for valid admin password
#if MESH_DEBUG
MESH_DEBUG_PRINTLN("Invalid password: %s", &data[0]);
#endif
login_guard.failed(millis()); // CUSTOM (TeTeHacko)
return 0;
}
@@ -387,12 +396,11 @@ uint8_t SensorMesh::handleLoginReq(const mesh::Identity& sender, const uint8_t*
MESH_DEBUG_PRINTLN("Possible login replay attack!");
return 0; // FATAL: client table is full -OR- replay attack
}
acl.persistTimestamp(client, sender_timestamp, getRTCClock()->getCurrentTime()); // CUSTOM (TeTeHacko): before acting
MESH_DEBUG_PRINTLN("Login success!");
client->last_timestamp = sender_timestamp;
client->last_activity = getRTCClock()->getCurrentTime();
client->permissions |= PERM_ACL_ADMIN;
acl.persistTimestamp(client, sender_timestamp, getRTCClock()->getCurrentTime()); // CUSTOM (TeTeHacko): admin only, so after the role
memcpy(client->shared_secret, secret, PUB_KEY_SIZE);
dirty_contacts_expiry = futureMillis(LAZY_CONTACTS_WRITE_DELAY);
+3 -3
View File
@@ -22,6 +22,7 @@
#include <helpers/CommonCLI.h>
#include <helpers/StatsFormatHelper.h>
#include <helpers/ClientACL.h>
#include <helpers/LoginGuard.h> // CUSTOM (TeTeHacko)
#include <helpers/RegionMap.h>
#include <RTClib.h>
#include <target.h>
@@ -41,8 +42,6 @@
#define FIRMWARE_VERSION "v1.18.0"
#endif
#define FIRMWARE_ROLE "sensor"
#define MAX_SEARCH_RESULTS 24
#define MAX_CONCURRENT_ALERTS 4
@@ -56,7 +55,7 @@ public:
// CommonCLI callbacks
const char* getFirmwareVer() override { return FIRMWARE_VERSION; }
const char* getBuildDate() override { return FIRMWARE_BUILD_DATE; }
const char* getRole() override { return FIRMWARE_ROLE; }
const char* getRole() override { return "sensor"; }
const char* getNodeName() { return _prefs.node_name; }
NodePrefs* getNodePrefs() { return &_prefs; }
void savePrefs() override { _cli.savePrefs(_fs); }
@@ -149,6 +148,7 @@ private:
unsigned long next_local_advert, next_flood_advert;
NodePrefs _prefs;
ClientACL acl;
LoginGuard login_guard; // CUSTOM (TeTeHacko)
CommonCLI _cli;
uint8_t reply_data[MAX_PACKET_PAYLOAD];
unsigned long dirty_contacts_expiry;
-125
View File
@@ -1,125 +0,0 @@
#include "UITask.h"
#include <Arduino.h>
#include <helpers/CommonCLI.h>
#ifndef USER_BTN_PRESSED
#define USER_BTN_PRESSED LOW
#endif
#define AUTO_OFF_MILLIS 20000 // 20 seconds
#define BOOT_SCREEN_MILLIS 4000 // 4 seconds
// 'meshcore', 128x13px
static const uint8_t meshcore_logo [] PROGMEM = {
0x3c, 0x01, 0xe3, 0xff, 0xc7, 0xff, 0x8f, 0x03, 0x87, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe,
0x3c, 0x03, 0xe3, 0xff, 0xc7, 0xff, 0x8e, 0x03, 0x8f, 0xfe, 0x3f, 0xfe, 0x1f, 0xff, 0x1f, 0xfe,
0x3e, 0x03, 0xc3, 0xff, 0x8f, 0xff, 0x0e, 0x07, 0x8f, 0xfe, 0x7f, 0xfe, 0x1f, 0xff, 0x1f, 0xfc,
0x3e, 0x07, 0xc7, 0x80, 0x0e, 0x00, 0x0e, 0x07, 0x9e, 0x00, 0x78, 0x0e, 0x3c, 0x0f, 0x1c, 0x00,
0x3e, 0x0f, 0xc7, 0x80, 0x1e, 0x00, 0x0e, 0x07, 0x1e, 0x00, 0x70, 0x0e, 0x38, 0x0f, 0x3c, 0x00,
0x7f, 0x0f, 0xc7, 0xfe, 0x1f, 0xfc, 0x1f, 0xff, 0x1c, 0x00, 0x70, 0x0e, 0x38, 0x0e, 0x3f, 0xf8,
0x7f, 0x1f, 0xc7, 0xfe, 0x0f, 0xff, 0x1f, 0xff, 0x1c, 0x00, 0xf0, 0x0e, 0x38, 0x0e, 0x3f, 0xf8,
0x7f, 0x3f, 0xc7, 0xfe, 0x0f, 0xff, 0x1f, 0xff, 0x1c, 0x00, 0xf0, 0x1e, 0x3f, 0xfe, 0x3f, 0xf0,
0x77, 0x3b, 0x87, 0x00, 0x00, 0x07, 0x1c, 0x0f, 0x3c, 0x00, 0xe0, 0x1c, 0x7f, 0xfc, 0x38, 0x00,
0x77, 0xfb, 0x8f, 0x00, 0x00, 0x07, 0x1c, 0x0f, 0x3c, 0x00, 0xe0, 0x1c, 0x7f, 0xf8, 0x38, 0x00,
0x73, 0xf3, 0x8f, 0xff, 0x0f, 0xff, 0x1c, 0x0e, 0x3f, 0xf8, 0xff, 0xfc, 0x70, 0x78, 0x7f, 0xf8,
0xe3, 0xe3, 0x8f, 0xff, 0x1f, 0xfe, 0x3c, 0x0e, 0x3f, 0xf8, 0xff, 0xfc, 0x70, 0x3c, 0x7f, 0xf8,
0xe3, 0xe3, 0x8f, 0xff, 0x1f, 0xfc, 0x3c, 0x0e, 0x1f, 0xf8, 0xff, 0xf8, 0x70, 0x3c, 0x7f, 0xf8,
};
void UITask::begin(NodePrefs* node_prefs, const char* build_date, const char* firmware_version) {
_prevBtnState = HIGH;
_auto_off = millis() + AUTO_OFF_MILLIS;
_node_prefs = node_prefs;
_display->turnOn();
// strip off dash and commit hash by changing dash to null terminator
// e.g: v1.2.3-abcdef -> v1.2.3
char *version = strdup(firmware_version);
char *dash = strchr(version, '-');
if(dash){
*dash = 0;
}
// v1.2.3 (1 Jan 2025)
snprintf(_version_info, sizeof(_version_info), "%s (%s)", version, build_date);
free(version);
}
void UITask::renderCurrScreen() {
char tmp[80];
if (millis() < BOOT_SCREEN_MILLIS) { // boot screen
// meshcore logo
_display->setColor(UIColor::corp_blue);
int logoWidth = 128;
_display->drawXbm((_display->width() - logoWidth) / 2, 3, meshcore_logo, logoWidth, 13);
// meshcore website
const char* website = "https://meshcore.io";
_display->setColor(UIColor::primary_txt);
_display->setTextSize(1);
uint16_t websiteWidth = _display->getTextWidth(website);
_display->setCursor((_display->width() - websiteWidth) / 2, 22);
_display->print(website);
// version info
_display->setTextSize(1);
uint16_t versionWidth = _display->getTextWidth(_version_info);
_display->setCursor((_display->width() - versionWidth) / 2, 35);
_display->print(_version_info);
// node type
const char* node_type = "< Sensor >";
uint16_t typeWidth = _display->getTextWidth(node_type);
_display->setCursor((_display->width() - typeWidth) / 2, 48);
_display->print(node_type);
} else { // home screen
// node name
_display->setCursor(0, 0);
_display->setTextSize(1);
_display->setColor(UIColor::primary_txt);
_display->print(_node_prefs->node_name);
// freq / sf
_display->setCursor(0, 20);
sprintf(tmp, "FREQ: %06.3f SF%d", _node_prefs->freq, _node_prefs->sf);
_display->print(tmp);
// bw / cr
_display->setCursor(0, 30);
sprintf(tmp, "BW: %03.2f CR: %d", _node_prefs->bw, _node_prefs->cr);
_display->print(tmp);
}
}
void UITask::loop() {
#ifdef PIN_USER_BTN
if (millis() >= _next_read) {
int btnState = digitalRead(PIN_USER_BTN);
if (btnState != _prevBtnState) {
if (btnState == USER_BTN_PRESSED) { // pressed?
if (_display->isOn()) {
// TODO: any action ?
} else {
_display->turnOn();
}
_auto_off = millis() + AUTO_OFF_MILLIS; // extend auto-off timer
}
_prevBtnState = btnState;
}
_next_read = millis() + 200; // 5 reads per second
}
#endif
if (_display->isOn()) {
if (millis() >= _next_refresh) {
_display->startFrame();
renderCurrScreen();
_display->endFrame();
_next_refresh = millis() + 1000; // refresh every second
}
if (millis() > _auto_off) {
_display->turnOff();
}
}
}
-19
View File
@@ -1,19 +0,0 @@
#pragma once
#include <helpers/ui/DisplayDriver.h>
#include <helpers/CommonCLI.h>
class UITask {
DisplayDriver* _display;
unsigned long _next_read, _next_refresh, _auto_off;
int _prevBtnState;
NodePrefs* _node_prefs;
char _version_info[32];
void renderCurrScreen();
public:
UITask(DisplayDriver& display) : _display(&display) { _next_read = _next_refresh = 0; }
void begin(NodePrefs* node_prefs, const char* build_date, const char* firmware_version);
void loop();
};
+1 -6
View File
@@ -4,11 +4,6 @@
// CUSTOM (TeTeHacko): dfu, radio silence watchdog, reset reason -- see NodeMaintenance.h.
static NodeMaintenance maint(board, radio_driver);
#ifdef DISPLAY_CLASS
#include "UITask.h"
static UITask ui_task(display);
#endif
class MyMesh : public SensorMesh {
public:
MyMesh(mesh::MainBoard& board, mesh::Radio& radio, mesh::MillisecondClock& ms, mesh::RNG& rng, mesh::RTCClock& rtc, mesh::MeshTables& tables)
@@ -118,7 +113,7 @@ void setup() {
maint.begin(fs, the_mesh.getNodePrefs(), &the_mesh);
#ifdef DISPLAY_CLASS
ui_task.begin(the_mesh.getNodePrefs(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION);
ui_task.begin(the_mesh.getNodePrefs(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION, "< Sensor >");
#endif
// send out initial zero hop Advertisement to the mesh
+3
View File
@@ -182,5 +182,8 @@ public:
bool setChannel(int idx, const ChannelDetails& src);
int findChannelIdx(const mesh::GroupChannel& ch);
virtual void savePrefs() { }
virtual void enterCLIRescue() { }
void loop();
};
+6
View File
@@ -27,4 +27,10 @@ public:
// distinguish an unauthenticated local channel (USB) from a paired one, so
// callers can gate sensitive commands (key export, PIN read/set).
virtual bool isConnectionSecure() const { return true; }
// CUSTOM (TeTeHacko): a reply that must go back only over the transport the
// request came on -- the private key, the BLE PIN. writeFrame() of a
// multi-transport wrapper sends to every enabled transport, so a key exported
// over paired BLE also went out on USB. Single transports: the same thing.
virtual size_t writeReplyFrame(const uint8_t src[], size_t len) { return writeFrame(src, len); }
};
+5
View File
@@ -160,6 +160,11 @@ void ClientACL::orphanTimestamp(const ClientInfo* c) {
}
void ClientACL::persistTimestamp(ClientInfo* c, uint32_t sender_timestamp, uint32_t now) {
// Admins only. A guest can only read, and anybody gets in as one when the
// guest password is empty (the default): its every request would be a flash
// write, and its floors would push the admins' out of the orphan list. Its
// floor stays in RAM, as upstream.
if (!c->isAdmin()) return;
if (sender_timestamp <= c->saved_timestamp) return; // retry, or nothing new
if (sender_timestamp > now + ACL_TS_MAX_AHEAD) return; // runaway sender clock
c->saved_timestamp = sender_timestamp;
+29 -1
View File
@@ -927,6 +927,30 @@ void CommonCLI::handleSetCmd(uint32_t sender_timestamp, char* command, char* rep
void CommonCLI::handleGetCmd(uint32_t sender_timestamp, char* command, char* reply) {
const char* config = &command[4];
#ifdef LOCKED_NODE
// CUSTOM (TeTeHacko): a locked node gives its secrets to nobody -- not to the
// USB console (no login: whoever holds the board), not to the BLE console, not
// to an admin over the mesh. docs/locked-bootloader.md, point 4.
if (memcmp(config, "prv.key", 7) == 0 || memcmp(config, "guest.password", 14) == 0 ||
memcmp(config, "bridge.secret", 13) == 0) {
strcpy(reply, "Error: locked build");
return;
}
#endif
#if defined(NRF52_PLATFORM)
// CUSTOM (TeTeHacko): which silicon, and whether SWD can read the flash
// (docs/locked-bootloader.md, point 5). Variant xxF0 and later = rev3, where
// the hardware closes the debug port unless the firmware opens it on every
// boot -- ours never does; rev1/rev2 obey UICR.APPROTECT alone (0xFF = open).
if (memcmp(config, "chip", 4) == 0 && config[4] == 0) {
uint32_t v = NRF_FICR->INFO.VARIANT;
uint32_t ap = NRF_UICR->APPROTECT;
sprintf(reply, "> nRF%lx %c%c%c%c, uicr.approtect %08lx (%s)", (unsigned long)NRF_FICR->INFO.PART,
(char)(v >> 24), (char)(v >> 16), (char)(v >> 8), (char)v, (unsigned long)ap,
(ap & 0xFF) == 0xFF ? "open" : "protected");
return;
}
#endif
if (memcmp(config, "allow.read.only", 15) == 0) {
sprintf(reply, "> %s", _prefs->allow_read_only ? "on" : "off");
} else if (memcmp(config, "flood.advert.interval", 21) == 0) {
@@ -1102,7 +1126,11 @@ void CommonCLI::handleGetCmd(uint32_t sender_timestamp, char* command, char* rep
sprintf(reply, "No extra SF configured");
}
} else {
sprintf(reply, "??: %s", config);
// CUSTOM (TeTeHacko): bounded echo, as the `set` branch does. An unbounded
// sprintf put a remote `get <167 chars>` (172 B reply) into the 164 B the
// repeater and room server leave for it (temp[169] minus the 5 B header).
strcpy(reply, "??: ");
StrHelper::strncpy(&reply[4], config, 160-5);
}
}
-6
View File
@@ -4,16 +4,10 @@
#include "SensorManager.h"
class CommonGpsPrefs : public ConfigSerializer {
bool _is_dirty = false;
protected:
CommonGpsPrefs() = default;
public:
void markDirty() { _is_dirty = true; }
void clearDirty() { _is_dirty = false; }
bool isDirty() const { return _is_dirty; }
virtual bool isGpsEnabled() const = 0;
virtual void setGpsEnabled(bool enabled) = 0;
virtual uint32_t getGpsPeriod() const = 0;
-5
View File
@@ -6,7 +6,6 @@
#endif
class CommonRadioPrefs : public ConfigSerializer, public KeyValueStore {
bool _is_dirty = false;
#ifdef WITH_RX_POWERSAVING
uint8_t _active_sf = 0; // what the radio runs now (tempradio differs from prefs)
float _active_bw = 0;
@@ -14,10 +13,6 @@ class CommonRadioPrefs : public ConfigSerializer, public KeyValueStore {
protected:
CommonRadioPrefs() { }
public:
void markDirty() { _is_dirty = true; }
void clearDirty() { _is_dirty = false; }
bool isDirty() const { return _is_dirty; }
virtual float getFreq() const = 0;
virtual void setFreq(float f) = 0;
File renamed without changes.
+41
View File
@@ -0,0 +1,41 @@
#pragma once
#include <stdint.h>
// CUSTOM (TeTeHacko): a cap on wrong passwords. Upstream checks every login,
// so a password can be guessed over the air as fast as the channel carries
// packets, from a fresh identity each time, and a wrong one is not even
// answered. After LOGIN_FAIL_MAX wrong passwords within LOGIN_FAIL_SECS no
// password is checked until that window ends.
//
// The caller lets a client that is already an admin in the ACL through anyway:
// a login is encrypted with the sender's key, so nobody can send one in an
// admin's name, and a guessing attack cannot lock the admins out.
//
// Times are millis(), compared by difference: a clock set backwards or the
// 49-day wrap cannot stretch the window.
#ifndef LOGIN_FAIL_MAX
#define LOGIN_FAIL_MAX 4
#endif
#ifndef LOGIN_FAIL_SECS
#define LOGIN_FAIL_SECS 180
#endif
class LoginGuard {
uint32_t _since = 0; // millis() of the first failure in the window
uint16_t _fails = 0;
bool inWindow(uint32_t now_ms) const { return now_ms - _since < LOGIN_FAIL_SECS * 1000UL; }
public:
bool locked(uint32_t now_ms) const { return _fails >= LOGIN_FAIL_MAX && inWindow(now_ms); }
void failed(uint32_t now_ms) {
if (_fails == 0 || !inWindow(now_ms)) {
_since = now_ms;
_fails = 0;
}
if (_fails < LOGIN_FAIL_MAX) _fails++;
}
};
+24
View File
@@ -0,0 +1,24 @@
#pragma once
#include <MeshCore.h>
#include <helpers/ContactInfo.h>
#include <helpers/ChannelDetails.h>
class MeshEventListener {
public:
virtual void onMessageRecv(mesh::Packet *pkt, const ContactInfo &from, uint8_t txt_type, uint32_t sender_timestamp, const char* text) = 0;
virtual void onChannelMessageRecv(mesh::Packet *pkt, ChannelDetails& channel_details, const char* text) = 0;
virtual void onQueueSizeChanged(int msgcount) = 0;
virtual void onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path_len, const uint8_t* path) { }
virtual void onControlDataRecv(const mesh::Packet* pkt) { }
virtual void onChannelDataRecv(mesh::Packet *pkt, const mesh::GroupChannel &channel, uint16_t data_type,
const uint8_t *data, size_t data_len) { }
virtual void onACKRecv(uint32_t ack_crc) { }
virtual uint8_t onUnhandledRequest(const ContactInfo &contact, uint32_t sender_timestamp, const uint8_t *data,
uint8_t len, uint8_t *reply) { return 0; /* unknown request type */ }
virtual bool onUnhandledResponse(const ContactInfo &from, uint32_t tag, const uint8_t* data, uint8_t len) { return false; /* not handled */ }
virtual void onTraceRecv(mesh::Packet *pkt, uint32_t tag, uint32_t auth_code, uint8_t flags,
const uint8_t *path_snrs, const uint8_t *path_hashes, uint8_t path_len) { }
virtual void onRawDataRecv(mesh::Packet *pkt) { }
virtual ~MeshEventListener() { }
};
+32 -2
View File
@@ -26,6 +26,7 @@ private:
bool _enabled = false;
RegisteredInterface _interfaces[MAX_INTERFACES] = {};
int _last_rx = -1; // CUSTOM (TeTeHacko): slot of the most recent frame's transport
public:
bool addInterface(InterfaceType type, BaseSerialInterface* iface) {
@@ -57,6 +58,7 @@ public:
for(int i = 0; i < MAX_INTERFACES; i++){
if(_interfaces[i].instance == iface){
_interfaces[i] = {};
if (_last_rx == i) _last_rx = -1;
return true;
}
}
@@ -184,11 +186,13 @@ public:
}
// try to read a frame from any enabled interface
for(auto iface : _interfaces){
for(int i = 0; i < MAX_INTERFACES; i++){
auto& iface = _interfaces[i];
if(iface.instance && iface.instance->isEnabled()){
size_t frameSize = iface.instance->checkRecvFrame(dest);
if(frameSize > 0){
return frameSize;
_last_rx = i;
return frameSize;
}
}
}
@@ -197,4 +201,30 @@ public:
return 0;
}
// CUSTOM (TeTeHacko): only a frame that came over (MITM-paired) Bluetooth is
// authenticated. USB, a hardware UART, WiFi and Ethernet carry no pairing, so
// the companion's key-export / PIN gates (89eb71ab) refuse them. Without this
// override the base class answered `true` for everything: the gates written
// for SerialDualInterface went dead when the v1.17 merge replaced it with
// this class, and USB could export the key and read or set the BLE PIN.
// A build with no Bluetooth (USB-only companion) has nothing to pair over, so
// its one transport stays trusted, as BaseSerialInterface defines it.
bool isConnectionSecure() const override {
bool has_ble = false;
for (const auto& iface : _interfaces) {
if (iface.instance && iface.type == InterfaceType::Bluetooth) has_ble = true;
}
if (!has_ble) return true;
if (_last_rx < 0) return false;
const auto& iface = _interfaces[_last_rx];
return iface.instance && iface.type == InterfaceType::Bluetooth && iface.instance->isConnectionSecure();
}
size_t writeReplyFrame(const uint8_t src[], size_t len) override {
if (!_enabled || len == 0 || _last_rx < 0) return 0;
auto* iface = _interfaces[_last_rx].instance;
if (!iface || !iface->isEnabled()) return 0;
return iface->writeFrame(src, len);
}
};
@@ -5,15 +5,14 @@
#include <helpers/ui/UIScreen.h>
#include <helpers/SensorManager.h>
#include <helpers/MultiSerialInterface.h>
#include <helpers/MeshEventListener.h>
#include <helpers/CompanionNodePrefs.h>
#include <Arduino.h>
#ifdef PIN_BUZZER
#include <helpers/ui/buzzer.h>
#endif
#include "NodePrefs.h"
#include "MyMesh.h"
enum class UIEventType {
none,
contactMessage,
@@ -23,12 +22,12 @@ enum class UIEventType {
ack
};
class AbstractUITask : public MyMesh::Listener {
class AbstractUITask : public MeshEventListener {
protected:
mesh::MainBoard* _board;
MultiSerialInterface* _interfaceManager;
AbstractUITask(mesh::MainBoard* board, MultiSerialInterface* interfaceManager) : _board(board), _interfaceManager(interfaceManager) {
AbstractUITask(mesh::MainBoard* board, MultiSerialInterface* interfaceManager = NULL) : _board(board), _interfaceManager(interfaceManager) {
}
public:
+17
View File
@@ -0,0 +1,17 @@
#include "BaseUITask.h"
#include <Arduino.h>
void BaseUITask::loop() {
if (_display->isOn()) {
if (millis() >= _next_refresh) {
_display->startFrame();
long interval = renderCurrScreen();
_display->endFrame();
_next_refresh = millis() + interval;
}
if (millis() > _auto_off) {
_display->turnOff();
}
}
}
+19
View File
@@ -0,0 +1,19 @@
#pragma once
#include <MeshCore.h>
#include <helpers/ui/DisplayDriver.h>
// #include <helpers/ui/UIScreen.h>
class BaseUITask {
protected:
mesh::MainBoard* _board;
DisplayDriver* _display;
unsigned long _next_refresh, _auto_off;
BaseUITask(mesh::MainBoard* board, DisplayDriver* display) : _board(board), _display(display) { _next_refresh = 0; }
virtual long renderCurrScreen() = 0;
public:
virtual void loop();
};
@@ -1,8 +1,8 @@
#include "UITask.h"
#include <helpers/TxtDataHelpers.h>
#include "../MyMesh.h"
#include "target.h"
#include <time.h>
#include <RTClib.h>
#ifdef ENABLE_WIFI_INTERFACE
#include <WiFi.h>
#endif
@@ -31,18 +31,22 @@
#define PRESS_LABEL "long press"
#endif
// Copied from simple_repeater
#define CTL_TYPE_NODE_DISCOVER_REQ 0x80
#define CTL_TYPE_NODE_DISCOVER_RESP 0x90
#include "icons.h"
class SplashScreen : public UIScreen {
UITask* _task;
unsigned long dismiss_after;
char _version_info[12];
const char* _build_date;
public:
SplashScreen(UITask* task) : _task(task) {
SplashScreen(UITask* task, const char* ver, const char* build_date) : _task(task) {
// strip off dash and commit hash by changing dash to null terminator
// e.g: v1.2.3-abcdef -> v1.2.3
const char *ver = FIRMWARE_VERSION;
const char *dash = strchr(ver, '-');
int len = dash ? dash - ver : strlen(ver);
@@ -50,6 +54,8 @@ public:
memcpy(_version_info, ver, len);
_version_info[len] = 0;
_build_date = build_date;
dismiss_after = millis() + BOOT_SCREEN_MILLIS;
}
@@ -74,7 +80,7 @@ public:
display.setColor(UIColor::secondary_txt);
display.setTextSize(1);
display.drawTextCentered(display.width()/2, 48, FIRMWARE_BUILD_DATE);
display.drawTextCentered(display.width()/2, 48, _build_date);
return 1000;
}
@@ -110,6 +116,11 @@ static void formatFixAge(char* buf, size_t size, uint32_t seconds) {
}
#endif
struct AdvertPath {
char name[32];
uint32_t recv_timestamp;
};
class HomeScreen : public UIScreen {
enum HomePage {
FIRST,
@@ -140,6 +151,7 @@ class HomeScreen : public UIScreen {
NodePrefs* _node_prefs;
uint8_t _page;
bool _shutdown_init;
int recent_next_idx;
AdvertPath recent[UI_RECENT_LIST_SIZE];
#if UI_DISCOVER_SCREEN
DiscoveredNode discovered[DISCOVERED_NODES_TABLE_SIZE]; // not circular, latest discovered nodes are not kept
@@ -230,19 +242,31 @@ class HomeScreen : public UIScreen {
public:
HomeScreen(UITask* task, mesh::RTCClock* rtc, SensorManager* sensors, NodePrefs* node_prefs)
: _task(task), _rtc(rtc), _sensors(sensors), _node_prefs(node_prefs), _page(0),
_shutdown_init(false), sensors_lpp(200) { }
_shutdown_init(false), sensors_lpp(200)
{
memset(recent, 0, sizeof(recent));
recent_next_idx = 0;
}
void addToRecents(ContactInfo &contact) {
auto p = &recent[recent_next_idx];
recent_next_idx = (recent_next_idx + 1) % UI_RECENT_LIST_SIZE;
strcpy(p->name, contact.name);
p->recv_timestamp = _rtc->getCurrentTime();
}
#if UI_DISCOVER_SCREEN
bool sendDiscoverRequest() {
uint8_t cmd_bytes[6];
cmd_bytes[0] = CTL_TYPE_NODE_DISCOVER_REQ | 1; // DISCOVER_REQ | prefix only
cmd_bytes[1] = 0xFF; // Repeaters
the_mesh.getRNG()->random((uint8_t *) &disc_node_req_tag, 4); // generate random tag
_task->getMesh()->getRNG()->random((uint8_t *) &disc_node_req_tag, 4); // generate random tag
memcpy(&cmd_bytes[2], &disc_node_req_tag, 4);
disc_nodes_count = 0;
mesh::Packet* req = the_mesh.createControlData(cmd_bytes, sizeof(cmd_bytes));
mesh::Packet* req = _task->getMesh()->createControlData(cmd_bytes, sizeof(cmd_bytes));
if (req) {
the_mesh.sendZeroHop(req);
_task->getMesh()->sendZeroHop(req);
discovery_req_time = millis();
return true;
}
@@ -256,7 +280,7 @@ public:
d->type = packet->payload[0] & 0xF;
d->snr_out = ((int8_t)packet->payload[1]) / 4.0;
d->snr_in = radio_driver.getLastSNR();
ContactInfo* c = the_mesh.lookupContactByPubKey(&packet->payload[6], 8);
ContactInfo* c = _task->getMesh()->lookupContactByPubKey(&packet->payload[6], 8);
if (c != NULL) {
strncpy(d->name, c->name, 32);
} else {
@@ -342,9 +366,9 @@ public:
display.drawTextCentered(display.width() / 2, 43, "< Connected >");
// CUSTOM (TeTeHacko): jen kdyz BT opravdu bezi -- jinak displej nabizi PIN
// k parovani, ktere neni jak navazat.
} else if (the_mesh.getBLEPin() != 0 && _task->isBluetoothEnabled()) { // BT pin
} else if (_task->getBLEPin() != 0 && _task->isBluetoothEnabled()) { // BT pin
display.setColor(UIColor::warning_txt);
sprintf(tmp, "Pin:%d", the_mesh.getBLEPin());
sprintf(tmp, "Pin:%d", _task->getBLEPin());
if (_node_prefs->ui_show_clock) {
display.setTextSize(1);
display.drawTextCentered(display.width() / 2, 110, tmp);
@@ -354,11 +378,10 @@ public:
}
}
} else if (_page == HomePage::RECENT) {
the_mesh.getRecentlyHeard(recent, UI_RECENT_LIST_SIZE);
display.setColor(UIColor::primary_txt);
int y = 20;
for (int i = 0; i < UI_RECENT_LIST_SIZE; i++, y += 11) {
auto a = &recent[i];
for (int i = 0, k = recent_next_idx; i < UI_RECENT_LIST_SIZE; i++, y += 11, k = (k + 1) % UI_RECENT_LIST_SIZE) {
auto a = &recent[k];
if (a->name[0] == 0) continue; // empty slot
int secs = _rtc->getCurrentTime() - a->recv_timestamp;
if (secs < 60) {
@@ -625,7 +648,15 @@ public:
#endif
if (c == KEY_ENTER && _page == HomePage::ADVERT) {
_task->notify(UIEventType::ack);
if (the_mesh.advert()) {
mesh::Packet* pkt;
if (_node_prefs->advert_loc_policy == ADVERT_LOC_NONE) {
pkt = _task->getMesh()->createSelfAdvert(_node_prefs->node_name);
} else {
pkt = _task->getMesh()->createSelfAdvert(_node_prefs->node_name, sensors.node_lat, sensors.node_lon);
}
if (pkt) {
_task->getMesh()->sendZeroHop(pkt);
_task->showAlert("Advert sent!", 1000);
} else {
_task->showAlert("Advert failed..", 1000);
@@ -758,9 +789,14 @@ public:
}
};
void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs) {
void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs, MultiSerialInterface* serial,
BaseChatMesh* mesh, uint32_t ble_pin, const char* ver, const char* build_date)
{
_display = display;
_sensors = sensors;
_interfaceManager = serial;
the_mesh = mesh;
_ble_pin = ble_pin;
#if defined(PIN_USER_BTN)
user_btn.begin();
@@ -793,7 +829,7 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
ui_started_at = millis();
_alert_expiry = 0;
splash = new SplashScreen(this);
splash = new SplashScreen(this, ver, build_date);
home = new HomeScreen(this, &rtc_clock, sensors, node_prefs);
msg_preview = new MsgPreviewScreen(this, &rtc_clock);
setCurrScreen(splash);
@@ -890,6 +926,8 @@ void UITask::onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path
if (!hasConnection()) {
notify(UIEventType::newContactMessage);
}
((HomeScreen *) home)->addToRecents(contact);
}
void UITask::onControlDataRecv(const mesh::Packet* packet) {
@@ -1180,7 +1218,7 @@ char UITask::checkDisplayOn(char c) {
char UITask::handleLongPress(char c) {
if (millis() - ui_started_at < 8000) { // long press in first 8 seconds since startup -> CLI/rescue
the_mesh.enterCLIRescue();
the_mesh->enterCLIRescue();
c = 0; // consume event
}
return c;
@@ -1225,7 +1263,7 @@ void UITask::toggleGPS() {
_node_prefs->getGpsPrefs()->setGpsEnabled(*_sensors, true);
notify(UIEventType::ack);
}
the_mesh.savePrefs();
the_mesh->savePrefs();
showAlert(_node_prefs->getGpsPrefs()->isGpsEnabled() ? "GPS: Enabled" : "GPS: Disabled", 800);
_next_refresh = 0;
break;
@@ -1253,7 +1291,7 @@ void UITask::toggleBuzzer() {
buzzer.quiet(true);
}
_node_prefs->buzzer_quiet = buzzer.isQuiet();
the_mesh.savePrefs();
the_mesh->savePrefs();
showAlert(buzzer.isQuiet() ? "Buzzer: OFF" : "Buzzer: ON", 800);
_next_refresh = 0; // trigger refresh
#endif
@@ -4,6 +4,7 @@
#include <helpers/ui/DisplayDriver.h>
#include <helpers/ui/UIScreen.h>
#include <helpers/SensorManager.h>
#include <helpers/BaseChatMesh.h>
#include <helpers/MultiSerialInterface.h>
#include <Arduino.h>
#include <helpers/sensors/LPPDataHelpers.h>
@@ -19,8 +20,8 @@
#include <helpers/ui/GenericVibration.h>
#endif
#include "../AbstractUITask.h"
#include "../NodePrefs.h"
#include <helpers/ui/AbstractUITask.h>
#include <helpers/CompanionNodePrefs.h>
#ifdef UI_NO_DISCOVER_SCREEN
#error "UI_NO_DISCOVER_SCREEN is obsolete - use -D UI_DISCOVER_SCREEN=0 instead"
@@ -49,6 +50,8 @@ struct DiscoveredNode {
class UITask : public AbstractUITask {
DisplayDriver* _display;
SensorManager* _sensors;
BaseChatMesh* the_mesh;
uint32_t _ble_pin;
#ifdef PIN_BUZZER
genericBuzzer buzzer;
#endif
@@ -90,12 +93,13 @@ class UITask : public AbstractUITask {
public:
UITask(mesh::MainBoard* board, MultiSerialInterface* serial) : AbstractUITask(board, serial), _display(NULL), _sensors(NULL) {
UITask(mesh::MainBoard* board, DisplayDriver* display = NULL) : AbstractUITask(board), _display(display), _sensors(NULL) {
next_batt_chck = _next_refresh = 0;
ui_started_at = 0;
curr = NULL;
}
void begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs);
void begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs, MultiSerialInterface* serial,
BaseChatMesh* mesh, uint32_t ble_pin, const char* ver, const char* build_date);
void gotoHomeScreen() { setCurrScreen(home); }
void showAlert(const char* text, int duration_millis);
@@ -103,6 +107,9 @@ public:
bool hasDisplay() const { return _display != NULL; }
bool isButtonPressed() const;
BaseChatMesh* getMesh() const { return the_mesh; }
uint32_t getBLEPin() const { return _ble_pin; }
bool isBuzzerQuiet() {
#ifdef PIN_BUZZER
return buzzer.isQuiet();
@@ -116,7 +123,7 @@ public:
void toggleGPS();
void triggerGPS();
// MyMesh::Listener
// MeshEventListener
void onMessageRecv(mesh::Packet *pkt, const ContactInfo &from, uint8_t txt_type, uint32_t sender_timestamp, const char* text) override;
void onChannelMessageRecv(mesh::Packet *pkt, ChannelDetails& channel_details, const char* text) override;
void onQueueSizeChanged(int offline_queue_size) override;
File renamed without changes.
@@ -1,7 +1,7 @@
#include "UITask.h"
#include <Arduino.h>
#include <helpers/TxtDataHelpers.h>
#include "../MyMesh.h"
#include "target.h"
#define AUTO_OFF_MILLIS 15000 // 15 seconds
#define BOOT_SCREEN_MILLIS 3000 // 3 seconds
@@ -40,9 +40,15 @@ static const uint8_t meshcore_logo [] PROGMEM = {
0xe3, 0xe3, 0x8f, 0xff, 0x1f, 0xfc, 0x3c, 0x0e, 0x1f, 0xf8, 0xff, 0xf8, 0x70, 0x3c, 0x7f, 0xf8,
};
void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs) {
void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs, MultiSerialInterface* serial,
BaseChatMesh* mesh, uint32_t ble_pin, const char* ver, const char* build_date)
{
_display = display;
_sensors = sensors;
_interfaceManager = serial;
the_mesh = mesh;
_ble_pin = ble_pin;
_auto_off = millis() + AUTO_OFF_MILLIS;
clearMsgPreview();
_node_prefs = node_prefs;
@@ -52,14 +58,14 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
// strip off dash and commit hash by changing dash to null terminator
// e.g: v1.2.3-abcdef -> v1.2.3
char *version = strdup(FIRMWARE_VERSION);
char *version = strdup(ver);
char *dash = strchr(version, '-');
if (dash) {
*dash = 0;
}
// v1.2.3 (1 Jan 2025)
sprintf(_version_info, "%s (%s)", version, FIRMWARE_BUILD_DATE);
sprintf(_version_info, "%s (%s)", version, build_date);
#ifdef PIN_BUZZER
buzzer.begin();
@@ -300,11 +306,11 @@ void UITask::renderCurrScreen() {
_display->print(tmp);
// BT pin
if (!hasConnection() && the_mesh.getBLEPin() != 0) {
if (!hasConnection() && _ble_pin != 0) {
_display->setColor(UIColor::warning_txt);
_display->setTextSize(2);
_display->setCursor(0, 43);
sprintf(tmp, "Pin:%d", the_mesh.getBLEPin());
sprintf(tmp, "Pin:%d", _ble_pin);
_display->print(tmp);
_display->setColor(UIColor::primary_txt);
} else {
@@ -555,7 +561,14 @@ void UITask::handleButtonDoublePress() {
#ifdef PIN_BUZZER
notify(UIEventType::ack);
#endif
if (the_mesh.advert()) {
mesh::Packet* pkt;
if (_node_prefs->advert_loc_policy == ADVERT_LOC_NONE) {
pkt = the_mesh->createSelfAdvert(_node_prefs->node_name);
} else {
pkt = the_mesh->createSelfAdvert(_node_prefs->node_name, sensors.node_lat, sensors.node_lon);
}
if (pkt) {
the_mesh->sendZeroHop(pkt);
MESH_DEBUG_PRINTLN("Advert sent!");
sprintf(_alert, "Advert sent!");
} else {
@@ -584,7 +597,7 @@ void UITask::handleButtonTriplePress() {
case 2: sprintf(_alert, "Alerts: Vibe only"); break;
default: sprintf(_alert, "Alerts: Silent"); break;
}
the_mesh.savePrefs();
the_mesh->savePrefs();
_need_refresh = true;
#elif defined(PIN_BUZZER)
if (buzzer.isQuiet()) {
@@ -596,7 +609,7 @@ void UITask::handleButtonTriplePress() {
sprintf(_alert, "Buzzer: OFF");
}
_node_prefs->buzzer_quiet = buzzer.isQuiet();
the_mesh.savePrefs();
the_mesh->savePrefs();
_need_refresh = true;
#endif
}
@@ -617,7 +630,7 @@ void UITask::handleButtonQuadruplePress() {
notify(UIEventType::ack);
sprintf(_alert, "GPS: Enabled");
}
the_mesh.savePrefs();
the_mesh->savePrefs();
break;
}
}
@@ -628,7 +641,7 @@ void UITask::handleButtonQuadruplePress() {
void UITask::handleButtonLongPress() {
MESH_DEBUG_PRINTLN("UITask: long press triggered");
if (millis() - ui_started_at < 8000) { // long press in first 8 seconds since startup -> CLI/rescue
the_mesh.enterCLIRescue();
the_mesh->enterCLIRescue();
} else {
shutdown();
}
@@ -3,14 +3,15 @@
#include <MeshCore.h>
#include <helpers/ui/DisplayDriver.h>
#include <helpers/SensorManager.h>
#include <helpers/BaseChatMesh.h>
#include <stddef.h>
#ifdef PIN_BUZZER
#include <helpers/ui/buzzer.h>
#endif
#include "../AbstractUITask.h"
#include "../NodePrefs.h"
#include <helpers/ui/AbstractUITask.h>
#include <helpers/CompanionNodePrefs.h>
#include "Button.h"
@@ -21,6 +22,8 @@
class UITask : public AbstractUITask {
DisplayDriver* _display;
SensorManager* _sensors;
BaseChatMesh* the_mesh;
uint32_t _ble_pin;
#ifdef PIN_BUZZER
genericBuzzer buzzer;
#endif
@@ -57,20 +60,20 @@ class UITask : public AbstractUITask {
void handleButtonTriplePress();
void handleButtonQuadruplePress();
void handleButtonLongPress();
public:
UITask(mesh::MainBoard* board, MultiSerialInterface* serial) : AbstractUITask(board, serial), _display(NULL), _sensors(NULL) {
UITask(mesh::MainBoard* board, DisplayDriver* display = NULL) : AbstractUITask(board), _display(display), _sensors(NULL) {
_next_refresh = 0;
ui_started_at = 0;
}
void begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs);
void begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs, MultiSerialInterface* serial,
BaseChatMesh* mesh, uint32_t ble_pin, const char* ver, const char* build_date);
bool hasDisplay() const { return _display != NULL; }
void clearMsgPreview();
// MyMesh::Listener
// MeshEventListener
void onMessageRecv(mesh::Packet *pkt, const ContactInfo &from, uint8_t txt_type, uint32_t sender_timestamp, const char* text) override;
void onChannelMessageRecv(mesh::Packet *pkt, ChannelDetails& channel_details, const char* text) override;
void onQueueSizeChanged(int offline_queue_size) override;
@@ -1,6 +1,5 @@
#include "UITask.h"
#include <helpers/TxtDataHelpers.h>
#include "../MyMesh.h"
#include "target.h"
#include "u8g2_icons.h"
@@ -36,12 +35,12 @@ class SplashScreen : public UIScreen {
unsigned long dismiss_after;
unsigned long version_after;
char _version_info[12];
const char* _build_date;
public:
SplashScreen(UITask* task) : _task(task) {
SplashScreen(UITask* task, const char* ver, const char* build_date) : _task(task) {
// strip off dash and commit hash by changing dash to null terminator
// e.g: v1.2.3-abcdef -> v1.2.3
const char *ver = FIRMWARE_VERSION;
const char *dash = strchr(ver, '-');
int len = dash ? dash - ver : strlen(ver);
@@ -49,6 +48,8 @@ public:
memcpy(_version_info, ver, len);
_version_info[len] = 0;
_build_date = build_date;
version_after = millis() + BOOT_SCREEN_MILLIS / 2;
dismiss_after = millis() + BOOT_SCREEN_MILLIS;
}
@@ -75,7 +76,7 @@ public:
display.setColor(UIColor::secondary_txt);
display.setTextSize(1);
display.drawTextCentered(display.width()/2, 27, FIRMWARE_BUILD_DATE);
display.drawTextCentered(display.width()/2, 27, _build_date);
}
return 1000;
}
@@ -87,6 +88,11 @@ public:
}
};
struct AdvertPath {
char name[32];
uint32_t recv_timestamp;
};
class HomeScreen : public UIScreen {
enum HomePage {
FIRST,
@@ -110,6 +116,7 @@ class HomeScreen : public UIScreen {
NodePrefs* _node_prefs;
uint8_t _page;
bool _shutdown_init;
int recent_next_idx;
AdvertPath recent[UI_RECENT_LIST_SIZE];
CayenneLPP sensors_lpp;
@@ -142,7 +149,19 @@ class HomeScreen : public UIScreen {
public:
HomeScreen(UITask* task, mesh::RTCClock* rtc, SensorManager* sensors, NodePrefs* node_prefs)
: _task(task), _rtc(rtc), _sensors(sensors), _node_prefs(node_prefs), _page(0),
_shutdown_init(false), sensors_lpp(200) { }
_shutdown_init(false), sensors_lpp(200)
{
memset(recent, 0, sizeof(recent));
recent_next_idx = 0;
}
void addToRecents(ContactInfo &contact) {
auto p = &recent[recent_next_idx];
recent_next_idx = (recent_next_idx + 1) % UI_RECENT_LIST_SIZE;
strcpy(p->name, contact.name);
p->recv_timestamp = _rtc->getCurrentTime();
}
void poll() override {
if (_shutdown_init && !_task->isButtonPressed()) { // must wait for USR button to be released
@@ -184,18 +203,17 @@ public:
display.setTextSize(1);
display.drawTextCentered(display.width() / 2, display.height()-8, "< Connected >");
} else if (the_mesh.getBLEPin() != 0) { // BT pin
} else if (_task->getBLEPin() != 0) { // BT pin
display.setColor(UIColor::warning_txt);
display.setTextSize(2);
sprintf(tmp, "Pin:%d", the_mesh.getBLEPin());
sprintf(tmp, "Pin:%d", _task->getBLEPin());
display.drawTextCentered(display.width() / 2, display.height()-8, tmp);
}
} else if (_page == HomePage::RECENT) {
the_mesh.getRecentlyHeard(recent, UI_RECENT_LIST_SIZE);
display.setColor(UIColor::primary_txt);
int y = 8;
for (int i = 0; i < UI_RECENT_LIST_SIZE; i++, y += 11) {
auto a = &recent[i];
for (int i = 0, k = recent_next_idx; i < UI_RECENT_LIST_SIZE; i++, y += 11, k = (k + 1) % UI_RECENT_LIST_SIZE) {
auto a = &recent[k];
if (a->name[0] == 0) continue; // empty slot
int secs = _rtc->getCurrentTime() - a->recv_timestamp;
if (secs < 60) {
@@ -400,7 +418,14 @@ public:
}
if (c == KEY_ENTER && _page == HomePage::ADVERT) {
_task->notify(UIEventType::ack);
if (the_mesh.advert()) {
mesh::Packet* pkt;
if (_node_prefs->advert_loc_policy == ADVERT_LOC_NONE) {
pkt = _task->getMesh()->createSelfAdvert(_node_prefs->node_name);
} else {
pkt = _task->getMesh()->createSelfAdvert(_node_prefs->node_name, sensors.node_lat, sensors.node_lon);
}
if (pkt) {
_task->getMesh()->sendZeroHop(pkt);
_task->showAlert("Advert sent!", 1000);
} else {
_task->showAlert("Advert failed..", 1000);
@@ -428,10 +453,14 @@ public:
}
};
void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs) {
void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs, MultiSerialInterface* serial,
BaseChatMesh* mesh, uint32_t ble_pin, const char* ver, const char* build_date)
{
_display = display;
_sensors = sensors;
_interfaceManager = serial;
the_mesh = mesh;
_ble_pin = ble_pin;
_auto_off = millis() + AUTO_OFF_MILLIS;
_cached_batt_mv = getBattMilliVolts();
@@ -463,7 +492,7 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
ui_started_at = millis();
_alert_expiry = 0;
splash = new SplashScreen(this);
splash = new SplashScreen(this, ver, build_date);
home = new HomeScreen(this, &rtc_clock, sensors, node_prefs);
setCurrScreen(splash);
}
@@ -547,6 +576,7 @@ void UITask::onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path
if (!hasConnection()) {
notify(UIEventType::newContactMessage);
}
((HomeScreen *) home)->addToRecents(contact);
}
void UITask::userLedHandler() {
@@ -794,7 +824,7 @@ char UITask::checkDisplayOn(char c) {
char UITask::handleLongPress(char c) {
if (millis() - ui_started_at < 8000) { // long press in first 8 seconds since startup -> CLI/rescue
the_mesh.enterCLIRescue();
the_mesh->enterCLIRescue();
c = 0; // consume event
}
return c;
@@ -839,7 +869,7 @@ void UITask::toggleGPS() {
_node_prefs->getGpsPrefs()->setGpsEnabled(*_sensors, true);
notify(UIEventType::ack);
}
the_mesh.savePrefs();
the_mesh->savePrefs();
showAlert(_node_prefs->getGpsPrefs()->isGpsEnabled() ? "GPS: Enabled" : "GPS: Disabled", 800);
_next_refresh = 0;
break;
@@ -858,7 +888,7 @@ void UITask::toggleBuzzer() {
buzzer.quiet(true);
}
_node_prefs->buzzer_quiet = buzzer.isQuiet();
the_mesh.savePrefs();
the_mesh->savePrefs();
showAlert(buzzer.isQuiet() ? "Buzzer: OFF" : "Buzzer: ON", 800);
_next_refresh = 0; // trigger refresh
#endif
@@ -4,6 +4,7 @@
#include <helpers/ui/DisplayDriver.h>
#include <helpers/ui/UIScreen.h>
#include <helpers/SensorManager.h>
#include <helpers/BaseChatMesh.h>
#include <helpers/MultiSerialInterface.h>
#include <Arduino.h>
#include <helpers/sensors/LPPDataHelpers.h>
@@ -22,12 +23,14 @@
#include <helpers/ui/GenericVibration.h>
#endif
#include "../AbstractUITask.h"
#include "../NodePrefs.h"
#include <helpers/ui/AbstractUITask.h>
#include <helpers/CompanionNodePrefs.h>
class UITask : public AbstractUITask {
DisplayDriver* _display;
SensorManager* _sensors;
BaseChatMesh* the_mesh;
uint32_t _ble_pin;
ScrollingStatusBar _statusBar;
#ifdef PIN_BUZZER
genericBuzzer buzzer;
@@ -71,13 +74,14 @@ class UITask : public AbstractUITask {
public:
UITask(mesh::MainBoard* board, MultiSerialInterface* serial) : AbstractUITask(board, serial), _display(NULL), _sensors(NULL) {
UITask(mesh::MainBoard* board, DisplayDriver* display = NULL) : AbstractUITask(board), _display(display), _sensors(NULL) {
next_batt_chck = _next_refresh = 0;
_cached_batt_mv = 0;
ui_started_at = 0;
curr = NULL;
}
void begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs);
void begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs, MultiSerialInterface* serial,
BaseChatMesh* mesh, uint32_t ble_pin, const char* ver, const char* build_date);
void gotoHomeScreen() { setCurrScreen(home); }
void showAlert(const char* text, int duration_millis);
@@ -86,6 +90,9 @@ public:
bool hasDisplay() const { return _display != NULL; }
bool isButtonPressed() const;
BaseChatMesh* getMesh() const { return the_mesh; }
uint32_t getBLEPin() const { return _ble_pin; }
bool isBuzzerQuiet() {
#ifdef PIN_BUZZER
return buzzer.isQuiet();
@@ -98,7 +105,7 @@ public:
bool getGPSState();
void toggleGPS();
// MyMesh::Listener
// MeshEventListener
void onMessageRecv(mesh::Packet *pkt, const ContactInfo &from, uint8_t txt_type, uint32_t sender_timestamp, const char* text) override;
void onChannelMessageRecv(mesh::Packet *pkt, ChannelDetails& channel_details, const char* text) override;
void onQueueSizeChanged(int offline_queue_size) override;
@@ -29,7 +29,7 @@ static const uint8_t meshcore_logo [] PROGMEM = {
0xe3, 0xe3, 0x8f, 0xff, 0x1f, 0xfc, 0x3c, 0x0e, 0x1f, 0xf8, 0xff, 0xf8, 0x70, 0x3c, 0x7f, 0xf8,
};
void UITask::begin(NodePrefs* node_prefs, const char* build_date, const char* firmware_version) {
void UITask::begin(NodePrefs* node_prefs, const char* build_date, const char* firmware_version, const char* role_lbl) {
_prevBtnState = HIGH;
_auto_off = millis() + AUTO_OFF_MILLIS;
_started_at = millis();
@@ -44,16 +44,18 @@ void UITask::begin(NodePrefs* node_prefs, const char* build_date, const char* fi
// e.g: v1.2.3-abcdef -> v1.2.3
char *version = strdup(firmware_version);
char *dash = strchr(version, '-');
if(dash){
if (dash){
*dash = 0;
}
// v1.2.3 (1 Jan 2025)
snprintf(_version_info, sizeof(_version_info), "%s (%s)", version, build_date);
free(version);
_role_label = role_lbl;
}
void UITask::renderCurrScreen() {
long UITask::renderCurrScreen() {
char tmp[80];
if (millis() < _started_at + BOOT_SCREEN_MILLIS) { // boot screen
// meshcore logo
@@ -72,8 +74,7 @@ void UITask::renderCurrScreen() {
_display->drawTextCentered(_display->width() / 2, 35, _version_info);
// node type
const char* node_type = "< Repeater >";
_display->drawTextCentered(_display->width() / 2, 48, node_type);
_display->drawTextCentered(_display->width() / 2, 48, _role_label);
} else if (_powering_off_at > 0) {
// meshcore logo
_display->setColor(UIColor::corp_blue);
@@ -107,6 +108,7 @@ void UITask::renderCurrScreen() {
sprintf(tmp, "BW: %03.2f CR: %d", _node_prefs->bw, _node_prefs->cr);
_display->print(tmp);
}
return 1000; // 1 sec interval
}
void UITask::loop() {
@@ -126,18 +128,7 @@ void UITask::loop() {
}
#endif
if (_display->isOn()) {
if (millis() >= _next_refresh) {
_display->startFrame();
renderCurrScreen();
_display->endFrame();
_next_refresh = millis() + 1000; // refresh every second
}
if (millis() > _auto_off) {
_display->turnOff();
}
}
BaseUITask::loop();
if (_powering_off_at > 0) { // power off timer armed
#if defined(LED_PIN) && defined(LED_STATE_ON)
+23
View File
@@ -0,0 +1,23 @@
#pragma once
#include <helpers/ui/BaseUITask.h>
#include <helpers/CommonCLI.h>
class UITask : public BaseUITask {
unsigned long _next_read;
int _prevBtnState;
NodePrefs* _node_prefs;
char _version_info[32];
const char* _role_label;
unsigned long _powering_off_at = 0;
unsigned long _started_at = 0;
protected:
long renderCurrScreen() override;
public:
UITask(mesh::MainBoard* board, DisplayDriver* display) : BaseUITask(board, display) { _next_read = 0; }
void begin(NodePrefs* node_prefs, const char* build_date, const char* firmware_version, const char* role_lbl);
void loop() override;
};
@@ -109,17 +109,28 @@ TEST(AclReplayFloor, FloorsOutliveAclClear) {
EXPECT_FALSE(n.accept(n.acl->putClient(idFor(3), 0), NOW - 50));
}
TEST(AclReplayFloor, EvictedClientKeepsItsFloor) {
TEST(AclReplayFloor, GuestTrafficWritesNothing) {
Node n;
ClientInfo* g = n.acl->putClient(idFor(4), 0);
g->last_activity = 1; // least active -> evicted first
ASSERT_TRUE(n.accept(g, NOW - 70));
for (int i = 0; i < MAX_CLIENTS; i++) {
g->permissions = PERM_ACL_GUEST; // anybody, with the default empty guest password
int writes = n.fs.writes;
for (uint32_t i = 0; i < 1000; i++) ASSERT_TRUE(n.accept(g, NOW - 1000 + i));
EXPECT_EQ(n.fs.writes, writes);
}
TEST(AclReplayFloor, GuestsDoNotPushOutAdminFloors) {
Node n;
ASSERT_TRUE(n.accept(n.admin(3), NOW - 50));
n.acl->save(&n.fs);
n.acl->clear(); // the admin's floor is an orphan now
for (int i = 0; i < 4 * MAX_CLIENTS; i++) { // a flood of fresh guest identities
ClientInfo* c = n.acl->putClient(idFor(100 + i), 0);
c->last_activity = 1000 + i;
c->permissions = PERM_ACL_GUEST;
c->last_activity = i;
n.accept(c, NOW - 10);
}
ASSERT_EQ(n.acl->getClient(idFor(4).pub_key, PUB_KEY_SIZE), nullptr);
EXPECT_FALSE(n.accept(n.acl->putClient(idFor(4), 0), NOW - 70));
n.boot();
EXPECT_FALSE(n.accept(n.acl->putClient(idFor(3), 0), NOW - 50));
}
TEST(AclReplayFloor, TornWriteFallsBackToTheOtherSlot) {
@@ -4,7 +4,7 @@
#include <cstring>
#include <string>
#include "../../examples/companion_radio/NodePrefs.h"
#include "../../src/helpers/CompanionNodePrefs.h"
class ReplayStream : public Stream {
const char* _text;
@@ -0,0 +1,47 @@
#include <gtest/gtest.h>
#include "helpers/LoginGuard.h"
static const uint32_t WINDOW_MS = LOGIN_FAIL_SECS * 1000UL;
TEST(LoginGuard, LocksAfterTheCap) {
LoginGuard g;
for (int i = 0; i < LOGIN_FAIL_MAX; i++) {
EXPECT_FALSE(g.locked(1000 + i));
g.failed(1000 + i);
}
EXPECT_TRUE(g.locked(1000 + LOGIN_FAIL_MAX));
}
TEST(LoginGuard, UnlocksWhenTheWindowEnds) {
LoginGuard g;
for (int i = 0; i < LOGIN_FAIL_MAX; i++) g.failed(1000);
EXPECT_TRUE(g.locked(1000 + WINDOW_MS - 1));
EXPECT_FALSE(g.locked(1000 + WINDOW_MS));
}
TEST(LoginGuard, FailuresInAnOldWindowDoNotCount) {
LoginGuard g;
for (int i = 0; i < LOGIN_FAIL_MAX - 1; i++) g.failed(1000);
g.failed(1000 + WINDOW_MS); // a new window: one failure, not LOGIN_FAIL_MAX
EXPECT_FALSE(g.locked(1000 + WINDOW_MS + 1));
}
TEST(LoginGuard, LockedFailuresDoNotExtendTheWindow) {
LoginGuard g;
for (int i = 0; i < LOGIN_FAIL_MAX; i++) g.failed(1000);
for (uint32_t t = 1000; t < 1000 + WINDOW_MS; t += 1000) g.failed(t); // the caller does not, but still
EXPECT_FALSE(g.locked(1000 + WINDOW_MS));
}
TEST(LoginGuard, SurvivesTheMillisWrap) {
LoginGuard g;
const uint32_t start = 0xFFFFFFFFu - 1000;
for (int i = 0; i < LOGIN_FAIL_MAX; i++) g.failed(start);
EXPECT_TRUE(g.locked(start + 2000)); // wrapped past 0
EXPECT_FALSE(g.locked(start + WINDOW_MS));
}
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
@@ -0,0 +1,116 @@
// CUSTOM (TeTeHacko): which transport a companion frame came over, and where a
// sensitive reply goes. The v1.17 merge swapped SerialDualInterface for this
// class, whose isConnectionSecure() was the base class's `true`, so USB could
// export the private key and read or set the BLE PIN.
#include <gtest/gtest.h>
#include <string.h>
#include <deque>
#include <vector>
#include "helpers/MultiSerialInterface.h"
class FakeIface : public BaseSerialInterface {
public:
bool enabled = false;
std::deque<std::vector<uint8_t>> inbox;
std::vector<std::vector<uint8_t>> sent;
void enable() override { enabled = true; }
void disable() override { enabled = false; }
bool isEnabled() const override { return enabled; }
bool isConnected() const override { return true; }
bool isWriteBusy() const override { return false; }
size_t writeFrame(const uint8_t src[], size_t len) override {
sent.emplace_back(src, src + len);
return len;
}
size_t checkRecvFrame(uint8_t dest[]) override {
if (inbox.empty()) return 0;
auto f = inbox.front();
inbox.pop_front();
memcpy(dest, f.data(), f.size());
return f.size();
}
};
struct MultiSerial : ::testing::Test {
MultiSerialInterface multi;
FakeIface ble, usb;
uint8_t buf[MAX_FRAME_SIZE + 1];
void SetUp() override {
multi.addInterface(InterfaceType::Bluetooth, &ble);
multi.addInterface(InterfaceType::USB, &usb);
multi.enable();
}
};
TEST_F(MultiSerial, NothingReceivedIsNotSecure) {
EXPECT_FALSE(multi.isConnectionSecure());
}
TEST_F(MultiSerial, UsbFrameIsNotSecure) {
usb.inbox.push_back({1, 2, 3});
ASSERT_EQ(multi.checkRecvFrame(buf), 3u);
EXPECT_FALSE(multi.isConnectionSecure());
}
TEST_F(MultiSerial, BleFrameIsSecure) {
ble.inbox.push_back({1, 2, 3});
ASSERT_EQ(multi.checkRecvFrame(buf), 3u);
EXPECT_TRUE(multi.isConnectionSecure());
}
TEST_F(MultiSerial, FollowsTheLatestFrame) {
ble.inbox.push_back({1});
multi.checkRecvFrame(buf);
usb.inbox.push_back({2});
multi.checkRecvFrame(buf);
EXPECT_FALSE(multi.isConnectionSecure()); // a BLE session does not bless a later USB frame
}
TEST_F(MultiSerial, ReplyGoesOnlyToTheRequestingTransport) {
ble.inbox.push_back({1});
multi.checkRecvFrame(buf);
const uint8_t key[] = {0xAA, 0xBB};
EXPECT_EQ(multi.writeReplyFrame(key, 2), 2u);
EXPECT_EQ(ble.sent.size(), 1u);
EXPECT_TRUE(usb.sent.empty());
}
TEST_F(MultiSerial, PushStillGoesEverywhere) {
const uint8_t push[] = {0x83};
multi.writeFrame(push, 1);
EXPECT_EQ(ble.sent.size(), 1u);
EXPECT_EQ(usb.sent.size(), 1u);
}
TEST_F(MultiSerial, NoReplyBeforeAnyRequest) {
const uint8_t key[] = {0xAA};
EXPECT_EQ(multi.writeReplyFrame(key, 1), 0u);
EXPECT_TRUE(ble.sent.empty());
EXPECT_TRUE(usb.sent.empty());
}
TEST_F(MultiSerial, RemovedTransportForgetsTheSource) {
ble.inbox.push_back({1});
multi.checkRecvFrame(buf);
multi.removeInterface(&ble);
const uint8_t key[] = {0xAA};
EXPECT_EQ(multi.writeReplyFrame(key, 1), 0u);
}
TEST(MultiSerialUsbOnly, SingleTransportStaysTrusted) {
MultiSerialInterface multi;
FakeIface usb;
multi.addInterface(InterfaceType::USB, &usb);
multi.enable();
uint8_t buf[MAX_FRAME_SIZE + 1];
usb.inbox.push_back({1});
multi.checkRecvFrame(buf);
EXPECT_TRUE(multi.isConnectionSecure()); // nothing to pair over, as before v1.17
}
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
+3
View File
@@ -44,6 +44,9 @@ a different board.
| `ble_flash_node.sh` | BLE OTA of a node out of reach of a cable, with the checks around it (silence, services, version) |
| `ble_dfu.py` | legacy Nordic DFU over BLE for the Adafruit nRF52 bootloader (buttonless, both phases) |
| `build_version.py` | PlatformIO pre-script: real version and build time for `ver` |
| `bl_sign_pkg.py` | DFU zip for a board with the signed (`SIGNED_FW`) Adafruit bootloader: `adafruit-nrfutil dfu genpkg --key-file` with its two Python 3 bugs on that path fixed |
| `bl_verify_pkg.py` | checks a DFU zip the way the signed bootloader will (device type, ECDSA P-256 over the init packet, image length and hash) |
| `bl_allowed_key` | the public key the signed bootloader carries (`SIGNED_FW_QX`/`QY`) |
## Admin-pushed firmware update (experimental `-ota` images)
+5
View File
@@ -0,0 +1,5 @@
# P-256 public key of the signed (SIGNED_FW) Adafruit bootloader of a locked node,
# X || Y big-endian hex = SIGNED_FW_QX, SIGNED_FW_QY (docs/locked-bootloader.md).
# The private half is the CI secret BL_SIGNING_KEY of tth/meshcore-tth, generated
# straight into it on 19. 11. 2026; nobody has seen it.
debd215fe1d6442c968ef6b8c5ed26f48ad7f6ce2062a10bb80c8de72acb94788bd377ed041046c1974c401fea07c2ac660a8dcd0dec213c721f570e118f3937
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env python3
"""Build a DFU zip signed for the signed (SIGNED_FW) Adafruit bootloader.
usage: bl_sign_pkg.py <firmware.hex> <signing-key.pem> <out.zip>
adafruit-nrfutil's own `dfu genpkg --key-file` builds the package; this only
runs it with two fixes. Its signed path (0.5.3.post16, the latest on PyPI and
the one PlatformIO ships) never worked on Python 3: Signing.load_key() ends
with a dead Python 2 line, `c.encode('hex') for c in sk.to_string()`, and
manifest.json cannot serialize the image hash (bytes). The init packet layout stays
nrfutil's; tools/bl_verify_pkg.py checks the result independently.
Device type 0x0052 (Adafruit), any SoftDevice (0xFFFE), as the bootloader
expects for an application (src/dfu_init.c).
"""
import sys
if len(sys.argv) != 4 or sys.argv[1] in ("-h", "--help"):
print(__doc__.strip())
sys.exit(0 if len(sys.argv) > 1 and sys.argv[1] in ("-h", "--help") else 2)
import json
from ecdsa import SigningKey
from nordicsemi import __main__ as nrfutil
from nordicsemi.dfu import manifest, signing
def _load_key(self, filename):
with open(filename) as f:
self.sk = SigningKey.from_pem(f.read())
signing.Signing.load_key = _load_key
# Second Python 3 break on the signed path: manifest.json carries the image
# hash as bytes, which the json default hook does not know. Informational only
# (the bootloader reads the .dat init packet), written as hex like nrfutil 0.5.x.
def _to_json(self):
def remove_none_entries(d):
if not isinstance(d, dict):
return d
return {k: remove_none_entries(v) for k, v in d.items() if v is not None}
def default(o):
if isinstance(o, bytes):
return o.hex()
return remove_none_entries(o.__dict__)
return json.dumps({"manifest": self.manifest}, default=default,
sort_keys=True, indent=4, separators=(",", ": "))
manifest.ManifestGenerator.to_json = _to_json
hexfile, keyfile, out = sys.argv[1:]
sys.exit(nrfutil.cli.main(
["dfu", "genpkg", "--dev-type", "0x0052", "--sd-req", "0xFFFE",
"--application", hexfile, "--key-file", keyfile, out],
standalone_mode=True,
))
+88
View File
@@ -0,0 +1,88 @@
#!/usr/bin/env python3
"""Check a DFU zip the way the signed (SIGNED_FW) Adafruit bootloader will.
usage: bl_verify_pkg.py <package.zip> [key-file]
key-file X||Y hex of the P-256 public key (default: tools/bl_allowed_key)
Mirrors src/dfu_init.c of adafruit/Adafruit_nRF52_Bootloader (>= 0.10.0):
device type 0x0052, the extended init packet marked ECDS (2), the ECDSA P-256
signature (r||s) over SHA-256 of the init packet up to and including the
image length and hash, and that length/hash against the image itself. Exit 0
only when the bootloader would take it -- so a package that a locked node
would refuse after the transfer is caught before it is published or sent.
"""
import sys
if len(sys.argv) < 2 or sys.argv[1] in ("-h", "--help"):
print(__doc__.strip())
sys.exit(0)
import hashlib
import json
import os
import struct
import zipfile
from ecdsa import BadSignatureError, NIST256p, VerifyingKey
from ecdsa.util import sigdecode_string
ADAFRUIT_DEVICE_TYPE = 0x0052
USES_ECDS = 2
EXT_SIGNED_LEN = 40 # identifier + image length + sha256
def fail(msg):
print(f"REFUSED: {msg}")
sys.exit(1)
def load_key(path):
with open(path) as f:
lines = [ln.strip() for ln in f if ln.strip() and not ln.startswith("#")]
raw = bytes.fromhex(lines[0])
if len(raw) != 64:
fail(f"{path}: expected 64 bytes (X||Y), got {len(raw)}")
return VerifyingKey.from_string(raw, curve=NIST256p)
def main():
pkg = sys.argv[1]
keyfile = sys.argv[2] if len(sys.argv) > 2 else os.path.join(os.path.dirname(__file__), "bl_allowed_key")
vk = load_key(keyfile)
with zipfile.ZipFile(pkg) as z:
man = json.loads(z.read("manifest.json"))["manifest"]
if "application" not in man:
fail(f"no application image in {sorted(man)}")
app = man["application"]
init = z.read(app["dat_file"])
image = z.read(app["bin_file"])
# dfu_init_packet_t: device_type, device_rev, app_version, softdevice_len, softdevice[]
if len(init) < 10:
fail("init packet too short")
dev_type, _dev_rev, _app_ver, sd_len = struct.unpack_from("<HHIH", init, 0)
if dev_type != ADAFRUIT_DEVICE_TYPE:
fail(f"device type 0x{dev_type:04x}, the bootloader wants 0x{ADAFRUIT_DEVICE_TYPE:04x}")
ext_start = 10 + 2 * sd_len
ext = init[ext_start:]
if len(ext) < EXT_SIGNED_LEN + 64:
fail(f"extended init packet {len(ext)} B: not signed (plain CRC package?)")
ident, img_len = struct.unpack_from("<II", ext, 0)
if ident != USES_ECDS:
fail(f"extended packet identifier {ident}, the bootloader wants {USES_ECDS} (ECDS)")
signed = init[: ext_start + EXT_SIGNED_LEN]
sig = ext[EXT_SIGNED_LEN : EXT_SIGNED_LEN + 64]
try:
vk.verify(sig, signed, hashfunc=hashlib.sha256, sigdecode=sigdecode_string)
except BadSignatureError:
fail(f"signature does not match {keyfile}")
if img_len != len(image):
fail(f"image is {len(image)} B, the signed init packet says {img_len}")
if hashlib.sha256(image).digest() != ext[8:40]:
fail("image sha256 does not match the signed init packet")
print(f"OK: {os.path.basename(pkg)} signed by {os.path.basename(keyfile)}, image {len(image)} B")
if __name__ == "__main__":
main()
@@ -52,7 +52,7 @@ extends = DFRobot_LoRaWAN_ESP32S3
build_flags =
${DFRobot_LoRaWAN_ESP32S3.build_flags}
-I src/helpers/ui
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D DISPLAY_ROTATION=3
-D DISPLAY_CLASS=ST7735Display
-D MAX_CONTACTS=350
@@ -67,7 +67,7 @@ build_src_filter = ${DFRobot_LoRaWAN_ESP32S3.build_src_filter}
+<helpers/ui/MomentaryButton.cpp>
+<helpers/ui/ST7735Display.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${DFRobot_LoRaWAN_ESP32S3.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -19,6 +19,7 @@ SensorManager sensors;
DISPLAY_CLASS display(&board.periph_power);
// Active-low button, internal pull-up.
MomentaryButton user_btn(PIN_USER_BTN, 1000, true, true);
UITask ui_task(&board, &display);
#endif
bool radio_init() {
@@ -10,6 +10,7 @@
#ifdef DISPLAY_CLASS
#include <helpers/ui/ST7735Display.h>
#include <helpers/ui/MomentaryButton.h>
#include <UITask.h>
#endif
extern DFRobotLoRaBoard board;
@@ -20,6 +21,7 @@ extern SensorManager sensors;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
extern UITask ui_task;
#endif
bool radio_init();
+9 -4
View File
@@ -37,6 +37,7 @@ build_flags =
-D SX126X_RX_BOOSTED_GAIN=1
build_src_filter = ${esp32_base.build_src_filter}
+<../variants/ebyte_eora_s3>
+<helpers/ui/BaseUITask.cpp>
lib_deps =
${esp32_base.lib_deps}
adafruit/Adafruit SSD1306 @ ^2.5.13
@@ -46,6 +47,7 @@ lib_deps =
extends = Ebyte_EoRa-S3
build_flags =
${Ebyte_EoRa-S3.build_flags}
-I src/helpers/ui/server
-D DISPLAY_CLASS=SSD1306Display
-D ADVERT_NAME='"EORA_S3-1262 Repeater"'
-D ADVERT_LAT=0.0
@@ -57,6 +59,7 @@ build_flags =
build_src_filter = ${Ebyte_EoRa-S3.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_repeater>
+<helpers/ui/server>
lib_deps =
${Ebyte_EoRa-S3.lib_deps}
${esp32_ota.lib_deps}
@@ -79,6 +82,7 @@ lib_deps =
extends = Ebyte_EoRa-S3
build_flags =
${Ebyte_EoRa-S3.build_flags}
-I src/helpers/ui/server
-D DISPLAY_CLASS=SSD1306Display
-D ADVERT_NAME='"EORA_S3-1262 Room"'
-D ADVERT_LAT=0.0
@@ -90,6 +94,7 @@ build_flags =
build_src_filter = ${Ebyte_EoRa-S3.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_room_server>
+<helpers/ui/server>
lib_deps =
${Ebyte_EoRa-S3.lib_deps}
${esp32_ota.lib_deps}
@@ -98,7 +103,7 @@ lib_deps =
extends = Ebyte_EoRa-S3
build_flags =
${Ebyte_EoRa-S3.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@@ -109,7 +114,7 @@ build_src_filter = ${Ebyte_EoRa-S3.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Ebyte_EoRa-S3.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -118,7 +123,7 @@ lib_deps =
extends = Ebyte_EoRa-S3
build_flags =
${Ebyte_EoRa-S3.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@@ -132,7 +137,7 @@ build_src_filter = ${Ebyte_EoRa-S3.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Ebyte_EoRa-S3.lib_deps}
densaugeo/base64 @ ~1.4.0
+1
View File
@@ -19,6 +19,7 @@ SensorManager sensors;
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
UITask ui_task(&board, &display);
#endif
#ifndef LORA_CR
+2
View File
@@ -10,6 +10,7 @@
#ifdef DISPLAY_CLASS
#include <helpers/ui/SSD1306Display.h>
#include <helpers/ui/MomentaryButton.h>
#include <UITask.h>
#endif
extern ESP32Board board;
@@ -20,6 +21,7 @@ extern SensorManager sensors;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
extern UITask ui_task;
#endif
bool radio_init();
+9 -5
View File
@@ -23,6 +23,7 @@ build_src_filter = ${nrf52_base.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/sensors>
+<helpers/ui/BaseUITask.cpp>
lib_deps =
${nrf52_base.lib_deps}
${sensor_base.lib_deps}
@@ -34,7 +35,7 @@ lib_deps =
extends = GAT562_30S_Mesh_Kit
build_flags =
${GAT562_30S_Mesh_Kit.build_flags}
-D DISPLAY_CLASS=SSD1306Display
-I src/helpers/ui/server
-D ADVERT_NAME='"GAT562 Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -45,12 +46,14 @@ build_flags =
build_src_filter = ${GAT562_30S_Mesh_Kit.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_repeater>
+<helpers/ui/server>
[env:GAT562_30S_Mesh_Kit_room_server]
extends = GAT562_30S_Mesh_Kit
build_flags =
${GAT562_30S_Mesh_Kit.build_flags}
-I src/helpers/ui/server
-D DISPLAY_CLASS=SSD1306Display
-D ADVERT_NAME='"GAT562 Room"'
-D ADVERT_LAT=0.0
@@ -62,6 +65,7 @@ build_flags =
build_src_filter = ${GAT562_30S_Mesh_Kit.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_room_server>
+<helpers/ui/server>
[env:GAT562_30S_Mesh_Kit_companion_radio_usb]
@@ -70,7 +74,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${GAT562_30S_Mesh_Kit.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@@ -79,7 +83,7 @@ build_flags =
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
build_src_filter = ${GAT562_30S_Mesh_Kit.build_src_filter}
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
+<helpers/ui/buzzer.cpp>
lib_deps =
${GAT562_30S_Mesh_Kit.lib_deps}
@@ -93,7 +97,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${GAT562_30S_Mesh_Kit.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@@ -106,7 +110,7 @@ build_src_filter = ${GAT562_30S_Mesh_Kit.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<helpers/ui/buzzer.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${GAT562_30S_Mesh_Kit.lib_deps}
densaugeo/base64 @ ~1.4.0
+1
View File
@@ -15,6 +15,7 @@ GAT56230SMeshKitBoard board;
MomentaryButton joystick_left(JOYSTICK_LEFT, 1000, true, false, false);
MomentaryButton joystick_right(JOYSTICK_RIGHT, 1000, true, false, false);
MomentaryButton back_btn(PIN_BACK_BTN, 1000, true, false, true);
UITask ui_task(&board, &display);
#endif
+2
View File
@@ -10,12 +10,14 @@
#ifdef DISPLAY_CLASS
#include <helpers/ui/SSD1306Display.h>
#include <UITask.h>
extern DISPLAY_CLASS display;
#include <helpers/ui/MomentaryButton.h>
extern MomentaryButton user_btn;
extern MomentaryButton joystick_left;
extern MomentaryButton joystick_right;
extern MomentaryButton back_btn;
extern UITask ui_task;
#endif
extern GAT56230SMeshKitBoard board;
+1 -1
View File
@@ -12,8 +12,8 @@ GAT562EVBProBoard board;
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
MomentaryButton user_btn(PIN_USER_BTN, 1000, true, false, false);
MomentaryButton back_btn(PIN_BACK_BTN, 1000, true, false, true);
UITask ui_task(&board, &display);
#endif
+2
View File
@@ -10,11 +10,13 @@
#ifdef DISPLAY_CLASS
#include <helpers/ui/SSD1306Display.h>
#include <UITask.h>
extern DISPLAY_CLASS display;
#include <helpers/ui/MomentaryButton.h>
extern MomentaryButton user_btn;
extern MomentaryButton back_btn;
extern UITask ui_task;
#endif
extern GAT562EVBProBoard board;
@@ -19,6 +19,7 @@ build_src_filter = ${nrf52_base.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/sensors>
+<helpers/ui/BaseUITask.cpp>
lib_deps =
${nrf52_base.lib_deps}
${sensor_base.lib_deps}
@@ -30,6 +31,7 @@ lib_deps =
extends = GAT562_Mesh_Tracker_Pro
build_flags =
${GAT562_Mesh_Tracker_Pro.build_flags}
-I src/helpers/ui/server
-D DISPLAY_CLASS=SSD1306Display
-D ADVERT_NAME='"GAT562 Repeater"'
-D ADVERT_LAT=0.0
@@ -41,12 +43,14 @@ build_flags =
build_src_filter = ${GAT562_Mesh_Tracker_Pro.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_repeater>
+<helpers/ui/server>
[env:GAT562_Mesh_Tracker_Pro_room_server]
extends = GAT562_Mesh_Tracker_Pro
build_flags =
${GAT562_Mesh_Tracker_Pro.build_flags}
-I src/helpers/ui/server
-D DISPLAY_CLASS=SSD1306Display
-D ADVERT_NAME='"GAT562 Room"'
-D ADVERT_LAT=0.0
@@ -58,6 +62,7 @@ build_flags =
build_src_filter = ${GAT562_Mesh_Tracker_Pro.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_room_server>
+<helpers/ui/server>
[env:GAT562_Mesh_Tracker_Pro_companion_radio_usb]
@@ -66,7 +71,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${GAT562_Mesh_Tracker_Pro.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@@ -75,7 +80,7 @@ build_flags =
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
build_src_filter = ${GAT562_Mesh_Tracker_Pro.build_src_filter}
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${GAT562_Mesh_Tracker_Pro.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -88,7 +93,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${GAT562_Mesh_Tracker_Pro.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@@ -101,7 +106,7 @@ build_src_filter = ${GAT562_Mesh_Tracker_Pro.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${GAT562_Mesh_Tracker_Pro.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -15,6 +15,7 @@ GAT562MeshTrackerProBoard board;
MomentaryButton joystick_left(JOYSTICK_LEFT, 1000, true, false, false);
MomentaryButton joystick_right(JOYSTICK_RIGHT, 1000, true, false, false);
MomentaryButton back_btn(PIN_BACK_BTN, 1000, true, false, true);
UITask ui_task(&board, &display);
#endif
@@ -10,7 +10,9 @@
#ifdef DISPLAY_CLASS
#include <helpers/ui/SSD1306Display.h>
#include <UITask.h>
extern DISPLAY_CLASS display;
extern UITask ui_task;
#include <helpers/ui/MomentaryButton.h>
extern MomentaryButton user_btn;
extern MomentaryButton joystick_left;
+3 -2
View File
@@ -22,6 +22,7 @@ build_src_filter = ${nrf52_base.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/sensors>
+<helpers/ui/BaseUITask.cpp>
lib_deps =
${nrf52_base.lib_deps}
${sensor_base.lib_deps}
@@ -66,7 +67,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${GAT562_Mesh_Watch13.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@@ -81,7 +82,7 @@ build_src_filter = ${GAT562_Mesh_Watch13.build_src_filter}
+<helpers/ui/MomentaryButton.cpp>
+<helpers/ui/GenericVibration.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${GAT562_Mesh_Watch13.lib_deps}
densaugeo/base64 @ ~1.4.0
+1
View File
@@ -12,6 +12,7 @@ GAT56MeshWatch13Board board;
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
MomentaryButton user_btn(PIN_USER_BTN, 1000, true, false, true);
UITask ui_task(&board, &display);
#endif
+2
View File
@@ -10,6 +10,8 @@
#ifdef DISPLAY_CLASS
#include <helpers/ui/SSD1306Display.h>
#include <UITask.h>
extern UITask ui_task;
extern DISPLAY_CLASS display;
#include <helpers/ui/MomentaryButton.h>
extern MomentaryButton user_btn;
+11 -4
View File
@@ -37,6 +37,7 @@ build_flags =
-D DISP_MOSI=6
build_src_filter = ${esp32_base.build_src_filter}
+<../variants/heltec_e213>
+<helpers/ui/BaseUITask.cpp>
lib_deps =
${esp32_base.lib_deps}
https://github.com/Quency-D/heltec-eink-modules/archive/563dd41fd850a1bc3039b8723da4f3a20fe1c800.zip
@@ -45,7 +46,7 @@ lib_deps =
extends = Heltec_E213_base
build_flags =
${Heltec_E213_base.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D DISPLAY_CLASS=E213Display
@@ -57,7 +58,7 @@ build_src_filter = ${Heltec_E213_base.build_src_filter}
+<helpers/ui/E213Display.cpp>
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_E213_base.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -67,7 +68,7 @@ lib_deps =
extends = Heltec_E213_base
build_flags =
${Heltec_E213_base.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D DISPLAY_CLASS=E213Display
@@ -78,7 +79,7 @@ build_src_filter = ${Heltec_E213_base.build_src_filter}
+<helpers/ui/E213Display.cpp>
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_E213_base.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -88,6 +89,7 @@ lib_deps =
extends = Heltec_E213_base
build_flags =
${Heltec_E213_base.build_flags}
-I src/helpers/ui/server
-D DISPLAY_CLASS=E213Display
-D ADVERT_NAME='"Heltec E213 Repeater"'
-D ADVERT_LAT=0.0
@@ -97,6 +99,7 @@ build_flags =
build_src_filter = ${Heltec_E213_base.build_src_filter}
+<helpers/ui/E213Display.cpp>
+<../examples/simple_repeater>
+<helpers/ui/server>
lib_deps =
${Heltec_E213_base.lib_deps}
${esp32_ota.lib_deps}
@@ -131,6 +134,7 @@ lib_deps =
extends = Heltec_E213_base
build_flags =
${Heltec_E213_base.build_flags}
-I src/helpers/ui/server
-D DISPLAY_CLASS=E213Display
-D ADVERT_NAME='"ESPNow Bridge"'
-D ADVERT_LAT=0.0
@@ -145,6 +149,7 @@ build_src_filter = ${Heltec_E213_base.build_src_filter}
+<helpers/bridges/ESPNowBridge.cpp>
+<helpers/ui/E213Display.cpp>
+<../examples/simple_repeater>
+<helpers/ui/server>
lib_deps =
${Heltec_E213_base.lib_deps}
${esp32_ota.lib_deps}
@@ -154,6 +159,7 @@ lib_deps =
extends = Heltec_E213_base
build_flags =
${Heltec_E213_base.build_flags}
-I src/helpers/ui/server
-D DISPLAY_CLASS=E213Display
-D ADVERT_NAME='"Heltec E213 Room"'
-D ADVERT_LAT=0.0
@@ -163,6 +169,7 @@ build_flags =
build_src_filter = ${Heltec_E213_base.build_src_filter}
+<helpers/ui/E213Display.cpp>
+<../examples/simple_room_server>
+<helpers/ui/server>
lib_deps =
${Heltec_E213_base.lib_deps}
${esp32_ota.lib_deps}
+1
View File
@@ -20,6 +20,7 @@ SensorManager sensors;
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display(&board.periph_power);
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
UITask ui_task(&board, &display);
#endif
bool radio_init() {
+2
View File
@@ -10,6 +10,7 @@
#ifdef DISPLAY_CLASS
#include <helpers/ui/E213Display.h>
#include <helpers/ui/MomentaryButton.h>
#include <UITask.h>
#endif
extern HeltecE213Board board;
@@ -20,6 +21,7 @@ extern SensorManager sensors;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
extern UITask ui_task;
#endif
bool radio_init();
+11 -4
View File
@@ -31,6 +31,7 @@ build_flags =
-D PIN_BOARD_SCL=38
build_src_filter = ${esp32_base.build_src_filter}
+<../variants/heltec_e290>
+<helpers/ui/BaseUITask.cpp>
lib_deps =
${esp32_base.lib_deps}
https://github.com/Quency-D/heltec-eink-modules/archive/563dd41fd850a1bc3039b8723da4f3a20fe1c800.zip
@@ -39,7 +40,7 @@ lib_deps =
extends = Heltec_E290_base
build_flags =
${Heltec_E290_base.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D DISPLAY_CLASS=E290Display
@@ -51,7 +52,7 @@ build_src_filter = ${Heltec_E290_base.build_src_filter}
+<helpers/ui/E290Display.cpp>
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_E290_base.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -61,7 +62,7 @@ lib_deps =
extends = Heltec_E290_base
build_flags =
${Heltec_E290_base.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D DISPLAY_CLASS=E290Display
@@ -72,7 +73,7 @@ build_src_filter = ${Heltec_E290_base.build_src_filter}
+<helpers/ui/E290Display.cpp>
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_E290_base.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -82,6 +83,7 @@ lib_deps =
extends = Heltec_E290_base
build_flags =
${Heltec_E290_base.build_flags}
-I src/helpers/ui/server
-D DISPLAY_CLASS=E290Display
-D ADVERT_NAME='"Heltec E290 Repeater"'
-D ADVERT_LAT=0.0
@@ -91,6 +93,7 @@ build_flags =
build_src_filter = ${Heltec_E290_base.build_src_filter}
+<helpers/ui/E290Display.cpp>
+<../examples/simple_repeater>
+<helpers/ui/server>
lib_deps =
${Heltec_E290_base.lib_deps}
${esp32_ota.lib_deps}
@@ -125,6 +128,7 @@ lib_deps =
extends = Heltec_E290_base
build_flags =
${Heltec_E290_base.build_flags}
-I src/helpers/ui/server
-D DISPLAY_CLASS=E290Display
-D ADVERT_NAME='"ESPNow Bridge"'
-D ADVERT_LAT=0.0
@@ -139,6 +143,7 @@ build_src_filter = ${Heltec_E290_base.build_src_filter}
+<helpers/bridges/ESPNowBridge.cpp>
+<helpers/ui/E290Display.cpp>
+<../examples/simple_repeater>
+<helpers/ui/server>
lib_deps =
${Heltec_E290_base.lib_deps}
${esp32_ota.lib_deps}
@@ -148,6 +153,7 @@ lib_deps =
extends = Heltec_E290_base
build_flags =
${Heltec_E290_base.build_flags}
-I src/helpers/ui/server
-D DISPLAY_CLASS=E290Display
-D ADVERT_NAME='"Heltec E290 Room"'
-D ADVERT_LAT=0.0
@@ -157,6 +163,7 @@ build_flags =
build_src_filter = ${Heltec_E290_base.build_src_filter}
+<helpers/ui/E290Display.cpp>
+<../examples/simple_room_server>
+<helpers/ui/server>
lib_deps =
${Heltec_E290_base.lib_deps}
${esp32_ota.lib_deps}
+1
View File
@@ -20,6 +20,7 @@ SensorManager sensors;
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display(&board.periph_power);
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
UITask ui_task(&board, &display);
#endif
bool radio_init() {
+2
View File
@@ -10,6 +10,7 @@
#ifdef DISPLAY_CLASS
#include <helpers/ui/E290Display.h>
#include <helpers/ui/MomentaryButton.h>
#include <UITask.h>
#endif
extern HeltecE290Board board;
@@ -20,6 +21,7 @@ extern SensorManager sensors;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
extern UITask ui_task;
#endif
bool radio_init();
+1
View File
@@ -18,6 +18,7 @@ SolarExternalWatchdog external_watchdog;
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
UITask ui_task(&board, &display);
#endif
bool radio_init() {
+2
View File
@@ -11,6 +11,7 @@
#include <helpers/ExternalWatchdogManager.h>
#ifdef DISPLAY_CLASS
#include <helpers/ui/ST7789Display.h>
#include <UITask.h>
#endif
class SolarSensorManager : public SensorManager {
@@ -47,6 +48,7 @@ extern SolarExternalWatchdog external_watchdog;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
extern UITask ui_task;
#endif
bool radio_init();
+22 -15
View File
@@ -72,6 +72,7 @@ build_flags =
build_src_filter = ${Heltec_RC32.build_src_filter}
+<helpers/ui/NV3001BDisplay.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/ui/BaseUITask.cpp>
lib_deps =
${Heltec_RC32.lib_deps}
@@ -127,7 +128,7 @@ lib_deps =
extends = Heltec_RC32
build_flags =
${Heltec_RC32.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D DISPLAY_CLASS=NullDisplayDriver
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@@ -138,7 +139,7 @@ build_src_filter = ${Heltec_RC32.build_src_filter}
+<helpers/ui/NullDisplayDriver.cpp>
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_RC32.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -148,7 +149,7 @@ lib_deps =
extends = Heltec_RC32
build_flags =
${Heltec_RC32.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D DISPLAY_CLASS=NullDisplayDriver
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@@ -162,7 +163,7 @@ build_src_filter = ${Heltec_RC32.build_src_filter}
+<helpers/ui/NullDisplayDriver.cpp>
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_RC32.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -172,7 +173,7 @@ lib_deps =
extends = Heltec_RC32
build_flags =
${Heltec_RC32.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D ENABLE_WIFI_INTERFACE
-D DISPLAY_CLASS=NullDisplayDriver
-D MAX_CONTACTS=350
@@ -188,7 +189,7 @@ build_src_filter = ${Heltec_RC32.build_src_filter}
+<helpers/esp32/*.cpp>
+<helpers/wifi/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_RC32.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -214,6 +215,7 @@ lib_deps =
extends = Heltec_RC32_with_display
build_flags =
${Heltec_RC32_with_display.build_flags}
-I src/helpers/ui/server
-D ADVERT_NAME='"Heltec RC32 Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -221,6 +223,7 @@ build_flags =
-D MAX_NEIGHBOURS=50
build_src_filter = ${Heltec_RC32_with_display.build_src_filter}
+<../examples/simple_repeater>
+<helpers/ui/server>
lib_deps =
${Heltec_RC32_with_display.lib_deps}
${esp32_ota.lib_deps}
@@ -230,6 +233,7 @@ lib_deps =
extends = Heltec_RC32_with_display
build_flags =
${Heltec_RC32_with_display.build_flags}
-I src/helpers/ui/server
-D ADVERT_NAME='"ESPNow Bridge"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -239,6 +243,7 @@ build_flags =
build_src_filter = ${Heltec_RC32_with_display.build_src_filter}
+<helpers/bridges/ESPNowBridge.cpp>
+<../examples/simple_repeater>
+<helpers/ui/server>
lib_deps =
${Heltec_RC32_with_display.lib_deps}
${esp32_ota.lib_deps}
@@ -247,6 +252,7 @@ lib_deps =
extends = Heltec_RC32_with_display
build_flags =
${Heltec_RC32_with_display.build_flags}
-I src/helpers/ui/server
-D ADVERT_NAME='"Heltec RC32 Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -254,6 +260,7 @@ build_flags =
-D ROOM_PASSWORD='"hello"'
build_src_filter = ${Heltec_RC32_with_display.build_src_filter}
+<../examples/simple_room_server>
+<helpers/ui/server>
lib_deps =
${Heltec_RC32_with_display.lib_deps}
${esp32_ota.lib_deps}
@@ -274,7 +281,7 @@ lib_deps =
extends = Heltec_RC32_with_display
build_flags =
${Heltec_RC32_with_display.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D UI_HAS_ROTARY_INPUT
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@@ -283,7 +290,7 @@ build_src_filter = ${Heltec_RC32_with_display.build_src_filter}
+<helpers/ui/buzzer.cpp>
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_RC32_with_display.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -293,7 +300,7 @@ lib_deps =
extends = Heltec_RC32_with_display
build_flags =
${Heltec_RC32_with_display.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D UI_HAS_ROTARY_INPUT
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@@ -305,7 +312,7 @@ build_src_filter = ${Heltec_RC32_with_display.build_src_filter}
+<helpers/ui/buzzer.cpp>
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_RC32_with_display.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -315,7 +322,7 @@ lib_deps =
extends = Heltec_RC32_with_display
build_flags =
${Heltec_RC32_with_display.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D ENABLE_WIFI_INTERFACE
-D UI_HAS_ROTARY_INPUT
-D MAX_CONTACTS=350
@@ -329,7 +336,7 @@ build_src_filter = ${Heltec_RC32_with_display.build_src_filter}
+<helpers/esp32/*.cpp>
+<helpers/wifi/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_RC32_with_display.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -338,17 +345,17 @@ lib_deps =
[env:heltec_rc32_sensor]
extends = Heltec_RC32_with_display
build_flags =
${Heltec_RC32_with_display.build_flags}
${Heltec_RC32.build_flags}
-D ADVERT_NAME='"Heltec RC32 Sensor"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D ENV_PIN_SDA=21
-D ENV_PIN_SCL=18
build_src_filter = ${Heltec_RC32_with_display.build_src_filter}
build_src_filter = ${Heltec_RC32.build_src_filter}
+<../examples/simple_sensor>
lib_deps =
${Heltec_RC32_with_display.lib_deps}
${Heltec_RC32.lib_deps}
${esp32_ota.lib_deps}
[env:heltec_rc32_kiss_modem]
+1
View File
@@ -35,6 +35,7 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
static HeltecRC32RotaryInput rotaryInputImpl(&board.periph_power);
RotaryInput& rotary_input = rotaryInputImpl;
#endif
UITask ui_task(&board, &display);
#endif
bool radio_init() {
+2
View File
@@ -18,6 +18,7 @@
#else
#include <helpers/ui/NullDisplayDriver.h>
#endif
#include <UITask.h>
#endif
extern HeltecRC32Board board;
@@ -31,6 +32,7 @@ extern EnvironmentSensorManager sensors;
#if defined(UI_HAS_ROTARY_INPUT)
extern RotaryInput& rotary_input;
#endif
extern UITask ui_task;
#endif
bool radio_init();
+13 -8
View File
@@ -66,7 +66,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${heltec_rc52.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-orig
-D DISPLAY_CLASS=NullDisplayDriver
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@@ -76,7 +76,7 @@ build_src_filter = ${heltec_rc52.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<helpers/ui/NullDisplayDriver.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-orig>
lib_deps =
${heltec_rc52.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -87,7 +87,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${heltec_rc52.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-orig
-D DISPLAY_CLASS=NullDisplayDriver
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@@ -95,7 +95,7 @@ build_src_filter = ${heltec_rc52.build_src_filter}
+<helpers/nrf52/*.cpp>
+<helpers/ui/NullDisplayDriver.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-orig>
lib_deps =
${heltec_rc52.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -113,6 +113,7 @@ build_flags =
build_src_filter = ${heltec_rc52.build_src_filter}
+<helpers/ui/NV3001BDisplay.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/ui/BaseUITask.cpp>
lib_deps =
${heltec_rc52.lib_deps}
@@ -120,8 +121,10 @@ lib_deps =
extends = heltec_rc52_with_display
build_src_filter = ${heltec_rc52_with_display.build_src_filter}
+<../examples/simple_repeater>
+<helpers/ui/server>
build_flags =
${heltec_rc52_with_display.build_flags}
-I src/helpers/ui/server
-D ADVERT_NAME='"Heltec RC52 Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -132,8 +135,10 @@ build_flags =
extends = heltec_rc52_with_display
build_src_filter = ${heltec_rc52_with_display.build_src_filter}
+<../examples/simple_room_server>
+<helpers/ui/server>
build_flags =
${heltec_rc52_with_display.build_flags}
-I src/helpers/ui/server
-D ADVERT_NAME='"Heltec RC52 Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -146,7 +151,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${heltec_rc52_with_display.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D PIN_BUZZER=5
-D UI_HAS_ROTARY_INPUT
-D MAX_CONTACTS=350
@@ -158,7 +163,7 @@ build_src_filter = ${heltec_rc52_with_display.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<helpers/ui/buzzer.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${heltec_rc52_with_display.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -170,7 +175,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${heltec_rc52_with_display.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D PIN_BUZZER=5
-D UI_HAS_ROTARY_INPUT
-D MAX_CONTACTS=350
@@ -180,7 +185,7 @@ build_src_filter = ${heltec_rc52_with_display.build_src_filter}
+<helpers/nrf52/*.cpp>
+<helpers/ui/buzzer.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${heltec_rc52_with_display.lib_deps}
densaugeo/base64 @ ~1.4.0
+1
View File
@@ -39,6 +39,7 @@ MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
static HeltecRC52RotaryInput rotaryInputImpl(&board.periph_power);
RotaryInput& rotary_input = rotaryInputImpl;
#endif
UITask ui_task(&board, &display);
#endif
bool radio_init()
+2
View File
@@ -19,6 +19,7 @@
#else
#include <helpers/ui/NullDisplayDriver.h>
#endif
#include <UITask.h>
#endif
extern HeltecRC52Board board;
@@ -32,6 +33,7 @@ extern MomentaryButton user_btn;
#if defined(UI_HAS_ROTARY_INPUT)
extern RotaryInput& rotary_input;
#endif
extern UITask ui_task;
#endif
bool radio_init();
+14 -5
View File
@@ -47,6 +47,7 @@ build_src_filter = ${nrf52_base.build_src_filter}
+<../variants/heltec_t096>
+<helpers/ui/ST7735Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/ui/BaseUITask.cpp>
lib_deps =
${nrf52_base.lib_deps}
${sensor_base.lib_deps}
@@ -58,9 +59,10 @@ upload_protocol = nrfutil
extends = Heltec_t096
build_src_filter = ${Heltec_t096.build_src_filter}
+<../examples/simple_repeater>
+<helpers/ui/server>
build_flags =
${Heltec_t096.build_flags}
-I src/helpers/ui/server
-D ADVERT_NAME='"Heltec_t096 Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -73,6 +75,7 @@ build_flags =
extends = Heltec_t096
build_flags =
${Heltec_t096.build_flags}
-I src/helpers/ui/server
-D ADVERT_NAME='"RS232 Bridge"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -87,13 +90,16 @@ build_flags =
build_src_filter = ${Heltec_t096.build_src_filter}
+<helpers/bridges/RS232Bridge.cpp>
+<../examples/simple_repeater>
+<helpers/ui/server>
[env:Heltec_t096_room_server]
extends = Heltec_t096
build_src_filter = ${Heltec_t096.build_src_filter}
+<../examples/simple_room_server>
+<helpers/ui/server>
build_flags =
${Heltec_t096.build_flags}
-I src/helpers/ui/server
-D ADVERT_NAME='"Heltec_t096 Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -125,7 +131,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${Heltec_t096.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
@@ -137,7 +143,7 @@ build_flags =
build_src_filter = ${Heltec_t096.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_t096.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -148,7 +154,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${Heltec_t096.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D ENABLE_USB_INTERFACE
@@ -159,12 +165,15 @@ build_flags =
build_src_filter = ${Heltec_t096.build_src_filter}
+<helpers/nrf52/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_t096.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:Heltec_t096_kiss_modem]
extends = Heltec_t096
build_flags =
${Heltec_t096.build_flags}
-U DISPLAY_CLASS
build_src_filter = ${Heltec_t096.build_src_filter}
+<../examples/kiss_modem/>
+1
View File
@@ -33,6 +33,7 @@ EnvironmentSensorManager sensors;
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display(&board.periph_power);
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
UITask ui_task(&board, &display);
#endif
bool radio_init() {
+2
View File
@@ -12,6 +12,7 @@
#ifdef DISPLAY_CLASS
#include <helpers/ui/MomentaryButton.h>
#include <helpers/ui/ST7735Display.h>
#include <UITask.h>
#else
#include "helpers/ui/NullDisplayDriver.h"
#endif
@@ -24,6 +25,7 @@ extern EnvironmentSensorManager sensors;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
extern UITask ui_task;
#endif
bool radio_init();
+12 -5
View File
@@ -20,6 +20,7 @@ build_src_filter = ${nrf52_base.build_src_filter}
+<../variants/heltec_t1>
+<helpers/ui/ST7735Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/ui/BaseUITask.cpp>
lib_deps =
${nrf52_base.lib_deps}
${sensor_base.lib_deps}
@@ -31,9 +32,10 @@ upload_protocol = nrfutil
extends = Heltec_t1
build_src_filter = ${Heltec_t1.build_src_filter}
+<../examples/simple_repeater>
+<helpers/ui/server>
build_flags =
${Heltec_t1.build_flags}
-I src/helpers/ui/server
-D ADVERT_NAME='"Heltec_t1 Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -46,8 +48,10 @@ build_flags =
extends = Heltec_t1
build_src_filter = ${Heltec_t1.build_src_filter}
+<../examples/simple_room_server>
+<helpers/ui/server>
build_flags =
${Heltec_t1.build_flags}
-I src/helpers/ui/server
-D ADVERT_NAME='"Heltec_t1 Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -62,7 +66,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${Heltec_t1.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
@@ -75,7 +79,7 @@ build_src_filter = ${Heltec_t1.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<helpers/ui/buzzer.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_t1.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -87,7 +91,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${Heltec_t1.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D ENABLE_USB_INTERFACE
@@ -97,7 +101,7 @@ build_src_filter = ${Heltec_t1.build_src_filter}
+<helpers/nrf52/*.cpp>
+<helpers/ui/buzzer.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_t1.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -105,5 +109,8 @@ lib_deps =
[env:Heltec_t1_kiss_modem]
extends = Heltec_t1
build_flags =
${Heltec_t1.build_flags}
-U DISPLAY_CLASS
build_src_filter = ${Heltec_t1.build_src_filter}
+<../examples/kiss_modem/>
+1
View File
@@ -32,6 +32,7 @@ EnvironmentSensorManager sensors;
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display(&board.periph_power);
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
UITask ui_task(&board, &display);
#endif
bool radio_init() {
+2
View File
@@ -12,6 +12,7 @@
#ifdef DISPLAY_CLASS
#include <helpers/ui/MomentaryButton.h>
#include <helpers/ui/ST7735Display.h>
#include <UITask.h>
#else
#include "helpers/ui/NullDisplayDriver.h"
#endif
@@ -24,6 +25,7 @@ extern EnvironmentSensorManager sensors;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
extern UITask ui_task;
#endif
bool radio_init();
+18 -9
View File
@@ -98,7 +98,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${Heltec_t114.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D DISPLAY_CLASS=NullDisplayDriver
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@@ -111,7 +111,7 @@ build_src_filter = ${Heltec_t114.build_src_filter}
+<helpers/ui/NullDisplayDriver.cpp>
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_t114.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -122,7 +122,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${Heltec_t114.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D DISPLAY_CLASS=NullDisplayDriver
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@@ -131,7 +131,7 @@ build_src_filter = ${Heltec_t114.build_src_filter}
+<helpers/nrf52/*.cpp>
+<helpers/ui/NullDisplayDriver.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_t114.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -152,6 +152,7 @@ build_src_filter = ${Heltec_t114.build_src_filter}
+<helpers/ui/MomentaryButton.cpp>
+<helpers/ui/OLEDDisplay.cpp>
+<helpers/ui/OLEDDisplayFonts.cpp>
+<helpers/ui/BaseUITask.cpp>
lib_deps =
${Heltec_t114.lib_deps}
adafruit/Adafruit SSD1306 @ ^2.5.13
@@ -162,9 +163,10 @@ upload_protocol = nrfutil
extends = Heltec_t114_with_display
build_src_filter = ${Heltec_t114_with_display.build_src_filter}
+<../examples/simple_repeater>
+<helpers/ui/server>
build_flags =
${Heltec_t114_with_display.build_flags}
-I src/helpers/ui/server
-D ADVERT_NAME='"Heltec_T114 Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -177,6 +179,7 @@ build_flags =
extends = Heltec_t114
build_flags =
${Heltec_t114.build_flags}
-I src/helpers/ui/server
-D ADVERT_NAME='"RS232 Bridge"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -191,13 +194,16 @@ build_flags =
build_src_filter = ${Heltec_t114_with_display.build_src_filter}
+<helpers/bridges/RS232Bridge.cpp>
+<../examples/simple_repeater>
+<helpers/ui/server>
[env:Heltec_t114_room_server]
extends = Heltec_t114_with_display
build_src_filter = ${Heltec_t114_with_display.build_src_filter}
+<../examples/simple_room_server>
+<helpers/ui/server>
build_flags =
${Heltec_t114_with_display.build_flags}
-I src/helpers/ui/server
-D ADVERT_NAME='"Heltec_T114 Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -212,7 +218,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${Heltec_t114_with_display.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
@@ -224,7 +230,7 @@ build_flags =
build_src_filter = ${Heltec_t114_with_display.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_t114_with_display.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -235,7 +241,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${Heltec_t114_with_display.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D ENABLE_USB_INTERFACE
@@ -246,12 +252,15 @@ build_flags =
build_src_filter = ${Heltec_t114_with_display.build_src_filter}
+<helpers/nrf52/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_t114_with_display.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:Heltec_t114_kiss_modem]
extends = Heltec_t114
build_flags =
${Heltec_t114.build_flags}
-U DISPLAY_CLASS
build_src_filter = ${Heltec_t114.build_src_filter}
+<../examples/kiss_modem/>
+1
View File
@@ -32,6 +32,7 @@ EnvironmentSensorManager sensors;
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
UITask ui_task(&board, &display);
#endif
bool radio_init() {
+2
View File
@@ -16,6 +16,7 @@
#else
#include "helpers/ui/NullDisplayDriver.h"
#endif
#include <UITask.h>
#endif
extern T114Board board;
@@ -26,6 +27,7 @@ extern EnvironmentSensorManager sensors;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
extern UITask ui_task;
#endif
bool radio_init();
+14 -4
View File
@@ -44,6 +44,7 @@ build_src_filter = ${esp32_base.build_src_filter}
+<helpers/ui/ST7789Display.cpp>
+<helpers/ui/OLEDDisplay.cpp>
+<helpers/ui/OLEDDisplayFonts.cpp>
+<helpers/ui/BaseUITask.cpp>
lib_deps =
${esp32_base.lib_deps}
adafruit/Adafruit GFX Library @ ^1.12.1
@@ -52,7 +53,7 @@ lib_deps =
extends = Heltec_T190_base
build_flags =
${Heltec_T190_base.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456 ; dynamic, random PIN
@@ -61,7 +62,7 @@ build_flags =
build_src_filter = ${Heltec_T190_base.build_src_filter}
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_T190_base.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -70,7 +71,7 @@ lib_deps =
extends = Heltec_T190_base
build_flags =
${Heltec_T190_base.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D OFFLINE_QUEUE_SIZE=256
@@ -78,7 +79,7 @@ build_flags =
build_src_filter = ${Heltec_T190_base.build_src_filter}
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_T190_base.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -87,6 +88,7 @@ lib_deps =
extends = Heltec_T190_base
build_flags =
${Heltec_T190_base.build_flags}
-I src/helpers/ui/server
-D ADVERT_NAME='"Heltec T190 Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -94,6 +96,7 @@ build_flags =
-D MAX_NEIGHBOURS=50
build_src_filter = ${Heltec_T190_base.build_src_filter}
+<../examples/simple_repeater>
+<helpers/ui/server>
lib_deps =
${Heltec_T190_base.lib_deps}
${esp32_ota.lib_deps}
@@ -124,6 +127,7 @@ lib_deps =
extends = Heltec_T190_base
build_flags =
${Heltec_T190_base.build_flags}
-I src/helpers/ui/server
-D ADVERT_NAME='"ESPNow Bridge"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -136,6 +140,7 @@ build_flags =
build_src_filter = ${Heltec_T190_base.build_src_filter}
+<helpers/bridges/ESPNowBridge.cpp>
+<../examples/simple_repeater>
+<helpers/ui/server>
lib_deps =
${Heltec_T190_base.lib_deps}
${esp32_ota.lib_deps}
@@ -144,6 +149,7 @@ lib_deps =
extends = Heltec_T190_base
build_flags =
${Heltec_T190_base.build_flags}
-I src/helpers/ui/server
-D ADVERT_NAME='"Heltec T190 Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -151,11 +157,15 @@ build_flags =
-D ROOM_PASSWORD='"hello"'
build_src_filter = ${Heltec_T190_base.build_src_filter}
+<../examples/simple_room_server>
+<helpers/ui/server>
lib_deps =
${Heltec_T190_base.lib_deps}
${esp32_ota.lib_deps}
[env:Heltec_T190_kiss_modem]
extends = Heltec_T190_base
build_flags =
${Heltec_T190_base.build_flags}
-U DISPLAY_CLASS
build_src_filter = ${Heltec_T190_base.build_src_filter}
+<../examples/kiss_modem/>
+1
View File
@@ -20,6 +20,7 @@ SensorManager sensors;
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
UITask ui_task(&board, &display);
#endif
bool radio_init() {
+2
View File
@@ -10,6 +10,7 @@
#ifdef DISPLAY_CLASS
#include <helpers/ui/ST7789Display.h>
#include <helpers/ui/MomentaryButton.h>
#include <UITask.h>
#endif
extern HeltecT190Board board;
@@ -20,6 +21,7 @@ extern SensorManager sensors;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
extern UITask ui_task;
#endif
bool radio_init();
+4 -4
View File
@@ -59,7 +59,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${Heltec_tower_v2.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D DISPLAY_CLASS=NullDisplayDriver
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@@ -72,7 +72,7 @@ build_src_filter = ${Heltec_tower_v2.build_src_filter}
+<helpers/ui/NullDisplayDriver.cpp>
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_tower_v2.lib_deps}
densaugeo/base64 @ ~1.4.0
@@ -83,7 +83,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${Heltec_tower_v2.build_flags}
-I examples/companion_radio/ui-new
-I src/helpers/ui/companion-new
-D DISPLAY_CLASS=NullDisplayDriver
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@@ -96,7 +96,7 @@ build_src_filter = ${Heltec_tower_v2.build_src_filter}
+<helpers/ui/NullDisplayDriver.cpp>
+<helpers/nrf52/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/companion-new>
lib_deps =
${Heltec_tower_v2.lib_deps}
densaugeo/base64 @ ~1.4.0
Loaded 100 of 283 files, more files were not shown because too many files have changed in this diff. Show more