kopia lustrzana https://github.com/meshtastic/firmware
commit
a47d6c4d68
|
@ -12,7 +12,7 @@
|
||||||
"type": "platformio-debug",
|
"type": "platformio-debug",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "PIO Debug",
|
"name": "PIO Debug",
|
||||||
"executable": "/home/kevinh/development/meshtastic/meshtastic-esp32/.pio/build/esp32/firmware.elf",
|
"executable": "/home/kevinh/development/meshtastic/meshtastic-esp32/.pio/build/tbeam/firmware.elf",
|
||||||
"toolchainBinDir": "/home/kevinh/.platformio/packages/toolchain-xtensa32/bin",
|
"toolchainBinDir": "/home/kevinh/.platformio/packages/toolchain-xtensa32/bin",
|
||||||
"preLaunchTask": {
|
"preLaunchTask": {
|
||||||
"type": "PlatformIO",
|
"type": "PlatformIO",
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
"type": "platformio-debug",
|
"type": "platformio-debug",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "PIO Debug (skip Pre-Debug)",
|
"name": "PIO Debug (skip Pre-Debug)",
|
||||||
"executable": "/home/kevinh/development/meshtastic/meshtastic-esp32/.pio/build/esp32/firmware.elf",
|
"executable": "/home/kevinh/development/meshtastic/meshtastic-esp32/.pio/build/tbeam/firmware.elf",
|
||||||
"toolchainBinDir": "/home/kevinh/.platformio/packages/toolchain-xtensa32/bin",
|
"toolchainBinDir": "/home/kevinh/.platformio/packages/toolchain-xtensa32/bin",
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,6 @@ source bin/version.sh
|
||||||
COUNTRIES="US EU433 EU865 CN JP"
|
COUNTRIES="US EU433 EU865 CN JP"
|
||||||
#COUNTRIES=US
|
#COUNTRIES=US
|
||||||
|
|
||||||
SRCMAP=.pio/build/esp32/output.map
|
|
||||||
SRCBIN=.pio/build/esp32/firmware.bin
|
|
||||||
SRCELF=.pio/build/esp32/firmware.elf
|
|
||||||
OUTDIR=release/latest
|
OUTDIR=release/latest
|
||||||
|
|
||||||
# We keep all old builds (and their map files in the archive dir)
|
# We keep all old builds (and their map files in the archive dir)
|
||||||
|
@ -17,25 +14,28 @@ ARCHIVEDIR=release/archive
|
||||||
|
|
||||||
rm -f $OUTDIR/firmware*
|
rm -f $OUTDIR/firmware*
|
||||||
|
|
||||||
|
# build the named environment and copy the bins to the release directory
|
||||||
|
function do_build {
|
||||||
|
ENV_NAME=$1
|
||||||
|
echo "Building for $ENV_NAME with $PLATFORMIO_BUILD_FLAGS"
|
||||||
|
SRCBIN=.pio/build/$ENV_NAME/firmware.bin
|
||||||
|
SRCELF=.pio/build/$ENV_NAME/firmware.elf
|
||||||
|
rm -f $SRCBIN
|
||||||
|
pio run --environment $ENV_NAME # -v
|
||||||
|
cp $SRCBIN $OUTDIR/firmware-$ENV_NAME-$COUNTRY-$VERSION.bin
|
||||||
|
cp $SRCELF $OUTDIR/firmware-$ENV_NAME-$COUNTRY-$VERSION.elf
|
||||||
|
}
|
||||||
|
|
||||||
for COUNTRY in $COUNTRIES; do
|
for COUNTRY in $COUNTRIES; do
|
||||||
|
|
||||||
HWVERSTR="1.0-$COUNTRY"
|
HWVERSTR="1.0-$COUNTRY"
|
||||||
COMMONOPTS="-DAPP_VERSION=$VERSION -DHW_VERSION_$COUNTRY -DHW_VERSION=$HWVERSTR -Wall -Wextra -Wno-missing-field-initializers -Isrc -Os -Wl,-Map,.pio/build/esp32/output.map -DAXP_DEBUG_PORT=Serial"
|
COMMONOPTS="-DAPP_VERSION=$VERSION -DHW_VERSION_$COUNTRY -DHW_VERSION=$HWVERSTR -Wall -Wextra -Wno-missing-field-initializers -Isrc -Os -DAXP_DEBUG_PORT=Serial"
|
||||||
|
|
||||||
export PLATFORMIO_BUILD_FLAGS="-DT_BEAM_V10 $COMMONOPTS"
|
export PLATFORMIO_BUILD_FLAGS="$COMMONOPTS"
|
||||||
echo "Building with $PLATFORMIO_BUILD_FLAGS"
|
|
||||||
rm -f $SRCBIN $SRCMAP
|
|
||||||
pio run # -v
|
|
||||||
cp $SRCBIN $OUTDIR/firmware-TBEAM-$COUNTRY-$VERSION.bin
|
|
||||||
cp $SRCELF $OUTDIR/firmware-TBEAM-$COUNTRY-$VERSION.elf
|
|
||||||
#cp $SRCMAP $ARCHIVEDIR/firmware-TBEAM-$COUNTRY-$VERSION.map
|
|
||||||
|
|
||||||
export PLATFORMIO_BUILD_FLAGS="-DHELTEC_LORA32 $COMMONOPTS"
|
do_build "ttgo-lora32-v1"
|
||||||
rm -f $SRCBIN $SRCMAP
|
do_build "tbeam"
|
||||||
pio run # -v
|
do_build "heltec"
|
||||||
cp $SRCBIN $OUTDIR/firmware-HELTEC-$COUNTRY-$VERSION.bin
|
|
||||||
cp $SRCELF $OUTDIR/firmware-HELTEC-$COUNTRY-$VERSION.elf
|
|
||||||
#cp $SRCMAP $ARCHIVEDIR/firmware-HELTEC-$COUNTRY-$VERSION.map
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# keep the bins in archive also
|
# keep the bins in archive also
|
||||||
|
|
|
@ -17,6 +17,7 @@ Items to complete soon (next couple of alpha releases).
|
||||||
|
|
||||||
Items to complete before the first beta release.
|
Items to complete before the first beta release.
|
||||||
|
|
||||||
|
- possibly switch to https://github.com/SlashDevin/NeoGPS for gps comms
|
||||||
- good source of battery/signal/gps icons https://materialdesignicons.com/
|
- good source of battery/signal/gps icons https://materialdesignicons.com/
|
||||||
- research and implement better mesh algorithm - investigate changing routing to https://github.com/sudomesh/LoRaLayer2 ?
|
- research and implement better mesh algorithm - 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/
|
- check fcc rules on duty cycle. we might not need to freq hop. https://www.sunfiretesting.com/LoRa-FCC-Certification-Guide/
|
||||||
|
|
|
@ -6,19 +6,15 @@ in these instructions I describe use of their command line tool.
|
||||||
1. Purchase a suitable radio (see above)
|
1. Purchase a suitable radio (see above)
|
||||||
2. Install [PlatformIO](https://platformio.org/platformio-ide)
|
2. Install [PlatformIO](https://platformio.org/platformio-ide)
|
||||||
3. Download this git repo and cd into it
|
3. Download this git repo and cd into it
|
||||||
4. Edit configuration.h and comment out *one* of the following two lines (depending on which board you are using):
|
4. If you are outside the USA, edit [platformio.ini](/platformio.ini) to set the correct frequency range for your country. The line you need to change starts with "hw_version" and instructions are provided above that line. Options are provided for EU433, EU835, CN, JP and US. Pull-requests eagerly accepted for other countries.
|
||||||
```
|
|
||||||
// #define T_BEAM_V10
|
|
||||||
#define HELTEC_LORA32
|
|
||||||
```
|
|
||||||
5. Plug the radio into your USB port
|
5. Plug the radio into your USB port
|
||||||
6. Type "pio run -t upload" (This command will fetch dependencies, build the project and install it on the board via USB)
|
6. Type "pio run --environment XXX -t upload" (This command will fetch dependencies, build the project and install it on the board via USB). For XXX, use the board type you have (either tbeam, heltec, ttgo-lora32-v1, ttgo-lora32-v2).
|
||||||
7. Platform IO also installs a very nice VisualStudio Code based IDE, see their [tutorial](https://docs.platformio.org/en/latest/tutorials/espressif32/arduino_debugging_unit_testing.html) if you'd like to use it
|
7. Platform IO also installs a very nice VisualStudio Code based IDE, see their [tutorial](https://docs.platformio.org/en/latest/tutorials/espressif32/arduino_debugging_unit_testing.html) if you'd like to use it.
|
||||||
|
|
||||||
|
|
||||||
## Decoding stack traces
|
## Decoding stack traces
|
||||||
|
|
||||||
If you get a crash, you can decode the addresses from the `Backtrace:` line:
|
If you get a crash, you can decode the addresses from the `Backtrace:` line:
|
||||||
|
|
||||||
1. Save the `Backtrace: 0x....` line to a file, e.g., `backtrace.txt`.
|
1. Save the `Backtrace: 0x....` line to a file, e.g., `backtrace.txt`.
|
||||||
2. Run `bin/exception_decoder.py backtrace.txt` (this uses symbols from the
|
2. Run `bin/exception_decoder.py backtrace.txt` (this uses symbols from the
|
||||||
last `firmware.elf`, so you must be running the same binary that's still in
|
last `firmware.elf`, so you must be running the same binary that's still in
|
||||||
|
|
|
@ -10,7 +10,7 @@ TODO:
|
||||||
* DONE read about mesh routing solutions (DSR and AODV)
|
* DONE read about mesh routing solutions (DSR and AODV)
|
||||||
* DONE read about general mesh flooding solutions (naive, MPR, geo assisted)
|
* DONE read about general mesh flooding solutions (naive, MPR, geo assisted)
|
||||||
* DONE reread the disaster radio protocol docs - seems based on Babel (which is AODVish)
|
* DONE reread the disaster radio protocol docs - seems based on Babel (which is AODVish)
|
||||||
* possibly dash7? https://www.slideshare.net/MaartenWeyn1/dash7-alliance-protocol-technical-presentation https://github.com/MOSAIC-LoPoW/dash7-ap-open-source-stack
|
* possibly dash7? https://www.slideshare.net/MaartenWeyn1/dash7-alliance-protocol-technical-presentation https://github.com/MOSAIC-LoPoW/dash7-ap-open-source-stack - does the opensource stack implement multihop routing? flooding? their discussion mailing list looks dead-dead
|
||||||
* update duty cycle spreadsheet for our typical usecase
|
* update duty cycle spreadsheet for our typical usecase
|
||||||
* generalize naive flooding on top of radiohead or disaster.radio? (and fix radiohead to use my new driver)
|
* generalize naive flooding on top of radiohead or disaster.radio? (and fix radiohead to use my new driver)
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,14 @@
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
|
default_envs = tbeam
|
||||||
|
|
||||||
[env:esp32]
|
[common]
|
||||||
|
; default to a US frequency range, change it as needed for your region and hardware (CN, JP, EU433, EU865)
|
||||||
|
hw_version = US
|
||||||
|
|
||||||
|
[env]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = ttgo-t-beam
|
|
||||||
; board = heltec_wifi_lora_32_V2
|
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
|
||||||
; customize the partition table
|
; customize the partition table
|
||||||
|
@ -22,14 +25,13 @@ board_build.partitions = partition-table.csv
|
||||||
|
|
||||||
; note: we add src to our include search path so that lmic_project_config can override
|
; note: we add src to our include search path so that lmic_project_config can override
|
||||||
; FIXME: fix lib/BluetoothOTA dependency back on src/ so we can remove -Isrc
|
; 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
|
build_flags = -Wall -Wextra -Wno-missing-field-initializers -Isrc -Os -Wl,-Map,.pio/build/output.map -DAXP_DEBUG_PORT=Serial -DHW_VERSION_${common.hw_version}
|
||||||
|
|
||||||
; not needed included in ttgo-t-beam board file
|
; 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
|
; also to use PSRAM https://docs.platformio.org/en/latest/platforms/espressif32.html#external-ram-psram
|
||||||
; -DBOARD_HAS_PSRAM
|
; -DBOARD_HAS_PSRAM
|
||||||
; -mfix-esp32-psram-cache-issue
|
; -mfix-esp32-psram-cache-issue
|
||||||
|
|
||||||
|
|
||||||
; -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
; -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
||||||
|
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
|
@ -55,8 +57,6 @@ debug_tool = jlink
|
||||||
|
|
||||||
debug_init_break = tbreak setup
|
debug_init_break = tbreak setup
|
||||||
|
|
||||||
; Note: some libraries are specified by #ID where there are conflicting library
|
|
||||||
; names.
|
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/meshtastic/RadioHead.git
|
https://github.com/meshtastic/RadioHead.git
|
||||||
https://github.com/meshtastic/esp8266-oled-ssd1306.git ; ESP8266_SSD1306
|
https://github.com/meshtastic/esp8266-oled-ssd1306.git ; ESP8266_SSD1306
|
||||||
|
@ -68,9 +68,19 @@ lib_deps =
|
||||||
https://github.com/meshtastic/arduino-fsm.git
|
https://github.com/meshtastic/arduino-fsm.git
|
||||||
https://github.com/meshtastic/SparkFun_Ublox_Arduino_Library.git
|
https://github.com/meshtastic/SparkFun_Ublox_Arduino_Library.git
|
||||||
|
|
||||||
;[env:tbeam]
|
[env:tbeam]
|
||||||
;board = ttgo-t-beam
|
board = ttgo-t-beam
|
||||||
|
lib_deps =
|
||||||
|
${env.lib_deps}
|
||||||
|
AXP202X_Library
|
||||||
|
|
||||||
;[env:heltec]
|
[env:heltec]
|
||||||
;build_type = debug ; to make it possible to step through our jtag debugger
|
;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
|
||||||
|
|
||||||
|
[env:ttgo-lora32-v1]
|
||||||
|
board = ttgo-lora32-v1
|
||||||
|
|
||||||
|
; note: the platformio definition for lora32-v2 seems stale, it is missing a pins_arduino.h file, therefore I don't think it works
|
||||||
|
; [env:ttgo-lora32-v2]
|
||||||
|
; board = ttgo-lora32-v2
|
|
@ -151,7 +151,7 @@ void MeshService::handleFromRadio(MeshPacket *mp)
|
||||||
mp->rx_time = gps.getValidTime(); // store the arrival timestamp for the phone
|
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 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)
|
if (!gps.isConnected)
|
||||||
handleIncomingPosition(mp);
|
handleIncomingPosition(mp);
|
||||||
else {
|
else {
|
||||||
DEBUG_MSG("Ignoring incoming time, because we have a GPS\n");
|
DEBUG_MSG("Ignoring incoming time, because we have a GPS\n");
|
||||||
|
@ -263,7 +263,7 @@ void MeshService::sendToMesh(MeshPacket *p)
|
||||||
// nodes shouldn't trust it anyways) Note: for now, we allow a device with a local GPS to include the time, so that gpsless
|
// nodes shouldn't trust it anyways) Note: for now, we allow a device with a local GPS to include the time, so that gpsless
|
||||||
// devices can get time.
|
// devices can get time.
|
||||||
if (p->has_payload && p->payload.which_variant == SubPacket_position_tag) {
|
if (p->has_payload && p->payload.which_variant == SubPacket_position_tag) {
|
||||||
if (!myNodeInfo.has_gps) {
|
if (!gps.isConnected) {
|
||||||
DEBUG_MSG("Stripping time %u from position send\n", p->payload.variant.position.time);
|
DEBUG_MSG("Stripping time %u from position send\n", p->payload.variant.position.time);
|
||||||
p->payload.variant.position.time = 0;
|
p->payload.variant.position.time = 0;
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -39,18 +39,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// Configuration
|
// Configuration
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Select which board is being used. If the outside build environment has sent a choice, just use that
|
|
||||||
#if !defined(T_BEAM_V10) && !defined(HELTEC_LORA32)
|
|
||||||
#define T_BEAM_V10 // AKA Rev1 (second board released)
|
|
||||||
// #define HELTEC_LORA32
|
|
||||||
|
|
||||||
#define HW_VERSION_US // We encode the hardware freq range in the hw version string, so sw update can eventually install the
|
|
||||||
// correct build
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// If we are using the JTAG port for debugging, some pins must be left free for that (and things like GPS have to be disabled)
|
// If we are using the JTAG port for debugging, some pins must be left free for that (and things like GPS have to be disabled)
|
||||||
// we don't support jtag on the ttgo - access to gpio 12 is a PITA
|
// we don't support jtag on the ttgo - access to gpio 12 is a PITA
|
||||||
#ifdef HELTEC_LORA32
|
#ifdef ARDUINO_HELTEC_WIFI_LORA_32_V2
|
||||||
//#define USE_JTAG
|
//#define USE_JTAG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -105,9 +96,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define MOSI_GPIO 27
|
#define MOSI_GPIO 27
|
||||||
#define NSS_GPIO 18
|
#define NSS_GPIO 18
|
||||||
|
|
||||||
#if defined(T_BEAM_V10)
|
#if defined(ARDUINO_T_Beam)
|
||||||
// This string must exactly match the case used in release file names or the android updater won't work
|
// 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 BUTTON_NEED_PULLUP // if set we need to turn on the internal CPU pullup during sleep
|
// #define BUTTON_NEED_PULLUP // if set we need to turn on the internal CPU pullup during sleep
|
||||||
|
|
||||||
|
@ -126,27 +117,61 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// Leave undefined to disable our PMU IRQ handler
|
// Leave undefined to disable our PMU IRQ handler
|
||||||
#define PMU_IRQ 35
|
#define PMU_IRQ 35
|
||||||
|
|
||||||
#elif defined(HELTEC_LORA32)
|
#elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V2)
|
||||||
// This string must exactly match the case used in release file names or the android updater won't work
|
// 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
|
#ifndef USE_JTAG // gpio15 is TDO for JTAG, so no I2C on this board while doing jtag
|
||||||
#define I2C_SDA 4
|
#define I2C_SDA 4 // I2C pins for this board
|
||||||
#define I2C_SCL 15
|
#define I2C_SCL 15
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define RESET_OLED 16
|
#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller
|
||||||
|
|
||||||
#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost
|
#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost
|
||||||
#define LED_PIN 25
|
#define LED_PIN 25 // If defined we will blink this LED
|
||||||
#define BUTTON_PIN 0
|
#define BUTTON_PIN 0 // If defined, this will be used for user button presses
|
||||||
|
|
||||||
#ifndef USE_JTAG
|
#ifndef USE_JTAG
|
||||||
#define RESET_GPIO 14
|
#define RESET_GPIO 14 // If defined, this pin will be used to reset the LORA radio
|
||||||
#endif
|
#endif
|
||||||
#define DIO0_GPIO 26
|
#define DIO0_GPIO 26
|
||||||
#define DIO1_GPIO 35
|
#define DIO1_GPIO 35 // DIO1 & DIO2 are not currently used, but they must be assigned to a pin number
|
||||||
#define DIO2_GPIO 34
|
#define DIO2_GPIO 34 // DIO1 & DIO2 are not currently used, but they must be assigned to a pin number
|
||||||
|
#elif defined(ARDUINO_TTGO_LoRa32_V1)
|
||||||
|
// This string must exactly match the case used in release file names or the android updater won't work
|
||||||
|
#define HW_VENDOR "ttgo-lora32-v1"
|
||||||
|
|
||||||
|
#define I2C_SDA 4 // I2C pins for this board
|
||||||
|
#define I2C_SCL 15
|
||||||
|
|
||||||
|
#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller
|
||||||
|
|
||||||
|
// #define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost
|
||||||
|
#define LED_PIN 2 // If defined we will blink this LED
|
||||||
|
#define BUTTON_PIN 0 // If defined, this will be used for user button presses
|
||||||
|
|
||||||
|
#define RESET_GPIO 23 // If defined, this pin will be used to reset the LORA radio
|
||||||
|
#define DIO0_GPIO 26 // IRQ line for the LORA radio
|
||||||
|
#define DIO1_GPIO 35 // DIO1 & DIO2 are not currently used, but they must be assigned to a pin number
|
||||||
|
#define DIO2_GPIO 34 // DIO1 & DIO2 are not currently used, but they must be assigned to a pin number
|
||||||
|
#elif defined(ARDUINO_TTGO_LoRa32_V2)
|
||||||
|
// This string must exactly match the case used in release file names or the android updater won't work
|
||||||
|
#define HW_VENDOR "ttgo-lora32-v2"
|
||||||
|
|
||||||
|
#define I2C_SDA 21 // I2C pins for this board
|
||||||
|
#define I2C_SCL 22
|
||||||
|
|
||||||
|
#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller
|
||||||
|
|
||||||
|
#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost
|
||||||
|
#define LED_PIN 2 // If defined we will blink this LED
|
||||||
|
#define BUTTON_PIN 0 // If defined, this will be used for user button presses
|
||||||
|
|
||||||
|
#define RESET_GPIO 23 // If defined, this pin will be used to reset the LORA radio
|
||||||
|
#define DIO0_GPIO 26 // IRQ line for the LORA radio
|
||||||
|
#define DIO1_GPIO 35 // DIO1 & DIO2 are not currently used, but they must be assigned to a pin number
|
||||||
|
#define DIO2_GPIO 34 // DIO1 & DIO2 are not currently used, but they must be assigned to a pin number
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
54
src/main.cpp
54
src/main.cpp
|
@ -39,7 +39,7 @@
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <driver/rtc_io.h>
|
#include <driver/rtc_io.h>
|
||||||
|
|
||||||
#ifdef T_BEAM_V10
|
#ifdef ARDUINO_T_Beam
|
||||||
#include "axp20x.h"
|
#include "axp20x.h"
|
||||||
AXP20X_Class axp;
|
AXP20X_Class axp;
|
||||||
bool pmu_irq = false;
|
bool pmu_irq = false;
|
||||||
|
@ -81,7 +81,7 @@ void scanI2Cdevice(void)
|
||||||
ssd1306_found = true;
|
ssd1306_found = true;
|
||||||
DEBUG_MSG("ssd1306 display found\n");
|
DEBUG_MSG("ssd1306 display found\n");
|
||||||
}
|
}
|
||||||
#ifdef T_BEAM_V10
|
#ifdef ARDUINO_T_Beam
|
||||||
if (addr == AXP192_SLAVE_ADDRESS) {
|
if (addr == AXP192_SLAVE_ADDRESS) {
|
||||||
axp192_found = true;
|
axp192_found = true;
|
||||||
DEBUG_MSG("axp192 PMU found\n");
|
DEBUG_MSG("axp192 PMU found\n");
|
||||||
|
@ -97,7 +97,7 @@ void scanI2Cdevice(void)
|
||||||
DEBUG_MSG("done\n");
|
DEBUG_MSG("done\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef T_BEAM_V10
|
#ifdef ARDUINO_T_Beam
|
||||||
/// Reads power status to powerStatus singleton.
|
/// Reads power status to powerStatus singleton.
|
||||||
//
|
//
|
||||||
// TODO(girts): move this and other axp stuff to power.h/power.cpp.
|
// TODO(girts): move this and other axp stuff to power.h/power.cpp.
|
||||||
|
@ -110,7 +110,7 @@ void readPowerStatus()
|
||||||
powerStatus.usb = axp.isVBUSPlug();
|
powerStatus.usb = axp.isVBUSPlug();
|
||||||
powerStatus.charging = axp.isChargeing();
|
powerStatus.charging = axp.isChargeing();
|
||||||
}
|
}
|
||||||
#endif // T_BEAM_V10
|
#endif // ARDUINO_T_Beam
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init the power manager chip
|
* Init the power manager chip
|
||||||
|
@ -123,7 +123,7 @@ void readPowerStatus()
|
||||||
*/
|
*/
|
||||||
void axp192Init()
|
void axp192Init()
|
||||||
{
|
{
|
||||||
#ifdef T_BEAM_V10
|
#ifdef ARDUINO_T_Beam
|
||||||
if (axp192_found) {
|
if (axp192_found) {
|
||||||
if (!axp.begin(Wire, AXP192_SLAVE_ADDRESS)) {
|
if (!axp.begin(Wire, AXP192_SLAVE_ADDRESS)) {
|
||||||
DEBUG_MSG("AXP192 Begin PASS\n");
|
DEBUG_MSG("AXP192 Begin PASS\n");
|
||||||
|
@ -173,13 +173,15 @@ void axp192Init()
|
||||||
axp.debugCharging();
|
axp.debugCharging();
|
||||||
|
|
||||||
#ifdef PMU_IRQ
|
#ifdef PMU_IRQ
|
||||||
pinMode(PMU_IRQ, INPUT_PULLUP);
|
pinMode(PMU_IRQ, INPUT);
|
||||||
attachInterrupt(
|
attachInterrupt(
|
||||||
PMU_IRQ, [] { pmu_irq = true; }, RISING);
|
PMU_IRQ, [] { pmu_irq = true; }, FALLING);
|
||||||
|
|
||||||
axp.adc1Enable(AXP202_BATT_CUR_ADC1, 1);
|
axp.adc1Enable(AXP202_BATT_CUR_ADC1, 1);
|
||||||
axp.enableIRQ(AXP202_VBUS_REMOVED_IRQ | AXP202_VBUS_CONNECT_IRQ | AXP202_BATT_REMOVED_IRQ | AXP202_BATT_CONNECT_IRQ,
|
axp.enableIRQ(AXP202_BATT_REMOVED_IRQ | AXP202_BATT_CONNECT_IRQ | AXP202_CHARGING_FINISHED_IRQ | AXP202_CHARGING_IRQ |
|
||||||
|
AXP202_VBUS_REMOVED_IRQ | AXP202_VBUS_CONNECT_IRQ | AXP202_PEK_SHORTPRESS_IRQ,
|
||||||
1);
|
1);
|
||||||
|
|
||||||
axp.clearIRQ();
|
axp.clearIRQ();
|
||||||
#endif
|
#endif
|
||||||
readPowerStatus();
|
readPowerStatus();
|
||||||
|
@ -355,23 +357,37 @@ void loop()
|
||||||
// for debug printing
|
// for debug printing
|
||||||
// service.radio.rf95.canSleep();
|
// service.radio.rf95.canSleep();
|
||||||
|
|
||||||
#ifdef T_BEAM_V10
|
|
||||||
if (axp192_found) {
|
|
||||||
#ifdef PMU_IRQ
|
#ifdef PMU_IRQ
|
||||||
if (pmu_irq) {
|
if (pmu_irq) {
|
||||||
pmu_irq = false;
|
pmu_irq = false;
|
||||||
axp.readIRQ();
|
axp.readIRQ();
|
||||||
|
|
||||||
DEBUG_MSG("pmu irq!\n");
|
DEBUG_MSG("pmu irq!\n");
|
||||||
|
|
||||||
readPowerStatus();
|
if (axp.isChargingIRQ()) {
|
||||||
|
DEBUG_MSG("Battery start charging\n");
|
||||||
axp.clearIRQ();
|
}
|
||||||
|
if (axp.isChargingDoneIRQ()) {
|
||||||
|
DEBUG_MSG("Battery fully charged\n");
|
||||||
|
}
|
||||||
|
if (axp.isVbusRemoveIRQ()) {
|
||||||
|
DEBUG_MSG("USB unplugged\n");
|
||||||
|
}
|
||||||
|
if (axp.isVbusPlugInIRQ()) {
|
||||||
|
DEBUG_MSG("USB plugged In\n");
|
||||||
|
}
|
||||||
|
if (axp.isBattPlugInIRQ()) {
|
||||||
|
DEBUG_MSG("Battery inserted\n");
|
||||||
|
}
|
||||||
|
if (axp.isBattRemoveIRQ()) {
|
||||||
|
DEBUG_MSG("Battery removed\n");
|
||||||
|
}
|
||||||
|
if (axp.isPEKShortPressIRQ()) {
|
||||||
|
DEBUG_MSG("PEK short button press\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME AXP192 interrupt is not firing, remove this temporary polling of battery state
|
|
||||||
readPowerStatus();
|
readPowerStatus();
|
||||||
#endif // PMU_IRQ
|
axp.clearIRQ();
|
||||||
}
|
}
|
||||||
#endif // T_BEAM_V10
|
#endif // T_BEAM_V10
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <driver/rtc_io.h>
|
#include <driver/rtc_io.h>
|
||||||
|
|
||||||
#ifdef T_BEAM_V10
|
#ifdef ARDUINO_T_Beam
|
||||||
#include "axp20x.h"
|
#include "axp20x.h"
|
||||||
extern AXP20X_Class axp;
|
extern AXP20X_Class axp;
|
||||||
#endif
|
#endif
|
||||||
|
@ -48,7 +48,7 @@ void setLed(bool ledOn)
|
||||||
digitalWrite(LED_PIN, ledOn);
|
digitalWrite(LED_PIN, ledOn);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef T_BEAM_V10
|
#ifdef ARDUINO_T_Beam
|
||||||
if (axp192_found) {
|
if (axp192_found) {
|
||||||
// blink the axp led
|
// blink the axp led
|
||||||
axp.setChgLEDMode(ledOn ? AXP20X_LED_LOW_LEVEL : AXP20X_LED_OFF);
|
axp.setChgLEDMode(ledOn ? AXP20X_LED_LOW_LEVEL : AXP20X_LED_OFF);
|
||||||
|
@ -60,7 +60,7 @@ void setGPSPower(bool on)
|
||||||
{
|
{
|
||||||
DEBUG_MSG("Setting GPS power=%d\n", on);
|
DEBUG_MSG("Setting GPS power=%d\n", on);
|
||||||
|
|
||||||
#ifdef T_BEAM_V10
|
#ifdef ARDUINO_T_Beam
|
||||||
if (axp192_found)
|
if (axp192_found)
|
||||||
axp.setPowerOutPut(AXP192_LDO3, on ? AXP202_ON : AXP202_OFF); // GPS main power
|
axp.setPowerOutPut(AXP192_LDO3, on ? AXP202_ON : AXP202_OFF); // GPS main power
|
||||||
#endif
|
#endif
|
||||||
|
@ -124,7 +124,7 @@ void doDeepSleep(uint64_t msecToWake)
|
||||||
|
|
||||||
setLed(false);
|
setLed(false);
|
||||||
|
|
||||||
#ifdef T_BEAM_V10
|
#ifdef ARDUINO_T_Beam
|
||||||
if (axp192_found) {
|
if (axp192_found) {
|
||||||
// No need to turn this off if the power draw in sleep mode really is just 0.2uA and turning it off would
|
// No need to turn this off if the power draw in sleep mode really is just 0.2uA and turning it off would
|
||||||
// leave floating input for the IRQ line
|
// leave floating input for the IRQ line
|
||||||
|
@ -155,17 +155,11 @@ void doDeepSleep(uint64_t msecToWake)
|
||||||
static const uint8_t rtcGpios[] = {/* 0, */ 2,
|
static const uint8_t rtcGpios[] = {/* 0, */ 2,
|
||||||
/* 4, */
|
/* 4, */
|
||||||
#ifndef USE_JTAG
|
#ifndef USE_JTAG
|
||||||
12,
|
12, 13,
|
||||||
13,
|
/* 14, */ /* 15, */
|
||||||
/* 14, */ /* 15, */
|
|
||||||
#endif
|
#endif
|
||||||
/* 25, */ 26, /* 27, */
|
/* 25, */ 26, /* 27, */
|
||||||
32,
|
32, 33, 34, 35, 36, 37,
|
||||||
33,
|
|
||||||
34,
|
|
||||||
35,
|
|
||||||
36,
|
|
||||||
37,
|
|
||||||
/* 38, */ 39};
|
/* 38, */ 39};
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(rtcGpios); i++)
|
for (int i = 0; i < sizeof(rtcGpios); i++)
|
||||||
|
@ -222,7 +216,8 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r
|
||||||
gpio_wakeup_enable((gpio_num_t)DIO0_GPIO, GPIO_INTR_HIGH_LEVEL); // RF95 interrupt, active high
|
gpio_wakeup_enable((gpio_num_t)DIO0_GPIO, GPIO_INTR_HIGH_LEVEL); // RF95 interrupt, active high
|
||||||
#ifdef PMU_IRQ
|
#ifdef PMU_IRQ
|
||||||
// FIXME, disable wake due to PMU because it seems to fire all the time?
|
// FIXME, disable wake due to PMU because it seems to fire all the time?
|
||||||
// gpio_wakeup_enable((gpio_num_t)PMU_IRQ, GPIO_INTR_HIGH_LEVEL); // pmu irq
|
if (axp192_found)
|
||||||
|
gpio_wakeup_enable((gpio_num_t)PMU_IRQ, GPIO_INTR_LOW_LEVEL); // pmu irq
|
||||||
#endif
|
#endif
|
||||||
assert(esp_sleep_enable_gpio_wakeup() == ESP_OK);
|
assert(esp_sleep_enable_gpio_wakeup() == ESP_OK);
|
||||||
assert(esp_sleep_enable_timer_wakeup(sleepUsec) == ESP_OK);
|
assert(esp_sleep_enable_timer_wakeup(sleepUsec) == ESP_OK);
|
||||||
|
|
Ładowanie…
Reference in New Issue