Compare commits

..
449 Commits
Author SHA1 Message Date
Scott Powell ff6e2447b8 Merge branch 'dev' 2025-04-07 22:01:08 +10:00
Scott Powell 19797c9b87 * ver bump to v1.4.3 2025-04-07 21:59:53 +10:00
Scott Powell f80f5f090b * default SF now 11 2025-04-07 21:55:24 +10:00
Scott Powell 7d731e82f5 * ID hash 0x00 and 0xFF now reserved for future. 2025-04-06 12:34:09 +10:00
ripplebiz 98d29a7a2b Merge pull request #172 from recrof/dev
set repeater/room server Lat & Lon to 0.0 as default
2025-04-04 19:26:30 +11:00
ripplebiz 8fe566d95c Merge pull request #173 from oltaco/promicro-rfswitch
FIX: Set RfSwitch pins properly.
2025-04-04 19:25:12 +11:00
taco b4bc19a942 FIX: Need to explicitly setRfSwitchPins to drive RXEN high when in receive mode. 2025-04-04 15:39:11 +11:00
recrof e3f13a8285 set repeater/room server Lat & Lon to 0.0 as default 2025-04-03 14:59:20 +02:00
ripplebiz 86c4dbf222 Merge pull request #171 from LitBomb/patch-9
Update faq.md
2025-04-02 19:15:33 +11:00
uncle lit 5e3f6e9ca1 Update faq.md
Add table of content
Add http://config.meshcore.dev for repeater and room server setup
Add T-Deck GPS info screen sentences counter
Add explanation who 869.525MHz is the chosen frequency for EU and UK and why 867.5MHz isn't good comparing to 869.525
2025-04-01 22:49:09 -07:00
ripplebiz 47ee171147 Merge pull request #167 from fdlamotte/xiao_s3_serial_onpins
Allow the use companion radio on other serial interfaces
2025-04-02 00:02:46 +11:00
Florent de Lamotte a8241aabeb Merge branch 'dev' into xiao_s3_serial_onpins 2025-04-01 11:33:00 +02:00
Florent de Lamotte fcfc54d2b4 initial commit 2025-04-01 11:32:04 +02:00
ripplebiz a895e3a887 Merge pull request #165 from liamcottle/dev
Show please wait message on boot
2025-04-01 14:42:59 +11:00
liamcottle 6c34844486 init display before radio 2025-04-01 16:10:12 +13:00
liamcottle fb57b4d2d6 show please wait message on room server boot 2025-04-01 16:04:06 +13:00
liamcottle ddeb1421c5 show please wait message on repeater boot 2025-04-01 16:00:09 +13:00
liamcottle 196b225035 show please wait message on companion boot 2025-04-01 15:50:24 +13:00
ripplebiz 331c1d9cff Merge pull request #164 from liamcottle/dev
Fix Companion Display Noise
2025-04-01 13:02:57 +11:00
liamcottle afe3507ec5 clear display on init to avoid static 2025-04-01 14:46:48 +13:00
ripplebiz 48e4a4289f Merge pull request #155 from oltaco/promicro-refactor
ProMicro refactoring
2025-04-01 12:43:09 +11:00
ripplebiz 245b323076 Merge pull request #163 from LitBomb/patch-7
Update faq.md
2025-04-01 12:37:08 +11:00
uncle lit b66d5ebe15 Update faq.md
added the following to FAQ:

public/private flood and repeater set flood.max CLI
public key in hex and base64
How paths are created and reuse to minimize utilization
T-Deck Diag explanation
Update repeater with a Raspberry Pi
clients don't repeat explanation
other meshcore projects
fix discord link to build instruction
2025-03-31 14:51:52 -07:00
Scott Powell 0b95fc76ba * room server: faster sync of unread posts, MAX_UNSYNCED_POSTS now 32 (was 16) 2025-03-31 14:01:49 +11:00
ripplebiz 57862dec0f Merge pull request #149 from jameshall9327/main
TBeam: Added Repeater
2025-03-31 13:10:20 +11:00
Scott Powell afc64d8674 * Tbeam fix: GPIO assignments wrong 2025-03-31 13:03:33 +11:00
Scott Powell 017e567669 Merge commit '387a83e129114b6005321739149a1e0eb1fa5a82' into dev 2025-03-31 00:15:38 +11:00
ripplebiz 387a83e129 Merge pull request #157 from fdlamotte/t1000e_clock
Remove rtc auto-detect on t1000
2025-03-31 00:14:17 +11:00
Florent 90aaa41d84 Remove rtc auto-detect on t1000 2025-03-30 15:09:40 +02:00
Scott Powell 1c482b4315 Merge branch 'dev' 2025-03-30 19:18:35 +11:00
ripplebiz 5b986a36fc Merge pull request #145 from recrof/main
change new default freq to 869.525
2025-03-30 19:01:55 +11:00
Scott Powell e2ff6879dc * ver bump to v1.4.2 2025-03-30 18:56:21 +11:00
taco 2a236b0dc1 fix: give ProMicroLLCC68 a different definition 2025-03-30 15:57:20 +11:00
taco 68b3c75510 Refactor: FaketecBoard to PromicroBoard 2025-03-30 15:52:25 +11:00
Scott Powell 0d2d1e9c66 * minor refactor 2025-03-30 14:47:52 +11:00
ripplebiz d8d155ca5e Merge pull request #154 from recrof/dev
added new CommonCLI get commands: `get role` and `get public.key`
2025-03-30 14:40:49 +11:00
recrof f31e78069c added new CommonCLI get commands: get role and get public.key 2025-03-29 19:40:35 +01:00
Scott Powell dfca574481 * ESP-Now: long range mode 2025-03-29 13:27:17 +11:00
Scott Powell 01cf9d8535 * isReceiving() now includes either preamble detect or header detect 2025-03-28 22:20:42 +11:00
Scott Powell f1c2c96fb8 * Dispatcher: now impose a max time for CAD fail (ie. channel busy), defined by getCADFailMaxDuration(), default 4 seconds.
(an sx126x bug _might_ be making radio->isReceiving() return true indefinitely)
2025-03-28 20:50:42 +11:00
Scott Powell f615e9f5b7 * companion: temp fix: logRxRaw() is blowing the MAX_FRAME_SIZE 2025-03-28 14:14:59 +11:00
James Hall a3cd7fe761 TBeam: Added Repeater 2025-03-27 09:21:29 -04:00
Scott Powell 06684438b3 * refactor: rtc_clock now defined by variants/*/target modules 2025-03-27 21:28:06 +11:00
Scott Powell c8fa816dfc * new ESPNOWRadio driver
* refactored the examples/*/main.cpp modules, moving radio specifics to variants/*/target modules
* new Generic_ESPNOW_* target envs
2025-03-27 19:34:16 +11:00
Scott Powell b4b2ca2063 Merge branch 'dev' into esp-now 2025-03-27 17:24:56 +11:00
Scott Powell 882e5ba1c0 * room server: now support "log start/stop..." 2025-03-27 13:00:40 +11:00
recrof bf48fefd44 change new default freq to 869.525 2025-03-26 18:06:20 +01:00
ripplebiz 8f3d8da5db Merge pull request #144 from adrian-immel/Fix-Typo
Fix build issue for FakeTec board
2025-03-26 16:22:01 +11:00
Adrian ed69024cae Update FaketecBoard.cpp 2025-03-25 23:21:05 +01:00
Adrian 6fa77381d2 Rename faketecBoard.h to FaketecBoard.h 2025-03-25 23:16:08 +01:00
Adrian c6ff5ee850 Rename faketecBoard.cpp to FaketecBoard.cpp 2025-03-25 23:14:48 +01:00
Scott Powell 696dbded26 * experiment: enabling forwarding in terminal chat 2025-03-26 03:57:36 +11:00
Scott Powell c1c378b40c * ver bump to 1.4.1 2025-03-25 22:02:37 +11:00
Scott Powell 2424d026dc * flood_advert_interval" now defaults to 3 hours for upgrading nodes (not just fresh install)
* companion: "node_prefs" -> "new_prefs" migration
2025-03-25 20:20:03 +11:00
Scott Powell 83138bd39a * fix for double radio.begin(). RNG seed from pressing ENTER 2025-03-25 17:40:36 +11:00
Scott Powell e12d7bf699 * wifi power max 2025-03-25 15:13:07 +11:00
Scott Powell c97c27561a * more experiments 2025-03-25 01:26:46 +11:00
Scott Powell 7fff6dfe5c * ESP-NOW experiment with terminal-chat 2025-03-24 21:16:00 +11:00
Scott Powell 63845b0d5c * build fixes 2025-03-24 13:11:08 +11:00
ripplebiz 2722ee8f55 Merge pull request #128 from Noki/xiao-s3-wio-room-server
xiao s3 wio: add room server
2025-03-24 11:59:05 +11:00
ripplebiz e20c74b12a Merge pull request #127 from jameshall9327/main
Added screen and button support for the lilygo tbeam
2025-03-24 11:55:22 +11:00
ripplebiz 3768540b9b Merge pull request #135 from recrof/dev
LilyGo T-ECHO: report correct battery voltage
2025-03-24 11:48:52 +11:00
recrof 51a6ce0f62 cleanup 2025-03-23 18:31:39 +01:00
Rastislav Vysoky 0a73a96864 Merge branch 'ripplebiz:dev' into dev 2025-03-23 18:27:02 +01:00
recrof e921af46b7 LilyGo T-ECHO: report correct battery voltage 2025-03-23 15:57:33 +01:00
Scott Powell 783529325f * repeater & room server: "node_prefs" -> "com_prefs" migration 2025-03-24 00:50:28 +11:00
Scott Powell 83008d287b * room server: new config "allow.read.only" 2025-03-24 00:25:36 +11:00
Scott Powell e951143446 * repeater & room server: new config "flood.advert.interval" 2025-03-23 23:23:02 +11:00
Scott Powell 83c9dd6fa4 * companion: CMD_SEND_TXT_MSG fix for attempt number 2025-03-23 20:25:03 +11:00
Scott Powell a0ccea47c3 * refactor: ESP32 OTA lib-deps now selectively added 2025-03-23 17:36:31 +11:00
Scott Powell fe653b2836 * OTA update for ESP32 targets 2025-03-22 23:51:44 +11:00
Scott Powell 71af826344 * workaround for > 3 retry attempts 2025-03-22 22:21:54 +11:00
ripplebiz 0516c65709 Merge pull request #131 from fdlamotte/t1000e_range_fix
Some fixes for range issue
2025-03-22 11:54:10 +11:00
Florent de Lamotte 292349c7e0 Some fixes for range issue 2025-03-21 15:08:13 +01:00
Scott Powell 1320b4cea6 * faketec/promicro fix 2025-03-21 21:53:53 +11:00
Scott Powell 1b6ccc1c8d * fix for Faketec/Promicro 2025-03-21 21:53:23 +11:00
Scott Powell 41918efd6d * BIG refactor: 'board' and 'radio' objects now defined in 'target.h/.cpp'
* mesh::RTCClock class moved to MeshCore.h
2025-03-21 18:57:12 +11:00
Tobias Schwarz 7947d331d2 xiao s3 wio: add room server 2025-03-20 16:49:24 +00:00
James Hall 325569c526 added button support 2025-03-20 12:26:52 -04:00
James Hall b626dbca8a removed repeater code not working properly 2025-03-20 11:48:35 -04:00
James Hall a0633bdbb1 Screen support for tbeam 2025-03-20 11:44:12 -04:00
ripplebiz d068193481 Merge pull request #124 from recrof/dev
added battery voltage support for Heltec T114
2025-03-20 22:22:33 +11:00
recrof c5a69d4c72 added battery voltage support for Heltec T114 2025-03-20 11:08:13 +01:00
ripplebiz c18cde7ee2 Merge pull request #123 from oltaco/faketec-support
Faketec display and button support.
2025-03-20 15:27:25 +11:00
Scott Powell aabdabe232 * minor refactor, SNR from packet 2025-03-20 15:26:23 +11:00
taco 2bd3bc1a15 Fix builds for repeater, room server and companion usb. 2025-03-20 12:50:35 +11:00
taco b87f9b3b55 Remove PIN_OLED_RESET from board header, will leave in build target for now. 2025-03-20 10:05:01 +11:00
taco 5fcdbd357b Changed BLE pin back to 123456 now - dynamic display sensing happening. 2025-03-20 09:46:40 +11:00
taco 5d7deaffc9 Add faketec changes back after dev merge 2025-03-20 09:27:11 +11:00
taco 3bc9d094ac Merge branch 'dev' into faketec-support 2025-03-20 09:26:23 +11:00
Scott Powell 46cb2afb4f * build.sh: .uf2 step also for Faketec/ProMicro targets 2025-03-19 20:22:46 +11:00
Scott Powell 58852bcbd8 * ver bump to v1.4.0 2025-03-19 19:32:07 +11:00
Scott Powell 9c27e887ba * companion: CMD_SET_DEVICE_PIN now uint32 param, RESP_CODE_DEVICE_INFO now includes ble_pin 2025-03-19 18:21:35 +11:00
Scott Powell 3598836d19 * companion: added CMD_SET_DEVICE_PIN 2025-03-19 17:54:55 +11:00
Scott Powell debdfef299 * verify() fix moved to Identity class 2025-03-19 17:30:35 +11:00
Scott Powell d617e78558 * workaround for Identity::verify() bug. 2025-03-19 14:31:48 +11:00
Scott Powell 911fd2994a * experimental workaround for sig verify() bug 2025-03-19 13:54:43 +11:00
Scott Powell 331caffa98 * refactored platformio.ini, breaking up into variants/*.ini files 2025-03-18 23:57:04 +11:00
Scott Powell 797538bfae * TBeam: minor refactor. 2025-03-18 21:34:32 +11:00
ripplebiz ebfcf3abcc Merge pull request #100 from jameshall9327/main
Added Support for the LilyGo TBeam v1.1 and v1.2 with the SX1276
2025-03-18 21:29:38 +11:00
Scott Powell 9af1948674 * room server: now handles REQ_TYPE_GET_STATUS, replies with ServerStats (same as RepeaterStats, with extra fields: n_posted, n_post_push) 2025-03-18 16:49:40 +11:00
Scott Powell ad8c2e4a65 * companion: RESP_CODE_ERR now has err_code byte 2025-03-18 15:27:55 +11:00
ripplebiz b2c393ff58 Merge pull request #114 from lincomatic/pr-llcc68
Add ProMicroLLCC68 builds
2025-03-18 13:45:03 +11:00
Scott Powell 5b4ac86b06 * CMD_SEND_TRACE_PATH, now replies with RESP_CODE_SENT 2025-03-18 00:14:57 +11:00
Scott Powell cc9c9b4d57 * workaround for TRACE packets so they can follow a return path 2025-03-17 19:35:08 +11:00
Scott Powell c07dc51368 * companion support for TRACE packets. (CMD_SEND_TRACE_PATH, PUSH_CODE_TRACE_DATA) 2025-03-17 18:15:38 +11:00
Scott Powell 3aa7cf5652 * redesigned TRACE packet structure 2025-03-17 17:56:12 +11:00
taco d29ee95a49 match changes to other nrf52 boards, add pin definitions to platformio.ini 2025-03-17 13:51:26 +11:00
taco c20d3b7dda revert variant.h pins 2025-03-17 13:50:05 +11:00
taco 8825b74746 Merge branch 'faketec-testing' into dev 2025-03-17 13:15:54 +11:00
taco dc6a250133 move DISPLAY_CLASS definition 2025-03-17 13:09:26 +11:00
taco 356f0b762d define PIN_OLED_RESET -1 2025-03-17 13:09:02 +11:00
Scott Powell c7e1faca80 Merge branch 'dev' into trace
# Conflicts:
#	examples/companion_radio/main.cpp
2025-03-17 12:18:27 +11:00
taco 7c90cd3e38 tidy up 2025-03-17 12:17:36 +11:00
lincomatic 28fb5875b2 add ProMicroLLCC68 for Faketec w/ LLCC68 2025-03-16 17:48:52 -07:00
lincomatic a5ba20da35 fix compilation error 2025-03-16 16:49:55 -07:00
Scott Powell 6f79ddc025 * build fix 2025-03-16 22:11:27 +11:00
ripplebiz 34e16cb0d0 Merge pull request #111 from recrof/dev
added display support for RAK4631
2025-03-16 21:36:19 +11:00
recrof 304deff1c4 fixed: added back pin inits when SDA and SCL are set. 2025-03-16 10:17:04 +01:00
recrof 91405ac70a added display support for RAK4631, removed Wire.begin(int, int) from nrf52 devices, cosmetic changes 2025-03-16 09:07:21 +01:00
ripplebiz 35b13beb8e Merge pull request #107 from recrof/dev
heltec v2: added display, room server role
2025-03-16 19:04:38 +11:00
Rastislav Vysoky 9d46aa4307 Merge branch 'ripplebiz:dev' into dev 2025-03-16 07:11:53 +01:00
Scott Powell 968ccc47a3 * companion: SSD1306 display now dynamically detected at runtime. 2025-03-16 13:42:36 +11:00
taco 3c9a15fd14 OLED and button support, some refactoring. 2025-03-16 13:24:43 +11:00
James Hall 3c437fba6a Merge branch 'dev' into main 2025-03-15 15:10:17 -04:00
recrof 1f16b58822 heltec v2: added display, room server role 2025-03-15 20:10:07 +01:00
James Hall 787658dab7 Update TBeamBoard.h 2025-03-15 13:09:15 -04:00
James Hall 5b74d68a10 Merge branch 'ripplebiz:main' into main 2025-03-15 13:03:49 -04:00
ripplebiz 0edb67ae38 Merge pull request #105 from recrof/dev
added display support for t3s3
2025-03-15 23:44:09 +11:00
recrof a166613cc7 added display support for t3s3 2025-03-15 13:07:18 +01:00
Scott Powell 0e8fe7579b * CMD_SIGN_DATA null check 2025-03-15 22:06:57 +11:00
Scott Powell 0546edc51f * companion: can now sign arbitrary data (up to 8K) 2025-03-15 21:41:44 +11:00
Scott Powell a63a6ec6d4 Merge branch 'dev' into trace
# Conflicts:
#	examples/companion_radio/main.cpp
#	src/Dispatcher.cpp
2025-03-15 15:12:50 +11:00
Scott Powell 05e02babe6 * minor refactor for RAK_4631 SerialInterface 2025-03-15 14:55:52 +11:00
ripplebiz 46454ad7e3 Merge pull request #90 from oltaco/faketec-support
Faketec support
2025-03-15 14:47:18 +11:00
ripplebiz fd04cb818c Merge pull request #65 from awolden/awolden/h3-pin-fix
Fix heltec v3.2 pin polarity reversal
2025-03-15 12:09:47 +11:00
James Hall 935bc8a0de Cleaned up code 2025-03-14 19:54:46 -04:00
taco 7565014945 remove old unused board.json 2025-03-15 10:54:37 +11:00
James Hall 6d0d9b7d18 removed unnecessary defines 2025-03-14 14:27:10 -04:00
James Hall d247ec9c24 removed unnecessary constants 2025-03-14 14:22:13 -04:00
Scott Powell c00ee96d86 * some fixes around the powerOff(). Tidy ups 2025-03-14 19:08:41 +11:00
ripplebiz 54260688f0 Merge pull request #87 from fdlamotte/t1000e_ui
enhancement on the UI and support for power off and status_led
2025-03-14 18:52:00 +11:00
taco fc30e9eb2d MAX_GROUP_CHANNELS=8 for faketec 2025-03-14 15:24:58 +11:00
taco 21bec6c32b added conditional to room server radio bringup for supporting RA01sh radio on faketec 2025-03-14 15:22:42 +11:00
James Hall 8c7e4779a4 Delete .vscode/settings.json 2025-03-13 20:42:36 -04:00
James Hall 0e9ce66d2c removed pmu flag 2025-03-13 20:41:32 -04:00
James Hall 7a08f33604 Update settings.json 2025-03-13 20:35:44 -04:00
ripplebiz 7ffab96733 Merge pull request #94 from LitBomb/patch-5
Update faq.md for new EU and UK frequency, additional steps to setup repeater frequency
2025-03-14 11:29:34 +11:00
ripplebiz fef133124a Update README.md 2025-03-14 09:55:48 +11:00
James Hall c5dfb3d8c3 Added Support for the LilyGo TBeam v1.2 SX1276 2025-03-13 14:07:54 -04:00
fdlamotte b2c8b4dbc4 Merge branch 'ripplebiz:main' into t1000e_ui 2025-03-13 09:44:10 +01:00
taco bb05858bb6 added SX126X_RX_BOOSTED_GAIN=1 to faketec target 2025-03-13 17:46:58 +11:00
oltaco 84dbc284ad Merge branch 'ripplebiz:main' into faketec-support 2025-03-13 16:22:02 +11:00
Scott Powell c3a3309f5e * ver bump: 1.3.0 2025-03-13 13:46:01 +11:00
Scott Powell cc3c2ba958 * missing param 2025-03-13 13:32:46 +11:00
uncle lit 5ad461d033 Update faq.md
update UK and EU frequency to 869.525MHz per Andy and Recrof
add steps to set frequency on repeater after flash and before disconnecting USB cable
2025-03-12 10:45:07 -07:00
oltaco f01933f2c3 Merge branch 'ripplebiz:main' into faketec-support 2025-03-12 18:31:37 +11:00
fdlamotte c107a515d0 Merge branch 'ripplebiz:main' into t1000e_ui 2025-03-11 20:38:52 +01:00
Scott Powell 3dbe6bb11f Merge branch 'main' into dev 2025-03-11 20:09:59 +11:00
ripplebiz f94f63f5db Merge pull request #83 from fdlamotte/configure-cpu-frequency-at-build-time-for-esp32
Add an ESP32_CPU_FREQ build flag to lower freq
2025-03-11 20:06:28 +11:00
Florent de Lamotte 9bbe6626bc resolve conflict 2025-03-11 09:18:50 +01:00
Florent de Lamotte 9a8857b24e set cpu freq in ESP32Board.h 2025-03-11 09:11:14 +01:00
fdlamotte 47625da085 Merge branch 'ripplebiz:main' into configure-cpu-frequency-at-build-time-for-esp32 2025-03-11 09:01:45 +01:00
Scott Powell 60982b3821 * companion: channel names 2025-03-11 17:58:12 +11:00
taco 6db852f421 updated to MIT licensed board variant 2025-03-11 15:38:37 +11:00
Scott Powell c0379858b6 * companion: channels now persisted. RESP_CODE_DEVICE_INFO now includes MAX_CONTACTS (div 2) and MAX_GROUP_CHANNELS 2025-03-11 15:31:38 +11:00
Scott Powell 4863508e95 * Companion: new CMD_GET_CHANNEL, CMD_SET_CHANNEL 2025-03-11 14:50:40 +11:00
Scott Powell 6cb1be33d1 * BLE_NAME_PREFIX refactor 2025-03-11 13:25:48 +11:00
Scott Powell 8b586e1b66 Merge branch 'main' into dev 2025-03-11 13:20:52 +11:00
Scott Powell a38b0455f3 Merge branch 'main' into dev 2025-03-11 13:19:13 +11:00
ripplebiz f441697205 Merge pull request #74 from ddmunhoz/add-bool-meshcore-prefix
add: BLE_NAME_PREFIX flag
2025-03-11 13:02:54 +11:00
ripplebiz 31648b0fdb Merge pull request #85 from recrof/dev
Enabled sx1262 boosted RX gain for all supported radios + platformio.ini: Made quoted -D flags more readable
2025-03-11 12:54:44 +11:00
ripplebiz 782c4a5a69 Merge pull request #71 from fdlamotte/t1000e_txpower
tx_power can be raised to 22dBm on LR1110
2025-03-11 12:43:26 +11:00
ripplebiz e71237258c Merge pull request #88 from LitBomb/patch-4
Update faq.md
2025-03-11 12:40:30 +11:00
taco eebc4753c3 added conditional to radio bringup for RA01-SH support on faketec 2025-03-11 09:34:52 +11:00
taco 533f87e93b build fix to support RTC detection code 2025-03-11 09:34:52 +11:00
taco 319218b7ba Added logic to companion_radio firmware to hopefully fix the radio bringup for Faketec with RA01-SH. 2025-03-11 09:34:52 +11:00
taco 7fa0677fd3 Added defines for SX126X_RXEN, SX126X_TXEN.
Updated build target to enable privkey import/export.
2025-03-11 09:34:52 +11:00
taco aada976237 Faketec board support, including build targets 2025-03-11 09:34:52 +11:00
Florent d41b535ba8 better handling of BTN_USER_PRESSED definition 2025-03-10 22:42:52 +01:00
uncle lit 340d618258 Update faq.md
update Canada to use USA frequency
add guide to add nodes to map
add guide to do OTA firmware update for nRF devices
update donation links
general text cleanup
2025-03-10 11:52:39 -07:00
Florent de Lamotte afd52de03d enhancement on the UI and support for power off and status_led for t1000e 2025-03-10 18:11:15 +01:00
Scott Powell a88a3401c4 * repeater & room server: new CLI config "flood.max" 2025-03-10 23:28:19 +11:00
recrof 8f0fea86ca Merge branch 'dev' of github.com:recrof/MeshCore into dev 2025-03-09 23:07:36 +01:00
recrof 5e71294069 - Enabled sx1262 boosted RX gain for all supported radios
- Made quoted -D flags more readable
2025-03-09 22:57:31 +01:00
Florent 7e34f95f43 Add an ESP32_CPU_FREQ build flag to lower freq 2025-03-09 15:49:35 +01:00
ripplebiz 8a964b4bcb Merge pull request #81 from recrof/dev
roles: t-echo, t114: +room_server; WSL3: +room_server, +repeater
2025-03-10 00:22:33 +11:00
Scott Powell c5011e8b74 ver bump to 1.2.2 2025-03-09 23:46:03 +11:00
Scott Powell 2a8d42791f updating RadioLib to ver 7.1.2 2025-03-09 23:44:34 +11:00
Scott Powell 2df1820424 * trying setCRC(1) 2025-03-09 22:15:58 +11:00
Scott Powell 31aca85109 * repeater and room server: MESH_PACKET_LOGGING, now dumps RAW: rx packet contents
* Dispatcher: MESH_PACKET_LOGGING,  added " hash={packet-hash}"
2025-03-09 20:36:49 +11:00
Rastislav Vysoky aabd6ef396 Merge branch 'ripplebiz:dev' into dev 2025-03-09 07:16:50 +01:00
Scott Powell 82b53fb64d * PUSH_CODE_LOG_RX_DATA: is now just: {snr*4},{rssi},{raw-lora-packet} 2025-03-09 17:04:22 +11:00
Scott Powell 5b384a0122 * companion: added new PUSH_CODE_LOG_RX_DATA (0x88) for inspecting all received packets 2025-03-09 15:41:32 +11:00
Scott Powell bc4f4d0e66 Merge branch 'main' into dev
# Conflicts:
#	platformio.ini
2025-03-09 14:56:39 +11:00
ripplebiz ae2e9d9724 Merge pull request #78 from awolden/awolden/enable-SSD13060-lilygo-tlora
Enable SSD1306 display class for LilyGo_TLora_V2_1_1_6
2025-03-09 14:43:54 +11:00
Alex Wolden c32c4c0107 Fix heltec v3.2 pin polarity reversal 2025-03-08 11:21:19 -08:00
Scott Powell f7523c0eb3 * T1000e battery measure fix 2025-03-08 20:18:15 +11:00
Rastislav Vysoky b215e46196 Merge branch 'ripplebiz:dev' into dev 2025-03-08 10:05:27 +01:00
Scott Powell d8391a90ea * new build option: SX126X_RX_BOOSTED_GAIN 2025-03-08 19:59:07 +11:00
Scott Powell b6f9bd6a76 * Dispatcher: added guard for packet payload size too large 2025-03-08 19:38:36 +11:00
Rastislav Vysoky ad7289c88a added room server roles to t114 and t-echo; added repeater and room server roles to WSL3; unified json intendations in /boards 2025-03-08 09:15:51 +01:00
ripplebiz c09157c407 Merge pull request #70 from recrof/dev
added new board: Station G2; fix: added t114 and t-echo boards to uf2conv release workflow
2025-03-08 15:10:49 +11:00
Scott Powell 211fa85c19 * doc updates 2025-03-08 13:40:39 +11:00
Alex Wolden f38c17e98e Enable SSD1306 display class for LilyGo_TLora_V2_1_1_6 2025-03-07 14:30:11 -08:00
Diego Munhoz 09cb6935aa add: BLE_NAME_PREFIX flag 2025-03-07 11:41:53 -06:00
Rastislav Vysoky 89f068e662 Added basic support for Station G2 2025-03-07 15:34:00 +01:00
Florent de Lamotte 83e50fc5aa tx_power can be raised to 22dBm on LR1110 2025-03-07 13:52:47 +01:00
Rastislav Vysoky c108b842a0 Merge branch 'ripplebiz:dev' into dev 2025-03-07 13:42:56 +01:00
Rastislav Vysoky 8d7694383d fix: added t114 and t-echo boards to uf2conv release workflow 2025-03-07 13:17:46 +01:00
Scott Powell 39f286bdab Version bump to v1.2.1 2025-03-07 22:01:30 +11:00
Scott Powell e643722ef3 * Heltec v3.2 VEXT fix
* Heltec T114 LED fix, (now flashes with LoRa TX)
2025-03-07 21:37:05 +11:00
Scott Powell 04cc772a4f * display.begin() delayed in setup().
* all firmwares now bumped to v1.2.0
2025-03-07 17:19:27 +11:00
Scott Powell a1e89e524f * companion: better incoming ACK processing (match prev attempts) 2025-03-07 15:09:29 +11:00
Scott Powell c1f51e8996 * companion: FIRMWARE_VER_CODE now bumped to 3.
* companion: new RESP_CODE_CONTACT_MSG_RECV_V3, and _CHANNEL_MSG_RECV_V3. (now with packet SNR included)
2025-03-07 14:17:37 +11:00
Scott Powell ddded8a3e6 * refactor Packet::_snr to single byte 2025-03-07 12:32:23 +11:00
Scott Powell c762c4440d * TRACE packet logging fix 2025-03-07 12:24:18 +11:00
Scott Powell 8379a785cc Merge branch 'dev' into trace
# Conflicts:
#	src/Dispatcher.cpp
#	src/Mesh.cpp
#	src/helpers/BaseChatMesh.cpp
2025-03-07 12:14:26 +11:00
Scott Powell 4af80aa1d6 * companion: new command: CMD_GET_CONTACT_BY_KEY (30) 2025-03-07 12:00:11 +11:00
ripplebiz 21537d0085 Merge pull request #68 from recrof/dev
Added basic support for Heltec t114, LilyGo T-Echo
2025-03-07 10:22:34 +11:00
Rastislav Vysoky 0bc42c62a6 moved nrf sdk headers to ./lib/ and added Repeater envs for t114 & t-echo 2025-03-07 00:16:22 +01:00
Rastislav Vysoky dd0fe675a7 Added support for LilyGo T-Echo 2025-03-06 21:39:17 +01:00
Rastislav Vysoky ffb0ba36d9 fix: T114 reset pin value 2025-03-06 21:37:24 +01:00
Rastislav Vysoky 5a685bc829 Added support for Heltec t114 2025-03-06 20:43:56 +01:00
Scott Powell 4154632d63 * room server: version bump to v1.1.0. This is now NOT compatible with previous clients (TDeck and companion radio). 2025-03-06 18:36:43 +11:00
Scott Powell f4740815db * Room Server post ACK bug fix! 2025-03-06 18:16:48 +11:00
ripplebiz 89dde05929 Merge pull request #62 from awolden/awolden/t3lora
Add LILYGO T-LoRa V2.1-1.6 firmware
2025-03-06 16:33:27 +11:00
Alex Wolden 27ff6349dc Revert identity change 2025-03-05 19:38:08 -08:00
Scott Powell 4da58a8141 * .yml files, permissions: write 2025-03-05 19:48:52 +11:00
Scott Powell bbdf3eb2b9 * now suppressing 'cp' errors 2025-03-05 19:20:28 +11:00
Scott Powell f32a8093d4 * companion, HeltecV3: now picks random BLE pin for every session (from boot), unless a (non-zero) one stored in _prefs
* companion, WSL3: uses static BLE pin, per build BLE_PIN_CODE define
2025-03-05 19:14:34 +11:00
Alex Wolden 8d09e0f5c0 Merge remote-tracking branch 'origin/dev' into awolden/t3lora 2025-03-04 23:23:03 -08:00
Alex Wolden 22b3d7c435 Refactor naming 2025-03-04 22:00:48 -08:00
Scott Powell cb2211e1ca * repeater and room server: CommonCLI now handles load/save of Prefs. Now sanitise bad prefs values. 2025-03-05 16:39:45 +11:00
Scott Powell 2719e5195a * companion: UITask now shows BLE PIN (when no connection)
* companion, HeltecV3: new installs, now chooses random BLE PIN
* companion: prefs load/save improvements (sanitises bad values)
2025-03-05 15:47:29 +11:00
Alex Wolden 300844e4d4 add libsodium 2025-03-04 20:04:19 -08:00
Scott Powell ea6f0bfaa5 * basic UITask added to repeater and room server (only HeltecV3 targets enable so far) 2025-03-05 12:52:29 +11:00
Alex Wolden 7f8a529297 fix memory 2025-03-04 12:13:45 -08:00
Alex Wolden 652b70a36e readded 1262 radio 2025-03-04 09:03:36 -08:00
Scott Powell 6bc5946661 * new ui/DisplayDriver classes (just SSD1306Display impl for now)
* companion radio: now with optional UITask (enabled by DISPLAY_CLASS config in target/env)
2025-03-04 23:09:43 +11:00
Alex Wolden 9c2da990d2 Remove duplicate entries from platformio.ini
- Remove unnecessary T3S3 configurations
- Keep only the LilyGo T3 with SX1276 configurations
- Clean up the platformio.ini file to remove duplication
2025-03-04 00:16:35 -08:00
Alex Wolden 30e0047809 Add support for LilyGo T3 with SX1276 module
- Add custom partition table for fitting larger firmware
- Create LilyGoT3S3Board.h for board-specific functionality
- Update all example files to support the T3 board with SX1276
- Configure build environment for optimizing firmware size
- Set up the right pin configuration for SX1276 on LilyGo T3
2025-03-04 00:07:36 -08:00
Scott Powell 103fb04a7d * 'last_snr' added to repeater stats. 2025-03-04 18:29:16 +11:00
Scott Powell aa00004949 Merge branch 'main' into dev 2025-03-04 16:41:31 +11:00
Scott Powell bcb78e2c19 * build script change, for companion radio targets 2025-03-04 14:06:03 +11:00
Scott Powell 11179b6808 * SerialWifiInterface: misc tidy-ups 2025-03-04 14:04:47 +11:00
ripplebiz c47c33e07b Merge pull request #61 from fdlamotte/wifi-support
new Heltec_v3_companion_radio_wifi target
2025-03-04 13:54:23 +11:00
Florent de Lamotte 4aa925eada new Heltec_v3_companion_radio_wifi target 2025-03-03 13:26:37 +01:00
Scott Powell dba81f5b0c * misc 2025-03-03 19:51:45 +11:00
ripplebiz 75a8c8a7d9 Merge pull request #60 from liamcottle/feature/build-automation
Automated Firmware Builds and Releases
2025-03-03 19:51:07 +11:00
liamcottle 945553157c also build uf2 for t1000e 2025-03-03 21:13:55 +13:00
liamcottle 1ac71296d7 merge bins for esp32 boards 2025-03-03 18:51:27 +13:00
liamcottle ab0b2e3781 add release docs 2025-03-03 18:08:00 +13:00
liamcottle a4464b608d setup automated firmware builds with github actions 2025-03-03 17:58:15 +13:00
Scott Powell db5b44e546 * room server: adding post, was not sending Acks on retries.
* room server and repeater: now does NOT send Acks for TXT_TYPE_CLI_DATA commands
2025-03-03 15:30:50 +11:00
Scott Powell 5e463f6474 Merge branch 'dev' 2025-03-03 13:26:43 +11:00
Scott Powell e5b701a97b * Semantic versioning in repeater, room server. "ver" CLI command changed. 2025-03-03 13:22:49 +11:00
Scott Powell d26a201819 * HOTIFX: HeltecV3, SDA/SCL pin defines 2025-03-03 12:52:39 +11:00
Scott Powell fd882cbfd9 * companion: RESP_CODE_DEVICE_INFO format change. 2025-03-03 12:31:11 +11:00
ripplebiz e07ca873dc Merge pull request #58 from LitBomb/patch-1
Update faq.md
2025-03-03 11:55:56 +11:00
uncle lit 4d1b9e3893 Update faq.md
Add:
- definitions for BW, SF, CR
- Liam's meshcore web client and meshcore js
- what is 'import form clipboard' feature on t-deck

Update:
- Repeater and room server explanations
- phone client apps now support repeater and room server management over RF
2025-03-02 16:07:36 -08:00
Scott Powell 7f543df20c * new docs folder, FAQ added 2025-03-03 10:11:43 +11:00
Scott Powell 48ca4ab772 * companion radio: connection status now supported (Keep_alive pings, etc) 2025-03-02 20:15:13 +11:00
Scott Powell 19ad023fc5 * room server: login response, permission byte now returned 2025-03-02 14:19:19 +11:00
Scott Powell ee1fd75150 * companion radio: support for TXT_TYPE_SIGNED_PLAIN 2025-03-02 13:57:50 +11:00
Scott Powell bac3f1456e * prefs guard word added 2025-02-28 13:06:26 +11:00
Scott Powell 1058b5bca6 * misc 2025-02-28 12:50:14 +11:00
Scott Powell dfbc10f4ed * "set radio.." now with "OK" response 2025-02-28 12:49:36 +11:00
Scott Powell 9b887361d8 * CLI: get/set radio added 2025-02-28 12:24:45 +11:00
Scott Powell 7c063806d9 * repeater, room server: new prefs: sf, cr, bw. "set tx ..." now instant, no reboot needed. 2025-02-28 11:48:46 +11:00
ripplebiz 11ec8c535f Merge pull request #52 from liamcottle/board/t1000e
Add nRF52 S140 SoftDevice Header Files
2025-02-27 19:24:53 +11:00
Scott Powell a531537984 * CommonCLI: "get " commands 2025-02-27 18:02:47 +11:00
Scott Powell 3df3aac8ab * refactored handleCommand() to CommonCLI class 2025-02-27 17:00:44 +11:00
Scott Powell aab1326516 * various changes for CLI support via companion radio 2025-02-27 12:51:00 +11:00
Scott Powell 7c1c273255 * new Dispatcher::getCADFailRetryDelay() 2025-02-27 04:05:50 +11:00
liamcottle d39710160a add nrf52 s140 softdevice header files for compiling t1000e firmware 2025-02-27 02:35:12 +13:00
Scott Powell fcb213bf4d * ESP32: SerialBLEInterface, delay(500) not needed 2025-02-26 21:08:54 +11:00
Scott Powell 0d33e2e70a * esp32 SerialBLEInterface: 1 second delay now applied before testing whether to re-start advertising 2025-02-26 20:53:31 +11:00
ripplebiz 1d8057e232 Merge pull request #49 from liamcottle/main
Fix double pairing prompt for ESP32
2025-02-26 18:35:45 +11:00
liamcottle f072eb32b5 don't set encryption level on device as it's set on each characteristic 2025-02-26 20:24:14 +13:00
Scott Powell 6018775741 * build fixes for RAK targets 2025-02-26 18:19:38 +11:00
ripplebiz eb8089616b Merge pull request #47 from fdlamotte/t1000e_work
T1000e in tree ;)
2025-02-26 18:04:22 +11:00
ripplebiz 13b1d8c274 Merge pull request #48 from liamcottle/main
Fix BLE Pin for ESP32 and nRF52
2025-02-26 17:41:11 +11:00
liamcottle e232b1ce12 enforce pin being used for ble pairing on nrf52 2025-02-26 17:27:58 +13:00
liamcottle e6ca98f91e enforce pin being used for ble pairing on esp32 2025-02-26 17:04:44 +13:00
Florent de Lamotte f841d27d4d t1000e companion radio example builds in tree ! 2025-02-25 16:46:06 +01:00
Florent de Lamotte 6d38a1b502 upd t1000e board support 2025-02-25 14:02:19 +01:00
Scott Powell 9bb9e989fa * new helper: AutoDiscoverRTCClock, which detects: DS3231 (on i2c addr 0x68), or RV3028 (on i2c addr 0x52)
* repeater and room server: ver bump (v5), now use AutoDiscoverRTCClock
* various Board::begin() now should do Wire.begin(), with custom pin mappings if needed
* examples removed: ping client/server, and test_admin
2025-02-25 19:00:07 +11:00
Scott Powell b4b9705c7d * repeater and room server: login password now using strcmp(), new 'set direct.txdelay ..' config 2025-02-24 20:52:13 +11:00
Scott Powell 91bce664a5 * repeater: login now evicts oldest client table entry if full. New RESP_SERVER_LOGIN_OK login response format (with permissions byte)
* companion radio: PUSH_CODE_LOGIN_SUCCESS now returns 'permissions' byte (0 for legacy "OK" response)
2025-02-24 16:01:14 +11:00
Scott Powell 91d04dfdf1 * companion radio: new CMD_SEND_LOGIN, CMD_SEND_STATUS_REQ 2025-02-24 14:05:17 +11:00
Scott Powell 509964427a * new PAYLOAD_TYPE_RAW_CUSTOM 2025-02-23 15:35:33 +11:00
Scott Powell a896b9c5f7 * new StrHelper::strzcpy() 2025-02-22 20:10:31 +11:00
Scott Powell 395b026e6c * strncpy() refactor/fix 2025-02-22 19:41:24 +11:00
Scott Powell 4bf16344cd * added S3 WIO target for BLE companion radio 2025-02-22 10:44:45 +11:00
Scott Powell a8f2551c78 * tidy ups of PRIVATE_KEY_IMPORT/_EXPORT stuff 2025-02-21 13:51:26 +11:00
ripplebiz 2c7af7a643 Merge pull request #32 from liamcottle/main
add new commands to companion firmware to import and export identity
2025-02-21 13:29:39 +11:00
liamcottle 4027bef7b9 add build flags to enable and disable private key import and export 2025-02-21 14:54:59 +13:00
liamcottle 5cd282b15b add new commands to companion firmware to import and export identity private key 2025-02-21 12:34:15 +13:00
Scott Powell fa13ef1969 * room server: minor timing fix 2025-02-20 22:59:47 +11:00
Scott Powell 6af88ed02f * MESH_DEBUG_PRINTLN fixes 2025-02-20 18:04:35 +11:00
Scott Powell 159c4ce8c2 * Mesh/Dispatcher: MESH_DEBUG_ and MESH_PACKET_LOGGING now output date-time. (new getLogDateTime() virtual)
* MESH_PACKET_LOGGING now parity with dynamic/file logging (src/dest hashes)
2025-02-20 12:41:47 +11:00
Scott Powell c468459061 * companion radio: new CMD_DEVICE_QUERY -> RESP_CODE_DEVICE_INFO, airtime_factor added to CMD_SET_TUNING_PARAMS, CMD_REBOOT change 2025-02-19 18:59:43 +11:00
ripplebiz 706bc0cf48 Merge pull request #23 from fdlamotte/t1000e_code
T1000e code
2025-02-19 17:49:36 +11:00
Scott Powell e32003f8a3 * added RTCClock::getCurrentTimeUnique(), for when timestamps need to be unique (if temp rapid-fire) 2025-02-19 17:24:25 +11:00
Scott Powell 73c4ae748e * repeater: added src/dest hashes to logging 2025-02-18 23:49:25 +11:00
Scott Powell 01e8096e66 * SimpleMeshTables: ACKs now handled separately
* Dispatcher: logging methods now with 'len' param
2025-02-18 22:59:03 +11:00
Scott Powell 88ac6b6ee8 * repeater: Get Stats new fields added: n_direct_dups, n_flood_dups 2025-02-18 17:47:00 +11:00
Scott Powell 4cccaf6d47 * repeater: new CLI commands: "log start", "log stop", "log erase", and "log" 2025-02-18 13:20:48 +11:00
Scott Powell bea3ccb116 * new Packet type: PAYLOAD_TYPE_TRACE 2025-02-17 19:22:31 +11:00
Scott Powell ce20ec8f13 * repeater, room server and terminal chat: default to rxdelay off 2025-02-17 10:56:41 +11:00
Scott Powell 18b4e60bb0 * companion radio: "set af .." now applied, rxdelay now OFF by default. (can set though with new CMD_SET_TUNING_PARAMS) 2025-02-17 10:43:48 +11:00
ripplebiz f01daa2f78 Merge pull request #27 from liamcottle/main
added CMD_GET_BATTERY_VOLTAGE to companion radio
2025-02-16 14:56:54 +11:00
liamcottle 4a6f669aa3 added CMD_GET_BATTERY_VOLTAGE to companion radio 2025-02-16 16:51:10 +13:00
ripplebiz 5685bbd272 Merge pull request #26 from liamcottle/main
added CMD_REBOOT to companion radio
2025-02-16 13:50:34 +11:00
liamcottle 62703330ac added CMD_REBOOT to companion radio 2025-02-16 15:24:46 +13:00
Scott Powell e01ee62c72 * companion radio: new CMD_EXPORT_CONTACT, CMD_IMPORT_CONTACT 2025-02-15 15:57:02 +11:00
Scott Powell edf52ad4f3 * companion radio: new CMD_SHARE_CONTACT
* room server: push notify loop interval changed to 2 secs
2025-02-15 13:23:19 +11:00
Florent 9083d4db9b helper files for t1000e and LR1110 2025-02-14 09:54:06 +01:00
Florent 04553004af add T1000e conditionals to examples 2025-02-14 07:17:46 +01:00
Scott Powell 2081030449 * companion radio: BLE variants now set device name to "MeshCore-{advert-name}" 2025-02-14 10:46:40 +11:00
Scott Powell a06f5a8407 * ver bumps
* companion radio, USB: onSendTimeout() bug fix
2025-02-14 09:35:15 +11:00
Scott Powell 4048d1bd90 * BaseChatMesh: sendLogin(), onContactResponse()
* companion radio: contacts file, new 'sync_since' field
2025-02-14 07:52:43 +11:00
Scott Powell d350a7c341 * nrf52 BLE, increased MTU to 250 2025-02-13 20:22:56 +11:00
ripplebiz b9579718fa Merge pull request #20 from fdlamotte/nrf52_serial_ble
nrf52 ble uart should work with this ;)
2025-02-13 19:47:37 +11:00
Scott Powell bf8b9a61b9 * BaseChatMesh::sendGroupMessage() added
* companion radio, RESP_CODE_CHANNEL_MSG_RECV, CMD_SEND_CHANNEL_TXT_MSG
2025-02-13 10:18:48 +11:00
Florent de36c12362 nrf52 ble uart should work 2025-02-12 17:44:06 +01:00
Scott Powell fc075ecaa5 * companion radio for RAK (USB) now fixed. (thanks to Bernd Giesecke)
* experimental NRF52 impl of SerialBLEInterface, and experimental RAK BLE companion radio target
2025-02-12 18:40:00 +11:00
Scott Powell 2532210cdf * companion radio: _SELF_INFO frames now include current adv_lat, and adv_lon 2025-02-11 16:02:35 +11:00
Scott Powell 0ff94be3b3 * new target/envs: Heltec_v2_repeater, Heltec_v2_companion_radio_usb 2025-02-11 15:50:10 +11:00
Scott Powell fe9fa4766a * new target/env: Heltec_v2_terminal_chat 2025-02-11 12:36:26 +11:00
Scott Powell a2a8747be8 * companion radio: new command frames: CMD_SET_ADVERT_LATLON, CMD_REMOVE_CONTACT 2025-02-11 12:02:27 +11:00
Scott Powell 1762662419 Merge branch 'main' into rx_delay
# Conflicts:
#	examples/simple_repeater/main.cpp
#	examples/simple_room_server/main.cpp
2025-02-10 20:13:09 +11:00
Scott Powell 36a00175f4 * new "set guest.password .." CLI command 2025-02-10 16:36:14 +11:00
Scott Powell 8a952334e4 Merge branch 'main' into rx_delay 2025-02-10 11:08:42 +11:00
ripplebiz 2b71e9b3c2 Merge pull request #17 from Garrisonsan/patch-1
Update README.md regarding building for RAK devices
2025-02-10 11:06:23 +11:00
Garrisonsan bd42947f8b Update README.md
Added small section under RAK compatibility for info on how to convert hex to uf2, with link to Microsoft GitHub uf2conv python script. Cleaned up how links display in that section.
2025-02-09 16:24:04 -06:00
Scott Powell afd6889557 Merge branch 'main' into rx_delay
# Conflicts:
#	examples/companion_radio/main.cpp
#	examples/simple_secure_chat/main.cpp
2025-02-09 13:06:01 +11:00
Scott Powell 79399eb766 * companion radio: removed need for reboot after setting radio params or tx power 2025-02-09 09:58:56 +11:00
Scott Powell 5d62c1c247 * TIMEOUT estimate adjusted
* companion radio: new CMD_RESET_PATH
2025-02-08 20:57:35 +11:00
Scott Powell 759e50bd5d * repeater: min/max advert.interval changes 2025-02-08 19:57:10 +11:00
Scott Powell f5cd4333fd Merge branch 'main' into rx_delay
# Conflicts:
#	examples/simple_repeater/main.cpp
#	examples/simple_room_server/main.cpp
2025-02-08 12:04:17 +11:00
Scott Powell e05aa5da67 * repeater and room server: new CLI command: "set advert.interval {mins}" 2025-02-08 11:44:09 +11:00
Scott Powell 5a762aa511 Merge branch 'main' into rx_delay 2025-02-06 22:57:07 +11:00
Scott Powell 9699cf3ae4 * companion radio: new RESP_CODE_NO_MORE_MESSAGES response 2025-02-06 22:39:33 +11:00
Scott Powell e140649e4d * bug fix for rxdelay 0 2025-02-06 11:16:17 +11:00
Scott Powell aff21068b0 Merge branch 'main' into rx_delay 2025-02-06 10:54:52 +11:00
Scott Powell ff014ccf06 * RAK battery ADC multiplier tweak 2025-02-06 08:44:06 +11:00
Scott Powell 8b298d7c76 * companion radio: CMD_SET_RADIO_PARAMS fix 2025-02-05 22:04:25 +11:00
Scott Powell 9bc8494bf8 * new CLI command: "set txdelay ..." 2025-02-05 12:36:32 +11:00
Scott Powell af33db165f Merge branch 'main' into rx_delay 2025-02-05 12:09:27 +11:00
Scott Powell 523336b059 * companion radio: CMD_GET_DEVICE_TIME now responds with RESP_CODE_CURR_TIME(9) instead of RESP_CODE_OK 2025-02-05 11:13:39 +11:00
Scott Powell 73c4664a68 * companion radio bug fix 2025-02-05 10:42:40 +11:00
Scott Powell e83022c3fb * added companion radio targets for T3S3 board 2025-02-04 22:09:46 +11:00
Scott Powell d0f7e351aa Merge branch 'main' into rx_delay
# Conflicts:
#	examples/simple_repeater/main.cpp
#	examples/simple_room_server/main.cpp
2025-02-04 20:53:27 +11:00
Scott Powell f609f45fa1 * companion radio: offline messages queue 2025-02-04 19:40:30 +11:00
Scott Powell 2603c5272f * repeater and room server, new "set repeat {on|off}" CLI command 2025-02-04 18:27:13 +11:00
Scott Powell f10cdb0a3d Merge branch 'main' into rx_delay 2025-02-04 16:03:32 +11:00
Scott Powell 91ef5bbfa8 * Room server: added "start ota" CLI command 2025-02-04 16:03:17 +11:00
Scott Powell 04716c817c * new "set rxdelay ..." CLI command 2025-02-04 15:35:36 +11:00
Scott Powell c7a06d4f86 * new packet score function 2025-02-04 15:00:28 +11:00
Scott Powell 547cb0f734 * ver bumps
* RAK battery experiment
2025-02-04 13:40:54 +11:00
Scott Powell 63381dac25 * new RX delays based on SNR 2025-02-04 12:35:53 +11:00
Scott Powell 1369a3c127 * IdentityStore::save() was failing on RAK.
* Repeater: CLI 'erase' command added.
2025-02-04 01:35:04 +11:00
Scott Powell 6f087fb2b8 * companion radio: new CMD_SET_RADIO_TX_POWER frame, RESP_CODE_SELF_INFO responses now include tx_power_dbm and MAX_LORA_TX_POWER 2025-02-03 21:06:08 +11:00
Scott Powell d4eba69a74 * 'help' updated. 2025-02-03 14:21:19 +11:00
Scott Powell e25fb26ef3 * Terminal Chat: "set ..." commands, save to "node_prefs" file, consistent with the other firmwares 2025-02-03 13:56:57 +11:00
Scott Powell 12012a517f * refactor: new helpers/nrf52 dir
* RAK, startOTAUpdate()
2025-02-03 12:53:38 +11:00
Scott Powell db9f6d7ba0 * BUG FIX: Initial key generation 2025-02-02 11:03:23 +11:00
Scott Powell c2025820f2 * RAK batt read (hopefully) fixed 2025-02-02 09:44:59 +11:00
Scott Powell 60f0ff4642 * repeater and room server: added "set tx .." CLI command 2025-02-02 08:45:18 +11:00
Scott Powell 3a2eccbba1 * releasePacket() missing 2025-02-01 23:10:56 +11:00
Scott Powell 4a601f8241 * Terminal Chat: new commands "card" and "import" 2025-02-01 21:45:34 +11:00
Scott Powell 2cb55d3936 * Repeater: timing changes for self-advert 2025-02-01 19:06:39 +11:00
Scott Powell 0a6a8c40a7 * companion radio: RESP_CODE_END_OF_CONTACTS change 2025-02-01 17:04:26 +11:00
Scott Powell 59fc55208b * readme tweak 2025-02-01 14:31:19 +11:00
Scott Powell 08ef5f804c * companion radio CMD_SET_RADIO_PARAMS 2025-02-01 12:43:06 +11:00
Scott Powell 78e4f86b2a * added LLCC68 module support 2025-01-31 12:46:33 +11:00
Scott Powell 5a5efcbbfb * oops, default LORA_FREQ revert 2025-01-31 11:51:30 +11:00
Scott Powell 70279933fd * new target/envs: LilyGo_T3S3_sx1262, _repeater and _terminal_chat 2025-01-31 11:46:19 +11:00
Scott Powell 8044d92c40 * ver bump 2025-01-31 00:47:26 +11:00
Scott Powell 0177d4dbd4 * Room server: keep_alive changes 2025-01-31 00:02:29 +11:00
Scott Powell 55f7ed31f1 * Room server: no more "[posted]" replies from server 2025-01-30 20:09:00 +11:00
Scott Powell 959196de99 * new Packet::writeTo(), readFrom() methods. (for saving snapshots of packets) 2025-01-30 18:34:18 +11:00
ripplebiz 7ffaf710b5 Update README.md 2025-01-30 15:10:05 +11:00
Scott Powell 9af5adb861 * BaseChatMesh::sendMessage(), new est_timeout (OUT) param 2025-01-30 14:03:31 +11:00
Scott Powell f94d5f7423 * ver bumps 2025-01-30 13:46:04 +11:00
Scott Powell 659e66e3d1 * reset push_failures on successfully recv 2025-01-29 20:45:55 +11:00
Scott Powell 77a7656b99 * companion_radio: CMD_SEND_TXT_MSG format change 2025-01-29 14:06:46 +11:00
Scott Powell f46263a263 * ContactInfo, added gps_lat, gps_lon
* companion_radio: now also save gps_lat, gps_lon
* BaseChatMesh: now parses gps_lat, gps_lon out of Advertisement
2025-01-29 13:56:39 +11:00
Scott Powell 2e3d2d13b2 * room_server: login response now with a 'keep alive' interval suggestion
* room_server: new Request payload sub-type: REQ_TYPE_KEEP_ALIVE -> RESP_SERVER_KEEP_ALIVE
2025-01-29 13:14:42 +11:00
Scott Powell 4f0acbd8da * companion_radio_usb: encoding in ArduinoSerialInterface changed to 16-bit frame lengths
* MAX_FRAME_SIZE now 172 (to fit max 160 byte text msg)
2025-01-29 10:12:22 +11:00
Scott Powell e53f0d0725 * refactored BaseChatMesh::sendMessage(), added timestamp param 2025-01-29 02:11:46 +11:00
Scott Powell fe306a311e * new "contacts2" file format 2025-01-29 00:51:52 +11:00
Scott Powell dc11fe85cb * new env: RAK_4631_companion_radio_usb 2025-01-29 00:02:05 +11:00
Scott Powell cd81878e92 * added helpers/ArduinoSerialInterface, for the 'companion radio'
* .ini, target envs: Heltec_v3_companion_radio_usb &  Heltec_v3_companion_radio_ble
2025-01-28 23:26:55 +11:00
Scott Powell d9dc76f197 * new helper for ESP32: SerialBLEInterface
* Some refactoring in BaseChatMesh and Terminal Chat
* new companion_radio example
2025-01-28 20:30:15 +11:00
Scott Powell 52f9c358b7 * repeater: extra CLI commands
* room server: now loads/saves prefs, same CLI commands as repeater ("set ...")
2025-01-28 00:00:14 +11:00
Scott Powell 6fc21b815d * HeltecV3 targets, now flash built-in LED on LoRa TX 2025-01-27 12:53:34 +11:00
Scott Powell 37a6c230ad * new repeater CLI commands: "set af", "set name", "set lat", "set lon", "password" 2025-01-27 11:13:37 +11:00
Scott Powell 9a9b4fca82 * version bumps 2025-01-27 00:42:42 +11:00
Scott Powell 6c00653272 * TxtDataHelpers.h, with standard TXT sub-types
* Terminal chat: added "time <epoch-secs>"
* repeater: now recognises either TXT_TYPE_PLAIN or TXT_TYPE_CLI_DATA for CLI commands
* Room server: now uses TXT_TYPE_SIGNED_PLAIN (for push/outbound), recognises TXT_TYPE_PLAIN (to add a Post), and TXT_TYPE_CLI_DATA for CLI command
2025-01-26 22:56:38 +11:00
Scott Powell 40c3dfa20b * fixes for various targets (BaseChatMesh not compiling for non-terminal chat targets) 2025-01-26 15:40:32 +11:00
Scott Powell a3ce65c770 * new env: Xiao_S3_WIO_terminal_chat 2025-01-26 14:48:17 +11:00
Scott Powell 42af720b02 * fix for RAK terminal chat 2025-01-26 07:00:56 +11:00
Scott Powell 6d5e69ae04 * support for GroupChannels in BaseChatMesh, and terminal chat 2025-01-26 00:46:36 +11:00
Scott Powell e58d866949 * merge-bin.py script 2025-01-25 23:09:09 +11:00
Scott Powell 00a9e93754 * simple_secure_chat now with a proper CLI
* new: BaseChatMesh class, for abstract chat client
2025-01-25 22:03:25 +11:00
Scott Powell a3b7701bc0 * added 'ver' command to CLI (repeater and room server) 2025-01-24 22:00:13 +11:00
Scott Powell e78aa66d57 * Bug fix: hasName(), missing return :-(
* refactored methods to AdvertDataHelper.cpp
2025-01-24 19:45:45 +11:00
Scott Powell 068aeee87f * Refactor: new AdvertDataHelpers.h 2025-01-24 11:41:37 +11:00
Scott Powell 2d34ac58ee * room_server: crash fix, now detects timeouts on push post, if 3 timeouts on same client, then evicts/logs out 2025-01-23 21:24:23 +11:00
Scott Powell b8a5c3369f * NEW: simple_room_server 2025-01-23 16:07:44 +11:00
Scott Powell f5f978a398 * CAD detect fixed 2025-01-22 21:48:18 +11:00
Scott Powell 932d845922 * fix for duplicate msgId's in repeater CLI view 2025-01-22 20:53:43 +11:00
Scott Powell d69d2be722 * repeater: some refactors/clean ups, and (for ESP32) now using ESP32RTCClock which can keep time across a "reboot" command. 2025-01-22 19:47:53 +11:00
Scott Powell 22e87836db * Mesh.cpp: optimisation to not retransmit packets handled by this node
* simple_repeater: now supports a remote CLI
2025-01-22 12:11:43 +11:00
Scott Powell 6d10fab4f3 * commenting out CAD detect, for now 2025-01-21 22:35:20 +11:00
Scott Powell 47567b003f * new targets: RAK_4631_chat_alice, and _bob 2025-01-21 21:36:44 +11:00
Scott Powell 96724cd26a * onPeerPathRecv() refactored: 'reciprocal path' now handled in Mesh class, not in application layer 2025-01-21 18:39:55 +11:00
Scott Powell de27dfacb6 * basic CAD before TX, for sx126x wrappers 2025-01-21 13:37:32 +11:00
Scott Powell e838f405a7 * sx126x TX power boost for RAK target 2025-01-20 23:32:02 +11:00
Scott Powell c9579a7b7c * Notes for RAK support 2025-01-20 22:03:31 +11:00
Scott Powell 515285e3c9 * new target: RAK_4631_Repeater 2025-01-20 20:22:40 +11:00
Scott Powell eb685db693 * readme update 2025-01-20 10:30:52 +11:00
Scott Powell e4ec9aec0b * tidy ups 2025-01-20 10:20:42 +11:00
Scott Powell 919e6d380c * extra debug diagnostics for repeater 2025-01-19 20:22:02 +11:00
Scott Powell 88f21d9aa4 * new target env: Xiao S3 WIO repeater 2025-01-19 16:44:25 +11:00
Scott Powell 07ad40cac0 * repeater: build config: ADVERT_NAME, ADVERT_LAT, ADVERT_LON 2025-01-19 08:24:42 +11:00
Scott Powell 382b73f6c5 * Dispatcher: more stats added 2025-01-19 00:36:59 +11:00
Scott Powell 67b0dfa868 * configurable REPEATER_NAME 2025-01-18 22:52:34 +11:00
Scott Powell f1ab110ae1 * new targets: Xiao_C3_repeater_sx1262, _sx1268 2025-01-18 21:45:47 +11:00
Scott Powell 4bf7d7d58f * chat sample updated to auto-add Chat node advertisements 2025-01-17 02:12:58 +11:00
Scott Powell 9b09545379 * new advertisement app_data format 2025-01-16 22:26:01 +11:00
Scott Powell 86f11d08aa * LocalIdentity:: writeTo( array ) and readFrom (array ) 2025-01-16 01:59:11 +11:00
Scott Powell ec92bfa6b1 * Refactor: Mesh::onPeer ... methods added 'secret' param. (is whatever getPeerSharedSecret() returned) 2025-01-15 20:52:13 +11:00
Scott Powell cd92308c41 * simple_secure_chat: round trip time diagnostics, plus better timeout estimations 2025-01-15 18:47:25 +11:00
Scott Powell 57b7fc45b8 * simple_repeater CLI: basic commands (reboot, advert) 2025-01-15 17:14:08 +11:00
Scott Powell 20cd756c88 * Radio:: getLastSNR(), getLastRSSI()
* MESH_PACKET_LOGGING
2025-01-15 17:02:49 +11:00
Scott Powell cc5f21ab09 * more options for setting radio params via .ini file 2025-01-15 02:14:52 +11:00
Scott Powell daa157cf49 * minor fixes 2025-01-15 00:39:32 +11:00
Scott Powell a05b951018 * removed unused Destination class 2025-01-14 20:13:20 +11:00
Scott Powell c44f124616 * new 'flags' byte added to PAYLOAD_TYPE_TXT_MSG 2025-01-14 13:11:34 +11:00
Scott Powell 20fccac2b7 * refactored the hasSeen(Packet) stuff. 2025-01-14 06:43:03 +11:00
Scott Powell 8983584dd8 * added getTransmitDelay(), applied to Flood mode retransmissions. 2025-01-13 20:45:01 +11:00
Scott Powell d06532d6f1 * simple_secure_chat: bug fixes 2025-01-13 16:57:01 +11:00
Scott Powell d291c6d31e * zeroing of path_len now in sendFlood() 2025-01-13 15:09:03 +11:00
Scott Powell 2faff914f6 * separated PAYLOAD_TYPE_ANON_REQ, to new createAnonDatagram(), with extra 'sender' param. So, caller can use 'self_id' or ephemeral key 2025-01-13 15:01:15 +11:00
Scott Powell 6c7efdd0f6 Initial commit 2025-01-13 14:07:48 +11:00
290 changed files with 41331 additions and 39031 deletions

No files matched your search

@@ -0,0 +1,29 @@
name: Setup Build Environment
runs:
using: "composite"
steps:
- name: Init Cache
uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install PlatformIO
shell: bash
run: |
pip install --upgrade platformio
# a git tag of "room-server-v1.2.3" should set "v1.2.3" as GIT_TAG_VERSION
- name: Extract Version from Git Tag
shell: bash
run: |
GIT_TAG_NAME="${GITHUB_REF#refs/tags/}"
echo "GIT_TAG_VERSION=${GIT_TAG_NAME##*-}" >> $GITHUB_ENV
@@ -0,0 +1,42 @@
name: Build Companion Firmwares
permissions:
contents: write
on:
workflow_dispatch:
push:
tags:
- 'companion-*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Clone Repo
uses: actions/checkout@v4
- name: Setup Build Environment
uses: ./.github/actions/setup-build-environment
- name: Build Firmwares
env:
FIRMWARE_VERSION: ${{ env.GIT_TAG_VERSION }}
run: /usr/bin/env bash build.sh build-companion-firmwares
- name: Upload Workflow Artifacts
uses: actions/upload-artifact@v4
with:
name: companion-firmwares
path: out
- name: Create Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
name: Companion Firmware ${{ env.GIT_TAG_VERSION }}
body: ""
draft: true
files: out/*
@@ -0,0 +1,42 @@
name: Build Repeater Firmwares
permissions:
contents: write
on:
workflow_dispatch:
push:
tags:
- 'repeater-*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Clone Repo
uses: actions/checkout@v4
- name: Setup Build Environment
uses: ./.github/actions/setup-build-environment
- name: Build Firmwares
env:
FIRMWARE_VERSION: ${{ env.GIT_TAG_VERSION }}
run: /usr/bin/env bash build.sh build-repeater-firmwares
- name: Upload Workflow Artifacts
uses: actions/upload-artifact@v4
with:
name: repeater-firmwares
path: out
- name: Create Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
name: Repeater Firmware ${{ env.GIT_TAG_VERSION }}
body: ""
draft: true
files: out/*
@@ -0,0 +1,42 @@
name: Build Room Server Firmwares
permissions:
contents: write
on:
workflow_dispatch:
push:
tags:
- 'room-server-*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Clone Repo
uses: actions/checkout@v4
- name: Setup Build Environment
uses: ./.github/actions/setup-build-environment
- name: Build Firmwares
env:
FIRMWARE_VERSION: ${{ env.GIT_TAG_VERSION }}
run: /usr/bin/env bash build.sh build-room-server-firmwares
- name: Upload Workflow Artifacts
uses: actions/upload-artifact@v4
with:
name: room-server-firmwares
path: out
- name: Create Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
name: Room Server Firmware ${{ env.GIT_TAG_VERSION }}
body: ""
draft: true
files: out/*
+6
View File
@@ -0,0 +1,6 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
out/
+10
View File
@@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}
-574
View File
@@ -1,574 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="generator" content="mkdocs-1.6.1, mkdocs-terminal-4.8.0">
<meta name="description" content="MeshCore fork meshcore-tth -- repeater antispam, diagnostics, OTA, Czech mesh defaults">
<link rel="icon" type="image/png" sizes="192x192" href="/meshcore-tth/img/android-chrome-192x192.png" />
<link rel="icon" type="image/png" sizes="512x512" href="/meshcore-tth/img/android-chrome-512x512.png" />
<link rel="apple-touch-icon" sizes="180x180" href="/meshcore-tth/img/apple-touch-icon.png" />
<link rel="shortcut icon" type="image/png" sizes="48x48" href="/meshcore-tth/img/favicon.ico" />
<link rel="icon" type="image/png" sizes="16x16" href="/meshcore-tth/img/favicon-16x16.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/meshcore-tth/img/favicon-32x32.png" />
<title>404 - MeshCore TTH</title>
<link href="/meshcore-tth/css/fontawesome/css/fontawesome.min.css" rel="stylesheet">
<link href="/meshcore-tth/css/fontawesome/css/solid.min.css" rel="stylesheet">
<link href="/meshcore-tth/css/normalize.css" rel="stylesheet">
<link href="/meshcore-tth/css/terminal.css" rel="stylesheet">
<link href="/meshcore-tth/css/theme.css" rel="stylesheet">
<link href="/meshcore-tth/css/theme.tile_grid.css" rel="stylesheet">
<link href="/meshcore-tth/css/theme.footer.css" rel="stylesheet">
<!-- dark color palette -->
<link href="/meshcore-tth/css/palettes/dark.css" rel="stylesheet">
<!-- page layout -->
<style>
/* initially set page layout to a one column grid */
.terminal-mkdocs-main-grid {
display: grid;
grid-column-gap: 1.4em;
grid-template-columns: auto;
grid-template-rows: auto;
}
/*
* when side navigation is not hidden, use a two column grid.
* if the screen is too narrow, fall back to the initial one column grid layout.
* in this case the main content will be placed under the navigation panel.
*/
@media only screen and (min-width: 70em) {
.terminal-mkdocs-main-grid {
grid-template-columns: 4fr 9fr;
}
}</style>
<!-- cursor_animation override -->
<style>
#mkdocs-terminal-site-name.terminal-prompt::after {
display: none;
}
</style>
<link href="/meshcore-tth/_stylesheets/tth.css" rel="stylesheet">
<!-- search css support -->
<link href="/meshcore-tth/css/search/bootstrap-modal.css" rel="stylesheet">
<!-- search scripts -->
<script>
var base_url = "/meshcore-tth/",
shortcuts = "{}";
</script>
<script src="/meshcore-tth/js/jquery/jquery-1.10.1.min.js" defer></script>
<script src="/meshcore-tth/js/bootstrap/bootstrap.min.js" defer></script>
<script src="/meshcore-tth/js/mkdocs/base.js" defer></script>
<script src="/meshcore-tth/search/main.js"></script>
</head>
<body class="terminal"><div class="container">
<div class="terminal-nav">
<header class="terminal-logo">
<div id="mkdocs-terminal-site-name" class="logo terminal-prompt"><a href="https://tth-pub.pages.rfa.cz/meshcore-tth/" class="no-style">MeshCore TTH</a></div>
</header>
<nav class="terminal-menu">
<ul vocab="https://schema.org/" typeof="BreadcrumbList">
<li property="itemListElement" typeof="ListItem">
<a href="/meshcore-tth/." class="menu-item " property="item" typeof="WebPage">
<span property="name">About the fork</span>
</a>
<meta property="position" content="0">
</li>
<li property="itemListElement" typeof="ListItem">
<a href="/meshcore-tth/cs/" class="menu-item " property="item" typeof="WebPage">
<span property="name">Česky</span>
</a>
<meta property="position" content="1">
</li>
<li property="itemListElement" typeof="ListItem">
<a href="#" class="menu-item" data-toggle="modal" data-target="#mkdocs_search_modal" property="item" typeof="SearchAction">
<i aria-hidden="true" class="fa fa-search"></i> <span property="name">Search</span>
</a>
<meta property="position" content="2">
</li>
</ul>
</nav>
</div>
</div>
<div class="container">
<div class="terminal-mkdocs-main-grid"><aside id="terminal-mkdocs-side-panel"><nav>
<ul class="terminal-mkdocs-side-nav-items">
<li class="terminal-mkdocs-side-nav-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/.">About the fork</a>
</li>
<li class="terminal-mkdocs-side-nav-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/cs/">Česky</a>
</li>
<li class="terminal-mkdocs-side-nav-li">
<span class="
terminal-mkdocs-side-nav-item terminal-mkdocs-side-nav-section-no-index">Fork meshcore-tth</span>
<ul class="terminal-mkdocs-side-nav-li-ul">
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/tth-commands/">Console commands</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/ota/">Firmware update by the admin (OTA)</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/power/">Power saving</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/budka-sensor/">Budka as a sensor</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/ble-lora-coexistence/">BLE/LoRa coexistence</a>
</li>
</ul>
</li>
<li class="terminal-mkdocs-side-nav-li">
<span class="
terminal-mkdocs-side-nav-item terminal-mkdocs-side-nav-section-no-index">MeshCore (upstream)</span>
<ul class="terminal-mkdocs-side-nav-li-ul">
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/meshcore/">Introduction</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/faq/">FAQ</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/cli_commands/">CLI commands</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/companion_cli/">Companion CLI</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/companion_protocol/">Companion protocol</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/terminal_chat_cli/">Terminal chat CLI</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/kiss_modem_protocol/">KISS modem protocol</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/packet_format/">Packet format</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/payloads/">Payloads</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/stats_binary_frames/">Stats binary frames</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/number_allocations/">Number allocations</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/qr_codes/">QR codes</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/radio_presets/">Radio presets</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="/meshcore-tth/nrf52_power_management/">nRF52 power management</a>
</li>
</ul>
</li>
</ul>
</nav>
</aside>
<main id="terminal-mkdocs-main-content">
<br>
<div class="terminal-alert terminal-alert-error">The page you requested could not be found.</div>
<a href="https://tth-pub.pages.rfa.cz/meshcore-tth/"><button class="btn btn-default">Return Home</button></a>
</main>
</div>
<hr><footer>
<div class="terminal-mkdocs-footer-grid">
<div id="terminal-mkdocs-footer-copyright-info">
Site built with <a href="http://www.mkdocs.org">MkDocs</a> and <a href="https://github.com/ntno/mkdocs-terminal">Terminal for MkDocs</a>.
</div>
</div>
</footer>
</div>
<div class="modal" id="mkdocs_search_modal" tabindex="-1" role="alertdialog" aria-modal="true" aria-labelledby="searchModalLabel">
<div class="modal-dialog modal-lg" role="search">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="searchModalLabel">Search</h5>
<button type="button" class="close btn btn-default btn-ghost" data-dismiss="modal" aria-label="Close">x</button>
</div>
<div class="modal-body">
<p id="searchInputLabel">Type to start searching</p>
<form>
<div class="form-group">
<input type="search" class="form-control" aria-labelledby="searchInputLabel" placeholder="" id="mkdocs-search-query" title="Please enter search terms here">
</div>
</form>
<div id="mkdocs-search-results" data-no-results-text="No document matches found"></div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</body>
</html>
+76
View File
@@ -0,0 +1,76 @@
## About MeshCore
MeshCore is a lightweight, portable C++ library that enables multi-hop packet routing for embedded projects using LoRa and other packet radios. It is designed for developers who want to create resilient, decentralized communication networks that work without the internet.
## 🔍 What is MeshCore?
MeshCore now supports a range of LoRa devices, allowing for easy flashing without the need to compile firmware manually. Users can flash a pre-built binary using tools like Adafruit ESPTool and interact with the network through a serial console.
MeshCore provides the ability to create wireless mesh networks, similar to Meshtastic and Reticulum but with a focus on lightweight multi-hop packet routing for embedded projects. Unlike Meshtastic, which is tailored for casual LoRa communication, or Reticulum, which offers advanced networking, MeshCore balances simplicity with scalability, making it ideal for custom embedded solutions., where devices (nodes) can communicate over long distances by relaying messages through intermediate nodes. This is especially useful in off-grid, emergency, or tactical situations where traditional communication infrastructure is unavailable.
## ⚡ Key Features
* Multi-Hop Packet Routing – Devices can forward messages across multiple nodes, extending range beyond a single radio's reach. MeshCore supports up to a configurable number of hops to balance network efficiency and prevent excessive traffic.
* Supports LoRa Radios – Works with Heltec, RAK Wireless, and other LoRa-based hardware.
* Decentralized & Resilient – No central server or internet required; the network is self-healing.
* Low Power Consumption – Ideal for battery-powered or solar-powered devices.
* Simple to Deploy – Pre-built example applications make it easy to get started.
## 🎯 What Can You Use MeshCore For?
* Off-Grid Communication: Stay connected even in remote areas.
* Emergency Response & Disaster Recovery: Set up instant networks where infrastructure is down.
* Outdoor Activities: Hiking, camping, and adventure racing communication.
* Tactical & Security Applications: Military, law enforcement, and private security use cases.
* IoT & Sensor Networks: Collect data from remote sensors and relay it back to a central location.
## 🚀 How to Get Started
Andy Kirby has published a very useful [intro video](https://www.youtube.com/watch?v=t1qne8uJBAc) which explains the steps for beginners.
For developers, install [PlatformIO](https://docs.platformio.org) in Visual Studio Code.
Download & Open the MeshCore repository.
Select a Sample Application: Choose from chat, repeater, other example app.
Monitor & Communicate using the Serial Monitor (e.g., Serial USB Terminal on Android).
📁 Included Example Applications
* 📡 Terminal Chat: Secure text communication between devices.
* 📡 Simple Repeater: Extends network coverage by relaying messages.
* 📡 Companion Radio: For use with an external chat app, over BLE or USB.
* 📡 Room Server: A simple BBS server for shared Posts.
## 🛠 Hardware Compatibility
MeshCore is designed for use with:
* Heltec V3 LoRa Boards
* RAK4631
* XiaoS3 WIO (sx1262 combo)
* XiaoC3 (plus external sx126x module)
* LilyGo T3S3
* Heltec T114
* Station G2
* Sensecap T1000e
* Heltec V2
* LilyGo TLora32 v1.6
## 📜 License
MeshCore is open-source software released under the MIT License. You are free to use, modify, and distribute it for personal and commercial projects.
## Contributing
Please submit PR's using 'dev' as the base branch!
For minor changes just submit your PR and I'll try to review it, but for anything more 'impactful' please open an Issue first and start a discussion. Is better to sound out what it is you want to achieve first, and try to come to a consensus on what the best approach is, especially when it impacts the structure or architecture of this codebase.
## 📞 Get Support
Check out the GitHub Issues page to report bugs or request features.
You will be able to find additional guides and components at [my site](https://buymeacoffee.com/ripplebiz), or [join Andy Kirby's Discord](https://discord.gg/GBxVx2JMAy) for discussions.
## RAK Wireless Board Support in PlatformIO
Before building/flashing the RAK4631 targets in this project, there is, unfortunately, some patching you have to do to your platformIO packages to make it work. There is a guide here on the process:
[RAK Wireless: How to Perform Installation of Board Support Package in PlatformIO](https://learn.rakwireless.com/hc/en-us/articles/26687276346775-How-To-Perform-Installation-of-Board-Support-Package-in-PlatformIO)
After building, you will need to convert the output firmware.hex file into a .uf2 file you can copy over to your RAK4631 device (after doing a full erase) by using the command `uf2conv.py -f 0xADA52840 -c firmware.hex` with the python script available from:
[GitHub: Microsoft - uf2](https://github.com/Microsoft/uf2/blob/master/utils/uf2conv.py)
+15
View File
@@ -0,0 +1,15 @@
# Releasing Firmware
GitHub Actions is set up to automatically build and release firmware.
It will automatically build firmware when one of the following tag formats are pushed.
- `companion-v1.0.0`
- `repeater-v1.0.0`
- `room-server-v1.0.0`
> NOTE: replace `v1.0.0` with the version you want to release as.
- You can push one, or more tags on the same commit, and they will all build separately.
- Once the firmware has been built, a new (draft) GitHub Release will be created.
- You will need to update the release notes, and publish it.
-12
View File
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 134 15" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<path d="M3.277,0.053C2.829,0.053 2.401,0.41 2.321,0.851L0.013,13.623C-0.067,14.064 0.232,14.421 0.681,14.421L3.13,14.421C3.578,14.421 4.006,14.064 4.086,13.623L5.004,8.54L6.684,13.957C6.766,14.239 7.02,14.421 7.337,14.421L10.58,14.421C10.897,14.421 11.217,14.239 11.401,13.957L15.043,8.513L14.119,13.623C14.038,14.064 14.338,14.421 14.787,14.421L17.236,14.421C17.684,14.421 18.112,14.064 18.192,13.623L20.5,0.851C20.582,0.41 20.283,0.053 19.834,0.053L16.69,0.053C16.373,0.053 16.053,0.235 15.87,0.517L9.897,9.473C9.803,9.616 9.578,9.578 9.528,9.41L7.074,0.517C6.992,0.235 6.738,0.053 6.421,0.053L3.277,0.053Z" style="fill:white;fill-rule:nonzero;"/>
<path d="M21.146,14.421C21.146,14.421 33.257,14.421 33.257,14.421C33.526,14.421 33.784,14.205 33.831,13.942L34.337,11.128C34.385,10.863 34.206,10.649 33.936,10.649L25.519,10.649C25.429,10.649 25.37,10.576 25.385,10.488L25.635,9.105C25.65,9.017 25.736,8.944 25.826,8.944L32.596,8.944C32.865,8.944 33.123,8.728 33.171,8.465L33.621,5.974C33.669,5.709 33.49,5.495 33.221,5.495L26.45,5.495C26.361,5.495 26.301,5.423 26.317,5.335L26.584,3.852C26.599,3.764 26.685,3.691 26.775,3.691L35.192,3.691C35.462,3.691 35.719,3.476 35.767,3.21L36.258,0.498C36.306,0.235 36.126,0.019 35.857,0.019L23.746,0.019C23.297,0.019 22.867,0.378 22.788,0.819L20.474,13.621C20.396,14.062 20.695,14.421 21.146,14.421Z" style="fill:white;fill-rule:nonzero;"/>
<path d="M45.926,14.419L45.926,14.421L46.346,14.421C48.453,14.421 50.465,12.742 50.839,10.67L51.081,9.327C51.456,7.256 50.05,5.576 47.943,5.576L41.455,5.576C41.186,5.576 41.007,5.363 41.054,5.097L41.218,4.192C41.266,3.927 41.524,3.713 41.793,3.713L50.569,3.713C51.018,3.713 51.446,3.356 51.526,2.915L51.9,0.85C51.98,0.407 51.68,0.05 51.232,0.05L41.638,0.05C39.531,0.05 37.519,1.73 37.145,3.801L36.88,5.267C36.505,7.339 37.91,9.018 40.018,9.018L46.506,9.018C46.775,9.018 46.954,9.231 46.907,9.497L46.785,10.176C46.737,10.441 46.479,10.655 46.21,10.655L37.189,10.655C36.741,10.655 36.313,11.012 36.233,11.453L35.841,13.621C35.761,14.062 36.061,14.419 36.51,14.419L45.926,14.419Z" style="fill:white;fill-rule:nonzero;"/>
<path d="M68.008,0.046C68.008,0.046 65.296,0.046 65.296,0.046C64.847,0.046 64.42,0.403 64.34,0.844L63.532,5.31C63.517,5.398 63.431,5.469 63.341,5.469L58.085,5.469C57.995,5.469 57.936,5.398 57.951,5.31L58.758,0.844C58.837,0.403 58.539,0.046 58.09,0.046L55.378,0.046C54.93,0.046 54.502,0.403 54.422,0.844L52.112,13.623C52.032,14.064 52.331,14.421 52.78,14.421L55.492,14.421C55.941,14.421 56.369,14.064 56.449,13.623L57.272,9.074C57.287,8.986 57.373,8.914 57.462,8.914L62.719,8.914C62.809,8.914 62.868,8.985 62.853,9.074L62.032,13.623C61.952,14.064 62.252,14.421 62.7,14.421L65.413,14.421C65.861,14.421 66.289,14.064 66.369,13.623L68.678,0.844C68.755,0.403 68.457,0.046 68.008,0.046Z" style="fill:white;fill-rule:nonzero;"/>
<path d="M72.099,14.421C72.099,14.421 80.066,14.421 80.066,14.421C80.515,14.421 80.943,14.064 81.022,13.623L81.414,11.453C81.494,11.012 81.194,10.655 80.746,10.655L73.828,10.655C73.559,10.655 73.38,10.441 73.427,10.176L74.51,4.215C74.558,3.951 74.815,3.736 75.082,3.736L82,3.736C82.448,3.736 82.876,3.379 82.956,2.938L83.34,0.817C83.42,0.376 83.12,0.019 82.672,0.019L74.724,0.019C72.622,0.019 70.614,1.691 70.236,3.757L68.965,10.665C68.587,12.738 69.99,14.421 72.099,14.421Z" style="fill:white;fill-rule:nonzero;"/>
<path d="M97.176,-0C97.176,0 88.882,0 88.882,0C86.775,0 84.763,1.68 84.389,3.751L83.139,10.67C82.765,12.741 84.169,14.421 86.277,14.421L94.571,14.421C96.678,14.421 98.69,12.741 99.064,10.67L100.314,3.751C100.689,1.68 99.284,-0 97.176,-0ZM94.798,10.178C94.75,10.443 94.492,10.657 94.223,10.657L87.978,10.657C87.709,10.657 87.529,10.443 87.577,10.178L88.659,4.192C88.707,3.927 88.964,3.713 89.234,3.713L95.477,3.713C95.747,3.713 95.926,3.927 95.878,4.192L94.798,10.178Z" style="fill:white;fill-rule:nonzero;"/>
<path d="M101.284,14.421L103.995,14.421C104.443,14.421 104.871,14.065 104.951,13.624L105.43,10.97C105.446,10.882 105.531,10.81 105.621,10.81L108.902,10.806C109.064,10.806 109.2,10.886 109.267,11.018L110.813,14.035C110.992,14.392 111.319,14.434 112.303,14.419C112.88,14.426 113.756,14.382 115.169,14.382C115.623,14.382 115.902,13.907 115.678,13.51L113.989,10.569C113.945,10.491 113.993,10.386 114.086,10.34C115.39,9.707 116.423,8.477 116.681,7.055L117.27,3.785C117.646,1.713 116.242,0.033 114.134,0.033L103.884,0.033C103.436,0.033 103.008,0.39 102.928,0.831L100.616,13.623C100.536,14.064 100.836,14.421 101.284,14.421L101.284,14.421ZM106.73,3.791C106.745,3.703 106.831,3.631 106.921,3.631L112.225,3.631C112.626,3.631 112.891,3.949 112.821,4.343L112.431,6.494C112.359,6.885 111.979,7.204 111.58,7.204L106.276,7.204C106.186,7.204 106.127,7.133 106.142,7.043L106.73,3.791Z" style="fill:white;fill-rule:nonzero;"/>
<path d="M118.277,14.421C118.277,14.421 130.388,14.421 130.388,14.421C130.657,14.421 130.915,14.205 130.963,13.942L131.468,11.128C131.516,10.863 131.337,10.649 131.068,10.649L122.65,10.649C122.56,10.649 122.501,10.576 122.516,10.488L122.766,9.105C122.781,9.017 122.867,8.944 122.957,8.944L129.728,8.944C129.997,8.944 130.254,8.728 130.302,8.465L130.753,5.974C130.801,5.709 130.621,5.495 130.352,5.495L123.581,5.495C123.492,5.495 123.432,5.423 123.448,5.335L123.715,3.852C123.73,3.764 123.816,3.691 123.906,3.691L132.324,3.691C132.593,3.691 132.851,3.476 132.898,3.21L133.389,0.498C133.437,0.235 133.257,0.019 132.988,0.019L120.877,0.019C120.428,0.019 119.999,0.378 119.919,0.819L117.605,13.621C117.527,14.062 117.827,14.421 118.277,14.421Z" style="fill:white;fill-rule:nonzero;"/>
</svg>

Before

Width:  |  Height:  |  Size: 5.9 KiB

-14
View File
@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 139 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<path d="M3.232,3.582C2.789,3.582 2.368,3.934 2.289,4.369L0.013,16.964C-0.066,17.399 0.229,17.751 0.671,17.751L3.087,17.751C3.529,17.751 3.951,17.399 4.03,16.964L4.935,11.951L6.592,17.293C6.672,17.572 6.923,17.751 7.235,17.751L10.434,17.751C10.746,17.751 11.062,17.572 11.243,17.293L14.835,11.925L13.924,16.964C13.844,17.399 14.14,17.751 14.583,17.751L16.998,17.751C17.44,17.751 17.862,17.399 17.941,16.964L20.217,4.369C20.298,3.934 20.002,3.582 19.56,3.582L16.46,3.582C16.147,3.582 15.831,3.761 15.65,4.04L9.76,12.872C9.668,13.013 9.446,12.975 9.397,12.81L6.976,4.04C6.895,3.761 6.645,3.582 6.332,3.582L3.232,3.582Z" style="fill:white;fill-rule:nonzero;"/>
<path d="M20.853,17.751C20.853,17.751 32.797,17.751 32.797,17.751C33.063,17.751 33.317,17.538 33.364,17.278L33.863,14.504C33.91,14.242 33.733,14.031 33.467,14.031L25.166,14.031C25.077,14.031 25.019,13.96 25.034,13.873L25.281,12.508C25.296,12.421 25.38,12.35 25.469,12.35L32.146,12.35C32.411,12.35 32.665,12.137 32.712,11.877L33.157,9.421C33.204,9.159 33.027,8.949 32.761,8.949L26.085,8.949C25.996,8.949 25.938,8.877 25.953,8.79L26.216,7.328C26.232,7.241 26.316,7.17 26.405,7.17L34.706,7.17C34.971,7.17 35.226,6.957 35.272,6.695L35.756,4.021C35.804,3.761 35.627,3.548 35.361,3.548L23.417,3.548C22.975,3.548 22.551,3.902 22.473,4.337L20.191,16.962C20.114,17.397 20.409,17.751 20.853,17.751Z" style="fill:white;fill-rule:nonzero;"/>
<path d="M45.291,17.749L45.291,17.751L45.705,17.751C47.783,17.751 49.767,16.095 50.136,14.052L50.375,12.727C50.744,10.685 49.359,9.029 47.28,9.029L40.882,9.029C40.617,9.029 40.44,8.818 40.487,8.556L40.649,7.664C40.696,7.402 40.95,7.191 41.215,7.191L49.87,7.191C50.313,7.191 50.735,6.839 50.814,6.404L51.183,4.368C51.262,3.931 50.966,3.579 50.523,3.579L41.063,3.579C38.985,3.579 37,5.235 36.631,7.278L36.37,8.723C36.001,10.767 37.386,12.422 39.465,12.422L45.863,12.422C46.128,12.422 46.305,12.633 46.258,12.895L46.138,13.565C46.091,13.826 45.837,14.037 45.571,14.037L36.675,14.037C36.233,14.037 35.811,14.389 35.732,14.824L35.346,16.962C35.267,17.397 35.562,17.749 36.005,17.749L45.291,17.749Z" style="fill:white;fill-rule:nonzero;"/>
<path d="M67.068,3.575C67.068,3.575 64.393,3.575 64.393,3.575C63.951,3.575 63.529,3.927 63.45,4.361L62.654,8.766C62.639,8.853 62.554,8.923 62.466,8.923L57.282,8.923C57.193,8.923 57.135,8.853 57.15,8.766L57.946,4.361C58.023,3.927 57.73,3.575 57.287,3.575L54.613,3.575C54.17,3.575 53.748,3.927 53.669,4.361L51.392,16.964C51.313,17.399 51.608,17.751 52.05,17.751L54.725,17.751C55.168,17.751 55.589,17.399 55.668,16.964L56.48,12.478C56.495,12.392 56.58,12.32 56.668,12.32L61.852,12.32C61.941,12.32 61.999,12.39 61.984,12.478L61.174,16.964C61.096,17.399 61.391,17.751 61.834,17.751L64.508,17.751C64.951,17.751 65.372,17.399 65.451,16.964L67.729,4.361C67.804,3.927 67.511,3.575 67.068,3.575Z" style="fill:white;fill-rule:nonzero;"/>
<path d="M71.102,17.751C71.102,17.751 78.96,17.751 78.96,17.751C79.402,17.751 79.824,17.399 79.903,16.964L80.288,14.824C80.367,14.389 80.072,14.037 79.629,14.037L72.808,14.037C72.542,14.037 72.365,13.826 72.412,13.565L73.48,7.686C73.527,7.426 73.781,7.213 74.045,7.213L80.866,7.213C81.309,7.213 81.73,6.861 81.81,6.427L82.188,4.335C82.267,3.9 81.971,3.548 81.529,3.548L73.691,3.548C71.618,3.548 69.638,5.197 69.265,7.234L68.011,14.046C67.639,16.091 69.022,17.751 71.102,17.751Z" style="fill:white;fill-rule:nonzero;"/>
<path d="M95.833,3.529C95.833,3.529 87.654,3.529 87.654,3.529C85.576,3.529 83.592,5.186 83.223,7.228L81.99,14.052C81.621,16.094 83.006,17.751 85.084,17.751L93.263,17.751C95.341,17.751 97.326,16.095 97.695,14.052L98.928,7.228C99.297,5.186 97.911,3.529 95.833,3.529ZM93.488,13.567C93.44,13.828 93.186,14.039 92.921,14.039L86.762,14.039C86.496,14.039 86.319,13.828 86.366,13.567L87.434,7.663C87.481,7.402 87.735,7.191 88,7.191L94.157,7.191C94.423,7.191 94.6,7.402 94.553,7.663L93.488,13.567Z" style="fill:white;fill-rule:nonzero;"/>
<path d="M99.884,17.751L102.557,17.751C102.999,17.751 103.421,17.399 103.5,16.965L103.973,14.348C103.988,14.261 104.073,14.19 104.161,14.19L107.397,14.186C107.557,14.186 107.69,14.265 107.756,14.395L109.281,17.37C109.458,17.722 109.78,17.764 110.751,17.749C111.32,17.756 112.184,17.713 113.577,17.713C114.025,17.713 114.3,17.244 114.079,16.853L112.413,13.953C112.37,13.876 112.417,13.772 112.509,13.727C113.795,13.102 114.814,11.889 115.068,10.487L115.649,7.262C116.02,5.218 114.635,3.562 112.557,3.562L102.448,3.562C102.006,3.562 101.584,3.914 101.505,4.349L99.225,16.964C99.146,17.399 99.442,17.751 99.884,17.751L99.884,17.751ZM105.255,7.268C105.27,7.181 105.354,7.11 105.443,7.11L110.674,7.11C111.069,7.11 111.331,7.424 111.261,7.812L110.877,9.933C110.806,10.319 110.431,10.634 110.038,10.634L104.806,10.634C104.718,10.634 104.66,10.564 104.675,10.475L105.255,7.268Z" style="fill:white;fill-rule:nonzero;"/>
<path d="M116.642,17.751C116.642,17.751 128.586,17.751 128.586,17.751C128.851,17.751 129.105,17.538 129.152,17.278L129.651,14.504C129.698,14.242 129.521,14.031 129.256,14.031L120.955,14.031C120.866,14.031 120.808,13.96 120.823,13.873L121.069,12.508C121.084,12.421 121.169,12.35 121.257,12.35L127.934,12.35C128.2,12.35 128.454,12.137 128.501,11.877L128.945,9.421C128.992,9.159 128.815,8.949 128.55,8.949L121.873,8.949C121.785,8.949 121.726,8.877 121.741,8.79L122.005,7.328C122.02,7.241 122.105,7.17 122.193,7.17L130.495,7.17C130.76,7.17 131.014,6.957 131.061,6.695L131.545,4.021C131.592,3.761 131.415,3.548 131.15,3.548L119.206,3.548C118.763,3.548 118.34,3.902 118.261,4.337L115.98,16.962C115.902,17.397 116.198,17.751 116.642,17.751Z" style="fill:white;fill-rule:nonzero;"/>
<path d="M134.674,0C134.674,0 132.059,0 132.059,0C131.965,0 131.877,0.074 131.86,0.166L131.783,0.594C131.766,0.686 131.828,0.76 131.921,0.76L132.745,0.76C132.764,0.76 132.776,0.775 132.773,0.793L132.406,2.819C132.39,2.91 132.452,2.984 132.545,2.984L133.108,2.984C133.201,2.984 133.29,2.91 133.307,2.819L133.673,0.793C133.676,0.775 133.694,0.76 133.713,0.76L134.536,0.76C134.629,0.76 134.718,0.686 134.735,0.594L134.812,0.166C134.828,0.074 134.767,0 134.674,0Z" style="fill:white;fill-rule:nonzero;"/>
<path d="M135.278,0.002C135.185,0.002 135.096,0.076 135.079,0.167L134.6,2.819C134.583,2.91 134.646,2.984 134.739,2.984L135.247,2.984C135.34,2.984 135.429,2.91 135.446,2.819L135.636,1.763L135.985,2.888C136.002,2.947 136.055,2.984 136.121,2.984L136.794,2.984C136.86,2.984 136.926,2.947 136.964,2.888L137.72,1.758L137.528,2.819C137.512,2.91 137.574,2.984 137.667,2.984L138.176,2.984C138.269,2.984 138.358,2.91 138.374,2.819L138.853,0.167C138.87,0.076 138.808,0.002 138.715,0.002L138.062,0.002C137.997,0.002 137.93,0.039 137.892,0.098L136.652,1.957C136.633,1.987 136.586,1.979 136.575,1.944L136.066,0.098C136.049,0.039 135.996,0.002 135.93,0.002L135.278,0.002Z" style="fill:white;fill-rule:nonzero;"/>
</svg>

Before

Width:  |  Height:  |  Size: 7.1 KiB

-16
View File
@@ -1,16 +0,0 @@
:root {
--md-primary-fg-color: #1F2937;
--md-primary-fg-color--light: #1F2937;
--md-primary-fg-color--dark: #1F2937;
--md-accent-fg-color: #1F2937;
}
/* hide git repo version */
.md-source__fact--version {
display: none;
}
/* underline links */
.md-typeset a {
text-decoration: underline;
}
-36
View File
@@ -1,36 +0,0 @@
/* Docs site of the meshcore-tth fork (mkdocs.tth.yml, theme mkdocs-terminal,
palette "dark"): only what the palette lacks. Green instead of its blue,
and the GitHub callouts (> [!WARNING]) the theme does not style. */
:root {
--primary-color: #5fd38d;
--progress-bar-fill: #5fd38d;
/* plain black; the palette's 60em column was a thin noodle on a wide
screen (user, 2. 12. 2026) */
--background-color: #000;
--invert-font-color: #000;
--code-bg-color: #161616;
--page-width: min(110em, 94vw);
}
.admonition {
border: 1px solid var(--secondary-color);
padding: 0.2em 1em;
margin: var(--global-line-height) 0;
}
.admonition-title {
font-weight: bold;
margin: 0.4em 0 0;
}
.admonition.warning, .admonition.caution, .admonition.danger {
border-color: #e5a50a;
}
.admonition.warning > .admonition-title,
.admonition.caution > .admonition-title,
.admonition.danger > .admonition-title {
color: #e5a50a;
}
.admonition.note > .admonition-title,
.admonition.tip > .admonition-title,
.admonition.important > .admonition-title {
color: var(--primary-color);
}
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Ayush Sharma
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+2
View File
@@ -0,0 +1,2 @@
AsyncElegantOTA KEYWORD1
begin KEYWORD2
@@ -0,0 +1,9 @@
name=AsyncElegantOTA
version=2.2.8
author=Ayush Sharma
category=Communication
maintainer=Ayush Sharma <asrocks5@gmail.com>
sentence=Perform OTAs for ESP8266 & ESP32 Asynchronously.
paragraph=A User Interface Library which provides interactive elements for your Over the Air Updates on ESP8266/ESP32.
url=https://github.com/ayushsharma82/AsyncElegantOTA
architectures=esp8266,esp32
@@ -0,0 +1,129 @@
#include <AsyncElegantOTA.h>
AsyncElegantOtaClass AsyncElegantOTA;
void AsyncElegantOtaClass::setID(const char* id){
_id = id;
}
void AsyncElegantOtaClass::begin(AsyncWebServer *server, const char* username, const char* password){
_server = server;
if(strlen(username) > 0){
_authRequired = true;
_username = username;
_password = password;
}else{
_authRequired = false;
_username = "";
_password = "";
}
_server->on("/update/identity", HTTP_GET, [&](AsyncWebServerRequest *request){
if(_authRequired){
if(!request->authenticate(_username.c_str(), _password.c_str())){
return request->requestAuthentication();
}
}
#if defined(ESP8266)
request->send(200, "application/json", "{\"id\": \""+_id+"\", \"hardware\": \"ESP8266\"}");
#elif defined(ESP32)
request->send(200, "application/json", "{\"id\": \""+_id+"\", \"hardware\": \"ESP32\"}");
#endif
});
_server->on("/update", HTTP_GET, [&](AsyncWebServerRequest *request){
if(_authRequired){
if(!request->authenticate(_username.c_str(), _password.c_str())){
return request->requestAuthentication();
}
}
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", ELEGANT_HTML, ELEGANT_HTML_SIZE);
response->addHeader("Content-Encoding", "gzip");
request->send(response);
});
_server->on("/update", HTTP_POST, [&](AsyncWebServerRequest *request) {
if(_authRequired){
if(!request->authenticate(_username.c_str(), _password.c_str())){
return request->requestAuthentication();
}
}
// the request handler is triggered after the upload has finished...
// create the response, add header, and send response
AsyncWebServerResponse *response = request->beginResponse((Update.hasError())?500:200, "text/plain", (Update.hasError())?"FAIL":"OK");
response->addHeader("Connection", "close");
response->addHeader("Access-Control-Allow-Origin", "*");
request->send(response);
restart();
}, [&](AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) {
//Upload handler chunks in data
if(_authRequired){
if(!request->authenticate(_username.c_str(), _password.c_str())){
return request->requestAuthentication();
}
}
if (!index) {
if(!request->hasParam("MD5", true)) {
return request->send(400, "text/plain", "MD5 parameter missing");
}
if(!Update.setMD5(request->getParam("MD5", true)->value().c_str())) {
return request->send(400, "text/plain", "MD5 parameter invalid");
}
#if defined(ESP8266)
int cmd = (filename == "filesystem") ? U_FS : U_FLASH;
Update.runAsync(true);
size_t fsSize = ((size_t) &_FS_end - (size_t) &_FS_start);
uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
if (!Update.begin((cmd == U_FS)?fsSize:maxSketchSpace, cmd)){ // Start with max available size
#elif defined(ESP32)
int cmd = (filename == "filesystem") ? U_SPIFFS : U_FLASH;
if (!Update.begin(UPDATE_SIZE_UNKNOWN, cmd)) { // Start with max available size
#endif
Update.printError(Serial);
return request->send(400, "text/plain", "OTA could not begin");
}
}
// Write chunked data to the free sketch space
if(len){
if (Update.write(data, len) != len) {
return request->send(400, "text/plain", "OTA could not begin");
}
}
if (final) { // if the final flag is set then this is the last frame of data
if (!Update.end(true)) { //true to set the size to the current progress
Update.printError(Serial);
return request->send(400, "text/plain", "Could not end OTA");
}
}else{
return;
}
});
}
// deprecated, keeping for backward compatibility
void AsyncElegantOtaClass::loop() {
}
void AsyncElegantOtaClass::restart() {
yield();
delay(1000);
yield();
ESP.restart();
}
String AsyncElegantOtaClass::getID(){
String id = "";
#if defined(ESP8266)
id = String(ESP.getChipId());
#elif defined(ESP32)
id = String((uint32_t)ESP.getEfuseMac(), HEX);
#endif
id.toUpperCase();
return id;
}
@@ -0,0 +1,52 @@
#ifndef AsyncElegantOTA_h
#define AsyncElegantOTA_h
#warning AsyncElegantOTA library is deprecated, Please consider moving to newer ElegantOTA library which now comes with an Async Mode. Learn More: https://docs.elegantota.pro/async-mode/
#include "Arduino.h"
#include "stdlib_noniso.h"
#if defined(ESP8266)
#include "ESP8266WiFi.h"
#include "ESPAsyncTCP.h"
#include "flash_hal.h"
#include "FS.h"
#elif defined(ESP32)
#include "WiFi.h"
#include "AsyncTCP.h"
#include "Update.h"
#include "esp_int_wdt.h"
#include "esp_task_wdt.h"
#endif
#include "Hash.h"
#include "ESPAsyncWebServer.h"
#include "FS.h"
#include "elegantWebpage.h"
class AsyncElegantOtaClass{
public:
void
setID(const char* id),
begin(AsyncWebServer *server, const char* username = "", const char* password = ""),
loop(),
restart();
private:
AsyncWebServer *_server;
String getID();
String _id = getID();
String _username = "";
String _password = "";
bool _authRequired = false;
};
extern AsyncElegantOtaClass AsyncElegantOTA;
#endif
+38
View File
@@ -0,0 +1,38 @@
/**
* @file Hash.h
* @date 20.05.2015
* @author Markus Sattler
*
* Copyright (c) 2015 Markus Sattler. All rights reserved.
* This file is part of the esp8266 core for Arduino environment.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef HASH_H_
#define HASH_H_
//#define DEBUG_SHA1
void sha1(const uint8_t* data, uint32_t size, uint8_t hash[20]);
void sha1(const char* data, uint32_t size, uint8_t hash[20]);
void sha1(const String& data, uint8_t hash[20]);
String sha1(const uint8_t* data, uint32_t size);
String sha1(const char* data, uint32_t size);
String sha1(const String& data);
#endif /* HASH_H_ */
File diff suppressed because it is too large. Load diff
+361
View File
@@ -0,0 +1,361 @@
#!/usr/bin/env python3
import sys
import struct
import subprocess
import re
import os
import os.path
import argparse
import json
from time import sleep
UF2_MAGIC_START0 = 0x0A324655 # "UF2\n"
UF2_MAGIC_START1 = 0x9E5D5157 # Randomly selected
UF2_MAGIC_END = 0x0AB16F30 # Ditto
INFO_FILE = "/INFO_UF2.TXT"
appstartaddr = 0x2000
familyid = 0x0
def is_uf2(buf):
w = struct.unpack("<II", buf[0:8])
return w[0] == UF2_MAGIC_START0 and w[1] == UF2_MAGIC_START1
def is_hex(buf):
try:
w = buf[0:30].decode("utf-8")
except UnicodeDecodeError:
return False
if w[0] == ':' and re.match(rb"^[:0-9a-fA-F\r\n]+$", buf):
return True
return False
def convert_from_uf2(buf):
global appstartaddr
global familyid
numblocks = len(buf) // 512
curraddr = None
currfamilyid = None
families_found = {}
prev_flag = None
all_flags_same = True
outp = []
for blockno in range(numblocks):
ptr = blockno * 512
block = buf[ptr:ptr + 512]
hd = struct.unpack(b"<IIIIIIII", block[0:32])
if hd[0] != UF2_MAGIC_START0 or hd[1] != UF2_MAGIC_START1:
print("Skipping block at " + ptr + "; bad magic")
continue
if hd[2] & 1:
# NO-flash flag set; skip block
continue
datalen = hd[4]
if datalen > 476:
assert False, "Invalid UF2 data size at " + ptr
newaddr = hd[3]
if (hd[2] & 0x2000) and (currfamilyid == None):
currfamilyid = hd[7]
if curraddr == None or ((hd[2] & 0x2000) and hd[7] != currfamilyid):
currfamilyid = hd[7]
curraddr = newaddr
if familyid == 0x0 or familyid == hd[7]:
appstartaddr = newaddr
padding = newaddr - curraddr
if padding < 0:
assert False, "Block out of order at " + ptr
if padding > 10*1024*1024:
assert False, "More than 10M of padding needed at " + ptr
if padding % 4 != 0:
assert False, "Non-word padding size at " + ptr
while padding > 0:
padding -= 4
outp.append(b"\x00\x00\x00\x00")
if familyid == 0x0 or ((hd[2] & 0x2000) and familyid == hd[7]):
outp.append(block[32 : 32 + datalen])
curraddr = newaddr + datalen
if hd[2] & 0x2000:
if hd[7] in families_found.keys():
if families_found[hd[7]] > newaddr:
families_found[hd[7]] = newaddr
else:
families_found[hd[7]] = newaddr
if prev_flag == None:
prev_flag = hd[2]
if prev_flag != hd[2]:
all_flags_same = False
if blockno == (numblocks - 1):
print("--- UF2 File Header Info ---")
families = load_families()
for family_hex in families_found.keys():
family_short_name = ""
for name, value in families.items():
if value == family_hex:
family_short_name = name
print("Family ID is {:s}, hex value is 0x{:08x}".format(family_short_name,family_hex))
print("Target Address is 0x{:08x}".format(families_found[family_hex]))
if all_flags_same:
print("All block flag values consistent, 0x{:04x}".format(hd[2]))
else:
print("Flags were not all the same")
print("----------------------------")
if len(families_found) > 1 and familyid == 0x0:
outp = []
appstartaddr = 0x0
return b"".join(outp)
def convert_to_carray(file_content):
outp = "const unsigned long bindata_len = %d;\n" % len(file_content)
outp += "const unsigned char bindata[] __attribute__((aligned(16))) = {"
for i in range(len(file_content)):
if i % 16 == 0:
outp += "\n"
outp += "0x%02x, " % file_content[i]
outp += "\n};\n"
return bytes(outp, "utf-8")
def convert_to_uf2(file_content):
global familyid
datapadding = b""
while len(datapadding) < 512 - 256 - 32 - 4:
datapadding += b"\x00\x00\x00\x00"
numblocks = (len(file_content) + 255) // 256
outp = []
for blockno in range(numblocks):
ptr = 256 * blockno
chunk = file_content[ptr:ptr + 256]
flags = 0x0
if familyid:
flags |= 0x2000
hd = struct.pack(b"<IIIIIIII",
UF2_MAGIC_START0, UF2_MAGIC_START1,
flags, ptr + appstartaddr, 256, blockno, numblocks, familyid)
while len(chunk) < 256:
chunk += b"\x00"
block = hd + chunk + datapadding + struct.pack(b"<I", UF2_MAGIC_END)
assert len(block) == 512
outp.append(block)
return b"".join(outp)
class Block:
def __init__(self, addr, default_data=0xFF):
self.addr = addr
self.bytes = bytearray([default_data] * 256)
def encode(self, blockno, numblocks):
global familyid
flags = 0x0
if familyid:
flags |= 0x2000
hd = struct.pack("<IIIIIIII",
UF2_MAGIC_START0, UF2_MAGIC_START1,
flags, self.addr, 256, blockno, numblocks, familyid)
hd += self.bytes[0:256]
while len(hd) < 512 - 4:
hd += b"\x00"
hd += struct.pack("<I", UF2_MAGIC_END)
return hd
def convert_from_hex_to_uf2(buf):
global appstartaddr
appstartaddr = None
upper = 0
currblock = None
blocks = []
for line in buf.split('\n'):
if line[0] != ":":
continue
i = 1
rec = []
while i < len(line) - 1:
rec.append(int(line[i:i+2], 16))
i += 2
tp = rec[3]
if tp == 4:
upper = ((rec[4] << 8) | rec[5]) << 16
elif tp == 2:
upper = ((rec[4] << 8) | rec[5]) << 4
elif tp == 1:
break
elif tp == 0:
addr = upper + ((rec[1] << 8) | rec[2])
if appstartaddr == None:
appstartaddr = addr
i = 4
while i < len(rec) - 1:
if not currblock or currblock.addr & ~0xff != addr & ~0xff:
currblock = Block(addr & ~0xff)
blocks.append(currblock)
currblock.bytes[addr & 0xff] = rec[i]
addr += 1
i += 1
numblocks = len(blocks)
resfile = b""
for i in range(0, numblocks):
resfile += blocks[i].encode(i, numblocks)
return resfile
def to_str(b):
return b.decode("utf-8")
def get_drives():
drives = []
if sys.platform == "win32":
r = subprocess.check_output(["wmic", "PATH", "Win32_LogicalDisk",
"get", "DeviceID,", "VolumeName,",
"FileSystem,", "DriveType"])
for line in to_str(r).split('\n'):
words = re.split(r'\s+', line)
if len(words) >= 3 and words[1] == "2" and words[2] == "FAT":
drives.append(words[0])
else:
searchpaths = ["/media"]
if sys.platform == "darwin":
searchpaths = ["/Volumes"]
elif sys.platform == "linux":
searchpaths += ["/media/" + os.environ["USER"], '/run/media/' + os.environ["USER"]]
for rootpath in searchpaths:
if os.path.isdir(rootpath):
for d in os.listdir(rootpath):
if os.path.isdir(rootpath):
drives.append(os.path.join(rootpath, d))
def has_info(d):
try:
return os.path.isfile(d + INFO_FILE)
except:
return False
return list(filter(has_info, drives))
def board_id(path):
with open(path + INFO_FILE, mode='r') as file:
file_content = file.read()
return re.search(r"Board-ID: ([^\r\n]*)", file_content).group(1)
def list_drives():
for d in get_drives():
print(d, board_id(d))
def write_file(name, buf):
with open(name, "wb") as f:
f.write(buf)
print("Wrote %d bytes to %s" % (len(buf), name))
def load_families():
# The expectation is that the `uf2families.json` file is in the same
# directory as this script. Make a path that works using `__file__`
# which contains the full path to this script.
filename = "uf2families.json"
pathname = os.path.join(os.path.dirname(os.path.abspath(__file__)), filename)
with open(pathname) as f:
raw_families = json.load(f)
families = {}
for family in raw_families:
families[family["short_name"]] = int(family["id"], 0)
return families
def main():
global appstartaddr, familyid
def error(msg):
print(msg, file=sys.stderr)
sys.exit(1)
parser = argparse.ArgumentParser(description='Convert to UF2 or flash directly.')
parser.add_argument('input', metavar='INPUT', type=str, nargs='?',
help='input file (HEX, BIN or UF2)')
parser.add_argument('-b', '--base', dest='base', type=str,
default="0x2000",
help='set base address of application for BIN format (default: 0x2000)')
parser.add_argument('-f', '--family', dest='family', type=str,
default="0x0",
help='specify familyID - number or name (default: 0x0)')
parser.add_argument('-o', '--output', metavar="FILE", dest='output', type=str,
help='write output to named file; defaults to "flash.uf2" or "flash.bin" where sensible')
parser.add_argument('-d', '--device', dest="device_path",
help='select a device path to flash')
parser.add_argument('-l', '--list', action='store_true',
help='list connected devices')
parser.add_argument('-c', '--convert', action='store_true',
help='do not flash, just convert')
parser.add_argument('-D', '--deploy', action='store_true',
help='just flash, do not convert')
parser.add_argument('-w', '--wait', action='store_true',
help='wait for device to flash')
parser.add_argument('-C', '--carray', action='store_true',
help='convert binary file to a C array, not UF2')
parser.add_argument('-i', '--info', action='store_true',
help='display header information from UF2, do not convert')
args = parser.parse_args()
appstartaddr = int(args.base, 0)
families = load_families()
if args.family.upper() in families:
familyid = families[args.family.upper()]
else:
try:
familyid = int(args.family, 0)
except ValueError:
error("Family ID needs to be a number or one of: " + ", ".join(families.keys()))
if args.list:
list_drives()
else:
if not args.input:
error("Need input file")
with open(args.input, mode='rb') as f:
inpbuf = f.read()
from_uf2 = is_uf2(inpbuf)
ext = "uf2"
if args.deploy:
outbuf = inpbuf
elif from_uf2 and not args.info:
outbuf = convert_from_uf2(inpbuf)
ext = "bin"
elif from_uf2 and args.info:
outbuf = ""
convert_from_uf2(inpbuf)
elif is_hex(inpbuf):
outbuf = convert_from_hex_to_uf2(inpbuf.decode("utf-8"))
elif args.carray:
outbuf = convert_to_carray(inpbuf)
ext = "h"
else:
outbuf = convert_to_uf2(inpbuf)
if not args.deploy and not args.info:
print("Converted to %s, output size: %d, start address: 0x%x" %
(ext, len(outbuf), appstartaddr))
if args.convert or ext != "uf2":
if args.output == None:
args.output = "flash." + ext
if args.output:
write_file(args.output, outbuf)
if ext == "uf2" and not args.convert and not args.info:
drives = get_drives()
if len(drives) == 0:
if args.wait:
print("Waiting for drive to deploy...")
while len(drives) == 0:
sleep(0.1)
drives = get_drives()
elif not args.output:
error("No drive to deploy.")
for d in drives:
print("Flashing %s (%s)" % (d, board_id(d)))
write_file(d + "/NEW.UF2", outbuf)
if __name__ == "__main__":
main()
+362
View File
@@ -0,0 +1,362 @@
[
{
"id": "0x16573617",
"short_name": "ATMEGA32",
"description": "Microchip (Atmel) ATmega32"
},
{
"id": "0x1851780a",
"short_name": "SAML21",
"description": "Microchip (Atmel) SAML21"
},
{
"id": "0x1b57745f",
"short_name": "NRF52",
"description": "Nordic NRF52"
},
{
"id": "0x1c5f21b0",
"short_name": "ESP32",
"description": "ESP32"
},
{
"id": "0x1e1f432d",
"short_name": "STM32L1",
"description": "ST STM32L1xx"
},
{
"id": "0x202e3a91",
"short_name": "STM32L0",
"description": "ST STM32L0xx"
},
{
"id": "0x21460ff0",
"short_name": "STM32WL",
"description": "ST STM32WLxx"
},
{
"id": "0x22e0d6fc",
"short_name": "RTL8710B",
"description": "Realtek AmebaZ RTL8710B"
},
{
"id": "0x2abc77ec",
"short_name": "LPC55",
"description": "NXP LPC55xx"
},
{
"id": "0x300f5633",
"short_name": "STM32G0",
"description": "ST STM32G0xx"
},
{
"id": "0x31d228c6",
"short_name": "GD32F350",
"description": "GD32F350"
},
{
"id": "0x3379CFE2",
"short_name": "RTL8720D",
"description": "Realtek AmebaD RTL8720D"
},
{
"id": "0x04240bdf",
"short_name": "STM32L5",
"description": "ST STM32L5xx"
},
{
"id": "0x4c71240a",
"short_name": "STM32G4",
"description": "ST STM32G4xx"
},
{
"id": "0x4fb2d5bd",
"short_name": "MIMXRT10XX",
"description": "NXP i.MX RT10XX"
},
{
"id": "0x51e903a8",
"short_name": "XR809",
"description": "Xradiotech 809"
},
{
"id": "0x53b80f00",
"short_name": "STM32F7",
"description": "ST STM32F7xx"
},
{
"id": "0x55114460",
"short_name": "SAMD51",
"description": "Microchip (Atmel) SAMD51"
},
{
"id": "0x57755a57",
"short_name": "STM32F4",
"description": "ST STM32F4xx"
},
{
"id": "0x5a18069b",
"short_name": "FX2",
"description": "Cypress FX2"
},
{
"id": "0x5d1a0a2e",
"short_name": "STM32F2",
"description": "ST STM32F2xx"
},
{
"id": "0x5ee21072",
"short_name": "STM32F1",
"description": "ST STM32F103"
},
{
"id": "0x621e937a",
"short_name": "NRF52833",
"description": "Nordic NRF52833"
},
{
"id": "0x647824b6",
"short_name": "STM32F0",
"description": "ST STM32F0xx"
},
{
"id": "0x675a40b0",
"short_name": "BK7231U",
"description": "Beken 7231U/7231T"
},
{
"id": "0x68ed2b88",
"short_name": "SAMD21",
"description": "Microchip (Atmel) SAMD21"
},
{
"id": "0x6a82cc42",
"short_name": "BK7251",
"description": "Beken 7251/7252"
},
{
"id": "0x6b846188",
"short_name": "STM32F3",
"description": "ST STM32F3xx"
},
{
"id": "0x6d0922fa",
"short_name": "STM32F407",
"description": "ST STM32F407"
},
{
"id": "0x4e8f1c5d",
"short_name": "STM32H5",
"description": "ST STM32H5xx"
},
{
"id": "0x6db66082",
"short_name": "STM32H7",
"description": "ST STM32H7xx"
},
{
"id": "0x70d16653",
"short_name": "STM32WB",
"description": "ST STM32WBxx"
},
{
"id": "0x7b3ef230",
"short_name": "BK7231N",
"description": "Beken 7231N"
},
{
"id": "0x7eab61ed",
"short_name": "ESP8266",
"description": "ESP8266"
},
{
"id": "0x7f83e793",
"short_name": "KL32L2",
"description": "NXP KL32L2x"
},
{
"id": "0x8fb060fe",
"short_name": "STM32F407VG",
"description": "ST STM32F407VG"
},
{
"id": "0x9fffd543",
"short_name": "RTL8710A",
"description": "Realtek Ameba1 RTL8710A"
},
{
"id": "0xada52840",
"short_name": "NRF52840",
"description": "Nordic NRF52840"
},
{
"id": "0x820d9a5f",
"short_name": "NRF52820",
"description": "Nordic NRF52820_xxAA"
},
{
"id": "0xbfdd4eee",
"short_name": "ESP32S2",
"description": "ESP32-S2"
},
{
"id": "0xc47e5767",
"short_name": "ESP32S3",
"description": "ESP32-S3"
},
{
"id": "0xd42ba06c",
"short_name": "ESP32C3",
"description": "ESP32-C3"
},
{
"id": "0x2b88d29c",
"short_name": "ESP32C2",
"description": "ESP32-C2"
},
{
"id": "0x332726f6",
"short_name": "ESP32H2",
"description": "ESP32-H2"
},
{
"id": "0x540ddf62",
"short_name": "ESP32C6",
"description": "ESP32-C6"
},
{
"id": "0x3d308e94",
"short_name": "ESP32P4",
"description": "ESP32-P4"
},
{
"id": "0xf71c0343",
"short_name": "ESP32C5",
"description": "ESP32-C5"
},
{
"id": "0x77d850c4",
"short_name": "ESP32C61",
"description": "ESP32-C61"
},
{
"id": "0xb6dd00af",
"short_name": "ESP32H21",
"description": "ESP32-H21"
},
{
"id": "0x9e0baa8a",
"short_name": "ESP32H4",
"description": "ESP32-H4"
},
{
"id": "0xde1270b7",
"short_name": "BL602",
"description": "Boufallo 602"
},
{
"id": "0xe08f7564",
"short_name": "RTL8720C",
"description": "Realtek AmebaZ2 RTL8720C"
},
{
"id": "0xe48bff56",
"short_name": "RP2040",
"description": "Raspberry Pi RP2040"
},
{
"id": "0xe48bff57",
"short_name": "RP2XXX_ABSOLUTE",
"description": "Raspberry Pi Microcontrollers: Absolute (unpartitioned) download"
},
{
"id": "0xe48bff58",
"short_name": "RP2XXX_DATA",
"description": "Raspberry Pi Microcontrollers: Data partition download"
},
{
"id": "0xe48bff59",
"short_name": "RP2350_ARM_S",
"description": "Raspberry Pi RP2350, Secure Arm image"
},
{
"id": "0xe48bff5a",
"short_name": "RP2350_RISCV",
"description": "Raspberry Pi RP2350, RISC-V image"
},
{
"id": "0xe48bff5b",
"short_name": "RP2350_ARM_NS",
"description": "Raspberry Pi RP2350, Non-secure Arm image"
},
{
"id": "0x00ff6919",
"short_name": "STM32L4",
"description": "ST STM32L4xx"
},
{
"id": "0x9af03e33",
"short_name": "GD32VF103",
"description": "GigaDevice GD32VF103"
},
{
"id": "0x4f6ace52",
"short_name": "CSK4",
"description": "LISTENAI CSK300x/400x"
},
{
"id": "0x6e7348a8",
"short_name": "CSK6",
"description": "LISTENAI CSK60xx"
},
{
"id": "0x11de784a",
"short_name": "M0SENSE",
"description": "M0SENSE BL702"
},
{
"id": "0x4b684d71",
"short_name": "MaixPlay-U4",
"description": "Sipeed MaixPlay-U4(BL618)"
},
{
"id": "0x9517422f",
"short_name": "RZA1LU",
"description": "Renesas RZ/A1LU (R7S7210xx)"
},
{
"id": "0x2dc309c5",
"short_name": "STM32F411xE",
"description": "ST STM32F411xE"
},
{
"id": "0x06d1097b",
"short_name": "STM32F411xC",
"description": "ST STM32F411xC"
},
{
"id": "0x72721d4e",
"short_name": "NRF52832xxAA",
"description": "Nordic NRF52832xxAA"
},
{
"id": "0x6f752678",
"short_name": "NRF52832xxAB",
"description": "Nordic NRF52832xxAB"
},
{
"id": "0xa0c97b8e",
"short_name": "AT32F415",
"description": "ArteryTek AT32F415"
},
{
"id": "0x699b62ec",
"short_name": "CH32V",
"description": "WCH CH32V2xx and CH32V3xx"
},
{
"id": "0x7be8976d",
"short_name": "RA4M1",
"description": "Renesas RA4M1"
}
]
-919
View File
@@ -1,919 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="generator" content="mkdocs-1.6.1, mkdocs-terminal-4.8.0">
<meta name="description" content="MeshCore fork meshcore-tth -- repeater antispam, diagnostics, OTA, Czech mesh defaults">
<link rel="canonical" href="https://tth-pub.pages.rfa.cz/meshcore-tth/ble-lora-coexistence/"><link rel="icon" type="image/png" sizes="192x192" href="../img/android-chrome-192x192.png" />
<link rel="icon" type="image/png" sizes="512x512" href="../img/android-chrome-512x512.png" />
<link rel="apple-touch-icon" sizes="180x180" href="../img/apple-touch-icon.png" />
<link rel="shortcut icon" type="image/png" sizes="48x48" href="../img/favicon.ico" />
<link rel="icon" type="image/png" sizes="16x16" href="../img/favicon-16x16.png" />
<link rel="icon" type="image/png" sizes="32x32" href="../img/favicon-32x32.png" />
<title>BLE/LoRa coexistence - MeshCore TTH</title>
<link href="../css/fontawesome/css/fontawesome.min.css" rel="stylesheet">
<link href="../css/fontawesome/css/solid.min.css" rel="stylesheet">
<link href="../css/normalize.css" rel="stylesheet">
<link href="../css/terminal.css" rel="stylesheet">
<link href="../css/theme.css" rel="stylesheet">
<link href="../css/theme.tile_grid.css" rel="stylesheet">
<link href="../css/theme.footer.css" rel="stylesheet">
<!-- dark color palette -->
<link href="../css/palettes/dark.css" rel="stylesheet">
<!-- page layout -->
<style>
/* initially set page layout to a one column grid */
.terminal-mkdocs-main-grid {
display: grid;
grid-column-gap: 1.4em;
grid-template-columns: auto;
grid-template-rows: auto;
}
/*
* when side navigation is not hidden, use a two column grid.
* if the screen is too narrow, fall back to the initial one column grid layout.
* in this case the main content will be placed under the navigation panel.
*/
@media only screen and (min-width: 70em) {
.terminal-mkdocs-main-grid {
grid-template-columns: 4fr 9fr;
}
}</style>
<!-- cursor_animation override -->
<style>
#mkdocs-terminal-site-name.terminal-prompt::after {
display: none;
}
</style>
<link href="../_stylesheets/tth.css" rel="stylesheet">
<!-- search css support -->
<link href="../css/search/bootstrap-modal.css" rel="stylesheet">
<!-- search scripts -->
<script>
var base_url = "..",
shortcuts = "{}";
</script>
<script src="../js/jquery/jquery-1.10.1.min.js" defer></script>
<script src="../js/bootstrap/bootstrap.min.js" defer></script>
<script src="../js/mkdocs/base.js" defer></script>
<script src="../search/main.js"></script>
</head>
<body class="terminal"><div class="container">
<div class="terminal-nav">
<header class="terminal-logo">
<div id="mkdocs-terminal-site-name" class="logo terminal-prompt"><a href="https://tth-pub.pages.rfa.cz/meshcore-tth/" class="no-style">MeshCore TTH</a></div>
</header>
<nav class="terminal-menu">
<ul vocab="https://schema.org/" typeof="BreadcrumbList">
<li property="itemListElement" typeof="ListItem">
<a href=".." class="menu-item " property="item" typeof="WebPage">
<span property="name">About the fork</span>
</a>
<meta property="position" content="0">
</li>
<li property="itemListElement" typeof="ListItem">
<a href="../cs/" class="menu-item " property="item" typeof="WebPage">
<span property="name">Česky</span>
</a>
<meta property="position" content="1">
</li>
<li property="itemListElement" typeof="ListItem">
<a href="#" class="menu-item" data-toggle="modal" data-target="#mkdocs_search_modal" property="item" typeof="SearchAction">
<i aria-hidden="true" class="fa fa-search"></i> <span property="name">Search</span>
</a>
<meta property="position" content="2">
</li>
</ul>
</nav>
</div>
</div>
<div class="container">
<div class="terminal-mkdocs-main-grid"><aside id="terminal-mkdocs-side-panel"><nav>
<ul class="terminal-mkdocs-side-nav-items">
<li class="terminal-mkdocs-side-nav-li">
<a class="terminal-mkdocs-side-nav-item" href="..">About the fork</a>
</li>
<li class="terminal-mkdocs-side-nav-li">
<a class="terminal-mkdocs-side-nav-item" href="../cs/">Česky</a>
</li>
<li class="terminal-mkdocs-side-nav-li">
<span class="
terminal-mkdocs-side-nav-item--active terminal-mkdocs-side-nav-section-no-index">Fork meshcore-tth</span>
<ul class="terminal-mkdocs-side-nav-li-ul">
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../tth-commands/">Console commands</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../ota/">Firmware update by the admin (OTA)</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../power/">Power saving</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../budka-sensor/">Budka as a sensor</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<span class="terminal-mkdocs-side-nav-item--active">BLE/LoRa coexistence</span>
</li>
</ul>
</li>
<li class="terminal-mkdocs-side-nav-li">
<span class="
terminal-mkdocs-side-nav-item terminal-mkdocs-side-nav-section-no-index">MeshCore (upstream)</span>
<ul class="terminal-mkdocs-side-nav-li-ul">
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../meshcore/">Introduction</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../faq/">FAQ</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../cli_commands/">CLI commands</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../companion_cli/">Companion CLI</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../companion_protocol/">Companion protocol</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../terminal_chat_cli/">Terminal chat CLI</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../kiss_modem_protocol/">KISS modem protocol</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../packet_format/">Packet format</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../payloads/">Payloads</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../stats_binary_frames/">Stats binary frames</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../number_allocations/">Number allocations</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../qr_codes/">QR codes</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../radio_presets/">Radio presets</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../nrf52_power_management/">nRF52 power management</a>
</li>
</ul>
</li>
</ul>
</nav><hr>
<nav>
<ul>
<li><a href="#blelora-coexistence-bench-reproduction-attempt">BLE/LoRa coexistence — bench reproduction attempt</a></li>
<li><a href="#the-claim-under-test">The claim under test</a></li><li><a href="#rig">Rig</a></li><li><a href="#what-was-measured">What was measured</a></li><li><a href="#on-mast-hardware-with-the-file-log-on">On mast hardware, with the file log on</a></li><li><a href="#still-open">Still open</a></li><li><a href="#airtime-is-a-hard-limit-and-the-firmware-will-not-enforce-it">Airtime is a hard limit, and the firmware will not enforce it</a></li><li><a href="#traps-worth-remembering">Traps worth remembering</a></li><li><a href="#the-two-commands-this-bench-added">The two commands this bench added</a></li>
</ul>
</nav>
</aside>
<main id="terminal-mkdocs-main-content">
<section id="mkdocs-terminal-content">
<h1 id="blelora-coexistence-bench-reproduction-attempt">BLE/LoRa coexistence — bench reproduction attempt</h1>
<p>Working notes for the DIRECT-forward loss seen on <code>mast-three</code> (SenseCap Solar,
<code>SenseCap_Solar_repeater_ble</code>). Written down because the result is mostly
<strong>negative</strong>, and a negative result is only worth anything if the method and its
limits are recorded with it.</p>
<h2 id="the-claim-under-test">The claim under test</h2>
<p>Commit <code>f6e9aeca</code> widened the BLE connection interval from 15–30 ms to 60–80 ms
after an A/B on the mast showed ~40 % of DIRECT-route forwards silently lost
with an <strong>idle</strong> BLE connection at 15–30 ms. The stated mechanism is that the
SoftDevice's per-connection-event preemption disturbs the SX126x TX path
(<code>startTransmit</code> fail / send-complete timeout).</p>
<p>The fix is deployed. What was never established is whether a bench rig can
<strong>detect</strong> the effect at all — a measurement that reads zero in both the
treatment and the control has shown nothing.</p>
<h2 id="rig">Rig</h2>
<p>Isolated test mesh on <strong>866.5 MHz</strong> (BW 62.5, SF 8, CR 5). Isolation is by
frequency, not by tx power: a hilltop repeater with <code>RX_BOOSTED_GAIN</code> hears a
few mW just fine. The override is compile-time (<code>platformio.local.ini</code>) because
<code>MyMesh.cpp</code> seeds <code>_prefs.freq</code> from <code>LORA_FREQ</code>, so the firmware cannot come
up on the production frequency even after <code>erase</code>.</p>
<table>
<thead>
<tr>
<th>node</th>
<th>board</th>
<th>role</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>bench-board</code></td>
<td>XIAO nRF52840 + Wio-SX1262</td>
<td>forwarder under test</td>
</tr>
<tr>
<td><code>bench-board</code></td>
<td>same</td>
<td>paired control / radiating witness</td>
</tr>
<tr>
<td><code>bench-board</code>, <code>bench-board</code></td>
<td>same</td>
<td>probe sources</td>
</tr>
<tr>
<td><code>bench-rpt</code></td>
<td>SenseCap Solar Node</td>
<td>forwarder, mast-identical hardware</td>
</tr>
<tr>
<td><code>tth-s2-rpt</code></td>
<td>same</td>
<td>paired control</td>
</tr>
</tbody>
</table>
<p>Paired controls differ <strong>only</strong> in <code>ADVERT_NAME</code>, verified by diffing strings in
the ELF. Any other difference invalidates them.</p>
<h3 id="oracle">Oracle</h3>
<p>The measured quantity is the node's own <code>direct_rx − direct_tx</code> from
<code>stats-packets</code>: how many DIRECT packets it accepted for forwarding versus how
many it actually sent. This is self-normalising — it does not depend on channel
conditions or on a receiver hearing anything. <code>tx_start_fail</code> and <code>tx_timeout</code>
are the mechanism-level counters. A second repeater with <code>repeat off</code> acts as a
radiating witness, so "counted a TX" can be distinguished from "actually
radiated".</p>
<p>Route forcing: a contact is injected into the sender's companion with an
explicit <code>out_path</code>, so the DM must traverse the node under test.
<strong><code>out_path_len</code> is not a hop count</strong> — it is a packed byte, top two bits =
hash size − 1, low six = hop count (<code>Packet.h:85</code>). One hop with a 2-byte hash
is <code>0x41</code>, not <code>1</code>. The receiver reads the size out of the packet
(<code>Mesh.cpp:93</code>), so a forced path works regardless of the node's
<code>path.hash.mode</code>.</p>
<h2 id="what-was-measured">What was measured</h2>
<p>All cells at a <strong>verified</strong> 22.50 ms connection interval — <code>bleconn</code> reports the
parameters actually negotiated, because <code>bleOnSecured()</code> only requests them and
the central may refuse. Without that read-back none of the null results below
would mean anything.</p>
<table>
<thead>
<tr>
<th style="text-align: right;"><code>blepwr</code></th>
<th style="text-align: right;">≈RSSI at central</th>
<th style="text-align: right;">link up</th>
<th style="text-align: right;">direct_rx</th>
<th style="text-align: right;">direct_tx</th>
<th style="text-align: right;">lost</th>
<th style="text-align: right;">tx_timeout</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: right;">BLE off</td>
<td style="text-align: right;">—</td>
<td style="text-align: right;">—</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td style="text-align: right;">0 dBm</td>
<td style="text-align: right;">−67</td>
<td style="text-align: right;">100 %</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td style="text-align: right;">−8</td>
<td style="text-align: right;">−75</td>
<td style="text-align: right;">100 %</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td style="text-align: right;">−12</td>
<td style="text-align: right;">−79</td>
<td style="text-align: right;">100 %</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td style="text-align: right;">−16</td>
<td style="text-align: right;">−83</td>
<td style="text-align: right;">87 %</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td style="text-align: right;">−20</td>
<td style="text-align: right;">−87</td>
<td style="text-align: right;">27 %</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
</tr>
</tbody>
</table>
<p>The −20 dBm row is a bonus condition: the link held only a quarter of the
window, so the node spent the rest advertising and re-connecting — close to the
reconnect churn the mast reports as HCI 0x3E.</p>
<p><strong>Ruled out as the missing factor: BLE link margin.</strong> The whole −75..−90 window
the mast sits in is covered, at the known-bad interval, with zero loss.</p>
<h3 id="why-idle-weak-link-does-nothing">Why idle + weak link does nothing</h3>
<p>In idle the connection events carry empty PDUs, whose retransmission costs
almost no radio time. The cost of a retransmission scales with payload size, and
the mast has a bridge actively draining the console. Hence the <code>poll</code> mode in
the harness.</p>
<p>Direction matters too, and it is the reason to weaken <strong>our</strong> side rather than
the central's: a connection event ends as soon as either side misses a packet,
so if the central misses our PDU we must re-send it at the next anchor — an
extra slave TX. If we miss the central's PDU we never transmit in that event at
all, and the SoftDevice uses <em>less</em> radio.</p>
<h2 id="on-mast-hardware-with-the-file-log-on">On mast hardware, with the file log on</h2>
<p>Two SenseCap Solar nodes (<code>bench-rpt</code> forwarder, <code>tth-s2-rpt</code> paired control) —
the same board as the mast, so InternalFS logging, INA226/solar telemetry and
the SenseCap SPI layout are all in play. Again at a verified 22.50 ms interval
(<code>bleconn</code>).</p>
<table>
<thead>
<tr>
<th>file log</th>
<th>BLE</th>
<th style="text-align: right;">direct_rx</th>
<th style="text-align: right;">direct_tx</th>
<th style="text-align: right;">lost</th>
<th style="text-align: right;">tx_timeout</th>
<th style="text-align: right;">witness</th>
</tr>
</thead>
<tbody>
<tr>
<td>off</td>
<td>off</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">+39</td>
</tr>
<tr>
<td>off</td>
<td>idle, 88 % of window</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">+37</td>
</tr>
<tr>
<td><strong>on</strong></td>
<td>off</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">+39</td>
</tr>
<tr>
<td><strong>on</strong></td>
<td>idle, 90 % of window</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">+40</td>
</tr>
</tbody>
</table>
<p>The logging condition was real, not nominal: <code>log</code> afterwards held 69 entries
with RX/TX lines timestamped inside the measurement window, i.e. an InternalFS
write per packet — the mechanism behind the known deaf windows.</p>
<p><strong>Ten cells, 80 forced forwards, zero lost, <code>tx_timeout</code> and <code>tx_start_fail</code> at
zero throughout.</strong> Against the mast's reported ~40 % loss rate this is not a
weak null: a single 8-probe cell would miss a true 40 % effect with probability
0.6⁸ ≈ 1.7 %, and ten cells make it vanishing. Whatever the mast is doing, it is
not reproduced by the connection interval, the BLE link margin, the board, or
InternalFS logging — alone or together.</p>
<h2 id="still-open">Still open</h2>
<p><strong>Loaded LoRa channel</strong> is the one uncontrolled difference left. Ours is idle;
the mast relays flood traffic, so its forwards contend for a busy channel and
the TX window lands on a BLE connection event far more often. This cannot be
tested legally here: 866.5 is capped at 1 % duty and the 10 % sub-band
(869.4–869.65) is where production lives.</p>
<p>Practical consequence: <strong>f6e9aeca can be neither confirmed nor refuted on the
bench.</strong> Deciding whether the 60–80 ms interval is still needed requires
measuring on <code>mast-three</code> itself — the counters (<code>stats-packets</code>, and now
<code>bleconn</code> to prove which interval is actually in force) are all reachable over
its BLE console.</p>
<h2 id="airtime-is-a-hard-limit-and-the-firmware-will-not-enforce-it">Airtime is a hard limit, and the firmware will not enforce it</h2>
<p>866.5 MHz sits in 865–868 (CZ VO-R/10): 25 mW ERP, <strong>1 % duty cycle = 36 s of
transmission per hour</strong>. The firmware does not police this — <code>airtime_factor</code>
defaults to 0 (= 100 %) and is clamped to 9, so the lowest duty MeshCore can
enforce is 10 %. The first sweep consumed <code>tx_air_secs</code> 27 s in 18 minutes of
uptime, a rate of ~2.5 %. Budget the probes: <code>stats-radio.tx_air_secs</code> is the
ground truth, and the harness aborts before crossing a configured cap.</p>
<p><code>stats-core.queue_len</code> and <code>errors</code> are a required control, not decoration: when
the airtime budget runs out the Dispatcher <strong>defers</strong> a forward
(<code>next_tx_time</code>, <code>Dispatcher.cpp:101</code>), which looks identical to loss in the
counters. Both were zero throughout.</p>
<h2 id="traps-worth-remembering">Traps worth remembering</h2>
<ul>
<li><strong>USB and BLE consoles share one <code>command[160]</code>.</strong> Two concurrent consoles
interleave into one line and crash the node. The harness keeps a strict
sequence: counters over USB → close USB → BLE client → probes → stop BLE →
counters over USB.</li>
<li><strong><code>Bluefruit.setTxPower()</code> is advertising-only</strong> (see the commit message for
<code>blepwr</code>); the connection runs at the SoftDevice default 0 dBm.</li>
<li><strong>Weakening the link can lock you out of BLE.</strong> Below about −16 dBm the
node's replies stop arriving and the value is re-applied on every reconnect
(and, since 6. 10. 2026, saved). The way back is <code>blepwr</code> over the mesh admin
CLI.</li>
<li><strong>~~Runtime <code>set tx</code> does not change radiated LoRa power~~ — retracted.</strong> The
original reading (+2 dBm → RSSI −44.1, −9 dBm → −44.0) was made with an
instrument that could not report failure: <code>RadioLibWrapper::setTxPower()</code>
discarded RadioLib's status, so a refused request looked exactly like an
accepted one. Re-measured 2026-08-04 on the repeater build with <code>txpwr</code>
confirming each step, x1 transmitting and x4 as witness:</li>
</ul>
<table>
<thead>
<tr>
<th style="text-align: right;"><code>txpwr</code></th>
<th style="text-align: right;">witness <code>last_rssi</code></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: right;">+22</td>
<td style="text-align: right;">0 dBm <em>(saturated)</em></td>
</tr>
<tr>
<td style="text-align: right;">+14</td>
<td style="text-align: right;">−1 dBm <em>(saturated)</em></td>
</tr>
<tr>
<td style="text-align: right;">+6</td>
<td style="text-align: right;">−7 dBm</td>
</tr>
<tr>
<td style="text-align: right;">0</td>
<td style="text-align: right;">−18 dBm</td>
</tr>
<tr>
<td style="text-align: right;">−9</td>
<td style="text-align: right;">−28 dBm</td>
</tr>
</tbody>
</table>
<p>31 dB of command produced 28 dB of RSSI, and the witness <code>recv</code> counter rose
by one at every step, so no point was missed. Radiated power does follow the
setting. The top two points are saturated — the boards were ~10 cm apart — so
the usable range of that particular rig starts around +6 dBm; characterising
the top end needs attenuation or distance, not a bigger number.</p>
<p>The lesson is not about tx power. It is that a null result from an instrument
which cannot distinguish "refused" from "no effect" is not a result at all.</p>
<h2 id="the-two-commands-this-bench-added">The two commands this bench added</h2>
<p>Both live in <code>examples/simple_repeater/main.cpp</code> and are repeater-only.</p>
<h3 id="bleconn-what-the-link-is-actually-doing"><code>bleconn</code> — what the link is actually doing</h3>
<div class="highlight"><pre><span></span><code>bleconn
-&gt; BLE conn: interval 75.00 ms (req 60-80), latency 0, sup timeout 4000 ms [live]
</code></pre></div>
<p>Reports the <strong>negotiated</strong> connection parameters, not the requested ones. The
central is free to ignore a peripheral's request, so this is the only way to
know whether a change like <code>f6e9aeca</code> (widening the requested interval to
60–80 ms) is in force on a node you cannot see. The trailing <code>[live]</code> /
<code>[last]</code> says whether a client is connected right now or these are the values
from the last one; before any client has ever connected it answers
<code>nothing seen yet</code>.</p>
<h3 id="blepwr-dbm-connection-tx-power-saved"><code>blepwr [dBm]</code> — connection TX power, saved</h3>
<div class="highlight"><pre><span></span><code>blepwr # report: BLE conn tx: 0 dBm, adv tx: 8 dBm
blepwr 8 # set, apply to live connections and save
blepwr default # forget the saved value, back to RPT_BLE_CONN_TX_POWER
</code></pre></div>
<p>The reply carries how many live connections accepted the value
(<code>OK - BLE conn tx 8 dBm (1/1 conn), saved</code>) because the nRF52840 only takes
−40, −20, −16, −12, −8, −4, 0 and 2..8 dBm; anything else is rejected and is
<em>not</em> latched or saved, so a typo cannot arm itself for the next reconnect.
The value lives in <code>/ble_pwr</code> in InternalFS, so it survives a reboot and also a
reflash with a different build default: an explicit value is pinned even when
it equals the default (no file = follow <code>RPT_BLE_CONN_TX_POWER</code>, which
mast-three's env sets to 8).</p>
<p>Sets <code>BLE_GAP_TX_POWER_ROLE_CONN</code>, which is <strong>independent of</strong>
<code>Bluefruit.setTxPower()</code> — that one only affects advertising, despite reading
like a global. The connection otherwise runs at the SoftDevice default of
0 dBm; the compile-time starting value is <code>RPT_BLE_CONN_TX_POWER</code>.</p>
<p>The value is re-applied on every 'secured' event and saved, so a setting weak
enough to break the link persists across reconnects and reboots — at −40 dBm
during this bench it locked the BLE console out. Fix it over the mesh admin
CLI (<code>blepwr 0</code>), which does not depend on BLE. Until 6. 10. 2026 a weakening
auto-reverted after 5 minutes and nothing was saved; that went away once the
value started to be saved, because a revert that the next reboot undoes again
only made the state harder to read.</p>
</section>
</main>
</div>
<hr><footer>
<div class="terminal-mkdocs-footer-grid">
<div id="terminal-mkdocs-footer-copyright-info">
Site built with <a href="http://www.mkdocs.org">MkDocs</a> and <a href="https://github.com/ntno/mkdocs-terminal">Terminal for MkDocs</a>.
</div>
</div>
</footer>
</div>
<div class="modal" id="mkdocs_search_modal" tabindex="-1" role="alertdialog" aria-modal="true" aria-labelledby="searchModalLabel">
<div class="modal-dialog modal-lg" role="search">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="searchModalLabel">Search</h5>
<button type="button" class="close btn btn-default btn-ghost" data-dismiss="modal" aria-label="Close">x</button>
</div>
<div class="modal-body">
<p id="searchInputLabel">Type to start searching</p>
<form>
<div class="form-group">
<input type="search" class="form-control" aria-labelledby="searchInputLabel" placeholder="" id="mkdocs-search-query" title="Please enter search terms here">
</div>
</form>
<div id="mkdocs-search-results" data-no-results-text="No document matches found"></div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</body>
</html>
+60
View File
@@ -0,0 +1,60 @@
{
"build": {
"arduino": {
"ldscript": "nrf52840_s140_v6.ld"
},
"core": "nRF5",
"cpu": "cortex-m4",
"extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA",
"f_cpu": "64000000L",
"hwids": [
["0x239A","0x8029"],
["0x239A","0x0029"],
["0x239A","0x002A"],
["0x239A","0x802A"]
],
"usb_product": "HT-n5262",
"mcu": "nrf52840",
"variant": "Heltec_T114_Board",
"bsp": {
"name": "adafruit"
},
"softdevice": {
"sd_flags": "-DS140",
"sd_name": "s140",
"sd_version": "6.1.1",
"sd_fwid": "0x00B6"
},
"bootloader": {
"settings_addr": "0xFF000"
}
},
"connectivity": [
"bluetooth"
],
"debug": {
"jlink_device": "nRF52840_xxAA",
"svd_path": "nrf52840.svd"
},
"frameworks": [
"arduino"
],
"name": "Heltec T114 Board",
"upload": {
"maximum_ram_size": 248832,
"maximum_size": 815104,
"speed": 115200,
"protocol": "nrfutil",
"protocols": [
"jlink",
"nrfjprog",
"nrfutil",
"stlink"
],
"use_1200bps_touch": true,
"require_upload_port": true,
"wait_for_upload_port": true
},
"url": "https://heltec.org/",
"vendor": "Heltec"
}
+38
View File
@@ -0,0 +1,38 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
MEMORY
{
FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0xED000 - 0x26000
/* SRAM required by Softdevice depend on
* - Attribute Table Size (Number of Services and Characteristics)
* - Vendor UUID count
* - Max ATT MTU
* - Concurrent connection peripheral + central + secure links
* - Event Len, HVN queue, Write CMD queue
*/
RAM (rwx) : ORIGIN = 0x20006000, LENGTH = 0x20040000 - 0x20006000
}
SECTIONS
{
. = ALIGN(4);
.svc_data :
{
PROVIDE(__start_svc_data = .);
KEEP(*(.svc_data))
PROVIDE(__stop_svc_data = .);
} > RAM
.fs_data :
{
PROVIDE(__start_fs_data = .);
KEEP(*(.fs_data))
PROVIDE(__stop_fs_data = .);
} > RAM
} INSERT AFTER .data;
INCLUDE "nrf52_common.ld"
+38
View File
@@ -0,0 +1,38 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
MEMORY
{
FLASH (rx) : ORIGIN = 0x27000, LENGTH = 0xED000 - 0x27000
/* SRAM required by Softdevice depend on
* - Attribute Table Size (Number of Services and Characteristics)
* - Vendor UUID count
* - Max ATT MTU
* - Concurrent connection peripheral + central + secure links
* - Event Len, HVN queue, Write CMD queue
*/
RAM (rwx) : ORIGIN = 0x20006000, LENGTH = 0x20040000 - 0x20006000
}
SECTIONS
{
. = ALIGN(4);
.svc_data :
{
PROVIDE(__start_svc_data = .);
KEEP(*(.svc_data))
PROVIDE(__stop_svc_data = .);
} > RAM
.fs_data :
{
PROVIDE(__start_fs_data = .);
KEEP(*(.fs_data))
PROVIDE(__stop_fs_data = .);
} > RAM
} INSERT AFTER .data;
INCLUDE "nrf52_common.ld"
+78
View File
@@ -0,0 +1,78 @@
{
"build": {
"arduino":{
"ldscript": "nrf52840_s140_v6.ld"
},
"core": "nRF5",
"cpu": "cortex-m4",
"extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA",
"f_cpu": "64000000L",
"hwids": [
[
"0x239A",
"0x00B3"
],
[
"0x239A",
"0x8029"
],
[
"0x239A",
"0x0029"
],
[
"0x239A",
"0x002A"
],
[
"0x239A",
"0x802A"
]
],
"usb_product": "ProMicro NRF52840",
"mcu": "nrf52840",
"variant": "promicro_nrf52840",
"variants_dir": "variants",
"bsp": {
"name": "adafruit"
},
"softdevice": {
"sd_flags": "-DS140",
"sd_name": "s140",
"sd_version": "6.1.1",
"sd_fwid": "0x00B6"
},
"bootloader": {
"settings_addr": "0xFF000"
}
},
"connectivity": [
"bluetooth"
],
"debug": {
"jlink_device": "nRF52840_xxAA",
"svd_path": "nrf52840.svd"
},
"frameworks": [
"arduino",
"zephyr"
],
"name": "ProMicro NRF52840",
"upload": {
"maximum_ram_size": 248832,
"maximum_size": 815104,
"speed": 115200,
"protocol": "nrfutil",
"protocols": [
"jlink",
"nrfjprog",
"nrfutil",
"stlink"
],
"use_1200bps_touch": true,
"require_upload_port": true,
"wait_for_upload_port": true
},
"url": "https://www.nologo.tech/en/product/otherboard/NRF52840.html",
"vendor": "Nologo"
}
+43
View File
@@ -0,0 +1,43 @@
{
"build": {
"arduino": {
"ldscript": "esp32s3_out.ld",
"memory_type": "qio_opi"
},
"core": "esp32",
"extra_flags": [
"-DBOARD_HAS_PSRAM",
"-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_USB_MODE=0",
"-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=0"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "qio",
"hwids": [["0x303A", "0x1001"]],
"mcu": "esp32s3",
"variant": "esp32s3"
},
"connectivity": [
"wifi"
],
"debug": {
"default_tool": "esp-builtin",
"onboard_tools": ["esp-builtin"],
"openocd_target": "esp32s3.cfg"
},
"frameworks": ["arduino", "espidf"],
"name": "BQ Station G2",
"upload": {
"flash_size": "16MB",
"maximum_ram_size": 327680,
"maximum_size": 16777216,
"use_1200bps_touch": true,
"wait_for_upload_port": true,
"require_upload_port": true,
"speed": 921600
},
"url": "https://wiki.uniteng.com/en/meshtastic/station-g2",
"vendor": "BQ Consulting"
}
+62
View File
@@ -0,0 +1,62 @@
{
"build": {
"arduino": {
"ldscript": "nrf52840_s140_v6.ld"
},
"core": "nRF5",
"cpu": "cortex-m4",
"extra_flags": "-DARDUINO_NRF52840_PCA10056 -DNRF52840_XXAA",
"f_cpu": "64000000L",
"hwids": [
[
"0x239A",
"0x8029"
]
],
"usb_product": "NRF52 DK",
"mcu": "nrf52840",
"variant": "pca10056",
"bsp": {
"name": "adafruit"
},
"softdevice": {
"sd_flags": "-DS140",
"sd_name": "s140",
"sd_version": "6.1.1",
"sd_fwid": "0x00B6"
},
"bootloader": {
"settings_addr": "0xFF000"
}
},
"connectivity": [
"bluetooth"
],
"debug": {
"jlink_device": "nRF52840_xxAA",
"onboard_tools": [
"jlink"
],
"svd_path": "nrf52840.svd"
},
"frameworks": [
"arduino"
],
"name": "LilyGo T-ECHO",
"upload": {
"maximum_ram_size": 248832,
"maximum_size": 815104,
"require_upload_port": true,
"speed": 115200,
"protocol": "jlink",
"protocols": [
"jlink",
"nrfjprog",
"stlink",
"cmsis-dap",
"blackmagic"
]
},
"url": "https://os.mbed.com/platforms/Nordic-nRF52840-DK/",
"vendor": "Nordic"
}
+45
View File
@@ -0,0 +1,45 @@
{
"build": {
"arduino": {
"ldscript": "esp32s3_out.ld",
"partitions": "default.csv",
"memory_type": "qio_qspi"
},
"core": "esp32",
"extra_flags": [
"-DARDUINO_LILYGO_T3_S3_V1_X",
"-DBOARD_HAS_PSRAM",
"-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1",
"-DARDUINO_USB_MODE=1"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "qio",
"mcu": "esp32s3",
"variant": "esp32s3"
},
"connectivity": [
"wifi"
],
"debug": {
"openocd_target": "esp32s3.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "LilyGo T3-S3 Radio",
"upload": {
"flash_size": "4MB",
"maximum_ram_size": 327680,
"maximum_size": 4194304,
"use_1200bps_touch": true,
"wait_for_upload_port": true,
"require_upload_port": true,
"speed": 460800
},
"url": "https://www.lilygo.cc",
"vendor": "LilyGo"
}
+58
View File
@@ -0,0 +1,58 @@
{
"build": {
"arduino": {
"ldscript": "nrf52840_s140_v7.ld"
},
"core": "nRF5",
"cpu": "cortex-m4",
"extra_flags": "-DARDUINO_WIO_WM1110 -DNRF52840_XXAA",
"f_cpu": "64000000L",
"hwids": [
["0x239A", "0x8029"],
["0x239A", "0x0029"],
["0x239A", "0x002A"],
["0x239A", "0x802A"]
],
"usb_product": "T1000-E-BOOT",
"mcu": "nrf52840",
"variant": "Seeed_T1000-E",
"bsp": {
"name": "adafruit"
},
"softdevice": {
"sd_flags": "-DS140",
"sd_name": "s140",
"sd_version": "7.3.0",
"sd_fwid": "0x0123"
},
"bootloader": {
"settings_addr": "0xFF000"
}
},
"connectivity": ["bluetooth"],
"debug": {
"jlink_device": "nRF52840_xxAA",
"svd_path": "nrf52840.svd"
},
"frameworks": ["arduino"],
"name": "Seeed T1000-E",
"upload": {
"maximum_ram_size": 248832,
"maximum_size": 815104,
"speed": 115200,
"protocol": "nrfutil",
"protocols": [
"jlink",
"nrfjprog",
"nrfutil",
"stlink",
"cmsis-dap",
"blackmagic"
],
"use_1200bps_touch": true,
"require_upload_port": true,
"wait_for_upload_port": true
},
"url": "https://www.seeedstudio.com/SenseCAP-Card-Tracker-T1000-E-for-Meshtastic-p-5913.html",
"vendor": "Seeed Studio"
}
-640
View File
@@ -1,640 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="generator" content="mkdocs-1.6.1, mkdocs-terminal-4.8.0">
<meta name="description" content="MeshCore fork meshcore-tth -- repeater antispam, diagnostics, OTA, Czech mesh defaults">
<link rel="canonical" href="https://tth-pub.pages.rfa.cz/meshcore-tth/budka-sensor/"><link rel="icon" type="image/png" sizes="192x192" href="../img/android-chrome-192x192.png" />
<link rel="icon" type="image/png" sizes="512x512" href="../img/android-chrome-512x512.png" />
<link rel="apple-touch-icon" sizes="180x180" href="../img/apple-touch-icon.png" />
<link rel="shortcut icon" type="image/png" sizes="48x48" href="../img/favicon.ico" />
<link rel="icon" type="image/png" sizes="16x16" href="../img/favicon-16x16.png" />
<link rel="icon" type="image/png" sizes="32x32" href="../img/favicon-32x32.png" />
<title>Budka as a sensor - MeshCore TTH</title>
<link href="../css/fontawesome/css/fontawesome.min.css" rel="stylesheet">
<link href="../css/fontawesome/css/solid.min.css" rel="stylesheet">
<link href="../css/normalize.css" rel="stylesheet">
<link href="../css/terminal.css" rel="stylesheet">
<link href="../css/theme.css" rel="stylesheet">
<link href="../css/theme.tile_grid.css" rel="stylesheet">
<link href="../css/theme.footer.css" rel="stylesheet">
<!-- dark color palette -->
<link href="../css/palettes/dark.css" rel="stylesheet">
<!-- page layout -->
<style>
/* initially set page layout to a one column grid */
.terminal-mkdocs-main-grid {
display: grid;
grid-column-gap: 1.4em;
grid-template-columns: auto;
grid-template-rows: auto;
}
/*
* when side navigation is not hidden, use a two column grid.
* if the screen is too narrow, fall back to the initial one column grid layout.
* in this case the main content will be placed under the navigation panel.
*/
@media only screen and (min-width: 70em) {
.terminal-mkdocs-main-grid {
grid-template-columns: 4fr 9fr;
}
}</style>
<!-- cursor_animation override -->
<style>
#mkdocs-terminal-site-name.terminal-prompt::after {
display: none;
}
</style>
<link href="../_stylesheets/tth.css" rel="stylesheet">
<!-- search css support -->
<link href="../css/search/bootstrap-modal.css" rel="stylesheet">
<!-- search scripts -->
<script>
var base_url = "..",
shortcuts = "{}";
</script>
<script src="../js/jquery/jquery-1.10.1.min.js" defer></script>
<script src="../js/bootstrap/bootstrap.min.js" defer></script>
<script src="../js/mkdocs/base.js" defer></script>
<script src="../search/main.js"></script>
</head>
<body class="terminal"><div class="container">
<div class="terminal-nav">
<header class="terminal-logo">
<div id="mkdocs-terminal-site-name" class="logo terminal-prompt"><a href="https://tth-pub.pages.rfa.cz/meshcore-tth/" class="no-style">MeshCore TTH</a></div>
</header>
<nav class="terminal-menu">
<ul vocab="https://schema.org/" typeof="BreadcrumbList">
<li property="itemListElement" typeof="ListItem">
<a href=".." class="menu-item " property="item" typeof="WebPage">
<span property="name">About the fork</span>
</a>
<meta property="position" content="0">
</li>
<li property="itemListElement" typeof="ListItem">
<a href="../cs/" class="menu-item " property="item" typeof="WebPage">
<span property="name">Česky</span>
</a>
<meta property="position" content="1">
</li>
<li property="itemListElement" typeof="ListItem">
<a href="#" class="menu-item" data-toggle="modal" data-target="#mkdocs_search_modal" property="item" typeof="SearchAction">
<i aria-hidden="true" class="fa fa-search"></i> <span property="name">Search</span>
</a>
<meta property="position" content="2">
</li>
</ul>
</nav>
</div>
</div>
<div class="container">
<div class="terminal-mkdocs-main-grid"><aside id="terminal-mkdocs-side-panel"><nav>
<ul class="terminal-mkdocs-side-nav-items">
<li class="terminal-mkdocs-side-nav-li">
<a class="terminal-mkdocs-side-nav-item" href="..">About the fork</a>
</li>
<li class="terminal-mkdocs-side-nav-li">
<a class="terminal-mkdocs-side-nav-item" href="../cs/">Česky</a>
</li>
<li class="terminal-mkdocs-side-nav-li">
<span class="
terminal-mkdocs-side-nav-item--active terminal-mkdocs-side-nav-section-no-index">Fork meshcore-tth</span>
<ul class="terminal-mkdocs-side-nav-li-ul">
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../tth-commands/">Console commands</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../ota/">Firmware update by the admin (OTA)</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../power/">Power saving</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<span class="terminal-mkdocs-side-nav-item--active">Budka as a sensor</span>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../ble-lora-coexistence/">BLE/LoRa coexistence</a>
</li>
</ul>
</li>
<li class="terminal-mkdocs-side-nav-li">
<span class="
terminal-mkdocs-side-nav-item terminal-mkdocs-side-nav-section-no-index">MeshCore (upstream)</span>
<ul class="terminal-mkdocs-side-nav-li-ul">
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../meshcore/">Introduction</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../faq/">FAQ</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../cli_commands/">CLI commands</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../companion_cli/">Companion CLI</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../companion_protocol/">Companion protocol</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../terminal_chat_cli/">Terminal chat CLI</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../kiss_modem_protocol/">KISS modem protocol</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../packet_format/">Packet format</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../payloads/">Payloads</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../stats_binary_frames/">Stats binary frames</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../number_allocations/">Number allocations</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../qr_codes/">QR codes</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../radio_presets/">Radio presets</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../nrf52_power_management/">nRF52 power management</a>
</li>
</ul>
</li>
</ul>
</nav><hr>
<nav>
<ul>
<li><a href="#budka-link-a-chytra-budka-as-a-sensor-source">Budka link — a Chytra Budka as a sensor source</a></li>
<li><a href="#build">Build</a></li><li><a href="#wiring">Wiring</a></li><li><a href="#telemetry-layout">Telemetry layout</a></li><li><a href="#bench-result-13-10-2026">Bench result (13. 10. 2026)</a></li><li><a href="#not-done">Not done</a></li>
</ul>
</nav>
</aside>
<main id="terminal-mkdocs-main-content">
<section id="mkdocs-terminal-content">
<h1 id="budka-link-a-chytra-budka-as-a-sensor-source">Budka link — a Chytra Budka as a sensor source</h1>
<p>A Chytra Budka (ESP32-S3 bird box) sends its readings over a one-way UART line
to a XIAO nRF52840 running <code>simple_sensor</code>; the sensor serves them as
CayenneLPP telemetry to anyone on the mesh. The line format and the budka side
are documented in the chytra-budka repo, <code>firmware/MESHCORE.md</code>.</p>
<h2 id="build">Build</h2>
<p><code>BudkaLinkSensorManager</code> (<code>src/helpers/sensors/</code>) replaces the variant's
<code>EnvironmentSensorManager</code> when the env defines <code>BUDKA_LINK_RX_PIN</code>; every
other env is unchanged.</p>
<div class="highlight"><pre><span></span><code><span class="na">[env</span><span class="o">:</span><span class="s">Xiao_x1_budka]</span><span class="w"> </span><span class="c1">; platformio.local.ini</span>
<span class="na">extends</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">env:Xiao_nrf52_sensor</span>
<span class="na">build_flags</span><span class="w"> </span><span class="o">=</span>
<span class="w"> </span><span class="na">${env</span><span class="o">:</span><span class="s">Xiao_nrf52_sensor.build_flags}</span>
<span class="w"> </span><span class="na">${test_radio.build_flags} ; bench</span><span class="o">:</span><span class="w"> </span><span class="s">test band only</span>
<span class="w"> </span><span class="na">-D BUDKA_LINK_RX_PIN</span><span class="o">=</span><span class="s">0</span><span class="w"> </span><span class="c1">; D0 = the only pad LoRa + I²C leave free</span>
</code></pre></div>
<p>Optional: <code>BUDKA_LINK_TX_PIN</code> (default <code>LED_GREEN</code> — nothing is ever sent, the
idle-high line keeps that LED dark), <code>BUDKA_LINK_BAUD</code> (115200),
<code>BUDKA_LINK_METERS</code> (3), <code>BUDKA_LINK_STALE_MS</code> (120 s).</p>
<h2 id="wiring">Wiring</h2>
<p>Budka <code>mc_tx</code> pad → XIAO <strong>D0</strong>, GND ↔ GND, each board on its own USB. A
1 kΩ series resistor protects against back-powering when one side is off.</p>
<h2 id="telemetry-layout">Telemetry layout</h2>
<table>
<thead>
<tr>
<th>channel</th>
<th>content</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>the node itself</td>
</tr>
<tr>
<td>next</td>
<td>budka: temperature, humidity, pressure, motion count (generic sensor)</td>
</tr>
<tr>
<td>next + k</td>
<td>UC96 meter <em>k</em>: voltage, current, power (analog input), energy (kWh)</td>
</tr>
</tbody>
</table>
<p>A line with a bad checksum is dropped whole; a value not refreshed for 2 min is
left out. Meter channels stay reserved while a meter is missing.</p>
<p>Read it with <code>.tth/tools/budka_telem.py &lt;companion-port&gt; &lt;sensor-name&gt;</code>. The sensor
answers only clients in its ACL — a request from anyone else is dropped
(<code>recv matches no peers</code> in a <code>MESH_DEBUG</code> build). Add the companion from the
sensor's USB console with <code>setperm &lt;companion-pubkey&gt; 1</code>, or log in as admin.
The port may be a pyserial URL (<code>socket://…</code> for an openHop companion), and the
name may be the sensor's public key when the companion does not have it yet.</p>
<h2 id="bench-result-13-10-2026">Bench result (13. 10. 2026)</h2>
<p>x1 (sensor, test band) fed by the bench budka; x4 as USB companion:</p>
<div class="highlight"><pre><span></span><code>ch2 temp_C 25.3 humidity_% 59.0 generic 29
ch3 voltage_V 4.94 current_A 0.10 analog_in 0.49 energy_kWh 0.111
ch4 voltage_V 4.94 current_A 0.18 analog_in 0.89 energy_kWh 0.311
</code></pre></div>
<h2 id="not-done">Not done</h2>
<p>Alerts (reed opened, budka WiFi down) and the return direction (mesh → budka).
The sensor build has no <code>dfu</code> console command — reflash with
<code>pio run -t upload</code>, one touch per power session.</p>
</section>
</main>
</div>
<hr><footer>
<div class="terminal-mkdocs-footer-grid">
<div id="terminal-mkdocs-footer-copyright-info">
Site built with <a href="http://www.mkdocs.org">MkDocs</a> and <a href="https://github.com/ntno/mkdocs-terminal">Terminal for MkDocs</a>.
</div>
</div>
</footer>
</div>
<div class="modal" id="mkdocs_search_modal" tabindex="-1" role="alertdialog" aria-modal="true" aria-labelledby="searchModalLabel">
<div class="modal-dialog modal-lg" role="search">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="searchModalLabel">Search</h5>
<button type="button" class="close btn btn-default btn-ghost" data-dismiss="modal" aria-label="Close">x</button>
</div>
<div class="modal-body">
<p id="searchInputLabel">Type to start searching</p>
<form>
<div class="form-group">
<input type="search" class="form-control" aria-labelledby="searchInputLabel" placeholder="" id="mkdocs-search-query" title="Please enter search terms here">
</div>
</form>
<div id="mkdocs-search-results" data-no-results-text="No document matches found"></div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</body>
</html>
+156
View File
@@ -0,0 +1,156 @@
#!/usr/bin/env bash
# usage
# sh build.sh build-firmware RAK_4631_Repeater
# sh build.sh build-firmwares
# sh build.sh build-companion-firmwares
# sh build.sh build-repeater-firmwares
# sh build.sh build-room-server-firmwares
# get a list of pio env names that start with "env:"
get_pio_envs() {
echo $(pio project config | grep 'env:' | sed 's/env://')
}
# $1 should be the string to find (case insensitive)
get_pio_envs_containing_string() {
shopt -s nocasematch
envs=($(get_pio_envs))
for env in "${envs[@]}"; do
if [[ "$env" == *${1}* ]]; then
echo $env
fi
done
}
# build firmware for the provided pio env in $1
build_firmware() {
# get git commit sha
COMMIT_HASH=$(git rev-parse --short HEAD)
# set firmware build date
FIRMWARE_BUILD_DATE=$(date '+%d-%b-%Y')
# get FIRMWARE_VERSION, which should be provided by the environment
if [ -z "$FIRMWARE_VERSION" ]; then
echo "FIRMWARE_VERSION must be set in environment"
exit 1
fi
# set firmware version string
# e.g: v1.0.0-abcdef
FIRMWARE_VERSION_STRING="${FIRMWARE_VERSION}-${COMMIT_HASH}"
# craft filename
# e.g: RAK_4631_Repeater-v1.0.0-SHA
FIRMWARE_FILENAME="$1-${FIRMWARE_VERSION_STRING}"
# export build flags for pio so we can inject firmware version info
export PLATFORMIO_BUILD_FLAGS="-DFIRMWARE_BUILD_DATE='\"${FIRMWARE_BUILD_DATE}\"' -DFIRMWARE_VERSION='\"${FIRMWARE_VERSION_STRING}\"'"
# build firmware target
pio run -e $1
# build merge-bin for esp32 fresh install
if [ -f .pio/build/$1/firmware.bin ]; then
pio run -t mergebin -e $1
fi
# build .uf2 for nrf52 boards
if [[ $1 == *"RAK_4631"* || $1 == *"t1000e"* || $1 == *"t114"* || $1 == *"T-Echo"* || $1 == *"Faketec"* || $1 == *"ProMicro"* ]]; then
python bin/uf2conv/uf2conv.py .pio/build/$1/firmware.hex -c -o .pio/build/$1/firmware.uf2 -f 0xADA52840
fi
# copy .bin, .uf2, and .zip to out folder
# e.g: Heltec_v3_room_server-v1.0.0-SHA.bin
# e.g: RAK_4631_Repeater-v1.0.0-SHA.uf2
# copy .bin for esp32 boards
cp .pio/build/$1/firmware.bin out/${FIRMWARE_FILENAME}.bin 2>/dev/null || true
cp .pio/build/$1/firmware-merged.bin out/${FIRMWARE_FILENAME}-merged.bin 2>/dev/null || true
# copy .zip and .uf2 of nrf52 boards
cp .pio/build/$1/firmware.uf2 out/${FIRMWARE_FILENAME}.uf2 2>/dev/null || true
cp .pio/build/$1/firmware.zip out/${FIRMWARE_FILENAME}.zip 2>/dev/null || true
}
# firmwares containing $1 will be built
build_all_firmwares_matching() {
envs=($(get_pio_envs_containing_string "$1"))
for env in "${envs[@]}"; do
build_firmware $env
done
}
build_repeater_firmwares() {
# # build specific repeater firmwares
# build_firmware "Heltec_v2_repeater"
# build_firmware "Heltec_v3_repeater"
# build_firmware "Xiao_C3_Repeater_sx1262"
# build_firmware "Xiao_S3_WIO_Repeater"
# build_firmware "LilyGo_T3S3_sx1262_Repeater"
# build_firmware "RAK_4631_Repeater"
# build all repeater firmwares
build_all_firmwares_matching "repeater"
}
build_companion_firmwares() {
# # build specific companion firmwares
# build_firmware "Heltec_v2_companion_radio_usb"
# build_firmware "Heltec_v2_companion_radio_ble"
# build_firmware "Heltec_v3_companion_radio_usb"
# build_firmware "Heltec_v3_companion_radio_ble"
# build_firmware "Xiao_S3_WIO_companion_radio_ble"
# build_firmware "LilyGo_T3S3_sx1262_companion_radio_usb"
# build_firmware "LilyGo_T3S3_sx1262_companion_radio_ble"
# build_firmware "RAK_4631_companion_radio_usb"
# build_firmware "RAK_4631_companion_radio_ble"
# build_firmware "t1000e_companion_radio_ble"
# build all companion firmwares
build_all_firmwares_matching "companion_radio_usb"
build_all_firmwares_matching "companion_radio_ble"
}
build_room_server_firmwares() {
# # build specific room server firmwares
# build_firmware "Heltec_v3_room_server"
# build_firmware "RAK_4631_room_server"
# build all room server firmwares
build_all_firmwares_matching "room_server"
}
build_firmwares() {
build_companion_firmwares
build_repeater_firmwares
build_room_server_firmwares
}
# clean build dir
rm -rf out
mkdir -p out
# handle script args
if [[ $1 == "build-firmware" ]]; then
if [ "$2" ]; then
build_firmware $2
fi
elif [[ $1 == "build-firmwares" ]]; then
build_firmwares
elif [[ $1 == "build-companion-firmwares" ]]; then
build_companion_firmwares
elif [[ $1 == "build-repeater-firmwares" ]]; then
build_repeater_firmwares
elif [[ $1 == "build-room-server-firmwares" ]]; then
build_room_server_firmwares
fi
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
-889
View File
@@ -1,889 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="generator" content="mkdocs-1.6.1, mkdocs-terminal-4.8.0">
<meta name="description" content="MeshCore fork meshcore-tth -- repeater antispam, diagnostics, OTA, Czech mesh defaults">
<link rel="canonical" href="https://tth-pub.pages.rfa.cz/meshcore-tth/cs/"><link rel="icon" type="image/png" sizes="192x192" href="../img/android-chrome-192x192.png" />
<link rel="icon" type="image/png" sizes="512x512" href="../img/android-chrome-512x512.png" />
<link rel="apple-touch-icon" sizes="180x180" href="../img/apple-touch-icon.png" />
<link rel="shortcut icon" type="image/png" sizes="48x48" href="../img/favicon.ico" />
<link rel="icon" type="image/png" sizes="16x16" href="../img/favicon-16x16.png" />
<link rel="icon" type="image/png" sizes="32x32" href="../img/favicon-32x32.png" />
<title>Česky - MeshCore TTH</title>
<link href="../css/fontawesome/css/fontawesome.min.css" rel="stylesheet">
<link href="../css/fontawesome/css/solid.min.css" rel="stylesheet">
<link href="../css/normalize.css" rel="stylesheet">
<link href="../css/terminal.css" rel="stylesheet">
<link href="../css/theme.css" rel="stylesheet">
<link href="../css/theme.tile_grid.css" rel="stylesheet">
<link href="../css/theme.footer.css" rel="stylesheet">
<!-- dark color palette -->
<link href="../css/palettes/dark.css" rel="stylesheet">
<!-- page layout -->
<style>
/* initially set page layout to a one column grid */
.terminal-mkdocs-main-grid {
display: grid;
grid-column-gap: 1.4em;
grid-template-columns: auto;
grid-template-rows: auto;
}
/*
* when side navigation is not hidden, use a two column grid.
* if the screen is too narrow, fall back to the initial one column grid layout.
* in this case the main content will be placed under the navigation panel.
*/
@media only screen and (min-width: 70em) {
.terminal-mkdocs-main-grid {
grid-template-columns: 4fr 9fr;
}
}</style>
<!-- cursor_animation override -->
<style>
#mkdocs-terminal-site-name.terminal-prompt::after {
display: none;
}
</style>
<link href="../_stylesheets/tth.css" rel="stylesheet">
<!-- search css support -->
<link href="../css/search/bootstrap-modal.css" rel="stylesheet">
<!-- search scripts -->
<script>
var base_url = "..",
shortcuts = "{}";
</script>
<script src="../js/jquery/jquery-1.10.1.min.js" defer></script>
<script src="../js/bootstrap/bootstrap.min.js" defer></script>
<script src="../js/mkdocs/base.js" defer></script>
<script src="../search/main.js"></script>
</head>
<body class="terminal"><div class="container">
<div class="terminal-nav">
<header class="terminal-logo">
<div id="mkdocs-terminal-site-name" class="logo terminal-prompt"><a href="https://tth-pub.pages.rfa.cz/meshcore-tth/" class="no-style">MeshCore TTH</a></div>
</header>
<nav class="terminal-menu">
<ul vocab="https://schema.org/" typeof="BreadcrumbList">
<li property="itemListElement" typeof="ListItem">
<a href=".." class="menu-item " property="item" typeof="WebPage">
<span property="name">About the fork</span>
</a>
<meta property="position" content="0">
</li>
<li property="itemListElement" typeof="ListItem">
<a href="./" class="menu-item active" property="item" typeof="WebPage">
<span property="name">Česky</span>
</a>
<meta property="position" content="1">
</li>
<li property="itemListElement" typeof="ListItem">
<a href="#" class="menu-item" data-toggle="modal" data-target="#mkdocs_search_modal" property="item" typeof="SearchAction">
<i aria-hidden="true" class="fa fa-search"></i> <span property="name">Search</span>
</a>
<meta property="position" content="2">
</li>
</ul>
</nav>
</div>
</div>
<div class="container">
<div class="terminal-mkdocs-main-grid"><aside id="terminal-mkdocs-side-panel"><nav>
<ul class="terminal-mkdocs-side-nav-items">
<li class="terminal-mkdocs-side-nav-li">
<a class="terminal-mkdocs-side-nav-item" href="..">About the fork</a>
</li>
<li class="terminal-mkdocs-side-nav-li">
<span class="terminal-mkdocs-side-nav-item--active">Česky</span>
</li>
<li class="terminal-mkdocs-side-nav-li">
<span class="
terminal-mkdocs-side-nav-item terminal-mkdocs-side-nav-section-no-index">Fork meshcore-tth</span>
<ul class="terminal-mkdocs-side-nav-li-ul">
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../tth-commands/">Console commands</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../ota/">Firmware update by the admin (OTA)</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../power/">Power saving</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../budka-sensor/">Budka as a sensor</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../ble-lora-coexistence/">BLE/LoRa coexistence</a>
</li>
</ul>
</li>
<li class="terminal-mkdocs-side-nav-li">
<span class="
terminal-mkdocs-side-nav-item terminal-mkdocs-side-nav-section-no-index">MeshCore (upstream)</span>
<ul class="terminal-mkdocs-side-nav-li-ul">
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../meshcore/">Introduction</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../faq/">FAQ</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../cli_commands/">CLI commands</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../companion_cli/">Companion CLI</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../companion_protocol/">Companion protocol</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../terminal_chat_cli/">Terminal chat CLI</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../kiss_modem_protocol/">KISS modem protocol</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../packet_format/">Packet format</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../payloads/">Payloads</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../stats_binary_frames/">Stats binary frames</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../number_allocations/">Number allocations</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../qr_codes/">QR codes</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../radio_presets/">Radio presets</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="../nrf52_power_management/">nRF52 power management</a>
</li>
</ul>
</li>
</ul>
</nav><hr>
<nav>
<ul>
<li><a href="#o-tomto-forku-meshcore-tth">O tomto forku (meshcore-tth)</a></li>
<li><a href="#repeater-antispam-vsechno-vypinatelne-nic-z-toho-neni-v-upstreamu">Repeater: antispam (všechno vypínatelné, nic z toho není v upstreamu)</a></li><li><a href="#diagnostika-a-provoz">Diagnostika a provoz</a></li><li><a href="#opravy-jadra">Opravy jádra</a></li><li><a href="#napajeni-hodiny-gps">Napájení, hodiny, GPS</a></li><li><a href="#senzory-a-companiony">Senzory a companiony</a></li><li><a href="#verejne-buildy-vychozi-nastaveni-pro-cesky-mesh">Veřejné buildy: výchozí nastavení pro český mesh</a></li><li><a href="#nahrani-releasu">Nahrání releasu</a></li><li><a href="#experimentalni-aktualizace-firmwaru-od-admina-ota">Experimentální: aktualizace firmwaru od admina (*-ota)</a></li><li><a href="#sestaveni">Sestavení</a></li>
</ul>
</nav>
</aside>
<main id="terminal-mkdocs-main-content">
<section id="mkdocs-terminal-content">
<h1 id="o-tomto-forku-meshcore-tth">O tomto forku (meshcore-tth)</h1>
<p><em><a href="../">English version</a> -- experimental
firmware, not meant for regular users.</em></p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p><strong>Experimentální firmware – není určený pro běžné uživatele.</strong> Tenhle fork
i všechny jeho releasy jsou osobní vývojová větev pro uzly jedné malé sítě:
rolling release nad upstreamovou větví <code>dev</code>, sestavovaný automaticky
zhruba dvakrát denně, bez stabilního kanálu, bez podpory a vyzkoušený jen
na našich deskách. Může obsahovat chyby, které uzel vyřadí z provozu,
a vrátit ho pak jde jen s USB nebo BLE v ruce. Pro běžný provoz nahrajte
oficiální MeshCore (<a href="https://flasher.meshcore.io">flasher.meshcore.io</a>).</p>
</div>
<p>Fork projektu <a href="https://github.com/meshcore-dev/MeshCore">meshcore-dev/MeshCore</a>,
na kterém běží repeatery, senzory a testovací desky malé české sítě na CZ
meshi (869,432 MHz). Upstreamové větve <code>main</code> a <code>dev</code> se slučují automaticky
dvakrát denně; všechno níže je navíc nad nimi. Náš kód je ve zdrojácích
označený <code>CUSTOM (TeTeHacko)</code>. Nic z toho nemění protokol na rádiu.</p>
<h2 id="repeater-antispam-vsechno-vypinatelne-nic-z-toho-neni-v-upstreamu">Repeater: antispam (všechno vypínatelné, nic z toho není v upstreamu)</h2>
<p><strong>Po nahrání je zapnutý jen FairnessLimiter</strong>, s limity se zhruba
dvojnásobnou rezervou nad 30 dní skutečného provozu CZ meshe: na kanál dávka
100 zpráv a pak jedna za 30 s, na odesílatele 150 a jedna za 10 s, na
původce advertu 30 a jeden za 10 min. Je to síť na utržené floody, ne kvóta;
<code>fairness off</code> ho vypne natrvalo. Okno na adverty, filtry a dry-run jsou
vypnuté, dokud je nezapnete.</p>
<ul>
<li><strong>FairnessLimiter</strong> – token buckety na přeposílané floody podle 1bajtových
identifikátorů, které jsou v paketu stejně v čitelné podobě (hash kanálu,
hash odesílatele, původce advertu). Port návrhu Beanowa
<a href="https://github.com/meshcore-dev/MeshCore/pull/1502">#1502</a>, limity
přepočítané z 30 dní skutečného provozu CZ meshe.
<code>fairness [on|off|grid|cap|refill]</code>; přímo směrovaný provoz se neomezuje nikdy.</li>
<li><strong>Okno na adverty podle původce</strong> – flood advert každého uzlu se přepošle
nejvýš jednou za N hodin (<code>fairness advert &lt;h&gt;|clear</code>), převzato
z AdvertLimiteru <a href="https://github.com/Dutch-MeshCore/MeshCore">DutchMeshCore</a>.
Míří na uzly, které advertují každou minutu.</li>
<li><strong>Dry-run</strong> – <code>fairness dryrun on</code> započítá každý verdikt, ale přepošle
i tak; <code>fairness air</code> ukáže ušetřený (nebo ušetřitelný) airtime podle důvodu.</li>
<li><strong>Filtr kanálů</strong> – na kanálech, jejichž klíč repeater zná (Public
a <code>#hashtag</code> kanály), přestane přeposílat zprávy uvedených jmen odesílatelů
(<code>filter add|del|list</code>). Jméno se dá podvrhnout: je to brzda na utrženého
bota, ne bezpečnost.</li>
<li><strong>Blokace přeposílání podle hashe kanálu</strong> – <code>filter hash add &lt;hex&gt; [s]</code>:
bez klíče, takže funguje i na soukromých kanálech; příjem se nemění, jen
přeposílání. S <code>s</code> se kanál neodřízne, ale přiškrtí (jeden paket za <code>s</code>
sekund).</li>
<li><strong>Limit stáří zprávy</strong> – <code>filter age &lt;min&gt;|off</code> (volitelné, 1–10080 min):
nepřeposílá skupinové zprávy na dešifrovaných kanálech, jejichž čas od
odesílatele je starší; bez nastavených hodin repeateru neplatí. Posuzuje
hodiny odesílatele, takže zahodí i companiony bez synchronizace času –
nastavuj ho na dny.</li>
<li><code>filter dryrun on</code> započítá každý verdikt <code>filter</code>, ale přepošle i tak.</li>
</ul>
<h2 id="diagnostika-a-provoz">Diagnostika a provoz</h2>
<p>Všechny příkazy forku, kde je který build má a výchozí hodnoty:
<a href="https://git.rfa.cz/tth-pub/meshcore-tth/src/branch/main/tth-commands.md">docs/tth-commands.md</a>.</p>
<p>Repeater, room server i senzor (všechno s textovou konzolí) mají:</p>
<ul>
<li><strong>Watchdogy rádia.</strong> Hardwarový watchdog chytí jen zamrzlou smyčku; dva naše
uzly ale byly nalezeny hluché s běžící smyčkou a pomohl až restart.</li>
<li><code>set radio.silence &lt;min&gt;</code> – <strong>hluchý přijímač</strong>: když se za <code>&lt;min&gt;</code> minut
nepohne čítač přijatých rámců (počítá se i rámec s chybou CRC), uzel
napřed znovu nahodí příjem, a když ani to nepomůže, restartuje se. Každý
takový restart zdvojnásobí práh pro příští start (až 16×), první přijatý
rámec ho vrátí, takže tiché místo neskončí ve smyčce restartů. Uloží se;
<strong>ve výchozím stavu vypnutý</strong> (<code>0</code>) – práh volte s rezervou nad nejdelší
běžné ticho na místě.</li>
<li><strong>Zaseknuté vysílání</strong> (jen repeater): pakety čekají ve frontě a čítač
odeslaných se nehýbe → znovu nahodí rádio, pak restart. Prázdná fronta se
nepočítá. <strong>Zapnutý, 15 min</strong> (<code>RADIO_TXSTALL_MIN</code>); <code>set radio.txstall
&lt;min&gt;|off</code> platí jen do restartu.</li>
<li><code>get radio.reboots</code> – kolik restartů watchdogy udělaly (přežije i výpadek
napájení); <code>get boot</code> – proč se deska naposledy resetovala a záznam
o hardfaultu (vypíše se i při startu).</li>
<li><code>dfu [uf2|serial|ota]</code> – spolehlivý reboot do bootloaderu (jen z lokální
konzole); <code>i2c</code> – sken sběrnice.</li>
</ul>
<p>Repeater navíc:</p>
<ul>
<li><code>blink</code> (rozbliká LED, i přes mesh – najdete uzel na stožáru), <code>txpwr</code>
(vysílací výkon do restartu, s verdiktem RadioLibu), čítače chyb vysílání
ve stavové odpovědi.</li>
<li>Jen observer varianty (<code>*-observer</code>): textová konzole přes BLE vedle USB,
<code>ble on|off</code> uložené přes reboot (<code>RPT_BLE_DEFAULT_OFF</code>: startuje vypnuté),
vlastní BLE PIN (<code>ble pin</code>), uložený vysílací výkon spojení (<code>blepwr</code>),
<code>bleconn</code>, neblokující BLE vysílání a parametry spojení, které vydrží i na
slabém linku.</li>
<li>Taky jen observer varianty: pasivní analyzátor v konzoli – <code>nodes</code>
(slyšené repeatery a roomy, klíč pro spojení více cest), <code>rxlog</code> (každý
slyšený rámec: typ, cesta, SNR, RSSI), <code>pktlog</code> (surové rámce pro feed
observeru), velké stránkované odpovědi.</li>
<li>Jen vlastní buildy, ne releasy:</li>
<li>kanálový bot (<code>BOT_CHANNEL_PSK</code>: <code>!link</code>, <code>!path</code>, <code>!snr</code>, <code>!heard</code>,
<code>!noise</code>, <code>!ping</code>, <code>!help</code>, výběr přes <code>BOT_COMMANDS</code>, cooldown na
odesílatele, ignore list) – odpovídá, aniž by přeposílal;</li>
<li><code>RADIO_DIAG</code>: <code>radiostat</code> (stav přijímače SX1262 bez zásahu) a
<code>radiokick rx|clrirq|standby|agc</code> (jeden krok obnovy, od nejjemnějšího –
první, který pomůže, ukáže rozbitou vrstvu);</li>
<li><code>PIN_DIAG</code>: <code>dio1</code> (stav přerušení v čipu proti úrovni na pinu – který
konec mrtvé linky DIO1 je přerušený);</li>
<li><code>LORA_POLL_IRQ</code>: provoz bez DIO1 pro desku s mrtvou linkou přerušení.</li>
</ul>
<h2 id="opravy-jadra">Opravy jádra</h2>
<ul>
<li><strong>Ochrana proti přehrání admin příkazů přežije reboot.</strong> Upstream si
poslední timestamp klienta drží jen v RAM, takže po každém restartu projde
libovolný zachycený příkaz znovu – zachycený <code>reboot</code> uzel restartuje
pořád dokola. Repeater, room server i sensor ho teď zapíšou do flash dřív,
než příkaz provedou (<code>/s_acl_ts0|1</code>, 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 (<code>ACL_TS_MAX_AHEAD</code>) se přijme, ale neuloží, aby companion
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á.</li>
<li><strong>Hesla nejde hádat přes éter plnou rychlostí.</strong> Upstream kontroluje každý
login bez omezení a na špatné heslo ani neodpoví. Po 4 špatných heslech
během 3 minut (<code>LOGIN_FAIL_MAX</code>, <code>LOGIN_FAIL_SECS</code>) 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.</li>
<li><strong>Přehraný login bez hesla už nevyvolá flood odpověď.</strong> 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.</li>
<li>TRACE už nepřipisuje cestu za konec payloadu; parsování TRACE/PATH
a <code>Packet::readFrom</code> hlídají meze.</li>
<li><code>markSeen</code> je zase idempotentní (odesílací cesta ujídala okno deduplikace).</li>
<li>Záložní výpočet v <code>calcMaxPacketMillis</code> už nepodteče (uzel na tom ohluchl).</li>
<li>Šířka path hashe se bere z nastavení uzlu na všech cestách vysílání včetně
<code>sendZeroHop</code>; výchozí jsou 2bajtové path hashe (<code>PATH_HASH_MODE_DEFAULT</code>).</li>
<li>Nepovedené vysílání se zařadí znovu s odstupem, místo aby se zahodilo.</li>
<li>RSSI každého paketu se zaznamená při příjmu; <code>ContactInfo</code> se před
částečným vyplněním vynuluje.</li>
</ul>
<h2 id="napajeni-hodiny-gps">Napájení, hodiny, GPS</h2>
<ul>
<li>GPS duty cycle (<code>gps duty</code>), i na T1000-E, kde nebyl: přijímač běží jen
kolem synchronizace hodin (jednou denně, po neúspěšném okně znovu za 6 h).
Dotaz na polohu přijímač probudí pro příští dotaz.</li>
<li>Uzel bez GPS startuje na čase sestavení firmwaru, ne v roce 2024; hodiny
a záznam o hardfaultu přežijí teplý reset (<code>.noinit</code>); <code>clkreboot</code>.</li>
<li>Na solárních uzlech žádná blikající LED a pomalejší BLE advertising.</li>
<li>Stav baterie jako ikona na konci advertovaného jména: <code>set batt.icon on</code>,
prahy <code>set batt.icon.lo|hi &lt;mV&gt;</code> (výchozí vypnuté; dlouhé jméno ikonu
nepojme a příkaz na to upozorní).</li>
<li>Volitelný RX duty cycle (<code>set radio.rxps off|on|balanced|max</code>, jemněji
<code>level &lt;1-10&gt;</code>; port PowerSaving z EasySkyMesh): SX1262 mezi krátkými okny
poslechu spí. Ve veřejných buildech je zabudovaný a <strong>vypnutý</strong>; <code>max</code> na
lavici ušetřil ~2,3 mA bez ztráty paketů (<a href="https://git.rfa.cz/tth-pub/meshcore-tth/src/branch/main/power.md">docs/power.md</a>),
na ostrém meshi ale jeden náš stožár ztratil 16 % příjmu – zapínat s rozmyslem. Jen
SX1262, ne LR1110 (T1000-E).</li>
<li>Podpěťová pojistka při startu (<code>PWRMGT_VOLTAGE_BOOTLOCK</code>) je na nRF52
<strong>vypnutá</strong>, stejně jako v upstreamu od v1.18.0
(<a href="https://github.com/meshcore-dev/MeshCore/pull/2377">#2377</a>): pevný práh
3,3 V nepouštěl k životu uzly na LiFePO4 nebo LTO. Firmware tak naběhne na
jakékoli chemii článku; před hlubokým vybitím má chránit BMS nebo ochranná
destička článku. Konfigurovatelná pojistka podle chemie čeká na upstream
(<a href="https://github.com/meshcore-dev/MeshCore/pull/2088">#2088</a>). Výjimkou je
<code>SenseCap_Solar_repeater</code> (Li-ion, naše stožáry): pojistka je zapnutá
a oba prahy jdou nastavit za běhu, i přes mesh jako admin –
<code>set pwr.bootlock &lt;mV&gt;|off</code> (výchozí 3300, pod ním uzel nenaběhne a spí,
dokud se článek nezotaví) a <code>set pwr.cutoff &lt;mV&gt;|off</code> (výchozí vypnuto,
pod ním se běžící uzel vypne); <code>get pwr</code> (<a href="https://git.rfa.cz/tth-pub/meshcore-tth/src/branch/main/power.md">docs/power.md</a>).</li>
</ul>
<h2 id="senzory-a-companiony">Senzory a companiony</h2>
<ul>
<li><code>simple_sensor</code>: telemetrie z externí stanice po UART
(<code>BudkaLinkSensorManager</code>, jeden LPP kanál na veličinu), <code>sensor read</code>.</li>
<li>Senzory, které jinak měří nepřetržitě (INA219, INA226, INA260, INA3221,
BMP280), mezi čteními telemetrie spí a měří jen na vyžádání (nápad a první
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: <code>sensor set ina.shunt &lt;mΩ&gt;</code>.</li>
<li>Companion: <code>gps duty</code> 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
<code>set pin</code>) 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.</li>
</ul>
<h2 id="verejne-buildy-vychozi-nastaveni-pro-cesky-mesh">Veřejné buildy: výchozí nastavení pro český mesh</h2>
<p>Releasy z tohoto repozitáře (<code>pub-release</code>) jsou přednastavené pro český
mesh podle wiki <a href="https://meshcore.cz/">meshcore.cz</a>, takže čerstvě nahraný
uzel nepotřebuje obvyklé kolečko nastavování:</p>
<ul>
<li>rádio 869,432 MHz / 62,5 kHz / SF7 / CR5 (všechny buildy);</li>
<li>repeater a room server: zero-hop advert vypnutý, flood advert každých 25 h,
duty cycle 10 % (<code>get dutycycle</code> → <code>10.0%</code>; zastaralé <code>af</code> je 9);</li>
<li>repeater: regiony <code>cz</code> a <code>cs</code> vedle <code>*</code> – vlastní <code>cz-&lt;kraj&gt;</code> přidáš přes
<code>region put cz-xxx cz</code> + <code>region save</code>;</li>
<li>2bajtové path hashe (výchozí v tomto forku);</li>
<li>repeater: filtr kanálů (<code>filter add &lt;jméno&gt;</code>) je zabudovaný pro Public,
<code>#meshcore</code> a <code>#test</code>, s prázdným seznamem – nedělá nic, dokud do něj
nepřidáš jméno.</li>
</ul>
<p>Platí jen pro uzel bez uloženého nastavení (nový nebo po <code>erase</code>): 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.</p>
<p><strong>BLE PIN companionu je veřejný <code>123456</code></strong> (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é.</p>
<p>Varianty observer (<code>*_repeater-observer-*</code>) nRF52 repeaterů (XIAO, SenseCAP
Solar, RAK4631, T1000-E, Heltec T114) přidávají buffery <code>nodes</code> / <code>rxlog</code> /
<code>pktlog</code> a textovou konzoli přes BLE, aby šel repeater číst přes USB nebo BLE
(<a href="https://git.rfa.cz/tth-pub/meshcore-repeater-observer">meshcore-repeater-observer</a>).
BLE konzole je po nahrání <strong>vypnutá</strong> (<code>RPT_BLE_DEFAULT_OFF</code>). Nemá vlastní
přihlášení, jen BLE PIN, a PIN v buildu je veřejný zástupný <code>123456</code>. Nejdřív
si proto nastav vlastní – v USB konzoli, nebo jako admin přes mesh (vzdálené
CLI v aplikaci): <code>ble pin &lt;6 číslic&gt;</code> (uloží se a přežije reboot i nové
nahrání; zároveň smaže všechny bondy, takže spárovaná zařízení se párují
znovu). Teprve pak <code>ble on</code> – dokud je PIN zástupný, tyhle buildy ho odmítnou.
<code>ble</code> ukáže, jestli je PIN <code>own</code> nebo <code>build default</code>, samotný PIN nikdy.
Releasy do <code>tth-654d53f3</code> <code>ble pin</code> nemají: BLE tam nech vypnuté a používej USB.</p>
<h2 id="nahrani-releasu">Nahrání releasu</h2>
<p>Každý release je automatický build nad upstreamovým <code>dev</code> (viz upozornění
nahoře), ne stabilní verze. Nahrávejte ho jen na uzly, na které dosáhnete,
a nový release vždy nejdřív na jeden z nich.</p>
<p>Soubory jsou v <a href="https://git.rfa.cz/tth-pub/meshcore-tth/releases">Releases</a>.
Release se jmenuje podle upstreamové verze a data, např.
<code>v1.18.0+tth.20261112</code> (druhý téhož dne <code>.2</code>), a v popisu má změny od
předchozího releasu. Pro každou desku a roli je jedna sada
(<code>&lt;deska&gt;_&lt;role&gt;-&lt;release&gt;</code>, např. <code>Xiao_nrf52_repeater-v1.18.0+tth.20261112.zip</code>):
<code>.zip</code> a <code>.uf2</code> pro nRF52, <code>.bin</code> pro ESP32 (<code>-merged.bin</code> je celý obraz pro
prázdnou desku, obyčejný <code>.bin</code> aktualizace). Kontrolní součty jsou
v <code>SHA256SUMS</code>. Releasy do 12. 11. 2026 se jmenovaly <code>tth-&lt;sha&gt;</code>.</p>
<p><strong>nRF52 (XIAO, RAK4631, SenseCAP Solar, T1000-E, T114) přes
<a href="https://flasher.meshcore.io">webový flasher MeshCore</a></strong> – Chrome, Edge nebo
Chromium na počítači (Web Serial; ne Firefox ani Safari):</p>
<ol>
<li>Připoj desku přes USB.</li>
<li>Klikni na <strong>Custom Firmware</strong> a vyber <code>.zip</code> pro svou desku.</li>
<li>Klikni na <strong>Enter DFU mode</strong> a vyber sériový port desky. Deska se
restartuje do bootloaderu a objeví se jako nový port.</li>
<li>Klikni na <strong>Flash!</strong> a vyber ten nový port. Zhruba 30 s, pak se deska
restartuje do nového firmwaru.</li>
<li><strong>Console</strong> ve flasheru (nebo jakýkoli sériový terminál, 115200) ověří
výsledek: <code>ver</code> ukáže <code>v1.xx.x-tth&lt;sha&gt;</code>, stejně jako řádek „Verze v uzlu“
v popisu releasu.</li>
</ol>
<p><strong>Neklikej na Erase Flash</strong>, pokud nechceš nový uzel: smaže identitu (klíč
uzlu a všechno, co ho zná) i veškeré nastavení. Obyčejné nahrání je zachová.</p>
<p>Vyzkoušeno na XIAO (repeater-observer, 3. 11. 2026). ESP32 <code>.bin</code> přes stejné
tlačítko Custom Firmware tu vyzkoušené není.</p>
<p>Bez webového flasheru: na většině desek otevře dvojí stisk resetu bootloader
jako USB disk; zkopíruj na něj <code>.uf2</code>. Nebo
<code>adafruit-nrfutil dfu serial -pkg &lt;soubor&gt;.zip -p &lt;port&gt; -b 115200</code> s deskou
v bootloaderu.</p>
<p>Nový uzel po nahrání nastav v konzoli: <code>set name &lt;jméno&gt;</code>,
<code>password &lt;admin heslo&gt;</code> (nejvýš 15 znaků), vlastní region přes
<code>region put cz-&lt;kraj&gt; cz</code> + <code>region save</code>. Repeater přeposílá od prvního
startu (výchozí v upstreamu) a tyhle buildy jsou na ostré CZ frekvenci: na
stole bez antény dej <code>set repeat off</code>, dokud není na místě.</p>
<h2 id="experimentalni-aktualizace-firmwaru-od-admina-ota">Experimentální: aktualizace firmwaru od admina (<code>*-ota</code>)</h2>
<p>Každý nRF52 build s textovou konzolí (repeater, observer, room server,
senzor) je v releasu ještě jednou jako <strong>experimentální</strong> <code>*-ota</code> /
<code>*-observer-ota</code>. Ten umí přijmout nový firmware od admina příkazy <code>fw …</code>:
v USB nebo BLE konzoli, nebo <strong>přes mesh jako vzdálené admin CLI</strong>. Bez změny
bootloaderu a bez druhé banky: uzel si balíček uloží do volné flash,
zkontroluje ho celý (podpis, hashe, nanečisto provedená delta) a přepíše se
až na <code>fw apply</code>, rutinou běžící z RAM. Když během přepisu vypadne napájení,
zůstane v bootloaderu a vrátí se přes USB/BLE DFU.</p>
<ul>
<li>V releasu je ke každému <code>*-ota</code> obrazu plný balíček
<code>&lt;deska&gt;_&lt;role&gt;-ota-&lt;release&gt;.mcfw</code> (jen přes USB/BLE) a delta
<code>….from-&lt;starší release&gt;.mcfw</code> od každého drženého předchozího releasu,
typicky jednotky kB.</li>
<li><strong>Přes mesh uzel přijme jen deltu, a nikdy ne starší verzi, než má</strong> –
vynucuje to uzel, ne nástroj. Plný obraz nebo návrat ke starší verzi jen
lokálně (<code>fw apply downgrade</code>). <code>fw apply</code> čeká na baterii ≥ 3,8 V, pokud
uzel neběží z USB.</li>
<li>Balíčky i <code>SHA256SUMS</code> jsou podepsané klíčem <code>meshcore-ota@tth-pub</code>
a <code>*-ota</code> obraz jiný podpis nepřijme. Ověření stažených souborů:
<code>ssh-keygen -Y verify -f tools/ota_allowed_signers -I meshcore-ota@tth-pub
-n meshcore-ota -s SHA256SUMS.sig &lt; SHA256SUMS</code>. Vlastní build s vlastním
klíčem: <code>[ota] pubkey</code> v <code>platformio.local.ini</code>.</li>
<li>První <code>*-ota</code> obraz se nahraje obyčejně (viz výše), další už jako delta.
Nástroje: <code>tools/ota_push.py</code> (USB), <code>tools/ota_mesh_push.py</code> (přes mesh
skrz companion; potřebuje pythonovou knihovnu <code>meshcore</code>, admin heslo bere
z <code>[secrets] admin_pw</code> v <code>platformio.local.ini</code>; s <code>--side</code> jde přenos po
vedlejším kanálu mimo sdílený mesh), <code>tools/ota_pack.py info</code>. Přenos samotný
je OTA engine kolekce
<a href="https://git.rfa.cz/tth-pub/meshcore-ansible">tth.meshcore</a> (modul
<code>meshcore_fw_ota</code>), stejný kód pro nástroje i Ansible. Z telefonu: fork
aplikace <a href="https://git.rfa.cz/tth-pub/meshcore-open">meshcore-open</a>, správa
repeateru → Firmware update (OTA), deltu si najde v releasu sám.
Postup a čísla: <a href="https://git.rfa.cz/tth-pub/meshcore-tth/src/branch/main/ota.md">docs/ota.md</a>.</li>
<li><strong>Experimentální i v rámci tohoto forku</strong>: obrazy přicházejí s každým
releasem (viz upozornění nahoře) a nemají druhou banku ani automatický
návrat. Vadný firmware, který nabootuje, běží, dokud nepošlete další;
takový, který nenabootuje, chce USB/BLE DFU v ruce. Vyzkoušeno na lavici
(XIAO, USB, mesh, vedlejší kanál) a od 13. 11. 2026 na dvou našich
stožárech. Proti obrazu, který nabootuje s mrtvým rádiem, jsou watchdogy
rádia (viz Diagnostika a provoz): pro uzly, kam posíláte OTA, zapněte
<code>set radio.silence</code>. Stojí ~10 kB RAM navíc.</li>
</ul>
<h2 id="sestaveni">Sestavení</h2>
<ul>
<li>Razítko verze v každém nRF52 envu (<code>v1.18.0-tth&lt;sha&gt;</code>, <code>+</code> = neuklizený
strom), základní verze z upstreamového tagu (<code>tools/build_version.py</code>).</li>
<li><code>tools/</code>: nástroje na uzly – konzole (USB, BLE), flashování, testy na
lavici, diagnostika (<a href="https://git.rfa.cz/tth-pub/meshcore-tth/src/branch/main/tools/README.md">tools/README.md</a>). Desky podle jména
bere z lokálního configu mimo repo (<code>tools/config.example.ini</code>).</li>
<li><code>hardware/cavity-box</code>: parametrická krabička pro dutinový filtr na stožár.</li>
</ul>
<hr />
</section>
</main>
</div>
<hr><footer>
<div class="terminal-mkdocs-footer-grid">
<div id="terminal-mkdocs-footer-copyright-info">
Site built with <a href="http://www.mkdocs.org">MkDocs</a> and <a href="https://github.com/ntno/mkdocs-terminal">Terminal for MkDocs</a>.
</div>
</div>
</footer>
</div>
<div class="modal" id="mkdocs_search_modal" tabindex="-1" role="alertdialog" aria-modal="true" aria-labelledby="searchModalLabel">
<div class="modal-dialog modal-lg" role="search">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="searchModalLabel">Search</h5>
<button type="button" class="close btn btn-default btn-ghost" data-dismiss="modal" aria-label="Close">x</button>
</div>
<div class="modal-body">
<p id="searchInputLabel">Type to start searching</p>
<form>
<div class="form-group">
<input type="search" class="form-control" aria-labelledby="searchInputLabel" placeholder="" id="mkdocs-search-query" title="Please enter search terms here">
</div>
</form>
<div id="mkdocs-search-results" data-no-results-text="No document matches found"></div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</body>
</html>
File diff suppressed because it is too large. Load diff
-6
View File
@@ -1,6 +0,0 @@
/*!
* Font Awesome Free 6.2.1 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
* Copyright 2022 Fonticons, Inc.
*/
.fa{font-family:var(--fa-style-family,"Font Awesome 6 Free");font-weight:var(--fa-style,900)}.fa,.fa-brands,.fa-classic,.fa-regular,.fa-sharp,.fa-solid,.fab,.far,.fas{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:var(--fa-display,inline-block);font-style:normal;font-variant:normal;line-height:1;text-rendering:auto}.fa-classic,.fa-regular,.fa-solid,.far,.fas{font-family:"Font Awesome 6 Free"}.fa-brands,.fab{font-family:"Font Awesome 6 Brands"}.fa-1x{font-size:1em}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-6x{font-size:6em}.fa-7x{font-size:7em}.fa-8x{font-size:8em}.fa-9x{font-size:9em}.fa-10x{font-size:10em}.fa-2xs{font-size:.625em;line-height:.1em;vertical-align:.225em}.fa-xs{font-size:.75em;line-height:.08333em;vertical-align:.125em}.fa-sm{font-size:.875em;line-height:.07143em;vertical-align:.05357em}.fa-lg{font-size:1.25em;line-height:.05em;vertical-align:-.075em}.fa-xl{font-size:1.5em;line-height:.04167em;vertical-align:-.125em}.fa-2xl{font-size:2em;line-height:.03125em;vertical-align:-.1875em}.fa-fw{text-align:center;width:1.25em}.fa-ul{list-style-type:none;margin-left:var(--fa-li-margin,2.5em);padding-left:0}.fa-ul>li{position:relative}.fa-li{left:calc(var(--fa-li-width, 2em)*-1);position:absolute;text-align:center;width:var(--fa-li-width,2em);line-height:inherit}.fa-border{border-radius:var(--fa-border-radius,.1em);border:var(--fa-border-width,.08em) var(--fa-border-style,solid) var(--fa-border-color,#eee);padding:var(--fa-border-padding,.2em .25em .15em)}.fa-pull-left{float:left;margin-right:var(--fa-pull-margin,.3em)}.fa-pull-right{float:right;margin-left:var(--fa-pull-margin,.3em)}.fa-beat{-webkit-animation-name:fa-beat;animation-name:fa-beat;-webkit-animation-delay:var(--fa-animation-delay,0s);animation-delay:var(--fa-animation-delay,0s);-webkit-animation-direction:var(--fa-animation-direction,normal);animation-direction:var(--fa-animation-direction,normal);-webkit-animation-duration:var(--fa-animation-duration,1s);animation-duration:var(--fa-animation-duration,1s);-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,ease-in-out);animation-timing-function:var(--fa-animation-timing,ease-in-out)}.fa-bounce{-webkit-animation-name:fa-bounce;animation-name:fa-bounce;-webkit-animation-delay:var(--fa-animation-delay,0s);animation-delay:var(--fa-animation-delay,0s);-webkit-animation-direction:var(--fa-animation-direction,normal);animation-direction:var(--fa-animation-direction,normal);-webkit-animation-duration:var(--fa-animation-duration,1s);animation-duration:var(--fa-animation-duration,1s);-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,cubic-bezier(.28,.84,.42,1));animation-timing-function:var(--fa-animation-timing,cubic-bezier(.28,.84,.42,1))}.fa-fade{-webkit-animation-name:fa-fade;animation-name:fa-fade;-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,cubic-bezier(.4,0,.6,1));animation-timing-function:var(--fa-animation-timing,cubic-bezier(.4,0,.6,1))}.fa-beat-fade,.fa-fade{-webkit-animation-delay:var(--fa-animation-delay,0s);animation-delay:var(--fa-animation-delay,0s);-webkit-animation-direction:var(--fa-animation-direction,normal);animation-direction:var(--fa-animation-direction,normal);-webkit-animation-duration:var(--fa-animation-duration,1s);animation-duration:var(--fa-animation-duration,1s)}.fa-beat-fade{-webkit-animation-name:fa-beat-fade;animation-name:fa-beat-fade;-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,cubic-bezier(.4,0,.6,1));animation-timing-function:var(--fa-animation-timing,cubic-bezier(.4,0,.6,1))}.fa-flip{-webkit-animation-name:fa-flip;animation-name:fa-flip;-webkit-animation-delay:var(--fa-animation-delay,0s);animation-delay:var(--fa-animation-delay,0s);-webkit-animation-direction:var(--fa-animation-direction,normal);animation-direction:var(--fa-animation-direction,normal);-webkit-animation-duration:var(--fa-animation-duration,1s);animation-duration:var(--fa-animation-duration,1s);-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,ease-in-out);animation-timing-function:var(--fa-animation-timing,ease-in-out)}.fa-shake{-webkit-animation-name:fa-shake;animation-name:fa-shake;-webkit-animation-duration:var(--fa-animatLine truncated
-19
View File
@@ -1,19 +0,0 @@
/*!
* Font Awesome Free 6.2.1 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
* Copyright 2022 Fonticons, Inc.
*/
:root, :host {
--fa-style-family-classic: 'Font Awesome 6 Free';
--fa-font-solid: normal 900 1em/1 'Font Awesome 6 Free'; }
@font-face {
font-family: 'Font Awesome 6 Free';
font-style: normal;
font-weight: 900;
font-display: block;
src: url("../webfonts/fa-solid-900.woff2") format("woff2"), url("../webfonts/fa-solid-900.ttf") format("truetype"); }
.fas,
.fa-solid {
font-weight: 900; }
-6
View File
@@ -1,6 +0,0 @@
/*!
* Font Awesome Free 6.2.1 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
* Copyright 2022 Fonticons, Inc.
*/
:host,:root{--fa-style-family-classic:"Font Awesome 6 Free";--fa-font-solid:normal 900 1em/1 "Font Awesome 6 Free"}@font-face{font-family:"Font Awesome 6 Free";font-style:normal;font-weight:900;font-display:block;src:url(../webfonts/fa-solid-900.woff2) format("woff2"),url(../webfonts/fa-solid-900.ttf) format("truetype")}.fa-solid,.fas{font-weight:900}
Binary file not shown.
Binary file not shown.
-419
View File
@@ -1,419 +0,0 @@
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in iOS.
*/
html {
line-height: 1.15;
/* 1 */
-webkit-text-size-adjust: 100%;
/* 2 */
}
/* Sections
========================================================================== */
/**
* Remove the margin in all browsers.
*/
body {
margin: 0;
}
/**
* Render the `main` element consistently in IE.
*/
main {
display: block;
}
/**
* Correct the font size and margin on `h1` elements within `section` and
* `article` contexts in Chrome, Firefox, and Safari.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/* Grouping content
========================================================================== */
/**
* 1. Add the correct box sizing in Firefox.
* 2. Show the overflow in Edge and IE.
*/
hr {
box-sizing: content-box;
/* 1 */
height: 0;
/* 1 */
overflow: visible;
/* 2 */
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
pre {
font-family: monospace, monospace;
/* 1 */
font-size: 1em;
/* 2 */
}
/* Text-level semantics
========================================================================== */
/**
* Remove the gray background on active links in IE 10.
*/
a {
background-color: transparent;
}
/**
* 1. Remove the bottom border in Chrome 57-
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
*/
abbr[title] {
border-bottom: none;
/* 1 */
text-decoration: underline;
/* 2 */
text-decoration: underline dotted;
/* 2 */
}
/**
* Add the correct font weight in Chrome, Edge, and Safari.
*/
b,
strong {
font-weight: bolder;
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp {
font-family: monospace, monospace;
/* 1 */
font-size: 1em;
/* 2 */
}
/**
* Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` elements from affecting the line height in
* all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
/* Embedded content
========================================================================== */
/**
* Remove the border on images inside links in IE 10.
*/
img {
border-style: none;
}
/* Forms
========================================================================== */
/**
* 1. Change the font styles in all browsers.
* 2. Remove the margin in Firefox and Safari.
*/
button,
input,
optgroup,
select,
textarea {
font-family: inherit;
/* 1 */
font-size: 100%;
/* 1 */
line-height: 1.15;
/* 1 */
margin: 0;
/* 2 */
}
/**
* Show the overflow in IE.
* 1. Show the overflow in Edge.
*/
button,
input {
/* 1 */
overflow: visible;
}
/**
* Remove the inheritance of text transform in Edge, Firefox, and IE.
* 1. Remove the inheritance of text transform in Firefox.
*/
button,
select {
/* 1 */
text-transform: none;
}
/**
* Correct the inability to style clickable types in iOS and Safari.
*/
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
/**
* Remove the inner border and padding in Firefox.
*/
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding: 0;
}
/**
* Restore the focus styles unset by the previous rule.
*/
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px dotted ButtonText;
}
/**
* Correct the padding in Firefox.
*/
fieldset {
padding: 0.35em 0.75em 0.625em;
}
/**
* 1. Correct the text wrapping in Edge and IE.
* 2. Correct the color inheritance from `fieldset` elements in IE.
* 3. Remove the padding so developers are not caught out when they zero out
* `fieldset` elements in all browsers.
*/
legend {
box-sizing: border-box;
/* 1 */
color: inherit;
/* 2 */
display: table;
/* 1 */
max-width: 100%;
/* 1 */
padding: 0;
/* 3 */
white-space: normal;
/* 1 */
}
/**
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
*/
progress {
vertical-align: baseline;
}
/**
* Remove the default vertical scrollbar in IE 10+.
*/
textarea {
overflow: auto;
}
/**
* 1. Add the correct box sizing in IE 10.
* 2. Remove the padding in IE 10.
*/
[type="checkbox"],
[type="radio"] {
box-sizing: border-box;
/* 1 */
padding: 0;
/* 2 */
}
/**
* Correct the cursor style of increment and decrement buttons in Chrome.
*/
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Correct the odd appearance in Chrome and Safari.
* 2. Correct the outline style in Safari.
*/
[type="search"] {
-webkit-appearance: textfield;
/* 1 */
outline-offset: -2px;
/* 2 */
}
/**
* Remove the inner padding in Chrome and Safari on macOS.
*/
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* 1. Correct the inability to style clickable types in iOS and Safari.
* 2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button;
/* 1 */
font: inherit;
/* 2 */
}
/* Interactive
========================================================================== */
/*
* Add the correct display in Edge, IE 10+, and Firefox.
*/
details {
display: block;
}
/*
* Add the correct display in all browsers.
*/
summary {
display: list-item;
}
/* Misc
========================================================================== */
/**
* Add the correct display in IE 10+.
*/
template {
display: none;
}
/**
* Add the correct display in IE 10.
*/
[hidden] {
display: none;
}
-31
View File
@@ -1,31 +0,0 @@
/*! blueberry.css | MIT License | github.com/ntno/mkdocs-terminal */
:root {
--cream: #ffffcc;
--black: #190910;
--digital-navy: #000080;
--authentic-blue: #3737aa;
--corn-harvest: #8a6801;
--light-grey: #d4d4d4;
--dark-grey: #5e5e5e;
--white: #f7f7f7;
--global-font-size: 15px;
--global-line-height: 1.4em;
--global-space: 10px;
--font-stack: "Fira Code", Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
--mono-font-stack: "Fira Code", Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
--background-color: var(--cream);
--page-width: 60em;
--font-color: var(--black);
--invert-font-color: var(--white);
--primary-color: var(--digital-navy);
--secondary-color: var(--authentic-blue);
--tertiary-color: var(--authentic-blue);
--error-color: var(--corn-harvest);
--progress-bar-background: var(--light-grey);
--progress-bar-fill: var(--dark-grey);
--code-bg-color: var(--white);
--input-style: solid;
--display-h1-decoration: none;
}
-22
View File
@@ -1,22 +0,0 @@
/*! dark.css 0.7.5 | MIT License | github.com/Gioni06/terminal.css */
:root {
--global-font-size: 15px;
--global-line-height: 1.4em;
--global-space: 10px;
--font-stack: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
--mono-font-stack: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
--background-color: #222225;
--page-width: 60em;
--font-color: #e8e9ed;
--invert-font-color: #222225;
--secondary-color: #a3abba;
--tertiary-color: #a3abba;
--primary-color: #62c4ff;
--error-color: #ff3c74;
--progress-bar-background: #3f3f44;
--progress-bar-fill: #62c4ff;
--code-bg-color: #3f3f44;
--input-style: solid;
--display-h1-decoration: none;
}
-4
View File
@@ -1,4 +0,0 @@
/*! terminal.css 0.7.5 | MIT License | github.com/Gioni06/terminal.css */
/* this document is intentionally left empty. for root configuration, see terminal/css/terminal.css */
-50
View File
@@ -1,50 +0,0 @@
/*! gruvbox_dark.css | MIT License | github.com/Gioni06/terminal.css/issues/9 */
:root {
--gb-dm-bg0: #282828;
--gb-dm-bg0-hard: #1d2021;
--gb-dm-bg0-soft: #32302f;
--gb-dm-bg1: #3c3836;
--gb-dm-bg2: #504945;
--gb-dm-bg3: #665c54;
--gb-dm-bg4: #7c6f64;
--gb-dm-fg0: #fbf1c7;
--gb-dm-fg1: #ebdbb2;
--gb-dm-fg2: #d5c4a1;
--gb-dm-fg3: #bdae93;
--gb-dm-fg4: #a89984;
--gb-dm-dark-red: #cc241d;
--gb-dm-dark-green: #98971a;
--gb-dm-dark-yellow: #d79921;
--gb-dm-dark-blue: #458588;
--gb-dm-dark-purple: #b16286;
--gb-dm-dark-aqua: #689d6a;
--gb-dm-dark-orange: #d65d0e;
--gb-dm-dark-gray: #928374;
--gb-dm-light-red: #fb4934;
--gb-dm-light-green: #b8bb26;
--gb-dm-light-yellow: #fabd2f;
--gb-dm-light-blue: #83a598;
--gb-dm-light-purple: #d3869b;
--gb-dm-light-aqua: #8ec07c;
--gb-dm-light-orange: #f38019;
--gb-dm-light-gray: #a89984;
--global-font-size: 15px;
--global-line-height: 1.4em;
--global-space: 10px;
--font-stack: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
--mono-font-stack: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
--background-color: var(--gb-dm-bg0);
--page-width: 60em;
--font-color: var(--gb-dm-fg1);
--invert-font-color: var(--gb-dm-bg0-hard);
--primary-color: var(--gb-dm-light-yellow);
--secondary-color: var(--gb-dm-fg3);
--tertiary-color: var(--gb-dm-light-gray);
--error-color: var(--gb-dm-light-red);
--progress-bar-background: var(--gb-dm-bg2);
--progress-bar-fill: var(--gb-dm-fg2);
--code-bg-color: var(--gb-dm-bg2);
--input-style: solid;
--display-h1-decoration: none;
}
-31
View File
@@ -1,31 +0,0 @@
/*! lightyear.css | MIT License | github.com/ntno/mkdocs-terminal */
:root {
--mint: #e0ffe0;
--black: #190910;
--white: #f7f7f7;
--dark-purple: #4b0082;
--grape: #805b9c;
--red: #cc2517;
--light-grey: #d4d4d4;
--dark-grey: #5e5e5e;
--global-font-size: 15px;
--global-line-height: 1.4em;
--global-space: 10px;
--font-stack: "Fira Code", Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
--mono-font-stack: "Fira Code", Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
--background-color: var(--mint);
--page-width: 60em;
--font-color: var(--black);
--invert-font-color: var(--white);
--primary-color: var(--dark-purple);
--secondary-color: var(--grape);
--tertiary-color: var(--grape);
--error-color: var(--red);
--progress-bar-background: var(--light-grey);
--progress-bar-fill: var(--dark-grey);
--code-bg-color: var(--white);
--input-style: solid;
--display-h1-decoration: none;
}
-22
View File
@@ -1,22 +0,0 @@
/*! pink.css | MIT License | github.com/Gioni06/terminal.css/issues/9 */
:root {
--global-font-size: 15px;
--global-line-height: 1.4em;
--global-space: 10px;
--font-stack: 'Fira Code', Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
--mono-font-stack: 'Fira Code', Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
--background-color: #ffffff;
--page-width: 60em;
--font-color: #190910;
--invert-font-color: #f7f7f7;
--primary-color: #f90d7a;
--secondary-color: #715864;
--tertiary-color: #715864;
--error-color: #bb0047;
--progress-bar-background: #d4d4d4;
--progress-bar-fill: #5e5e5e;
--code-bg-color: #f7f7f7;
--input-style: solid;
--display-h1-decoration: none;
}
-31
View File
@@ -1,31 +0,0 @@
/*! red_drum.css | MIT License | github.com/ntno/mkdocs-terminal */
:root {
--pale-goldenrod: #eee8aa;
--black: #190910;
--white: #f7f7f7;
--dark-red: #8b0000;
--old-rose: #8b5a5b;
--sea-blue: #00678c;
--light-grey: #d4d4d4;
--dark-grey: #5e5e5e;
--global-font-size: 15px;
--global-line-height: 1.4em;
--global-space: 10px;
--font-stack: "Fira Code", Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
--mono-font-stack: "Fira Code", Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
--background-color: var(--pale-goldenrod);
--page-width: 60em;
--font-color: var(--black);
--invert-font-color: var(--white);
--primary-color: var(--dark-red);
--secondary-color: var(--old-rose);
--tertiary-color: var(--old-rose);
--error-color: var(--sea-blue);
--progress-bar-background: var(--light-grey);
--progress-bar-fill: var(--dark-grey);
--code-bg-color: var(--white);
--input-style: solid;
--display-h1-decoration: none;
}
-8
View File
@@ -1,8 +0,0 @@
/*! sans.css 0.7.5 | MIT License | github.com/Gioni06/terminal.css */
:root {
--global-font-size: 15px;
--global-line-height: 1.4em;
--font-stack: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
--input-style: solid;
}
-20
View File
@@ -1,20 +0,0 @@
/*! sans_dark.css 0.7.5 | MIT License | github.com/Gioni06/terminal.css */
:root {
--global-font-size: 15px;
--global-line-height: 1.4em;
--font-stack: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
--background-color: #222225;
--page-width: 60em;
--font-color: #e8e9ed;
--invert-font-color: #222225;
--secondary-color: #a3abba;
--tertiary-color: #a3abba;
--primary-color: #62c4ff;
--error-color: #ff3c74;
--progress-bar-background: #3f3f44;
--progress-bar-fill: #62c4ff;
--code-bg-color: #3f3f44;
--input-style: solid;
--display-h1-decoration: none;
}
-211
View File
@@ -1,211 +0,0 @@
/*! Terminal for MkDocs | MIT License | github.com/ntno/mkdocs-terminal */
/*!
/*! Bootstrap v4.3.1 | MIT License | github.com/twbs/bootstrap
* Copyright 2011-2019 The Bootstrap Authors
* Copyright 2011-2019 Twitter, Inc.
*/
.modal-open {
overflow: hidden;
}
.modal-open .modal {
overflow-x: hidden;
overflow-y: auto;
}
.modal {
position: fixed;
top: 0;
left: 0;
z-index: 1050;
display: none;
width: 100%;
height: 100%;
overflow: hidden;
outline: 0;
}
.modal-dialog {
position: relative;
width: auto;
margin: 0.5rem;
pointer-events: none;
}
.modal.fade .modal-dialog {
transition: -webkit-transform 0.3s ease-out;
transition: transform 0.3s ease-out;
transition: transform 0.3s ease-out, -webkit-transform 0.3s ease-out;
-webkit-transform: translate(0, -50px);
transform: translate(0, -50px);
}
@media (prefers-reduced-motion: reduce) {
.modal.fade .modal-dialog {
transition: none;
}
}
.modal.show .modal-dialog {
-webkit-transform: none;
transform: none;
}
.modal-dialog-scrollable {
display: flex;
max-height: calc(100% - 1rem);
}
.modal-dialog-scrollable .modal-content {
max-height: calc(100vh - 1rem);
overflow: hidden;
}
.modal-dialog-scrollable .modal-header,
.modal-dialog-scrollable .modal-footer {
flex-shrink: 0;
}
.modal-dialog-scrollable .modal-body {
overflow-y: auto;
}
.modal-dialog-centered {
display: flex;
align-items: center;
min-height: calc(100% - 1rem);
}
.modal-dialog-centered::before {
display: block;
height: calc(100vh - 1rem);
content: "";
}
.modal-dialog-centered.modal-dialog-scrollable {
flex-direction: column;
justify-content: center;
height: 100%;
}
.modal-dialog-centered.modal-dialog-scrollable .modal-content {
max-height: none;
}
.modal-dialog-centered.modal-dialog-scrollable::before {
content: none;
}
.modal-content {
position: relative;
display: flex;
flex-direction: column;
width: 100%;
pointer-events: auto;
background-color: var(--code-bg-color);
background-clip: padding-box;
border: 1px solid var(--font-color);
outline: 0;
}
.modal-backdrop {
position: fixed;
top: 0;
left: 0;
z-index: 1040;
width: 100vw;
height: 100vh;
background-color: #000;
}
.modal-backdrop.fade {
opacity: 0;
}
.modal-backdrop.show {
opacity: 0.5;
}
.modal-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 1rem 1rem;
border-bottom: 1px solid var(--secondary-color);
}
.modal-header .close {
padding: 1rem 1.5rem;
margin: -.7rem -.7rem -.7rem auto;
}
.modal-title {
margin-bottom: 0;
line-height: 1.5;
}
.modal-body {
position: relative;
flex: 1 1 auto;
padding: 1rem;
}
.modal-footer {
display: flex;
align-items: center;
justify-content: flex-end;
padding: 1rem;
border-top: 1px solid var(--secondary-color);
}
.modal-footer> :not(:first-child) {
margin-left: .25rem;
}
.modal-footer> :not(:last-child) {
margin-right: .25rem;
}
.modal-scrollbar-measure {
position: absolute;
top: -9999px;
width: 50px;
height: 50px;
overflow: scroll;
}
@media (min-width: 576px) {
.modal-dialog {
max-width: 500px;
margin: 1.75rem auto;
}
.modal-dialog-scrollable {
max-height: calc(100% - 3.5rem);
}
.modal-dialog-scrollable .modal-content {
max-height: calc(100vh - 3.5rem);
}
.modal-dialog-centered {
min-height: calc(100% - 3.5rem);
}
.modal-dialog-centered::before {
height: calc(100vh - 3.5rem);
}
.modal-sm {
max-width: 300px;
}
}
@media (min-width: 992px) {
.modal-lg,
.modal-xl {
max-width: 800px;
}
}
@media (min-width: 1200px) {
.modal-xl {
max-width: 1140px;
}
}
-1055
View File
File diff suppressed because it is too large. Load diff
-92
View File
@@ -1,92 +0,0 @@
/*! Terminal for MkDocs | MIT License | github.com/ntno/mkdocs-terminal */
/*! terminal.css 0.7.5 | MIT License | github.com/Gioni06/terminal.css */
body {
padding-top: 50px;
padding-bottom: 50px;
}
/* underline links in main content (except header anchor links) */
#terminal-mkdocs-main-content a:not(.headerlink) {
text-decoration: underline;
}
/* do not underline button links */
a.btn {
text-decoration: none !important;
}
.terminal-mkdocs-side-nav-item--active {
font-style: italic;
}
.terminal-mkdocs-side-nav-section-no-index {
color: var(--secondary-color);
}
.terminal-mkdocs-pad-to-match-side-nav {
padding-top: calc(var(--global-space) * 2);
}
.terminal-mkdocs-thin-border {
border: solid !important;
border-color: var(--secondary-color) !important;
border-width: thin !important;
}
.terminal-mkdocs-macro-error-banner {
border-style: solid;
border-width: 1px;
display: inline-flex;
align-items: center;
justify-content: center;
padding: .65em 2em;
border-color: var(--error-color);
}
p.terminal-mkdocs-macro-error-banner {
color: var(--font-color);
}
p.terminal-mkdocs-macro-error-banner>code {
color: var(--code-font-color);
}
/* set figcaption paragraph text to the secondary color. this occurs when using markdown inside the figcaption */
figure>figcaption>p {
color: var(--secondary-color);
}
/* ***************************************************************** */
/* Terminal.css Overrides */
/* ***************************************************************** */
/* don't display backticks on `code` items, just highlight */
code::after,
code::before {
content: "" !important;
display: inline;
}
/* use the `code-bg-color` and `code-font-color` for `<code>` blocks */
pre code {
background-color: var(--code-bg-color);
color: var(--code-font-color);
}
-25
View File
@@ -1,25 +0,0 @@
/* grid for footer */
.terminal-mkdocs-footer-grid {
display: grid;
grid-row-gap: 2em;
grid-column-gap: 2em;
grid-template-columns: auto;
grid-template-rows: auto;
}
/* place prev/next links to the right of copyright info when screen is wide enough */
@media only screen and (min-width: 50em) {
.terminal-mkdocs-footer-grid {
grid-template-columns: 6fr 3fr;
}
#terminal-mkdocs-footer-prev-next {
text-align: right;
}
}
#terminal-mkdocs-footer-copyright-info {
text-align: left;
}
-26
View File
@@ -1,26 +0,0 @@
/*! Terminal for MkDocs | MIT License | github.com/ntno/mkdocs-terminal */
.terminal-mkdocs-tile-grid {
display: grid;
grid-gap: 1em;
grid-template-rows: auto;
grid-template-columns: repeat(auto-fit, minmax(calc(var(--page-width) / 6), 1fr));
}
/* center link text within the tile */
.terminal-mkdocs-tile {
border: none;
text-align: center;
}
/* center images within the tile */
.terminal-mkdocs-tile div>figure>img,
.terminal-mkdocs-tile div>figure>a>img {
display: block;
margin-left: auto;
margin-right: auto;
}
+605
View File
@@ -0,0 +1,605 @@
**MeshCore-FAQ**<!-- omit from toc -->
A list of frequently-asked questions and answers for MeshCore
The current version of this MeshCore FAQ is at https://github.com/ripplebiz/MeshCore/blob/main/docs/faq.md.
This MeshCore FAQ is also mirrored at https://github.com/LitBomb/MeshCore-FAQ and might have newer updates if pull requests on Scott's MeshCore repo are not approved yet.
author: https://github.com/LitBomb<!-- omit from toc -->
---
- [1. Introduction](#1-introduction)
- [1.1. Q: What is MeshCore?](#11-q-what-is-meshcore)
- [1.2. Q: What do you need to start using MeshCore?](#12-q-what-do-you-need-to-start-using-meshcore)
- [1.2.1. Hardware](#121-hardware)
- [1.2.2. Firmware](#122-firmware)
- [1.2.3. Companion Radio Firmware](#123-companion-radio-firmware)
- [1.2.4. Repeater](#124-repeater)
- [1.2.5. Room Server](#125-room-server)
- [2. Initial Setup](#2-initial-setup)
- [2.1. Q: How many devices do I need to start using meshcore?](#21-q-how-many-devices-do-i-need-to-start-using-meshcore)
- [2.2. Q: Does MeshCore cost any money?](#22-q-does-meshcore-cost-any-money)
- [2.3. Q: What frequencies are supported by MeshCore?](#23-q-what-frequencies-are-supported-by-meshcore)
- [2.4. Q: What is an "advert" in MeshCore?](#24-q-what-is-an-advert-in-meshcore)
- [2.5. Q: Is there a hop limit?](#25-q-is-there-a-hop-limit)
- [3. Server Administration](#3-server-administration)
- [3.1. Q: How do you configure a repeater or a room server?](#31-q-how-do-you-configure-a-repeater-or-a-room-server)
- [3.2. Q: Do I need to set the location for a repeater?](#32-q-do-i-need-to-set-the-location-for-a-repeater)
- [3.3. Q: What is the password to administer a repeater or a room server?](#33-q-what-is-the-password-to-administer-a-repeater-or-a-room-server)
- [3.4. Q: What is the password to join a room server?](#34-q-what-is-the-password-to-join-a-room-server)
- [4. T-Deck Related](#4-t-deck-related)
- [4.1. Q: What are the steps to get a T-Deck into DFU (Device Firmware Update) mode?](#41-q-what-are-the-steps-to-get-a-t-deck-into-dfu-device-firmware-update-mode)
- [4.2. Q: Why is my T-Deck Plus not getting any satellite lock?](#42-q-why-is-my-t-deck-plus-not-getting-any-satellite-lock)
- [4.3. Q: Why is my OG (non-Plus) T-Deck not getting any satellite lock?](#43-q-why-is-my-og-non-plus-t-deck-not-getting-any-satellite-lock)
- [4.4. Q: What size of SD card does the T-Deck support?](#44-q-what-size-of-sd-card-does-the-t-deck-support)
- [4.5. Q: How do I get maps on T-Deck?](#45-q-how-do-i-get-maps-on-t-deck)
- [4.6. Q: Where do the map tiles go?](#46-q-where-do-the-map-tiles-go)
- [4.7. Q: How to unlock deeper map zoom and server management features on T-Deck?](#47-q-how-to-unlock-deeper-map-zoom-and-server-management-features-on-t-deck)
- [4.8. Q: How to decipher the diagnostics screen on T-Deck?](#48-q-how-to-decipher-the-diagnostics-screen-on-t-deck)
- [4.9. Q: The T-Deck sound is too loud?](#49-q-the-t-deck-sound-is-too-loud)
- [4.10. Q: Can you customize the sound?](#410-q-can-you-customize-the-sound)
- [4.11. Q: What is the 'Import from Clipboard' feature on the t-deck and is there a way to manually add nodes without having to receive adverts?](#411-q-what-is-the-import-from-clipboard-feature-on-the-t-deck-and-is-there-a-way-to-manually-add-nodes-without-having-to-receive-adverts)
- [5. General](#5-general)
- [5.1. Q: What are BW, SF, and CR?](#51-q-what-are-bw-sf-and-cr)
- [5.2. Q: Do MeshCore clients repeat?](#52-q-do-meshcore-clients-repeat)
- [5.3. Q: What happens when a node learns a route via a mobile repeater, and that repeater is gone?](#53-q-what-happens-when-a-node-learns-a-route-via-a-mobile-repeater-and-that-repeater-is-gone)
- [5.4. Q: How does a node discovery a path to its destination and then use it to send messages in the future, instead of flooding every message it sends like Meshtastic?](#54-q-how-does-a-node-discovery-a-path-to-its-destination-and-then-use-it-to-send-messages-in-the-future-instead-of-flooding-every-message-it-sends-like-meshtastic)
- [5.5. Q: Do public channels always flood? Do private channels always flood?](#55-q-do-public-channels-always-flood-do-private-channels-always-flood)
- [5.6. Q: what is the public key for the default public channel?](#56-q-what-is-the-public-key-for-the-default-public-channel)
- [5.7. Q: Is MeshCore open source?](#57-q-is-meshcore-open-source)
- [5.8. Q: How can I support MeshCore?](#58-q-how-can-i-support-meshcore)
- [5.9. Q: How do I build MeshCore firmware from source?](#59-q-how-do-i-build-meshcore-firmware-from-source)
- [5.10. Q: Are there other MeshCore related open source projects?](#510-q-are-there-other-meshcore-related-open-source-projects)
- [5.11. Q: Does MeshCore support ATAK](#511-q-does-meshcore-support-atak)
- [5.12. Q: How do I add a node to the MeshCore Map](#512-q-how-do-i-add-a-node-to-the-meshcore-map)
- [5.13. Q: Can I use a Raspberry Pi to update a MeshCore radio?](#513-q-can-i-use-a-raspberry-pi-to-update-a-meshcore-radio)
- [5.14. Q: Are there are projects built around MeshCore?](#514-q-are-there-are-projects-built-around-meshcore)
- [5.14.1. meshcoremqtt](#5141-meshcoremqtt)
- [5.14.2. MeshCore for Home Assistant](#5142-meshcore-for-home-assistant)
- [5.14.3. Python MeshCore](#5143-python-meshcore)
- [5.14.4. meshcore-cli](#5144-meshcore-cli)
- [5.14.5. meshcore.js](#5145-meshcorejs)
- [6. Troubleshooting](#6-troubleshooting)
- [6.1. Q: My client says another client or a repeater or a room server was last seen many, many days ago.](#61-q-my-client-says-another-client-or-a-repeater-or-a-room-server-was-last-seen-many-many-days-ago)
- [6.2. Q: A repeater or a client or a room server I expect to see on my discover list (on T-Deck) or contact list (on a smart device client) are not listed.](#62-q-a-repeater-or-a-client-or-a-room-server-i-expect-to-see-on-my-discover-list-on-t-deck-or-contact-list-on-a-smart-device-client-are-not-listed)
- [6.3. Q: How to connect to a repeater via BLE (bluetooth)?](#63-q-how-to-connect-to-a-repeater-via-ble-bluetooth)
- [6.4. Q: I can't connect via bluetooth, what is the bluetooth pairing code?](#64-q-i-cant-connect-via-bluetooth-what-is-the-bluetooth-pairing-code)
- [6.5. Q: My Heltec V3 keeps disconnecting from my smartphone. It can't hold a solid Bluetooth connection.](#65-q-my-heltec-v3-keeps-disconnecting-from-my-smartphone--it-cant-hold-a-solid-bluetooth-connection)
- [7. Other Questions:](#7-other-questions)
- [7.1. Q: How to Update repeater and room server firmware over the air?](#71-q-how-to--update-repeater-and-room-server-firmware-over-the-air)
## 1. Introduction
### 1.1. Q: What is MeshCore?
**A:** MeshCore is free and open source
* MeshCore is the routing and firmware etc, available on GitHub under MIT license
* There are clients made by the community, such as the web clients, these are free to use, and some are open source too
* The cross platform mobile app developed by [Liam Cottle](https://liamcottle.net) for Android/iOS/PC etc is free to download and use
* The T-Deck firmware is developed by Scott at Ripple Radios, the creator of MeshCore, is also free to flash on your devices and use
Some more advanced, but optional features are available on T-Deck if you register your device for a key to unlock. On the MeshCore smartphone clients for Android and iOS/iPadOS, you can unlock the wait timer for repeater and room server remote management over RF feature.
These features are completely optional and aren't needed for the core messaging experience. They're like super bonus features and to help the developers continue to work on these amazing features, they may charge a small fee for an unlock code to utilise the advanced features.
Anyone is able to build anything they like on top of MeshCore without paying anything.
### 1.2. Q: What do you need to start using MeshCore?
**A:** Everything you need for MeshCore is available at:
Main web site: [https://meshcore.co.uk/](https://meshcore.co.uk/)
Firmware Flasher: https://flasher.meshcore.co.uk/
Phone Client Applications: https://meshcore.co.uk/apps.html
MeshCore Fimrware Github: https://github.com/ripplebiz/MeshCore
NOTE: Andy Kirby has a very useful [intro video](https://www.youtube.com/watch?v=t1qne8uJBAc) for beginners.
You need LoRa hardware devices to run MeshCore firmware as clients or server (repeater and room server).
#### 1.2.1. Hardware
To use MeshCore without using a phone as the client interface, you can run MeshCore on a T-Deck or T-Deck Plus. It is a complete off-grid secure communication solution.
MeshCore is also available on a variety of 868MHz and 915MHz LoRa devices. For example, RAK4631 devices (19003, 19007, 19026), Heltec V3, Xiao S3 WIO, Xiao C3, Heltec T114, Station G2, Seeed Studio T1000-E. More devices will be supported later.
#### 1.2.2. Firmware
MeshCore has four firmware types that are not available on other LoRa systems. MeshCore has the following:
#### 1.2.3. Companion Radio Firmware
Companion radios are for connecting to the Android app or web app as a messenger client. There are two different companion radio firmware versions:
1. **BLE Companion**
BLE Companion firmware runs on a supported LoRa device and connects to a smart device running the Android MeshCore client over BLE (iOS MeshCore client will be available soon)
<https://meshcore.co.uk/apps.html>
2. **USB Serial Companion**
USB Serial Companion firmware runs on a supported LoRa device and connects to a smart device or a computer over USB Serial running the MeshCore web client
<https://meshcore.liamcottle.net/#/>
<https://client.meshcore.co.uk/tabs/devices>
#### 1.2.4. Repeater
Repeaters are used to extend the range of a MeshCore network. Repeater firmware runs on the same devices that run client firmware. A repeater's job is to forward MeshCore packets to the destination device. It does **not** forward or retransmit every packet it receives, unlike other LoRa mesh systems.
A repeater can be remotely administered using a T-Deck running the MeshCore firwmware with remote admistration features unlocked, or from a BLE Companion client connected to a smartphone running the MeshCore app.
#### 1.2.5. Room Server
A room server is a simple BBS server for sharing posts. T-Deck devices running MeshCore firmware or a BLE Companion client connected to a smartphone running the MeshCore app can connect to a room server.
room servers store message history on them, and push the stored messages to users. Room servers allow roaming users to come back later and retrieve message history. Contrast to channels, messages are either received when it's sent, or not received and missed if the a room user is out of range. You can think of room servers like email servers where you can come back later and get your emails from your mail server
A room server can be remotely administered using a T-Deck running the MeshCore firwmware with remote admistration features unlocked, or from a BLE Companion client connected to a smartphone running the MeshCore app.
When a client logs into a room server, the client will receive the previously 16 unseen messages.
A room server can also take on the repeater role. To enable repeater role on a room server, use this command:
`set repeat {on|off}`
---
## 2. Initial Setup
### 2.1. Q: How many devices do I need to start using meshcore?
**A:** If you have one supported device, flash the BLE Companion firmware and use your device as a client. You can connect to the device using the Android client via bluetooth (iOS client will be available later). You can start communiating with other MeshCore users near you.
If you have two supported devices, and there are not many MeshCore users near you, flash both of them to BLE Companion firmware so you can use your devices to communiate with your near-by friends and family.
If you have two supported devices, and there are other MeshcCore users near by, you can flash one of your devices with BLE Companion firmware, and flash another supported device to repeater firmware. Place the repeater high above ground o extend your MeshCore network's reach.
After you flashed the latest firmware onto your repeater device, keep the device connected to your computer via USB serial, use the console feature on the web flasher and set the frequency for your region or country, so your client can remote administer the rpeater or room server over RF:
`set freq {frequency}`
The repeater and room server CLI reference is here: https://github.com/ripplebiz/MeshCore/wiki/Repeater-&-Room-Server-CLI-Reference
If you have more supported devices, you can use your additional deivces with the room server firmware.
### 2.2. Q: Does MeshCore cost any money?
**A:** All radio firmware versions (e.g. for Heltec V3, RAK, T-1000E, etc) are free and open source developed by Scott at Ripple Radios.
The native Android and iOS client uses the freemium model and is developed by Liam Cottle, developer of meshtastic map at [meshtastic.liamcottle.net](https://meshtastic.liamcottle.net) on [github ](https://github.com/liamcottle/meshtastic-map)and [reticulum-meshchat on github](https://github.com/liamcottle/reticulum-meshchat).
The T-Deck firmware is free to download and most features are available without cost. To support the firmware developer, you can pay for a registration key to unlock your T-Deck for deeper map zoom and remote server administration over RF using the T-Deck. You do not need to pay for the registration to use your T-Deck for direct messaging and connecting to repeaters and room servers.
### 2.3. Q: What frequencies are supported by MeshCore?
**A:** It supports the 868MHz range in the UK/EU and the 915MHz range in New Zealand, Australia, and the USA. Countries and regions in these two frequency ranges are also supported. The firmware and client allow users to set their preferred frequency.
- Australia and New Zealand are on **915.8MHz**
- UK and EU are on **869.525MHz**
- Canada and USA are on **910.525MHz**
- For other regions and countries, please check your local LoRa frequency
In UK and EU, 867.5MHz is not allowed to use 250kHz bandwidth and it only allows 2.5% duty cycle for clients. 869.525Mhz allows an airtime of 10%, 250KHz bandwidth, and a higher EIRP, therefore MeshCore nodes can send more often and with more power. That is why this frequency is chosen for UK and EU. This is also why Meshtastic also uses this frequency.
[Source]([https://](https://discord.com/channels/826570251612323860/1330643963501351004/1356540643853209641))
the rest of the radio settings are the same for all frequencies:
- Spread Factor (SF): 10
- Coding Rate (CR): 5
- Bandwidth (BW): 250.00
### 2.4. Q: What is an "advert" in MeshCore?
**A:**
Advert means to advertise yourself on the network. In Reticulum terms it would be to announce. In Meshtastic terms it would be the node sending it's node info.
MeshCore allows you to manually broadcast your name, position and public encryption key, which is also signed to prevent spoofing. When you click the advert button, it broadcasts that data over LoRa. MeshCore calls that an Advert. There's two ways to advert, "zero hop" and "flood".
* Zero hop means your advert is broadcasted out to anyone that can hear it, and that's it.
* Flooded means it's broadcasted out, and then repeated by all the repeaters that hear it.
MeshCore clients only advertise themselves when the user initiates it. A repeater (and room server?) advertises its presence once every 240 minutes. This interval can be configured using the following command:
`set advert.interval {minutes}`
### 2.5. Q: Is there a hop limit?
**A:** Internally the firmware has maximum limit of 64 hops. In real world settings it will be difficult to get close to the limit due to the environments and timing as packets travel further and further. We want to hear how far your MeshCore conversations go.
---
## 3. Server Administration
### 3.1. Q: How do you configure a repeater or a room server?
**A:** - When MeshCore is flashed onto a LoRa device is for the first time, it is necessary to set the server device's frequency to make it utilize the frequency that is legal in your country or region.
Repeater or room server can be administered with one of the options below:
- After a repeater or room server firmware is flashed on to a LoRa device, go to <https://config.meshcore.dev> and use the web user interface to connect to the LoRa device via USB serial. From there you can set the name of the server, its frequency and other related settings, location, passwords etc.
![image](https://github.com/user-attachments/assets/bec28ff3-a7d6-4a1e-8602-cb6b290dd150)
- Connect the server device using a USB cable to a computer running Chrome on https://flasher.meshcore.co.uk/, then use the `console` feature to connect to the device
- Use a MeshCore smartphone clients to remotely administer servers via LoRa.
- A T-Deck running unlocked/registered MeshCore firmware. Remote server administration is enabled through registering your T-Deck with Ripple Radios. It is one of the ways to support MeshCore development. You can register your T-Deck at:
<https://buymeacoffee.com/ripplebiz/e/249834>
### 3.2. Q: Do I need to set the location for a repeater?
**A:** With location set for a repeater, it can show up on a MeshCore map in the future. Set location with the following commands:
`set lat <GPS Lat> set long <GPS Lon>`
You can get the latitude and longitude from Google Maps by right-clicking the location you are at on the map.
### 3.3. Q: What is the password to administer a repeater or a room server?
**A:** The default admin password to a repeater and room server is `password`. Use the following command to change the admin password:
`password {new-password}`
### 3.4. Q: What is the password to join a room server?
**A:** The default guest password to a room server is `hello`. Use the following command to change the guest password:
`set guest.password {guest-password}`
---
## 4. T-Deck Related
### 4.1. Q: What are the steps to get a T-Deck into DFU (Device Firmware Update) mode?
**A:**
1. Device off
2. Connect USB cable to device
3. Hold down trackball (keep holding)
4. Turn on device
5. Hear USB connection sound
6. Release trackball
7. T-Deck in DFU mode now
8. At this point you can begin flashing using <https://flasher.meshcore.co.uk/>
### 4.2. Q: Why is my T-Deck Plus not getting any satellite lock?
**A:** For T-Deck Plus, the GPS baud rate should be set to **38400**. Also, a number of T-Deck Plus devices were found to have the GPS module installed upside down, with the GPS antenna facing down instead of up. If your T-Deck Plus still doesn't get any satellite lock after setting the baud rate to 38400, you might need to open up the device to check the GPS orientation.
GPS on T-Deck is always enabled. You can skip the "GPS clock sync" and the T-Deck will continue to try to get a GPS lock. You can go to the `GPS Info` screen, you should see the `Sentences:` coutner increasing if the baud rate is correct.
[Source]([https://](https://discord.com/channels/826570251612323860/1330643963501351004/1356609240302616689))
### 4.3. Q: Why is my OG (non-Plus) T-Deck not getting any satellite lock?
**A:** The OG (non-Plus) T-Deck doesn't come with a GPS. If you added a GPS to your OG T-Deck, please refer to the manual of your GPS to see what baud rate it requires. Alternatively, you can try to set the baud rate from 9600, 19200, etc., and up to 115200 to see which one works.
### 4.4. Q: What size of SD card does the T-Deck support?
**A:** Users have had no issues using 16GB or 32GB SD cards. Format the SD card to **FAT32**.
### 4.5. Q: How do I get maps on T-Deck?
**A:** You need map tiles. You can get pre-downloaded map tiles here (a good way to support development):
- <https://buymeacoffee.com/ripplebiz/e/342543> (Europe)
- <https://buymeacoffee.com/ripplebiz/e/342542> (US)
Another way to download map tiles is to use this Python script to get the tiles in the areas you want:
<https://github.com/fistulareffigy/MTD-Script>
There is also a modified script that adds additional error handling and parallel downloads:
<https://discord.com/channels/826570251612323860/1330643963501351004/1338775811548905572>
UK map tiles are available separately from Andy Kirby on his discord server:
<https://discord.com/channels/826570251612323860/1330643963501351004/1331346597367386224>
### 4.6. Q: Where do the map tiles go?
Once you have the tiles downloaded, copy the `\tiles` folder to the root of your T-Deck's SD card.
### 4.7. Q: How to unlock deeper map zoom and server management features on T-Deck?
**A:** You can download, install, and use the T-Deck firmware for free, but it has some features (map zoom, server administration) that are enabled if you purchase an unlock code for \$10 per T-Deck device.
Unlock page: <https://buymeacoffee.com/ripplebiz/e/249834>
### 4.8. Q: How to decipher the diagnostics screen on T-Deck?
**A: ** Space is tight on T-Deck's screen so the information is a bit cryptic. Format is :
`{hops} l:{packet-length}({payload-len}) t:{packet-type} snr:{n} rssi:{n}`
See here for packet-type: [https://github.com/ripplebiz/MeshCore/blob/main/src/Packet.h#L19](https://github.com/ripplebiz/MeshCore/blob/main/src/Packet.h#L19 "https://github.com/ripplebiz/MeshCore/blob/main/src/Packet.h#L19")
#define PAYLOAD_TYPE_REQ 0x00 // request (prefixed with dest/src hashes, MAC) (enc data: timestamp, blob)
#define PAYLOAD_TYPE_RESPONSE 0x01 // response to REQ or ANON_REQ (prefixed with dest/src hashes, MAC) (enc data: timestamp, blob)
#define PAYLOAD_TYPE_TXT_MSG 0x02 // a plain text message (prefixed with dest/src hashes, MAC) (enc data: timestamp, text)
#define PAYLOAD_TYPE_ACK 0x03 // a simple ack #define PAYLOAD_TYPE_ADVERT 0x04 // a node advertising its Identity
#define PAYLOAD_TYPE_GRP_TXT 0x05 // an (unverified) group text message (prefixed with channel hash, MAC) (enc data: timestamp, "name: msg")
#define PAYLOAD_TYPE_GRP_DATA 0x06 // an (unverified) group datagram (prefixed with channel hash, MAC) (enc data: timestamp, blob)
#define PAYLOAD_TYPE_ANON_REQ 0x07 // generic request (prefixed with dest_hash, ephemeral pub_key, MAC) (enc data: ...)
#define PAYLOAD_TYPE_PATH 0x08 // returned path (prefixed with dest/src hashes, MAC) (enc data: path, extra)
[Source](https://discord.com/channels/1343693475589263471/1343693475589263474/1350611321040932966)
### 4.9. Q: The T-Deck sound is too loud?
### 4.10. Q: Can you customize the sound?
**A:** You can customise the sounds on the T-Deck, just by placing `.mp3` files onto the `root` dir of the SD card. `startup.mp3`, `alert.mp3` and `new-advert.mp3`
### 4.11. Q: What is the 'Import from Clipboard' feature on the t-deck and is there a way to manually add nodes without having to receive adverts?
**A:** 'Import from Clipboard' is for importing a contact via a file named 'clipboard.txt' on the SD card. The opposite, is in the Identity screen, the 'Card to Clipboard' menu, which writes to 'clipboard.txt' so you can share yourself (call these 'biz cards', that start with "meshcore://...")
---
## 5. General
### 5.1. Q: What are BW, SF, and CR?
**A:**
**BW is bandwidth** - width of frequency spectrum that is used for transmission
**SF is spreading factor** - how much should the communication spread in time
**CR is coding rate** - https://www.thethingsnetwork.org/docs/lorawan/fec-and-code-rate/
Making the bandwidth 2x wider (from BW125 to BW250) allows you to send 2x more bytes in the same time. Making the spreading factor 1 step lower (from SF10 to SF9) allows you to send 2x more bytes in the same time.
Lowering the spreading factor makes it more difficult for the gateway to receive a transmission, as it will be more sensitive to noise. You could compare this to two people taking in a noisy place (a bar for example). If you’re far from each other, you have to talk slow (SF10), but if you’re close, you can talk faster (SF7)
So it's balancing act between speed of the transmission and resistance to noise.
things network is mainly focused on LoRaWAN, but the LoRa low-level stuff still checks out for any LoRa project
### 5.2. Q: Do MeshCore clients repeat?
**A:** No, MeshCore clients do not repeat. This is the core of MeshCore's messaging-first design. This is to avoid devices flooding the air ware and create endless collisions so messages sent aren't received.
In MeshCore, only repeaters and room server with '`set repeat on` repeat.
### 5.3. Q: What happens when a node learns a route via a mobile repeater, and that repeater is gone?
**A:** If you used to reach a node through a repeater and the repeater is no longer reachable, the client will send the message using the existing (but now broken) known path, the message will fail after 3 retries, and the app will reset the path and send the message as flood on the last retry by default. This can be turned off in settings. If the destination is reachable directly or through another repeater, the new path will be used going forward. Or you can set the path manually if you know a specific repeater to use to reach that destination.
In the case if users are moving around frequently, and the paths are breaking, they just see the phone client retries and revert to flood to attempt to reestablish a path.
### 5.4. Q: How does a node discovery a path to its destination and then use it to send messages in the future, instead of flooding every message it sends like Meshtastic?
Routes are stored in sender's contact list. When you send a message the first time, the message first gets to your destination by flood routing, When your destination node gets the message, it sends back to the sender a delivery report with all repeaters that the original message went through. This delivery report is flood-routed back to you the sender and is a basis for future direct path. when you send the next message, the path will get embedded into the packet and be evaluated by repeaters. if the hop and address of the repeater matches, it will retransmit the message, otherwise it will not retransmit, hence minimizing utilization.
[Source](https://discord.com/channels/826570251612323860/1330643963501351004/1351279141630119996)
### 5.5. Q: Do public channels always flood? Do private channels always flood?
**A:** Yes, group channels are A to B, so there is no defined path. They have to flood. Repeaters can however deny flood traffic up to some hop limit, with the `set flood.max` CLI command. Admistrators of repeaters get to set the rules of their repeaters.
[Source](https://discord.com/channels/1343693475589263471/1343693475589263474/1350023009527664672)
### 5.6. Q: what is the public key for the default public channel?
**A:** The smartphone app key is in hex:
` 8b3387e9c5cdea6ac9e5edbaa115cd72`
T-Deck uses the same key but in base64
`izOH6cXN6mrJ5e26oRXNcg==`
The third character is the capital letter 'O', not zero `0`
[Source](https://discord.com/channels/826570251612323860/1330643963501351004/1354194409213792388)
### 5.7. Q: Is MeshCore open source?
**A:** Most of the firmware is freely available. Everything is open source except the T-Deck firmware and Liam's native mobile apps.
- Firmware repo: <https://github.com/ripplebiz/MeshCore>
### 5.8. Q: How can I support MeshCore?
**A:** Provide your honest feedback on GitHub and on AndyKirby's Discord server <http://discord.com/invite/H62Re4DCeD>. Spread the word of MeshCore to your friends and communities; help them get started with MeshCore. Support Scott's MeshCore development at <https://buymeacoffee.com/ripplebiz>.
Support Liam Cottle's smartphone client development by unlocking the server administration wait gate with in-app purchase
Support Rastislav Vysoky (recrof)'s flasher web site and the map web site development through [PayPal](https://www.paypal.com/donate/?business=DREHF5HM265ES&no_recurring=0&item_name=If+you+enjoy+my+work%2C+you+can+support+me+here%3A&currency_code=EUR) or [Revolut](https://revolut.me/recrof)
### 5.9. Q: How do I build MeshCore firmware from source?
**A:** See instructions here:
https://discord.com/channels/826570251612323860/1330643963501351004/1341826372120608769
Build instructions for MeshCore:
For Windows, first install WSL and Python+pip via: https://plainenglish.io/blog/setting-up-python-on-windows-subsystem-for-linux-wsl-26510f1b2d80
(Linux, Windows+WSL) In the terminal/shell:
```
sudo apt update
sudo apt install libpython3-dev
sudo apt install python3-venv
```
Mac: python3 should be already installed.
Then it should be the same for all platforms:
```
python3 -m venv meshcore
cd meshcore && source bin/activate
pip install -U platformio
git clone https://github.com/ripplebiz/MeshCore.git
cd MeshCore
```
open platformio.ini and in `[arduino_base]` edit the `LORA_FREQ=867.5`
save, then run:
```
pio run -e RAK_4631_Repeater
```
then you'll find `firmware.zip` in `.pio/build/RAK_4631_Repeater`
Andy also has a video on how to build using VS Code:
*How to build and flash Meshcore repeater firmware | Heltec V3*
<https://www.youtube.com/watch?v=WJvg6dt13hk> *(Link referenced in the Discord post)*
### 5.10. Q: Are there other MeshCore related open source projects?
**A:** [Liam Cottle](https://liamcottle.net)'s MeshCore web client and MeshCore Javascript libary are open source under MIT license.
Web client: https://github.com/liamcottle/meshcore-web
Javascript: https://github.com/liamcottle/meshcore.js
### 5.11. Q: Does MeshCore support ATAK
**A:** ATAK is not currently on MeshCore's roadmap.
Meshcore would not be best suited to ATAK because MeshCore:
clients do not repeat and therefore you would need a network of repeaters in place
will not have a stable path where all clients are constantly moving between repeaters
MeshCore clients would need to reset path constantly and flood traffic across the network which could lead to lots of collisions with something as chatty as ATAK.
This could change in the future if MeshCore develops a client firmware that repeats.
[Source](https://discord.com/channels/826570251612323860/1330643963501351004/1354780032140054659)
### 5.12. Q: How do I add a node to the [MeshCore Map]([url](https://meshcore.co.uk/map.html))
**A:** From the smartphone app, connect to a BLE Companion radio
- To add the BLE Companion radio your smartphone is connected to to the map, tap the `advert` icon, then tap `Advert (To Clipboard)`.
- To add a Repeater or Room Server to the map, tap the 3 dots next to the Repeater or Room Server you want to add to the map, then tap `Share (To Clipboard)`.
- Go to the [MeshCore Map web site]([url](https://meshcore.co.uk/map.html)), tap the plus sign on the lower right corner and paste in the meshcore://... blob, then tap `Add Node`
### 5.13. Q: Can I use a Raspberry Pi to update a MeshCore radio?
** A:** Yes.
You will need to install picocom on the pi.
`sudo apt install picocom`
Then run the following commands to setup the repeater.
```
picocom -b 115200 /dev/ttyUSB0 --imap lfcrlf
set name your_repeater_name
time epoch_time
password your_unique_password
set advert.interval 240
advert
```
Note: If using a RAK the path will most likely be /dev/ttyACM0
Epoch time comes from https://www.epochconverter.com/
You can also flash the repeater using esptool. You will need to install esptool with the following command...
`pip install esptool --break-system-packages`
Then to flash the firmware to Heltec, obtain the .bin file from https://flasher.meshcore.co.uk/ (download all firmware link)
For Heltec:
`esptool.py -p /dev/ttyUSB0 --chip esp32-s3 write_flash 0x00000 firmware.bin`
If flashing a visual studio code build bin file, flash with the following offset:
`esptool.py -p /dev/ttyUSB0 --chip esp32-s3 write_flash 0x10000 firmware.bin`
For Pi
Download the zip from the online flasher website and use the following command:
Note: Requires adafruit-nrfutil command which can be installed as follows.
`pip install adafruit-nrfutil --break-system-packages`
```
adafruit-nrfutil --verbose dfu serial --package t1000_e_bootloader-0.9.1-5-g488711a_s140_7.3.0.zip -p /dev/ttyACM0 -b 115200 --singlebank --touch 1200
```
[Source](https://discord.com/channels/826570251612323860/1330643963501351004/1342120825251299388)
### 5.14. Q: Are there are projects built around MeshCore?
**A:** Yes. See the following:
#### 5.14.1. meshcoremqtt
A python based script to send meshore debug and packet capture data to MQTT for analysis
https://github.com/Andrew-a-g/meshcoretomqtt
#### 5.14.2. MeshCore for Home Assistant
A custom Home Assistant integration for MeshCore mesh radio nodes. It allows you to monitor and control MeshCore nodes via USB, BLE, or TCP connections.
https://github.com/awolden/meshcore-ha
#### 5.14.3. Python MeshCore
Bindings to access your MeshCore companion radio nodes in python.
https://github.com/fdlamotte/meshcore_py
#### 5.14.4. meshcore-cli
CLI interface to MeshCore companion radio over BLE, TCP, or serial. Uses Pyton MeshCore above.
https://github.com/fdlamotte/meshcore-cli
#### 5.14.5. meshcore.js
A Javascript library for interacting with a MeshCore device running the companion radio firmware
https://github.com/liamcottle/meshcore.js
---
## 6. Troubleshooting
### 6.1. Q: My client says another client or a repeater or a room server was last seen many, many days ago.
### 6.2. Q: A repeater or a client or a room server I expect to see on my discover list (on T-Deck) or contact list (on a smart device client) are not listed.
**A:**
- If your client is a T-Deck, it may not have its time set (no GPS installed, no GPS lock, or wrong GPS baud rate).
- If you are using the Android or iOS client, the other client, repeater, or room server may have the wrong time.
You can get the epoch time on <https://www.epochconverter.com/> and use it to set your T-Deck clock. For a repeater and room server, the admin can use a T-Deck to remotely set their clock (clock sync), or use the `time` command in the USB serial console with the server device connected.
### 6.3. Q: How to connect to a repeater via BLE (bluetooth)?
**A:** You can't connect to a device running repeater firmware via bluetooth. Devices running the BLE companion firmware you can connect to it via bluetooth using the android app
### 6.4. Q: I can't connect via bluetooth, what is the bluetooth pairing code?
**A:** the default bluetooth pairing code is `123456`
### 6.5. Q: My Heltec V3 keeps disconnecting from my smartphone. It can't hold a solid Bluetooth connection.
**A:** Heltec V3 has a very small coil antenna on its PCB for WiFi and Bluetooth connectivty. It has a very short range, only a few feet. It is possible to remove the coil antenna and replace it with a 31mm wire. The BT range is much improved with the modification.
---
## 7. Other Questions:
### 7.1. Q: How to Update repeater and room server firmware over the air?
**A:** Only nRF-based RAK4631 and Heltec T114 OTA firmware update are verified using nRF smartphone app. Lilygo T-Echo doesn't work currently.
You can update repeater and room server firmware with a bluetooth connection between your smartphone and your LoRa radio using the nRF app.
1. Download the ZIP file for the specific node from the web flasher to your smartphone
2. On the phone client, log on to the repeater as administrator (default password is `password`) to issue the `start ota`command to the repeater or room server to get the device into OTA DFU mode
![image](https://github.com/user-attachments/assets/889bb81b-7214-4a1c-955a-396b5a05d8ad)
1. `start ota` can be initiated from USB serial console on the web flasher page or a T-Deck
4. On the smartphone, download and run the nRF app and scan for Bluetooth devices
5. Connect to the repeater/room server node you want to update
1. nRF app is available on both Android and iOS
**Android continues after the iOS section:**
**iOS continues here:**
5. Once connected successfully, a `DFU` icon ![Pasted image 20250309173039](https://github.com/user-attachments/assets/af7a9f78-8739-4946-b734-02bade9c8e71)
appears in the top right corner of the app
![Pasted image 20250309171919](https://github.com/user-attachments/assets/08007ec8-4924-49c1-989f-ca2611e78793)
6. Scroll down to change the `PRN(s)` number:
![Pasted image 20250309190158](https://github.com/user-attachments/assets/11f69cdd-12f3-4696-a6fc-14a78c85fe32)
- For the T114, change the number of packets `(PRN(s)` to 8
- For RAK, it can be 10, but it also works on 8.
7. Click the `DFU` icon ![Pasted image 20250309173039](https://github.com/user-attachments/assets/af7a9f78-8739-4946-b734-02bade9c8e71), select the type of file to upload (choose ZIP), then select the ZIP file that was downloaded earlier from the web flasher
8. The upload process will start now. If everything goes well, the node resets and is flashed successfully.
![Pasted image 20250309190342](https://github.com/user-attachments/assets/a60e25d0-33b8-46cf-af90-20a7d8ac2adb)
**Android steps continues below:**
1. on the top left corner of the nRF Connect app on Android, tap the 3-bar hamburger menu, then `Settings`, then `nRF5 DFU Options`
![Android nRF Hamberger](https://github.com/user-attachments/assets/ea6dfeef-9367-4830-bd70-1441d517c706)
![Android nRF Settings](https://github.com/user-attachments/assets/c63726bf-cecd-4987-be68-afb6358c7190)
![Android nRF DFU Options](https://github.com/user-attachments/assets/b20e872f-5122-41d9-90df-0215cff5fbc9)
2. Change `Number of packets` to `10` for RAK, `8` for Heltec T114
![Android nRF Number of Packets](https://github.com/user-attachments/assets/c092adaf-4cb3-460b-b7ef-8d7f450d602b)
3. Go back to the main screen
4. Your LoRa device should already ben in DFU mode from previous steps
5. tap `SCANNER` and then `SCAN` to find the device you want to update, tap `CONNECT`
![Android nRF Scanner Scan Connect](https://github.com/user-attachments/assets/37218717-f167-48b6-a6ca-93d132ef77ca)
6. On the top left corner of the nRF Connect app, tap the `DFU` icon next to the three dots
![Android nRF DFU](https://github.com/user-attachments/assets/1ec3b818-bf0c-461f-8fdf-37c41a63cafa)
7. Choose `Distribution packet (ZIP)` and then `OK`
![Android nRF Distribution Packet (ZIP)](https://github.com/user-attachments/assets/e65f5616-9793-44f5-95c0-a3eb15aa7152)
8. Choose the firmware file in ZIP formate that you downloaded earlier from the MeshCore web flasher, update will start as soon as you tap the file
![Android nRF FW Updating](https://github.com/user-attachments/assets/0814d123-85ce-4c87-90a7-e1a25dc71900)
9. When the update process is done, the device will disconnect from nRF app and the LoRa device is updated
---
+187
View File
@@ -0,0 +1,187 @@
#include "UITask.h"
#include <Arduino.h>
#include <helpers/TxtDataHelpers.h>
#define AUTO_OFF_MILLIS 15000 // 15 seconds
#ifndef USER_BTN_PRESSED
#define USER_BTN_PRESSED LOW
#endif
// '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(DisplayDriver* display, const char* node_name, const char* build_date, uint32_t pin_code) {
_display = display;
_auto_off = millis() + AUTO_OFF_MILLIS;
clearMsgPreview();
_node_name = node_name;
_build_date = build_date;
_pin_code = pin_code;
if (_display != NULL) {
_display->turnOn();
}
}
void UITask::msgRead(int msgcount) {
_msgcount = msgcount;
if (msgcount == 0) {
clearMsgPreview();
}
}
void UITask::clearMsgPreview() {
_origin[0] = 0;
_msg[0] = 0;
}
void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount) {
_msgcount = msgcount;
if (path_len == 0xFF) {
sprintf(_origin, "(F) %s", from_name);
} else {
sprintf(_origin, "(%d) %s", (uint32_t) path_len, from_name);
}
StrHelper::strncpy(_msg, text, sizeof(_msg));
if (_display != NULL) {
if (!_display->isOn()) _display->turnOn();
_auto_off = millis() + AUTO_OFF_MILLIS; // extend the auto-off timer
}
}
void UITask::renderCurrScreen() {
if (_display == NULL) return; // assert() ??
char tmp[80];
if (_origin[0] && _msg[0]) {
// render message preview
_display->setCursor(0, 0);
_display->setTextSize(1);
_display->print(_node_name);
_display->setCursor(0, 12);
_display->print(_origin);
_display->setCursor(0, 24);
_display->print(_msg);
_display->setCursor(100, 9);
_display->setTextSize(2);
sprintf(tmp, "%d", _msgcount);
_display->print(tmp);
} else {
// render 'home' screen
_display->drawXbm(0, 0, meshcore_logo, 128, 13);
_display->setCursor(0, 20);
_display->setTextSize(1);
_display->print(_node_name);
sprintf(tmp, "Build: %s", _build_date);
_display->setCursor(0, 32);
_display->print(tmp);
if (_connected) {
//_display->printf("freq : %03.2f sf %d\n", _prefs.freq, _prefs.sf);
//_display->printf("bw : %03.2f cr %d\n", _prefs.bw, _prefs.cr);
} else if (_pin_code != 0) {
_display->setTextSize(2);
_display->setCursor(0, 43);
sprintf(tmp, "Pin:%d", _pin_code);
_display->print(tmp);
}
}
}
void UITask::userLedHandler() {
#ifdef PIN_STATUS_LED
static int state = 0;
static int next_change = 0;
int cur_time = millis();
if (cur_time > next_change) {
if (state == 0) {
state = 1; // led on, short = unread msg
if (_msgcount > 0) {
next_change = cur_time + 500;
} else {
next_change = cur_time + 2000;
}
} else {
state = 0;
if (_board->getBattMilliVolts() > 3800) {
next_change = cur_time + 2000;
} else {
next_change = cur_time + 4000; // 4s blank if bat level low
}
}
digitalWrite(PIN_STATUS_LED, state);
}
#endif
}
void UITask::buttonHandler() {
#ifdef PIN_USER_BTN
static int prev_btn_state = !USER_BTN_PRESSED;
static unsigned long btn_state_change_time = 0;
static unsigned long next_read = 0;
int cur_time = millis();
if (cur_time >= next_read) {
int btn_state = digitalRead(PIN_USER_BTN);
if (btn_state != prev_btn_state) {
if (btn_state == USER_BTN_PRESSED) { // pressed?
if (_display != NULL) {
if (_display->isOn()) {
clearMsgPreview();
} else {
_display->turnOn();
}
_auto_off = cur_time + AUTO_OFF_MILLIS; // extend auto-off timer
}
} else { // unpressed ? check pressed time ...
if ((cur_time - btn_state_change_time) > 5000) {
#ifdef PIN_STATUS_LED
digitalWrite(PIN_STATUS_LED, LOW);
delay(10);
#endif
_board->powerOff();
}
}
btn_state_change_time = millis();
prev_btn_state = btn_state;
}
next_read = millis() + 100; // 10 reads per second
}
#endif
}
void UITask::loop() {
buttonHandler();
userLedHandler();
if (_display != NULL && _display->isOn()) {
if (millis() >= _next_refresh) {
_display->startFrame();
renderCurrScreen();
_display->endFrame();
_next_refresh = millis() + 1000; // refresh every second
}
if (millis() > _auto_off) {
_display->turnOff();
}
}
}
+37
View File
@@ -0,0 +1,37 @@
#pragma once
#include <MeshCore.h>
#include <helpers/ui/DisplayDriver.h>
#include <stddef.h>
class UITask {
DisplayDriver* _display;
mesh::MainBoard* _board;
unsigned long _next_refresh, _auto_off;
bool _connected;
uint32_t _pin_code;
const char* _node_name;
const char* _build_date;
char _origin[62];
char _msg[80];
int _msgcount;
void renderCurrScreen();
void buttonHandler();
void userLedHandler();
public:
UITask(mesh::MainBoard* board) : _board(board), _display(NULL) {
_next_refresh = 0;
_connected = false;
}
void begin(DisplayDriver* display, const char* node_name, const char* build_date, uint32_t pin_code);
void setHasConnection(bool connected) { _connected = connected; }
bool hasDisplay() const { return _display != NULL; }
void clearMsgPreview();
void msgRead(int msgcount);
void newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount);
void loop();
};
File diff suppressed because it is too large. Load diff
+79
View File
@@ -0,0 +1,79 @@
#include "UITask.h"
#include <Arduino.h>
#define AUTO_OFF_MILLIS 20000 // 20 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(const char* node_name, const char* build_date) {
_prevBtnState = HIGH;
_auto_off = millis() + AUTO_OFF_MILLIS;
_node_name = node_name;
_build_date = build_date;
_display->turnOn();
}
void UITask::renderCurrScreen() {
char tmp[80];
// render 'home' screen
_display->drawXbm(0, 0, meshcore_logo, 128, 13);
_display->setCursor(0, 20);
_display->setTextSize(1);
_display->print(_node_name);
sprintf(tmp, "Build: %s", _build_date);
_display->setCursor(0, 32);
_display->print(tmp);
_display->setCursor(0, 43);
_display->print("< Repeater >");
//_display->printf("freq : %03.2f sf %d\n", _prefs.freq, _prefs.sf);
//_display->printf("bw : %03.2f cr %d\n", _prefs.bw, _prefs.cr);
}
void UITask::loop() {
#ifdef PIN_USER_BTN
if (millis() >= _next_read) {
int btnState = digitalRead(PIN_USER_BTN);
if (btnState != _prevBtnState) {
if (btnState == LOW) { // 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();
}
}
}
+18
View File
@@ -0,0 +1,18 @@
#pragma once
#include <helpers/ui/DisplayDriver.h>
class UITask {
DisplayDriver* _display;
unsigned long _next_read, _next_refresh, _auto_off;
int _prevBtnState;
const char* _node_name;
const char* _build_date;
void renderCurrScreen();
public:
UITask(DisplayDriver& display) : _display(&display) { _next_read = _next_refresh = 0; }
void begin(const char* node_name, const char* build_date);
void loop();
};
+694
View File
@@ -0,0 +1,694 @@
#include <Arduino.h> // needed for PlatformIO
#include <Mesh.h>
#if defined(NRF52_PLATFORM)
#include <InternalFileSystem.h>
#elif defined(ESP32)
#include <SPIFFS.h>
#endif
#include <helpers/ArduinoHelpers.h>
#include <helpers/StaticPoolPacketManager.h>
#include <helpers/SimpleMeshTables.h>
#include <helpers/IdentityStore.h>
#include <helpers/AdvertDataHelpers.h>
#include <helpers/TxtDataHelpers.h>
#include <helpers/CommonCLI.h>
#include <RTClib.h>
#include <target.h>
/* ------------------------------ Config -------------------------------- */
#ifndef FIRMWARE_BUILD_DATE
#define FIRMWARE_BUILD_DATE "7 Apr 2025"
#endif
#ifndef FIRMWARE_VERSION
#define FIRMWARE_VERSION "v1.4.3"
#endif
#ifndef LORA_FREQ
#define LORA_FREQ 915.0
#endif
#ifndef LORA_BW
#define LORA_BW 250
#endif
#ifndef LORA_SF
#define LORA_SF 10
#endif
#ifndef LORA_CR
#define LORA_CR 5
#endif
#ifndef LORA_TX_POWER
#define LORA_TX_POWER 20
#endif
#ifndef ADVERT_NAME
#define ADVERT_NAME "repeater"
#endif
#ifndef ADVERT_LAT
#define ADVERT_LAT 0.0
#endif
#ifndef ADVERT_LON
#define ADVERT_LON 0.0
#endif
#ifndef ADMIN_PASSWORD
#define ADMIN_PASSWORD "password"
#endif
#ifdef DISPLAY_CLASS
#include <helpers/ui/SSD1306Display.h>
static DISPLAY_CLASS display;
#include "UITask.h"
static UITask ui_task(display);
#endif
#define FIRMWARE_ROLE "repeater"
#define PACKET_LOG_FILE "/packet_log"
/* ------------------------------ Code -------------------------------- */
#define CMD_GET_STATUS 0x01
#define RESP_SERVER_LOGIN_OK 0 // response to ANON_REQ
struct RepeaterStats {
uint16_t batt_milli_volts;
uint16_t curr_tx_queue_len;
uint16_t curr_free_queue_len;
int16_t last_rssi;
uint32_t n_packets_recv;
uint32_t n_packets_sent;
uint32_t total_air_time_secs;
uint32_t total_up_time_secs;
uint32_t n_sent_flood, n_sent_direct;
uint32_t n_recv_flood, n_recv_direct;
uint16_t n_full_events;
int16_t last_snr; // x 4
uint16_t n_direct_dups, n_flood_dups;
};
struct ClientInfo {
mesh::Identity id;
uint32_t last_timestamp, last_activity;
uint8_t secret[PUB_KEY_SIZE];
bool is_admin;
int8_t out_path_len;
uint8_t out_path[MAX_PATH_SIZE];
};
#define MAX_CLIENTS 4
// NOTE: need to space the ACK and the reply text apart (in CLI)
#define CLI_REPLY_DELAY_MILLIS 1500
class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
FILESYSTEM* _fs;
unsigned long next_local_advert, next_flood_advert;
bool _logging;
NodePrefs _prefs;
CommonCLI _cli;
uint8_t reply_data[MAX_PACKET_PAYLOAD];
ClientInfo known_clients[MAX_CLIENTS];
ClientInfo* putClient(const mesh::Identity& id) {
uint32_t min_time = 0xFFFFFFFF;
ClientInfo* oldest = &known_clients[0];
for (int i = 0; i < MAX_CLIENTS; i++) {
if (known_clients[i].last_activity < min_time) {
oldest = &known_clients[i];
min_time = oldest->last_activity;
}
if (id.matches(known_clients[i].id)) return &known_clients[i]; // already known
}
oldest->id = id;
oldest->out_path_len = -1; // initially out_path is unknown
oldest->last_timestamp = 0;
self_id.calcSharedSecret(oldest->secret, id); // calc ECDH shared secret
return oldest;
}
int handleRequest(ClientInfo* sender, uint8_t* payload, size_t payload_len) {
uint32_t now = getRTCClock()->getCurrentTimeUnique();
memcpy(reply_data, &now, 4); // response packets always prefixed with timestamp
switch (payload[0]) {
case CMD_GET_STATUS: { // guests can also access this now
RepeaterStats stats;
stats.batt_milli_volts = board.getBattMilliVolts();
stats.curr_tx_queue_len = _mgr->getOutboundCount();
stats.curr_free_queue_len = _mgr->getFreeCount();
stats.last_rssi = (int16_t) radio_driver.getLastRSSI();
stats.n_packets_recv = radio_driver.getPacketsRecv();
stats.n_packets_sent = radio_driver.getPacketsSent();
stats.total_air_time_secs = getTotalAirTime() / 1000;
stats.total_up_time_secs = _ms->getMillis() / 1000;
stats.n_sent_flood = getNumSentFlood();
stats.n_sent_direct = getNumSentDirect();
stats.n_recv_flood = getNumRecvFlood();
stats.n_recv_direct = getNumRecvDirect();
stats.n_full_events = getNumFullEvents();
stats.last_snr = (int16_t)(radio_driver.getLastSNR() * 4);
stats.n_direct_dups = ((SimpleMeshTables *)getTables())->getNumDirectDups();
stats.n_flood_dups = ((SimpleMeshTables *)getTables())->getNumFloodDups();
memcpy(&reply_data[4], &stats, sizeof(stats));
return 4 + sizeof(stats); // reply_len
}
}
// unknown command
return 0; // reply_len
}
mesh::Packet* createSelfAdvert() {
uint8_t app_data[MAX_ADVERT_DATA_SIZE];
uint8_t app_data_len;
{
AdvertDataBuilder builder(ADV_TYPE_REPEATER, _prefs.node_name, _prefs.node_lat, _prefs.node_lon);
app_data_len = builder.encodeTo(app_data);
}
return createAdvert(self_id, app_data, app_data_len);
}
File openAppend(const char* fname) {
#if defined(NRF52_PLATFORM)
return _fs->open(fname, FILE_O_WRITE);
#else
return _fs->open(fname, "a", true);
#endif
}
protected:
float getAirtimeBudgetFactor() const override {
return _prefs.airtime_factor;
}
bool allowPacketForward(const mesh::Packet* packet) override {
if (_prefs.disable_fwd) return false;
if (packet->isRouteFlood() && packet->path_len >= _prefs.flood_max) return false;
return true;
}
const char* getLogDateTime() override {
static char tmp[32];
uint32_t now = getRTCClock()->getCurrentTime();
DateTime dt = DateTime(now);
sprintf(tmp, "%02d:%02d:%02d - %d/%d/%d U", dt.hour(), dt.minute(), dt.second(), dt.day(), dt.month(), dt.year());
return tmp;
}
void logRxRaw(float snr, float rssi, const uint8_t raw[], int len) override {
#if MESH_PACKET_LOGGING
Serial.print(getLogDateTime());
Serial.print(" RAW: ");
mesh::Utils::printHex(Serial, raw, len);
Serial.println();
#endif
}
void logRx(mesh::Packet* pkt, int len, float score) override {
if (_logging) {
File f = openAppend(PACKET_LOG_FILE);
if (f) {
f.print(getLogDateTime());
f.printf(": RX, len=%d (type=%d, route=%s, payload_len=%d) SNR=%d RSSI=%d score=%d",
len, pkt->getPayloadType(), pkt->isRouteDirect() ? "D" : "F", pkt->payload_len,
(int)_radio->getLastSNR(), (int)_radio->getLastRSSI(), (int)(score*1000));
if (pkt->getPayloadType() == PAYLOAD_TYPE_PATH || pkt->getPayloadType() == PAYLOAD_TYPE_REQ
|| pkt->getPayloadType() == PAYLOAD_TYPE_RESPONSE || pkt->getPayloadType() == PAYLOAD_TYPE_TXT_MSG) {
f.printf(" [%02X -> %02X]\n", (uint32_t)pkt->payload[1], (uint32_t)pkt->payload[0]);
} else {
f.printf("\n");
}
f.close();
}
}
}
void logTx(mesh::Packet* pkt, int len) override {
if (_logging) {
File f = openAppend(PACKET_LOG_FILE);
if (f) {
f.print(getLogDateTime());
f.printf(": TX, len=%d (type=%d, route=%s, payload_len=%d)",
len, pkt->getPayloadType(), pkt->isRouteDirect() ? "D" : "F", pkt->payload_len);
if (pkt->getPayloadType() == PAYLOAD_TYPE_PATH || pkt->getPayloadType() == PAYLOAD_TYPE_REQ
|| pkt->getPayloadType() == PAYLOAD_TYPE_RESPONSE || pkt->getPayloadType() == PAYLOAD_TYPE_TXT_MSG) {
f.printf(" [%02X -> %02X]\n", (uint32_t)pkt->payload[1], (uint32_t)pkt->payload[0]);
} else {
f.printf("\n");
}
f.close();
}
}
}
void logTxFail(mesh::Packet* pkt, int len) override {
if (_logging) {
File f = openAppend(PACKET_LOG_FILE);
if (f) {
f.print(getLogDateTime());
f.printf(": TX FAIL!, len=%d (type=%d, route=%s, payload_len=%d)\n",
len, pkt->getPayloadType(), pkt->isRouteDirect() ? "D" : "F", pkt->payload_len);
f.close();
}
}
}
int calcRxDelay(float score, uint32_t air_time) const override {
if (_prefs.rx_delay_base <= 0.0f) return 0;
return (int) ((pow(_prefs.rx_delay_base, 0.85f - score) - 1.0) * air_time);
}
uint32_t getRetransmitDelay(const mesh::Packet* packet) override {
uint32_t t = (_radio->getEstAirtimeFor(packet->path_len + packet->payload_len + 2) * _prefs.tx_delay_factor);
return getRNG()->nextInt(0, 6)*t;
}
uint32_t getDirectRetransmitDelay(const mesh::Packet* packet) override {
uint32_t t = (_radio->getEstAirtimeFor(packet->path_len + packet->payload_len + 2) * _prefs.direct_tx_delay_factor);
return getRNG()->nextInt(0, 6)*t;
}
void onAnonDataRecv(mesh::Packet* packet, uint8_t type, const mesh::Identity& sender, uint8_t* data, size_t len) override {
if (type == PAYLOAD_TYPE_ANON_REQ) { // received an initial request by a possible admin client (unknown at this stage)
uint32_t timestamp;
memcpy(&timestamp, data, 4);
bool is_admin;
data[len] = 0; // ensure null terminator
if (strcmp((char *) &data[4], _prefs.password) == 0) { // check for valid password
is_admin = true;
} else if (strcmp((char *) &data[4], _prefs.guest_password) == 0) { // check guest password
is_admin = false;
} else {
#if MESH_DEBUG
MESH_DEBUG_PRINTLN("Invalid password: %s", &data[4]);
#endif
return;
}
auto client = putClient(sender); // add to known clients (if not already known)
if (timestamp <= client->last_timestamp) {
MESH_DEBUG_PRINTLN("Possible login replay attack!");
return; // FATAL: client table is full -OR- replay attack
}
MESH_DEBUG_PRINTLN("Login success!");
client->last_timestamp = timestamp;
client->last_activity = getRTCClock()->getCurrentTime();
client->is_admin = is_admin;
uint32_t now = getRTCClock()->getCurrentTimeUnique();
memcpy(reply_data, &now, 4); // response packets always prefixed with timestamp
#if 0
memcpy(&reply_data[4], "OK", 2); // legacy response
#else
reply_data[4] = RESP_SERVER_LOGIN_OK;
reply_data[5] = 0; // NEW: recommended keep-alive interval (secs / 16)
reply_data[6] = is_admin ? 1 : 0;
reply_data[7] = 0; // FUTURE: reserved
getRNG()->random(&reply_data[8], 4); // random blob to help packet-hash uniqueness
#endif
if (packet->isRouteFlood()) {
// let this sender know path TO here, so they can use sendDirect(), and ALSO encode the response
mesh::Packet* path = createPathReturn(sender, client->secret, packet->path, packet->path_len,
PAYLOAD_TYPE_RESPONSE, reply_data, 12);
if (path) sendFlood(path);
} else {
mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, sender, client->secret, reply_data, 12);
if (reply) {
if (client->out_path_len >= 0) { // we have an out_path, so send DIRECT
sendDirect(reply, client->out_path, client->out_path_len);
} else {
sendFlood(reply);
}
}
}
}
}
int matching_peer_indexes[MAX_CLIENTS];
int searchPeersByHash(const uint8_t* hash) override {
int n = 0;
for (int i = 0; i < MAX_CLIENTS; i++) {
if (known_clients[i].id.isHashMatch(hash)) {
matching_peer_indexes[n++] = i; // store the INDEXES of matching contacts (for subsequent 'peer' methods)
}
}
return n;
}
void getPeerSharedSecret(uint8_t* dest_secret, int peer_idx) override {
int i = matching_peer_indexes[peer_idx];
if (i >= 0 && i < MAX_CLIENTS) {
// lookup pre-calculated shared_secret
memcpy(dest_secret, known_clients[i].secret, PUB_KEY_SIZE);
} else {
MESH_DEBUG_PRINTLN("getPeerSharedSecret: Invalid peer idx: %d", i);
}
}
void onPeerDataRecv(mesh::Packet* packet, uint8_t type, int sender_idx, const uint8_t* secret, uint8_t* data, size_t len) override {
int i = matching_peer_indexes[sender_idx];
if (i < 0 || i >= MAX_CLIENTS) { // get from our known_clients table (sender SHOULD already be known in this context)
MESH_DEBUG_PRINTLN("onPeerDataRecv: invalid peer idx: %d", i);
return;
}
auto client = &known_clients[i];
if (type == PAYLOAD_TYPE_REQ) { // request (from a Known admin client!)
uint32_t timestamp;
memcpy(&timestamp, data, 4);
if (timestamp > client->last_timestamp) { // prevent replay attacks
int reply_len = handleRequest(client, &data[4], len - 4);
if (reply_len == 0) return; // invalid command
client->last_timestamp = timestamp;
client->last_activity = getRTCClock()->getCurrentTime();
if (packet->isRouteFlood()) {
// let this sender know path TO here, so they can use sendDirect(), and ALSO encode the response
mesh::Packet* path = createPathReturn(client->id, secret, packet->path, packet->path_len,
PAYLOAD_TYPE_RESPONSE, reply_data, reply_len);
if (path) sendFlood(path);
} else {
mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, client->id, secret, reply_data, reply_len);
if (reply) {
if (client->out_path_len >= 0) { // we have an out_path, so send DIRECT
sendDirect(reply, client->out_path, client->out_path_len);
} else {
sendFlood(reply);
}
}
}
} else {
MESH_DEBUG_PRINTLN("onPeerDataRecv: possible replay attack detected");
}
} else if (type == PAYLOAD_TYPE_TXT_MSG && len > 5 && client->is_admin) { // a CLI command
uint32_t sender_timestamp;
memcpy(&sender_timestamp, data, 4); // timestamp (by sender's RTC clock - which could be wrong)
uint flags = (data[4] >> 2); // message attempt number, and other flags
if (!(flags == TXT_TYPE_PLAIN || flags == TXT_TYPE_CLI_DATA)) {
MESH_DEBUG_PRINTLN("onPeerDataRecv: unsupported text type received: flags=%02x", (uint32_t)flags);
} else if (sender_timestamp >= client->last_timestamp) { // prevent replay attacks
bool is_retry = (sender_timestamp == client->last_timestamp);
client->last_timestamp = sender_timestamp;
client->last_activity = getRTCClock()->getCurrentTime();
// len can be > original length, but 'text' will be padded with zeroes
data[len] = 0; // need to make a C string again, with null terminator
if (flags == TXT_TYPE_PLAIN) { // for legacy CLI, send Acks
uint32_t ack_hash; // calc truncated hash of the message timestamp + text + sender pub_key, to prove to sender that we got it
mesh::Utils::sha256((uint8_t *) &ack_hash, 4, data, 5 + strlen((char *)&data[5]), client->id.pub_key, PUB_KEY_SIZE);
mesh::Packet* ack = createAck(ack_hash);
if (ack) {
if (client->out_path_len < 0) {
sendFlood(ack);
} else {
sendDirect(ack, client->out_path, client->out_path_len);
}
}
}
uint8_t temp[166];
if (is_retry) {
temp[0] = 0;
} else {
_cli.handleCommand(sender_timestamp, (const char *) &data[5], (char *) &temp[5]);
}
int text_len = strlen((char *) &temp[5]);
if (text_len > 0) {
uint32_t timestamp = getRTCClock()->getCurrentTimeUnique();
if (timestamp == sender_timestamp) {
// WORKAROUND: the two timestamps need to be different, in the CLI view
timestamp++;
}
memcpy(temp, &timestamp, 4); // mostly an extra blob to help make packet_hash unique
temp[4] = (TXT_TYPE_CLI_DATA << 2); // NOTE: legacy was: TXT_TYPE_PLAIN
auto reply = createDatagram(PAYLOAD_TYPE_TXT_MSG, client->id, secret, temp, 5 + text_len);
if (reply) {
if (client->out_path_len < 0) {
sendFlood(reply, CLI_REPLY_DELAY_MILLIS);
} else {
sendDirect(reply, client->out_path, client->out_path_len, CLI_REPLY_DELAY_MILLIS);
}
}
}
} else {
MESH_DEBUG_PRINTLN("onPeerDataRecv: possible replay attack detected");
}
}
}
bool onPeerPathRecv(mesh::Packet* packet, int sender_idx, const uint8_t* secret, uint8_t* path, uint8_t path_len, uint8_t extra_type, uint8_t* extra, uint8_t extra_len) override {
// TODO: prevent replay attacks
int i = matching_peer_indexes[sender_idx];
if (i >= 0 && i < MAX_CLIENTS) { // get from our known_clients table (sender SHOULD already be known in this context)
MESH_DEBUG_PRINTLN("PATH to client, path_len=%d", (uint32_t) path_len);
auto client = &known_clients[i];
memcpy(client->out_path, path, client->out_path_len = path_len); // store a copy of path, for sendDirect()
} else {
MESH_DEBUG_PRINTLN("onPeerPathRecv: invalid peer idx: %d", i);
}
// NOTE: no reciprocal path send!!
return false;
}
public:
MyMesh(mesh::MainBoard& board, mesh::Radio& radio, mesh::MillisecondClock& ms, mesh::RNG& rng, mesh::RTCClock& rtc, mesh::MeshTables& tables)
: mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables),
_cli(board, this, &_prefs, this)
{
memset(known_clients, 0, sizeof(known_clients));
next_local_advert = next_flood_advert = 0;
_logging = false;
// defaults
memset(&_prefs, 0, sizeof(_prefs));
_prefs.airtime_factor = 1.0; // one half
_prefs.rx_delay_base = 0.0f; // turn off by default, was 10.0;
_prefs.tx_delay_factor = 0.5f; // was 0.25f
StrHelper::strncpy(_prefs.node_name, ADVERT_NAME, sizeof(_prefs.node_name));
_prefs.node_lat = ADVERT_LAT;
_prefs.node_lon = ADVERT_LON;
StrHelper::strncpy(_prefs.password, ADMIN_PASSWORD, sizeof(_prefs.password));
_prefs.freq = LORA_FREQ;
_prefs.sf = LORA_SF;
_prefs.bw = LORA_BW;
_prefs.cr = LORA_CR;
_prefs.tx_power_dbm = LORA_TX_POWER;
_prefs.advert_interval = 1; // default to 2 minutes for NEW installs
_prefs.flood_advert_interval = 3; // 3 hours
_prefs.flood_max = 64;
}
CommonCLI* getCLI() { return &_cli; }
void begin(FILESYSTEM* fs) {
mesh::Mesh::begin();
_fs = fs;
// load persisted prefs
_cli.loadPrefs(_fs);
radio_set_params(_prefs.freq, _prefs.bw, _prefs.sf, _prefs.cr);
radio_set_tx_power(_prefs.tx_power_dbm);
updateAdvertTimer();
updateFloodAdvertTimer();
}
const char* getFirmwareVer() override { return FIRMWARE_VERSION; }
const char* getBuildDate() override { return FIRMWARE_BUILD_DATE; }
const char* getRole() override { return FIRMWARE_ROLE; }
const char* getNodeName() { return _prefs.node_name; }
void savePrefs() override {
_cli.savePrefs(_fs);
}
bool formatFileSystem() override {
#if defined(NRF52_PLATFORM)
return InternalFS.format();
#elif defined(ESP32)
return SPIFFS.format();
#else
#error "need to implement file system erase"
return false;
#endif
}
void sendSelfAdvertisement(int delay_millis) override {
mesh::Packet* pkt = createSelfAdvert();
if (pkt) {
sendFlood(pkt, delay_millis);
} else {
MESH_DEBUG_PRINTLN("ERROR: unable to create advertisement packet!");
}
}
void updateAdvertTimer() override {
if (_prefs.advert_interval > 0) { // schedule local advert timer
next_local_advert = futureMillis( ((uint32_t)_prefs.advert_interval) * 2 * 60 * 1000);
} else {
next_local_advert = 0; // stop the timer
}
}
void updateFloodAdvertTimer() override {
if (_prefs.flood_advert_interval > 0) { // schedule flood advert timer
next_flood_advert = futureMillis( ((uint32_t)_prefs.flood_advert_interval) * 60 * 60 * 1000);
} else {
next_flood_advert = 0; // stop the timer
}
}
void setLoggingOn(bool enable) override { _logging = enable; }
void eraseLogFile() override {
_fs->remove(PACKET_LOG_FILE);
}
void dumpLogFile() override {
File f = _fs->open(PACKET_LOG_FILE);
if (f) {
while (f.available()) {
int c = f.read();
if (c < 0) break;
Serial.print((char)c);
}
f.close();
}
}
void setTxPower(uint8_t power_dbm) override {
radio_set_tx_power(power_dbm);
}
void loop() {
mesh::Mesh::loop();
if (next_flood_advert && millisHasNowPassed(next_flood_advert)) {
mesh::Packet* pkt = createSelfAdvert();
if (pkt) sendFlood(pkt);
updateFloodAdvertTimer(); // schedule next flood advert
updateAdvertTimer(); // also schedule local advert (so they don't overlap)
} else if (next_local_advert && millisHasNowPassed(next_local_advert)) {
mesh::Packet* pkt = createSelfAdvert();
if (pkt) sendZeroHop(pkt);
updateAdvertTimer(); // schedule next local advert
}
#ifdef DISPLAY_CLASS
ui_task.loop();
#endif
}
};
StdRNG fast_rng;
SimpleMeshTables tables;
MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables);
void halt() {
while (1) ;
}
static char command[80];
void setup() {
Serial.begin(115200);
delay(1000);
board.begin();
#ifdef DISPLAY_CLASS
if(display.begin()){
display.startFrame();
display.print("Please wait...");
display.endFrame();
}
#endif
if (!radio_init()) { halt(); }
fast_rng.begin(radio_get_rng_seed());
FILESYSTEM* fs;
#if defined(NRF52_PLATFORM)
InternalFS.begin();
fs = &InternalFS;
IdentityStore store(InternalFS, "");
#elif defined(ESP32)
SPIFFS.begin(true);
fs = &SPIFFS;
IdentityStore store(SPIFFS, "/identity");
#else
#error "need to define filesystem"
#endif
if (!store.load("_main", the_mesh.self_id)) {
MESH_DEBUG_PRINTLN("Generating new keypair");
the_mesh.self_id = radio_new_identity(); // create new random identity
int count = 0;
while (count < 10 && (the_mesh.self_id.pub_key[0] == 0x00 || the_mesh.self_id.pub_key[0] == 0xFF)) { // reserved id hashes
the_mesh.self_id = radio_new_identity(); count++;
}
store.save("_main", the_mesh.self_id);
}
Serial.print("Repeater ID: ");
mesh::Utils::printHex(Serial, the_mesh.self_id.pub_key, PUB_KEY_SIZE); Serial.println();
command[0] = 0;
the_mesh.begin(fs);
#ifdef DISPLAY_CLASS
ui_task.begin(the_mesh.getNodeName(), FIRMWARE_BUILD_DATE);
#endif
// send out initial Advertisement to the mesh
the_mesh.sendSelfAdvertisement(16000);
}
void loop() {
int len = strlen(command);
while (Serial.available() && len < sizeof(command)-1) {
char c = Serial.read();
if (c != '\n') {
command[len++] = c;
command[len] = 0;
}
Serial.print(c);
}
if (len == sizeof(command)-1) { // command buffer full
command[sizeof(command)-1] = '\r';
}
if (len > 0 && command[len - 1] == '\r') { // received complete line
command[len - 1] = 0; // replace newline with C string null terminator
char reply[160];
the_mesh.getCLI()->handleCommand(0, command, reply); // NOTE: there is no sender_timestamp via serial!
if (reply[0]) {
Serial.print(" -> "); Serial.println(reply);
}
command[0] = 0; // reset command buffer
}
the_mesh.loop();
}
+79
View File
@@ -0,0 +1,79 @@
#include "UITask.h"
#include <Arduino.h>
#define AUTO_OFF_MILLIS 20000 // 20 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(const char* node_name, const char* build_date) {
_prevBtnState = HIGH;
_auto_off = millis() + AUTO_OFF_MILLIS;
_node_name = node_name;
_build_date = build_date;
_display->turnOn();
}
void UITask::renderCurrScreen() {
char tmp[80];
// render 'home' screen
_display->drawXbm(0, 0, meshcore_logo, 128, 13);
_display->setCursor(0, 20);
_display->setTextSize(1);
_display->print(_node_name);
sprintf(tmp, "Build: %s", _build_date);
_display->setCursor(0, 32);
_display->print(tmp);
_display->setCursor(0, 43);
_display->print("< Room Server >");
//_display->printf("freq : %03.2f sf %d\n", _prefs.freq, _prefs.sf);
//_display->printf("bw : %03.2f cr %d\n", _prefs.bw, _prefs.cr);
}
void UITask::loop() {
#ifdef PIN_USER_BTN
if (millis() >= _next_read) {
int btnState = digitalRead(PIN_USER_BTN);
if (btnState != _prevBtnState) {
if (btnState == LOW) { // 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();
}
}
}
+18
View File
@@ -0,0 +1,18 @@
#pragma once
#include <helpers/ui/DisplayDriver.h>
class UITask {
DisplayDriver* _display;
unsigned long _next_read, _next_refresh, _auto_off;
int _prevBtnState;
const char* _node_name;
const char* _build_date;
void renderCurrScreen();
public:
UITask(DisplayDriver& display) : _display(&display) { _next_read = _next_refresh = 0; }
void begin(const char* node_name, const char* build_date);
void loop();
};
+923
View File
@@ -0,0 +1,923 @@
#include <Arduino.h> // needed for PlatformIO
#include <Mesh.h>
#if defined(NRF52_PLATFORM)
#include <InternalFileSystem.h>
#elif defined(ESP32)
#include <SPIFFS.h>
#endif
#include <helpers/ArduinoHelpers.h>
#include <helpers/StaticPoolPacketManager.h>
#include <helpers/SimpleMeshTables.h>
#include <helpers/IdentityStore.h>
#include <helpers/AdvertDataHelpers.h>
#include <helpers/TxtDataHelpers.h>
#include <helpers/CommonCLI.h>
#include <RTClib.h>
#include <target.h>
/* ------------------------------ Config -------------------------------- */
#ifndef FIRMWARE_BUILD_DATE
#define FIRMWARE_BUILD_DATE "7 Apr 2025"
#endif
#ifndef FIRMWARE_VERSION
#define FIRMWARE_VERSION "v1.4.3"
#endif
#ifndef LORA_FREQ
#define LORA_FREQ 915.0
#endif
#ifndef LORA_BW
#define LORA_BW 250
#endif
#ifndef LORA_SF
#define LORA_SF 10
#endif
#ifndef LORA_CR
#define LORA_CR 5
#endif
#ifndef LORA_TX_POWER
#define LORA_TX_POWER 20
#endif
#ifndef ADVERT_NAME
#define ADVERT_NAME "Test BBS"
#endif
#ifndef ADVERT_LAT
#define ADVERT_LAT 0.0
#endif
#ifndef ADVERT_LON
#define ADVERT_LON 0.0
#endif
#ifndef ADMIN_PASSWORD
#define ADMIN_PASSWORD "password"
#endif
#ifndef MAX_CLIENTS
#define MAX_CLIENTS 32
#endif
#ifndef MAX_UNSYNCED_POSTS
#define MAX_UNSYNCED_POSTS 32
#endif
#ifdef DISPLAY_CLASS
#include <helpers/ui/SSD1306Display.h>
static DISPLAY_CLASS display;
#include "UITask.h"
static UITask ui_task(display);
#endif
#define FIRMWARE_ROLE "room_server"
#define PACKET_LOG_FILE "/packet_log"
/* ------------------------------ Code -------------------------------- */
enum RoomPermission {
ADMIN,
GUEST,
READ_ONLY
};
struct ClientInfo {
mesh::Identity id;
uint32_t last_timestamp; // by THEIR clock
uint32_t last_activity; // by OUR clock
uint32_t sync_since; // sync messages SINCE this timestamp (by OUR clock)
uint32_t pending_ack;
uint32_t push_post_timestamp;
unsigned long ack_timeout;
RoomPermission permission;
uint8_t push_failures;
uint8_t secret[PUB_KEY_SIZE];
int out_path_len;
uint8_t out_path[MAX_PATH_SIZE];
};
#define MAX_POST_TEXT_LEN (160-9)
struct PostInfo {
mesh::Identity author;
uint32_t post_timestamp; // by OUR clock
char text[MAX_POST_TEXT_LEN+1];
};
#define REPLY_DELAY_MILLIS 1500
#define PUSH_NOTIFY_DELAY_MILLIS 2000
#define SYNC_PUSH_INTERVAL 1200
#define PUSH_ACK_TIMEOUT_FLOOD 12000
#define PUSH_TIMEOUT_BASE 4000
#define PUSH_ACK_TIMEOUT_FACTOR 2000
#define CLIENT_KEEP_ALIVE_SECS 128
#define REQ_TYPE_GET_STATUS 0x01 // same as _GET_STATS
#define REQ_TYPE_KEEP_ALIVE 0x02
#define RESP_SERVER_LOGIN_OK 0 // response to ANON_REQ
struct ServerStats {
uint16_t batt_milli_volts;
uint16_t curr_tx_queue_len;
uint16_t curr_free_queue_len;
int16_t last_rssi;
uint32_t n_packets_recv;
uint32_t n_packets_sent;
uint32_t total_air_time_secs;
uint32_t total_up_time_secs;
uint32_t n_sent_flood, n_sent_direct;
uint32_t n_recv_flood, n_recv_direct;
uint16_t n_full_events;
int16_t last_snr; // x 4
uint16_t n_direct_dups, n_flood_dups;
uint16_t n_posted, n_post_push;
};
class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
FILESYSTEM* _fs;
unsigned long next_local_advert, next_flood_advert;
bool _logging;
NodePrefs _prefs;
CommonCLI _cli;
uint8_t reply_data[MAX_PACKET_PAYLOAD];
int num_clients;
ClientInfo known_clients[MAX_CLIENTS];
unsigned long next_push;
uint16_t _num_posted, _num_post_pushes;
int next_client_idx; // for round-robin polling
int next_post_idx;
PostInfo posts[MAX_UNSYNCED_POSTS]; // cyclic queue
ClientInfo* putClient(const mesh::Identity& id) {
for (int i = 0; i < num_clients; i++) {
if (id.matches(known_clients[i].id)) return &known_clients[i]; // already known
}
ClientInfo* newClient;
if (num_clients < MAX_CLIENTS) {
newClient = &known_clients[num_clients++];
} else { // table is currently full
// evict least active client
uint32_t oldest_timestamp = 0xFFFFFFFF;
newClient = &known_clients[0];
for (int i = 0; i < num_clients; i++) {
auto c = &known_clients[i];
if (c->last_activity < oldest_timestamp) {
oldest_timestamp = c->last_activity;
newClient = c;
}
}
}
newClient->id = id;
newClient->out_path_len = -1; // initially out_path is unknown
newClient->last_timestamp = 0;
self_id.calcSharedSecret(newClient->secret, id); // calc ECDH shared secret
return newClient;
}
void evict(ClientInfo* client) {
client->last_activity = 0; // this slot will now be re-used (will be oldest)
memset(client->id.pub_key, 0, sizeof(client->id.pub_key));
memset(client->secret, 0, sizeof(client->secret));
client->pending_ack = 0;
}
void addPost(ClientInfo* client, const char* postData) {
// TODO: suggested postData format: <title>/<descrption>
posts[next_post_idx].author = client->id; // add to cyclic queue
StrHelper::strncpy(posts[next_post_idx].text, postData, MAX_POST_TEXT_LEN);
posts[next_post_idx].post_timestamp = getRTCClock()->getCurrentTimeUnique();
next_post_idx = (next_post_idx + 1) % MAX_UNSYNCED_POSTS;
next_push = futureMillis(PUSH_NOTIFY_DELAY_MILLIS);
_num_posted++; // stats
}
void pushPostToClient(ClientInfo* client, PostInfo& post) {
int len = 0;
memcpy(&reply_data[len], &post.post_timestamp, 4); len += 4; // this is a PAST timestamp... but should be accepted by client
reply_data[len++] = (TXT_TYPE_SIGNED_PLAIN << 2); // 'signed' plain text
// encode prefix of post.author.pub_key
memcpy(&reply_data[len], post.author.pub_key, 4); len += 4; // just first 4 bytes
int text_len = strlen(post.text);
memcpy(&reply_data[len], post.text, text_len); len += text_len;
// calc expected ACK reply
mesh::Utils::sha256((uint8_t *)&client->pending_ack, 4, reply_data, len, client->id.pub_key, PUB_KEY_SIZE);
client->push_post_timestamp = post.post_timestamp;
auto reply = createDatagram(PAYLOAD_TYPE_TXT_MSG, client->id, client->secret, reply_data, len);
if (reply) {
if (client->out_path_len < 0) {
sendFlood(reply);
client->ack_timeout = futureMillis(PUSH_ACK_TIMEOUT_FLOOD);
} else {
sendDirect(reply, client->out_path, client->out_path_len);
client->ack_timeout = futureMillis(PUSH_TIMEOUT_BASE + PUSH_ACK_TIMEOUT_FACTOR * (client->out_path_len + 1));
}
_num_post_pushes++; // stats
} else {
client->pending_ack = 0;
MESH_DEBUG_PRINTLN("Unable to push post to client");
}
}
bool processAck(const uint8_t *data) {
for (int i = 0; i < num_clients; i++) {
auto client = &known_clients[i];
if (client->pending_ack && memcmp(data, &client->pending_ack, 4) == 0) { // got an ACK from Client!
client->pending_ack = 0; // clear this, so next push can happen
client->push_failures = 0;
client->sync_since = client->push_post_timestamp; // advance Client's SINCE timestamp, to sync next post
return true;
}
}
return false;
}
mesh::Packet* createSelfAdvert() {
uint8_t app_data[MAX_ADVERT_DATA_SIZE];
uint8_t app_data_len;
{
AdvertDataBuilder builder(ADV_TYPE_ROOM, _prefs.node_name, _prefs.node_lat, _prefs.node_lon);
app_data_len = builder.encodeTo(app_data);
}
return createAdvert(self_id, app_data, app_data_len);
}
File openAppend(const char* fname) {
#if defined(NRF52_PLATFORM)
return _fs->open(fname, FILE_O_WRITE);
#else
return _fs->open(fname, "a", true);
#endif
}
protected:
float getAirtimeBudgetFactor() const override {
return _prefs.airtime_factor;
}
void logRxRaw(float snr, float rssi, const uint8_t raw[], int len) override {
#if MESH_PACKET_LOGGING
Serial.print(getLogDateTime());
Serial.print(" RAW: ");
mesh::Utils::printHex(Serial, raw, len);
Serial.println();
#endif
}
void logRx(mesh::Packet* pkt, int len, float score) override {
if (_logging) {
File f = openAppend(PACKET_LOG_FILE);
if (f) {
f.print(getLogDateTime());
f.printf(": RX, len=%d (type=%d, route=%s, payload_len=%d) SNR=%d RSSI=%d score=%d",
len, pkt->getPayloadType(), pkt->isRouteDirect() ? "D" : "F", pkt->payload_len,
(int)_radio->getLastSNR(), (int)_radio->getLastRSSI(), (int)(score*1000));
if (pkt->getPayloadType() == PAYLOAD_TYPE_PATH || pkt->getPayloadType() == PAYLOAD_TYPE_REQ
|| pkt->getPayloadType() == PAYLOAD_TYPE_RESPONSE || pkt->getPayloadType() == PAYLOAD_TYPE_TXT_MSG) {
f.printf(" [%02X -> %02X]\n", (uint32_t)pkt->payload[1], (uint32_t)pkt->payload[0]);
} else {
f.printf("\n");
}
f.close();
}
}
}
void logTx(mesh::Packet* pkt, int len) override {
if (_logging) {
File f = openAppend(PACKET_LOG_FILE);
if (f) {
f.print(getLogDateTime());
f.printf(": TX, len=%d (type=%d, route=%s, payload_len=%d)",
len, pkt->getPayloadType(), pkt->isRouteDirect() ? "D" : "F", pkt->payload_len);
if (pkt->getPayloadType() == PAYLOAD_TYPE_PATH || pkt->getPayloadType() == PAYLOAD_TYPE_REQ
|| pkt->getPayloadType() == PAYLOAD_TYPE_RESPONSE || pkt->getPayloadType() == PAYLOAD_TYPE_TXT_MSG) {
f.printf(" [%02X -> %02X]\n", (uint32_t)pkt->payload[1], (uint32_t)pkt->payload[0]);
} else {
f.printf("\n");
}
f.close();
}
}
}
void logTxFail(mesh::Packet* pkt, int len) override {
if (_logging) {
File f = openAppend(PACKET_LOG_FILE);
if (f) {
f.print(getLogDateTime());
f.printf(": TX FAIL!, len=%d (type=%d, route=%s, payload_len=%d)\n",
len, pkt->getPayloadType(), pkt->isRouteDirect() ? "D" : "F", pkt->payload_len);
f.close();
}
}
}
int calcRxDelay(float score, uint32_t air_time) const override {
if (_prefs.rx_delay_base <= 0.0f) return 0;
return (int) ((pow(_prefs.rx_delay_base, 0.85f - score) - 1.0) * air_time);
}
const char* getLogDateTime() override {
static char tmp[32];
uint32_t now = getRTCClock()->getCurrentTime();
DateTime dt = DateTime(now);
sprintf(tmp, "%02d:%02d:%02d - %d/%d/%d U", dt.hour(), dt.minute(), dt.second(), dt.day(), dt.month(), dt.year());
return tmp;
}
uint32_t getRetransmitDelay(const mesh::Packet* packet) override {
uint32_t t = (_radio->getEstAirtimeFor(packet->path_len + packet->payload_len + 2) * _prefs.tx_delay_factor);
return getRNG()->nextInt(0, 6)*t;
}
uint32_t getDirectRetransmitDelay(const mesh::Packet* packet) override {
uint32_t t = (_radio->getEstAirtimeFor(packet->path_len + packet->payload_len + 2) * _prefs.direct_tx_delay_factor);
return getRNG()->nextInt(0, 6)*t;
}
bool allowPacketForward(const mesh::Packet* packet) override {
if (_prefs.disable_fwd) return false;
if (packet->isRouteFlood() && packet->path_len >= _prefs.flood_max) return false;
return true;
}
void onAnonDataRecv(mesh::Packet* packet, uint8_t type, const mesh::Identity& sender, uint8_t* data, size_t len) override {
if (type == PAYLOAD_TYPE_ANON_REQ) { // received an initial request by a possible admin client (unknown at this stage)
uint32_t sender_timestamp, sender_sync_since;
memcpy(&sender_timestamp, data, 4);
memcpy(&sender_sync_since, &data[4], 4); // sender's "sync messags SINCE x" timestamp
RoomPermission perm;
data[len] = 0; // ensure null terminator
if (strcmp((char *) &data[8], _prefs.password) == 0) { // check for valid admin password
perm = RoomPermission::ADMIN;
} else {
if (strcmp((char *) &data[8], _prefs.guest_password) == 0) { // check the room/public password
perm = RoomPermission::GUEST;
} else if (_prefs.allow_read_only) {
perm = RoomPermission::READ_ONLY;
} else {
MESH_DEBUG_PRINTLN("Incorrect room password");
return; // no response. Client will timeout
}
}
auto client = putClient(sender); // add to known clients (if not already known)
if (sender_timestamp <= client->last_timestamp) {
MESH_DEBUG_PRINTLN("possible replay attack!");
return;
}
MESH_DEBUG_PRINTLN("Login success!");
client->permission = perm;
client->last_timestamp = sender_timestamp;
client->sync_since = sender_sync_since;
client->pending_ack = 0;
client->push_failures = 0;
uint32_t now = getRTCClock()->getCurrentTime();
client->last_activity = now;
now = getRTCClock()->getCurrentTimeUnique();
memcpy(reply_data, &now, 4); // response packets always prefixed with timestamp
// TODO: maybe reply with count of messages waiting to be synced for THIS client?
reply_data[4] = RESP_SERVER_LOGIN_OK;
reply_data[5] = (CLIENT_KEEP_ALIVE_SECS >> 4); // NEW: recommended keep-alive interval (secs / 16)
reply_data[6] = (perm == RoomPermission::ADMIN ? 1 : (perm == RoomPermission::GUEST ? 0 : 2));
reply_data[7] = 0; // FUTURE: reserved
memcpy(&reply_data[8], "OK", 2); // REVISIT: not really needed
next_push = futureMillis(PUSH_NOTIFY_DELAY_MILLIS); // delay next push, give RESPONSE packet time to arrive first
if (packet->isRouteFlood()) {
// let this sender know path TO here, so they can use sendDirect(), and ALSO encode the response
mesh::Packet* path = createPathReturn(sender, client->secret, packet->path, packet->path_len,
PAYLOAD_TYPE_RESPONSE, reply_data, 8 + 2);
if (path) sendFlood(path);
} else {
mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, sender, client->secret, reply_data, 8 + 2);
if (reply) {
if (client->out_path_len >= 0) { // we have an out_path, so send DIRECT
sendDirect(reply, client->out_path, client->out_path_len);
} else {
sendFlood(reply);
}
}
}
}
}
int matching_peer_indexes[MAX_CLIENTS];
int searchPeersByHash(const uint8_t* hash) override {
int n = 0;
for (int i = 0; i < num_clients; i++) {
if (known_clients[i].id.isHashMatch(hash)) {
matching_peer_indexes[n++] = i; // store the INDEXES of matching contacts (for subsequent 'peer' methods)
}
}
return n;
}
void getPeerSharedSecret(uint8_t* dest_secret, int peer_idx) override {
int i = matching_peer_indexes[peer_idx];
if (i >= 0 && i < num_clients) {
// lookup pre-calculated shared_secret
memcpy(dest_secret, known_clients[i].secret, PUB_KEY_SIZE);
} else {
MESH_DEBUG_PRINTLN("getPeerSharedSecret: Invalid peer idx: %d", i);
}
}
void onPeerDataRecv(mesh::Packet* packet, uint8_t type, int sender_idx, const uint8_t* secret, uint8_t* data, size_t len) override {
int i = matching_peer_indexes[sender_idx];
if (i < 0 || i >= num_clients) { // get from our known_clients table (sender SHOULD already be known in this context)
MESH_DEBUG_PRINTLN("onPeerDataRecv: invalid peer idx: %d", i);
return;
}
auto client = &known_clients[i];
if (type == PAYLOAD_TYPE_TXT_MSG && len > 5) { // a CLI command or new Post
uint32_t sender_timestamp;
memcpy(&sender_timestamp, data, 4); // timestamp (by sender's RTC clock - which could be wrong)
uint flags = (data[4] >> 2); // message attempt number, and other flags
if (!(flags == TXT_TYPE_PLAIN || flags == TXT_TYPE_CLI_DATA)) {
MESH_DEBUG_PRINTLN("onPeerDataRecv: unsupported command flags received: flags=%02x", (uint32_t)flags);
} else if (sender_timestamp >= client->last_timestamp) { // prevent replay attacks, but send Acks for retries
bool is_retry = (sender_timestamp == client->last_timestamp);
client->last_timestamp = sender_timestamp;
uint32_t now = getRTCClock()->getCurrentTimeUnique();
client->last_activity = now;
client->push_failures = 0; // reset so push can resume (if prev failed)
// len can be > original length, but 'text' will be padded with zeroes
data[len] = 0; // need to make a C string again, with null terminator
uint32_t ack_hash; // calc truncated hash of the message timestamp + text + sender pub_key, to prove to sender that we got it
mesh::Utils::sha256((uint8_t *) &ack_hash, 4, data, 5 + strlen((char *)&data[5]), client->id.pub_key, PUB_KEY_SIZE);
uint8_t temp[166];
bool send_ack;
if (flags == TXT_TYPE_CLI_DATA) {
if (client->permission == RoomPermission::ADMIN) {
if (is_retry) {
temp[5] = 0; // no reply
} else {
_cli.handleCommand(sender_timestamp, (const char *) &data[5], (char *) &temp[5]);
temp[4] = (TXT_TYPE_CLI_DATA << 2); // attempt and flags, (NOTE: legacy was: TXT_TYPE_PLAIN)
}
send_ack = false;
} else {
temp[5] = 0; // no reply
send_ack = false; // and no ACK... user shoudn't be sending these
}
} else { // TXT_TYPE_PLAIN
if (client->permission == RoomPermission::READ_ONLY) {
temp[5] = 0; // no reply
send_ack = false; // no ACK
} else {
if (!is_retry) {
addPost(client, (const char *) &data[5]);
}
temp[5] = 0; // no reply (ACK is enough)
send_ack = true;
}
}
uint32_t delay_millis;
if (send_ack) {
mesh::Packet* ack = createAck(ack_hash);
if (ack) {
if (client->out_path_len < 0) {
sendFlood(ack);
} else {
sendDirect(ack, client->out_path, client->out_path_len);
}
}
delay_millis = REPLY_DELAY_MILLIS;
} else {
delay_millis = 0;
}
int text_len = strlen((char *) &temp[5]);
if (text_len > 0) {
if (now == sender_timestamp) {
// WORKAROUND: the two timestamps need to be different, in the CLI view
now++;
}
memcpy(temp, &now, 4); // mostly an extra blob to help make packet_hash unique
// calc expected ACK reply
//mesh::Utils::sha256((uint8_t *)&expected_ack_crc, 4, temp, 5 + text_len, self_id.pub_key, PUB_KEY_SIZE);
auto reply = createDatagram(PAYLOAD_TYPE_TXT_MSG, client->id, secret, temp, 5 + text_len);
if (reply) {
if (client->out_path_len < 0) {
sendFlood(reply, delay_millis);
} else {
sendDirect(reply, client->out_path, client->out_path_len, delay_millis);
}
}
}
} else {
MESH_DEBUG_PRINTLN("onPeerDataRecv: possible replay attack detected");
}
} else if (type == PAYLOAD_TYPE_REQ && len >= 5) {
uint32_t sender_timestamp;
memcpy(&sender_timestamp, data, 4); // timestamp (by sender's RTC clock - which could be wrong)
if (sender_timestamp < client->last_timestamp) { // prevent replay attacks
MESH_DEBUG_PRINTLN("onPeerDataRecv: possible replay attack detected");
} else {
client->last_timestamp = sender_timestamp;
uint32_t now = getRTCClock()->getCurrentTime();
client->last_activity = now; // <-- THIS will keep client connection alive
client->push_failures = 0; // reset so push can resume (if prev failed)
if (data[4] == REQ_TYPE_KEEP_ALIVE && packet->isRouteDirect()) { // request type
uint32_t forceSince = 0;
if (len >= 9) { // optional - last post_timestamp client received
memcpy(&forceSince, &data[5], 4); // NOTE: this may be 0, if part of decrypted PADDING!
} else {
memcpy(&data[5], &forceSince, 4); // make sure there are zeroes in payload (for ack_hash calc below)
}
if (forceSince > 0) {
client->sync_since = forceSince; // force-update the 'sync since'
}
client->pending_ack = 0;
// TODO: Throttle KEEP_ALIVE requests!
// if client sends too quickly, evict()
// RULE: only send keep_alive response DIRECT!
if (client->out_path_len >= 0) {
uint32_t ack_hash; // calc ACK to prove to sender that we got request
mesh::Utils::sha256((uint8_t *) &ack_hash, 4, data, 9, client->id.pub_key, PUB_KEY_SIZE);
auto reply = createAck(ack_hash);
if (reply) {
sendDirect(reply, client->out_path, client->out_path_len);
}
}
} else if (data[4] == REQ_TYPE_GET_STATUS) {
ServerStats stats;
stats.batt_milli_volts = board.getBattMilliVolts();
stats.curr_tx_queue_len = _mgr->getOutboundCount();
stats.curr_free_queue_len = _mgr->getFreeCount();
stats.last_rssi = (int16_t) radio_driver.getLastRSSI();
stats.n_packets_recv = radio_driver.getPacketsRecv();
stats.n_packets_sent = radio_driver.getPacketsSent();
stats.total_air_time_secs = getTotalAirTime() / 1000;
stats.total_up_time_secs = _ms->getMillis() / 1000;
stats.n_sent_flood = getNumSentFlood();
stats.n_sent_direct = getNumSentDirect();
stats.n_recv_flood = getNumRecvFlood();
stats.n_recv_direct = getNumRecvDirect();
stats.n_full_events = getNumFullEvents();
stats.last_snr = (int16_t)(radio_driver.getLastSNR() * 4);
stats.n_direct_dups = ((SimpleMeshTables *)getTables())->getNumDirectDups();
stats.n_flood_dups = ((SimpleMeshTables *)getTables())->getNumFloodDups();
stats.n_posted = _num_posted;
stats.n_post_push = _num_post_pushes;
now = getRTCClock()->getCurrentTimeUnique();
memcpy(reply_data, &now, 4); // response packets always prefixed with timestamp
memcpy(&reply_data[4], &stats, sizeof(stats));
uint8_t reply_len = 4 + sizeof(stats);
if (packet->isRouteFlood()) {
// let this sender know path TO here, so they can use sendDirect(), and ALSO encode the response
mesh::Packet* path = createPathReturn(client->id, secret, packet->path, packet->path_len,
PAYLOAD_TYPE_RESPONSE, reply_data, reply_len);
if (path) sendFlood(path);
} else {
mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, client->id, secret, reply_data, reply_len);
if (reply) {
if (client->out_path_len >= 0) { // we have an out_path, so send DIRECT
sendDirect(reply, client->out_path, client->out_path_len);
} else {
sendFlood(reply);
}
}
}
}
}
}
}
bool onPeerPathRecv(mesh::Packet* packet, int sender_idx, const uint8_t* secret, uint8_t* path, uint8_t path_len, uint8_t extra_type, uint8_t* extra, uint8_t extra_len) override {
// TODO: prevent replay attacks
int i = matching_peer_indexes[sender_idx];
if (i >= 0 && i < num_clients) { // get from our known_clients table (sender SHOULD already be known in this context)
MESH_DEBUG_PRINTLN("PATH to client, path_len=%d", (uint32_t) path_len);
auto client = &known_clients[i];
memcpy(client->out_path, path, client->out_path_len = path_len); // store a copy of path, for sendDirect()
} else {
MESH_DEBUG_PRINTLN("onPeerPathRecv: invalid peer idx: %d", i);
}
if (extra_type == PAYLOAD_TYPE_ACK && extra_len >= 4) {
// also got an encoded ACK!
processAck(extra);
}
// NOTE: no reciprocal path send!!
return false;
}
void onAckRecv(mesh::Packet* packet, uint32_t ack_crc) override {
if (processAck((uint8_t *)&ack_crc)) {
packet->markDoNotRetransmit(); // ACK was for this node, so don't retransmit
}
}
public:
MyMesh(mesh::MainBoard& board, mesh::Radio& radio, mesh::MillisecondClock& ms, mesh::RNG& rng, mesh::RTCClock& rtc, mesh::MeshTables& tables)
: mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables),
_cli(board, this, &_prefs, this)
{
next_local_advert = next_flood_advert = 0;
_logging = false;
// defaults
memset(&_prefs, 0, sizeof(_prefs));
_prefs.airtime_factor = 1.0; // one half
_prefs.rx_delay_base = 0.0f; // off by default, was 10.0
_prefs.tx_delay_factor = 0.5f; // was 0.25f;
StrHelper::strncpy(_prefs.node_name, ADVERT_NAME, sizeof(_prefs.node_name));
_prefs.node_lat = ADVERT_LAT;
_prefs.node_lon = ADVERT_LON;
StrHelper::strncpy(_prefs.password, ADMIN_PASSWORD, sizeof(_prefs.password));
_prefs.freq = LORA_FREQ;
_prefs.sf = LORA_SF;
_prefs.bw = LORA_BW;
_prefs.cr = LORA_CR;
_prefs.tx_power_dbm = LORA_TX_POWER;
_prefs.disable_fwd = 1;
_prefs.advert_interval = 1; // default to 2 minutes for NEW installs
_prefs.flood_advert_interval = 3; // 3 hours
_prefs.flood_max = 64;
#ifdef ROOM_PASSWORD
StrHelper::strncpy(_prefs.guest_password, ROOM_PASSWORD, sizeof(_prefs.guest_password));
#endif
num_clients = 0;
next_post_idx = 0;
next_client_idx = 0;
next_push = 0;
memset(posts, 0, sizeof(posts));
_num_posted = _num_post_pushes = 0;
}
CommonCLI* getCLI() { return &_cli; }
void begin(FILESYSTEM* fs) {
mesh::Mesh::begin();
_fs = fs;
// load persisted prefs
_cli.loadPrefs(_fs);
radio_set_params(_prefs.freq, _prefs.bw, _prefs.sf, _prefs.cr);
radio_set_tx_power(_prefs.tx_power_dbm);
updateAdvertTimer();
updateFloodAdvertTimer();
}
const char* getFirmwareVer() override { return FIRMWARE_VERSION; }
const char* getBuildDate() override { return FIRMWARE_BUILD_DATE; }
const char* getRole() override { return FIRMWARE_ROLE; }
const char* getNodeName() { return _prefs.node_name; }
void savePrefs() override {
_cli.savePrefs(_fs);
}
bool formatFileSystem() override {
#if defined(NRF52_PLATFORM)
return InternalFS.format();
#elif defined(ESP32)
return SPIFFS.format();
#else
#error "need to implement file system erase"
return false;
#endif
}
void sendSelfAdvertisement(int delay_millis) override {
mesh::Packet* pkt = createSelfAdvert();
if (pkt) {
sendFlood(pkt, delay_millis);
} else {
MESH_DEBUG_PRINTLN("ERROR: unable to create advertisement packet!");
}
}
void updateAdvertTimer() override {
if (_prefs.advert_interval > 0) { // schedule local advert timer
next_local_advert = futureMillis((uint32_t)_prefs.advert_interval * 2 * 60 * 1000);
} else {
next_local_advert = 0; // stop the timer
}
}
void updateFloodAdvertTimer() override {
if (_prefs.flood_advert_interval > 0) { // schedule flood advert timer
next_flood_advert = futureMillis( ((uint32_t)_prefs.flood_advert_interval) * 60 * 60 * 1000);
} else {
next_flood_advert = 0; // stop the timer
}
}
void setLoggingOn(bool enable) override { _logging = enable; }
void eraseLogFile() override {
_fs->remove(PACKET_LOG_FILE);
}
void dumpLogFile() override {
File f = _fs->open(PACKET_LOG_FILE);
if (f) {
while (f.available()) {
int c = f.read();
if (c < 0) break;
Serial.print((char)c);
}
f.close();
}
}
void setTxPower(uint8_t power_dbm) override {
radio_set_tx_power(power_dbm);
}
void loop() {
mesh::Mesh::loop();
if (millisHasNowPassed(next_push) && num_clients > 0) {
// check for ACK timeouts
for (int i = 0; i < num_clients; i++) {
auto c = &known_clients[i];
if (c->pending_ack && millisHasNowPassed(c->ack_timeout)) {
c->push_failures++;
c->pending_ack = 0; // reset (TODO: keep prev expected_ack's in a list, incase they arrive LATER, after we retry)
MESH_DEBUG_PRINTLN("pending ACK timed out: push_failures: %d", (uint32_t)c->push_failures);
}
}
// check next Round-Robin client, and sync next new post
auto client = &known_clients[next_client_idx];
bool did_push = false;
if (client->pending_ack == 0 && client->last_activity != 0 && client->push_failures < 3) { // not already waiting for ACK, AND not evicted, AND retries not max
MESH_DEBUG_PRINTLN("loop - checking for client %02X", (uint32_t) client->id.pub_key[0]);
for (int k = 0, idx = next_post_idx; k < MAX_UNSYNCED_POSTS; k++) {
if (posts[idx].post_timestamp > client->sync_since // is new post for this Client?
&& !posts[idx].author.matches(client->id)) { // don't push posts to the author
// push this post to Client, then wait for ACK
pushPostToClient(client, posts[idx]);
did_push = true;
MESH_DEBUG_PRINTLN("loop - pushed to client %02X: %s", (uint32_t) client->id.pub_key[0], posts[idx].text);
break;
}
idx = (idx + 1) % MAX_UNSYNCED_POSTS; // wrap to start of cyclic queue
}
} else {
MESH_DEBUG_PRINTLN("loop - skipping busy (or evicted) client %02X", (uint32_t) client->id.pub_key[0]);
}
next_client_idx = (next_client_idx + 1) % num_clients; // round robin polling for each client
if (did_push) {
next_push = futureMillis(SYNC_PUSH_INTERVAL);
} else {
// were no unsynced posts for curr client, so proccess next client much quicker! (in next loop())
next_push = futureMillis(SYNC_PUSH_INTERVAL / 8);
}
}
if (next_flood_advert && millisHasNowPassed(next_flood_advert)) {
mesh::Packet* pkt = createSelfAdvert();
if (pkt) sendFlood(pkt);
updateFloodAdvertTimer(); // schedule next flood advert
updateAdvertTimer(); // also schedule local advert (so they don't overlap)
} else if (next_local_advert && millisHasNowPassed(next_local_advert)) {
mesh::Packet* pkt = createSelfAdvert();
if (pkt) sendZeroHop(pkt);
updateAdvertTimer(); // schedule next local advert
}
#ifdef DISPLAY_CLASS
ui_task.loop();
#endif
// TODO: periodically check for OLD/inactive entries in known_clients[], and evict
}
};
StdRNG fast_rng;
SimpleMeshTables tables;
MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables);
void halt() {
while (1) ;
}
static char command[MAX_POST_TEXT_LEN+1];
void setup() {
Serial.begin(115200);
delay(1000);
board.begin();
#ifdef DISPLAY_CLASS
if(display.begin()){
display.startFrame();
display.print("Please wait...");
display.endFrame();
}
#endif
if (!radio_init()) { halt(); }
fast_rng.begin(radio_get_rng_seed());
FILESYSTEM* fs;
#if defined(NRF52_PLATFORM)
InternalFS.begin();
fs = &InternalFS;
IdentityStore store(InternalFS, "");
#elif defined(ESP32)
SPIFFS.begin(true);
fs = &SPIFFS;
IdentityStore store(SPIFFS, "/identity");
#else
#error "need to define filesystem"
#endif
if (!store.load("_main", the_mesh.self_id)) {
the_mesh.self_id = radio_new_identity(); // create new random identity
int count = 0;
while (count < 10 && (the_mesh.self_id.pub_key[0] == 0x00 || the_mesh.self_id.pub_key[0] == 0xFF)) { // reserved id hashes
the_mesh.self_id = radio_new_identity(); count++;
}
store.save("_main", the_mesh.self_id);
}
Serial.print("Room ID: ");
mesh::Utils::printHex(Serial, the_mesh.self_id.pub_key, PUB_KEY_SIZE); Serial.println();
command[0] = 0;
the_mesh.begin(fs);
#ifdef DISPLAY_CLASS
ui_task.begin(the_mesh.getNodeName(), FIRMWARE_BUILD_DATE);
#endif
// send out initial Advertisement to the mesh
the_mesh.sendSelfAdvertisement(16000);
}
void loop() {
int len = strlen(command);
while (Serial.available() && len < sizeof(command)-1) {
char c = Serial.read();
if (c != '\n') {
command[len++] = c;
command[len] = 0;
}
Serial.print(c);
}
if (len == sizeof(command)-1) { // command buffer full
command[sizeof(command)-1] = '\r';
}
if (len > 0 && command[len - 1] == '\r') { // received complete line
command[len - 1] = 0; // replace newline with C string null terminator
char reply[160];
the_mesh.getCLI()->handleCommand(0, command, reply); // NOTE: there is no sender_timestamp via serial!
if (reply[0]) {
Serial.print(" -> "); Serial.println(reply);
}
command[0] = 0; // reset command buffer
}
the_mesh.loop();
}
+566
View File
@@ -0,0 +1,566 @@
#include <Arduino.h> // needed for PlatformIO
#include <Mesh.h>
#if defined(NRF52_PLATFORM)
#include <InternalFileSystem.h>
#elif defined(ESP32)
#include <SPIFFS.h>
#endif
#include <helpers/ArduinoHelpers.h>
#include <helpers/StaticPoolPacketManager.h>
#include <helpers/SimpleMeshTables.h>
#include <helpers/IdentityStore.h>
#include <RTClib.h>
#include <target.h>
/* ---------------------------------- CONFIGURATION ------------------------------------- */
#define FIRMWARE_VER_TEXT "v2 (build: 4 Feb 2025)"
#ifndef LORA_FREQ
#define LORA_FREQ 915.0
#endif
#ifndef LORA_BW
#define LORA_BW 250
#endif
#ifndef LORA_SF
#define LORA_SF 10
#endif
#ifndef LORA_CR
#define LORA_CR 5
#endif
#ifndef LORA_TX_POWER
#define LORA_TX_POWER 20
#endif
#ifndef MAX_CONTACTS
#define MAX_CONTACTS 100
#endif
#include <helpers/BaseChatMesh.h>
#define SEND_TIMEOUT_BASE_MILLIS 500
#define FLOOD_SEND_TIMEOUT_FACTOR 16.0f
#define DIRECT_SEND_PERHOP_FACTOR 6.0f
#define DIRECT_SEND_PERHOP_EXTRA_MILLIS 250
#define PUBLIC_GROUP_PSK "izOH6cXN6mrJ5e26oRXNcg=="
// Believe it or not, this std C function is busted on some platforms!
static uint32_t _atoi(const char* sp) {
uint32_t n = 0;
while (*sp && *sp >= '0' && *sp <= '9') {
n *= 10;
n += (*sp++ - '0');
}
return n;
}
/* -------------------------------------------------------------------------------------- */
struct NodePrefs { // persisted to file
float airtime_factor;
char node_name[32];
double node_lat, node_lon;
float freq;
uint8_t tx_power_dbm;
uint8_t unused[3];
};
class MyMesh : public BaseChatMesh, ContactVisitor {
FILESYSTEM* _fs;
NodePrefs _prefs;
uint32_t expected_ack_crc;
ChannelDetails* _public;
unsigned long last_msg_sent;
ContactInfo* curr_recipient;
char command[512+10];
uint8_t tmp_buf[256];
char hex_buf[512];
const char* getTypeName(uint8_t type) const {
if (type == ADV_TYPE_CHAT) return "Chat";
if (type == ADV_TYPE_REPEATER) return "Repeater";
if (type == ADV_TYPE_ROOM) return "Room";
return "??"; // unknown
}
void loadContacts() {
if (_fs->exists("/contacts")) {
File file = _fs->open("/contacts");
if (file) {
bool full = false;
while (!full) {
ContactInfo c;
uint8_t pub_key[32];
uint8_t unused;
uint32_t reserved;
bool success = (file.read(pub_key, 32) == 32);
success = success && (file.read((uint8_t *) &c.name, 32) == 32);
success = success && (file.read(&c.type, 1) == 1);
success = success && (file.read(&c.flags, 1) == 1);
success = success && (file.read(&unused, 1) == 1);
success = success && (file.read((uint8_t *) &reserved, 4) == 4);
success = success && (file.read((uint8_t *) &c.out_path_len, 1) == 1);
success = success && (file.read((uint8_t *) &c.last_advert_timestamp, 4) == 4);
success = success && (file.read(c.out_path, 64) == 64);
c.gps_lat = c.gps_lon = 0; // not yet supported
if (!success) break; // EOF
c.id = mesh::Identity(pub_key);
c.lastmod = 0;
if (!addContact(c)) full = true;
}
file.close();
}
}
}
void saveContacts() {
#if defined(NRF52_PLATFORM)
File file = _fs->open("/contacts", FILE_O_WRITE);
if (file) { file.seek(0); file.truncate(); }
#else
File file = _fs->open("/contacts", "w", true);
#endif
if (file) {
ContactsIterator iter;
ContactInfo c;
uint8_t unused = 0;
uint32_t reserved = 0;
while (iter.hasNext(this, c)) {
bool success = (file.write(c.id.pub_key, 32) == 32);
success = success && (file.write((uint8_t *) &c.name, 32) == 32);
success = success && (file.write(&c.type, 1) == 1);
success = success && (file.write(&c.flags, 1) == 1);
success = success && (file.write(&unused, 1) == 1);
success = success && (file.write((uint8_t *) &reserved, 4) == 4);
success = success && (file.write((uint8_t *) &c.out_path_len, 1) == 1);
success = success && (file.write((uint8_t *) &c.last_advert_timestamp, 4) == 4);
success = success && (file.write(c.out_path, 64) == 64);
if (!success) break; // write failed
}
file.close();
}
}
void setClock(uint32_t timestamp) {
uint32_t curr = getRTCClock()->getCurrentTime();
if (timestamp > curr) {
getRTCClock()->setCurrentTime(timestamp);
Serial.println(" (OK - clock set!)");
} else {
Serial.println(" (ERR: clock cannot go backwards)");
}
}
void importCard(const char* command) {
while (*command == ' ') command++; // skip leading spaces
if (memcmp(command, "meshcore://", 11) == 0) {
command += 11; // skip the prefix
char *ep = strchr(command, 0); // find end of string
while (ep > command) {
ep--;
if (mesh::Utils::isHexChar(*ep)) break; // found tail end of card
*ep = 0; // remove trailing spaces and other junk
}
int len = strlen(command);
if (len % 2 == 0) {
len >>= 1; // halve, for num bytes
if (mesh::Utils::fromHex(tmp_buf, len, command)) {
importContact(tmp_buf, len);
return;
}
}
}
Serial.println(" error: invalid format");
}
protected:
float getAirtimeBudgetFactor() const override {
return _prefs.airtime_factor;
}
int calcRxDelay(float score, uint32_t air_time) const override {
return 0; // disable rxdelay
}
bool allowPacketForward(const mesh::Packet* packet) override {
return true;
}
void onDiscoveredContact(ContactInfo& contact, bool is_new) override {
// TODO: if not in favs, prompt to add as fav(?)
Serial.printf("ADVERT from -> %s\n", contact.name);
Serial.printf(" type: %s\n", getTypeName(contact.type));
Serial.print(" public key: "); mesh::Utils::printHex(Serial, contact.id.pub_key, PUB_KEY_SIZE); Serial.println();
saveContacts();
}
void onContactPathUpdated(const ContactInfo& contact) override {
Serial.printf("PATH to: %s, path_len=%d\n", contact.name, (int32_t) contact.out_path_len);
saveContacts();
}
bool processAck(const uint8_t *data) override {
if (memcmp(data, &expected_ack_crc, 4) == 0) { // got an ACK from recipient
Serial.printf(" Got ACK! (round trip: %d millis)\n", _ms->getMillis() - last_msg_sent);
// NOTE: the same ACK can be received multiple times!
expected_ack_crc = 0; // reset our expected hash, now that we have received ACK
return true;
}
//uint32_t crc;
//memcpy(&crc, data, 4);
//MESH_DEBUG_PRINTLN("unknown ACK received: %08X (expected: %08X)", crc, expected_ack_crc);
return false;
}
void onMessageRecv(const ContactInfo& from, mesh::Packet* pkt, uint32_t sender_timestamp, const char *text) override {
Serial.printf("(%s) MSG -> from %s\n", pkt->isRouteDirect() ? "DIRECT" : "FLOOD", from.name);
Serial.printf(" %s\n", text);
if (strcmp(text, "clock sync") == 0) { // special text command
setClock(sender_timestamp + 1);
}
}
void onCommandDataRecv(const ContactInfo& from, mesh::Packet* pkt, uint32_t sender_timestamp, const char *text) override {
}
void onSignedMessageRecv(const ContactInfo& from, mesh::Packet* pkt, uint32_t sender_timestamp, const uint8_t *sender_prefix, const char *text) override {
}
void onChannelMessageRecv(const mesh::GroupChannel& channel, mesh::Packet* pkt, uint32_t timestamp, const char *text) override {
if (pkt->isRouteDirect()) {
Serial.printf("PUBLIC CHANNEL MSG -> (Direct!)\n");
} else {
Serial.printf("PUBLIC CHANNEL MSG -> (Flood) hops %d\n", pkt->path_len);
}
Serial.printf(" %s\n", text);
}
void onContactResponse(const ContactInfo& contact, const uint8_t* data, uint8_t len) override {
// not supported
}
uint32_t calcFloodTimeoutMillisFor(uint32_t pkt_airtime_millis) const override {
return SEND_TIMEOUT_BASE_MILLIS + (FLOOD_SEND_TIMEOUT_FACTOR * pkt_airtime_millis);
}
uint32_t calcDirectTimeoutMillisFor(uint32_t pkt_airtime_millis, uint8_t path_len) const override {
return SEND_TIMEOUT_BASE_MILLIS +
( (pkt_airtime_millis*DIRECT_SEND_PERHOP_FACTOR + DIRECT_SEND_PERHOP_EXTRA_MILLIS) * (path_len + 1));
}
void onSendTimeout() override {
Serial.println(" ERROR: timed out, no ACK.");
}
public:
MyMesh(mesh::Radio& radio, StdRNG& rng, mesh::RTCClock& rtc, SimpleMeshTables& tables)
: BaseChatMesh(radio, *new ArduinoMillis(), rng, rtc, *new StaticPoolPacketManager(16), tables)
{
// defaults
memset(&_prefs, 0, sizeof(_prefs));
_prefs.airtime_factor = 2.0; // one third
strcpy(_prefs.node_name, "NONAME");
_prefs.freq = LORA_FREQ;
_prefs.tx_power_dbm = LORA_TX_POWER;
command[0] = 0;
curr_recipient = NULL;
}
float getFreqPref() const { return _prefs.freq; }
uint8_t getTxPowerPref() const { return _prefs.tx_power_dbm; }
void begin(FILESYSTEM& fs) {
_fs = &fs;
BaseChatMesh::begin();
#if defined(NRF52_PLATFORM)
IdentityStore store(fs, "");
#else
IdentityStore store(fs, "/identity");
#endif
if (!store.load("_main", self_id, _prefs.node_name, sizeof(_prefs.node_name))) { // legacy: node_name was from identity file
// Need way to get some entropy to seed RNG
Serial.println("Press ENTER to generate key:");
char c = 0;
while (c != '\n') { // wait for ENTER to be pressed
if (Serial.available()) c = Serial.read();
}
((StdRNG *)getRNG())->begin(millis());
self_id = mesh::LocalIdentity(getRNG()); // create new random identity
int count = 0;
while (count < 10 && (self_id.pub_key[0] == 0x00 || self_id.pub_key[0] == 0xFF)) { // reserved id hashes
self_id = mesh::LocalIdentity(getRNG()); count++;
}
store.save("_main", self_id);
}
// load persisted prefs
if (_fs->exists("/node_prefs")) {
File file = _fs->open("/node_prefs");
if (file) {
file.read((uint8_t *) &_prefs, sizeof(_prefs));
file.close();
}
}
loadContacts();
_public = addChannel("Public", PUBLIC_GROUP_PSK); // pre-configure Andy's public channel
}
void savePrefs() {
#if defined(NRF52_PLATFORM)
File file = _fs->open("/node_prefs", FILE_O_WRITE);
if (file) { file.seek(0); file.truncate(); }
#else
File file = _fs->open("/node_prefs", "w", true);
#endif
if (file) {
file.write((const uint8_t *)&_prefs, sizeof(_prefs));
file.close();
}
}
void showWelcome() {
Serial.println("===== MeshCore Chat Terminal =====");
Serial.println();
Serial.printf("WELCOME %s\n", _prefs.node_name);
mesh::Utils::printHex(Serial, self_id.pub_key, PUB_KEY_SIZE);
Serial.println();
Serial.println(" (enter 'help' for basic commands)");
Serial.println();
}
void sendSelfAdvert(int delay_millis) {
auto pkt = createSelfAdvert(_prefs.node_name, _prefs.node_lat, _prefs.node_lon);
if (pkt) {
sendFlood(pkt, delay_millis);
}
}
// ContactVisitor
void onContactVisit(const ContactInfo& contact) override {
Serial.printf(" %s - ", contact.name);
char tmp[40];
int32_t secs = contact.last_advert_timestamp - getRTCClock()->getCurrentTime();
AdvertTimeHelper::formatRelativeTimeDiff(tmp, secs, false);
Serial.println(tmp);
}
void handleCommand(const char* command) {
while (*command == ' ') command++; // skip leading spaces
if (memcmp(command, "send ", 5) == 0) {
if (curr_recipient) {
const char *text = &command[5];
uint32_t est_timeout;
int result = sendMessage(*curr_recipient, getRTCClock()->getCurrentTime(), 0, text, expected_ack_crc, est_timeout);
if (result == MSG_SEND_FAILED) {
Serial.println(" ERROR: unable to send.");
} else {
last_msg_sent = _ms->getMillis();
Serial.printf(" (message sent - %s)\n", result == MSG_SEND_SENT_FLOOD ? "FLOOD" : "DIRECT");
}
} else {
Serial.println(" ERROR: no recipient selected (use 'to' cmd).");
}
} else if (memcmp(command, "public ", 7) == 0) { // send GroupChannel msg
uint8_t temp[5+MAX_TEXT_LEN+32];
uint32_t timestamp = getRTCClock()->getCurrentTime();
memcpy(temp, &timestamp, 4); // mostly an extra blob to help make packet_hash unique
temp[4] = 0; // attempt and flags
sprintf((char *) &temp[5], "%s: %s", _prefs.node_name, &command[7]); // <sender>: <msg>
temp[5 + MAX_TEXT_LEN] = 0; // truncate if too long
int len = strlen((char *) &temp[5]);
auto pkt = createGroupDatagram(PAYLOAD_TYPE_GRP_TXT, _public->channel, temp, 5 + len);
if (pkt) {
sendFlood(pkt);
Serial.println(" Sent.");
} else {
Serial.println(" ERROR: unable to send");
}
} else if (memcmp(command, "list", 4) == 0) { // show Contact list, by most recent
int n = 0;
if (command[4] == ' ') { // optional param, last 'N'
n = atoi(&command[5]);
}
scanRecentContacts(n, this);
} else if (strcmp(command, "clock") == 0) { // show current time
uint32_t now = getRTCClock()->getCurrentTime();
DateTime dt = DateTime(now);
Serial.printf( "%02d:%02d - %d/%d/%d UTC\n", dt.hour(), dt.minute(), dt.day(), dt.month(), dt.year());
} else if (memcmp(command, "time ", 5) == 0) { // set time (to epoch seconds)
uint32_t secs = _atoi(&command[5]);
setClock(secs);
} else if (memcmp(command, "to ", 3) == 0) { // set current recipient
curr_recipient = searchContactsByPrefix(&command[3]);
if (curr_recipient) {
Serial.printf(" Recipient %s now selected.\n", curr_recipient->name);
} else {
Serial.println(" Error: Name prefix not found.");
}
} else if (strcmp(command, "to") == 0) { // show current recipient
if (curr_recipient) {
Serial.printf(" Current: %s\n", curr_recipient->name);
} else {
Serial.println(" Err: no recipient selected");
}
} else if (strcmp(command, "advert") == 0) {
auto pkt = createSelfAdvert(_prefs.node_name, _prefs.node_lat, _prefs.node_lon);
if (pkt) {
sendZeroHop(pkt);
Serial.println(" (advert sent, zero hop).");
} else {
Serial.println(" ERR: unable to send");
}
} else if (strcmp(command, "reset path") == 0) {
if (curr_recipient) {
resetPathTo(*curr_recipient);
saveContacts();
Serial.println(" Done.");
}
} else if (memcmp(command, "card", 4) == 0) {
Serial.printf("Hello %s\n", _prefs.node_name);
auto pkt = createSelfAdvert(_prefs.node_name, _prefs.node_lat, _prefs.node_lon);
if (pkt) {
uint8_t len = pkt->writeTo(tmp_buf);
releasePacket(pkt); // undo the obtainNewPacket()
mesh::Utils::toHex(hex_buf, tmp_buf, len);
Serial.println("Your MeshCore biz card:");
Serial.print("meshcore://"); Serial.println(hex_buf);
Serial.println();
} else {
Serial.println(" Error");
}
} else if (memcmp(command, "import ", 7) == 0) {
importCard(&command[7]);
} else if (memcmp(command, "set ", 4) == 0) {
const char* config = &command[4];
if (memcmp(config, "af ", 3) == 0) {
_prefs.airtime_factor = atof(&config[3]);
savePrefs();
Serial.println(" OK");
} else if (memcmp(config, "name ", 5) == 0) {
StrHelper::strncpy(_prefs.node_name, &config[5], sizeof(_prefs.node_name));
savePrefs();
Serial.println(" OK");
} else if (memcmp(config, "lat ", 4) == 0) {
_prefs.node_lat = atof(&config[4]);
savePrefs();
Serial.println(" OK");
} else if (memcmp(config, "lon ", 4) == 0) {
_prefs.node_lon = atof(&config[4]);
savePrefs();
Serial.println(" OK");
} else if (memcmp(config, "tx ", 3) == 0) {
_prefs.tx_power_dbm = atoi(&config[3]);
savePrefs();
Serial.println(" OK - reboot to apply");
} else if (memcmp(config, "freq ", 5) == 0) {
_prefs.freq = atof(&config[5]);
savePrefs();
Serial.println(" OK - reboot to apply");
} else {
Serial.printf(" ERROR: unknown config: %s\n", config);
}
} else if (memcmp(command, "ver", 3) == 0) {
Serial.println(FIRMWARE_VER_TEXT);
} else if (memcmp(command, "help", 4) == 0) {
Serial.println("Commands:");
Serial.println(" set {name|lat|lon|freq|tx|af} {value}");
Serial.println(" card");
Serial.println(" import {biz card}");
Serial.println(" clock");
Serial.println(" time <epoch-seconds>");
Serial.println(" list {n}");
Serial.println(" to <recipient name or prefix>");
Serial.println(" to");
Serial.println(" send <text>");
Serial.println(" advert");
Serial.println(" reset path");
Serial.println(" public <text>");
} else {
Serial.print(" ERROR: unknown command: "); Serial.println(command);
}
}
void loop() {
BaseChatMesh::loop();
int len = strlen(command);
while (Serial.available() && len < sizeof(command)-1) {
char c = Serial.read();
if (c != '\n') {
command[len++] = c;
command[len] = 0;
}
Serial.print(c);
}
if (len == sizeof(command)-1) { // command buffer full
command[sizeof(command)-1] = '\r';
}
if (len > 0 && command[len - 1] == '\r') { // received complete line
command[len - 1] = 0; // replace newline with C string null terminator
handleCommand(command);
command[0] = 0; // reset command buffer
}
}
};
StdRNG fast_rng;
SimpleMeshTables tables;
MyMesh the_mesh(radio_driver, fast_rng, *new VolatileRTCClock(), tables); // TODO: test with 'rtc_clock' in target.cpp
void halt() {
while (1) ;
}
void setup() {
Serial.begin(115200);
board.begin();
if (!radio_init()) { halt(); }
fast_rng.begin(radio_get_rng_seed());
#if defined(NRF52_PLATFORM)
InternalFS.begin();
the_mesh.begin(InternalFS);
#elif defined(ESP32)
SPIFFS.begin(true);
the_mesh.begin(SPIFFS);
#else
#error "need to define filesystem"
#endif
radio_set_params(the_mesh.getFreqPref(), LORA_BW, LORA_SF, LORA_CR);
radio_set_tx_power(the_mesh.getTxPowerPref());
the_mesh.showWelcome();
// send out initial Advertisement to the mesh
the_mesh.sendSelfAdvert(1200); // add slight delay
}
void loop() {
the_mesh.loop();
}
-1338
View File
File diff suppressed because it is too large. Load diff
+39
View File
@@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
-894
View File
@@ -1,894 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="generator" content="mkdocs-1.6.1, mkdocs-terminal-4.8.0">
<meta name="description" content="MeshCore fork meshcore-tth -- repeater antispam, diagnostics, OTA, Czech mesh defaults">
<link rel="canonical" href="https://tth-pub.pages.rfa.cz/meshcore-tth/"><link rel="icon" type="image/png" sizes="192x192" href="img/android-chrome-192x192.png" />
<link rel="icon" type="image/png" sizes="512x512" href="img/android-chrome-512x512.png" />
<link rel="apple-touch-icon" sizes="180x180" href="img/apple-touch-icon.png" />
<link rel="shortcut icon" type="image/png" sizes="48x48" href="img/favicon.ico" />
<link rel="icon" type="image/png" sizes="16x16" href="img/favicon-16x16.png" />
<link rel="icon" type="image/png" sizes="32x32" href="img/favicon-32x32.png" />
<title>About the fork - MeshCore TTH</title>
<link href="css/fontawesome/css/fontawesome.min.css" rel="stylesheet">
<link href="css/fontawesome/css/solid.min.css" rel="stylesheet">
<link href="css/normalize.css" rel="stylesheet">
<link href="css/terminal.css" rel="stylesheet">
<link href="css/theme.css" rel="stylesheet">
<link href="css/theme.tile_grid.css" rel="stylesheet">
<link href="css/theme.footer.css" rel="stylesheet">
<!-- dark color palette -->
<link href="css/palettes/dark.css" rel="stylesheet">
<!-- page layout -->
<style>
/* initially set page layout to a one column grid */
.terminal-mkdocs-main-grid {
display: grid;
grid-column-gap: 1.4em;
grid-template-columns: auto;
grid-template-rows: auto;
}
/*
* when side navigation is not hidden, use a two column grid.
* if the screen is too narrow, fall back to the initial one column grid layout.
* in this case the main content will be placed under the navigation panel.
*/
@media only screen and (min-width: 70em) {
.terminal-mkdocs-main-grid {
grid-template-columns: 4fr 9fr;
}
}</style>
<!-- cursor_animation override -->
<style>
#mkdocs-terminal-site-name.terminal-prompt::after {
display: none;
}
</style>
<link href="_stylesheets/tth.css" rel="stylesheet">
<!-- search css support -->
<link href="css/search/bootstrap-modal.css" rel="stylesheet">
<!-- search scripts -->
<script>
var base_url = ".",
shortcuts = "{}";
</script>
<script src="js/jquery/jquery-1.10.1.min.js" defer></script>
<script src="js/bootstrap/bootstrap.min.js" defer></script>
<script src="js/mkdocs/base.js" defer></script>
<script src="search/main.js"></script>
</head>
<body class="terminal"><div class="container">
<div class="terminal-nav">
<header class="terminal-logo">
<div id="mkdocs-terminal-site-name" class="logo terminal-prompt"><a href="https://tth-pub.pages.rfa.cz/meshcore-tth/" class="no-style">MeshCore TTH</a></div>
</header>
<nav class="terminal-menu">
<ul vocab="https://schema.org/" typeof="BreadcrumbList">
<li property="itemListElement" typeof="ListItem">
<a href="." class="menu-item active" property="item" typeof="WebPage">
<span property="name">About the fork</span>
</a>
<meta property="position" content="0">
</li>
<li property="itemListElement" typeof="ListItem">
<a href="cs/" class="menu-item " property="item" typeof="WebPage">
<span property="name">Česky</span>
</a>
<meta property="position" content="1">
</li>
<li property="itemListElement" typeof="ListItem">
<a href="#" class="menu-item" data-toggle="modal" data-target="#mkdocs_search_modal" property="item" typeof="SearchAction">
<i aria-hidden="true" class="fa fa-search"></i> <span property="name">Search</span>
</a>
<meta property="position" content="2">
</li>
</ul>
</nav>
</div>
</div>
<div class="container">
<div class="terminal-mkdocs-main-grid"><aside id="terminal-mkdocs-side-panel"><nav>
<ul class="terminal-mkdocs-side-nav-items">
<li class="terminal-mkdocs-side-nav-li">
<span class="terminal-mkdocs-side-nav-item--active">About the fork</span>
</li>
<li class="terminal-mkdocs-side-nav-li">
<a class="terminal-mkdocs-side-nav-item" href="cs/">Česky</a>
</li>
<li class="terminal-mkdocs-side-nav-li">
<span class="
terminal-mkdocs-side-nav-item terminal-mkdocs-side-nav-section-no-index">Fork meshcore-tth</span>
<ul class="terminal-mkdocs-side-nav-li-ul">
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="tth-commands/">Console commands</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="ota/">Firmware update by the admin (OTA)</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="power/">Power saving</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="budka-sensor/">Budka as a sensor</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="ble-lora-coexistence/">BLE/LoRa coexistence</a>
</li>
</ul>
</li>
<li class="terminal-mkdocs-side-nav-li">
<span class="
terminal-mkdocs-side-nav-item terminal-mkdocs-side-nav-section-no-index">MeshCore (upstream)</span>
<ul class="terminal-mkdocs-side-nav-li-ul">
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="meshcore/">Introduction</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="faq/">FAQ</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="cli_commands/">CLI commands</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="companion_cli/">Companion CLI</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="companion_protocol/">Companion protocol</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="terminal_chat_cli/">Terminal chat CLI</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="kiss_modem_protocol/">KISS modem protocol</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="packet_format/">Packet format</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="payloads/">Payloads</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="stats_binary_frames/">Stats binary frames</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="number_allocations/">Number allocations</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="qr_codes/">QR codes</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="radio_presets/">Radio presets</a>
</li>
<li class="terminal-mkdocs-side-nav-li-ul-li">
<a class="terminal-mkdocs-side-nav-item" href="nrf52_power_management/">nRF52 power management</a>
</li>
</ul>
</li>
</ul>
</nav><hr>
<nav>
<ul>
<li><a href="#about-this-fork-meshcore-tth">About this fork (meshcore-tth)</a></li>
<li><a href="#repeater-antispam-all-of-it-off-switchable-none-of-it-upstream">Repeater: antispam (all of it off-switchable, none of it upstream)</a></li><li><a href="#diagnostics-and-operations">Diagnostics and operations</a></li><li><a href="#core-fixes">Core fixes</a></li><li><a href="#power-clock-gps">Power, clock, GPS</a></li><li><a href="#sensors-and-companions">Sensors and companions</a></li><li><a href="#public-builds-czech-mesh-defaults">Public builds: Czech mesh defaults</a></li><li><a href="#flashing-a-release">Flashing a release</a></li><li><a href="#experimental-firmware-update-pushed-by-the-admin-ota">Experimental: firmware update pushed by the admin (*-ota)</a></li><li><a href="#build">Build</a></li>
</ul>
</nav>
</aside>
<main id="terminal-mkdocs-main-content">
<section id="mkdocs-terminal-content">
<h1 id="about-this-fork-meshcore-tth">About this fork (meshcore-tth)</h1>
<p><em><a href="cs/">Česká verze</a>.</em></p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p><strong>Experimental firmware -- not meant for regular users.</strong> This fork and all
its releases are a personal development branch for the nodes of one small
network: a rolling release on upstream <code>dev</code>, built automatically about
twice a day, with no stable channel, no support, and tried only on our own
boards. It may carry bugs that take a node out of service, and getting one
back then needs USB or BLE in hand. For everyday use flash the official
MeshCore (<a href="https://flasher.meshcore.io">flasher.meshcore.io</a>).</p>
</div>
<p>A fork of <a href="https://github.com/meshcore-dev/MeshCore">meshcore-dev/MeshCore</a>
that runs the repeaters, sensors and bench boards of a small Czech network on
the CZ mesh (869.432 MHz). Upstream <code>main</code> and <code>dev</code> are merged automatically
twice a day; everything below is on top of that. Our code is marked
<code>CUSTOM (TeTeHacko)</code> in the source. Nothing here changes the wire protocol.</p>
<h2 id="repeater-antispam-all-of-it-off-switchable-none-of-it-upstream">Repeater: antispam (all of it off-switchable, none of it upstream)</h2>
<p><strong>After flashing only the FairnessLimiter is on</strong>, with limits about twice
above 30 days of real CZ mesh traffic: per channel a burst of 100 messages,
then one per 30 s; per sender 150 and one per 10 s; per advert origin 30 and
one per 10 min. It is a net for runaway floods, not a quota; <code>fairness off</code>
switches it off for good. The advert window, the filters and dry-run stay
off until you turn them on.</p>
<ul>
<li><strong>FairnessLimiter</strong> -- token buckets on forwarded floods, keyed on the 1-byte
ids already in the clear (channel hash, sender hash, advert origin). Port of
Beanow's proposal <a href="https://github.com/meshcore-dev/MeshCore/pull/1502">#1502</a>,
limits re-sized from 30 days of real CZ traffic.
<code>fairness [on|off|grid|cap|refill]</code>; direct-routed traffic is never limited.</li>
<li><strong>Per-origin advert window</strong> -- each node's flood advert forwarded at most
once per N hours (<code>fairness advert &lt;h&gt;|clear</code>), ported from
<a href="https://github.com/Dutch-MeshCore/MeshCore">DutchMeshCore</a>'s AdvertLimiter.
Aimed at nodes that re-advertise every minute.</li>
<li><strong>Dry-run</strong> -- <code>fairness dryrun on</code> counts every verdict but forwards anyway;
<code>fairness air</code> reports the airtime shed (or that would be) per reason.</li>
<li><strong>Channel filter</strong> -- on channels whose key the repeater knows (Public and
<code>#hashtag</code> channels), stop forwarding messages of listed sender names
(<code>filter add|del|list</code>). Names are spoofable: it contains a runaway bot,
it is not security.</li>
<li><strong>Channel-hash deny-forward</strong> -- <code>filter hash add &lt;hex&gt; [secs]</code>: keyless,
works on private channels too; reception is unaffected, only forwarding.
With <code>secs</code> the channel is throttled (one packet per <code>secs</code>) instead of cut.</li>
<li><strong>Message age limit</strong> -- <code>filter age &lt;min&gt;|off</code> (opt-in, 1-10080 min): do not
forward group texts on the decrypted channels whose sender timestamp is
older; inactive while the repeater clock is unset. It judges the sender's
clock, so companions without a time sync are dropped too -- keep it in days.</li>
<li><code>filter dryrun on</code> counts every <code>filter</code> verdict but forwards anyway.</li>
</ul>
<h2 id="diagnostics-and-operations">Diagnostics and operations</h2>
<p>Every command of the fork, which builds have it and the defaults:
<a href="https://git.rfa.cz/tth-pub/meshcore-tth/src/branch/main/tth-commands.md">docs/tth-commands.md</a>.</p>
<p>Repeater, room server and sensor (everything with a text console) have:</p>
<ul>
<li><strong>Radio watchdogs.</strong> The hardware watchdog only catches a frozen loop; two
of our nodes were found deaf with the loop running, and only a reboot
helped.</li>
<li><code>set radio.silence &lt;min&gt;</code> -- <strong>deaf receiver</strong>: when the received-frame
counter does not move for <code>&lt;min&gt;</code> minutes (a frame with a CRC error
counts), the node re-arms its receiver first and reboots if that does not
help either. Each such reboot doubles the threshold for the next boot (up
to 16x) and the first frame received resets it, so a quiet site does not
end in a reboot loop. Saved; <strong>off by default</strong> (<code>0</code>) -- pick a threshold
well above the longest normal quiet spell of the site.</li>
<li><strong>Stalled TX</strong> (repeater only): packets wait in the queue and the sent
counter does not move -&gt; re-arm the radio, then reboot. An empty queue
never counts. <strong>On, 15 min</strong> (<code>RADIO_TXSTALL_MIN</code>); <code>set radio.txstall
&lt;min&gt;|off</code> holds until the next reboot.</li>
<li><code>get radio.reboots</code> -- reboots done by the watchdogs (survives power
loss); <code>get boot</code> -- why the board last reset, and the hardfault record
(also printed at boot).</li>
<li><code>dfu [uf2|serial|ota]</code> -- a deterministic reboot into the bootloader (local
console only); <code>i2c</code> -- bus scan.</li>
</ul>
<p>The repeater also has:</p>
<ul>
<li><code>blink</code> (flashes the LED, also over the mesh -- finds a node on a mast),
<code>txpwr</code> (TX power until reboot, with RadioLib's verdict), TX-failure
counters in the status reply.</li>
<li>Observer variants only (<code>*-observer</code>): text console over BLE next to USB,
<code>ble on|off</code> saved across reboots (<code>RPT_BLE_DEFAULT_OFF</code>: starts off), own
BLE PIN (<code>ble pin</code>), persisted connection TX power (<code>blepwr</code>), <code>bleconn</code>, a
non-blocking BLE TX pump and connection parameters that hold on a weak
link.</li>
<li>Also observer variants only: a passive analyzer in the console --
<code>nodes</code> (heard repeaters/rooms, multi-path join key), <code>rxlog</code> (every frame
heard, type/path/SNR/RSSI), <code>pktlog</code> (raw frames for an observer feed), big
paged replies.</li>
<li>Own builds only, not in the releases:</li>
<li>channel bot (<code>BOT_CHANNEL_PSK</code>: <code>!link</code>, <code>!path</code>, <code>!snr</code>, <code>!heard</code>,
<code>!noise</code>, <code>!ping</code>, <code>!help</code>, narrowed by <code>BOT_COMMANDS</code>, per-sender
cooldown, ignore list) -- answers without repeating;</li>
<li><code>RADIO_DIAG</code>: <code>radiostat</code> (SX1262 receiver state, hands off) and
<code>radiokick rx|clrirq|standby|agc</code> (one recovery step at a time, gentlest
first -- the first that helps names the broken layer);</li>
<li><code>PIN_DIAG</code>: <code>dio1</code> (the chip's IRQ status against the level on the pin --
which end of a dead DIO1 line is broken);</li>
<li><code>LORA_POLL_IRQ</code>: DIO1-less operation for a board with a dead IRQ line.</li>
</ul>
<h2 id="core-fixes">Core fixes</h2>
<ul>
<li><strong>Replay protection of admin commands survives a reboot.</strong> Upstream keeps a
client's last timestamp in RAM only, so after every restart any captured
command is accepted again -- a captured <code>reboot</code> reboots the node forever.
Repeater, room server and sensor now write it to flash before acting on the
command (<code>/s_acl_ts0|1</code>, 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
(<code>ACL_TS_MAX_AHEAD</code>) is accepted but not stored, so a companion with a runaway
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.</li>
<li><strong>Passwords can no longer be guessed over the air at full speed.</strong> Upstream
checks every login without a limit and does not even answer a wrong one.
After 4 wrong passwords within 3 minutes (<code>LOGIN_FAIL_MAX</code>,
<code>LOGIN_FAIL_SECS</code>) 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.</li>
<li><strong>A replayed blank-password login no longer floods a reply.</strong> 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.</li>
<li>TRACE no longer appends its path past the end of the payload; TRACE/PATH
parsing and <code>Packet::readFrom</code> are bounds-checked.</li>
<li><code>markSeen</code> is idempotent again (the send path was eating the dedup window).</li>
<li><code>calcMaxPacketMillis</code> fallback no longer underflows (a node went deaf on it).</li>
<li>Path-hash width comes from the node's prefs on every TX path, including
<code>sendZeroHop</code>; 2-byte path hashes are the default (<code>PATH_HASH_MODE_DEFAULT</code>).</li>
<li>Failed transmits are re-queued with backoff instead of dropped.</li>
<li>Per-packet RSSI captured at RX; <code>ContactInfo</code> zeroed before a partial fill.</li>
</ul>
<h2 id="power-clock-gps">Power, clock, GPS</h2>
<ul>
<li>GPS duty cycle (<code>gps duty</code>), also on the T1000-E, which had none: the
receiver runs only around a clock sync (once a day, after a window without
a fix again in 6 h). A position request warms it for the next request.</li>
<li>A node without GPS starts at its build epoch, not in 2024; the clock and a
hardfault record survive a warm reset (<code>.noinit</code>); <code>clkreboot</code>.</li>
<li>No blinking LED and slower BLE advertising on solar nodes.</li>
<li>Battery level as an icon at the end of the advertised name: <code>set batt.icon
on</code>, thresholds <code>set batt.icon.lo|hi &lt;mV&gt;</code> (off by default; a long name has
no room for it and the command says so).</li>
<li>Optional RX duty cycle (<code>set radio.rxps off|on|balanced|max</code>, finer
<code>level &lt;1-10&gt;</code>; ported from EasySkyMesh PowerSaving): the SX1262 sleeps
between short listening windows. Built into the public releases and
<strong>off</strong>; <code>max</code> saved ~2.3 mA on the bench with no packet loss
(<a href="https://git.rfa.cz/tth-pub/meshcore-tth/src/branch/main/power.md">docs/power.md</a>), but on the live mesh one of our masts lost
16 % of its reception -- switch it on with care. SX1262 only, not the LR1110
(T1000-E).</li>
<li>The nRF52 boot undervoltage lock (<code>PWRMGT_VOLTAGE_BOOTLOCK</code>) is <strong>off</strong>,
as in upstream since v1.18.0
(<a href="https://github.com/meshcore-dev/MeshCore/pull/2377">#2377</a>): its fixed
3.3 V threshold kept LiFePO4 and LTO nodes from booting. The firmware boots
on any cell chemistry; deep-discharge protection is up to the BMS or the
cell's protection board. A configurable, chemistry-aware lock is waiting
for upstream (<a href="https://github.com/meshcore-dev/MeshCore/pull/2088">#2088</a>). The exception
is <code>SenseCap_Solar_repeater</code> (Li-ion, our masts): the lock is on and both
thresholds are settable at runtime, also as an admin over the mesh --
<code>set pwr.bootlock &lt;mV&gt;|off</code> (default 3300; below it the node does not start
and sleeps until the cell recovers) and <code>set pwr.cutoff &lt;mV&gt;|off</code> (default
off; below it a running node switches off); <code>get pwr</code>
(<a href="https://git.rfa.cz/tth-pub/meshcore-tth/src/branch/main/power.md">docs/power.md</a>).</li>
</ul>
<h2 id="sensors-and-companions">Sensors and companions</h2>
<ul>
<li><code>simple_sensor</code>: telemetry from an external station over UART
(<code>BudkaLinkSensorManager</code>, one LPP channel per meter), <code>sensor read</code>.</li>
<li>Sensors that would otherwise convert continuously (INA219, INA226, INA260,
INA3221, BMP280) sleep between telemetry reads and measure on demand (idea
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: <code>sensor set ina.shunt &lt;mOhm&gt;</code>.</li>
<li>Companion: <code>gps duty</code> persists, bounded build-date copy. Private key
export, reading the BLE PIN and changing it (CLI <code>set pin</code> 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.</li>
</ul>
<h2 id="public-builds-czech-mesh-defaults">Public builds: Czech mesh defaults</h2>
<p>Releases built from this repository (<code>pub-release</code>) come preset for the
Czech mesh, following the <a href="https://meshcore.cz/">meshcore.cz</a> wiki, so a
freshly flashed node does not need the usual round of settings:</p>
<ul>
<li>radio 869.432 MHz / 62.5 kHz / SF7 / CR5 (all builds);</li>
<li>repeater and room server: zero-hop advert off, flood advert every 25 h,
10 % duty cycle (<code>get dutycycle</code> → <code>10.0%</code>; the deprecated <code>af</code> reads 9);</li>
<li>repeater: regions <code>cz</code> and <code>cs</code> next to <code>*</code> -- add your own <code>cz-&lt;kraj&gt;</code>
with <code>region put cz-xxx cz</code> + <code>region save</code>;</li>
<li>2-byte path hashes (this fork's default);</li>
<li>repeater: the channel filter (<code>filter add &lt;name&gt;</code>) is built in for Public,
<code>#meshcore</code> and <code>#test</code>, with an empty list -- it does nothing until you
add a name.</li>
</ul>
<p>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.</p>
<p><strong>The companion's BLE PIN is the public <code>123456</code></strong> (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.</p>
<p>Observer variants (<code>*_repeater-observer-*</code>) of the nRF52 repeaters (XIAO,
SenseCAP Solar, RAK4631, T1000-E, Heltec T114) add the <code>nodes</code> / <code>rxlog</code> /
<code>pktlog</code> rings and a text console over BLE, for reading the repeater over
USB or BLE (<a href="https://git.rfa.cz/tth-pub/meshcore-repeater-observer">meshcore-repeater-observer</a>).
The BLE console is <strong>off</strong> after flashing (<code>RPT_BLE_DEFAULT_OFF</code>). It has no
login of its own, only the BLE PIN, and the build's PIN is the public
placeholder <code>123456</code>. So first set your own -- in the USB console, or as
admin over the mesh (remote CLI in the app): <code>ble pin &lt;6 digits&gt;</code> (saved, survives a reboot and a reflash; it also drops
every existing bond, so paired devices pair again). Only then <code>ble on</code> --
these builds refuse it while the PIN is still the placeholder. <code>ble</code> shows
whether the PIN is <code>own</code> or <code>build default</code>, never the PIN itself. Releases
up to <code>tth-654d53f3</code> do not have <code>ble pin</code>: keep BLE off there and use USB.</p>
<h2 id="flashing-a-release">Flashing a release</h2>
<p>Every release is an automatic build on upstream <code>dev</code> (see the warning
above), not a stable version. Flash it only on nodes you can reach, and each
new release on one of them first.</p>
<p>Files are in <a href="https://git.rfa.cz/tth-pub/meshcore-tth/releases">Releases</a>.
A release is named after the upstream version and the date, e.g.
<code>v1.18.0+tth.20261112</code> (a second one that day <code>.2</code>), and its notes list the
changes since the previous release. One set per board and role
(<code>&lt;board&gt;_&lt;role&gt;-&lt;release&gt;</code>, e.g. <code>Xiao_nrf52_repeater-v1.18.0+tth.20261112.zip</code>):
<code>.zip</code> and <code>.uf2</code> for nRF52 boards, <code>.bin</code> for ESP32 (<code>-merged.bin</code> is the
full image for a blank board, the plain <code>.bin</code> an update). <code>SHA256SUMS</code> lists
the checksums. Releases up to 12. 11. 2026 were named <code>tth-&lt;sha&gt;</code>.</p>
<p><strong>nRF52 (XIAO, RAK4631, SenseCAP Solar, T1000-E, T114) with the
<a href="https://flasher.meshcore.io">MeshCore web flasher</a></strong> -- Chrome, Edge or
Chromium on a computer (Web Serial; not Firefox or Safari):</p>
<ol>
<li>Connect the board over USB.</li>
<li>Click <strong>Custom Firmware</strong> and choose the <code>.zip</code> for your board.</li>
<li>Click <strong>Enter DFU mode</strong> and pick the board's serial port. The board
restarts into its bootloader and shows up as a new port.</li>
<li>Click <strong>Flash!</strong> and pick that new port. About 30 s, then the board
restarts into the new firmware.</li>
<li><strong>Console</strong> in the flasher (or any serial terminal, 115200) checks the
result: <code>ver</code> shows <code>v1.xx.x-tth&lt;sha&gt;</code>, the same as the "Verze v uzlu"
(node version) line in the release notes.</li>
</ol>
<p><strong>Do not click Erase Flash</strong> unless you want a new node: it wipes the
identity (the node's key and everything that knows it) together with all
settings. A plain flash keeps them.</p>
<p>Tried on a XIAO (repeater-observer, 3. 11. 2026). ESP32 <code>.bin</code> through the
same Custom Firmware button is untested here.</p>
<p>Without the web flasher: on most boards a double-tap of reset opens the
bootloader as a USB drive; copy the <code>.uf2</code> onto it. Or
<code>adafruit-nrfutil dfu serial -pkg &lt;file&gt;.zip -p &lt;port&gt; -b 115200</code> with the
board in the bootloader.</p>
<p>After flashing a new node, set it up in the console: <code>set name &lt;name&gt;</code>,
<code>password &lt;admin password&gt;</code> (at most 15 characters), your own region with
<code>region put cz-&lt;kraj&gt; cz</code> + <code>region save</code>. A repeater forwards from its
first boot (upstream default) and these builds are on the live CZ frequency:
on a desk without its antenna, <code>set repeat off</code> until it is in place.</p>
<h2 id="experimental-firmware-update-pushed-by-the-admin-ota">Experimental: firmware update pushed by the admin (<code>*-ota</code>)</h2>
<p>Every nRF52 build with a text console (repeater, observer, room server,
sensor) is in the release once more as an <strong>experimental</strong> <code>*-ota</code> /
<code>*-observer-ota</code> image. It takes a new firmware from its admin with the
<code>fw …</code> commands: on the USB or BLE console, or <strong>over the mesh as remote admin
CLI</strong>. No bootloader change, no second bank: the node stores the package in
free flash, checks all of it (signature, hashes, the delta applied dry) and
rewrites itself only on <code>fw apply</code>, from a routine running in RAM. A power
cut during the rewrite leaves it in the bootloader, back via USB/BLE DFU.</p>
<ul>
<li>Each <code>*-ota</code> image comes with a full package
<code>&lt;board&gt;_&lt;role&gt;-ota-&lt;release&gt;.mcfw</code> (USB/BLE only) and a delta
<code>….from-&lt;earlier release&gt;.mcfw</code> from every kept earlier release, typically
a few kB.</li>
<li><strong>Over the mesh a node takes only a delta, and never an older version than
it runs</strong> -- enforced by the node, not by the tool. A full image or a step
back only locally (<code>fw apply downgrade</code>). <code>fw apply</code> wants the battery at
3.8 V or more unless the node runs on USB.</li>
<li>Packages and <code>SHA256SUMS</code> are signed by <code>meshcore-ota@tth-pub</code>, and an
<code>*-ota</code> image accepts no other signature. Checking the downloads:
<code>ssh-keygen -Y verify -f tools/ota_allowed_signers -I meshcore-ota@tth-pub
-n meshcore-ota -s SHA256SUMS.sig &lt; SHA256SUMS</code>. Your own build with your own
key: <code>[ota] pubkey</code> in <code>platformio.local.ini</code>.</li>
<li>The first <code>*-ota</code> image is flashed the usual way (above), later ones go as
deltas. Tools: <code>tools/ota_push.py</code> (USB), <code>tools/ota_mesh_push.py</code> (over the
mesh through a companion; needs the <code>meshcore</code> Python library, takes the
admin password from <code>[secrets] admin_pw</code> in <code>platformio.local.ini</code>; <code>--side</code>
carries the transfer on a side channel, off the shared mesh),
<code>tools/ota_pack.py info</code>. The transfer itself is the OTA engine of the
<a href="https://git.rfa.cz/tth-pub/meshcore-ansible">tth.meshcore</a> Ansible
collection (module <code>meshcore_fw_ota</code>), one code for the tools and Ansible.
From a phone: the <a href="https://git.rfa.cz/tth-pub/meshcore-open">meshcore-open</a>
fork, repeater management → Firmware update (OTA), which finds the delta in
the release by itself. How it works and bench numbers:
<a href="https://git.rfa.cz/tth-pub/meshcore-tth/src/branch/main/ota.md">docs/ota.md</a>.</li>
<li><strong>Experimental even within this fork</strong>: the images come with every
release (see the warning above) and have no second bank and no automatic
rollback. A bad firmware that boots keeps running until you push the next
one; one that does not boot needs USB/BLE DFU in hand. Tried on the bench
(XIAO, USB, mesh, side channel) and on two of our masts since 13. 11. 2026.
The radio watchdogs (see Diagnostics and operations) catch an image that
boots with a dead radio: switch <code>set radio.silence</code> on for nodes you push
to. Costs ~10 kB of RAM.</li>
</ul>
<h2 id="build">Build</h2>
<ul>
<li>Version stamping in every nRF52 env (<code>v1.18.0-tth&lt;sha&gt;</code>, <code>+</code> = dirty tree),
base version from the upstream tag (<code>tools/build_version.py</code>).</li>
<li><code>tools/</code>: host tools for the nodes -- consoles (USB, BLE), flashing, bench
tests, diagnostics (<a href="https://git.rfa.cz/tth-pub/meshcore-tth/src/branch/main/tools/README.md">tools/README.md</a>). Board names come
from a local config outside the repo (<code>tools/config.example.ini</code>).</li>
<li><code>hardware/cavity-box</code>: parametric enclosure for a cavity filter on a mast.</li>
</ul>
<hr />
<p><em>Níže je README upstreamového MeshCore. Jeho flasher, klienti a návody se
týkají oficiálního firmwaru, ne releasů tohoto forku. / Below is upstream
MeshCore's README: its flasher, clients and guides refer to the official
firmware, not to this fork's releases.</em></p>
</section>
</main>
</div>
<hr><footer>
<div class="terminal-mkdocs-footer-grid">
<div id="terminal-mkdocs-footer-copyright-info">
Site built with <a href="http://www.mkdocs.org">MkDocs</a> and <a href="https://github.com/ntno/mkdocs-terminal">Terminal for MkDocs</a>.
</div>
</div>
</footer>
</div>
<div class="modal" id="mkdocs_search_modal" tabindex="-1" role="alertdialog" aria-modal="true" aria-labelledby="searchModalLabel">
<div class="modal-dialog modal-lg" role="search">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="searchModalLabel">Search</h5>
<button type="button" class="close btn btn-default btn-ghost" data-dismiss="modal" aria-label="Close">x</button>
</div>
<div class="modal-body">
<p id="searchInputLabel">Type to start searching</p>
<form>
<div class="form-group">
<input type="search" class="form-control" aria-labelledby="searchInputLabel" placeholder="" id="mkdocs-search-query" title="Please enter search terms here">
</div>
</form>
<div id="mkdocs-search-results" data-no-results-text="No document matches found"></div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</body>
</html>
-4435
View File
File diff suppressed because it is too large. Load diff
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"bootstrap.js","sources":["../../js/src/util.js","../../js/src/alert.js","../../js/src/button.js","../../js/src/carousel.js","../../js/src/collapse.js","../../js/src/dropdown.js","../../js/src/modal.js","../../js/src/tools/sanitizer.js","../../js/src/tooltip.js","../../js/src/popover.js","../../js/src/scrollspy.js","../../js/src/tab.js","../../js/src/toast.js","../../js/src/index.js"],"sourcesContent":["/**\n * --------------------------------------------------------------------------\n * Bootstrap (v4.3.1): util.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport $ from 'jquery'\n\n/**\n * ------------------------------------------------------------------------\n * Private TransitionEnd Helpers\n * ------------------------------------------------------------------------\n */\n\nconst TRANSITION_END = 'transitionend'\nconst MAX_UID = 1000000\nconst MILLISECONDS_MULTIPLIER = 1000\n\n// Shoutout AngusCroll (https://goo.gl/pxwQGp)\nfunction toType(obj) {\n return {}.toString.call(obj).match(/\\s([a-z]+)/i)[1].toLowerCase()\n}\n\nfunction getSpecialTransitionEndEvent() {\n return {\n bindType: TRANSITION_END,\n delegateType: TRANSITION_END,\n handle(event) {\n if ($(event.target).is(this)) {\n return event.handleObj.handler.apply(this, arguments) // eslint-disable-line prefer-rest-params\n }\n return undefined // eslint-disable-line no-undefined\n }\n }\n}\n\nfunction transitionEndEmulator(duration) {\n let called = false\n\n $(this).one(Util.TRANSITION_END, () => {\n called = true\n })\n\n setTimeout(() => {\n if (!called) {\n Util.triggerTransitionEnd(this)\n }\n }, duration)\n\n return this\n}\n\nfunction setTransitionEndSupport() {\n $.fn.emulateTransitionEnd = transitionEndEmulator\n $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent()\n}\n\n/**\n * --------------------------------------------------------------------------\n * Public Util Api\n * --------------------------------------------------------------------------\n */\n\nconst Util = {\n\n TRANSITION_END: 'bsTransitionEnd',\n\n getUID(prefix) {\n do {\n // eslint-disable-next-line no-bitwise\n prefix += ~~(Math.random() * MAX_UID) // \"~~\" acts like a faster Math.floor() here\n } while (document.getElementById(prefix))\n return prefix\n },\n\n getSelectorFromElement(element) {\n let selector = element.getAttribute('data-target')\n\n if (!selector || selector === '#') {\n const hrefAttr = element.getAttribute('href')\n selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : ''\n }\n\n try {\n return document.querySelector(selector) ? selector : null\n } catch (err) {\n return null\n }\n },\n\n getTransitionDurationFromElement(element) {\n if (!element) {\n return 0\n }\n\n // Get transition-duration of the element\n let transitionDuration = $(element).css('transition-duration')\n let transitionDelay = $(element).css('transition-delay')\n\n const floatTransitionDuration = parseFloat(transitionDuration)\n const floatTransitionDelay = parseFloat(transitionDelay)\n\n // Return 0 if element or transition duration is not found\n if (!floatTransitionDuration && !floatTransitionDelay) {\n return 0\n }\n\n // If multiple durations are defined, take the first\n transitionDuration = transitionDuration.split(',')[0]\n transitionDelay = transitionDelay.split(',')[0]\n\n return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER\n },\n\n reflow(element) {\n return element.offsetHeight\n },\n\n triggerTransitionEnd(element) {\n $(element).trigger(TRANSITION_END)\n },\n\n // TODO: Remove in v5\n supportsTransitionEnd() {\n return Boolean(TRANSITION_END)\n },\n\n isElement(obj) {\n return (obj[0] || obj).nodeType\n },\n\n typeCheckConfig(componentName, config, configTypes) {\n for (const property in configTypes) {\n if (Object.prototype.hasOwnProperty.call(configTypes, property)) {\n const expectedTypes = configTypes[property]\n const value = config[property]\n const valueType = value && Util.isElement(value)\n ? 'element' : toType(value)\n\n if (!new RegExp(expectedTypes).test(valueType)) {\n throw new Error(\n `${componentName.toUpperCase()}: ` +\n `Option \"${property}\" provided type \"${valueType}\" ` +\n `but expected type \"${expectedTypes}\".`)\n }\n }\n }\n },\n\n findShadowRoot(element) {\n if (!document.documentElement.attachShadow) {\n return null\n }\n\n // Can find the shadow root otherwise it'll return the document\n if (typeof element.getRootNode === 'function') {\n const root = element.getRootNode()\n return root insLine truncated
-7
View File
@@ -1,7 +0,0 @@
/*!
* Bootstrap v4.3.1 (https://getbootstrap.com/)
* Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("jquery"),require("popper.js")):"function"==typeof define&&define.amd?define(["exports","jquery","popper.js"],e):e((t=t||self).bootstrap={},t.jQuery,t.Popper)}(this,function(t,g,u){"use strict";function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function s(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}function l(o){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},e=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(e=e.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),e.forEach(function(t){var e,n,i;e=o,i=r[n=t],n in e?Object.defineProperty(e,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[n]=i})}return o}g=g&&g.hasOwnProperty("default")?g.default:g,u=u&&u.hasOwnProperty("default")?u.default:u;var e="transitionend";function n(t){var e=this,n=!1;return g(this).one(_.TRANSITION_END,function(){n=!0}),setTimeout(function(){n||_.triggerTransitionEnd(e)},t),this}var _={TRANSITION_END:"bsTransitionEnd",getUID:function(t){for(;t+=~~(1e6*Math.random()),document.getElementById(t););return t},getSelectorFromElement:function(t){var e=t.getAttribute("data-target");if(!e||"#"===e){var n=t.getAttribute("href");e=n&&"#"!==n?n.trim():""}try{return document.querySelector(e)?e:null}catch(t){return null}},getTransitionDurationFromElement:function(t){if(!t)return 0;var e=g(t).css("transition-duration"),n=g(t).css("transition-delay"),i=parseFloat(e),o=parseFloat(n);return i||o?(e=e.split(",")[0],n=n.split(",")[0],1e3*(parseFloat(e)+parseFloat(n))):0},reflow:function(t){return t.offsetHeight},triggerTransitionEnd:function(t){g(t).trigger(e)},supportsTransitionEnd:function(){return Boolean(e)},isElement:function(t){return(t[0]||t).nodeType},typeCheckConfig:function(t,e,n){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var o=n[i],r=e[i],s=r&&_.isElement(r)?"element":(a=r,{}.toString.call(a).match(/\s([a-z]+)/i)[1].toLowerCase());if(!new RegExp(o).test(s))throw new Error(t.toUpperCase()+': Option "'+i+'" provided type "'+s+'" but expected type "'+o+'".')}var a},findShadowRoot:function(t){if(!document.documentElement.attachShadow)return null;if("function"!=typeof t.getRootNode)return t instanceof ShadowRoot?t:t.parentNode?_.findShadowRoot(t.parentNode):null;var e=t.getRootNode();return e instanceof ShadowRoot?e:null}};g.fn.emulateTransitionEnd=n,g.event.special[_.TRANSITION_END]={bindType:e,delegateType:e,handle:function(t){if(g(t.target).is(this))return t.handleObj.handler.apply(this,arguments)}};var o="alert",r="bs.alert",a="."+r,c=g.fn[o],h={CLOSE:"close"+a,CLOSED:"closed"+a,CLICK_DATA_API:"click"+a+".data-api"},f="alert",d="fade",m="show",p=function(){function i(t){this._element=t}var t=i.prototype;return t.close=function(t){var e=this._element;t&&(e=this._getRootElement(t)),this._triggerCloseEvent(e).isDefaultPrevented()||this._removeElement(e)},t.dispose=function(){g.removeData(this._element,r),this._element=null},t._getRootElement=function(t){var e=_.getSelectorFromElement(t),n=!1;return e&&(n=document.querySelector(e)),n||(n=g(t).closest("."+f)[0]),n},t._triggerCloseEvent=function(t){var e=g.Event(h.CLOSE);return g(t).trigger(e),e},t._removeElement=function(e){var n=this;if(g(e).removeClass(m),g(e).hasClass(d)){var t=_.getTransitionDurationFromElement(e);g(e).one(_.TRANSITION_END,function(t){return n._destroyElement(e,t)}).emulateTransitionEnd(t)}else this._destroyElement(e)},t._destroyElement=function(t){g(t).detach().trigger(h.CLOSED).remove()},i._jQueryInterface=function(n){return this.each(function(){var t=g(this),e=t.data(r);e||(e=new i(this),t.data(r,e)),"close"===n&&e[n](this)})},i._handleDismiss=function(e){return function(t){t&&t.preventDefault(),e.close(this)}},s(i,null,[{key:"VERSION",get:function(){return"4.3.1"}}]),i}();g(document).on(h.CLICK_DATA_API,'[data-dismiss="alert"]',p._handleDismiss(new p)),g.fn[o]=p._jQueryInterface,g.fn[o].Constructor=p,g.fn[o].noConflict=function(){return g.fn[o]=c,p._jQueryInterface};var v="button",y="bs.button",E="."+y,C=".data-api",T=g.fn[v],S="active",b="btn",I="focus",D='[data-toggle^="button"]',w='[data-toggle="buttons"]',A='input:not([type="hidden"])',N=".active",O=".btn",k={CLICK_DATA_API:"click"+E+C,FOCUS_BLUR_DATA_API:"focus"+E+C+" blur"+E+C},P=function(){function n(t){this._element=t}var t=n.prototype;return t.toggle=function(){var t=!0,e=!0,n=g(this._element).closest(w)[0];if(n){var i=this._element.querySelector(A);if(i){if("radio"===i.type)if(i.checked&&this._element.classList.contains(S))t=!1;else{var o=n.querySelector(N);o&&g(o).removeClass(S)}if(t){if(i.hasAttribute("disabled")||n.hasAttribute("disabled")||i.classList.contains("disabled")||n.classList.contains("disabled"))return;i.checked=!this._element.classList.contains(S),g(i).trigger("chLine truncated
//# sourceMappingURL=bootstrap.min.js.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"sources":["../../js/src/util.js","../../js/src/alert.js","../../js/src/button.js","../../js/src/carousel.js","../../js/src/collapse.js","../../js/src/dropdown.js","../../js/src/modal.js","../../js/src/tools/sanitizer.js","../../js/src/tooltip.js","../../js/src/popover.js","../../js/src/scrollspy.js","../../js/src/tab.js","../../js/src/toast.js","../../js/src/index.js"],"names":["TRANSITION_END","transitionEndEmulator","duration","_this","this","called","$","one","Util","setTimeout","triggerTransitionEnd","getUID","prefix","Math","random","document","getElementById","getSelectorFromElement","element","selector","getAttribute","hrefAttr","trim","querySelector","err","getTransitionDurationFromElement","transitionDuration","css","transitionDelay","floatTransitionDuration","parseFloat","floatTransitionDelay","split","reflow","offsetHeight","trigger","supportsTransitionEnd","Boolean","isElement","obj","nodeType","typeCheckConfig","componentName","config","configTypes","property","Object","prototype","hasOwnProperty","call","expectedTypes","value","valueType","toString","match","toLowerCase","RegExp","test","Error","toUpperCase","findShadowRoot","documentElement","attachShadow","getRootNode","ShadowRoot","parentNode","root","fn","emulateTransitionEnd","event","special","bindType","delegateType","handle","target","is","handleObj","handler","apply","arguments","NAME","DATA_KEY","EVENT_KEY","JQUERY_NO_CONFLICT","Event","CLOSE","CLOSED","CLICK_DATA_API","ClassName","Alert","_element","close","rootElement","_getRootElement","_triggerCloseEvent","isDefaultPrevented","_removeElement","dispose","removeData","parent","closest","closeEvent","removeClass","hasClass","_destroyElement","detach","remove","_jQueryInterface","each","$element","data","_handleDismiss","alertInstance","preventDefault","on","Constructor","noConflict","DATA_API_KEY","Selector","FOCUS_BLUR_DATA_API","Button","toggle","triggerChangeEvent","addAriaPressed","input","type","checked","classList","contains","activeElement","hasAttribute","focus","setAttribute","toggleClass","button","Default","interval","keyboard","slide","pause","wrap","touch","DefaultType","Direction","SLIDE","SLID","KEYDOWN","MOUSEENTER","MOUSELEAVE","TOUCHSTART","TOUCHMOVE","TOUCHEND","POINTERDOWN","POINTERUP","DRAG_START","LOAD_DATA_API","PointerType","TOUCH","PEN","Carousel","_items","_interval","_activeElement","_isPaused","_isSliding","touchTimeout","touchStartX","touchDeltaX","_config","_getConfig","_indicatorsElement","_touchSupported","navigator","maxTouchPoints","_pointerEvent","window","PointerEvent","MSPointerEvent","_addEventListeners","next","_slide","nextWhenVisible","hidden","prev","cycle","clearInterval","setInterval","visibilityState","bind","to","index","activeIndex","_getItemIndex","length","direction","off","_objectSpread","_handleSwipe","absDeltax","abs","_this2","_keydown","_addTouchEventListeners","_this3","start","originalEvent","pointerType","clientX","touches","end","clearTimeout","querySelectorAll","e","add","tagName","which","slice","indexOf","_getItemByDirection","isNextDirection","isPrevDirection","lastItemIndex","itemIndex","_triggerSlideEvent","relatedTarget","eventDirectionName","targetIndex","fromIndex","slideEvent","from","_setActiveIndicatorElement","indicators","nextIndicator","children","addClass","directionalClassName","orderClassName","_this4","activeElementIndex","nextElement","nextElementIndex","isCycling","slidEvent","nextElementInterval","parseInt","defaultInterval","action","TypeError","ride","_dataApiClickHandler","slideIndex","carousels","i","len","$carousel","SHOW","SHOWN","HIDE","HIDDEN","Dimension","Collapse","_isTransitioning","_triggerArray","id","toggleList","elem","filterElement","filter","foundElem","_selector","push","_parent","_getParent","_addAriaAndCollapsedClass","hide","show","actives","activesData","not","startEvent","dimension","_getDimension","style","attr","setTransitioning","scrollSize","getBoundingClientRect","triggerArrayLength","isTransitioning","jquery","_getTargetFromElement","triggerArray","isOpen","$this","currentTarget","$trigger","selectors","$target","REGEXP_KEYDOWN","ARROW_UP_KEYCODE","CLICK","KEYDOWN_DATA_API","KEYUP_DATA_API","AttachmentMap","offset","flip","boundary","reference","display","Dropdown","_popper","_menu","_getMenuElement","_inNavbar","_detectNavbar","disabled","_getParentFromElement","isActive","_clearMenus","showEvent","Popper","referenceElement","_getPopperConfig","body","noop","hideEvent","destroy","update","scheduleUpdate","stopPropagation","constructor","_getPlacement","$parentDropdown","placement","_getOffset","offsets","popperConfig","modifiers","enabled","preventOverflow","boundariesElement","applyStyle","toggles","context","clickEvent","dropdownMenu","_dataApiKeydownHandler","items","backdrop","FOCUSIN","RESIZE","CLICK_DISMISS","KEYDOWN_DISMISS","MOUSEUP_DISMISS","MOUSEDOWN_DISMISS","Modal","_dialog","_backdrop","_isShown","_isBodyOverflowing","_ignoreBackdropClick","_scrolLine truncated
-1
View File
@@ -1 +0,0 @@
(function(window,undefined){var readyList,rootjQuery,core_strundefined=typeof undefined,location=window.location,document=window.document,docElem=document.documentElement,_jQuery=window.jQuery,_$=window.$,class2type={},core_deletedIds=[],core_version="1.10.1",core_concat=core_deletedIds.concat,core_push=core_deletedIds.push,core_slice=core_deletedIds.slice,core_indexOf=core_deletedIds.indexOf,core_toString=class2type.toString,core_hasOwn=class2type.hasOwnProperty,core_trim=core_version.trim,jQuery=function(selector,context){return new jQuery.fn.init(selector,context,rootjQuery)},core_pnum=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,core_rnotwhite=/\S+/g,rtrim=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,rquickExpr=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,rsingleTag=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,rvalidchars=/^[\],:{}\s]*$/,rvalidbraces=/(?:^|:|,)(?:\s*\[)+/g,rvalidescape=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,rvalidtokens=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,rmsPrefix=/^-ms-/,rdashAlpha=/-([\da-z])/gi,fcamelCase=function(all,letter){return letter.toUpperCase()},completed=function(event){if(document.addEventListener||event.type==="load"||document.readyState==="complete"){detach();jQuery.ready()}},detach=function(){if(document.addEventListener){document.removeEventListener("DOMContentLoaded",completed,false);window.removeEventListener("load",completed,false)}else{document.detachEvent("onreadystatechange",completed);window.detachEvent("onload",completed)}};jQuery.fn=jQuery.prototype={jquery:core_version,constructor:jQuery,init:function(selector,context,rootjQuery){var match,elem;if(!selector){return this}if(typeof selector==="string"){if(selector.charAt(0)==="<"&&selector.charAt(selector.length-1)===">"&&selector.length>=3){match=[null,selector,null]}else{match=rquickExpr.exec(selector)}if(match&&(match[1]||!context)){if(match[1]){context=context instanceof jQuery?context[0]:context;jQuery.merge(this,jQuery.parseHTML(match[1],context&&context.nodeType?context.ownerDocument||context:document,true));if(rsingleTag.test(match[1])&&jQuery.isPlainObject(context)){for(match in context){if(jQuery.isFunction(this[match])){this[match](context[match])}else{this.attr(match,context[match])}}}return this}else{elem=document.getElementById(match[2]);if(elem&&elem.parentNode){if(elem.id!==match[2]){return rootjQuery.find(selector)}this.length=1;this[0]=elem}this.context=document;this.selector=selector;return this}}else if(!context||context.jquery){return(context||rootjQuery).find(selector)}else{return this.constructor(context).find(selector)}}else if(selector.nodeType){this.context=this[0]=selector;this.length=1;return this}else if(jQuery.isFunction(selector)){return rootjQuery.ready(selector)}if(selector.selector!==undefined){this.selector=selector.selector;this.context=selector.context}return jQuery.makeArray(selector,this)},selector:"",length:0,toArray:function(){return core_slice.call(this)},get:function(num){return num==null?this.toArray():num<0?this[this.length+num]:this[num]},pushStack:function(elems){var ret=jQuery.merge(this.constructor(),elems);ret.prevObject=this;ret.context=this.context;return ret},each:function(callback,args){return jQuery.each(this,callback,args)},ready:function(fn){jQuery.ready.promise().done(fn);return this},slice:function(){return this.pushStack(core_slice.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(i){var len=this.length,j=+i+(i<0?len:0);return this.pushStack(j>=0&&j<len?[this[j]]:[])},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem)}))},end:function(){return this.prevObject||this.constructor(null)},push:core_push,sort:[].sort,splice:[].splice};jQuery.fn.init.prototype=jQuery.fn;jQuery.extend=jQuery.fn.extend=function(){var src,copyIsArray,copy,name,options,clone,target=arguments[0]||{},i=1,length=arguments.length,deep=false;if(typeof target==="boolean"){deep=target;target=arguments[1]||{};i=2}if(typeof target!=="object"&&!jQuery.isFunction(target)){target={}}if(length===i){target=this;--i}for(;i<length;i++){if((options=arguments[i])!=null){for(name in options){src=target[name];copy=options[name];if(target===copy){continue}if(deep&&copy&&(jQuery.isPlainObject(copy)||(copyIsArray=jQuery.isArray(copy)))){if(copyIsArray){copyIsArray=false;clone=src&&jQuery.isArray(src)?src:[]}else{clone=src&&jQuery.isPlainObject(src)?src:{}}target[name]=jQuery.extend(deep,clone,copy)}else if(copy!==undefined){target[name]=copy}}}}return target};jQuery.extend({expando:"jQuery"+(core_version+Math.random()).replace(/\D/g,""),noConflict:function(deep){if(window.$===jQuery){window.$=_$}if(deep&&window.jQuery===jQuery){window.jQuery=_jQuery}return jQuery},isReady:false,readyWait:1,holdReady:function(hold){if(hold){jQuery.readyWait++}else{jQuery.ready(true)}},ready:function(wait){if(wait===true?--jQuery.readyWait:jQuery.isReady){return}if(!document.body){return setTimeout(jQueryLine truncated
-1
View File
@@ -1 +0,0 @@
{"version":3,"sources":["jquery-1.10.1/jquery-1.10.1.js"],"names":["window","undefined","readyList","rootjQuery","core_strundefined","location","document","docElem","documentElement","_jQuery","jQuery","_$","$","class2type","core_deletedIds","core_version","core_concat","concat","core_push","push","core_slice","slice","core_indexOf","indexOf","core_toString","toString","core_hasOwn","hasOwnProperty","core_trim","trim","selector","context","fn","init","core_pnum","source","core_rnotwhite","rtrim","rquickExpr","rsingleTag","rvalidchars","rvalidbraces","rvalidescape","rvalidtokens","rmsPrefix","rdashAlpha","fcamelCase","all","letter","toUpperCase","completed","event","addEventListener","type","readyState","detach","ready","removeEventListener","detachEvent","prototype","jquery","constructor","match","elem","this","charAt","length","exec","merge","parseHTML","nodeType","ownerDocument","test","isPlainObject","isFunction","attr","getElementById","parentNode","id","find","makeArray","toArray","call","get","num","pushStack","elems","ret","prevObject","each","callback","args","promise","done","apply","arguments","first","eq","last","i","len","j","map","end","sort","splice","extend","src","copyIsArray","copy","name","options","clone","target","deep","isArray","expando","Math","random","replace","noConflict","isReady","readyWait","holdReady","hold","wait","body","setTimeout","resolveWith","trigger","off","obj","Array","isWindow","isNumeric","isNaN","parseFloat","isFinite","String","key","e","support","ownLast","isEmptyObject","error","msg","Error","data","keepScripts","parsed","scripts","createElement","buildFragment","remove","childNodes","parseJSON","JSON","parse","Function","parseXML","xml","tmp","DOMParser","parseFromString","ActiveXObject","async","loadXML","getElementsByTagName","noop","globalEval","execScript","camelCase","string","nodeName","toLowerCase","value","isArraylike","text","arr","results","Object","inArray","max","second","l","grep","inv","retVal","arg","guid","proxy","access","chainable","emptyGet","raw","bulk","now","Date","getTime","swap","old","style","Deferred","attachEvent","top","frameElement","doScroll","doScrollCheck","split","cachedruns","Expr","getText","isXML","compile","outermostContext","sortInput","setDocument","documentIsHTML","rbuggyQSA","rbuggyMatches","matches","contains","preferredDoc","dirruns","classCache","createCache","tokenCache","compilerCache","hasDuplicate","sortOrder","strundefined","MAX_NEGATIVE","hasOwn","pop","push_native","booleans","whitespace","characterEncoding","identifier","attributes","pseudos","RegExp","rcomma","rcombinators","rsibling","rattributeQuotes","rpseudo","ridentifier","matchExpr","ID","CLASS","TAG","ATTR","PSEUDO","CHILD","bool","needsContext","rnative","rinputs","rheader","rescape","runescape","funescape","_","escaped","escapedWhitespace","high","fromCharCode","els","Sizzle","seed","m","groups","nid","newContext","newSelector","getElementsByClassName","qsa","tokenize","getAttribute","setAttribute","toSelector","join","querySelectorAll","qsaError","removeAttribute","select","isNative","keys","cache","cacheLength","shift","markFunction","assert","div","removeChild","addHandle","attrs","handler","current","setHandle","attrHandle","boolHandler","val","getAttributeNode","specified","interpolationHandler","valueHandler","defaultValue","siblingCheck","a","b","cur","diff","sourceIndex","nextSibling","createInputPseudo","createButtonPseudo","createPositionalPseudo","argument","matchIndexes","node","doc","parent","parentWindow","innerHTML","firstChild","className","input","appendChild","createComment","getById","getElementsByName","filter","attrId","tag","matchesSelector","webkitMatchesSelector","mozMatchesSelector","oMatchesSelector","msMatchesSelector","disconnectedMatch","compareDocumentPosition","adown","bup","sortDetached","div1","compare","aup","ap","bp","unshift","expr","elements","uniqueSort","duplicates","detectDuplicates","sortStable","textContent","nodeValue","selectors","createPseudo","relative",">","dir"," ","+","~","preFilter","excess","unquoted","nodeNameSelector","pattern","operator","check","result","what","simple","forward","ofType","outerCache","nodeIndex","start","useCache","lastChild","pseudo","setFilters","idx","matched","not","matcher","unmatched","has","innerText","lang","elemLang","hash","root","focus","activeElement","hasFocus","href","tabIndex","enabled","disabled","checked","selected","selectedIndex","empty","header","button","even","odd","lt","gt","radio","checkbox","file","password","image","submit","reset","parseOnly","tokens","soFar","preFilters","cached","addCombinator","combinator","base","checkNonElements","doneName","dirkey","elementMatcher","matchers","condense","newUnmatched","mapped","setMatcher","postFilter","postFinder","postSelector","temp","preMap","postMap","preexisting","multipleContexts","matcherIn","matcherOut","matcherFromTokens","checkContext","leadingRelative","implicitRelative","matchContext","matchAnyContexLine truncated
-26
View File
@@ -1,26 +0,0 @@
Copyright © 2014-present, Tom Christie. All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-284
View File
@@ -1,284 +0,0 @@
function getSearchTerm() {
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++) {
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == 'q') {
return sParameterName[1];
}
}
}
function applyTopPadding() {
// Update various absolute positions to match where the main container
// starts. This is necessary for handling multi-line nav headers, since
// that pushes the main container down.
var offset = $('body > .container').offset();
$('html').css('scroll-padding-top', offset.top + 'px');
$('.bs-sidebar.affix').css('top', offset.top + 'px');
}
$(document).ready(function() {
applyTopPadding();
var search_term = getSearchTerm(),
// $keyboard_modal = $('#mkdocs_keyboard_modal'),
$search_modal = $('#mkdocs_search_modal');
if (search_term) {
$search_modal.modal();
}
// make sure search input gets autofocus every time modal opens.
$search_modal.on('shown.bs.modal', function() {
$search_modal.find('#mkdocs-search-query').focus();
});
// Close search modal when result is selected
// The links get added later so listen to parent
$('#mkdocs-search-results').click(function(e) {
if ($(e.target).is('a')) {
$search_modal.modal('hide');
}
});
// Populate keyboard modal with proper Keys
// $keyboard_modal.find('.help.shortcut kbd')[0].innerHTML = keyCodes[shortcuts.help];
// $keyboard_modal.find('.prev.shortcut kbd')[0].innerHTML = keyCodes[shortcuts.previous];
// $keyboard_modal.find('.next.shortcut kbd')[0].innerHTML = keyCodes[shortcuts.next];
// $keyboard_modal.find('.search.shortcut kbd')[0].innerHTML = keyCodes[shortcuts.search];
// Keyboard navigation
document.addEventListener("keydown", function(e) {
if ($(e.target).is(':input')) return true;
var key = e.which || e.keyCode || window.event && window.event.keyCode;
var page;
switch (key) {
case shortcuts.next:
page = $('.navbar a[rel="next"]:first').prop('href');
break;
case shortcuts.previous:
page = $('.navbar a[rel="prev"]:first').prop('href');
break;
case shortcuts.search:
e.preventDefault();
// $keyboard_modal.modal('hide');
$search_modal.modal('show');
$search_modal.find('#mkdocs-search-query').focus();
break;
case shortcuts.help:
$search_modal.modal('hide');
// $keyboard_modal.modal('show');
break;
default:
break;
}
if (page) {
// $keyboard_modal.modal('hide');
window.location.href = page;
}
});
$('table').addClass('table table-striped table-hover');
// Improve the scrollspy behaviour when users click on a TOC item.
$(".bs-sidenav a").on("click", function() {
var clicked = this;
setTimeout(function() {
var active = $('.nav li.active a');
active = active[active.length - 1];
if (clicked !== active) {
$(active).parent().removeClass("active");
$(clicked).parent().addClass("active");
}
}, 50);
});
function showInnerDropdown(item) {
var popup = $(item).next('.dropdown-menu');
popup.addClass('show');
$(item).addClass('open');
// First, close any sibling dropdowns.
var container = $(item).parent().parent();
container.find('> .dropdown-submenu > a').each(function(i, el) {
if (el !== item) {
hideInnerDropdown(el);
}
});
var popupMargin = 10;
var maxBottom = $(window).height() - popupMargin;
var bounds = item.getBoundingClientRect();
popup.css('left', bounds.right + 'px');
if (bounds.top + popup.height() > maxBottom &&
bounds.top > $(window).height() / 2) {
popup.css({
'top': (bounds.bottom - popup.height()) + 'px',
'max-height': (bounds.bottom - popupMargin) + 'px',
});
} else {
popup.css({
'top': bounds.top + 'px',
'max-height': (maxBottom - bounds.top) + 'px',
});
}
}
function hideInnerDropdown(item) {
var popup = $(item).next('.dropdown-menu');
popup.removeClass('show');
$(item).removeClass('open');
popup.scrollTop(0);
popup.find('.dropdown-menu').scrollTop(0).removeClass('show');
popup.find('.dropdown-submenu > a').removeClass('open');
}
$('.dropdown-submenu > a').on('click', function(e) {
if ($(this).next('.dropdown-menu').hasClass('show')) {
hideInnerDropdown(this);
} else {
showInnerDropdown(this);
}
e.stopPropagation();
e.preventDefault();
});
$('.dropdown-menu').parent().on('hide.bs.dropdown', function(e) {
$(this).find('.dropdown-menu').scrollTop(0);
$(this).find('.dropdown-submenu > a').removeClass('open');
$(this).find('.dropdown-menu .dropdown-menu').removeClass('show');
});
});
$(window).on('resize', applyTopPadding);
$('body').scrollspy({
target: '.bs-sidebar',
offset: 100
});
/* Prevent disabled links from causing a page reload */
$("li.disabled a").click(function() {
event.preventDefault();
});
// See https://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes
// We only list common keys below. Obscure keys are omitted and their use is discouraged.
var keyCodes = {
8: 'backspace',
9: 'tab',
13: 'enter',
16: 'shift',
17: 'ctrl',
18: 'alt',
19: 'pause/break',
20: 'caps lock',
27: 'escape',
32: 'spacebar',
33: 'page up',
34: 'page down',
35: 'end',
36: 'home',
37: '&larr;',
38: '&uarr;',
39: '&rarr;',
40: '&darr;',
45: 'insert',
46: 'delete',
48: '0',
49: '1',
50: '2',
51: '3',
52: '4',
53: '5',
54: '6',
55: '7',
56: '8',
57: '9',
65: 'a',
66: 'b',
67: 'c',
68: 'd',
69: 'e',
70: 'f',
71: 'g',
72: 'h',
73: 'i',
74: 'j',
75: 'k',
76: 'l',
77: 'm',
78: 'n',
79: 'o',
80: 'p',
81: 'q',
82: 'r',
83: 's',
84: 't',
85: 'u',
86: 'v',
87: 'w',
88: 'x',
89: 'y',
90: 'z',
91: 'Left Windows Key / Left ⌘',
92: 'Right Windows Key',
93: 'Windows Menu / Right ⌘',
96: 'numpad 0',
97: 'numpad 1',
98: 'numpad 2',
99: 'numpad 3',
100: 'numpad 4',
101: 'numpad 5',
102: 'numpad 6',
103: 'numpad 7',
104: 'numpad 8',
105: 'numpad 9',
106: 'multiply',
107: 'add',
109: 'subtract',
110: 'decimal point',
111: 'divide',
112: 'f1',
113: 'f2',
114: 'f3',
115: 'f4',
116: 'f5',
117: 'f6',
118: 'f7',
119: 'f8',
120: 'f9',
121: 'f10',
122: 'f11',
123: 'f12',
124: 'f13',
125: 'f14',
126: 'f15',
127: 'f16',
128: 'f17',
129: 'f18',
130: 'f19',
131: 'f20',
132: 'f21',
133: 'f22',
134: 'f23',
135: 'f24',
144: 'num lock',
145: 'scroll lock',
186: '&semi;',
187: '&equals;',
188: '&comma;',
189: '&hyphen;',
190: '&period;',
191: '&quest;',
192: '&grave;',
219: '&lsqb;',
220: '&bsol;',
221: '&rsqb;',
222: '&apos;',
};
File diff suppressed because it is too large. Load diff
+46
View File
@@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
+69
View File
@@ -0,0 +1,69 @@
#include "ed_25519.h"
#include "ge.h"
#include "sc.h"
#include "sha512.h"
/* see http://crypto.stackexchange.com/a/6215/4697 */
void ed25519_add_scalar(unsigned char *public_key, unsigned char *private_key, const unsigned char *scalar) {
const unsigned char SC_1[32] = {1}; /* scalar with value 1 */
unsigned char n[32];
ge_p3 nB;
ge_p1p1 A_p1p1;
ge_p3 A;
ge_p3 public_key_unpacked;
ge_cached T;
sha512_context hash;
unsigned char hashbuf[64];
int i;
/* copy the scalar and clear highest bit */
for (i = 0; i < 31; ++i) {
n[i] = scalar[i];
}
n[31] = scalar[31] & 127;
/* private key: a = n + t */
if (private_key) {
sc_muladd(private_key, SC_1, n, private_key);
// https://github.com/orlp/ed25519/issues/3
sha512_init(&hash);
sha512_update(&hash, private_key + 32, 32);
sha512_update(&hash, scalar, 32);
sha512_final(&hash, hashbuf);
for (i = 0; i < 32; ++i) {
private_key[32 + i] = hashbuf[i];
}
}
/* public key: A = nB + T */
if (public_key) {
/* if we know the private key we don't need a point addition, which is faster */
/* using a "timing attack" you could find out wether or not we know the private
key, but this information seems rather useless - if this is important pass
public_key and private_key seperately in 2 function calls */
if (private_key) {
ge_scalarmult_base(&A, private_key);
} else {
/* unpack public key into T */
ge_frombytes_negate_vartime(&public_key_unpacked, public_key);
fe_neg(public_key_unpacked.X, public_key_unpacked.X); /* undo negate */
fe_neg(public_key_unpacked.T, public_key_unpacked.T); /* undo negate */
ge_p3_to_cached(&T, &public_key_unpacked);
/* calculate n*B */
ge_scalarmult_base(&nB, n);
/* A = n*B + T */
ge_add(&A_p1p1, &nB, &T);
ge_p1p1_to_p3(&A, &A_p1p1);
}
/* pack public key */
ge_p3_tobytes(public_key, &A);
}
}
+41
View File
@@ -0,0 +1,41 @@
#ifndef ED25519_H
#define ED25519_H
// Nightcracker's Ed25519 - https://github.com/orlp/ed25519
#include <stddef.h>
#if defined(_WIN32)
#if defined(ED25519_BUILD_DLL)
#define ED25519_DECLSPEC __declspec(dllexport)
#elif defined(ED25519_DLL)
#define ED25519_DECLSPEC __declspec(dllimport)
#else
#define ED25519_DECLSPEC
#endif
#else
#define ED25519_DECLSPEC
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef ED25519_NO_SEED
int ED25519_DECLSPEC ed25519_create_seed(unsigned char *seed);
#endif
void ED25519_DECLSPEC ed25519_create_keypair(unsigned char *public_key, unsigned char *private_key, const unsigned char *seed);
void ED25519_DECLSPEC ed25519_derive_pub(unsigned char *public_key, const unsigned char *private_key);
void ED25519_DECLSPEC ed25519_sign(unsigned char *signature, const unsigned char *message, size_t message_len, const unsigned char *public_key, const unsigned char *private_key);
int ED25519_DECLSPEC ed25519_verify(const unsigned char *signature, const unsigned char *message, size_t message_len, const unsigned char *public_key);
void ED25519_DECLSPEC ed25519_add_scalar(unsigned char *public_key, unsigned char *private_key, const unsigned char *scalar);
void ED25519_DECLSPEC ed25519_key_exchange(unsigned char *shared_secret, const unsigned char *public_key, const unsigned char *private_key);
#ifdef __cplusplus
}
#endif
#endif
+1491
View File
File diff suppressed because it is too large. Load diff
+41
View File
@@ -0,0 +1,41 @@
#ifndef FE_H
#define FE_H
#include "fixedint.h"
/*
fe means field element.
Here the field is \Z/(2^255-19).
An element t, entries t[0]...t[9], represents the integer
t[0]+2^26 t[1]+2^51 t[2]+2^77 t[3]+2^102 t[4]+...+2^230 t[9].
Bounds on each t[i] vary depending on context.
*/
typedef int32_t fe[10];
void fe_0(fe h);
void fe_1(fe h);
void fe_frombytes(fe h, const unsigned char *s);
void fe_tobytes(unsigned char *s, const fe h);
void fe_copy(fe h, const fe f);
int fe_isnegative(const fe f);
int fe_isnonzero(const fe f);
void fe_cmov(fe f, const fe g, unsigned int b);
void fe_cswap(fe f, fe g, unsigned int b);
void fe_neg(fe h, const fe f);
void fe_add(fe h, const fe f, const fe g);
void fe_invert(fe out, const fe z);
void fe_sq(fe h, const fe f);
void fe_sq2(fe h, const fe f);
void fe_mul(fe h, const fe f, const fe g);
void fe_mul121666(fe h, fe f);
void fe_pow22523(fe out, const fe z);
void fe_sub(fe h, const fe f, const fe g);
#endif
+72
View File
@@ -0,0 +1,72 @@
/*
Portable header to provide the 32 and 64 bits type.
Not a compatible replacement for <stdint.h>, do not blindly use it as such.
*/
#if ((defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined(__WATCOMC__) && (defined(_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_) || defined(__UINT_FAST64_TYPE__)) )) && !defined(FIXEDINT_H_INCLUDED)
#include <stdint.h>
#define FIXEDINT_H_INCLUDED
#if defined(__WATCOMC__) && __WATCOMC__ >= 1250 && !defined(UINT64_C)
#include <limits.h>
#define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX))
#endif
#endif
#ifndef FIXEDINT_H_INCLUDED
#define FIXEDINT_H_INCLUDED
#include <limits.h>
/* (u)int32_t */
#ifndef uint32_t
#if (ULONG_MAX == 0xffffffffUL)
typedef unsigned long uint32_t;
#elif (UINT_MAX == 0xffffffffUL)
typedef unsigned int uint32_t;
#elif (USHRT_MAX == 0xffffffffUL)
typedef unsigned short uint32_t;
#endif
#endif
#ifndef int32_t
#if (LONG_MAX == 0x7fffffffL)
typedef signed long int32_t;
#elif (INT_MAX == 0x7fffffffL)
typedef signed int int32_t;
#elif (SHRT_MAX == 0x7fffffffL)
typedef signed short int32_t;
#endif
#endif
/* (u)int64_t */
#if (defined(__STDC__) && defined(__STDC_VERSION__) && __STDC__ && __STDC_VERSION__ >= 199901L)
typedef long long int64_t;
typedef unsigned long long uint64_t;
#define UINT64_C(v) v ##ULL
#define INT64_C(v) v ##LL
#elif defined(__GNUC__)
__extension__ typedef long long int64_t;
__extension__ typedef unsigned long long uint64_t;
#define UINT64_C(v) v ##ULL
#define INT64_C(v) v ##LL
#elif defined(__MWERKS__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) || defined(__APPLE_CC__) || defined(_LONG_LONG) || defined(_CRAYC)
typedef long long int64_t;
typedef unsigned long long uint64_t;
#define UINT64_C(v) v ##ULL
#define INT64_C(v) v ##LL
#elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined(__BORLANDC__) && __BORLANDC__ > 0x460) || defined(__alpha) || defined(__DECC)
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#define UINT64_C(v) v ##UI64
#define INT64_C(v) v ##I64
#endif
#endif
+467
View File
@@ -0,0 +1,467 @@
#include "ge.h"
#include "precomp_data.h"
/*
r = p + q
*/
void ge_add(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q) {
fe t0;
fe_add(r->X, p->Y, p->X);
fe_sub(r->Y, p->Y, p->X);
fe_mul(r->Z, r->X, q->YplusX);
fe_mul(r->Y, r->Y, q->YminusX);
fe_mul(r->T, q->T2d, p->T);
fe_mul(r->X, p->Z, q->Z);
fe_add(t0, r->X, r->X);
fe_sub(r->X, r->Z, r->Y);
fe_add(r->Y, r->Z, r->Y);
fe_add(r->Z, t0, r->T);
fe_sub(r->T, t0, r->T);
}
static void slide(signed char *r, const unsigned char *a) {
int i;
int b;
int k;
for (i = 0; i < 256; ++i) {
r[i] = 1 & (a[i >> 3] >> (i & 7));
}
for (i = 0; i < 256; ++i)
if (r[i]) {
for (b = 1; b <= 6 && i + b < 256; ++b) {
if (r[i + b]) {
if (r[i] + (r[i + b] << b) <= 15) {
r[i] += r[i + b] << b;
r[i + b] = 0;
} else if (r[i] - (r[i + b] << b) >= -15) {
r[i] -= r[i + b] << b;
for (k = i + b; k < 256; ++k) {
if (!r[k]) {
r[k] = 1;
break;
}
r[k] = 0;
}
} else {
break;
}
}
}
}
}
/*
r = a * A + b * B
where a = a[0]+256*a[1]+...+256^31 a[31].
and b = b[0]+256*b[1]+...+256^31 b[31].
B is the Ed25519 base point (x,4/5) with x positive.
*/
void ge_double_scalarmult_vartime(ge_p2 *r, const unsigned char *a, const ge_p3 *A, const unsigned char *b) {
signed char aslide[256];
signed char bslide[256];
ge_cached Ai[8]; /* A,3A,5A,7A,9A,11A,13A,15A */
ge_p1p1 t;
ge_p3 u;
ge_p3 A2;
int i;
slide(aslide, a);
slide(bslide, b);
ge_p3_to_cached(&Ai[0], A);
ge_p3_dbl(&t, A);
ge_p1p1_to_p3(&A2, &t);
ge_add(&t, &A2, &Ai[0]);
ge_p1p1_to_p3(&u, &t);
ge_p3_to_cached(&Ai[1], &u);
ge_add(&t, &A2, &Ai[1]);
ge_p1p1_to_p3(&u, &t);
ge_p3_to_cached(&Ai[2], &u);
ge_add(&t, &A2, &Ai[2]);
ge_p1p1_to_p3(&u, &t);
ge_p3_to_cached(&Ai[3], &u);
ge_add(&t, &A2, &Ai[3]);
ge_p1p1_to_p3(&u, &t);
ge_p3_to_cached(&Ai[4], &u);
ge_add(&t, &A2, &Ai[4]);
ge_p1p1_to_p3(&u, &t);
ge_p3_to_cached(&Ai[5], &u);
ge_add(&t, &A2, &Ai[5]);
ge_p1p1_to_p3(&u, &t);
ge_p3_to_cached(&Ai[6], &u);
ge_add(&t, &A2, &Ai[6]);
ge_p1p1_to_p3(&u, &t);
ge_p3_to_cached(&Ai[7], &u);
ge_p2_0(r);
for (i = 255; i >= 0; --i) {
if (aslide[i] || bslide[i]) {
break;
}
}
for (; i >= 0; --i) {
ge_p2_dbl(&t, r);
if (aslide[i] > 0) {
ge_p1p1_to_p3(&u, &t);
ge_add(&t, &u, &Ai[aslide[i] / 2]);
} else if (aslide[i] < 0) {
ge_p1p1_to_p3(&u, &t);
ge_sub(&t, &u, &Ai[(-aslide[i]) / 2]);
}
if (bslide[i] > 0) {
ge_p1p1_to_p3(&u, &t);
ge_madd(&t, &u, &Bi[bslide[i] / 2]);
} else if (bslide[i] < 0) {
ge_p1p1_to_p3(&u, &t);
ge_msub(&t, &u, &Bi[(-bslide[i]) / 2]);
}
ge_p1p1_to_p2(r, &t);
}
}
static const fe d = {
-10913610, 13857413, -15372611, 6949391, 114729, -8787816, -6275908, -3247719, -18696448, -12055116
};
static const fe sqrtm1 = {
-32595792, -7943725, 9377950, 3500415, 12389472, -272473, -25146209, -2005654, 326686, 11406482
};
int ge_frombytes_negate_vartime(ge_p3 *h, const unsigned char *s) {
fe u;
fe v;
fe v3;
fe vxx;
fe check;
fe_frombytes(h->Y, s);
fe_1(h->Z);
fe_sq(u, h->Y);
fe_mul(v, u, d);
fe_sub(u, u, h->Z); /* u = y^2-1 */
fe_add(v, v, h->Z); /* v = dy^2+1 */
fe_sq(v3, v);
fe_mul(v3, v3, v); /* v3 = v^3 */
fe_sq(h->X, v3);
fe_mul(h->X, h->X, v);
fe_mul(h->X, h->X, u); /* x = uv^7 */
fe_pow22523(h->X, h->X); /* x = (uv^7)^((q-5)/8) */
fe_mul(h->X, h->X, v3);
fe_mul(h->X, h->X, u); /* x = uv^3(uv^7)^((q-5)/8) */
fe_sq(vxx, h->X);
fe_mul(vxx, vxx, v);
fe_sub(check, vxx, u); /* vx^2-u */
if (fe_isnonzero(check)) {
fe_add(check, vxx, u); /* vx^2+u */
if (fe_isnonzero(check)) {
return -1;
}
fe_mul(h->X, h->X, sqrtm1);
}
if (fe_isnegative(h->X) == (s[31] >> 7)) {
fe_neg(h->X, h->X);
}
fe_mul(h->T, h->X, h->Y);
return 0;
}
/*
r = p + q
*/
void ge_madd(ge_p1p1 *r, const ge_p3 *p, const ge_precomp *q) {
fe t0;
fe_add(r->X, p->Y, p->X);
fe_sub(r->Y, p->Y, p->X);
fe_mul(r->Z, r->X, q->yplusx);
fe_mul(r->Y, r->Y, q->yminusx);
fe_mul(r->T, q->xy2d, p->T);
fe_add(t0, p->Z, p->Z);
fe_sub(r->X, r->Z, r->Y);
fe_add(r->Y, r->Z, r->Y);
fe_add(r->Z, t0, r->T);
fe_sub(r->T, t0, r->T);
}
/*
r = p - q
*/
void ge_msub(ge_p1p1 *r, const ge_p3 *p, const ge_precomp *q) {
fe t0;
fe_add(r->X, p->Y, p->X);
fe_sub(r->Y, p->Y, p->X);
fe_mul(r->Z, r->X, q->yminusx);
fe_mul(r->Y, r->Y, q->yplusx);
fe_mul(r->T, q->xy2d, p->T);
fe_add(t0, p->Z, p->Z);
fe_sub(r->X, r->Z, r->Y);
fe_add(r->Y, r->Z, r->Y);
fe_sub(r->Z, t0, r->T);
fe_add(r->T, t0, r->T);
}
/*
r = p
*/
void ge_p1p1_to_p2(ge_p2 *r, const ge_p1p1 *p) {
fe_mul(r->X, p->X, p->T);
fe_mul(r->Y, p->Y, p->Z);
fe_mul(r->Z, p->Z, p->T);
}
/*
r = p
*/
void ge_p1p1_to_p3(ge_p3 *r, const ge_p1p1 *p) {
fe_mul(r->X, p->X, p->T);
fe_mul(r->Y, p->Y, p->Z);
fe_mul(r->Z, p->Z, p->T);
fe_mul(r->T, p->X, p->Y);
}
void ge_p2_0(ge_p2 *h) {
fe_0(h->X);
fe_1(h->Y);
fe_1(h->Z);
}
/*
r = 2 * p
*/
void ge_p2_dbl(ge_p1p1 *r, const ge_p2 *p) {
fe t0;
fe_sq(r->X, p->X);
fe_sq(r->Z, p->Y);
fe_sq2(r->T, p->Z);
fe_add(r->Y, p->X, p->Y);
fe_sq(t0, r->Y);
fe_add(r->Y, r->Z, r->X);
fe_sub(r->Z, r->Z, r->X);
fe_sub(r->X, t0, r->Y);
fe_sub(r->T, r->T, r->Z);
}
void ge_p3_0(ge_p3 *h) {
fe_0(h->X);
fe_1(h->Y);
fe_1(h->Z);
fe_0(h->T);
}
/*
r = 2 * p
*/
void ge_p3_dbl(ge_p1p1 *r, const ge_p3 *p) {
ge_p2 q;
ge_p3_to_p2(&q, p);
ge_p2_dbl(r, &q);
}
/*
r = p
*/
static const fe d2 = {
-21827239, -5839606, -30745221, 13898782, 229458, 15978800, -12551817, -6495438, 29715968, 9444199
};
void ge_p3_to_cached(ge_cached *r, const ge_p3 *p) {
fe_add(r->YplusX, p->Y, p->X);
fe_sub(r->YminusX, p->Y, p->X);
fe_copy(r->Z, p->Z);
fe_mul(r->T2d, p->T, d2);
}
/*
r = p
*/
void ge_p3_to_p2(ge_p2 *r, const ge_p3 *p) {
fe_copy(r->X, p->X);
fe_copy(r->Y, p->Y);
fe_copy(r->Z, p->Z);
}
void ge_p3_tobytes(unsigned char *s, const ge_p3 *h) {
fe recip;
fe x;
fe y;
fe_invert(recip, h->Z);
fe_mul(x, h->X, recip);
fe_mul(y, h->Y, recip);
fe_tobytes(s, y);
s[31] ^= fe_isnegative(x) << 7;
}
static unsigned char equal(signed char b, signed char c) {
unsigned char ub = b;
unsigned char uc = c;
unsigned char x = ub ^ uc; /* 0: yes; 1..255: no */
uint64_t y = x; /* 0: yes; 1..255: no */
y -= 1; /* large: yes; 0..254: no */
y >>= 63; /* 1: yes; 0: no */
return (unsigned char) y;
}
static unsigned char negative(signed char b) {
uint64_t x = b; /* 18446744073709551361..18446744073709551615: yes; 0..255: no */
x >>= 63; /* 1: yes; 0: no */
return (unsigned char) x;
}
static void cmov(ge_precomp *t, const ge_precomp *u, unsigned char b) {
fe_cmov(t->yplusx, u->yplusx, b);
fe_cmov(t->yminusx, u->yminusx, b);
fe_cmov(t->xy2d, u->xy2d, b);
}
static void select(ge_precomp *t, int pos, signed char b) {
ge_precomp minust;
unsigned char bnegative = negative(b);
unsigned char babs = b - (((-bnegative) & b) << 1);
fe_1(t->yplusx);
fe_1(t->yminusx);
fe_0(t->xy2d);
cmov(t, &base[pos][0], equal(babs, 1));
cmov(t, &base[pos][1], equal(babs, 2));
cmov(t, &base[pos][2], equal(babs, 3));
cmov(t, &base[pos][3], equal(babs, 4));
cmov(t, &base[pos][4], equal(babs, 5));
cmov(t, &base[pos][5], equal(babs, 6));
cmov(t, &base[pos][6], equal(babs, 7));
cmov(t, &base[pos][7], equal(babs, 8));
fe_copy(minust.yplusx, t->yminusx);
fe_copy(minust.yminusx, t->yplusx);
fe_neg(minust.xy2d, t->xy2d);
cmov(t, &minust, bnegative);
}
/*
h = a * B
where a = a[0]+256*a[1]+...+256^31 a[31]
B is the Ed25519 base point (x,4/5) with x positive.
Preconditions:
a[31] <= 127
*/
void ge_scalarmult_base(ge_p3 *h, const unsigned char *a) {
signed char e[64];
signed char carry;
ge_p1p1 r;
ge_p2 s;
ge_precomp t;
int i;
for (i = 0; i < 32; ++i) {
e[2 * i + 0] = (a[i] >> 0) & 15;
e[2 * i + 1] = (a[i] >> 4) & 15;
}
/* each e[i] is between 0 and 15 */
/* e[63] is between 0 and 7 */
carry = 0;
for (i = 0; i < 63; ++i) {
e[i] += carry;
carry = e[i] + 8;
carry >>= 4;
e[i] -= carry << 4;
}
e[63] += carry;
/* each e[i] is between -8 and 8 */
ge_p3_0(h);
for (i = 1; i < 64; i += 2) {
select(&t, i / 2, e[i]);
ge_madd(&r, h, &t);
ge_p1p1_to_p3(h, &r);
}
ge_p3_dbl(&r, h);
ge_p1p1_to_p2(&s, &r);
ge_p2_dbl(&r, &s);
ge_p1p1_to_p2(&s, &r);
ge_p2_dbl(&r, &s);
ge_p1p1_to_p2(&s, &r);
ge_p2_dbl(&r, &s);
ge_p1p1_to_p3(h, &r);
for (i = 0; i < 64; i += 2) {
select(&t, i / 2, e[i]);
ge_madd(&r, h, &t);
ge_p1p1_to_p3(h, &r);
}
}
/*
r = p - q
*/
void ge_sub(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q) {
fe t0;
fe_add(r->X, p->Y, p->X);
fe_sub(r->Y, p->Y, p->X);
fe_mul(r->Z, r->X, q->YminusX);
fe_mul(r->Y, r->Y, q->YplusX);
fe_mul(r->T, q->T2d, p->T);
fe_mul(r->X, p->Z, q->Z);
fe_add(t0, r->X, r->X);
fe_sub(r->X, r->Z, r->Y);
fe_add(r->Y, r->Z, r->Y);
fe_sub(r->Z, t0, r->T);
fe_add(r->T, t0, r->T);
}
void ge_tobytes(unsigned char *s, const ge_p2 *h) {
fe recip;
fe x;
fe y;
fe_invert(recip, h->Z);
fe_mul(x, h->X, recip);
fe_mul(y, h->Y, recip);
fe_tobytes(s, y);
s[31] ^= fe_isnegative(x) << 7;
}
+74
View File
@@ -0,0 +1,74 @@
#ifndef GE_H
#define GE_H
#include "fe.h"
/*
ge means group element.
Here the group is the set of pairs (x,y) of field elements (see fe.h)
satisfying -x^2 + y^2 = 1 + d x^2y^2
where d = -121665/121666.
Representations:
ge_p2 (projective): (X:Y:Z) satisfying x=X/Z, y=Y/Z
ge_p3 (extended): (X:Y:Z:T) satisfying x=X/Z, y=Y/Z, XY=ZT
ge_p1p1 (completed): ((X:Z),(Y:T)) satisfying x=X/Z, y=Y/T
ge_precomp (Duif): (y+x,y-x,2dxy)
*/
typedef struct {
fe X;
fe Y;
fe Z;
} ge_p2;
typedef struct {
fe X;
fe Y;
fe Z;
fe T;
} ge_p3;
typedef struct {
fe X;
fe Y;
fe Z;
fe T;
} ge_p1p1;
typedef struct {
fe yplusx;
fe yminusx;
fe xy2d;
} ge_precomp;
typedef struct {
fe YplusX;
fe YminusX;
fe Z;
fe T2d;
} ge_cached;
void ge_p3_tobytes(unsigned char *s, const ge_p3 *h);
void ge_tobytes(unsigned char *s, const ge_p2 *h);
int ge_frombytes_negate_vartime(ge_p3 *h, const unsigned char *s);
void ge_add(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q);
void ge_sub(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q);
void ge_double_scalarmult_vartime(ge_p2 *r, const unsigned char *a, const ge_p3 *A, const unsigned char *b);
void ge_madd(ge_p1p1 *r, const ge_p3 *p, const ge_precomp *q);
void ge_msub(ge_p1p1 *r, const ge_p3 *p, const ge_precomp *q);
void ge_scalarmult_base(ge_p3 *h, const unsigned char *a);
void ge_p1p1_to_p2(ge_p2 *r, const ge_p1p1 *p);
void ge_p1p1_to_p3(ge_p3 *r, const ge_p1p1 *p);
void ge_p2_0(ge_p2 *h);
void ge_p2_dbl(ge_p1p1 *r, const ge_p2 *p);
void ge_p3_0(ge_p3 *h);
void ge_p3_dbl(ge_p1p1 *r, const ge_p3 *p);
void ge_p3_to_cached(ge_cached *r, const ge_p3 *p);
void ge_p3_to_p2(ge_p2 *r, const ge_p3 *p);
#endif
+79
View File
@@ -0,0 +1,79 @@
#include "ed_25519.h"
#include "fe.h"
void ed25519_key_exchange(unsigned char *shared_secret, const unsigned char *public_key, const unsigned char *private_key) {
unsigned char e[32];
unsigned int i;
fe x1;
fe x2;
fe z2;
fe x3;
fe z3;
fe tmp0;
fe tmp1;
int pos;
unsigned int swap;
unsigned int b;
/* copy the private key and make sure it's valid */
for (i = 0; i < 32; ++i) {
e[i] = private_key[i];
}
e[0] &= 248;
e[31] &= 63;
e[31] |= 64;
/* unpack the public key and convert edwards to montgomery */
/* due to CodesInChaos: montgomeryX = (edwardsY + 1)*inverse(1 - edwardsY) mod p */
fe_frombytes(x1, public_key);
fe_1(tmp1);
fe_add(tmp0, x1, tmp1);
fe_sub(tmp1, tmp1, x1);
fe_invert(tmp1, tmp1);
fe_mul(x1, tmp0, tmp1);
fe_1(x2);
fe_0(z2);
fe_copy(x3, x1);
fe_1(z3);
swap = 0;
for (pos = 254; pos >= 0; --pos) {
b = e[pos / 8] >> (pos & 7);
b &= 1;
swap ^= b;
fe_cswap(x2, x3, swap);
fe_cswap(z2, z3, swap);
swap = b;
/* from montgomery.h */
fe_sub(tmp0, x3, z3);
fe_sub(tmp1, x2, z2);
fe_add(x2, x2, z2);
fe_add(z2, x3, z3);
fe_mul(z3, tmp0, x2);
fe_mul(z2, z2, tmp1);
fe_sq(tmp0, tmp1);
fe_sq(tmp1, x2);
fe_add(x3, z3, z2);
fe_sub(z2, z3, z2);
fe_mul(x2, tmp1, tmp0);
fe_sub(tmp1, tmp1, tmp0);
fe_sq(z2, z2);
fe_mul121666(z3, tmp1);
fe_sq(x3, x3);
fe_add(tmp0, tmp0, z3);
fe_mul(z3, x1, z2);
fe_mul(z2, tmp1, tmp0);
}
fe_cswap(x2, x3, swap);
fe_cswap(z2, z3, swap);
fe_invert(z2, z2);
fe_mul(x2, x2, z2);
fe_tobytes(shared_secret, x2);
}
+23
View File
@@ -0,0 +1,23 @@
#include "ed_25519.h"
#include "sha512.h"
#include "ge.h"
void ed25519_create_keypair(unsigned char *public_key, unsigned char *private_key, const unsigned char *seed) {
ge_p3 A;
sha512(seed, 32, private_key);
private_key[0] &= 248;
private_key[31] &= 63;
private_key[31] |= 64;
ge_scalarmult_base(&A, private_key);
ge_p3_tobytes(public_key, &A);
}
void ed25519_derive_pub(unsigned char *public_key, const unsigned char *private_key) {
ge_p3 A;
ge_scalarmult_base(&A, private_key);
ge_p3_tobytes(public_key, &A);
}
+16
View File
@@ -0,0 +1,16 @@
Copyright (c) 2015 Orson Peters <orsonpeters@gmail.com>
This software is provided 'as-is', without any express or implied warranty. In no event will the
authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the
original software. If you use this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as
being the original software.
3. This notice may not be removed or altered from any source distribution.
File diff suppressed because it is too large. Load diff
+809
View File
@@ -0,0 +1,809 @@
#include "fixedint.h"
#include "sc.h"
static uint64_t load_3(const unsigned char *in) {
uint64_t result;
result = (uint64_t) in[0];
result |= ((uint64_t) in[1]) << 8;
result |= ((uint64_t) in[2]) << 16;
return result;
}
static uint64_t load_4(const unsigned char *in) {
uint64_t result;
result = (uint64_t) in[0];
result |= ((uint64_t) in[1]) << 8;
result |= ((uint64_t) in[2]) << 16;
result |= ((uint64_t) in[3]) << 24;
return result;
}
/*
Input:
s[0]+256*s[1]+...+256^63*s[63] = s
Output:
s[0]+256*s[1]+...+256^31*s[31] = s mod l
where l = 2^252 + 27742317777372353535851937790883648493.
Overwrites s in place.
*/
void sc_reduce(unsigned char *s) {
int64_t s0 = 2097151 & load_3(s);
int64_t s1 = 2097151 & (load_4(s + 2) >> 5);
int64_t s2 = 2097151 & (load_3(s + 5) >> 2);
int64_t s3 = 2097151 & (load_4(s + 7) >> 7);
int64_t s4 = 2097151 & (load_4(s + 10) >> 4);
int64_t s5 = 2097151 & (load_3(s + 13) >> 1);
int64_t s6 = 2097151 & (load_4(s + 15) >> 6);
int64_t s7 = 2097151 & (load_3(s + 18) >> 3);
int64_t s8 = 2097151 & load_3(s + 21);
int64_t s9 = 2097151 & (load_4(s + 23) >> 5);
int64_t s10 = 2097151 & (load_3(s + 26) >> 2);
int64_t s11 = 2097151 & (load_4(s + 28) >> 7);
int64_t s12 = 2097151 & (load_4(s + 31) >> 4);
int64_t s13 = 2097151 & (load_3(s + 34) >> 1);
int64_t s14 = 2097151 & (load_4(s + 36) >> 6);
int64_t s15 = 2097151 & (load_3(s + 39) >> 3);
int64_t s16 = 2097151 & load_3(s + 42);
int64_t s17 = 2097151 & (load_4(s + 44) >> 5);
int64_t s18 = 2097151 & (load_3(s + 47) >> 2);
int64_t s19 = 2097151 & (load_4(s + 49) >> 7);
int64_t s20 = 2097151 & (load_4(s + 52) >> 4);
int64_t s21 = 2097151 & (load_3(s + 55) >> 1);
int64_t s22 = 2097151 & (load_4(s + 57) >> 6);
int64_t s23 = (load_4(s + 60) >> 3);
int64_t carry0;
int64_t carry1;
int64_t carry2;
int64_t carry3;
int64_t carry4;
int64_t carry5;
int64_t carry6;
int64_t carry7;
int64_t carry8;
int64_t carry9;
int64_t carry10;
int64_t carry11;
int64_t carry12;
int64_t carry13;
int64_t carry14;
int64_t carry15;
int64_t carry16;
s11 += s23 * 666643;
s12 += s23 * 470296;
s13 += s23 * 654183;
s14 -= s23 * 997805;
s15 += s23 * 136657;
s16 -= s23 * 683901;
s23 = 0;
s10 += s22 * 666643;
s11 += s22 * 470296;
s12 += s22 * 654183;
s13 -= s22 * 997805;
s14 += s22 * 136657;
s15 -= s22 * 683901;
s22 = 0;
s9 += s21 * 666643;
s10 += s21 * 470296;
s11 += s21 * 654183;
s12 -= s21 * 997805;
s13 += s21 * 136657;
s14 -= s21 * 683901;
s21 = 0;
s8 += s20 * 666643;
s9 += s20 * 470296;
s10 += s20 * 654183;
s11 -= s20 * 997805;
s12 += s20 * 136657;
s13 -= s20 * 683901;
s20 = 0;
s7 += s19 * 666643;
s8 += s19 * 470296;
s9 += s19 * 654183;
s10 -= s19 * 997805;
s11 += s19 * 136657;
s12 -= s19 * 683901;
s19 = 0;
s6 += s18 * 666643;
s7 += s18 * 470296;
s8 += s18 * 654183;
s9 -= s18 * 997805;
s10 += s18 * 136657;
s11 -= s18 * 683901;
s18 = 0;
carry6 = (s6 + (1 << 20)) >> 21;
s7 += carry6;
s6 -= carry6 << 21;
carry8 = (s8 + (1 << 20)) >> 21;
s9 += carry8;
s8 -= carry8 << 21;
carry10 = (s10 + (1 << 20)) >> 21;
s11 += carry10;
s10 -= carry10 << 21;
carry12 = (s12 + (1 << 20)) >> 21;
s13 += carry12;
s12 -= carry12 << 21;
carry14 = (s14 + (1 << 20)) >> 21;
s15 += carry14;
s14 -= carry14 << 21;
carry16 = (s16 + (1 << 20)) >> 21;
s17 += carry16;
s16 -= carry16 << 21;
carry7 = (s7 + (1 << 20)) >> 21;
s8 += carry7;
s7 -= carry7 << 21;
carry9 = (s9 + (1 << 20)) >> 21;
s10 += carry9;
s9 -= carry9 << 21;
carry11 = (s11 + (1 << 20)) >> 21;
s12 += carry11;
s11 -= carry11 << 21;
carry13 = (s13 + (1 << 20)) >> 21;
s14 += carry13;
s13 -= carry13 << 21;
carry15 = (s15 + (1 << 20)) >> 21;
s16 += carry15;
s15 -= carry15 << 21;
s5 += s17 * 666643;
s6 += s17 * 470296;
s7 += s17 * 654183;
s8 -= s17 * 997805;
s9 += s17 * 136657;
s10 -= s17 * 683901;
s17 = 0;
s4 += s16 * 666643;
s5 += s16 * 470296;
s6 += s16 * 654183;
s7 -= s16 * 997805;
s8 += s16 * 136657;
s9 -= s16 * 683901;
s16 = 0;
s3 += s15 * 666643;
s4 += s15 * 470296;
s5 += s15 * 654183;
s6 -= s15 * 997805;
s7 += s15 * 136657;
s8 -= s15 * 683901;
s15 = 0;
s2 += s14 * 666643;
s3 += s14 * 470296;
s4 += s14 * 654183;
s5 -= s14 * 997805;
s6 += s14 * 136657;
s7 -= s14 * 683901;
s14 = 0;
s1 += s13 * 666643;
s2 += s13 * 470296;
s3 += s13 * 654183;
s4 -= s13 * 997805;
s5 += s13 * 136657;
s6 -= s13 * 683901;
s13 = 0;
s0 += s12 * 666643;
s1 += s12 * 470296;
s2 += s12 * 654183;
s3 -= s12 * 997805;
s4 += s12 * 136657;
s5 -= s12 * 683901;
s12 = 0;
carry0 = (s0 + (1 << 20)) >> 21;
s1 += carry0;
s0 -= carry0 << 21;
carry2 = (s2 + (1 << 20)) >> 21;
s3 += carry2;
s2 -= carry2 << 21;
carry4 = (s4 + (1 << 20)) >> 21;
s5 += carry4;
s4 -= carry4 << 21;
carry6 = (s6 + (1 << 20)) >> 21;
s7 += carry6;
s6 -= carry6 << 21;
carry8 = (s8 + (1 << 20)) >> 21;
s9 += carry8;
s8 -= carry8 << 21;
carry10 = (s10 + (1 << 20)) >> 21;
s11 += carry10;
s10 -= carry10 << 21;
carry1 = (s1 + (1 << 20)) >> 21;
s2 += carry1;
s1 -= carry1 << 21;
carry3 = (s3 + (1 << 20)) >> 21;
s4 += carry3;
s3 -= carry3 << 21;
carry5 = (s5 + (1 << 20)) >> 21;
s6 += carry5;
s5 -= carry5 << 21;
carry7 = (s7 + (1 << 20)) >> 21;
s8 += carry7;
s7 -= carry7 << 21;
carry9 = (s9 + (1 << 20)) >> 21;
s10 += carry9;
s9 -= carry9 << 21;
carry11 = (s11 + (1 << 20)) >> 21;
s12 += carry11;
s11 -= carry11 << 21;
s0 += s12 * 666643;
s1 += s12 * 470296;
s2 += s12 * 654183;
s3 -= s12 * 997805;
s4 += s12 * 136657;
s5 -= s12 * 683901;
s12 = 0;
carry0 = s0 >> 21;
s1 += carry0;
s0 -= carry0 << 21;
carry1 = s1 >> 21;
s2 += carry1;
s1 -= carry1 << 21;
carry2 = s2 >> 21;
s3 += carry2;
s2 -= carry2 << 21;
carry3 = s3 >> 21;
s4 += carry3;
s3 -= carry3 << 21;
carry4 = s4 >> 21;
s5 += carry4;
s4 -= carry4 << 21;
carry5 = s5 >> 21;
s6 += carry5;
s5 -= carry5 << 21;
carry6 = s6 >> 21;
s7 += carry6;
s6 -= carry6 << 21;
carry7 = s7 >> 21;
s8 += carry7;
s7 -= carry7 << 21;
carry8 = s8 >> 21;
s9 += carry8;
s8 -= carry8 << 21;
carry9 = s9 >> 21;
s10 += carry9;
s9 -= carry9 << 21;
carry10 = s10 >> 21;
s11 += carry10;
s10 -= carry10 << 21;
carry11 = s11 >> 21;
s12 += carry11;
s11 -= carry11 << 21;
s0 += s12 * 666643;
s1 += s12 * 470296;
s2 += s12 * 654183;
s3 -= s12 * 997805;
s4 += s12 * 136657;
s5 -= s12 * 683901;
s12 = 0;
carry0 = s0 >> 21;
s1 += carry0;
s0 -= carry0 << 21;
carry1 = s1 >> 21;
s2 += carry1;
s1 -= carry1 << 21;
carry2 = s2 >> 21;
s3 += carry2;
s2 -= carry2 << 21;
carry3 = s3 >> 21;
s4 += carry3;
s3 -= carry3 << 21;
carry4 = s4 >> 21;
s5 += carry4;
s4 -= carry4 << 21;
carry5 = s5 >> 21;
s6 += carry5;
s5 -= carry5 << 21;
carry6 = s6 >> 21;
s7 += carry6;
s6 -= carry6 << 21;
carry7 = s7 >> 21;
s8 += carry7;
s7 -= carry7 << 21;
carry8 = s8 >> 21;
s9 += carry8;
s8 -= carry8 << 21;
carry9 = s9 >> 21;
s10 += carry9;
s9 -= carry9 << 21;
carry10 = s10 >> 21;
s11 += carry10;
s10 -= carry10 << 21;
s[0] = (unsigned char) (s0 >> 0);
s[1] = (unsigned char) (s0 >> 8);
s[2] = (unsigned char) ((s0 >> 16) | (s1 << 5));
s[3] = (unsigned char) (s1 >> 3);
s[4] = (unsigned char) (s1 >> 11);
s[5] = (unsigned char) ((s1 >> 19) | (s2 << 2));
s[6] = (unsigned char) (s2 >> 6);
s[7] = (unsigned char) ((s2 >> 14) | (s3 << 7));
s[8] = (unsigned char) (s3 >> 1);
s[9] = (unsigned char) (s3 >> 9);
s[10] = (unsigned char) ((s3 >> 17) | (s4 << 4));
s[11] = (unsigned char) (s4 >> 4);
s[12] = (unsigned char) (s4 >> 12);
s[13] = (unsigned char) ((s4 >> 20) | (s5 << 1));
s[14] = (unsigned char) (s5 >> 7);
s[15] = (unsigned char) ((s5 >> 15) | (s6 << 6));
s[16] = (unsigned char) (s6 >> 2);
s[17] = (unsigned char) (s6 >> 10);
s[18] = (unsigned char) ((s6 >> 18) | (s7 << 3));
s[19] = (unsigned char) (s7 >> 5);
s[20] = (unsigned char) (s7 >> 13);
s[21] = (unsigned char) (s8 >> 0);
s[22] = (unsigned char) (s8 >> 8);
s[23] = (unsigned char) ((s8 >> 16) | (s9 << 5));
s[24] = (unsigned char) (s9 >> 3);
s[25] = (unsigned char) (s9 >> 11);
s[26] = (unsigned char) ((s9 >> 19) | (s10 << 2));
s[27] = (unsigned char) (s10 >> 6);
s[28] = (unsigned char) ((s10 >> 14) | (s11 << 7));
s[29] = (unsigned char) (s11 >> 1);
s[30] = (unsigned char) (s11 >> 9);
s[31] = (unsigned char) (s11 >> 17);
}
/*
Input:
a[0]+256*a[1]+...+256^31*a[31] = a
b[0]+256*b[1]+...+256^31*b[31] = b
c[0]+256*c[1]+...+256^31*c[31] = c
Output:
s[0]+256*s[1]+...+256^31*s[31] = (ab+c) mod l
where l = 2^252 + 27742317777372353535851937790883648493.
*/
void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b, const unsigned char *c) {
int64_t a0 = 2097151 & load_3(a);
int64_t a1 = 2097151 & (load_4(a + 2) >> 5);
int64_t a2 = 2097151 & (load_3(a + 5) >> 2);
int64_t a3 = 2097151 & (load_4(a + 7) >> 7);
int64_t a4 = 2097151 & (load_4(a + 10) >> 4);
int64_t a5 = 2097151 & (load_3(a + 13) >> 1);
int64_t a6 = 2097151 & (load_4(a + 15) >> 6);
int64_t a7 = 2097151 & (load_3(a + 18) >> 3);
int64_t a8 = 2097151 & load_3(a + 21);
int64_t a9 = 2097151 & (load_4(a + 23) >> 5);
int64_t a10 = 2097151 & (load_3(a + 26) >> 2);
int64_t a11 = (load_4(a + 28) >> 7);
int64_t b0 = 2097151 & load_3(b);
int64_t b1 = 2097151 & (load_4(b + 2) >> 5);
int64_t b2 = 2097151 & (load_3(b + 5) >> 2);
int64_t b3 = 2097151 & (load_4(b + 7) >> 7);
int64_t b4 = 2097151 & (load_4(b + 10) >> 4);
int64_t b5 = 2097151 & (load_3(b + 13) >> 1);
int64_t b6 = 2097151 & (load_4(b + 15) >> 6);
int64_t b7 = 2097151 & (load_3(b + 18) >> 3);
int64_t b8 = 2097151 & load_3(b + 21);
int64_t b9 = 2097151 & (load_4(b + 23) >> 5);
int64_t b10 = 2097151 & (load_3(b + 26) >> 2);
int64_t b11 = (load_4(b + 28) >> 7);
int64_t c0 = 2097151 & load_3(c);
int64_t c1 = 2097151 & (load_4(c + 2) >> 5);
int64_t c2 = 2097151 & (load_3(c + 5) >> 2);
int64_t c3 = 2097151 & (load_4(c + 7) >> 7);
int64_t c4 = 2097151 & (load_4(c + 10) >> 4);
int64_t c5 = 2097151 & (load_3(c + 13) >> 1);
int64_t c6 = 2097151 & (load_4(c + 15) >> 6);
int64_t c7 = 2097151 & (load_3(c + 18) >> 3);
int64_t c8 = 2097151 & load_3(c + 21);
int64_t c9 = 2097151 & (load_4(c + 23) >> 5);
int64_t c10 = 2097151 & (load_3(c + 26) >> 2);
int64_t c11 = (load_4(c + 28) >> 7);
int64_t s0;
int64_t s1;
int64_t s2;
int64_t s3;
int64_t s4;
int64_t s5;
int64_t s6;
int64_t s7;
int64_t s8;
int64_t s9;
int64_t s10;
int64_t s11;
int64_t s12;
int64_t s13;
int64_t s14;
int64_t s15;
int64_t s16;
int64_t s17;
int64_t s18;
int64_t s19;
int64_t s20;
int64_t s21;
int64_t s22;
int64_t s23;
int64_t carry0;
int64_t carry1;
int64_t carry2;
int64_t carry3;
int64_t carry4;
int64_t carry5;
int64_t carry6;
int64_t carry7;
int64_t carry8;
int64_t carry9;
int64_t carry10;
int64_t carry11;
int64_t carry12;
int64_t carry13;
int64_t carry14;
int64_t carry15;
int64_t carry16;
int64_t carry17;
int64_t carry18;
int64_t carry19;
int64_t carry20;
int64_t carry21;
int64_t carry22;
s0 = c0 + a0 * b0;
s1 = c1 + a0 * b1 + a1 * b0;
s2 = c2 + a0 * b2 + a1 * b1 + a2 * b0;
s3 = c3 + a0 * b3 + a1 * b2 + a2 * b1 + a3 * b0;
s4 = c4 + a0 * b4 + a1 * b3 + a2 * b2 + a3 * b1 + a4 * b0;
s5 = c5 + a0 * b5 + a1 * b4 + a2 * b3 + a3 * b2 + a4 * b1 + a5 * b0;
s6 = c6 + a0 * b6 + a1 * b5 + a2 * b4 + a3 * b3 + a4 * b2 + a5 * b1 + a6 * b0;
s7 = c7 + a0 * b7 + a1 * b6 + a2 * b5 + a3 * b4 + a4 * b3 + a5 * b2 + a6 * b1 + a7 * b0;
s8 = c8 + a0 * b8 + a1 * b7 + a2 * b6 + a3 * b5 + a4 * b4 + a5 * b3 + a6 * b2 + a7 * b1 + a8 * b0;
s9 = c9 + a0 * b9 + a1 * b8 + a2 * b7 + a3 * b6 + a4 * b5 + a5 * b4 + a6 * b3 + a7 * b2 + a8 * b1 + a9 * b0;
s10 = c10 + a0 * b10 + a1 * b9 + a2 * b8 + a3 * b7 + a4 * b6 + a5 * b5 + a6 * b4 + a7 * b3 + a8 * b2 + a9 * b1 + a10 * b0;
s11 = c11 + a0 * b11 + a1 * b10 + a2 * b9 + a3 * b8 + a4 * b7 + a5 * b6 + a6 * b5 + a7 * b4 + a8 * b3 + a9 * b2 + a10 * b1 + a11 * b0;
s12 = a1 * b11 + a2 * b10 + a3 * b9 + a4 * b8 + a5 * b7 + a6 * b6 + a7 * b5 + a8 * b4 + a9 * b3 + a10 * b2 + a11 * b1;
s13 = a2 * b11 + a3 * b10 + a4 * b9 + a5 * b8 + a6 * b7 + a7 * b6 + a8 * b5 + a9 * b4 + a10 * b3 + a11 * b2;
s14 = a3 * b11 + a4 * b10 + a5 * b9 + a6 * b8 + a7 * b7 + a8 * b6 + a9 * b5 + a10 * b4 + a11 * b3;
s15 = a4 * b11 + a5 * b10 + a6 * b9 + a7 * b8 + a8 * b7 + a9 * b6 + a10 * b5 + a11 * b4;
s16 = a5 * b11 + a6 * b10 + a7 * b9 + a8 * b8 + a9 * b7 + a10 * b6 + a11 * b5;
s17 = a6 * b11 + a7 * b10 + a8 * b9 + a9 * b8 + a10 * b7 + a11 * b6;
s18 = a7 * b11 + a8 * b10 + a9 * b9 + a10 * b8 + a11 * b7;
s19 = a8 * b11 + a9 * b10 + a10 * b9 + a11 * b8;
s20 = a9 * b11 + a10 * b10 + a11 * b9;
s21 = a10 * b11 + a11 * b10;
s22 = a11 * b11;
s23 = 0;
carry0 = (s0 + (1 << 20)) >> 21;
s1 += carry0;
s0 -= carry0 << 21;
carry2 = (s2 + (1 << 20)) >> 21;
s3 += carry2;
s2 -= carry2 << 21;
carry4 = (s4 + (1 << 20)) >> 21;
s5 += carry4;
s4 -= carry4 << 21;
carry6 = (s6 + (1 << 20)) >> 21;
s7 += carry6;
s6 -= carry6 << 21;
carry8 = (s8 + (1 << 20)) >> 21;
s9 += carry8;
s8 -= carry8 << 21;
carry10 = (s10 + (1 << 20)) >> 21;
s11 += carry10;
s10 -= carry10 << 21;
carry12 = (s12 + (1 << 20)) >> 21;
s13 += carry12;
s12 -= carry12 << 21;
carry14 = (s14 + (1 << 20)) >> 21;
s15 += carry14;
s14 -= carry14 << 21;
carry16 = (s16 + (1 << 20)) >> 21;
s17 += carry16;
s16 -= carry16 << 21;
carry18 = (s18 + (1 << 20)) >> 21;
s19 += carry18;
s18 -= carry18 << 21;
carry20 = (s20 + (1 << 20)) >> 21;
s21 += carry20;
s20 -= carry20 << 21;
carry22 = (s22 + (1 << 20)) >> 21;
s23 += carry22;
s22 -= carry22 << 21;
carry1 = (s1 + (1 << 20)) >> 21;
s2 += carry1;
s1 -= carry1 << 21;
carry3 = (s3 + (1 << 20)) >> 21;
s4 += carry3;
s3 -= carry3 << 21;
carry5 = (s5 + (1 << 20)) >> 21;
s6 += carry5;
s5 -= carry5 << 21;
carry7 = (s7 + (1 << 20)) >> 21;
s8 += carry7;
s7 -= carry7 << 21;
carry9 = (s9 + (1 << 20)) >> 21;
s10 += carry9;
s9 -= carry9 << 21;
carry11 = (s11 + (1 << 20)) >> 21;
s12 += carry11;
s11 -= carry11 << 21;
carry13 = (s13 + (1 << 20)) >> 21;
s14 += carry13;
s13 -= carry13 << 21;
carry15 = (s15 + (1 << 20)) >> 21;
s16 += carry15;
s15 -= carry15 << 21;
carry17 = (s17 + (1 << 20)) >> 21;
s18 += carry17;
s17 -= carry17 << 21;
carry19 = (s19 + (1 << 20)) >> 21;
s20 += carry19;
s19 -= carry19 << 21;
carry21 = (s21 + (1 << 20)) >> 21;
s22 += carry21;
s21 -= carry21 << 21;
s11 += s23 * 666643;
s12 += s23 * 470296;
s13 += s23 * 654183;
s14 -= s23 * 997805;
s15 += s23 * 136657;
s16 -= s23 * 683901;
s23 = 0;
s10 += s22 * 666643;
s11 += s22 * 470296;
s12 += s22 * 654183;
s13 -= s22 * 997805;
s14 += s22 * 136657;
s15 -= s22 * 683901;
s22 = 0;
s9 += s21 * 666643;
s10 += s21 * 470296;
s11 += s21 * 654183;
s12 -= s21 * 997805;
s13 += s21 * 136657;
s14 -= s21 * 683901;
s21 = 0;
s8 += s20 * 666643;
s9 += s20 * 470296;
s10 += s20 * 654183;
s11 -= s20 * 997805;
s12 += s20 * 136657;
s13 -= s20 * 683901;
s20 = 0;
s7 += s19 * 666643;
s8 += s19 * 470296;
s9 += s19 * 654183;
s10 -= s19 * 997805;
s11 += s19 * 136657;
s12 -= s19 * 683901;
s19 = 0;
s6 += s18 * 666643;
s7 += s18 * 470296;
s8 += s18 * 654183;
s9 -= s18 * 997805;
s10 += s18 * 136657;
s11 -= s18 * 683901;
s18 = 0;
carry6 = (s6 + (1 << 20)) >> 21;
s7 += carry6;
s6 -= carry6 << 21;
carry8 = (s8 + (1 << 20)) >> 21;
s9 += carry8;
s8 -= carry8 << 21;
carry10 = (s10 + (1 << 20)) >> 21;
s11 += carry10;
s10 -= carry10 << 21;
carry12 = (s12 + (1 << 20)) >> 21;
s13 += carry12;
s12 -= carry12 << 21;
carry14 = (s14 + (1 << 20)) >> 21;
s15 += carry14;
s14 -= carry14 << 21;
carry16 = (s16 + (1 << 20)) >> 21;
s17 += carry16;
s16 -= carry16 << 21;
carry7 = (s7 + (1 << 20)) >> 21;
s8 += carry7;
s7 -= carry7 << 21;
carry9 = (s9 + (1 << 20)) >> 21;
s10 += carry9;
s9 -= carry9 << 21;
carry11 = (s11 + (1 << 20)) >> 21;
s12 += carry11;
s11 -= carry11 << 21;
carry13 = (s13 + (1 << 20)) >> 21;
s14 += carry13;
s13 -= carry13 << 21;
carry15 = (s15 + (1 << 20)) >> 21;
s16 += carry15;
s15 -= carry15 << 21;
s5 += s17 * 666643;
s6 += s17 * 470296;
s7 += s17 * 654183;
s8 -= s17 * 997805;
s9 += s17 * 136657;
s10 -= s17 * 683901;
s17 = 0;
s4 += s16 * 666643;
s5 += s16 * 470296;
s6 += s16 * 654183;
s7 -= s16 * 997805;
s8 += s16 * 136657;
s9 -= s16 * 683901;
s16 = 0;
s3 += s15 * 666643;
s4 += s15 * 470296;
s5 += s15 * 654183;
s6 -= s15 * 997805;
s7 += s15 * 136657;
s8 -= s15 * 683901;
s15 = 0;
s2 += s14 * 666643;
s3 += s14 * 470296;
s4 += s14 * 654183;
s5 -= s14 * 997805;
s6 += s14 * 136657;
s7 -= s14 * 683901;
s14 = 0;
s1 += s13 * 666643;
s2 += s13 * 470296;
s3 += s13 * 654183;
s4 -= s13 * 997805;
s5 += s13 * 136657;
s6 -= s13 * 683901;
s13 = 0;
s0 += s12 * 666643;
s1 += s12 * 470296;
s2 += s12 * 654183;
s3 -= s12 * 997805;
s4 += s12 * 136657;
s5 -= s12 * 683901;
s12 = 0;
carry0 = (s0 + (1 << 20)) >> 21;
s1 += carry0;
s0 -= carry0 << 21;
carry2 = (s2 + (1 << 20)) >> 21;
s3 += carry2;
s2 -= carry2 << 21;
carry4 = (s4 + (1 << 20)) >> 21;
s5 += carry4;
s4 -= carry4 << 21;
carry6 = (s6 + (1 << 20)) >> 21;
s7 += carry6;
s6 -= carry6 << 21;
carry8 = (s8 + (1 << 20)) >> 21;
s9 += carry8;
s8 -= carry8 << 21;
carry10 = (s10 + (1 << 20)) >> 21;
s11 += carry10;
s10 -= carry10 << 21;
carry1 = (s1 + (1 << 20)) >> 21;
s2 += carry1;
s1 -= carry1 << 21;
carry3 = (s3 + (1 << 20)) >> 21;
s4 += carry3;
s3 -= carry3 << 21;
carry5 = (s5 + (1 << 20)) >> 21;
s6 += carry5;
s5 -= carry5 << 21;
carry7 = (s7 + (1 << 20)) >> 21;
s8 += carry7;
s7 -= carry7 << 21;
carry9 = (s9 + (1 << 20)) >> 21;
s10 += carry9;
s9 -= carry9 << 21;
carry11 = (s11 + (1 << 20)) >> 21;
s12 += carry11;
s11 -= carry11 << 21;
s0 += s12 * 666643;
s1 += s12 * 470296;
s2 += s12 * 654183;
s3 -= s12 * 997805;
s4 += s12 * 136657;
s5 -= s12 * 683901;
s12 = 0;
carry0 = s0 >> 21;
s1 += carry0;
s0 -= carry0 << 21;
carry1 = s1 >> 21;
s2 += carry1;
s1 -= carry1 << 21;
carry2 = s2 >> 21;
s3 += carry2;
s2 -= carry2 << 21;
carry3 = s3 >> 21;
s4 += carry3;
s3 -= carry3 << 21;
carry4 = s4 >> 21;
s5 += carry4;
s4 -= carry4 << 21;
carry5 = s5 >> 21;
s6 += carry5;
s5 -= carry5 << 21;
carry6 = s6 >> 21;
s7 += carry6;
s6 -= carry6 << 21;
carry7 = s7 >> 21;
s8 += carry7;
s7 -= carry7 << 21;
carry8 = s8 >> 21;
s9 += carry8;
s8 -= carry8 << 21;
carry9 = s9 >> 21;
s10 += carry9;
s9 -= carry9 << 21;
carry10 = s10 >> 21;
s11 += carry10;
s10 -= carry10 << 21;
carry11 = s11 >> 21;
s12 += carry11;
s11 -= carry11 << 21;
s0 += s12 * 666643;
s1 += s12 * 470296;
s2 += s12 * 654183;
s3 -= s12 * 997805;
s4 += s12 * 136657;
s5 -= s12 * 683901;
s12 = 0;
carry0 = s0 >> 21;
s1 += carry0;
s0 -= carry0 << 21;
carry1 = s1 >> 21;
s2 += carry1;
s1 -= carry1 << 21;
carry2 = s2 >> 21;
s3 += carry2;
s2 -= carry2 << 21;
carry3 = s3 >> 21;
s4 += carry3;
s3 -= carry3 << 21;
carry4 = s4 >> 21;
s5 += carry4;
s4 -= carry4 << 21;
carry5 = s5 >> 21;
s6 += carry5;
s5 -= carry5 << 21;
carry6 = s6 >> 21;
s7 += carry6;
s6 -= carry6 << 21;
carry7 = s7 >> 21;
s8 += carry7;
s7 -= carry7 << 21;
carry8 = s8 >> 21;
s9 += carry8;
s8 -= carry8 << 21;
carry9 = s9 >> 21;
s10 += carry9;
s9 -= carry9 << 21;
carry10 = s10 >> 21;
s11 += carry10;
s10 -= carry10 << 21;
s[0] = (unsigned char) (s0 >> 0);
s[1] = (unsigned char) (s0 >> 8);
s[2] = (unsigned char) ((s0 >> 16) | (s1 << 5));
s[3] = (unsigned char) (s1 >> 3);
s[4] = (unsigned char) (s1 >> 11);
s[5] = (unsigned char) ((s1 >> 19) | (s2 << 2));
s[6] = (unsigned char) (s2 >> 6);
s[7] = (unsigned char) ((s2 >> 14) | (s3 << 7));
s[8] = (unsigned char) (s3 >> 1);
s[9] = (unsigned char) (s3 >> 9);
s[10] = (unsigned char) ((s3 >> 17) | (s4 << 4));
s[11] = (unsigned char) (s4 >> 4);
s[12] = (unsigned char) (s4 >> 12);
s[13] = (unsigned char) ((s4 >> 20) | (s5 << 1));
s[14] = (unsigned char) (s5 >> 7);
s[15] = (unsigned char) ((s5 >> 15) | (s6 << 6));
s[16] = (unsigned char) (s6 >> 2);
s[17] = (unsigned char) (s6 >> 10);
s[18] = (unsigned char) ((s6 >> 18) | (s7 << 3));
s[19] = (unsigned char) (s7 >> 5);
s[20] = (unsigned char) (s7 >> 13);
s[21] = (unsigned char) (s8 >> 0);
s[22] = (unsigned char) (s8 >> 8);
s[23] = (unsigned char) ((s8 >> 16) | (s9 << 5));
s[24] = (unsigned char) (s9 >> 3);
s[25] = (unsigned char) (s9 >> 11);
s[26] = (unsigned char) ((s9 >> 19) | (s10 << 2));
s[27] = (unsigned char) (s10 >> 6);
s[28] = (unsigned char) ((s10 >> 14) | (s11 << 7));
s[29] = (unsigned char) (s11 >> 1);
s[30] = (unsigned char) (s11 >> 9);
s[31] = (unsigned char) (s11 >> 17);
}
+12
View File
@@ -0,0 +1,12 @@
#ifndef SC_H
#define SC_H
/*
The set of scalars is \Z/l
where l = 2^252 + 27742317777372353535851937790883648493.
*/
void sc_reduce(unsigned char *s);
void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b, const unsigned char *c);
#endif
+40
View File
@@ -0,0 +1,40 @@
#include "ed_25519.h"
#ifndef ED25519_NO_SEED
#ifdef _WIN32
#include <windows.h>
#include <wincrypt.h>
#else
#include <stdio.h>
#endif
int ed25519_create_seed(unsigned char *seed) {
#ifdef _WIN32
HCRYPTPROV prov;
if (!CryptAcquireContext(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
return 1;
}
if (!CryptGenRandom(prov, 32, seed)) {
CryptReleaseContext(prov, 0);
return 1;
}
CryptReleaseContext(prov, 0);
#else
FILE *f = fopen("/dev/urandom", "rb");
if (f == NULL) {
return 1;
}
fread(seed, 1, 32, f);
fclose(f);
#endif
return 0;
}
#endif
+275
View File
@@ -0,0 +1,275 @@
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
*
* LibTomCrypt is a library that provides various cryptographic
* algorithms in a highly modular and flexible manner.
*
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "fixedint.h"
#include "sha512.h"
/* the K array */
static const uint64_t K[80] = {
UINT64_C(0x428a2f98d728ae22), UINT64_C(0x7137449123ef65cd),
UINT64_C(0xb5c0fbcfec4d3b2f), UINT64_C(0xe9b5dba58189dbbc),
UINT64_C(0x3956c25bf348b538), UINT64_C(0x59f111f1b605d019),
UINT64_C(0x923f82a4af194f9b), UINT64_C(0xab1c5ed5da6d8118),
UINT64_C(0xd807aa98a3030242), UINT64_C(0x12835b0145706fbe),
UINT64_C(0x243185be4ee4b28c), UINT64_C(0x550c7dc3d5ffb4e2),
UINT64_C(0x72be5d74f27b896f), UINT64_C(0x80deb1fe3b1696b1),
UINT64_C(0x9bdc06a725c71235), UINT64_C(0xc19bf174cf692694),
UINT64_C(0xe49b69c19ef14ad2), UINT64_C(0xefbe4786384f25e3),
UINT64_C(0x0fc19dc68b8cd5b5), UINT64_C(0x240ca1cc77ac9c65),
UINT64_C(0x2de92c6f592b0275), UINT64_C(0x4a7484aa6ea6e483),
UINT64_C(0x5cb0a9dcbd41fbd4), UINT64_C(0x76f988da831153b5),
UINT64_C(0x983e5152ee66dfab), UINT64_C(0xa831c66d2db43210),
UINT64_C(0xb00327c898fb213f), UINT64_C(0xbf597fc7beef0ee4),
UINT64_C(0xc6e00bf33da88fc2), UINT64_C(0xd5a79147930aa725),
UINT64_C(0x06ca6351e003826f), UINT64_C(0x142929670a0e6e70),
UINT64_C(0x27b70a8546d22ffc), UINT64_C(0x2e1b21385c26c926),
UINT64_C(0x4d2c6dfc5ac42aed), UINT64_C(0x53380d139d95b3df),
UINT64_C(0x650a73548baf63de), UINT64_C(0x766a0abb3c77b2a8),
UINT64_C(0x81c2c92e47edaee6), UINT64_C(0x92722c851482353b),
UINT64_C(0xa2bfe8a14cf10364), UINT64_C(0xa81a664bbc423001),
UINT64_C(0xc24b8b70d0f89791), UINT64_C(0xc76c51a30654be30),
UINT64_C(0xd192e819d6ef5218), UINT64_C(0xd69906245565a910),
UINT64_C(0xf40e35855771202a), UINT64_C(0x106aa07032bbd1b8),
UINT64_C(0x19a4c116b8d2d0c8), UINT64_C(0x1e376c085141ab53),
UINT64_C(0x2748774cdf8eeb99), UINT64_C(0x34b0bcb5e19b48a8),
UINT64_C(0x391c0cb3c5c95a63), UINT64_C(0x4ed8aa4ae3418acb),
UINT64_C(0x5b9cca4f7763e373), UINT64_C(0x682e6ff3d6b2b8a3),
UINT64_C(0x748f82ee5defb2fc), UINT64_C(0x78a5636f43172f60),
UINT64_C(0x84c87814a1f0ab72), UINT64_C(0x8cc702081a6439ec),
UINT64_C(0x90befffa23631e28), UINT64_C(0xa4506cebde82bde9),
UINT64_C(0xbef9a3f7b2c67915), UINT64_C(0xc67178f2e372532b),
UINT64_C(0xca273eceea26619c), UINT64_C(0xd186b8c721c0c207),
UINT64_C(0xeada7dd6cde0eb1e), UINT64_C(0xf57d4f7fee6ed178),
UINT64_C(0x06f067aa72176fba), UINT64_C(0x0a637dc5a2c898a6),
UINT64_C(0x113f9804bef90dae), UINT64_C(0x1b710b35131c471b),
UINT64_C(0x28db77f523047d84), UINT64_C(0x32caab7b40c72493),
UINT64_C(0x3c9ebe0a15c9bebc), UINT64_C(0x431d67c49c100d4c),
UINT64_C(0x4cc5d4becb3e42b6), UINT64_C(0x597f299cfc657e2a),
UINT64_C(0x5fcb6fab3ad6faec), UINT64_C(0x6c44198c4a475817)
};
/* Various logical functions */
#define ROR64c(x, y) \
( ((((x)&UINT64_C(0xFFFFFFFFFFFFFFFF))>>((uint64_t)(y)&UINT64_C(63))) | \
((x)<<((uint64_t)(64-((y)&UINT64_C(63)))))) & UINT64_C(0xFFFFFFFFFFFFFFFF))
#define STORE64H(x, y) \
{ (y)[0] = (unsigned char)(((x)>>56)&255); (y)[1] = (unsigned char)(((x)>>48)&255); \
(y)[2] = (unsigned char)(((x)>>40)&255); (y)[3] = (unsigned char)(((x)>>32)&255); \
(y)[4] = (unsigned char)(((x)>>24)&255); (y)[5] = (unsigned char)(((x)>>16)&255); \
(y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); }
#define LOAD64H(x, y) \
{ x = (((uint64_t)((y)[0] & 255))<<56)|(((uint64_t)((y)[1] & 255))<<48) | \
(((uint64_t)((y)[2] & 255))<<40)|(((uint64_t)((y)[3] & 255))<<32) | \
(((uint64_t)((y)[4] & 255))<<24)|(((uint64_t)((y)[5] & 255))<<16) | \
(((uint64_t)((y)[6] & 255))<<8)|(((uint64_t)((y)[7] & 255))); }
#define Ch(x,y,z) (z ^ (x & (y ^ z)))
#define Maj(x,y,z) (((x | y) & z) | (x & y))
#define S(x, n) ROR64c(x, n)
#define R(x, n) (((x) &UINT64_C(0xFFFFFFFFFFFFFFFF))>>((uint64_t)n))
#define Sigma0(x) (S(x, 28) ^ S(x, 34) ^ S(x, 39))
#define Sigma1(x) (S(x, 14) ^ S(x, 18) ^ S(x, 41))
#define Gamma0(x) (S(x, 1) ^ S(x, 8) ^ R(x, 7))
#define Gamma1(x) (S(x, 19) ^ S(x, 61) ^ R(x, 6))
#ifndef MIN
#define MIN(x, y) ( ((x)<(y))?(x):(y) )
#endif
/* compress 1024-bits */
static int sha512_compress(sha512_context *md, unsigned char *buf)
{
uint64_t S[8], W[80], t0, t1;
int i;
/* copy state into S */
for (i = 0; i < 8; i++) {
S[i] = md->state[i];
}
/* copy the state into 1024-bits into W[0..15] */
for (i = 0; i < 16; i++) {
LOAD64H(W[i], buf + (8*i));
}
/* fill W[16..79] */
for (i = 16; i < 80; i++) {
W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];
}
/* Compress */
#define RND(a,b,c,d,e,f,g,h,i) \
t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
t1 = Sigma0(a) + Maj(a, b, c);\
d += t0; \
h = t0 + t1;
for (i = 0; i < 80; i += 8) {
RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],i+0);
RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],i+1);
RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],i+2);
RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],i+3);
RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],i+4);
RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],i+5);
RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],i+6);
RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],i+7);
}
#undef RND
/* feedback */
for (i = 0; i < 8; i++) {
md->state[i] = md->state[i] + S[i];
}
return 0;
}
/**
Initialize the hash state
@param md The hash state you wish to initialize
@return 0 if successful
*/
int sha512_init(sha512_context * md) {
if (md == NULL) return 1;
md->curlen = 0;
md->length = 0;
md->state[0] = UINT64_C(0x6a09e667f3bcc908);
md->state[1] = UINT64_C(0xbb67ae8584caa73b);
md->state[2] = UINT64_C(0x3c6ef372fe94f82b);
md->state[3] = UINT64_C(0xa54ff53a5f1d36f1);
md->state[4] = UINT64_C(0x510e527fade682d1);
md->state[5] = UINT64_C(0x9b05688c2b3e6c1f);
md->state[6] = UINT64_C(0x1f83d9abfb41bd6b);
md->state[7] = UINT64_C(0x5be0cd19137e2179);
return 0;
}
/**
Process a block of memory though the hash
@param md The hash state
@param in The data to hash
@param inlen The length of the data (octets)
@return 0 if successful
*/
int sha512_update (sha512_context * md, const unsigned char *in, size_t inlen)
{
size_t n;
size_t i;
int err;
if (md == NULL) return 1;
if (in == NULL) return 1;
if (md->curlen > sizeof(md->buf)) {
return 1;
}
while (inlen > 0) {
if (md->curlen == 0 && inlen >= 128) {
if ((err = sha512_compress (md, (unsigned char *)in)) != 0) {
return err;
}
md->length += 128 * 8;
in += 128;
inlen -= 128;
} else {
n = MIN(inlen, (128 - md->curlen));
for (i = 0; i < n; i++) {
md->buf[i + md->curlen] = in[i];
}
md->curlen += n;
in += n;
inlen -= n;
if (md->curlen == 128) {
if ((err = sha512_compress (md, md->buf)) != 0) {
return err;
}
md->length += 8*128;
md->curlen = 0;
}
}
}
return 0;
}
/**
Terminate the hash to get the digest
@param md The hash state
@param out [out] The destination of the hash (64 bytes)
@return 0 if successful
*/
int sha512_final(sha512_context * md, unsigned char *out)
{
int i;
if (md == NULL) return 1;
if (out == NULL) return 1;
if (md->curlen >= sizeof(md->buf)) {
return 1;
}
/* increase the length of the message */
md->length += md->curlen * UINT64_C(8);
/* append the '1' bit */
md->buf[md->curlen++] = (unsigned char)0x80;
/* if the length is currently above 112 bytes we append zeros
* then compress. Then we can fall back to padding zeros and length
* encoding like normal.
*/
if (md->curlen > 112) {
while (md->curlen < 128) {
md->buf[md->curlen++] = (unsigned char)0;
}
sha512_compress(md, md->buf);
md->curlen = 0;
}
/* pad upto 120 bytes of zeroes
* note: that from 112 to 120 is the 64 MSB of the length. We assume that you won't hash
* > 2^64 bits of data... :-)
*/
while (md->curlen < 120) {
md->buf[md->curlen++] = (unsigned char)0;
}
/* store length */
STORE64H(md->length, md->buf+120);
sha512_compress(md, md->buf);
/* copy output */
for (i = 0; i < 8; i++) {
STORE64H(md->state[i], out+(8*i));
}
return 0;
}
int sha512(const unsigned char *message, size_t message_len, unsigned char *out)
{
sha512_context ctx;
int ret;
if ((ret = sha512_init(&ctx))) return ret;
if ((ret = sha512_update(&ctx, message, message_len))) return ret;
if ((ret = sha512_final(&ctx, out))) return ret;
return 0;
}
+21
View File
@@ -0,0 +1,21 @@
#ifndef SHA512_H
#define SHA512_H
#include <stddef.h>
#include "fixedint.h"
/* state */
typedef struct sha512_context_ {
uint64_t length, state[8];
size_t curlen;
unsigned char buf[128];
} sha512_context;
int sha512_init(sha512_context * md);
int sha512_final(sha512_context * md, unsigned char *out);
int sha512_update(sha512_context * md, const unsigned char *in, size_t inlen);
int sha512(const unsigned char *message, size_t message_len, unsigned char *out);
#endif
+31
View File
@@ -0,0 +1,31 @@
#include "ed_25519.h"
#include "sha512.h"
#include "ge.h"
#include "sc.h"
void ed25519_sign(unsigned char *signature, const unsigned char *message, size_t message_len, const unsigned char *public_key, const unsigned char *private_key) {
sha512_context hash;
unsigned char hram[64];
unsigned char r[64];
ge_p3 R;
sha512_init(&hash);
sha512_update(&hash, private_key + 32, 32);
sha512_update(&hash, message, message_len);
sha512_final(&hash, r);
sc_reduce(r);
ge_scalarmult_base(&R, r);
ge_p3_tobytes(signature, &R);
sha512_init(&hash);
sha512_update(&hash, signature, 32);
sha512_update(&hash, public_key, 32);
sha512_update(&hash, message, message_len);
sha512_final(&hash, hram);
sc_reduce(hram);
sc_muladd(signature + 32, hram, private_key, r);
}
+77
View File
@@ -0,0 +1,77 @@
#include "ed_25519.h"
#include "sha512.h"
#include "ge.h"
#include "sc.h"
static int consttime_equal(const unsigned char *x, const unsigned char *y) {
unsigned char r = 0;
r = x[0] ^ y[0];
#define F(i) r |= x[i] ^ y[i]
F(1);
F(2);
F(3);
F(4);
F(5);
F(6);
F(7);
F(8);
F(9);
F(10);
F(11);
F(12);
F(13);
F(14);
F(15);
F(16);
F(17);
F(18);
F(19);
F(20);
F(21);
F(22);
F(23);
F(24);
F(25);
F(26);
F(27);
F(28);
F(29);
F(30);
F(31);
#undef F
return !r;
}
int ed25519_verify(const unsigned char *signature, const unsigned char *message, size_t message_len, const unsigned char *public_key) {
unsigned char h[64];
unsigned char checker[32];
sha512_context hash;
ge_p3 A;
ge_p2 R;
if (signature[63] & 224) {
return 0;
}
if (ge_frombytes_negate_vartime(&A, public_key) != 0) {
return 0;
}
sha512_init(&hash);
sha512_update(&hash, signature, 32);
sha512_update(&hash, public_key, 32);
sha512_update(&hash, message, message_len);
sha512_final(&hash, h);
sc_reduce(h);
ge_double_scalarmult_vartime(&R, h, &A, signature + 32);
ge_tobytes(checker, &R);
if (!consttime_equal(checker, signature)) {
return 0;
}
return 1;
}
Loaded 100 of 290 files, more files were not shown because too many files have changed in this diff. Show more