mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-14 06:42:34 +00:00
Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
651b13b3e5 | ||
|
|
951f5d11d5 | ||
|
|
2ce95ed2ce | ||
|
|
d1b7b6c5c5 | ||
|
|
425c570757 | ||
|
|
46dab2d496 | ||
|
|
f5271f5c79 | ||
|
|
375804c9e4 | ||
|
|
fe5703c684 | ||
|
|
f1c90a232f | ||
|
|
a91fba763a | ||
|
|
28588f6730 | ||
|
|
d074218049 | ||
|
|
1f07d6735b | ||
|
|
bb0b2e72c8 | ||
|
|
30c717ac2f | ||
|
|
e01680cd4b | ||
|
|
4bb308c80c | ||
|
|
12a68026e7 | ||
|
|
06449e39c1 | ||
|
|
cc6a8c8430 | ||
|
|
9aedec2c5c | ||
|
|
2221ddfca2 | ||
|
|
7dc6264fa7 | ||
|
|
f091a9505a | ||
|
|
57d5a54099 | ||
|
|
045a2031a3 | ||
|
|
0b8d7768fd | ||
|
|
c41f572cf5 | ||
|
|
bf26994d4e | ||
|
|
30ff67d46a | ||
|
|
65e6d029e0 | ||
|
|
31e9d34d1e | ||
|
|
0a796c4937 |
19
.github/workflows/main.yml
vendored
Normal file
19
.github/workflows/main.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
name: Continuous Integration
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
main:
|
||||
name: Main
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@master
|
||||
with:
|
||||
python-version: 3.x
|
||||
- name: Install Platform IO
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -U platformio
|
||||
- name: Build
|
||||
run: platformio run
|
||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "proto"]
|
||||
path = proto
|
||||
url = https://github.com/meshtastic/Meshtastic-protobufs.git
|
||||
15
README.md
15
README.md
@@ -1,6 +1,8 @@
|
||||
# Meshtastic-esp32
|
||||
This is the device side code for the [meshtastic.org](https://www.meshtastic.org) project.
|
||||
|
||||

|
||||
|
||||
Meshtastic is a project that lets you use
|
||||
inexpensive GPS mesh radios as an extensible, super long battery life mesh GPS communicator. These radios are great for hiking, skiing, paragliding -
|
||||
essentially any hobby where you don't have reliable internet access. Each member of your private mesh can always see the location and distance of all other
|
||||
@@ -16,14 +18,14 @@ This project is currently early-alpha, but if you have questions please join our
|
||||
This software is 100% open source and developed by a group of hobbyist experimenters. No warranty is provided, if you'd like to improve it - we'd love your help. Please post in the chat.
|
||||
|
||||
## Supported hardware
|
||||
We currently support two brands of radios. The [TTGO T-Beam](https://www.aliexpress.com/item/4000119152086.html) and the [Heltec LoRa 32](https://heltec.org/project/wifi-lora-32/). Most users should buy the T-Beam and a 18650 battery (total cost less than $35). Make
|
||||
We currently support three models of radios. The [TTGO T-Beam](https://www.aliexpress.com/item/4000119152086.html), [TTGO LORA32](https://www.banggood.com/LILYGO-TTGO-LORA32-868Mhz-SX1276-ESP32-Oled-Display-bluetooth-WIFI-Lora-Development-Module-Board-p-1248652.html?cur_warehouse=UK) and the [Heltec LoRa 32](https://heltec.org/project/wifi-lora-32/). Most users should buy the T-Beam and a 18650 battery (total cost less than $35). Make
|
||||
sure to buy the frequency range which is legal for your country. For the USA, you should buy the 915MHz version. Getting a version that include a screen
|
||||
is optional, but highly recommended.
|
||||
|
||||
See (meshtastic.org) for 3D printable cases.
|
||||
|
||||
## Installing the firmware
|
||||
Prebuilt binaries for the supported radios is available in our [releases](https://github.com/geeksville/Meshtastic-esp32/releases). Your initial installation has to happen over USB from your Mac, Windows or Linux PC. Once our software is installed, all future software updates happen over bluetooth from your phone.
|
||||
Prebuilt binaries for the supported radios is available in our [releases](https://github.com/meshtastic/Meshtastic-esp32/releases). Your initial installation has to happen over USB from your Mac, Windows or Linux PC. Once our software is installed, all future software updates happen over bluetooth from your phone.
|
||||
|
||||
The instructions currently require a few commmand lines, but it should be pretty straightforward. Please post comments on our group chat if you have problems or successes. Steps to install:
|
||||
|
||||
@@ -31,7 +33,7 @@ The instructions currently require a few commmand lines, but it should be pretty
|
||||
2. Install "pip". Pip is the python package manager we use to get the esptool installer app. Instructions [here](https://www.makeuseof.com/tag/install-pip-for-python/).
|
||||
3. Run "pip install --upgrade esptool" to get esptool installed on your machine
|
||||
4. Connect your radio to your USB port
|
||||
5. Confirm that your device is talking to your PC by running "esptool.py chip_id". You should see something like:
|
||||
5. Confirm that your device is talking to your PC by running "esptool.py chip_id". The Heltec build also works on the TTGO LORA32 radio. You should see something like:
|
||||
```
|
||||
mydir$ esptool.py chip_id
|
||||
esptool.py v2.6
|
||||
@@ -76,8 +78,11 @@ Hard resetting via RTS pin...
|
||||
8. Please post a comment on our chat so we know if these instructions worked for you ;-). If you find bugs/have-questions post there also - we will be rapidly iterating over the next few weeks.
|
||||
|
||||
## Meshtastic Android app
|
||||
The source code for the (optional) Meshtastic Android app is [here](https://github.com/geeksville/Meshtastic-Android).
|
||||
Soon our first alpha release of will be released here:
|
||||
The source code for the (optional) Meshtastic Android app is [here](https://github.com/meshtastic/Meshtastic-Android).
|
||||
|
||||
Alpha test builds are current available by opting into our alpha test group. See (www.meshtastic.org) for instructions.
|
||||
|
||||
After our rate of change slows a bit, we will make beta builds available here (without needing to join the alphatest group):
|
||||
[](https://play.google.com/store/apps/details?id=com.geeksville.mesh&referrer=utm_source%3Dgithub%26utm_medium%3Desp32-readme%26utm_campaign%3Dmeshtastic-esp32%2520readme%26anid%3Dadmob&pcampaignid=pcampaignidMKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1)
|
||||
|
||||
# Development
|
||||
|
||||
99
TODO.md
99
TODO.md
@@ -2,88 +2,82 @@
|
||||
|
||||
Items to complete soon (next couple of alpha releases).
|
||||
|
||||
* text messages are not showing on local screen if screen was on
|
||||
|
||||
* The following three items are all the same:
|
||||
Have state machine properly enter deep sleep based on loss of mesh and phone comms.
|
||||
Default to enter deep sleep if no LORA received for two hours (indicates user has probably left the mesh).
|
||||
If the phone doesn't read fromradio mailbox within X seconds, assume the phone is gone and we can stop queing location msgs
|
||||
for it (because it will redownload the nodedb when it comes back)
|
||||
|
||||
* lower wait_bluetooth_secs to 30 seconds once we have the GPS power on (but GPS in sleep mode) across light sleep. For the time
|
||||
being I have it set at 2 minutes to ensure enough time for a GPS lock from scratch.
|
||||
|
||||
* retest BLE software update for both board types
|
||||
* report on wikifactory
|
||||
* send note to the guy who designed the cases
|
||||
* use gps sleep mode instead of killing its power (to allow fast position when we wake)
|
||||
* enable fast lock and low power inside the gps chip
|
||||
* remeasure wake time power draws now that we run CPU down at 80MHz
|
||||
|
||||
# AXP192 tasks
|
||||
* "AXP192 interrupt is not firing, remove this temporary polling of battery state"
|
||||
* make debug info screen show real data (including battery level & charging) - close corresponding github issue
|
||||
|
||||
# Medium priority
|
||||
|
||||
Items to complete before the first beta release.
|
||||
|
||||
* Make a FAQ
|
||||
* good source of battery/signal/gps icons https://materialdesignicons.com/
|
||||
* investigate changing routing to https://github.com/sudomesh/LoRaLayer2 ?
|
||||
* check fcc rules on duty cycle. we might not need to freq hop. https://www.sunfiretesting.com/LoRa-FCC-Certification-Guide/
|
||||
* use fuse bits to store the board type and region. So one load can be used on all boards
|
||||
* "AXP192 interrupt is not firing, remove this temporary polling of battery state"
|
||||
* make mesh aware network timing state machine (sync wake windows to gps time)
|
||||
* turn light sleep on aggressively (while lora is on but BLE off)
|
||||
* research and implement better mesh algorithm
|
||||
* the BLE stack is leaking about 200 bytes each time we go to light sleep
|
||||
* use gps sleep mode instead of killing its power (to allow fast position when we wake)
|
||||
* rx signal measurements -3 marginal, -9 bad, 10 great, -10 means almost unusable. So scale this into % signal strength. preferably as a graph, with an X indicating loss of comms.
|
||||
* assign every "channel" a random shared 8 bit sync word (per 4.2.13.6 of datasheet) - use that word to filter packets before even checking CRC. This will ensure our CPU will only wake for packets on our "channel"
|
||||
* Note: we do not do address filtering at the chip level, because we might need to route for the mesh
|
||||
* Use the Periodic class for both position and user periodic broadcasts
|
||||
* make debug info screen show real data (including battery level & charging)
|
||||
* don't forward redundant pings or ping responses to the phone, it just wastes phone battery
|
||||
* don't treat north as up, instead adjust shown bearings for our guess at the users heading (i.e. subtract one from the other)
|
||||
* answer to pings (because some other user is looking at our nodeinfo) with our latest location
|
||||
* show radio and gps signal strength as an image
|
||||
* only BLE advertise for a short time after the screen is on and button pressed - to save power and prevent people for sniffing for our BT app.
|
||||
* use https://platformio.org/lib/show/1260/OneButton if necessary
|
||||
* make an about to sleep screen
|
||||
* don't send location packets if we haven't moved
|
||||
* scrub default radio config settings for bandwidth/range/speed
|
||||
* add basic crypto - https://github.com/chegewara/esp32-mbedtls-aes-test/blob/master/main/main.c https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation - use ECB at first (though it is shit) because it doesn't require us to send 16 bytes of IV with each packet. Then OFB per example
|
||||
* override peekAtMessage so we can see any messages that pass through our node (even if not broadcast)? would that be useful?
|
||||
* sendToMesh can currently block for a long time, instead have it just queue a packet for a radio freertos thread
|
||||
* How do avalanche beacons work? Could this do that as well? possibly by using beacon mode feature of the RF95?
|
||||
* use std::map<NodeInfo*, std::string> in node db
|
||||
* make a HAM build: yep - that's a great idea. I'll add it to the TODO. should be pretty painless - just a new frequency list, a bool to say 'never do encryption' and use hte callsign as that node's unique id. -from Girts
|
||||
* add frequency hopping, dependent on the gps time, make the switch moment far from the time anyone is going to be transmitting
|
||||
* share channel settings over Signal (or qr code) by embedding an an URL which is handled by the MeshUtil app.
|
||||
* publish update articles on the web
|
||||
|
||||
# Pre-beta priority
|
||||
|
||||
During the beta timeframe the following improvements 'would be nice' (and yeah - I guess some of these items count as features, but it is a hobby project ;-) )
|
||||
|
||||
* If the phone doesn't read fromradio mailbox within X seconds, assume the phone is gone and we can stop queing location msgs
|
||||
for it (because it will redownload the nodedb when it comes back)
|
||||
* Figure out why the RF95 ISR is never seeing RH_RF95_VALID_HEADER, so it is not protecting our rx packets from getting stomped on by sends
|
||||
* use BLEDevice::setPower to lower our BLE transmit power - extra range doesn't help us, it costs amps and it increases snoopability
|
||||
* make an install script to let novices install software on their boards
|
||||
* fix the frequency error reading in the RF95 RX code (can't do floating point math in an ISR ;-)
|
||||
* See CustomRF95::send and fix the problem of dropping partially received packets if we want to start sending
|
||||
* use variable length arduino Strings in protobufs (instead of current fixed buffers)
|
||||
* don't even power on bluetooth until we have some data to send to the android phone. Most of the time we should be sleeping in a lowpower "listening for lora" only mode. Once we have some packets for the phone, then power on bluetooth
|
||||
until the phone pulls those packets. Ever so often power on bluetooth just so we can see if the phone wants to send some packets. Possibly might need ULP processor to help with this wake process.
|
||||
* do hibernation mode to get power draw down to 2.5uA https://lastminuteengineers.com/esp32-sleep-modes-power-consumption/
|
||||
* make sure main cpu is not woken for packets with bad crc or not addressed to this node - do that in the radio hw
|
||||
* enable fast init inside the gps chip
|
||||
* triple check fcc compliance
|
||||
* pick channel center frequency based on name? "dolphin" would hash to 900Mhz, "cat" to 905MHz etc? Or is that too opaque?
|
||||
* scan to find channels with low background noise?
|
||||
* share channel settings over Signal (or qr code) by embedding an an URL which is handled by the MeshUtil app.
|
||||
* pick channel center frequency based on channel name? "dolphin" would hash to 900Mhz, "cat" to 905MHz etc? allows us to hide the concept of channel # from hte user.
|
||||
* scan to find channels with low background noise? (Use CAD mode of the RF95 to automatically find low noise channels)
|
||||
* make a no bluetooth configured yet screen - include this screen in the loop if the user hasn't yet paired
|
||||
* if radio params change fundamentally, discard the nodedb
|
||||
* reneable the bluetooth battery level service on the T-BEAM, because we can read battery level there
|
||||
|
||||
# Spinoff project ideas
|
||||
|
||||
* an open source version of https://www.burnair.ch/skynet/
|
||||
* a paragliding app like http://airwhere.co.uk/
|
||||
* a version with a solar cell for power, just mounted high to permanently provide routing for nodes in a valley. Someone just pointed me at disaster.radio
|
||||
* How do avalanche beacons work? Could this do that as well? possibly by using beacon mode feature of the RF95?
|
||||
* provide generalized (but slow) internet message forwarding servie if one of our nodes has internet connectivity
|
||||
|
||||
# Low priority
|
||||
|
||||
Items after the first final candidate release.
|
||||
|
||||
* use variable length arduino Strings in protobufs (instead of current fixed buffers)
|
||||
* use BLEDevice::setPower to lower our BLE transmit power - extra range doesn't help us, it costs amps and it increases snoopability
|
||||
* make an install script to let novices install software on their boards
|
||||
* use std::map<NodeInfo*, std::string> in node db
|
||||
* make a HAM build: yep - that's a great idea. I'll add it to the TODO. should be pretty painless - just a new frequency list, a bool to say 'never do encryption' and use hte callsign as that node's unique id. -from Girts
|
||||
* don't forward redundant pings or ping responses to the phone, it just wastes phone battery
|
||||
* use https://platformio.org/lib/show/1260/OneButton if necessary
|
||||
* don't send location packets if we haven't moved
|
||||
* scrub default radio config settings for bandwidth/range/speed
|
||||
* answer to pings (because some other user is looking at our nodeinfo) with our latest location (not a stale location)
|
||||
* show radio and gps signal strength as an image
|
||||
* only BLE advertise for a short time after the screen is on and button pressed - to save power and prevent people for sniffing for our BT app.
|
||||
* make mesh aware network timing state machine (sync wake windows to gps time)
|
||||
* split out the software update utility so other projects can use it. Have the appload specify the URL for downloads.
|
||||
* Use CAD mode of the RF95 to automatically find low noise channels
|
||||
* read the PMU battery fault indicators and blink/led/warn user on screen
|
||||
* make a no bluetooth configured yet screen - include this screen in the loop if the user hasn't yet paired
|
||||
* the AXP debug output says it is trying to charge at 700mA, but the max I've seen is 180mA, so AXP registers probably need to be set to tell them the circuit can only provide 300mAish max. So that the low charge rate kicks in faster and we don't wear out batteries.
|
||||
* increase the max charging rate a bit for 18650s, currently it limits to 180mA (at 4V). Work backwards from the 500mA USB limit (at 5V) and let the AXP charge at that rate.
|
||||
* if radio params change fundamentally, discard the nodedb
|
||||
* discard very old nodedb records (> 1wk)
|
||||
* using the genpartitions based table doesn't work on TTGO so for now I stay with my old memory map
|
||||
* We let anyone BLE scan for us (FIXME, perhaps only allow that until we are paired with a phone and configured)
|
||||
@@ -93,9 +87,7 @@ Items after the first final candidate release.
|
||||
* break out my bluetooth OTA software as a seperate library so others can use it
|
||||
* Heltec LoRa32 has 8MB flash, use a bigger partition table if needed - TTGO is 4MB but has PSRAM
|
||||
* add a watchdog timer
|
||||
* fix GPS.zeroOffset calculation it is wrong
|
||||
* handle millis() rollover in GPS.getTime - otherwise we will break after 50 days
|
||||
* reneable the bluetooth battery level service on the T-BEAM, because we can read battery level there
|
||||
* report esp32 device code bugs back to the mothership via android
|
||||
|
||||
# Done
|
||||
@@ -183,3 +175,18 @@ Items after the first final candidate release.
|
||||
* stay awake while charging
|
||||
* check gps battery voltage
|
||||
* if a position report includes ground truth time and we don't have time yet, set our clock from that. It is better than nothing.
|
||||
* retest BLE software update for both board types
|
||||
* report on wikifactory
|
||||
* send note to the guy who designed the cases
|
||||
* turn light sleep on aggressively (while lora is on but BLE off)
|
||||
* Use the Periodic class for both position and user periodic broadcasts
|
||||
* don't treat north as up, instead adjust shown bearings for our guess at the users heading (i.e. subtract one from the other)
|
||||
* sendToMesh can currently block for a long time, instead have it just queue a packet for a radio freertos thread
|
||||
* don't even power on bluetooth until we have some data to send to the android phone. Most of the time we should be sleeping in a lowpower "listening for lora" only mode. Once we have some packets for the phone, then power on bluetooth
|
||||
until the phone pulls those packets. Ever so often power on bluetooth just so we can see if the phone wants to send some packets. Possibly might need ULP processor to help with this wake process.
|
||||
* do hibernation mode to get power draw down to 2.5uA https://lastminuteengineers.com/esp32-sleep-modes-power-consumption/
|
||||
* fix GPS.zeroOffset calculation it is wrong
|
||||
* (needs testing) fixed the following during a plane flight:
|
||||
Have state machine properly enter deep sleep based on loss of mesh and phone comms.
|
||||
Default to enter deep sleep if no LORA received for two hours (indicates user has probably left the mesh).
|
||||
* (fixed I think) text messages are not showing on local screen if screen was on
|
||||
|
||||
@@ -4,8 +4,8 @@ set -e
|
||||
|
||||
source bin/version.sh
|
||||
|
||||
# COUNTRIES="US EU CN JP"
|
||||
COUNTRIES=US
|
||||
COUNTRIES="US EU CN JP"
|
||||
# COUNTRIES=US
|
||||
|
||||
SRCMAP=.pio/build/esp32/output.map
|
||||
SRCBIN=.pio/build/esp32/firmware.bin
|
||||
@@ -26,13 +26,13 @@ for COUNTRY in $COUNTRIES; do
|
||||
rm -f $SRCBIN $SRCMAP
|
||||
pio run # -v
|
||||
cp $SRCBIN $OUTDIR/firmware-TBEAM-$COUNTRY-$VERSION.bin
|
||||
cp $SRCMAP $ARCHIVEDIR/firmware-TBEAM-$COUNTRY-$VERSION.map
|
||||
#cp $SRCMAP $ARCHIVEDIR/firmware-TBEAM-$COUNTRY-$VERSION.map
|
||||
|
||||
export PLATFORMIO_BUILD_FLAGS="-DHELTEC_LORA32 $COMMONOPTS"
|
||||
rm -f $SRCBIN $SRCMAP
|
||||
pio run # -v
|
||||
cp $SRCBIN $OUTDIR/firmware-HELTEC-$COUNTRY-$VERSION.bin
|
||||
cp $SRCMAP $ARCHIVEDIR/firmware-HELTEC-$COUNTRY-$VERSION.map
|
||||
#cp $SRCMAP $ARCHIVEDIR/firmware-HELTEC-$COUNTRY-$VERSION.map
|
||||
done
|
||||
|
||||
# keep the bins in archive also
|
||||
@@ -50,6 +50,7 @@ Generated by bin/buildall.sh -->
|
||||
</resources>
|
||||
XML
|
||||
|
||||
rm -f $ARCHIVEDIR/firmware-$VERSION.zip
|
||||
zip $ARCHIVEDIR/firmware-$VERSION.zip $OUTDIR/firmware-*-$VERSION.bin
|
||||
|
||||
echo BUILT ALL
|
||||
@@ -3,4 +3,4 @@ set -e
|
||||
|
||||
source bin/version.sh
|
||||
|
||||
esptool.py --baud 921600 write_flash 0x10000 release/firmware-HELTEC-US-$VERSION.bin
|
||||
esptool.py --baud 921600 write_flash 0x10000 release/latest/firmware-HELTEC-US-$VERSION.bin
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
/home/kevinh/packages/nanopb-0.4.1-linux-x86/generator-bin/protoc --nanopb_out=-v:src -I=../MeshUtil/app/src/main/proto mesh.proto
|
||||
#!/bin/bash
|
||||
|
||||
echo "This script requires https://jpa.kapsi.fi/nanopb/download/ version 0.4.1"
|
||||
# the nanopb tool seems to require that the .options file be in the current directory!
|
||||
cd proto
|
||||
../../nanopb-0.4.1-linux-x86/generator-bin/protoc --nanopb_out=-v:../src -I=../proto mesh.proto
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
|
||||
|
||||
export VERSION=0.0.5
|
||||
export VERSION=0.1.0
|
||||
9
docs/.well-known/assetlinks.json
Normal file
9
docs/.well-known/assetlinks.json
Normal file
@@ -0,0 +1,9 @@
|
||||
[{
|
||||
"relation": ["delegate_permission/common.handle_all_urls"],
|
||||
"target": {
|
||||
"namespace": "android_app",
|
||||
"package_name": "com.geeksville.mesh",
|
||||
"sha256_cert_fingerprints":
|
||||
["D0:05:E7:8B:D2:1B:FA:94:56:1D:6B:90:EB:53:07:1A:74:4F:D9:C2:6F:13:87:6A:D9:17:4F:C2:59:48:02:9D"]
|
||||
}
|
||||
}]
|
||||
@@ -18,7 +18,7 @@ will optionally work with your phone, but no phone is required.
|
||||
[](https://www.youtube.com/watch?v=WlNbMbVZlHI "Meshtastic early demo")
|
||||
|
||||
### Features
|
||||
Not all of these features are fully implemented yet - see below. But they should be in by the time we decide to call this project beta (three months?)
|
||||
Not all of these features are fully implemented yet - see **important** disclaimers below. But they should be in by the time we decide to call this project beta (three months?)
|
||||
|
||||
* Very long battery life (should be about eight days with the beta software)
|
||||
* Built in GPS and [LoRa](https://en.wikipedia.org/wiki/LoRa) radio, but we manage the radio automatically for you
|
||||
@@ -28,7 +28,7 @@ Not all of these features are fully implemented yet - see below. But they shoul
|
||||
* Open and extensible codebase supporting multiple hardware vendors - no lock in to one vendor
|
||||
* Communication API for bluetooth devices (such as our Android app) to use the mesh. So if you have some application that needs long range low power networking, this might work for you.
|
||||
* Eventually (within a couple of months) we should have a modified version of Signal that works with this project.
|
||||
* Very easy sharing of private secured channels. Just share a special link or QR code with other users and they can join your encrypted mesh
|
||||
* Very easy sharing of private secured channels. Just share a special link or QR code with friends and they can join your encrypted mesh
|
||||
|
||||
This project is currently in early alpha - if you have questions please join our chat [](https://gitter.im/Meshtastic/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge).
|
||||
|
||||
@@ -36,9 +36,12 @@ This software is 100% open source and developed by a group of hobbyist experimen
|
||||
|
||||
# Updates
|
||||
|
||||
Note: Updates are happening almost daily, only major updates are listed below. For more details see our chat, github releases or the Android alpha tester emails.
|
||||
|
||||
* 03/03/2020 - 0.0.9 of the Android app and device code is released. Still an alpha but fairly functional.
|
||||
* 02/25/2020 - 0.0.4 of the Android app is released. This is a very early alpha, see below to join the alpha-testers group.
|
||||
* 02/23/2020 - 0.0.4 release. Still very bleeding edge but much closer to the final power management, a charged T-BEAM should run for many days with this load. If you'd like to try it, we'd love your feedback. Click [here](https://github.com/geeksville/Meshtastic-esp32/blob/master/README.md) for instructions.
|
||||
* 02/20/2020 - Our first alpha release (0.0.3) of the radio software is ready for early users.
|
||||
* 02/23/2020 - 0.0.4 release. Still very bleeding edge but much closer to the final power management, a charged T-BEAM should run for many days with this load. If you'd like to try it, we'd love your feedback. Click [here](https://github.com/meshtastic/Meshtastic-esp32/blob/master/README.md) for instructions.
|
||||
* 02/20/2020 - Our first alpha release (0.0.3) of the radio software is ready brave early people.
|
||||
|
||||
## Meshtastic Android app
|
||||
Once out of alpha the companion Android application will be released here:
|
||||
@@ -51,14 +54,13 @@ But if you want the bleeding edge app now, we'd love to have your help testing.
|
||||
2. Go to this [URL](https://play.google.com/apps/testing/com.geeksville.mesh) to opt-in to the alpha test.
|
||||
3. If you encounter any problems or have questions, post in our gitter chat and we'll help.
|
||||
|
||||
If you'd like to help with development, the source code is [on github](https://github.com/geeksville/Meshtastic-Android).
|
||||
If you'd like to help with development, the source code is [on github](https://github.com/meshtastic/Meshtastic-Android).
|
||||
|
||||
## Supported hardware
|
||||
We currently support two brands of radios. The [TTGO T-Beam](https://www.aliexpress.com/item/4000119152086.html) and the [Heltec LoRa 32](https://heltec.org/project/wifi-lora-32/). Most users should buy the T-Beam and a 18650 battery (total cost less than $35). Make
|
||||
sure to buy the frequency range which is legal for your country. For the USA, you should buy the 915MHz version. Getting a version that include a screen
|
||||
is optional, but highly recommended.
|
||||
We currently support two brands of radios. The [TTGO T-Beam](https://www.aliexpress.com/item/4000119152086.html) and the [Heltec LoRa 32](https://heltec.org/project/wifi-lora-32/). Most people should buy the T-Beam and a 18650 battery (total cost less than $35). Make
|
||||
sure to buy the frequency range which is legal for your country. For the USA, you should buy the 915MHz version. Getting a version that include a screen is optional, but highly recommended.
|
||||
|
||||
Instructions for installing prebuilt firmware can be found [here](https://github.com/geeksville/Meshtastic-esp32/blob/master/README.md).
|
||||
Instructions for installing prebuilt firmware can be found [here](https://github.com/meshtastic/Meshtastic-esp32/blob/master/README.md).
|
||||
|
||||
For a nice TTGO 3D printable case see this [design](https://www.thingiverse.com/thing:3773717) by [bsiege](https://www.thingiverse.com/bsiege).
|
||||
For a nice Heltec 3D printable case see this [design](https://www.thingiverse.com/thing:3125854) by [ornotermes](https://www.thingiverse.com/ornotermes).
|
||||
@@ -70,11 +72,11 @@ Most of these problems should be solved by the beta release:
|
||||
|
||||
* We don't make these devices and they haven't been tested by UL or the FCC. If you use them you are experimenting and we can't promise they won't burn your house down ;-)
|
||||
* Encryption is turned off for now
|
||||
* A number of (straightforward) software work items have to be completed before battery life matches our measurements, currently battery life is about two days. Join us on chat if you want the spreadsheet of power measurements/calculations.
|
||||
* A number of (straightforward) software work items have to be completed before battery life matches our measurements, currently battery life is about three days. Join us on chat if you want the spreadsheet of power measurements/calculations.
|
||||
* The current Android GUI is pretty ugly still
|
||||
* The Android API needs to be documented better
|
||||
* The Bluetooth API needs to be documented better
|
||||
* The mesh protocol is turned off for now, currently we only send packets one hop distant
|
||||
* No one has written an iOS app yet ;-)
|
||||
|
||||
For more details see the [device software TODO](https://github.com/geeksville/Meshtastic-esp32/blob/master/TODO.md) or the [Android app TODO](https://github.com/geeksville/Meshtastic-Android/blob/master/TODO.md).
|
||||
For more details see the [device software TODO](https://github.com/meshtastic/Meshtastic-esp32/blob/master/TODO.md) or the [Android app TODO](https://github.com/meshtastic/Meshtastic-Android/blob/master/TODO.md).
|
||||
|
||||
BIN
docs/hardware/AN1200_22_Semtech_LoRa_Basics_v2_STD.pdf
Normal file
BIN
docs/hardware/AN1200_22_Semtech_LoRa_Basics_v2_STD.pdf
Normal file
Binary file not shown.
BIN
docs/hardware/AXP192 Datasheet_v1.1_en_draft_2211.pdf
Normal file
BIN
docs/hardware/AXP192 Datasheet_v1.1_en_draft_2211.pdf
Normal file
Binary file not shown.
BIN
docs/hardware/DS_SX1276-7-8-9_W_APP_V6.pdf
Normal file
BIN
docs/hardware/DS_SX1276-7-8-9_W_APP_V6.pdf
Normal file
Binary file not shown.
BIN
docs/hardware/NEO-6_DataSheet_(GPS.G6-HW-09005).pdf
Normal file
BIN
docs/hardware/NEO-6_DataSheet_(GPS.G6-HW-09005).pdf
Normal file
Binary file not shown.
BIN
docs/hardware/RFM95_96_97_98W.pdf
Normal file
BIN
docs/hardware/RFM95_96_97_98W.pdf
Normal file
Binary file not shown.
BIN
docs/hardware/T_BeamV1.0.pdf
Normal file
BIN
docs/hardware/T_BeamV1.0.pdf
Normal file
Binary file not shown.
BIN
docs/hardware/WIFI_LoRa_32_V2(868-915).PDF
Normal file
BIN
docs/hardware/WIFI_LoRa_32_V2(868-915).PDF
Normal file
Binary file not shown.
BIN
docs/hardware/axp192-complete-datasheet-chinese.pdf
Normal file
BIN
docs/hardware/axp192-complete-datasheet-chinese.pdf
Normal file
Binary file not shown.
BIN
docs/hardware/esp32_datasheet_en.pdf
Normal file
BIN
docs/hardware/esp32_datasheet_en.pdf
Normal file
Binary file not shown.
BIN
docs/hardware/lora-fcc-requirements.pdf
Normal file
BIN
docs/hardware/lora-fcc-requirements.pdf
Normal file
Binary file not shown.
BIN
docs/hardware/pe4259ds-rf-switch.pdf
Normal file
BIN
docs/hardware/pe4259ds-rf-switch.pdf
Normal file
Binary file not shown.
@@ -5,7 +5,7 @@ We don't collect any personal identifying information.
|
||||
If you have opted-in to analytics (thank you - that helps us know what things we need to improve), we'll receive anonymized information about user behavior. i.e. which screens you used in the app etc... We never
|
||||
capture usernames, the contents of your texts or your location.
|
||||
|
||||
This is an open-source project run by hobbyists and we try to be completely transparent. If you have questions on this policy, please file [a github issue](https://github.com/geeksville/meshtastic-esp32/issues) and we'll reply/clarify/correct.
|
||||
This is an open-source project run by hobbyists and we try to be completely transparent. If you have questions on this policy, please file [a github issue](https://github.com/meshtastic/meshtastic-esp32/issues) and we'll reply/clarify/correct.
|
||||
|
||||
Keep being awesome!
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ This is a mini design doc for various core behaviors...
|
||||
|
||||
From lower to higher power consumption.
|
||||
|
||||
* Super-deep-sleep (SDS) - everything is off, CPU, radio, bluetooth, GPS. Only wakes due to timer or button press
|
||||
* Super-deep-sleep (SDS) - everything is off, CPU, radio, bluetooth, GPS. Only wakes due to timer or button press. We enter this mode only after no radio comms for a few hours, used to put the device into what is effectively "off" mode.
|
||||
onEntry: setBluetoothOn(false), call doDeepSleep
|
||||
onExit: (standard bootup code, starts in DARK)
|
||||
|
||||
@@ -53,8 +53,8 @@ off during light sleep, but there is a TODO item to fix this.
|
||||
* While in ON: If it has been more than screen_on_secs since a press, lower to DARK
|
||||
* While in DARK: If time since last contact by our phone exceeds phone_timeout_secs (15 minutes), we transition down into NB mode
|
||||
* While in DARK or NB: If nothing above is forcing us to stay in a higher mode (wait_bluetooth_secs, min_wake_secs) we will lower down to LS state
|
||||
* While in into LS: If either phone_sds_timeout_secs (default 1 hr) or mesh_sds_timeout_secs (default 1 hr) are exceeded we will lower into SDS mode for sds_secs (default 1 hr) (or a button press).
|
||||
* Any time we enter LS mode: We stay in that mode for ls_secs (default 1 hr) (or until an interrupt, button press)
|
||||
* While in LS: If either phone_sds_timeout_secs (default 2 hr) or mesh_sds_timeout_secs (default 2 hr) are exceeded we will lower into SDS mode for sds_secs (default 1 yr) (or a button press).
|
||||
* Any time we enter LS mode: We stay in that until an interrupt, button press or other state transition. Every ls_secs (default 1 hr) and let the arduino loop() run one iteration (FIXME, not sure if we need this at all), and then immediately reenter lightsleep mode on the CPU.
|
||||
|
||||
TODO: Eventually these scheduled intervals should be synchronized to the GPS clock, so that we can consider leaving the lora receiver off to save even more power.
|
||||
TODO: In NB mode we should put cpu into light sleep any time we really aren't that busy (without declaring LS state) - i.e. we should leave GPS on etc...
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
"name": "BluetoothOTA",
|
||||
"keywords": "esp32, bluetooth",
|
||||
"description": "A BTLE based software OTA update tool",
|
||||
"repository":
|
||||
{
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/geeksville/fixme.git"
|
||||
},
|
||||
"authors":
|
||||
[
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kevin Hester",
|
||||
"email": "kevinh@geeksville.com",
|
||||
@@ -20,7 +18,15 @@
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*",
|
||||
"dependencies": [
|
||||
{ "name": "Update" },
|
||||
{ "name": "ESP32 BLE Arduino" }
|
||||
{
|
||||
"name": "Update"
|
||||
},
|
||||
{
|
||||
"name": "ESP32 BLE Arduino"
|
||||
},
|
||||
{
|
||||
"name": "arduino-fsm",
|
||||
"version": "https://github.com/meshtastic/arduino-fsm.git"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -212,7 +212,7 @@ class MySecurity : public BLESecurityCallbacks
|
||||
}
|
||||
|
||||
// Remove our custom screen
|
||||
screen_set_frames();
|
||||
screen.setFrames();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../MeshUtil/app/src/main/proto/mesh.options
|
||||
@@ -1 +0,0 @@
|
||||
../MeshUtil/app/src/main/proto/mesh.proto
|
||||
@@ -21,8 +21,8 @@ framework = arduino
|
||||
board_build.partitions = partition-table.csv
|
||||
|
||||
; note: we add src to our include search path so that lmic_project_config can override
|
||||
; FIXME fix dependencies on arduino-fsm
|
||||
build_flags = -Wall -Wextra -Wno-missing-field-initializers -I.pio/libdeps/esp32/arduino-fsm -Isrc -Os -Wl,-Map,.pio/build/esp32/output.map -DAXP_DEBUG_PORT=Serial
|
||||
; FIXME: fix lib/BluetoothOTA dependency back on src/ so we can remove -Isrc
|
||||
build_flags = -Wall -Wextra -Wno-missing-field-initializers -Isrc -Os -Wl,-Map,.pio/build/esp32/output.map -DAXP_DEBUG_PORT=Serial
|
||||
|
||||
; not needed included in ttgo-t-beam board file
|
||||
; also to use PSRAM https://docs.platformio.org/en/latest/platforms/espressif32.html#external-ram-psram
|
||||
@@ -55,20 +55,22 @@ debug_tool = jlink
|
||||
|
||||
debug_init_break = tbreak setup
|
||||
|
||||
; Note: some libraries are specified by #ID where there are conflicting library
|
||||
; names.
|
||||
lib_deps =
|
||||
https://github.com/geeksville/RadioHead.git
|
||||
TinyGPSPlus
|
||||
https://github.com/geeksville/esp8266-oled-ssd1306.git ; ESP8266_SSD1306
|
||||
https://github.com/meshtastic/RadioHead.git
|
||||
1655 ; TinyGPSPlus
|
||||
https://github.com/meshtastic/esp8266-oled-ssd1306.git ; ESP8266_SSD1306
|
||||
AXP202X_Library
|
||||
SPI
|
||||
OneButton
|
||||
CRC32 ; explicitly needed because dependency is missing in the ble ota update lib
|
||||
1260 ; OneButton
|
||||
1202 ; CRC32, explicitly needed because dependency is missing in the ble ota update lib
|
||||
Wire ; explicitly needed here because the AXP202 library forgets to add it
|
||||
https://github.com/geeksville/arduino-fsm.git
|
||||
https://github.com/meshtastic/arduino-fsm.git
|
||||
|
||||
;[env:tbeam]
|
||||
;board = ttgo-t-beam
|
||||
|
||||
;[env:heltec]
|
||||
;build_type = debug ; to make it possible to step through our jtag debugger
|
||||
;board = heltec_wifi_lora_32_V2
|
||||
;board = heltec_wifi_lora_32_V2
|
||||
|
||||
1
proto
Submodule
1
proto
Submodule
Submodule proto added at f309ee8f9e
@@ -5,5 +5,5 @@ release. It is used by the android app for forcing software updates. Do not ed
|
||||
Generated by bin/buildall.sh -->
|
||||
|
||||
<resources>
|
||||
<string name="cur_firmware_version">0.0.5</string>
|
||||
<string name="cur_firmware_version">0.0.9</string>
|
||||
</resources>
|
||||
|
||||
@@ -190,16 +190,16 @@ public:
|
||||
{
|
||||
static FromRadio fRadio;
|
||||
|
||||
// Encapsulate as a ToRadio packet
|
||||
// Encapsulate as a FromRadio packet
|
||||
memset(&fRadio, 0, sizeof(fRadio));
|
||||
fRadio.which_variant = FromRadio_packet_tag;
|
||||
fRadio.variant.packet = *mp;
|
||||
|
||||
service.releaseToPool(mp); // we just copied the bytes, so don't need this buffer anymore
|
||||
|
||||
size_t numbytes = pb_encode_to_bytes(trBytes, sizeof(trBytes), FromRadio_fields, &fRadio);
|
||||
DEBUG_MSG("delivering toPhone packet to phone %d bytes\n", numbytes);
|
||||
c->setValue(trBytes, numbytes);
|
||||
|
||||
service.releaseToPool(mp); // we just copied the bytes, so don't need this buffer anymore
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -329,6 +329,14 @@ BLEService *createMeshBluetoothService(BLEServer *server)
|
||||
return service;
|
||||
}
|
||||
|
||||
void stopMeshBluetoothService()
|
||||
{
|
||||
assert(meshService);
|
||||
meshService->stop();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void destroyMeshBluetoothService()
|
||||
{
|
||||
assert(meshService);
|
||||
@@ -336,15 +344,3 @@ void destroyMeshBluetoothService()
|
||||
|
||||
meshFromNumCharacteristic = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Super skanky FIXME - when we start a software update we force the mesh service to shutdown.
|
||||
* If the sw update fails, the user will have to manually reset the board to get things running again.
|
||||
*/
|
||||
void stopMeshBluetoothService()
|
||||
{
|
||||
if (meshService)
|
||||
meshService->stop();
|
||||
|
||||
meshFromNumCharacteristic = NULL; // don't try to notify anymore
|
||||
}
|
||||
@@ -12,8 +12,4 @@ void destroyMeshBluetoothService();
|
||||
*/
|
||||
void bluetoothNotifyFromNum(uint32_t newValue);
|
||||
|
||||
/**
|
||||
* Super skanky FIXME - when we start a software update we force the mesh service to shutdown.
|
||||
* If the sw update fails, the user will have to manually reset the board to get things running again.
|
||||
*/
|
||||
void stopMeshBluetoothService();
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "GPS.h"
|
||||
#include "screen.h"
|
||||
#include "Periodic.h"
|
||||
#include "PowerFSM.h"
|
||||
|
||||
/*
|
||||
receivedPacketQueue - this is a queue of messages we've received from the mesh, which we are keeping to deliver to the phone.
|
||||
@@ -144,11 +145,13 @@ void MeshService::handleIncomingPosition(MeshPacket *mp)
|
||||
|
||||
void MeshService::handleFromRadio(MeshPacket *mp)
|
||||
{
|
||||
powerFSM.trigger(EVENT_RECEIVED_PACKET); // Possibly keep the node from sleeping
|
||||
|
||||
mp->rx_time = gps.getValidTime(); // store the arrival timestamp for the phone
|
||||
|
||||
// If it is a position packet, perhaps set our clock (if we don't have a GPS of our own, otherwise wait for that to work)
|
||||
if(!myNodeInfo.has_gps)
|
||||
handleIncomingPosition(mp);
|
||||
if (!myNodeInfo.has_gps)
|
||||
handleIncomingPosition(mp);
|
||||
|
||||
if (mp->has_payload && mp->payload.which_variant == SubPacket_user_tag)
|
||||
{
|
||||
|
||||
@@ -21,6 +21,14 @@ MyNodeInfo &myNodeInfo = devicestate.my_node;
|
||||
RadioConfig &radioConfig = devicestate.radio;
|
||||
ChannelSettings &channelSettings = radioConfig.channel_settings;
|
||||
|
||||
/*
|
||||
DeviceState versions used to be defined in the .proto file but really only this function cares. So changed to a
|
||||
#define here.
|
||||
*/
|
||||
|
||||
#define DEVICESTATE_CUR_VER 1
|
||||
#define DEVICESTATE_MIN_VER DEVICESTATE_CUR_VER
|
||||
|
||||
#define FS SPIFFS
|
||||
|
||||
/**
|
||||
@@ -54,9 +62,9 @@ void NodeDB::init()
|
||||
radioConfig.preferences.position_broadcast_secs = 15 * 60;
|
||||
radioConfig.preferences.wait_bluetooth_secs = 120;
|
||||
radioConfig.preferences.screen_on_secs = 30;
|
||||
radioConfig.preferences.mesh_sds_timeout_secs = 60 * 60;
|
||||
radioConfig.preferences.phone_sds_timeout_sec = 60 * 60;
|
||||
radioConfig.preferences.sds_secs = 60 * 60;
|
||||
radioConfig.preferences.mesh_sds_timeout_secs = 2 * 60 * 60;
|
||||
radioConfig.preferences.phone_sds_timeout_sec = 2 * 60 * 60;
|
||||
radioConfig.preferences.sds_secs = 365 * 24 * 60 * 60; // one year
|
||||
radioConfig.preferences.ls_secs = 60 * 60;
|
||||
radioConfig.preferences.phone_timeout_secs = 15 * 60;
|
||||
|
||||
@@ -64,6 +72,9 @@ void NodeDB::init()
|
||||
// some hardware defaults to have a built in GPS
|
||||
myNodeInfo.has_gps = true;
|
||||
#endif
|
||||
strncpy(myNodeInfo.region, xstr(HW_VERSION), sizeof(myNodeInfo.region));
|
||||
strncpy(myNodeInfo.firmware_version, xstr(APP_VERSION), sizeof(myNodeInfo.firmware_version));
|
||||
strncpy(myNodeInfo.hw_model, HW_VENDOR, sizeof(myNodeInfo.hw_model));
|
||||
|
||||
// Init our blank owner info to reasonable defaults
|
||||
esp_efuse_mac_get_default(ourMacAddr);
|
||||
@@ -144,7 +155,7 @@ void NodeDB::loadFromDisk()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (scratch.version < DeviceState_Version_Minimum)
|
||||
if (scratch.version < DEVICESTATE_MIN_VER)
|
||||
DEBUG_MSG("Warn: devicestate is old, discarding\n");
|
||||
else
|
||||
{
|
||||
@@ -173,7 +184,7 @@ void NodeDB::saveToDisk()
|
||||
|
||||
//DEBUG_MSG("Presave channel name=%s\n", channelSettings.name);
|
||||
|
||||
devicestate.version = DeviceState_Version_Current;
|
||||
devicestate.version = DEVICESTATE_CUR_VER;
|
||||
if (!pb_encode(&stream, DeviceState_fields, &devicestate))
|
||||
{
|
||||
DEBUG_MSG("Error: can't write protobuf %s\n", PB_GET_ERROR(&stream));
|
||||
|
||||
@@ -25,21 +25,24 @@ static void sdsEnter()
|
||||
|
||||
static void lsEnter()
|
||||
{
|
||||
screen.setOn(false);
|
||||
|
||||
while (!service.radio.rf95.canSleep())
|
||||
delay(10); // Kinda yucky - wait until radio says say we can shutdown (finished in process sends/receives)
|
||||
|
||||
gps.prepareSleep(); // abandon in-process parsing
|
||||
|
||||
if(!isUSBPowered) // FIXME - temp hack until we can put gps in sleep mode, if we have AC when we go to sleep then leave GPS on
|
||||
setGPSPower(false); // kill GPS power
|
||||
if (!isUSBPowered) // FIXME - temp hack until we can put gps in sleep mode, if we have AC when we go to sleep then leave GPS on
|
||||
setGPSPower(false); // kill GPS power
|
||||
}
|
||||
|
||||
static void lsIdle()
|
||||
{
|
||||
uint32_t secsSlept = 0;
|
||||
esp_sleep_source_t wakeCause = ESP_SLEEP_WAKEUP_UNDEFINED;
|
||||
bool reached_ls_secs = false;
|
||||
|
||||
while (secsSlept < radioConfig.preferences.ls_secs)
|
||||
while (!reached_ls_secs)
|
||||
{
|
||||
// Briefly come out of sleep long enough to blink the led once every few seconds
|
||||
uint32_t sleepTime = 5;
|
||||
@@ -55,11 +58,20 @@ static void lsIdle()
|
||||
break;
|
||||
|
||||
secsSlept += sleepTime;
|
||||
reached_ls_secs = secsSlept >= radioConfig.preferences.ls_secs;
|
||||
}
|
||||
setLed(false);
|
||||
|
||||
// Regardless of why we woke (for now) just transition to NB (and that state will handle stuff like IRQs etc)
|
||||
powerFSM.trigger(EVENT_WAKE_TIMER);
|
||||
if (reached_ls_secs)
|
||||
{
|
||||
// stay in LS mode but let loop check whatever it wants
|
||||
DEBUG_MSG("reached ls_secs, servicing loop()\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Regardless of why we woke just transition to NB (and that state will handle stuff like IRQs etc)
|
||||
powerFSM.trigger(EVENT_WAKE_TIMER);
|
||||
}
|
||||
}
|
||||
|
||||
static void lsExit()
|
||||
@@ -70,6 +82,7 @@ static void lsExit()
|
||||
|
||||
static void nbEnter()
|
||||
{
|
||||
screen.setOn(false);
|
||||
setBluetoothEnable(false);
|
||||
|
||||
// FIXME - check if we already have packets for phone and immediately trigger EVENT_PACKETS_FOR_PHONE
|
||||
@@ -86,10 +99,7 @@ static void onEnter()
|
||||
setBluetoothEnable(true);
|
||||
}
|
||||
|
||||
static void onExit()
|
||||
{
|
||||
screen.setOn(false);
|
||||
}
|
||||
|
||||
static void wakeForPing()
|
||||
{
|
||||
}
|
||||
@@ -103,7 +113,7 @@ State stateSDS(sdsEnter, NULL, NULL, "SDS");
|
||||
State stateLS(lsEnter, lsIdle, lsExit, "LS");
|
||||
State stateNB(nbEnter, NULL, NULL, "NB");
|
||||
State stateDARK(darkEnter, NULL, NULL, "DARK");
|
||||
State stateON(onEnter, NULL, onExit, "ON");
|
||||
State stateON(onEnter, NULL, NULL, "ON");
|
||||
Fsm powerFSM(&stateDARK);
|
||||
|
||||
void PowerFSM_setup()
|
||||
@@ -147,5 +157,8 @@ void PowerFSM_setup()
|
||||
|
||||
powerFSM.add_timed_transition(&stateDARK, &stateLS, radioConfig.preferences.wait_bluetooth_secs * 1000, NULL, "Bluetooth timeout");
|
||||
|
||||
powerFSM.add_timed_transition(&stateLS, &stateSDS, radioConfig.preferences.mesh_sds_timeout_secs * 1000, NULL, "mesh timeout");
|
||||
powerFSM.add_timed_transition(&stateLS, &stateSDS, radioConfig.preferences.phone_sds_timeout_sec * 1000, NULL, "phone timeout");
|
||||
|
||||
powerFSM.run_machine(); // run one interation of the state machine, so we run our on enter tasks for the initial DARK state
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Fsm.h"
|
||||
#include <Fsm.h>
|
||||
|
||||
// See sw-design.md for documentation
|
||||
|
||||
@@ -16,4 +16,4 @@
|
||||
|
||||
extern Fsm powerFSM;
|
||||
|
||||
void PowerFSM_setup();
|
||||
void PowerFSM_setup();
|
||||
|
||||
@@ -31,11 +31,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// If app version is not specified we assume we are not being invoked by the build script
|
||||
#ifndef APP_VERSION
|
||||
#define APP_VERSION 0.0.0 // this def normally comes from build-all.sh
|
||||
#define HW_VERSION 1.0-US // normally comes from build-all.sh and contains the region code
|
||||
#define APP_VERSION 0.0.0 // this def normally comes from build-all.sh
|
||||
#define HW_VERSION 1.0 - US // normally comes from build-all.sh and contains the region code
|
||||
#endif
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Configuration
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -54,18 +53,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//#define USE_JTAG
|
||||
#endif
|
||||
|
||||
#define DEBUG_PORT Serial // Serial debug port
|
||||
#define SERIAL_BAUD 115200 // Serial debug baud rate
|
||||
#define DEBUG_PORT Serial // Serial debug port
|
||||
#define SERIAL_BAUD 115200 // Serial debug baud rate
|
||||
|
||||
#define REQUIRE_RADIO true // If true, we will fail to start if the radio is not found
|
||||
#define REQUIRE_RADIO true // If true, we will fail to start if the radio is not found
|
||||
|
||||
#define xstr(s) str(s)
|
||||
#define str(s) #s
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// DEBUG
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#ifdef DEBUG_PORT
|
||||
#define DEBUG_MSG(...) DEBUG_PORT.printf( __VA_ARGS__ )
|
||||
#define DEBUG_MSG(...) DEBUG_PORT.printf(__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_MSG(...)
|
||||
#endif
|
||||
@@ -80,15 +81,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// GPS
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define GPS_SERIAL_NUM 1
|
||||
#define GPS_BAUDRATE 9600
|
||||
#define GPS_SERIAL_NUM 1
|
||||
#define GPS_BAUDRATE 9600
|
||||
|
||||
#if defined(T_BEAM_V10)
|
||||
#define GPS_RX_PIN 34
|
||||
#define GPS_RX_PIN 34
|
||||
#ifdef USE_JTAG
|
||||
#define GPS_TX_PIN -1
|
||||
#define GPS_TX_PIN -1
|
||||
#else
|
||||
#define GPS_TX_PIN 12
|
||||
#define GPS_TX_PIN 12
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -96,61 +97,59 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// LoRa SPI
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define SCK_GPIO 5
|
||||
#define MISO_GPIO 19
|
||||
#define MOSI_GPIO 27
|
||||
#define NSS_GPIO 18
|
||||
#define SCK_GPIO 5
|
||||
#define MISO_GPIO 19
|
||||
#define MOSI_GPIO 27
|
||||
#define NSS_GPIO 18
|
||||
|
||||
#if defined(T_BEAM_V10)
|
||||
// This string must exactly match the case used in release file names or the android updater won't work
|
||||
#define HW_VENDOR "TBEAM"
|
||||
#define HW_VENDOR "TBEAM"
|
||||
|
||||
#define BICOLOR_DISPLAY // we have yellow at the top 16 lines
|
||||
|
||||
#define I2C_SDA 21
|
||||
#define I2C_SCL 22
|
||||
#define I2C_SDA 21
|
||||
#define I2C_SCL 22
|
||||
|
||||
#define BUTTON_PIN 38
|
||||
#define BUTTON_PIN 38
|
||||
|
||||
#ifndef USE_JTAG
|
||||
#define RESET_GPIO 14
|
||||
#define RESET_GPIO 14
|
||||
#endif
|
||||
#define DIO0_GPIO 26
|
||||
#define DIO1_GPIO 33 // Note: not really used on this board
|
||||
#define DIO2_GPIO 32 // Note: not really used on this board
|
||||
#define DIO0_GPIO 26
|
||||
#define DIO1_GPIO 33 // Note: not really used on this board
|
||||
#define DIO2_GPIO 32 // Note: not really used on this board
|
||||
|
||||
// Leave undefined to disable our PMU IRQ handler
|
||||
#define PMU_IRQ 35
|
||||
// Leave undefined to disable our PMU IRQ handler
|
||||
#define PMU_IRQ 35
|
||||
|
||||
#elif defined(HELTEC_LORA32)
|
||||
// This string must exactly match the case used in release file names or the android updater won't work
|
||||
#define HW_VENDOR "HELTEC"
|
||||
#define HW_VENDOR "HELTEC"
|
||||
|
||||
#ifndef USE_JTAG // gpio15 is TDO for JTAG, so no I2C on this board while doing jtag
|
||||
#define I2C_SDA 4
|
||||
#define I2C_SCL 15
|
||||
#define I2C_SDA 4
|
||||
#define I2C_SCL 15
|
||||
#endif
|
||||
|
||||
#define RESET_OLED 16
|
||||
#define RESET_OLED 16
|
||||
|
||||
#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost
|
||||
#define LED_PIN 25
|
||||
#define BUTTON_PIN 0
|
||||
#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost
|
||||
#define LED_PIN 25
|
||||
#define BUTTON_PIN 0
|
||||
|
||||
#ifndef USE_JTAG
|
||||
#define RESET_GPIO 14
|
||||
#define RESET_GPIO 14
|
||||
#endif
|
||||
#define DIO0_GPIO 26
|
||||
#define DIO1_GPIO 35
|
||||
#define DIO2_GPIO 34
|
||||
#define DIO0_GPIO 26
|
||||
#define DIO1_GPIO 35
|
||||
#define DIO2_GPIO 34
|
||||
#endif
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// AXP192 (Rev1-specific options)
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// #define AXP192_SLAVE_ADDRESS 0x34 // Now defined in axp20x.h
|
||||
#define GPS_POWER_CTRL_CH 3
|
||||
#define LORA_POWER_CTRL_CH 2
|
||||
|
||||
#define GPS_POWER_CTRL_CH 3
|
||||
#define LORA_POWER_CTRL_CH 2
|
||||
|
||||
@@ -52,10 +52,7 @@ bool isUSBPowered;
|
||||
bool ssd1306_found;
|
||||
bool axp192_found;
|
||||
|
||||
bool bluetoothOn;
|
||||
|
||||
#define xstr(s) str(s)
|
||||
#define str(s) #s
|
||||
bool bluetoothOn;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Application
|
||||
@@ -201,8 +198,6 @@ const char *getDeviceName()
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Debug
|
||||
@@ -288,11 +283,12 @@ void setBluetoothEnable(bool on)
|
||||
{
|
||||
Serial.printf("Pre BT: %u heap size\n", ESP.getFreeHeap());
|
||||
//ESP_ERROR_CHECK( heap_trace_start(HEAP_TRACE_LEAKS) );
|
||||
initBluetooth();
|
||||
initBluetooth();
|
||||
}
|
||||
else
|
||||
{
|
||||
// We have to totally teardown our bluetooth objects to prevent leaks
|
||||
stopMeshBluetoothService(); // Must do before shutting down bluetooth
|
||||
deinitBLE();
|
||||
destroyMeshBluetoothService(); // must do after deinit, because it frees our service
|
||||
Serial.printf("Shutdown BT: %u heap size\n", ESP.getFreeHeap());
|
||||
@@ -49,7 +49,6 @@ PB_BIND(ToRadio, ToRadio, 2)
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef PB_CONVERT_DOUBLE_FLOAT
|
||||
/* On some platforms (such as AVR), double is really float.
|
||||
* To be able to encode/decode double on these platforms, you need.
|
||||
|
||||
@@ -31,12 +31,6 @@ typedef enum _ChannelSettings_ModemConfig {
|
||||
ChannelSettings_ModemConfig_Bw125Cr48Sf4096 = 3
|
||||
} ChannelSettings_ModemConfig;
|
||||
|
||||
typedef enum _DeviceState_Version {
|
||||
DeviceState_Version_Unset = 0,
|
||||
DeviceState_Version_Minimum = 17,
|
||||
DeviceState_Version_Current = 17
|
||||
} DeviceState_Version;
|
||||
|
||||
/* Struct definitions */
|
||||
typedef struct _ChannelSettings {
|
||||
int32_t tx_power;
|
||||
@@ -56,6 +50,9 @@ typedef struct _MyNodeInfo {
|
||||
int32_t my_node_num;
|
||||
bool has_gps;
|
||||
int32_t num_channels;
|
||||
char region[12];
|
||||
char hw_model[12];
|
||||
char firmware_version[12];
|
||||
} MyNodeInfo;
|
||||
|
||||
typedef struct _Position {
|
||||
@@ -135,9 +132,9 @@ typedef struct _DeviceState {
|
||||
NodeInfo node_db[32];
|
||||
pb_size_t receive_queue_count;
|
||||
MeshPacket receive_queue[32];
|
||||
DeviceState_Version version;
|
||||
bool has_rx_text_message;
|
||||
MeshPacket rx_text_message;
|
||||
uint32_t version;
|
||||
} DeviceState;
|
||||
|
||||
typedef struct _FromRadio {
|
||||
@@ -169,10 +166,6 @@ typedef struct _ToRadio {
|
||||
#define _ChannelSettings_ModemConfig_MAX ChannelSettings_ModemConfig_Bw125Cr48Sf4096
|
||||
#define _ChannelSettings_ModemConfig_ARRAYSIZE ((ChannelSettings_ModemConfig)(ChannelSettings_ModemConfig_Bw125Cr48Sf4096+1))
|
||||
|
||||
#define _DeviceState_Version_MIN DeviceState_Version_Unset
|
||||
#define _DeviceState_Version_MAX DeviceState_Version_Current
|
||||
#define _DeviceState_Version_ARRAYSIZE ((DeviceState_Version)(DeviceState_Version_Current+1))
|
||||
|
||||
|
||||
/* Initializer values for message structs */
|
||||
#define Position_init_default {0, 0, 0, 0, 0}
|
||||
@@ -184,8 +177,8 @@ typedef struct _ToRadio {
|
||||
#define RadioConfig_init_default {false, RadioConfig_UserPreferences_init_default, false, ChannelSettings_init_default}
|
||||
#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
#define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0, 0}
|
||||
#define MyNodeInfo_init_default {0, 0, 0}
|
||||
#define DeviceState_init_default {false, RadioConfig_init_default, false, MyNodeInfo_init_default, false, User_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default}, _DeviceState_Version_MIN, false, MeshPacket_init_default}
|
||||
#define MyNodeInfo_init_default {0, 0, 0, "", "", ""}
|
||||
#define DeviceState_init_default {false, RadioConfig_init_default, false, MyNodeInfo_init_default, false, User_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default}, false, MeshPacket_init_default, 0}
|
||||
#define FromRadio_init_default {0, 0, {MeshPacket_init_default}}
|
||||
#define ToRadio_init_default {0, {MeshPacket_init_default}}
|
||||
#define Position_init_zero {0, 0, 0, 0, 0}
|
||||
@@ -197,8 +190,8 @@ typedef struct _ToRadio {
|
||||
#define RadioConfig_init_zero {false, RadioConfig_UserPreferences_init_zero, false, ChannelSettings_init_zero}
|
||||
#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
#define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0, 0}
|
||||
#define MyNodeInfo_init_zero {0, 0, 0}
|
||||
#define DeviceState_init_zero {false, RadioConfig_init_zero, false, MyNodeInfo_init_zero, false, User_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero}, _DeviceState_Version_MIN, false, MeshPacket_init_zero}
|
||||
#define MyNodeInfo_init_zero {0, 0, 0, "", "", ""}
|
||||
#define DeviceState_init_zero {false, RadioConfig_init_zero, false, MyNodeInfo_init_zero, false, User_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero}, false, MeshPacket_init_zero, 0}
|
||||
#define FromRadio_init_zero {0, 0, {MeshPacket_init_zero}}
|
||||
#define ToRadio_init_zero {0, {MeshPacket_init_zero}}
|
||||
|
||||
@@ -213,6 +206,9 @@ typedef struct _ToRadio {
|
||||
#define MyNodeInfo_my_node_num_tag 1
|
||||
#define MyNodeInfo_has_gps_tag 2
|
||||
#define MyNodeInfo_num_channels_tag 3
|
||||
#define MyNodeInfo_region_tag 4
|
||||
#define MyNodeInfo_hw_model_tag 5
|
||||
#define MyNodeInfo_firmware_version_tag 6
|
||||
#define Position_latitude_tag 1
|
||||
#define Position_longitude_tag 2
|
||||
#define Position_altitude_tag 3
|
||||
@@ -255,7 +251,7 @@ typedef struct _ToRadio {
|
||||
#define DeviceState_owner_tag 3
|
||||
#define DeviceState_node_db_tag 4
|
||||
#define DeviceState_receive_queue_tag 5
|
||||
#define DeviceState_version_tag 6
|
||||
#define DeviceState_version_tag 8
|
||||
#define DeviceState_rx_text_message_tag 7
|
||||
#define FromRadio_packet_tag 2
|
||||
#define FromRadio_num_tag 1
|
||||
@@ -353,7 +349,10 @@ X(a, STATIC, SINGULAR, INT32, frequency_error, 6)
|
||||
#define MyNodeInfo_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, INT32, my_node_num, 1) \
|
||||
X(a, STATIC, SINGULAR, BOOL, has_gps, 2) \
|
||||
X(a, STATIC, SINGULAR, INT32, num_channels, 3)
|
||||
X(a, STATIC, SINGULAR, INT32, num_channels, 3) \
|
||||
X(a, STATIC, SINGULAR, STRING, region, 4) \
|
||||
X(a, STATIC, SINGULAR, STRING, hw_model, 5) \
|
||||
X(a, STATIC, SINGULAR, STRING, firmware_version, 6)
|
||||
#define MyNodeInfo_CALLBACK NULL
|
||||
#define MyNodeInfo_DEFAULT NULL
|
||||
|
||||
@@ -363,8 +362,8 @@ X(a, STATIC, OPTIONAL, MESSAGE, my_node, 2) \
|
||||
X(a, STATIC, OPTIONAL, MESSAGE, owner, 3) \
|
||||
X(a, STATIC, REPEATED, MESSAGE, node_db, 4) \
|
||||
X(a, STATIC, REPEATED, MESSAGE, receive_queue, 5) \
|
||||
X(a, STATIC, SINGULAR, UENUM, version, 6) \
|
||||
X(a, STATIC, OPTIONAL, MESSAGE, rx_text_message, 7)
|
||||
X(a, STATIC, OPTIONAL, MESSAGE, rx_text_message, 7) \
|
||||
X(a, STATIC, SINGULAR, UINT32, version, 8)
|
||||
#define DeviceState_CALLBACK NULL
|
||||
#define DeviceState_DEFAULT NULL
|
||||
#define DeviceState_radio_MSGTYPE RadioConfig
|
||||
@@ -426,8 +425,8 @@ extern const pb_msgdesc_t ToRadio_msg;
|
||||
#define RadioConfig_size 126
|
||||
#define RadioConfig_UserPreferences_size 72
|
||||
#define NodeInfo_size 155
|
||||
#define MyNodeInfo_size 24
|
||||
#define DeviceState_size 15021
|
||||
#define MyNodeInfo_size 63
|
||||
#define DeviceState_size 15064
|
||||
#define FromRadio_size 301
|
||||
#define ToRadio_size 295
|
||||
|
||||
|
||||
@@ -140,6 +140,7 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
||||
{
|
||||
MeshPacket &mp = devicestate.rx_text_message;
|
||||
NodeInfo *node = nodeDB.getNode(mp.from);
|
||||
// DEBUG_MSG("drawing text message from 0x%x: %s\n", mp.from, mp.payload.variant.data.payload.bytes);
|
||||
|
||||
// Demo for drawStringMaxWidth:
|
||||
// with the third parameter you can define the width after which words will be wrapped.
|
||||
@@ -445,11 +446,17 @@ void drawDebugInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, i
|
||||
|
||||
// We don't show battery levels yet - for now just lie and show debug info
|
||||
static char batStr[20];
|
||||
snprintf(batStr, sizeof(channelStr), "Batt %x%%", (isCharging << 1) + isUSBPowered);
|
||||
snprintf(batStr, sizeof(batStr), "Batt %x%%", (isCharging << 1) + isUSBPowered);
|
||||
|
||||
static char gpsStr[20];
|
||||
if (myNodeInfo.has_gps)
|
||||
snprintf(gpsStr, sizeof(gpsStr), "GPS %d%%", 75); // FIXME, use something based on hdop
|
||||
else
|
||||
gpsStr[0] = '\0'; // Just show emptystring
|
||||
|
||||
const char *fields[] = {
|
||||
batStr,
|
||||
"GPS 75%",
|
||||
gpsStr,
|
||||
usersStr,
|
||||
channelStr,
|
||||
NULL};
|
||||
@@ -500,17 +507,21 @@ void Screen::setOn(bool on)
|
||||
|
||||
if (on != screenOn)
|
||||
{
|
||||
if (on) {
|
||||
if (on)
|
||||
{
|
||||
DEBUG_MSG("Turning on screen\n");
|
||||
dispdev.displayOn();
|
||||
setPeriod(1); // redraw ASAP
|
||||
}
|
||||
else
|
||||
else {
|
||||
DEBUG_MSG("Turning off screen\n");
|
||||
dispdev.displayOff();
|
||||
}
|
||||
screenOn = on;
|
||||
}
|
||||
}
|
||||
|
||||
static void screen_print(const char *text, uint8_t x, uint8_t y, uint8_t alignment)
|
||||
void screen_print(const char *text, uint8_t x, uint8_t y, uint8_t alignment)
|
||||
{
|
||||
DEBUG_MSG(text);
|
||||
|
||||
@@ -613,7 +624,6 @@ void Screen::doTask()
|
||||
targetFramerate = IDLE_FRAMERATE;
|
||||
ui.setTargetFPS(targetFramerate);
|
||||
}
|
||||
ui.update();
|
||||
|
||||
// While showing the bluetooth pair screen all of our standard screen switching is stopped
|
||||
if (!showingBluetooth)
|
||||
@@ -624,7 +634,7 @@ void Screen::doTask()
|
||||
if (millis() > 3 * 1000) // we show the boot screen for a few seconds only
|
||||
{
|
||||
showingBootScreen = false;
|
||||
screen_set_frames();
|
||||
setFrames();
|
||||
}
|
||||
}
|
||||
else // standard screen loop handling ehre
|
||||
@@ -632,13 +642,16 @@ void Screen::doTask()
|
||||
// If the # nodes changes, we need to regen our list of screens
|
||||
if (nodeDB.updateGUI || nodeDB.updateTextMessage)
|
||||
{
|
||||
screen_set_frames();
|
||||
setFrames();
|
||||
nodeDB.updateGUI = false;
|
||||
nodeDB.updateTextMessage = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This must be after we possibly do screen_set_frames() to ensure we draw the new data
|
||||
ui.update();
|
||||
|
||||
// DEBUG_MSG("want fps %d, fixed=%d\n", targetFramerate, ui.getUiState()->frameState);
|
||||
// If we are scrolling we need to be called soon, otherwise just 1 fps (to save CPU)
|
||||
// We also ask to be called twice as fast as we really need so that any rounding errors still result
|
||||
@@ -665,7 +678,7 @@ void screen_start_bluetooth(uint32_t pin)
|
||||
}
|
||||
|
||||
// restore our regular frame list
|
||||
void screen_set_frames()
|
||||
void Screen::setFrames()
|
||||
{
|
||||
DEBUG_MSG("showing standard frames\n");
|
||||
|
||||
@@ -709,4 +722,4 @@ void Screen::onPress()
|
||||
targetFramerate = TRANSITION_FRAMERATE;
|
||||
ui.setTargetFPS(targetFramerate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "PeriodicTask.h"
|
||||
|
||||
void screen_print(const char * text);
|
||||
void screen_print(const char * text, uint8_t x, uint8_t y, uint8_t alignment);
|
||||
|
||||
|
||||
// Show the bluetooth PIN screen
|
||||
@@ -34,6 +35,10 @@ public:
|
||||
|
||||
/// Handle a button press
|
||||
void onPress();
|
||||
|
||||
/// Rebuilt our list of screens
|
||||
void setFrames();
|
||||
private:
|
||||
};
|
||||
|
||||
extern Screen screen;
|
||||
extern Screen screen;
|
||||
|
||||
Reference in New Issue
Block a user