Compare commits

...

109 Commits

Author SHA1 Message Date
Ben Meadors
9fce57e74d Remove .tmp 2025-03-04 08:37:54 -06:00
Ben Meadors
0533ca0eda Move order 2025-03-04 06:57:54 -06:00
Ben Meadors
661fcd0e77 Locks 2025-03-04 06:55:00 -06:00
Ben Meadors
ac3980e98d Remove old junk 2025-03-03 07:48:39 -06:00
Ben Meadors
ff4b7fdce3 Remove this one 2025-03-02 08:54:10 -06:00
Ben Meadors
b933b48898 Update calls 2025-03-02 08:41:20 -06:00
Ben Meadors
df52bbcae3 Merge branch 'master' into backup-restore 2025-03-02 08:23:55 -06:00
Ben Meadors
4a9f6ceb55 Remove automatic backup 2025-02-27 06:49:15 -06:00
Ben Meadors
db84fbed5d Change to warning 2025-02-27 06:45:07 -06:00
Ben Meadors
96663218ee Move reboot 2025-02-27 06:41:09 -06:00
Ben Meadors
51dc2da83c Merge remote-tracking branch 'origin/2.6' into backup-restore 2025-02-27 06:16:26 -06:00
Ben Meadors
19951e3b6a Merge branch 'master' into 2.6 2025-02-26 17:43:54 -06:00
mverch67
0b106d4642 MUI: BT programming mode button 2025-02-26 23:41:52 +01:00
mverch67
70d8da6561 MUI hot-fix username dialog 2025-02-26 22:37:34 +01:00
mverch67
5f5fac25fd MUI hot-fix pub/priv keys 2025-02-26 21:58:36 +01:00
mverch67
9cdd6b8633 defined(SENSECAP_INDICATOR) 2025-02-26 20:10:34 +01:00
mverch67
f5db94e606 device-ui lib: last minute update 2025-02-26 14:01:28 +01:00
mverch67
3f512976b8 device-lib update: fix settings panel -> no scrolling 2025-02-26 10:42:04 +01:00
mverch67
ad41f9e013 fix channel OK button 2025-02-26 10:11:43 +01:00
mverch67
b85d9f988e Merge branch '2.6' of https://github.com/meshtastic/firmware into 2.6 2025-02-26 03:28:28 +01:00
mverch67
7150a68714 device-ui lib update 2025-02-26 03:28:22 +01:00
Ben Meadors
6cf8cbcda7 Updeet 2025-02-25 20:28:00 -06:00
Ben Meadors
4e74c549ed Remove backup 2025-02-25 08:56:57 -06:00
Ben Meadors
065370c6b6 Merge remote-tracking branch 'origin/2.6' into backup-restore 2025-02-25 07:57:57 -06:00
github-actions[bot]
f913ce0310 [create-pull-request] automated change (#6152)
Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com>
2025-02-25 07:49:06 -06:00
Ben Meadors
261c326da6 Protos 2025-02-25 07:34:40 -06:00
Ben Meadors
eb3ffc1922 Updates and fix lame legacy code paths 2025-02-25 07:32:17 -06:00
Ben Meadors
c986c4a742 Merge branch '2.6' into backup-restore 2025-02-25 05:11:27 -06:00
github-actions[bot]
cb0982c2f1 [create-pull-request] automated change (#6144)
Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com>
2025-02-24 19:25:46 -06:00
Ben Meadors
ccbec44bfb Space 2025-02-24 19:20:37 -06:00
Ben Meadors
109d66e976 Merge remote-tracking branch 'origin/master' into 2.6 2025-02-24 19:20:27 -06:00
Ben Meadors
320a38f9ac Update protobufs 2025-02-24 19:18:26 -06:00
Ben Meadors
488e76d27b Merge remote-tracking branch 'origin/master' into 2.6 2025-02-24 07:11:06 -06:00
Ben Meadors
ada8b96842 Backup / restore preferences method 2025-02-24 07:10:08 -06:00
github-actions[bot]
c2cc3207ba [create-pull-request] automated change (#6133)
Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com>
2025-02-23 13:30:45 -06:00
Ben Meadors
f309fba89c Proto update for backup 2025-02-23 13:06:45 -06:00
github-actions[bot]
7dc0330897 [create-pull-request] automated change (#6131) 2025-02-23 10:10:05 -06:00
Ben Meadors
6c227157b5 Proto 2025-02-23 08:56:06 -06:00
github-actions[bot]
e4c6aa588e [create-pull-request] automated change (#6129)
Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com>
2025-02-23 08:09:39 -06:00
Ben Meadors
164d46facb Update protos and device-ui 2025-02-23 08:05:12 -06:00
Ben Meadors
6c6b804b53 Update device-ui 2025-02-19 18:17:50 -06:00
Ben Meadors
1a92b7881f Merge remote-tracking branch 'origin/master' into 2.6 2025-02-19 18:17:30 -06:00
Ben Meadors
1961bcaf9d Backup / migrate pub private keys when upgrading to new files in 2.6 (#6096)
* Save a backup of pub/private keys before factory reset

* Fix licensed mode warning

* Unlock spi on else file doesn't exist
2025-02-20 07:54:56 +08:00
Ben Meadors
a7c4361d7c Merge remote-tracking branch 'origin/master' into 2.6 2025-02-17 15:04:11 -06:00
Manuel
c0145001ef unPhone TFT: include into build, enable SD card, increase PSRAM (#6082)
* unPhone-tft: include into build, enable SD card, increase assigned PSRAM

* lib update
2025-02-17 13:45:12 -06:00
Ben Meadors
01618e99e5 Update device-ui 2025-02-17 13:44:42 -06:00
Manuel
a02d538b58 MUI: move UI initialization out of main.cpp and adding lightsleep observer + mutex (#6078)
* added device-ui to lightSleep observers for handling graceful sleep; refactoring main.cpp

* bump lib version
2025-02-17 10:35:11 -06:00
Thomas Göttgens
ac9cb235a8 Merge branch 'master' into 2.6 2025-02-17 15:53:14 +01:00
Ben Meadors
9ce19c5c1c Prevent licensed users from rebroadcasting unlicensed traffic (#6068)
* Prevent licensed users from rebroadcasting unlicensed traffic

* Added method and enum to make user license status more clear
2025-02-16 20:18:16 -06:00
Ben Meadors
022dc29ea7 Device UI submodule bump 2025-02-15 09:35:01 -06:00
Ben Meadors
18410ba80d Merge remote-tracking branch 'origin/master' into 2.6 2025-02-15 09:34:05 -06:00
Ben Meadors
3f3f89c06e Licensed usage compliance (#6047)
* Prevent psk and legacy admin channel on licensed mode

* Move it

* Consolidate warning strings

* More holes
2025-02-15 09:24:37 -06:00
GUVWAF
919085379e Increase MAX_THREADS for InkHUD variants with WiFi (#6064) 2025-02-15 09:05:26 -06:00
Ben Meadors
bdf60d8e4d Fixed persistence stragglers from NodeDB / Device State divorce (#6059) 2025-02-15 07:56:04 -06:00
todd-herbert
431b067f30 Wireless Paper: remove stray board_level = extra (#6060)
Makes sure the InkHUD version gets build into the release zip
2025-02-15 19:04:39 +08:00
mverch67
4a63b36a7d remove debuglog leftover 2025-02-14 10:25:54 +01:00
Manuel
1fe16a0471 MUI: fix nag timeout, disable BT programming mode for native (#6052)
* allow BT connection with disabled MUI

* Update device-ui

* MUI: fix nag timeout default and remove programming mode for native

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
2025-02-14 09:04:54 +01:00
Manuel
2b1f45fd8b MUI: BT programming mode (#6046)
* allow BT connection with disabled MUI

* Update device-ui

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
2025-02-13 12:01:24 -06:00
Ben Meadors
79c0e8168d Sigh... 2025-02-12 15:07:19 -06:00
Ben Meadors
459dbfff23 Yet another case issue! 2025-02-12 13:39:16 -06:00
Ben Meadors
27ddd549f9 RTC 2025-02-12 11:55:03 -06:00
Ben Meadors
e5ed913a8a Moar 2025-02-12 11:31:39 -06:00
Ben Meadors
93d041b4b0 More case-sensitivity instances 2025-02-12 09:39:25 -06:00
Ben Meadors
005e8501ce Case sensitive perhaps? 2025-02-12 08:02:03 -06:00
Ben Meadors
6cb3acd79f Guard eink drivers w/ MESHTASTIC_INCLUDE_NICHE_GRAPHICS 2025-02-12 06:23:49 -06:00
todd-herbert
910efd86f0 fix: InkHUD shouldn't nag about timezone (#6040) 2025-02-12 19:09:42 +08:00
Ben Meadors
ded45cf17d Collect inkhud 2025-02-11 20:01:57 -06:00
Ben Meadors
6f9e4d5b1a Merge remote-tracking branch 'origin/master' into 2.6 2025-02-11 19:57:57 -06:00
mverch67
b012e561eb update device-ui: fix touch/crash issue while light sleep 2025-02-11 23:54:42 +01:00
todd-herbert
9fd100dd92 InkHUD UI for E-Ink (#6034)
* Decouple ButtonThread from sleep.cpp
Reorganize sleep observables. Don't call ButtonThread methods inside doLightSleep. Instead, handle in class with new lightsleep Observables.

* InkHUD: initial commit (WIP)
Publicly discloses the current work in progress. Not ready for use.

* feat: battery icon

* chore: implement meshtastic/firmware #5454
Clean up some inline functions

* feat: menu & settings for "jump to applet"

* Remove the beforeRender pattern
It hugely complicates things. If we can achieve acceptable performance without it, so much the better.

* Remove previous Map Applet
Needs re-implementation to work without the beforeRender pattern

* refactor: reimplement map applet
Doesn't require own position
Doesn't require the beforeRender pattern to precalculate; now all-at-once in render
Lays groundwork for fixed-size map with custom background image

* feat: autoshow
Allow user to select which applets (if any) should be automatically brought to foreground when they have new data to display

* refactor: tidy-up applet constructors
misc. jobs including:
- consistent naming
- move initializer-list-only constructors to header
- give derived applets unique identifiers for MeshModule and OSThread logging

* hotfix: autoshow always uses FAST update
In future, it *will* often use FAST, but this will be controlled by a WindowManager component which has not yet been written.
Hotfixed, in case anybody is attempting to use this development version on their deployed devices.

* refactor: bringToForeground no longer requests FAST update
In situations where an applet has moved to foreground because of user input, requestUpdate can be manually called, to upgrade to FAST refresh.
More permanent solution for #23e1dfc

* refactor: extract string storage from ThreadedMessageApplet
Separates the code responsible for storing the limited message history, which was previously part of the ThreadedMessageApplet.
We're now also using this code to store the "most recent message". Previously, this was stored in the `InkHUD::settings` struct, which was much less space-efficient.
We're also now storing the latest DM, laying the foundation for an applet to display only DMs, which will complement the threaded message applet.

* fix: text wrapping
Attempts to fix a disparity between `Applet::printWrapped` and `Applet::getWrappedTextHeight`, which would occasionally cause a ThreadedMessageApplet message to render "too short", overlapping other text.

* fix: purge old constructor
This one slipped through the last commit..

* feat: DM Applet
Useful in combination with the ThreadedMessageApplets, which don't show DMs

* fix: applets shouldn't handle events while deactivated
Only one or two applets were actually doing this, but I'm making a habit of having all applets return early from their event handling methods (as good practice), even if those methods are disabled elsewhere (e.g. not observing observable, return false from wantPacket)

* refactor: allow requesting update without requesting autoshow
Some applets may want to redraw, if they are displayed, but not feel the information is worth being brought to foreground for. Example: ActiveNodesApplet, when purging old nodes from list.

* feat: custom "Recently Active" duration
Allows users to tailor how long nodes will appear in the "Recents" applets, to suit the activity level of their mesh.

* refactor: rename some applets

* fix: autoshow

* fix: getWrappedTextHeight
Remove the "simulate" option from printWrapped; too hard to keep inline with genuine printing (because of AdafruitGFX Fonts' xAdvance, mabye?). Instead of simulating, we printWrapped as normal, and discard pixel output by setting crop. Both methods are similarly inefficient, apparently.

* fix: text wrapping in ThreadedMessageApplet
Wrong arguments were passed to Applet::printWrapped

* feat: notifications for text messages
Only shown if current applet does not already display the same info. Autoshow takes priority over notifications, if both would be used to display the same info.

* feat: optimize FAST vs FULL updates
New UpdateMediator class counts the number of each update type, and suggets which one to use, if the code doesn't already have an explicit prefence. Also performs "maintenance refreshes" unprovoked if display is not given an opportunity to before a FULL refresh through organic use.

* chore: update todo list

* fix: rare lock-up of buttons

* refactor: backlight
Replaces the initial proof-of-concept frontlight code for T-Echo
Presses less than 5 seconds momentarily illuminate the display
Presses longer than 5 seconds latch the light, requiring another tap to disable
If user has previously removed the T-Echo's capacitive touch button (some DIY projects), the light is controlled by the on-screen menu. This fallback is used by all T-Echo devices, until a press of the capacitive touch button is detected.

* feat: change tile with aux button
Applied to VM-E290.
Working as is, but a refactor of WindowManager::render is expected shortly, which will also tidy code from this push.

* fix: specify out-of-the-box tile assignments
Prevents placeholder applet showing on initial boot, for devices which use a mult-tile layout by default (VM-E290)

* fix: verify settings version when loading

* fix: wrong settings version

* refactor: remove unimplemented argument from requestUpdate
Specified whether or not to update "async", however the implementation was slightly broken, Applet::requestUpdate is only handled next time WindowManager::runOnce is called. This didn't allow code to actually await an update, which was misleading.

* refactor: renaming
Applet::render becomes Applet::onRender.
Tile::displayedApplet becomes Tile::assignedApplet.
New onRender method name allows us to move some of the pre and post render code from WindowManager into new Applet::render method, which will call onRender for us.

* refactor: rendering
Bit of a tidy-up. No intended change in behavior.

* fix: optimize refresh times
Shorter wait between retrying update if display was previously busy.
Set anticipated update durations closer to observed values. No signifacant performance increase, but does decrease the amount of polling required.

* feat: blocking update for E-Ink
Option to wait for display update to complete before proceeding. Important when shutting down the device.

* refactor: allow system applets to lock rendering
Temporarily prevents other applets from rendering.

* feat: boot and shutdown screens

* feat: BluetoothStatus
Adds a meshtastic::Status object which exposes the state of the Bluetooth connection. Intends to allow decoupling of UI code.

* feat: Bluetooth pairing screen

* fix: InkHUD defaults not honored

* fix: random Bluetooth pin for NicheGraphics UIs

* chore: button interrupts tested

* fix: emoji reactions show as blank messages

* fix: autoshow and notification triggered by outgoing message

* feat: save InkHUD data before reboot
Implemented with a new Observable. Previously, config and a few recent messages were saved on shutdown. These were lost if the device rebooted, for example when firmware settings were changed by a client. Now, the InkHUD config and recent messages saved on reboot, the same as during an intentional shutdown.

* feat: imperial distances
Controlled by the config.display.units setting

* fix: hide features which are not yet implemented

* refactor: faster rendering
Previously, only tiles which requested update were re-rendered. Affected tiles had their region blanked before render, pixel by pixel. Benchmarking revealed that it is significantly faster to memset the framebuffer and redraw all tiles.

* refactor: tile ownership
Tiles and Applets now maintain a reciprocal link, which is enforced by asserts. Less confusing than the old situation, where an applet and a tile may disagree on their relationship. Empty tiles are now identified by a nullptr *Applet, instead of by having the placeholderApplet assigned.

* fix: notifications and battery when menu open
Do render notifications in front of menu; don't render battery icon in front of menu.

* fix: simpler defaults
Don't expose new users to multiplexed applets straight away: make them enable the feature for themselves.

* fix: Inputs::TwoButton interrupts, when only one button in use

* fix: ensure display update is complete when ESP32 enters light sleep
Many panels power down automatically, but some require active intervention from us. If light sleep (ESP32) occurs during a display update, these panels could potentially remain powered on, applying voltage the pixels for an extended period of time, and potentially damaging the display.

* fix: honor per-variant user tile limit
Set as the default value for InkHUD::settings.userTiles.maxCount in nicheGraphics.h

* feat: initial InkHUD support for Wireless Paper v1.1 and VM-E213

* refactor: Heard and Recents Applets
Tidier code, significant speed boost. Possibly no noticable change in responsiveness, but rendering now spends much less time blocking execution, which is important for correction functioning of the other firmware components.

* refactor: use a common pio base config
Easier to make any future PlatformIO config changes

* feat: tips
Show information that we think the user might find helpful. Some info shown first boot only. Other info shown when / if relevant.

* fix: text wrapping for '\n'
Previously, the newline was honored, but the adojining word was not printed.

* Decouple ButtonThread from sleep.cpp
Reorganize sleep observables. Don't call ButtonThread methods inside doLightSleep. Instead, handle in class with new lightsleep Observables.

* feat: BluetoothStatus
Adds a meshtastic::Status object which exposes the state of the Bluetooth connection. Intends to allow decoupling of UI code.

* feat: observable for reboot

* refactor: Heltec VM-E290 installDefaultConfig

* fix: random Bluetooth pin for NicheGraphics UIs
2025-02-11 16:01:17 -06:00
github-actions[bot]
c756bea711 [create-pull-request] automated change (#6037)
Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com>
2025-02-11 11:30:20 -06:00
Ben Meadors
068d529298 2.6 update 2025-02-11 11:27:30 -06:00
Ben Meadors
add75f073a Littlefs per device 2025-02-10 15:14:08 -06:00
Austin
a00e272afe meshtasticd: Add X11 480x480 preset (#6020) 2025-02-10 14:29:45 -06:00
Manuel
48b00188fb Fix T-Deck SD card detection (#6023)
* increase T-Deck PSRAM to avoid too early out-of-memory when messages fill up the storage

* fix SDCard for T-Deck; allow SPI frequency config
2025-02-10 07:41:37 -06:00
mverch67
62058b650a update device-ui lib 2025-02-10 14:10:43 +01:00
mverch67
147416045a increase T-Deck PSRAM to avoid too early out-of-memory when messages fill up the storage 2025-02-10 13:40:35 +01:00
mverch67
72e991104e Merge branch '2.6' of https://github.com/meshtastic/firmware into 2.6 2025-02-09 22:01:59 +01:00
Manuel
26a0612e37 fixed Indicator touch issue (causing IO expander issues), added more RAM (#6013) 2025-02-08 18:06:03 +01:00
mverch67
6cfa5d8f29 update lib 2025-02-08 17:49:32 +01:00
mverch67
2e21e49144 fixed Indicator touch issue (causing IO expander issues), added more RAM 2025-02-08 17:49:16 +01:00
Tom Fifield
aad9e352b7 Merge branch 'master' into 2.6 2025-02-08 20:04:12 +08:00
Ben Meadors
368d811ea6 Exclude unphone tft for now. Something is wonky 2025-02-07 20:07:54 -06:00
Ben Meadors
2996a9616f Add -tft environments to the ci matrix 2025-02-07 19:07:38 -06:00
rcarteraz
99e47cf73c Merge pull request #6007 from meshtastic/update-indicator-speed-again
Update Indicator upload_speed... again
2025-02-07 15:43:16 -07:00
rcarteraz
102c328436 Merge branch '2.6' into update-indicator-speed-again 2025-02-07 15:41:21 -07:00
Ben Meadors
0cd4224033 Un-extra 2025-02-07 16:35:38 -06:00
rcarteraz
20743ae2c4 Merge branch '2.6' into update-indicator-speed-again 2025-02-07 14:09:05 -07:00
rcarteraz
51c5d8ce93 tested higher speed and it works 2025-02-07 14:02:11 -07:00
rcarteraz
b229d351cf Update platformio.ini (#6006) 2025-02-07 14:32:09 -06:00
Ben Meadors
350b82bc08 Version this 2025-02-07 13:32:48 -06:00
Manuel
d21b272680 fancy T-Deck / SenseCAP Indicator / unPhone / PICOmputer-S3 TFT screen (#3259)
* lib update: light theme

* fix merge issue

* lib update: home buttons + button try-fix

* lib update: icon color fix

* lib update: fix instability/crash on notification

* update lib: timezone

* timezone label

* lib update: fix set owner

* fix spiLock in RadioLibInterface

* add picomputer tft build

* picomputer build

* fix compiler error std::find()

* fix merge

* lib update: theme runtime config

* lib update: packet logger + T-Deck Plus

* lib update: mesh detector

* lib update: fix brightness & trackball crash

* try-fix less paranoia

* sensecap indicator updates

* lib update: indicator fix

* lib update: statistic & some fixes

* lib-update: other T-Deck touch driver

* use custom touch driver for Indicator

* lower tft task prio

* prepare LVGL ST7789 driver

* lib update: try-fix audio

* Drop received packets from self

* Additional decoded packet ignores

* Honor flip & color for Heltec T114 and T190 (#4786)

* Honor TFT_MESH color if defined for Heltec T114 or T190

* Temporary: point lib_deps at fork of Heltec's ST7789 library
For demo only, until ST7789 is merged

* Update lib_deps; tidy preprocessor logic

* Download debian files after firmware zip

* set title for protobufs bump PR (#4792)

* set title for version bump PR (#4791)

* Enable Dependabot

* chore: trunk fmt

* fix dependabot syntax (#4795)

* fix dependabot syntax

* Update dependabot.yml

* Update dependabot.yml

* Bump peter-evans/create-pull-request from 6 to 7 in /.github/workflows (#4797)

* Bump docker/build-push-action from 5 to 6 in /.github/workflows (#4800)

* Actions: Semgrep Images have moved from returntocorp to semgrep (#4774)

https://hub.docker.com/r/returntocorp/semgrep notes: "We've moved!
 Official Docker images for Semgrep now available at semgrep/semgrep."

Patch updates our CI workflow for these images.

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>

* Bump meshtestic from `31ee3d9` to `37245b3` (#4799)

Bumps [meshtestic](https://github.com/meshtastic/meshTestic) from `31ee3d9` to `37245b3`.
- [Commits](31ee3d90c8...37245b3d61)

---
updated-dependencies:
- dependency-name: meshtestic
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [create-pull-request] automated change (#4789)

Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com>

* Bump pnpm/action-setup from 2 to 4 in /.github/workflows (#4798)

Bumps [pnpm/action-setup](https://github.com/pnpm/action-setup) from 2 to 4.
- [Release notes](https://github.com/pnpm/action-setup/releases)
- [Commits](https://github.com/pnpm/action-setup/compare/v2...v4)

---
updated-dependencies:
- dependency-name: pnpm/action-setup
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Raspberry Pico2 - needs protos

* Re-order doDeepSleep (#4802)

Make sure PMU sleep takes place before I2C ends

* [create-pull-request] automated change

* heltec-wireless-bridge
requires Proto PR first

* feat: trigger class update when protobufs are changed

* meshtastic/ is a test suite; protobufs/ contains protobufs;

* Update platform-native to pick up portduino crash fix (#4807)

* Hopefully extract and commit to meshtastic.github.io

* CI fixes

* [Board] DIY "t-energy-s3_e22" (#4782)

* New variant "t-energy-s3_e22"

- Lilygo T-Energy-S3
- NanoVHF "Mesh-v1.06-TTGO-T18" board
- Ebyte E22 Series

* add board_level = extra

* Update variant.h

---------

Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com>
Co-authored-by: Tom Fifield <tom@tomfifield.net>

* Consolidate variant build steps (#4806)

* poc: consolidate variant build steps

* use build-variant action

* only checkout once and clean up after run

* Revert "Consolidate variant build steps (#4806)" (#4816)

This reverts commit 9f8d86cb25.

* Make Ublox code more readable (#4727)

* Simplify Ublox code

Ublox comes in a myriad of versions and settings. Presently our
configuration code does a lot of branching based on versions being
or not being present.

This patch adds version detection earlier in the piece and branches
on the set gnssModel instead to create separate setup methods for Ublox 6,
Ublox 7/8/9, and Ublox10.

Additionally, adds a macro to make the code much shorter and more
readable.

* Make trunk happy

* Make trunk happy

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>

* Consider the LoRa header when checking packet length

* Minor fix (#4666)

* Minor fixes

It turns out setting a map value with the index notation causes
an lookup that can be avoided with emplace. Apply this to one line in
the StoreForward module.

Fix also Cppcheck-determined highly minor performance increase by
passing gpiochipname as a const reference :)

The amount of cycles used on this laptop while learning about these
callouts from cppcheck is unlikely to ever be more than the cycles
saved by the fixes ;)

* Update PortduinoGlue.cpp

* Revert "Update classes on protobufs update" (#4824)

* Revert "Update classes on protobufs update"

* remove quotes to fix trunk.

---------

Co-authored-by: Tom Fifield <tom@tomfifield.net>

* Implement optional second I2C bus for NRF52840
Enabled at compile-time if WIRE_INFERFACES_COUNT defined as 2

* Add I2C bus to Heltec T114 header pins
SDA: P0.13
SCL: P0.16

Uses bus 1, leaving bus 0 routed to the unpopulated footprint for the RTC (general future-proofing)

* Tidier macros

* Swap SDA and SCL
SDA=P0.16, SCL=P0.13

* Refactor and consolidate time window logic (#4826)

* Refactor and consolidate windowing logic

* Trunk

* Fixes

* More

* Fix braces and remove unused now variables.

There was a brace in src/mesh/RadioLibInterface.cpp that was breaking
compile on some architectures.

Additionally, there were some brace errors in
src/modules/Telemetry/AirQualityTelemetry.cpp
src/modules/Telemetry/EnvironmentTelemetry.cpp
src/mesh/wifi/WiFiAPClient.cpp

Move throttle include in WifiAPClient.cpp to top.

Add Default.h to sleep.cpp

rest of files just remove unused now variables.

* Remove a couple more meows

---------

Co-authored-by: Tom Fifield <tom@tomfifield.net>

* Rename message length headers and set payload max to 255 (#4827)

* Rename message length headers and set payload max to 255

* Add MESHTASTIC_PKC_OVERHEAD

* compare to MESHTASTIC_HEADER_LENGTH

---------

Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com>

* Check for null before printing debug (#4835)

* fix merge

* try-fix crash

* lib update: fix neighbors

* fix GPIO0 mode after I2S audio

* lib update: audio fix

* lib update: fixes and improvements

* extra

* added ILI9342 (from master)

* device-ui persistency

* review update

* fix request, add handled

* fix merge issue

* fix merge issue

* remove newline

* remove newlines from debug log

* playing with locks; but needs more testing

* diy mesh-tab initial files

* board definition for mesh-tab (not yet used)

* use DISPLAY_SET_RESOLUTION to avoid hw dependency in code

* no telemetry for Indicator

* 16MB partition for Indicator

* 8MB partition for Indicator

* stability: add SPI lock before saving via littleFS

* dummy for config transfer (#5154)

* update indicator (due to compile and linker errors)

* remove faulty partition line

* fix missing include

* update indicator board

* update mesh-tab ILI9143 TFT

* fix naming

* mesh-tab targets

* try: disable duplicate locks

* fix nodeDB erase loop when free mem returns invalid value (0, -1).

* upgrade toolchain for nrf52 to gcc 9.3.1

* try-fix (workaround) T-Deck audio crash

* update mesh-tab tft configs

* set T-Deck audio to unused 48 (mem mclk)

* swap mclk to gpio 21

* update meshtab voltage divider

* update mesh-tab ini

* Fixed the issue that indicator device uploads via rp2040 serial port in some cases.

* Fixed the issue that the touch I2C address definition was not effective.

* Fixed the issue that the wifi configuration saved to RAM did not take effect.

* rotation fix; added ST7789 3.2" display

* dreamcatcher: assign GPIO44 to audio mclk

* mesh-tab touch updates

* add mesh-tab powersave as default

* fix DIO1 wakeup

* mesh-tab: enable alert message menu

* Streamline board definitions for first tech preview. (#5390)

* Streamline board definitions for first tech preview. TBD: Indicator Support

* add point-of-checkin

* use board/unphone.json

---------

Co-authored-by: mverch67 <manuel.verch@gmx.de>

* fix native targets

* add RadioLib debugging options for (T-Deck)

* fix T-Deck build

* fix native tft targets for rpi

* remove wrong debug defines

* t-deck-tft button is handled in device-ui

* disable default lightsleep for indicator

* Windows Support - Trunk and Platformio (#5397)

* Add support for GPG

* Add usb device support

* Add trunk.io to devcontainer

* Trunk things

* trunk fmt

* formatting

* fix trivy/DS002, checkov/CKV_DOCKER_3

* hide docker extension popup

* fix trivy/DS026, checkov/CKV_DOCKER_2

* fix radioLib warnings for T-Deck target

* wake screen with button only

* use custom touch driver

* define wake button for unphone

* use board definition for mesh-tab

* mesh-tab rotation upside-down

* update platform native

* use MESH_TAB hardware model definition

* radioLib update (fix crash/assert)

* reference seeed indicator fix commit arduino-esp32

* Remove unneeded file change :)

* disable serial module and tcp socket api for standalone devices (#5591)

* disable serial module and tcp socket api for standalone devices
* just disable webserver, leave wifi available
* disable socket api

* mesh-tab: lower I2C touch frequency

* log error when packet queue is full

* add more locking for shared SPI devices (#5595)

* add more locking for shared SPI devices
* call initSPI before the lock is used
* remove old one
* don't double lock
* Add missing unlock
* More missing unlocks
* Add locks to SafeFile, remove from `readcb`, introduce some LockGuards
* fix lock in setupSDCard()
* pull radiolib trunk with SPI-CS fixes
* change ContentHandler to Constructor type locks, where applicable

---------

Co-authored-by: mverch67 <manuel.verch@gmx.de>
Co-authored-by: GUVWAF <thijs@havinga.eu>
Co-authored-by: Manuel <71137295+mverch67@users.noreply.github.com>

* T-Deck: revert back to lovyanGFX touch driver

* T-Deck: increase allocated PSRAM by 50%

* mesh-tab: streamline target definitions

* update RadioLib 7.1.2

* mesh-tab: fix touch rotation 4.0 inch display

* Mesh-Tab platformio: 4.0inch: increase SPI frequency to max

* mesh-tab: fix rotation for 3.5 IPS capacitive display

* mesh-tab: fix rotation for 3.2 IPS capacitive display

* restructure device-ui library into sub-directories

* preparations for generic DisplayDriverFactory

* T-Deck: increase LVGL memory size

* update lib

* trunk fmt

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
Co-authored-by: todd-herbert <herbert.todd@gmail.com>
Co-authored-by: Jason Murray <15822260+scruplelesswizard@users.noreply.github.com>
Co-authored-by: Jason Murray <jason@chaosaffe.io>
Co-authored-by: Tom Fifield <tom@tomfifield.net>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com>
Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com>
Co-authored-by: Jonathan Bennett <jbennett@incomsystems.biz>
Co-authored-by: Austin <vidplace7@gmail.com>
Co-authored-by: virgil <virgil.wang.cj@gmail.com>
Co-authored-by: Mark Trevor Birss <markbirss@gmail.com>
Co-authored-by: Kalle Lilja <15094562+ThatKalle@users.noreply.github.com>
Co-authored-by: GUVWAF <thijs@havinga.eu>
2025-02-07 13:05:17 -06:00
mverch67
fe5d251393 fix "native" compiler errors/warnings NodeDB.h 2025-02-07 18:09:46 +01:00
Ben Meadors
66a98fb062 2.6 <- Next hop router (#6005)
* Initial version of NextHopRouter

* Set original hop limit in header flags

* Short-circuit to FloodingRouter for broadcasts

* If packet traveled 1 hop, set `relay_node` as `next_hop` for the original transmitter

* Set last byte to 0xFF if it ended at 0x00
As per an idea of @S5NC

* Also update next-hop based on received DM for us

* temp

* Add 1 retransmission for intermediate hops when using NextHopRouter

* Add next_hop and relayed_by in PacketHistory for setting next-hop and handle flooding fallback

* Update protos, store multiple relayers

* Remove next-hop update logic from NeighborInfoModule

* Fix retransmissions

* Improve ACKs for repeated packets and responses

* Stop retransmission even if there's not relay node

* Revert perhapsRebroadcast()

* Remove relayer if we cancel a transmission

* Better checking for fallback to flooding

* Fix newlines in traceroute print logs

* Stop retransmission for original packet

* Use relayID

* Also when want_ack is set, we should try to retransmit

* Fix cppcheck error

* Fix 'router' not in scope error

* Fix another cppcheck error

* Check for hop_limit and also update next hop when `hop_start == hop_limit` on ACK
Also check for broadcast in `getNextHop()`

* Formatting and correct NUM_RETRANSMISSIONS

* Update protos

* Start retransmissions in NextHopRouter if ReliableRouter didn't do it

* Handle repeated/fallback to flooding packets properly
First check if it's not still in the TxQueue

* Guard against clients setting `next_hop`/`relay_node`

* Don't cancel relay if we were the assigned next-hop

* Replies (e.g. tapback emoji) are also a valid confirmation of receipt

---------

Co-authored-by: GUVWAF <thijs@havinga.eu>
Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com>
Co-authored-by: Tom Fifield <tom@tomfifield.net>
Co-authored-by: GUVWAF <78759985+GUVWAF@users.noreply.github.com>
2025-02-07 06:29:36 -06:00
Ben Meadors
d65d9305d3 Merge branch 'master' into 2.6 2025-02-07 06:03:13 -06:00
github-actions[bot]
34e5cf0d96 [create-pull-request] automated change (#6002)
Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com>
2025-02-06 20:26:27 -06:00
Ben Meadors
b28db07409 Back to 80 2025-02-06 20:01:18 -06:00
Ben Meadors
f753caf15d Update ref 2025-02-06 20:00:56 -06:00
github-actions[bot]
0c1838dde7 [create-pull-request] automated change (#6000)
Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com>
2025-02-06 14:55:39 -06:00
Ben Meadors
b183febd3c Merge remote-tracking branch 'origin/master' into 2.6 2025-02-06 14:20:46 -06:00
Ben Meadors
87601f4760 File system persistence fixes 2025-01-12 19:03:21 -06:00
GUVWAF
0e3c419652 Explicitly set CAD symbols, improve slot time calculation and adjust CW size accordingly (#5772) 2025-01-12 17:52:35 +01:00
Ben Meadors
891bf643e2 Remove logging statement no longer needed 2025-01-12 09:13:14 -06:00
Ben Meadors
143cdf4572 Make NodeDatabase (and file) independent of DeviceState (#5813)
* Make NodeDatabase (and file) independent of DeviceState

* 70
2025-01-11 09:02:05 -06:00
Ben Meadors
d440dbd522 Hello world support for UDP broadcasts over the LAN on ESP32 (#5779)
* UDP local area network meshing on ESP32

* Logs

* Comment

* Update UdpMulticastThread.h

* Changes

* Only use router->send
2025-01-11 09:01:49 -06:00
Ben Meadors
7e063c1dda Merge branch 'master' into 2.6 2025-01-10 06:27:18 -06:00
github-actions[bot]
988d8cd1ab [create-pull-request] automated change (#5789)
Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com>
2025-01-07 20:44:52 -06:00
Ben Meadors
c98c682cff Merge branch 'master' into 2.6 2025-01-07 20:39:51 -06:00
Ben Meadors
8023fec0ec 2.6 protos 2025-01-07 19:58:00 -06:00
7 changed files with 171 additions and 35 deletions

View File

@@ -7,16 +7,23 @@ static File openFile(const char *filename, bool fullAtomic)
{ {
concurrency::LockGuard g(spiLock); concurrency::LockGuard g(spiLock);
LOG_DEBUG("Opening %s, fullAtomic=%d", filename, fullAtomic); LOG_DEBUG("Opening %s, fullAtomic=%d", filename, fullAtomic);
#ifdef ARCH_NRF52 #ifdef ARCH_NRF52
FSCom.remove(filename); FSCom.remove(filename);
return FSCom.open(filename, FILE_O_WRITE); return FSCom.open(filename, FILE_O_WRITE);
#endif #endif
if (!fullAtomic) if (!fullAtomic) {
FSCom.remove(filename); // Nuke the old file to make space (ignore if it !exists) FSCom.remove(filename); // Nuke the old file to make space (ignore if it !exists)
}
String filenameTmp = filename; String filenameTmp = filename;
filenameTmp += ".tmp"; filenameTmp += ".tmp";
// If we are doing a full atomic write, remove the old tmp file now
if (fullAtomic) {
FSCom.remove(filename);
}
// clear any previous LFS errors // clear any previous LFS errors
return FSCom.open(filenameTmp.c_str(), FILE_O_WRITE); return FSCom.open(filenameTmp.c_str(), FILE_O_WRITE);
} }

View File

@@ -117,17 +117,13 @@ void MeshService::loop()
} }
/// The radioConfig object just changed, call this to force the hw to change to the new settings /// The radioConfig object just changed, call this to force the hw to change to the new settings
bool MeshService::reloadConfig(int saveWhat) void MeshService::reloadConfig(int saveWhat)
{ {
// If we can successfully set this radio to these settings, save them to disk
// This will also update the region as needed // This will also update the region as needed
bool didReset = nodeDB->resetRadioConfig(); // Don't let the phone send us fatally bad settings nodeDB->resetRadioConfig(); // Don't let the phone send us fatally bad settings
configChanged.notifyObservers(NULL); // This will cause radio hardware to change freqs etc configChanged.notifyObservers(NULL); // This will cause radio hardware to change freqs etc
nodeDB->saveToDisk(saveWhat); nodeDB->saveToDisk(saveWhat);
return didReset;
} }
/// The owner User record just got updated, update our node DB and broadcast the info into the mesh /// The owner User record just got updated, update our node DB and broadcast the info into the mesh

View File

@@ -118,7 +118,7 @@ class MeshService
/** The radioConfig object just changed, call this to force the hw to change to the new settings /** The radioConfig object just changed, call this to force the hw to change to the new settings
* @return true if client devices should be sent a new set of radio configs * @return true if client devices should be sent a new set of radio configs
*/ */
bool reloadConfig(int saveWhat = SEGMENT_CONFIG | SEGMENT_MODULECONFIG | SEGMENT_DEVICESTATE | SEGMENT_CHANNELS); void reloadConfig(int saveWhat = SEGMENT_CONFIG | SEGMENT_MODULECONFIG | SEGMENT_DEVICESTATE | SEGMENT_CHANNELS);
/// The owner User record just got updated, update our node DB and broadcast the info into the mesh /// The owner User record just got updated, update our node DB and broadcast the info into the mesh
void reloadOwner(bool shouldSave = true); void reloadOwner(bool shouldSave = true);

View File

@@ -400,36 +400,20 @@ bool isBroadcast(uint32_t dest)
return dest == NODENUM_BROADCAST || dest == NODENUM_BROADCAST_NO_LORA; return dest == NODENUM_BROADCAST || dest == NODENUM_BROADCAST_NO_LORA;
} }
bool NodeDB::resetRadioConfig(bool factory_reset, bool is_fresh_install) void NodeDB::resetRadioConfig(bool is_fresh_install)
{ {
bool didFactoryReset = false;
if (is_fresh_install) { if (is_fresh_install) {
radioGeneration++; radioGeneration++;
} }
if (factory_reset) {
didFactoryReset = factoryReset();
}
if (channelFile.channels_count != MAX_NUM_CHANNELS) { if (channelFile.channels_count != MAX_NUM_CHANNELS) {
LOG_INFO("Set default channel and radio preferences!"); LOG_INFO("Set default channel and radio preferences!");
channels.initDefaults(); channels.initDefaults();
} }
channels.onConfigChanged(); channels.onConfigChanged();
// Update the global myRegion // Update the global myRegion
initRegion(); initRegion();
if (didFactoryReset) {
LOG_INFO("Reboot due to factory reset");
screen->startAlert("Rebooting...");
rebootAtMsec = millis() + (5 * 1000);
}
return didFactoryReset;
} }
bool NodeDB::factoryReset(bool eraseBleBonds) bool NodeDB::factoryReset(bool eraseBleBonds)
@@ -591,7 +575,7 @@ void NodeDB::installDefaultConfig(bool preserveKey = false)
config.device.node_info_broadcast_secs = default_node_info_broadcast_secs; config.device.node_info_broadcast_secs = default_node_info_broadcast_secs;
config.security.serial_enabled = true; config.security.serial_enabled = true;
config.security.admin_channel_enabled = false; config.security.admin_channel_enabled = false;
resetRadioConfig(false, true); // This also triggers NodeInfo/Position requests since we're fresh resetRadioConfig(true); // This also triggers NodeInfo/Position requests since we're fresh
strncpy(config.network.ntp_server, "meshtastic.pool.ntp.org", 32); strncpy(config.network.ntp_server, "meshtastic.pool.ntp.org", 32);
#if (defined(T_DECK) || defined(T_WATCH_S3) || defined(UNPHONE) || defined(PICOMPUTER_S3) || defined(SENSECAP_INDICATOR)) && \ #if (defined(T_DECK) || defined(T_WATCH_S3) || defined(UNPHONE) || defined(PICOMPUTER_S3) || defined(SENSECAP_INDICATOR)) && \
@@ -1047,6 +1031,9 @@ void NodeDB::loadFromDisk()
if (devicestate.version < DEVICESTATE_MIN_VER) { if (devicestate.version < DEVICESTATE_MIN_VER) {
LOG_WARN("Devicestate %d is old, discard", devicestate.version); LOG_WARN("Devicestate %d is old, discard", devicestate.version);
installDefaultDeviceState(); installDefaultDeviceState();
} else if (state != LoadFileResult::LOAD_SUCCESS) {
// If we have an owner in the backup, restore it
restorePreferences(meshtastic_AdminMessage_BackupLocation_FLASH, SEGMENT_DEVICESTATE);
} else { } else {
LOG_INFO("Loaded saved devicestate version %d", devicestate.version); LOG_INFO("Loaded saved devicestate version %d", devicestate.version);
} }
@@ -1055,6 +1042,7 @@ void NodeDB::loadFromDisk()
&config); &config);
if (state != LoadFileResult::LOAD_SUCCESS) { if (state != LoadFileResult::LOAD_SUCCESS) {
installDefaultConfig(); // Our in RAM copy might now be corrupt installDefaultConfig(); // Our in RAM copy might now be corrupt
restorePreferences(meshtastic_AdminMessage_BackupLocation_FLASH, SEGMENT_CONFIG);
} else { } else {
if (config.version < DEVICESTATE_MIN_VER) { if (config.version < DEVICESTATE_MIN_VER) {
LOG_WARN("config %d is old, discard", config.version); LOG_WARN("config %d is old, discard", config.version);
@@ -1064,7 +1052,7 @@ void NodeDB::loadFromDisk()
} }
} }
if (backupSecurity.private_key.size > 0) { if (backupSecurity.private_key.size > 0) {
LOG_DEBUG("Restoring backup of security config"); LOG_DEBUG("Restoring security config");
config.security = backupSecurity; config.security = backupSecurity;
saveToDisk(SEGMENT_CONFIG); saveToDisk(SEGMENT_CONFIG);
} }
@@ -1124,6 +1112,7 @@ void NodeDB::loadFromDisk()
&meshtastic_LocalModuleConfig_msg, &moduleConfig); &meshtastic_LocalModuleConfig_msg, &moduleConfig);
if (state != LoadFileResult::LOAD_SUCCESS) { if (state != LoadFileResult::LOAD_SUCCESS) {
installDefaultModuleConfig(); // Our in RAM copy might now be corrupt installDefaultModuleConfig(); // Our in RAM copy might now be corrupt
restorePreferences(meshtastic_AdminMessage_BackupLocation_FLASH, SEGMENT_MODULECONFIG);
} else { } else {
if (moduleConfig.version < DEVICESTATE_MIN_VER) { if (moduleConfig.version < DEVICESTATE_MIN_VER) {
LOG_WARN("moduleConfig %d is old, discard", moduleConfig.version); LOG_WARN("moduleConfig %d is old, discard", moduleConfig.version);
@@ -1137,6 +1126,7 @@ void NodeDB::loadFromDisk()
&channelFile); &channelFile);
if (state != LoadFileResult::LOAD_SUCCESS) { if (state != LoadFileResult::LOAD_SUCCESS) {
installDefaultChannels(); // Our in RAM copy might now be corrupt installDefaultChannels(); // Our in RAM copy might now be corrupt
restorePreferences(meshtastic_AdminMessage_BackupLocation_FLASH, SEGMENT_CHANNELS);
} else { } else {
if (channelFile.version < DEVICESTATE_MIN_VER) { if (channelFile.version < DEVICESTATE_MIN_VER) {
LOG_WARN("channelFile %d is old, discard", channelFile.version); LOG_WARN("channelFile %d is old, discard", channelFile.version);
@@ -1252,8 +1242,18 @@ bool NodeDB::saveToDiskNoRetry(int saveWhat)
config.has_network = true; config.has_network = true;
config.has_bluetooth = true; config.has_bluetooth = true;
config.has_security = true; config.has_security = true;
LOG_DEBUG("Saving config version %d", config.version);
success &= saveProto(configFileName, meshtastic_LocalConfig_size, &meshtastic_LocalConfig_msg, &config); #ifndef ARCH_NRF52
// First, remove the temp file if it exists
spiLock->lock();
std::string tempFileName = std::string(configFileName) + ".tmp";
FSCom.remove(tempFileName.c_str());
spiLock->unlock();
#endif
size_t configSize;
pb_get_encoded_size(&configSize, meshtastic_LocalConfig_fields, &config);
success &= saveProto(configFileName, configSize, &meshtastic_LocalConfig_msg, &config);
} }
if (saveWhat & SEGMENT_MODULECONFIG) { if (saveWhat & SEGMENT_MODULECONFIG) {
@@ -1269,9 +1269,18 @@ bool NodeDB::saveToDiskNoRetry(int saveWhat)
moduleConfig.has_ambient_lighting = true; moduleConfig.has_ambient_lighting = true;
moduleConfig.has_audio = true; moduleConfig.has_audio = true;
moduleConfig.has_paxcounter = true; moduleConfig.has_paxcounter = true;
LOG_DEBUG("Saving moduleConfig version %d", moduleConfig.version);
success &= #ifndef ARCH_NRF52
saveProto(moduleConfigFileName, meshtastic_LocalModuleConfig_size, &meshtastic_LocalModuleConfig_msg, &moduleConfig); // First, remove the temp file if it exists
spiLock->lock();
std::string tempFileName = std::string(configFileName) + ".tmp";
FSCom.remove(tempFileName.c_str());
spiLock->unlock();
#endif
size_t moduleConfigSize;
pb_get_encoded_size(&moduleConfigSize, meshtastic_LocalModuleConfig_fields, &moduleConfig);
success &= saveProto(moduleConfigFileName, moduleConfigSize, &meshtastic_LocalModuleConfig_msg, &moduleConfig);
} }
if (saveWhat & SEGMENT_CHANNELS) { if (saveWhat & SEGMENT_CHANNELS) {
@@ -1612,6 +1621,94 @@ UserLicenseStatus NodeDB::getLicenseStatus(uint32_t nodeNum)
return info->user.is_licensed ? UserLicenseStatus::Licensed : UserLicenseStatus::NotLicensed; return info->user.is_licensed ? UserLicenseStatus::Licensed : UserLicenseStatus::NotLicensed;
} }
bool NodeDB::backupPreferences(meshtastic_AdminMessage_BackupLocation location)
{
bool success = false;
lastBackupAttempt = millis();
#ifdef FSCom
if (location == meshtastic_AdminMessage_BackupLocation_FLASH) {
meshtastic_BackupPreferences backup = meshtastic_BackupPreferences_init_zero;
backup.version = DEVICESTATE_CUR_VER;
backup.timestamp = getValidTime(RTCQuality::RTCQualityDevice, false);
backup.has_config = true;
backup.config = config;
backup.has_module_config = true;
backup.module_config = moduleConfig;
backup.has_channels = true;
backup.channels = channelFile;
backup.has_owner = true;
backup.owner = owner;
size_t backupSize;
pb_get_encoded_size(&backupSize, meshtastic_BackupPreferences_fields, &backup);
spiLock->lock();
FSCom.mkdir("/backups");
spiLock->unlock();
success = saveProto(backupFileName, backupSize, &meshtastic_BackupPreferences_msg, &backup);
if (success) {
LOG_INFO("Saved backup preferences");
} else {
LOG_ERROR("Failed to save backup preferences to file");
}
} else if (location == meshtastic_AdminMessage_BackupLocation_SD) {
// TODO: After more mainline SD card support
}
#endif
return success;
}
bool NodeDB::restorePreferences(meshtastic_AdminMessage_BackupLocation location, int restoreWhat)
{
bool success = false;
#ifdef FSCom
if (location == meshtastic_AdminMessage_BackupLocation_FLASH) {
spiLock->lock();
if (!FSCom.exists(backupFileName)) {
spiLock->unlock();
LOG_WARN("Could not restore. No backup file found");
return false;
} else {
spiLock->unlock();
}
meshtastic_BackupPreferences backup = meshtastic_BackupPreferences_init_zero;
success = loadProto(backupFileName, meshtastic_BackupPreferences_size, sizeof(meshtastic_BackupPreferences),
&meshtastic_BackupPreferences_msg, &backup);
if (success) {
if (restoreWhat & SEGMENT_CONFIG) {
config = backup.config;
LOG_DEBUG("Restored config");
}
if (restoreWhat & SEGMENT_MODULECONFIG) {
moduleConfig = backup.module_config;
LOG_DEBUG("Restored module config");
}
if (restoreWhat & SEGMENT_DEVICESTATE) {
devicestate.owner = backup.owner;
LOG_DEBUG("Restored device state");
}
if (restoreWhat & SEGMENT_CHANNELS) {
channelFile = backup.channels;
LOG_DEBUG("Restored channels");
}
success = saveToDisk(restoreWhat);
if (success) {
LOG_INFO("Restored preferences from backup");
} else {
LOG_ERROR("Failed to save restored preferences to flash");
}
} else {
LOG_ERROR("Failed to restore preferences from backup file");
}
} else if (location == meshtastic_AdminMessage_BackupLocation_SD) {
// TODO: After more mainline SD card support
}
return success;
#endif
}
/// Record an error that should be reported via analytics /// Record an error that should be reported via analytics
void recordCriticalError(meshtastic_CriticalErrorCode code, uint32_t address, const char *filename) void recordCriticalError(meshtastic_CriticalErrorCode code, uint32_t address, const char *filename)
{ {

View File

@@ -48,6 +48,7 @@ static constexpr const char *configFileName = "/prefs/config.proto";
static constexpr const char *uiconfigFileName = "/prefs/uiconfig.proto"; static constexpr const char *uiconfigFileName = "/prefs/uiconfig.proto";
static constexpr const char *moduleConfigFileName = "/prefs/module.proto"; static constexpr const char *moduleConfigFileName = "/prefs/module.proto";
static constexpr const char *channelFileName = "/prefs/channels.proto"; static constexpr const char *channelFileName = "/prefs/channels.proto";
static constexpr const char *backupFileName = "/backups/backup.proto";
/// Given a node, return how many seconds in the past (vs now) that we last heard from it /// Given a node, return how many seconds in the past (vs now) that we last heard from it
uint32_t sinceLastSeen(const meshtastic_NodeInfoLite *n); uint32_t sinceLastSeen(const meshtastic_NodeInfoLite *n);
@@ -98,12 +99,10 @@ class NodeDB
/** Reinit radio config if needed, because either: /** Reinit radio config if needed, because either:
* a) sometimes a buggy android app might send us bogus settings or * a) sometimes a buggy android app might send us bogus settings or
* b) the client set factory_reset * b) the client set factory_reset
*
* @param factory_reset if true, reset all settings to factory defaults
* @param is_fresh_install set to true after a fresh install, to trigger NodeInfo/Position requests * @param is_fresh_install set to true after a fresh install, to trigger NodeInfo/Position requests
* @return true if the config was completely reset, in that case, we should send it back to the client * @return true if the config was completely reset, in that case, we should send it back to the client
*/ */
bool resetRadioConfig(bool factory_reset = false, bool is_fresh_install = false); void resetRadioConfig(bool factory_reset = false);
/// given a subpacket sniffed from the network, update our DB state /// given a subpacket sniffed from the network, update our DB state
/// we updateGUI and updateGUIforNode if we think our this change is big enough for a redraw /// we updateGUI and updateGUIforNode if we think our this change is big enough for a redraw
@@ -202,8 +201,14 @@ class NodeDB
bool hasValidPosition(const meshtastic_NodeInfoLite *n); bool hasValidPosition(const meshtastic_NodeInfoLite *n);
// bool shouldAutoPerformBackup();
bool backupPreferences(meshtastic_AdminMessage_BackupLocation location);
bool restorePreferences(meshtastic_AdminMessage_BackupLocation location,
int restoreWhat = SEGMENT_CONFIG | SEGMENT_MODULECONFIG | SEGMENT_DEVICESTATE | SEGMENT_CHANNELS);
private: private:
uint32_t lastNodeDbSave = 0; // when we last saved our db to flash uint32_t lastNodeDbSave = 0; // when we last saved our db to flash
uint32_t lastBackupAttempt = 0; // when we last tried a backup automatically or manually
/// Find a node in our DB, create an empty NodeInfoLite if missing /// Find a node in our DB, create an empty NodeInfoLite if missing
meshtastic_NodeInfoLite *getOrCreateMeshNode(NodeNum n); meshtastic_NodeInfoLite *getOrCreateMeshNode(NodeNum n);

View File

@@ -370,6 +370,37 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
LOG_DEBUG("Failed to delete file"); LOG_DEBUG("Failed to delete file");
} }
spiLock->unlock(); spiLock->unlock();
#endif
break;
}
case meshtastic_AdminMessage_backup_preferences_tag: {
LOG_INFO("Client requesting to backup preferences");
if (nodeDB->backupPreferences(r->backup_preferences)) {
myReply = allocErrorResponse(meshtastic_Routing_Error_NONE, &mp);
} else {
myReply = allocErrorResponse(meshtastic_Routing_Error_BAD_REQUEST, &mp);
}
break;
}
case meshtastic_AdminMessage_restore_preferences_tag: {
LOG_INFO("Client requesting to restore preferences");
if (nodeDB->restorePreferences(r->backup_preferences,
SEGMENT_DEVICESTATE | SEGMENT_CONFIG | SEGMENT_MODULECONFIG | SEGMENT_CHANNELS)) {
myReply = allocErrorResponse(meshtastic_Routing_Error_NONE, &mp);
LOG_DEBUG("Rebooting after successful restore of preferences");
reboot(1000);
disableBluetooth();
} else {
myReply = allocErrorResponse(meshtastic_Routing_Error_BAD_REQUEST, &mp);
}
break;
}
case meshtastic_AdminMessage_remove_backup_preferences_tag: {
LOG_INFO("Client requesting to remove backup preferences");
#ifdef FSCom
spiLock->lock();
FSCom.remove(backupFileName);
spiLock->unlock();
#endif #endif
break; break;
} }