From 05b9fd04c6a393221ab8cf6e13979b762b3c0bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 2 Nov 2022 15:08:49 +0100 Subject: [PATCH 01/32] switch submodule branch to develop --- .gitmodules | 1 + protobufs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index e6f376a0b..238eda7de 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "protobufs"] path = protobufs url = https://github.com/meshtastic/protobufs.git + branch = develop diff --git a/protobufs b/protobufs index ed9f2499d..fa47c6455 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit ed9f2499d692925461facd64c6af2d2a7672245a +Subproject commit fa47c64558473c806ca6535d407df7409acbc283 From cae75dcb6da79e43e52856a25f29d652f3c7f863 Mon Sep 17 00:00:00 2001 From: code8buster Date: Sun, 30 Oct 2022 22:27:16 -0400 Subject: [PATCH 02/32] Rearranging deck chairs, 900M22S working, 30S not --- variants/diy/dr-dev/variant.h | 51 ++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/variants/diy/dr-dev/variant.h b/variants/diy/dr-dev/variant.h index 6356cad14..e670c5a91 100644 --- a/variants/diy/dr-dev/variant.h +++ b/variants/diy/dr-dev/variant.h @@ -1,47 +1,54 @@ // For OLED LCD -#define I2C_SDA 21 -#define I2C_SCL 22 +#define HAS_WIRE 0 +#define HAS_SCREEN 0 +#define I2C_SDA 4 +#define I2C_SCL 5 // GPS #undef GPS_RX_PIN #define GPS_RX_PIN NOT_A_PIN -#undef WANT_GPS +#define HAS_GPS 0 -#define BUTTON_PIN 2 // The middle button GPIO on the T-Beam +#define BUTTON_PIN 13 // The middle button GPIO on the T-Beam #define BUTTON_NEED_PULLUP #define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975). -#define LORA_DIO0 -1 // a No connect on the SX1262/SX1268 module -#define LORA_RESET -1 // RST for SX1276, and for SX1262/SX1268 -#define LORA_DIO1 27 // IRQ for SX1262/SX1268 (IO26 FOR 22S) -#define LORA_DIO2 NOT_A_PIN // BUSY for SX1262/SX1268 -#define LORA_DIO3 // Not connected on PCB, but internally on the SX1262/SX1268, if DIO3 is high the TXCO is enabled +#define LORA_DIO0 NOT_A_PIN // a No connect on the SX1262/SX1268 module +#define LORA_RESET NOT_A_PIN // RST for SX1276, and for SX1262/SX1268 +#define LORA_DIO3 NOT_A_PIN // Not connected on PCB, but internally on the SX1262/SX1268, if DIO3 is high the TXCO is enabled // In transmitting, set TXEN as high communication level,RXEN pin is low level; // In receiving, set RXEN as high communication level, TXEN is lowlevel; // Before powering off, set TXEN、RXEN as low level. -#define LORA_RXEN 17 // Input - RF switch RX control, connecting external MCU IO, valid in high level -#define LORA_TXEN -1 // Input - RF switch TX control, connecting external MCU IO or DIO2, valid in high level -/* --PINS FOR THE 900M22S + #undef RF95_SCK #define RF95_SCK 18 #undef RF95_MISO #define RF95_MISO 19 #undef RF95_MOSI #define RF95_MOSI 23 + +// --PINS FOR THE 900M22S + +#define LORA_DIO1 26 // IRQ for SX1262/SX1268 +#define LORA_DIO2 22 // BUSY for SX1262/SX1268 +#define LORA_TXEN NOT_A_PIN // Input - RF switch TX control, connecting external MCU IO or DIO2, valid in high level +#define LORA_RXEN 17 // Input - RF switch RX control, connecting external MCU IO, valid in high level #undef RF95_NSS #define RF95_NSS 16 -*/ +#define SX126X_BUSY 22 + // PINS FOR THE 900M30S -#undef RF95_SCK -#define RF95_SCK 18 -#undef RF95_MISO -#define RF95_MISO 19 -#undef RF95_MOSI -#define RF95_MOSI 23 +/* +#define LORA_DIO1 27 // IRQ for SX1262/SX1268 +#define LORA_RXEN 21 // Input - RF switch RX control, connecting external MCU IO, valid in high level +#define LORA_DIO2 35 // BUSY for SX1262/SX1268 +#define LORA_TXEN NOT_A_PIN // Input - RF switch TX control, connecting external MCU IO or DIO2, valid in high level #undef RF95_NSS #define RF95_NSS 33 +#define SX126X_BUSY 35 +*/ // RX/TX for RFM95/SX127x #define RF95_RXEN LORA_RXEN @@ -51,7 +58,6 @@ // common pinouts for SX126X modules #define SX126X_CS 33 #define SX126X_DIO1 LORA_DIO1 -#define SX126X_BUSY 35 #define SX126X_RESET LORA_RESET #define SX126X_RXEN LORA_RXEN #define SX126X_TXEN LORA_TXEN @@ -61,9 +67,4 @@ #define USE_SX1262 #define USE_SX1268 #define USE_LLCC68 - -#ifdef EBYTE_E22 -// Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch -// (which is the default for the sx1262interface code) #define SX126X_E22 -#endif From 15a8710e694c9b6ec5f7d36673d61bdfdd04cfac Mon Sep 17 00:00:00 2001 From: code8buster Date: Sun, 30 Oct 2022 22:30:33 -0400 Subject: [PATCH 03/32] We do have wire, just not where it's expected --- variants/diy/dr-dev/variant.h | 1 - 1 file changed, 1 deletion(-) diff --git a/variants/diy/dr-dev/variant.h b/variants/diy/dr-dev/variant.h index e670c5a91..b756536af 100644 --- a/variants/diy/dr-dev/variant.h +++ b/variants/diy/dr-dev/variant.h @@ -1,5 +1,4 @@ // For OLED LCD -#define HAS_WIRE 0 #define HAS_SCREEN 0 #define I2C_SDA 4 #define I2C_SCL 5 From 0ce018cf97bd153e19bdbe45442106b1852d4259 Mon Sep 17 00:00:00 2001 From: code8buster Date: Mon, 31 Oct 2022 21:39:11 -0400 Subject: [PATCH 04/32] Put more of the module specific pins in their blocks --- variants/diy/dr-dev/variant.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/variants/diy/dr-dev/variant.h b/variants/diy/dr-dev/variant.h index b756536af..7d0625907 100644 --- a/variants/diy/dr-dev/variant.h +++ b/variants/diy/dr-dev/variant.h @@ -1,4 +1,4 @@ -// For OLED LCD +// Initialize i2c bus on sd_dat and esp_led pins, respectively. We need a bus to not hang on boot #define HAS_SCREEN 0 #define I2C_SDA 4 #define I2C_SCL 5 @@ -27,7 +27,7 @@ #undef RF95_MOSI #define RF95_MOSI 23 -// --PINS FOR THE 900M22S +// PINS FOR THE 900M22S #define LORA_DIO1 26 // IRQ for SX1262/SX1268 #define LORA_DIO2 22 // BUSY for SX1262/SX1268 @@ -36,17 +36,19 @@ #undef RF95_NSS #define RF95_NSS 16 #define SX126X_BUSY 22 +#define SX126X_CS 16 // PINS FOR THE 900M30S /* #define LORA_DIO1 27 // IRQ for SX1262/SX1268 -#define LORA_RXEN 21 // Input - RF switch RX control, connecting external MCU IO, valid in high level #define LORA_DIO2 35 // BUSY for SX1262/SX1268 #define LORA_TXEN NOT_A_PIN // Input - RF switch TX control, connecting external MCU IO or DIO2, valid in high level +#define LORA_RXEN 21 // Input - RF switch RX control, connecting external MCU IO, valid in high level #undef RF95_NSS #define RF95_NSS 33 #define SX126X_BUSY 35 +#define SX126X_CS 33 */ // RX/TX for RFM95/SX127x @@ -55,15 +57,15 @@ // #define RF95_TCXO // common pinouts for SX126X modules -#define SX126X_CS 33 + #define SX126X_DIO1 LORA_DIO1 #define SX126X_RESET LORA_RESET #define SX126X_RXEN LORA_RXEN #define SX126X_TXEN LORA_TXEN // supported modules list -#define USE_RF95 // RFM95/SX127x +//#define USE_RF95 // RFM95/SX127x #define USE_SX1262 -#define USE_SX1268 -#define USE_LLCC68 +//#define USE_SX1268 +//#define USE_LLCC68 #define SX126X_E22 From 57ca5fea81d572879f8dc48f5b8775c0a6291cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 2 Nov 2022 10:17:59 +0100 Subject: [PATCH 05/32] tryfix compile with NO_SCREEN --- src/graphics/Screen.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index cee00f174..23828b3ee 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -10,7 +10,7 @@ namespace graphics class Screen { public: - Screen(char){} + explicit Screen(char){} void onPress() {} void setup() {} void setOn(bool) {} From b1f2025558601066ba3bd914fcbb22b63ac85bf5 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Wed, 2 Nov 2022 12:58:14 +0100 Subject: [PATCH 06/32] Portduino only: don't continue to try rebooting (#1887) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Thomas Göttgens --- src/shutdown.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/shutdown.h b/src/shutdown.h index 678a1401c..3927825fb 100644 --- a/src/shutdown.h +++ b/src/shutdown.h @@ -13,7 +13,8 @@ void powerCommandsCheck() #elif defined(ARCH_NRF52) NVIC_SystemReset(); #else - DEBUG_MSG("FIXME implement reboot for this platform"); + rebootAtMsec = -1; + DEBUG_MSG("FIXME implement reboot for this platform. Skipping for now.\n"); #endif } From 3e82cd7dd46e0368671fa42acbfab9af9167e904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 2 Nov 2022 13:12:15 +0100 Subject: [PATCH 07/32] Support for TLORA 2.1-1.8 --- src/main.cpp | 10 +++--- src/mesh/InterfacesTemplates.cpp | 2 +- ...X1281Interface.cpp => SX1280Interface.cpp} | 4 +-- .../{SX1281Interface.h => SX1280Interface.h} | 6 ++-- src/mesh/SX128xInterface.h | 2 +- src/platform/esp32/architecture.h | 2 ++ variants/tlora_v2_1_18/platformio.ini | 7 ++++ variants/tlora_v2_1_18/variant.h | 33 +++++++++++++++++++ 8 files changed, 54 insertions(+), 12 deletions(-) rename src/mesh/{SX1281Interface.cpp => SX1280Interface.cpp} (72%) rename src/mesh/{SX1281Interface.h => SX1280Interface.h} (52%) create mode 100644 variants/tlora_v2_1_18/platformio.ini create mode 100644 variants/tlora_v2_1_18/variant.h diff --git a/src/main.cpp b/src/main.cpp index 20bbcd085..8836b6460 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,7 +51,7 @@ #include "RF95Interface.h" #include "SX1262Interface.h" #include "SX1268Interface.h" -#include "SX1281Interface.h" +#include "SX1280Interface.h" #if !HAS_RADIO && defined(ARCH_PORTDUINO) #include "platform/portduino/SimRadio.h" #endif @@ -372,15 +372,15 @@ void setup() } #endif -#if defined(USE_SX1281) && !defined(ARCH_PORTDUINO) +#if defined(USE_SX1280) && !defined(ARCH_PORTDUINO) if (!rIf) { - rIf = new SX1281Interface(SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY, SPI); + rIf = new SX1280Interface(SX128X_CS, SX128X_DIO1, SX128X_RESET, SX128X_BUSY, SPI); if (!rIf->init()) { - DEBUG_MSG("Warning: Failed to find SX1281 radio\n"); + DEBUG_MSG("Warning: Failed to find SX1280 radio\n"); delete rIf; rIf = NULL; } else { - DEBUG_MSG("SX1281 Radio init succeeded, using SX1281 radio\n"); + DEBUG_MSG("SX1280 Radio init succeeded, using SX1280 radio\n"); rIf_wide_lora = true; } } diff --git a/src/mesh/InterfacesTemplates.cpp b/src/mesh/InterfacesTemplates.cpp index 6707813db..ccef2df23 100644 --- a/src/mesh/InterfacesTemplates.cpp +++ b/src/mesh/InterfacesTemplates.cpp @@ -9,5 +9,5 @@ template class SX126xInterface; template class SX126xInterface; #if !defined(ARCH_PORTDUINO) -template class SX128xInterface; +template class SX128xInterface; #endif \ No newline at end of file diff --git a/src/mesh/SX1281Interface.cpp b/src/mesh/SX1280Interface.cpp similarity index 72% rename from src/mesh/SX1281Interface.cpp rename to src/mesh/SX1280Interface.cpp index 50805cfe0..37aad1d40 100644 --- a/src/mesh/SX1281Interface.cpp +++ b/src/mesh/SX1280Interface.cpp @@ -1,10 +1,10 @@ #include "configuration.h" -#include "SX1281Interface.h" +#include "SX1280Interface.h" #include "error.h" #if !defined(ARCH_PORTDUINO) -SX1281Interface::SX1281Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy, +SX1280Interface::SX1280Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy, SPIClass &spi) : SX128xInterface(cs, irq, rst, busy, spi) { diff --git a/src/mesh/SX1281Interface.h b/src/mesh/SX1280Interface.h similarity index 52% rename from src/mesh/SX1281Interface.h rename to src/mesh/SX1280Interface.h index 3bd65309a..1c2e24900 100644 --- a/src/mesh/SX1281Interface.h +++ b/src/mesh/SX1280Interface.h @@ -3,15 +3,15 @@ #include "SX128xInterface.h" /** - * Our adapter for SX1281 radios + * Our adapter for SX1280 radios */ #if !defined(ARCH_PORTDUINO) -class SX1281Interface : public SX128xInterface +class SX1280Interface : public SX128xInterface { public: - SX1281Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy, SPIClass &spi); + SX1280Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy, SPIClass &spi); }; #endif \ No newline at end of file diff --git a/src/mesh/SX128xInterface.h b/src/mesh/SX128xInterface.h index d01dfc510..f712b8bc4 100644 --- a/src/mesh/SX128xInterface.h +++ b/src/mesh/SX128xInterface.h @@ -6,7 +6,7 @@ /** * \brief Adapter for SX128x radio family. Implements common logic for child classes. - * \tparam T RadioLib module type for SX128x: SX1281. + * \tparam T RadioLib module type for SX128x: SX1280. */ template class SX128xInterface : public RadioLibInterface diff --git a/src/platform/esp32/architecture.h b/src/platform/esp32/architecture.h index 18253abe5..00d221691 100644 --- a/src/platform/esp32/architecture.h +++ b/src/platform/esp32/architecture.h @@ -70,6 +70,8 @@ #define HW_VENDOR HardwareModel_TLORA_V1_1P3 #elif defined(TLORA_V2_1_16) #define HW_VENDOR HardwareModel_TLORA_V2_1_1P6 +#elif defined(TLORA_V2_1_18) + #define HW_VENDOR HardwareModel_TLORA_V2_1_1P8 #elif defined(GENIEBLOCKS) #define HW_VENDOR HardwareModel_GENIEBLOCKS #elif defined(PRIVATE_HW) diff --git a/variants/tlora_v2_1_18/platformio.ini b/variants/tlora_v2_1_18/platformio.ini new file mode 100644 index 000000000..2cb1c3d2f --- /dev/null +++ b/variants/tlora_v2_1_18/platformio.ini @@ -0,0 +1,7 @@ +[env:tlora-v2-1-1.8] +extends = esp32_base +board = ttgo-lora32-v21 +lib_deps = + ${esp32_base.lib_deps} +build_flags = + ${esp32_base.build_flags} -D TLORA_V2_1_18 -I variants/tlora_v2_1_18 \ No newline at end of file diff --git a/variants/tlora_v2_1_18/variant.h b/variants/tlora_v2_1_18/variant.h new file mode 100644 index 000000000..cd693a3d2 --- /dev/null +++ b/variants/tlora_v2_1_18/variant.h @@ -0,0 +1,33 @@ +#undef GPS_RX_PIN +#undef GPS_TX_PIN +#define GPS_RX_PIN 15 // per @der_bear on the forum, 36 is incorrect for this board type and 15 is a better pick +#define GPS_TX_PIN 13 + +#define EXT_NOTIFY_OUT 2 // Default pin to use for Ext Notify Module. + +#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +// ratio of voltage divider = 2.0 (R42=100k, R43=100k) +#define ADC_MULTIPLIER 2.11 // 2.0 + 10% for correction of display undervoltage. + +#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. Crashes on newer ESP-IDF and not needed per schematic + +#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost +#define LED_PIN 25 // If defined we will blink this LED +#define BUTTON_PIN 12 // If defined, this will be used for user button presses, + +#define BUTTON_NEED_PULLUP + +#define USE_SX1280 +#define LORA_DIO0 26 // a No connect on the SX1262 module +#define LORA_RESET 23 + +#define SX128X_CS 18 // FIXME - we really should define LORA_CS instead +#define SX128X_DIO1 33 +#define SX128X_BUSY 32 +#define SX128X_RESET LORA_RESET +#define SX128X_E22 // Not really an E22 but TTGO seems to be trying to clone that +// Internally the TTGO module hooks the SX1280-DIO2 in to control the TX/RX switch (which is the default for the sx1280interface +// code) From ac4e88e0d2676da8b8a605aef11efffedf73142e Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Wed, 2 Nov 2022 13:18:15 +0100 Subject: [PATCH 08/32] Don't allow arbitrary channel name for admin (#1886) Co-authored-by: Ben Meadors --- src/mesh/MeshModule.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/mesh/MeshModule.cpp b/src/mesh/MeshModule.cpp index 7b204ae49..ca1fb5b50 100644 --- a/src/mesh/MeshModule.cpp +++ b/src/mesh/MeshModule.cpp @@ -109,10 +109,7 @@ void MeshModule::callPlugins(const MeshPacket &mp, RxSource src) /// Also: if a packet comes in on the local PC interface, we don't check for bound channels, because it is TRUSTED and it needs to /// to be able to fetch the initial admin packets without yet knowing any channels. - bool rxChannelOk = !pi.boundChannel || (mp.from == 0) || - !ch || - strlen(ch->settings.name) > 0 || - (strcasecmp(ch->settings.name, pi.boundChannel) == 0); + bool rxChannelOk = !pi.boundChannel || (mp.from == 0) || (strcasecmp(ch->settings.name, pi.boundChannel) == 0); if (!rxChannelOk) { // no one should have already replied! From ef18b173cdee1cb1482561ff6cb28353ac1e7758 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 2 Nov 2022 07:48:14 -0500 Subject: [PATCH 09/32] Experimental DIY nrf52840 feather support (#1884) * Experimental DIY nrf52840 feather support * Fix target * sx1262 wiring * Remove lib --- .github/workflows/main_matrix.yml | 2 ++ src/platform/nrf52/architecture.h | 2 +- variants/feather_diy/platformio.ini | 11 ++++++++++ variants/feather_diy/variant.h | 33 +++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 variants/feather_diy/platformio.ini create mode 100644 variants/feather_diy/variant.h diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 06a229312..66bf7539c 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -42,6 +42,7 @@ jobs: - board: m5stack-core - board: m5stack-coreink - board: tbeam-s3-core + - board: feather_diy # - board: pico runs-on: ubuntu-latest @@ -181,6 +182,7 @@ jobs: - board: rak4631_eink - board: t-echo - board: pca10059_diy_eink + - board: feather_diy runs-on: ubuntu-latest steps: diff --git a/src/platform/nrf52/architecture.h b/src/platform/nrf52/architecture.h index 47d95c92d..986a864c9 100644 --- a/src/platform/nrf52/architecture.h +++ b/src/platform/nrf52/architecture.h @@ -45,7 +45,7 @@ #define HW_VENDOR HardwareModel_T_ECHO #elif defined(NORDIC_PCA10059) #define HW_VENDOR HardwareModel_NRF52840_PCA10059 -#elif defined(PRIVATE_HW) +#elif defined(PRIVATE_HW) || defined(FEATHER_DIY) #define HW_VENDOR HardwareModel_PRIVATE_HW #else #define HW_VENDOR HardwareModel_NRF52_UNKNOWN diff --git a/variants/feather_diy/platformio.ini b/variants/feather_diy/platformio.ini new file mode 100644 index 000000000..446011cb9 --- /dev/null +++ b/variants/feather_diy/platformio.ini @@ -0,0 +1,11 @@ +; The very slick RAK wireless RAK 4631 / 4630 board - Unified firmware for 5005/19003, with or without OLED RAK 1921 +[env:feather_diy] +extends = nrf52840_base +board = adafruit_feather_nrf52840 +build_flags = ${nrf52840_base.build_flags} -Ivariants/feather_diy -D feather_diy +build_src_filter = ${nrf52_base.build_src_filter} +<../variants/feather_diy> +lib_deps = + ${nrf52840_base.lib_deps} +debug_tool = jlink +; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) +;upload_protocol = jlink \ No newline at end of file diff --git a/variants/feather_diy/variant.h b/variants/feather_diy/variant.h new file mode 100644 index 000000000..8327e6050 --- /dev/null +++ b/variants/feather_diy/variant.h @@ -0,0 +1,33 @@ +// For OLED LCD +#define I2C_SDA 22 +#define I2C_SCL 23 + +#define BUTTON_PIN 7 + +#define LORA_DIO0 -1 // a No connect on the SX1262/SX1268 module +#define LORA_RESET 13 // RST for SX1276, and for SX1262/SX1268 +#define LORA_DIO1 11 // IRQ for SX1262/SX1268 +#define LORA_DIO2 12 // BUSY for SX1262/SX1268 +#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262/SX1268, if DIO3 is high the TXCO is enabled + +#define RF95_SCK SCK +#define RF95_MISO MI +#define RF95_MOSI MO +#define RF95_NSS D2 + +// supported modules list +#define USE_SX1262 + +// common pinouts for SX126X modules +#define SX126X_CS RF95_NSS // NSS for SX126X +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY LORA_DIO2 +#define SX126X_RESET LORA_RESET +#define SX126X_RXEN 10 +#define SX126X_TXEN 9 + +#ifdef EBYTE_E22 +// Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch +// (which is the default for the sx1262interface code) +#define SX126X_E22 +#endif From 09ddde177c430b86bb26a963b80d674361a0b825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 2 Nov 2022 18:23:41 +0100 Subject: [PATCH 10/32] codec2 Audio Support for SX1280 (untested) --- src/modules/Modules.cpp | 12 +- src/modules/esp32/AudioModule.cpp | 249 ++++++++++++++++++++++++++ src/modules/esp32/AudioModule.h | 68 +++++++ variants/tlora_v2_1_18/platformio.ini | 1 + 4 files changed, 325 insertions(+), 5 deletions(-) create mode 100644 src/modules/esp32/AudioModule.cpp create mode 100644 src/modules/esp32/AudioModule.h diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index 986a375df..d24fa8f26 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -19,6 +19,9 @@ #ifdef ARCH_ESP32 #include "modules/esp32/RangeTestModule.h" #include "modules/esp32/StoreForwardModule.h" +#ifdef USE_SX1280 +#include "modules/esp32/AudioModule.h" +#endif #endif #if defined(ARCH_ESP32) || defined(ARCH_NRF52) #include "modules/ExternalNotificationModule.h" @@ -65,17 +68,16 @@ void setupModules() #endif #ifdef ARCH_ESP32 // Only run on an esp32 based device. - - /* - Maintained by MC Hamster (Jm Casler) jm@casler.org - */ +#ifdef USE_SX1280 + new AudioModule(); +#endif new ExternalNotificationModule(); storeForwardModule = new StoreForwardModule(); new RangeTestModule(); #elif defined(ARCH_NRF52) -new ExternalNotificationModule(); + new ExternalNotificationModule(); #endif // NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra acks diff --git a/src/modules/esp32/AudioModule.cpp b/src/modules/esp32/AudioModule.cpp new file mode 100644 index 000000000..9328bdd81 --- /dev/null +++ b/src/modules/esp32/AudioModule.cpp @@ -0,0 +1,249 @@ +#include "configuration.h" +#include "AudioModule.h" +#include "MeshService.h" +#include "NodeDB.h" +#include "RTC.h" +#include "Router.h" +#include "FSCommon.h" + +#include + +/* + AudioModule + A interface to send raw codec2 audio data over the mesh network. Based on the example code from the ESP32_codec2 project. + https://github.com/deulis/ESP32_Codec2 + + Codec 2 is a low-bitrate speech audio codec (speech coding) + that is patent free and open source develop by David Grant Rowe. + http://www.rowetel.com/ and https://github.com/drowe67/codec2 + + Basic Usage: + 1) Enable the module by setting audio.codec2_enabled to 1. + 2) Set the pins (audio.mic_pin / audio.amp_pin) for your preferred microphone and amplifier GPIO pins. + On tbeam, recommend to use: + audio.mic_chan 7 (GPIO 35) + audio.amp_pin 25 (GPIO 25) + 3) Set audio.timeout to the amount of time to wait before we consider + your voice stream as "done". + 4) Set audio.bitrate to the desired codec2 rate (CODEC2_3200, CODEC2_2400, CODEC2_1600, CODEC2_1400, CODEC2_1300, CODEC2_1200, CODEC2_700, CODEC2_700B) + + KNOWN PROBLEMS + * Until the module is initilized by the startup sequence, the amp_pin pin is in a floating + state. This may produce a bit of "noise". + * Will not work on NRF and the Linux device targets. +*/ + +#define AMIC 7 +#define AAMP 25 +#define PTT_PIN 39 + +#define AUDIO_MODULE_RX_BUFFER 128 +#define AUDIO_MODULE_DATA_MAX Constants_DATA_PAYLOAD_LEN +#define AUDIO_MODULE_MODE 7 // 700B +#define AUDIO_MODULE_ACK 1 + +AudioModule *audioModule; + +#if defined(ARCH_ESP32) && defined(USE_SX1280) +ButterworthFilter hp_filter(240, 8000, ButterworthFilter::ButterworthFilter::Highpass, 1); +#endif + +//int16_t 1KHz sine test tone +int16_t Sine1KHz[8] = { -21210 , -30000, -21210, 0 , 21210 , 30000 , 21210, 0 }; +int Sine1KHz_index = 0; + +uint8_t rx_raw_audio_value = 127; + +AudioModule::AudioModule() : SinglePortModule("AudioModule", PortNum_AUDIO_APP), concurrency::OSThread("AudioModule") {} + +void AudioModule::run_codec2() +{ +#if defined(ARCH_ESP32) && defined(USE_SX1280) + if (state == State::tx) + { + for (int i = 0; i < ADC_BUFFER_SIZE; i++) + speech[i] = (int16_t)hp_filter.Update((float)speech[i]); + + codec2_encode(codec2_state, tx_encode_frame + tx_encode_frame_index, speech); + + //increment the pointer where the encoded frame must be saved + tx_encode_frame_index += 8; + + //If it is the 5th time then we have a ready trasnmission frame + if (tx_encode_frame_index == ENCODE_FRAME_SIZE) + { + tx_encode_frame_index = 0; + //Transmit it + sendPayload(); + } + } + if (state == State::rx) //Receiving + { + //Make a cycle to get each codec2 frame from the received frame + for (int i = 0; i < ENCODE_FRAME_SIZE; i += 8) + { + //Decode the codec2 frame + codec2_decode(codec2_state, output_buffer, rx_encode_frame + i); + + // Add to the audio buffer the 320 samples resulting of the decode of the codec2 frame. + for (int g = 0; g < ADC_BUFFER_SIZE; g++) + audio_fifo.put(output_buffer[g]); + } + } + state = State::standby; +#endif +} + +void AudioModule::handleInterrupt() +{ + audioModule->onTimer(); +} + +void AudioModule::onTimer() +{ +#if defined(ARCH_ESP32) && defined(USE_SX1280) + if (state == State::tx) { + adc_buffer[adc_buffer_index++] = (16 * adc1_get_raw(mic_chan)) - 32768; + + //If you want to test with a 1KHz tone, comment the line above and descomment the three lines below + + // adc_buffer[adc_buffer_index++] = Sine1KHz[Sine1KHz_index++]; + // if (Sine1KHz_index >= 8) + // Sine1KHz_index = 0; + + if (adc_buffer_index == ADC_BUFFER_SIZE) { + adc_buffer_index = 0; + memcpy((void*)speech, (void*)adc_buffer, 2 * ADC_BUFFER_SIZE); + audioModule->setIntervalFromNow(0); // process buffer immediately + } + } else if (state == State::rx) { + + int16_t v; + + //Get a value from audio_fifo and convert it to 0 - 255 to play it in the ADC + //If none value is available the DAC will play the last one that was read, that's + //why the rx_raw_audio_value variable is a global one. + if (audio_fifo.get(&v)) + rx_raw_audio_value = (uint8_t)((v + 32768) / 256); + + //Play + dacWrite(moduleConfig.audio.amp_pin ? moduleConfig.audio.amp_pin : AAMP, rx_raw_audio_value); + } +#endif +} + +int32_t AudioModule::runOnce() +{ +#if defined(ARCH_ESP32) && defined(USE_SX1280) + + if (moduleConfig.audio.codec2_enabled) { + + if (firstTime) { + + DEBUG_MSG("Initializing ADC on Channel %u\n", moduleConfig.audio.mic_chan ? moduleConfig.audio.mic_chan : AMIC); + + mic_chan = moduleConfig.audio.mic_chan ? (adc1_channel_t)(int)moduleConfig.audio.mic_chan : (adc1_channel_t)AMIC; + adc1_config_width(ADC_WIDTH_12Bit); + adc1_config_channel_atten(mic_chan, ADC_ATTEN_DB_6); + + // Start a timer at 8kHz to sample the ADC and play the audio on the DAC. + uint32_t cpufreq = getCpuFrequencyMhz(); + switch (cpufreq){ + case 160: + adcTimer = timerBegin(3, 1000, true); // 160 MHz / 1000 = 160KHz + break; + case 240: + adcTimer = timerBegin(3, 1500, true); // 240 MHz / 1500 = 160KHz + break; + case 320: + adcTimer = timerBegin(3, 2000, true); // 320 MHz / 2000 = 160KHz + break; + case 80: + default: + adcTimer = timerBegin(3, 500, true); // 80 MHz / 500 = 160KHz + break; + } + timerAttachInterrupt(adcTimer, &AudioModule::handleInterrupt, true); + timerAlarmWrite(adcTimer, 20, true); // Interrupts when counter == 20, 8.000 times a second + timerAlarmEnable(adcTimer); + + DEBUG_MSG("Initializing DAC on Pin %u\n", moduleConfig.audio.amp_pin ? moduleConfig.audio.amp_pin : AAMP); + DEBUG_MSG("Initializing PTT on Pin %u\n", moduleConfig.audio.ptt_pin ? moduleConfig.audio.ptt_pin : PTT_PIN); + + // Configure PTT input + pinMode(moduleConfig.audio.ptt_pin ? moduleConfig.audio.ptt_pin : PTT_PIN, INPUT_PULLUP); + + state = State::rx; + + DEBUG_MSG("Setting up codec2 in mode %u\n", moduleConfig.audio.bitrate ? moduleConfig.audio.bitrate : AUDIO_MODULE_MODE); + + codec2_state = codec2_create(moduleConfig.audio.bitrate ? moduleConfig.audio.bitrate : AUDIO_MODULE_MODE); + codec2_set_lpc_post_filter(codec2_state, 1, 0, 0.8, 0.2); + + firstTime = 0; + } else { + // Check if we have a PTT press + if (digitalRead(moduleConfig.audio.ptt_pin ? moduleConfig.audio.ptt_pin : PTT_PIN) == LOW) { + // PTT pressed, recording + state = State::tx; + } + if (state != State::standby) { + run_codec2(); + } + } + + return 100; + } else { + DEBUG_MSG("Audio Module Disabled\n"); + + return INT32_MAX; + } +#else + return INT32_MAX; +#endif +} + +MeshPacket *AudioModule::allocReply() +{ + + auto reply = allocDataPacket(); // Allocate a packet for sending + + return reply; +} + +void AudioModule::sendPayload(NodeNum dest, bool wantReplies) +{ + MeshPacket *p = allocReply(); + p->to = dest; + p->decoded.want_response = wantReplies; + + p->want_ack = AUDIO_MODULE_ACK; + + p->decoded.payload.size = ENCODE_FRAME_SIZE; + memcpy(p->decoded.payload.bytes, tx_encode_frame, p->decoded.payload.size); + + service.sendToMesh(p); +} + +ProcessMessage AudioModule::handleReceived(const MeshPacket &mp) +{ +#if defined(ARCH_ESP32) && defined(USE_SX1280) + + if (moduleConfig.audio.codec2_enabled) { + auto &p = mp.decoded; + if (getFrom(&mp) != nodeDB.getNodeNum()) { + if (p.payload.size == ENCODE_FRAME_SIZE) { + memcpy(rx_encode_frame, p.payload.bytes, p.payload.size); + state = State::rx; + audioModule->setIntervalFromNow(0); + run_codec2(); + } else { + DEBUG_MSG("Invalid payload size %u != %u\n", p.payload.size, ENCODE_FRAME_SIZE); + } + } + } + +#endif + + return ProcessMessage::CONTINUE; +} diff --git a/src/modules/esp32/AudioModule.h b/src/modules/esp32/AudioModule.h new file mode 100644 index 000000000..fcd5d169e --- /dev/null +++ b/src/modules/esp32/AudioModule.h @@ -0,0 +1,68 @@ +#pragma once + +#include "SinglePortModule.h" +#include "concurrency/OSThread.h" +#include "configuration.h" +#include "NodeDB.h" +#include +#include +#include +#if defined(ARCH_ESP32) && defined(USE_SX1280) +#include +#include +#include +#else +typedef int FastAudioFIFO; +#endif + +#define ADC_BUFFER_SIZE 320 // 40ms of voice in 8KHz sampling frequency +#define ENCODE_FRAME_SIZE 40 // 5 codec2 frames of 8 bytes each + +class AudioModule : public SinglePortModule, private concurrency::OSThread +{ + bool firstTime = 1; + hw_timer_t* adcTimer = NULL; + uint16_t adc_buffer[ADC_BUFFER_SIZE]; + int16_t speech[ADC_BUFFER_SIZE]; + int16_t output_buffer[ADC_BUFFER_SIZE]; + unsigned char rx_encode_frame[ENCODE_FRAME_SIZE]; + unsigned char tx_encode_frame[ENCODE_FRAME_SIZE]; + int tx_encode_frame_index = 0; + FastAudioFIFO audio_fifo; + uint16_t adc_buffer_index = 0; + adc1_channel_t mic_chan = (adc1_channel_t)0; + struct CODEC2* codec2_state; + + enum State + { + standby, rx, tx + }; + volatile State state = State::tx; + + public: + AudioModule(); + + /** + * Send our payload into the mesh + */ + void sendPayload(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false); + + protected: + virtual int32_t runOnce() override; + + static void handleInterrupt(); + + void onTimer(); + + void run_codec2(); + + virtual MeshPacket *allocReply() override; + + /** Called to handle a particular incoming message + * @return ProcessMessage::STOP if you've guaranteed you've handled this message and no other handlers should be considered for it + */ + virtual ProcessMessage handleReceived(const MeshPacket &mp) override; +}; + +extern AudioModule *audioModule; + diff --git a/variants/tlora_v2_1_18/platformio.ini b/variants/tlora_v2_1_18/platformio.ini index 2cb1c3d2f..4160be5de 100644 --- a/variants/tlora_v2_1_18/platformio.ini +++ b/variants/tlora_v2_1_18/platformio.ini @@ -3,5 +3,6 @@ extends = esp32_base board = ttgo-lora32-v21 lib_deps = ${esp32_base.lib_deps} + caveman99/ESP32 Codec2@^1.0.1 build_flags = ${esp32_base.build_flags} -D TLORA_V2_1_18 -I variants/tlora_v2_1_18 \ No newline at end of file From 20686cc66a5844c8d7a1a2ba86d4d7bc09e5c210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 3 Nov 2022 09:46:32 +0100 Subject: [PATCH 11/32] Show boot logo / OEM Logo longer - 5 seconds each now. --- src/graphics/Screen.cpp | 17 +++++---- src/mesh/generated/admin.pb.h | 7 ++-- src/mesh/generated/localonly.pb.h | 14 +++++--- src/mesh/generated/mesh.pb.h | 2 ++ src/mesh/generated/module_config.pb.c | 4 +++ src/mesh/generated/module_config.pb.h | 50 ++++++++++++++++++++++++++- src/mesh/generated/portnums.pb.h | 3 ++ 7 files changed, 83 insertions(+), 14 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 4ddbe10d4..d6e90c6f9 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -50,8 +50,6 @@ along with this program. If not, see . using namespace meshtastic; /** @todo remove */ -extern bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct); - namespace graphics { @@ -67,6 +65,8 @@ namespace graphics static FrameCallback normalFrames[MAX_NUM_NODES + NUM_EXTRA_FRAMES]; static uint32_t targetFramerate = IDLE_FRAMERATE; static char btPIN[16] = "888888"; + +uint32_t logo_timeout = 5000; // 4 seconds for EACH logo // This image definition is here instead of images.h because it's modified dynamically by the drawBattery function uint8_t imgBattery[16] = {0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xE7, 0x3C}; @@ -944,6 +944,9 @@ void Screen::setup() // Set the utf8 conversion function dispdev.setFontTableLookupFunction(customFontTableLookup); + if (strlen(oemStore.oem_text) > 0) + logo_timeout *= 2; + // Add frames. static FrameCallback bootFrames[] = {drawBootScreen}; static const int bootFrameCount = sizeof(bootFrames) / sizeof(bootFrames[0]); @@ -1012,26 +1015,28 @@ int32_t Screen::runOnce() return RUN_SAME; } - // Show boot screen for first 5 seconds, then switch to normal operation. + // Show boot screen for first logo_timeout seconds, then switch to normal operation. // serialSinceMsec adjusts for additional serial wait time during nRF52 bootup static bool showingBootScreen = true; - if (showingBootScreen && (millis() > (5000 + serialSinceMsec))) { + if (showingBootScreen && (millis() > (logo_timeout + serialSinceMsec))) { DEBUG_MSG("Done with boot screen...\n"); stopBootScreen(); showingBootScreen = false; } - // If we have an OEM Boot screen, toggle after 2,5 seconds + // If we have an OEM Boot screen, toggle after logo_timeout seconds if (strlen(oemStore.oem_text) > 0) { static bool showingOEMBootScreen = true; - if (showingOEMBootScreen && (millis() > (2500 + serialSinceMsec))) { + if (showingOEMBootScreen && (millis() > ((logo_timeout / 2) + serialSinceMsec))) { DEBUG_MSG("Switch to OEM screen...\n"); // Change frames. static FrameCallback bootOEMFrames[] = {drawOEMBootScreen}; static const int bootOEMFrameCount = sizeof(bootOEMFrames) / sizeof(bootOEMFrames[0]); ui.setFrames(bootOEMFrames, bootOEMFrameCount); ui.update(); +#ifndef USE_EINK ui.update(); +#endif showingOEMBootScreen = false; } } diff --git a/src/mesh/generated/admin.pb.h b/src/mesh/generated/admin.pb.h index 9b93bfd44..b5dc769ca 100644 --- a/src/mesh/generated/admin.pb.h +++ b/src/mesh/generated/admin.pb.h @@ -32,7 +32,8 @@ typedef enum _AdminMessage_ModuleConfigType { AdminMessage_ModuleConfigType_STOREFORWARD_CONFIG = 3, AdminMessage_ModuleConfigType_RANGETEST_CONFIG = 4, AdminMessage_ModuleConfigType_TELEMETRY_CONFIG = 5, - AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG = 6 + AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG = 6, + AdminMessage_ModuleConfigType_AUDIO_CONFIG = 7 } AdminMessage_ModuleConfigType; /* Struct definitions */ @@ -116,8 +117,8 @@ typedef struct _AdminMessage { #define _AdminMessage_ConfigType_ARRAYSIZE ((AdminMessage_ConfigType)(AdminMessage_ConfigType_BLUETOOTH_CONFIG+1)) #define _AdminMessage_ModuleConfigType_MIN AdminMessage_ModuleConfigType_MQTT_CONFIG -#define _AdminMessage_ModuleConfigType_MAX AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG -#define _AdminMessage_ModuleConfigType_ARRAYSIZE ((AdminMessage_ModuleConfigType)(AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG+1)) +#define _AdminMessage_ModuleConfigType_MAX AdminMessage_ModuleConfigType_AUDIO_CONFIG +#define _AdminMessage_ModuleConfigType_ARRAYSIZE ((AdminMessage_ModuleConfigType)(AdminMessage_ModuleConfigType_AUDIO_CONFIG+1)) #ifdef __cplusplus diff --git a/src/mesh/generated/localonly.pb.h b/src/mesh/generated/localonly.pb.h index b691ee408..76e713c1d 100644 --- a/src/mesh/generated/localonly.pb.h +++ b/src/mesh/generated/localonly.pb.h @@ -66,6 +66,9 @@ typedef struct _LocalModuleConfig { incompatible changes This integer is set at build time and is private to NodeDB.cpp in the device code. */ uint32_t version; + /* The part of the config that is specific to the Audio module */ + bool has_audio; + ModuleConfig_AudioConfig audio; } LocalModuleConfig; @@ -75,9 +78,9 @@ extern "C" { /* Initializer values for message structs */ #define LocalConfig_init_default {false, Config_DeviceConfig_init_default, false, Config_PositionConfig_init_default, false, Config_PowerConfig_init_default, false, Config_NetworkConfig_init_default, false, Config_DisplayConfig_init_default, false, Config_LoRaConfig_init_default, false, Config_BluetoothConfig_init_default, 0} -#define LocalModuleConfig_init_default {false, ModuleConfig_MQTTConfig_init_default, false, ModuleConfig_SerialConfig_init_default, false, ModuleConfig_ExternalNotificationConfig_init_default, false, ModuleConfig_StoreForwardConfig_init_default, false, ModuleConfig_RangeTestConfig_init_default, false, ModuleConfig_TelemetryConfig_init_default, false, ModuleConfig_CannedMessageConfig_init_default, 0} +#define LocalModuleConfig_init_default {false, ModuleConfig_MQTTConfig_init_default, false, ModuleConfig_SerialConfig_init_default, false, ModuleConfig_ExternalNotificationConfig_init_default, false, ModuleConfig_StoreForwardConfig_init_default, false, ModuleConfig_RangeTestConfig_init_default, false, ModuleConfig_TelemetryConfig_init_default, false, ModuleConfig_CannedMessageConfig_init_default, 0, false, ModuleConfig_AudioConfig_init_default} #define LocalConfig_init_zero {false, Config_DeviceConfig_init_zero, false, Config_PositionConfig_init_zero, false, Config_PowerConfig_init_zero, false, Config_NetworkConfig_init_zero, false, Config_DisplayConfig_init_zero, false, Config_LoRaConfig_init_zero, false, Config_BluetoothConfig_init_zero, 0} -#define LocalModuleConfig_init_zero {false, ModuleConfig_MQTTConfig_init_zero, false, ModuleConfig_SerialConfig_init_zero, false, ModuleConfig_ExternalNotificationConfig_init_zero, false, ModuleConfig_StoreForwardConfig_init_zero, false, ModuleConfig_RangeTestConfig_init_zero, false, ModuleConfig_TelemetryConfig_init_zero, false, ModuleConfig_CannedMessageConfig_init_zero, 0} +#define LocalModuleConfig_init_zero {false, ModuleConfig_MQTTConfig_init_zero, false, ModuleConfig_SerialConfig_init_zero, false, ModuleConfig_ExternalNotificationConfig_init_zero, false, ModuleConfig_StoreForwardConfig_init_zero, false, ModuleConfig_RangeTestConfig_init_zero, false, ModuleConfig_TelemetryConfig_init_zero, false, ModuleConfig_CannedMessageConfig_init_zero, 0, false, ModuleConfig_AudioConfig_init_zero} /* Field tags (for use in manual encoding/decoding) */ #define LocalConfig_device_tag 1 @@ -96,6 +99,7 @@ extern "C" { #define LocalModuleConfig_telemetry_tag 6 #define LocalModuleConfig_canned_message_tag 7 #define LocalModuleConfig_version_tag 8 +#define LocalModuleConfig_audio_tag 9 /* Struct field encoding specification for nanopb */ #define LocalConfig_FIELDLIST(X, a) \ @@ -125,7 +129,8 @@ X(a, STATIC, OPTIONAL, MESSAGE, store_forward, 4) \ X(a, STATIC, OPTIONAL, MESSAGE, range_test, 5) \ X(a, STATIC, OPTIONAL, MESSAGE, telemetry, 6) \ X(a, STATIC, OPTIONAL, MESSAGE, canned_message, 7) \ -X(a, STATIC, SINGULAR, UINT32, version, 8) +X(a, STATIC, SINGULAR, UINT32, version, 8) \ +X(a, STATIC, OPTIONAL, MESSAGE, audio, 9) #define LocalModuleConfig_CALLBACK NULL #define LocalModuleConfig_DEFAULT NULL #define LocalModuleConfig_mqtt_MSGTYPE ModuleConfig_MQTTConfig @@ -135,6 +140,7 @@ X(a, STATIC, SINGULAR, UINT32, version, 8) #define LocalModuleConfig_range_test_MSGTYPE ModuleConfig_RangeTestConfig #define LocalModuleConfig_telemetry_MSGTYPE ModuleConfig_TelemetryConfig #define LocalModuleConfig_canned_message_MSGTYPE ModuleConfig_CannedMessageConfig +#define LocalModuleConfig_audio_MSGTYPE ModuleConfig_AudioConfig extern const pb_msgdesc_t LocalConfig_msg; extern const pb_msgdesc_t LocalModuleConfig_msg; @@ -145,7 +151,7 @@ extern const pb_msgdesc_t LocalModuleConfig_msg; /* Maximum encoded size of messages (where known) */ #define LocalConfig_size 359 -#define LocalModuleConfig_size 270 +#define LocalModuleConfig_size 294 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index 3f2a8839c..812099166 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -52,6 +52,8 @@ typedef enum _HardwareModel { HardwareModel_RAK11200 = 13, /* B&Q Consulting Nano Edition G1: https://uniteng.com/wiki/doku.php?id=meshtastic:nano */ HardwareModel_NANO_G1 = 14, + /* TODO: REPLACE */ + HardwareModel_TLORA_V2_1_1P8 = 15, /* B&Q Consulting Station Edition G1: https://uniteng.com/wiki/doku.php?id=meshtastic:station */ HardwareModel_STATION_G1 = 25, /* Less common/prototype boards listed here (needs one more byte over the air) */ diff --git a/src/mesh/generated/module_config.pb.c b/src/mesh/generated/module_config.pb.c index a3e4ddfbe..381ce6351 100644 --- a/src/mesh/generated/module_config.pb.c +++ b/src/mesh/generated/module_config.pb.c @@ -12,6 +12,9 @@ PB_BIND(ModuleConfig, ModuleConfig, AUTO) PB_BIND(ModuleConfig_MQTTConfig, ModuleConfig_MQTTConfig, AUTO) +PB_BIND(ModuleConfig_AudioConfig, ModuleConfig_AudioConfig, AUTO) + + PB_BIND(ModuleConfig_SerialConfig, ModuleConfig_SerialConfig, AUTO) @@ -34,3 +37,4 @@ PB_BIND(ModuleConfig_CannedMessageConfig, ModuleConfig_CannedMessageConfig, AUTO + diff --git a/src/mesh/generated/module_config.pb.h b/src/mesh/generated/module_config.pb.h index b0f14eea2..af4d4dce9 100644 --- a/src/mesh/generated/module_config.pb.h +++ b/src/mesh/generated/module_config.pb.h @@ -10,6 +10,18 @@ #endif /* Enum definitions */ +typedef enum _ModuleConfig_AudioConfig_Audio_Baud { + ModuleConfig_AudioConfig_Audio_Baud_CODEC2_DEFAULT = 0, + ModuleConfig_AudioConfig_Audio_Baud_CODEC2_3200 = 1, + ModuleConfig_AudioConfig_Audio_Baud_CODEC2_2400 = 2, + ModuleConfig_AudioConfig_Audio_Baud_CODEC2_1600 = 3, + ModuleConfig_AudioConfig_Audio_Baud_CODEC2_1400 = 4, + ModuleConfig_AudioConfig_Audio_Baud_CODEC2_1300 = 5, + ModuleConfig_AudioConfig_Audio_Baud_CODEC2_1200 = 6, + ModuleConfig_AudioConfig_Audio_Baud_CODEC2_700 = 7, + ModuleConfig_AudioConfig_Audio_Baud_CODEC2_700B = 8 +} ModuleConfig_AudioConfig_Audio_Baud; + typedef enum _ModuleConfig_SerialConfig_Serial_Baud { ModuleConfig_SerialConfig_Serial_Baud_BAUD_DEFAULT = 0, ModuleConfig_SerialConfig_Serial_Baud_BAUD_110 = 1, @@ -49,6 +61,14 @@ typedef enum _ModuleConfig_CannedMessageConfig_InputEventChar { } ModuleConfig_CannedMessageConfig_InputEventChar; /* Struct definitions */ +typedef struct _ModuleConfig_AudioConfig { + bool codec2_enabled; + uint32_t mic_chan; + uint32_t amp_pin; + uint32_t ptt_pin; + ModuleConfig_AudioConfig_Audio_Baud bitrate; +} ModuleConfig_AudioConfig; + typedef struct _ModuleConfig_CannedMessageConfig { bool rotary1_enabled; uint32_t inputbroker_pin_a; @@ -131,11 +151,17 @@ typedef struct _ModuleConfig { ModuleConfig_TelemetryConfig telemetry; /* TODO: REPLACE */ ModuleConfig_CannedMessageConfig canned_message; + /* TODO: REPLACE */ + ModuleConfig_AudioConfig audio; } payload_variant; } ModuleConfig; /* Helper constants for enums */ +#define _ModuleConfig_AudioConfig_Audio_Baud_MIN ModuleConfig_AudioConfig_Audio_Baud_CODEC2_DEFAULT +#define _ModuleConfig_AudioConfig_Audio_Baud_MAX ModuleConfig_AudioConfig_Audio_Baud_CODEC2_700B +#define _ModuleConfig_AudioConfig_Audio_Baud_ARRAYSIZE ((ModuleConfig_AudioConfig_Audio_Baud)(ModuleConfig_AudioConfig_Audio_Baud_CODEC2_700B+1)) + #define _ModuleConfig_SerialConfig_Serial_Baud_MIN ModuleConfig_SerialConfig_Serial_Baud_BAUD_DEFAULT #define _ModuleConfig_SerialConfig_Serial_Baud_MAX ModuleConfig_SerialConfig_Serial_Baud_BAUD_921600 #define _ModuleConfig_SerialConfig_Serial_Baud_ARRAYSIZE ((ModuleConfig_SerialConfig_Serial_Baud)(ModuleConfig_SerialConfig_Serial_Baud_BAUD_921600+1)) @@ -156,6 +182,7 @@ extern "C" { /* Initializer values for message structs */ #define ModuleConfig_init_default {0, {ModuleConfig_MQTTConfig_init_default}} #define ModuleConfig_MQTTConfig_init_default {0, "", "", "", 0, 0} +#define ModuleConfig_AudioConfig_init_default {0, 0, 0, 0, _ModuleConfig_AudioConfig_Audio_Baud_MIN} #define ModuleConfig_SerialConfig_init_default {0, 0, 0, 0, _ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _ModuleConfig_SerialConfig_Serial_Mode_MIN} #define ModuleConfig_ExternalNotificationConfig_init_default {0, 0, 0, 0, 0, 0} #define ModuleConfig_StoreForwardConfig_init_default {0, 0, 0, 0, 0} @@ -164,6 +191,7 @@ extern "C" { #define ModuleConfig_CannedMessageConfig_init_default {0, 0, 0, 0, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, 0, 0, "", 0} #define ModuleConfig_init_zero {0, {ModuleConfig_MQTTConfig_init_zero}} #define ModuleConfig_MQTTConfig_init_zero {0, "", "", "", 0, 0} +#define ModuleConfig_AudioConfig_init_zero {0, 0, 0, 0, _ModuleConfig_AudioConfig_Audio_Baud_MIN} #define ModuleConfig_SerialConfig_init_zero {0, 0, 0, 0, _ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _ModuleConfig_SerialConfig_Serial_Mode_MIN} #define ModuleConfig_ExternalNotificationConfig_init_zero {0, 0, 0, 0, 0, 0} #define ModuleConfig_StoreForwardConfig_init_zero {0, 0, 0, 0, 0} @@ -172,6 +200,11 @@ extern "C" { #define ModuleConfig_CannedMessageConfig_init_zero {0, 0, 0, 0, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, 0, 0, "", 0} /* Field tags (for use in manual encoding/decoding) */ +#define ModuleConfig_AudioConfig_codec2_enabled_tag 1 +#define ModuleConfig_AudioConfig_mic_chan_tag 2 +#define ModuleConfig_AudioConfig_amp_pin_tag 3 +#define ModuleConfig_AudioConfig_ptt_pin_tag 4 +#define ModuleConfig_AudioConfig_bitrate_tag 5 #define ModuleConfig_CannedMessageConfig_rotary1_enabled_tag 1 #define ModuleConfig_CannedMessageConfig_inputbroker_pin_a_tag 2 #define ModuleConfig_CannedMessageConfig_inputbroker_pin_b_tag 3 @@ -222,6 +255,7 @@ extern "C" { #define ModuleConfig_range_test_tag 5 #define ModuleConfig_telemetry_tag 6 #define ModuleConfig_canned_message_tag 7 +#define ModuleConfig_audio_tag 8 /* Struct field encoding specification for nanopb */ #define ModuleConfig_FIELDLIST(X, a) \ @@ -231,7 +265,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,external_notification,payloa X(a, STATIC, ONEOF, MESSAGE, (payload_variant,store_forward,payload_variant.store_forward), 4) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,range_test,payload_variant.range_test), 5) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,telemetry,payload_variant.telemetry), 6) \ -X(a, STATIC, ONEOF, MESSAGE, (payload_variant,canned_message,payload_variant.canned_message), 7) +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,canned_message,payload_variant.canned_message), 7) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,audio,payload_variant.audio), 8) #define ModuleConfig_CALLBACK NULL #define ModuleConfig_DEFAULT NULL #define ModuleConfig_payload_variant_mqtt_MSGTYPE ModuleConfig_MQTTConfig @@ -241,6 +276,7 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,canned_message,payload_varia #define ModuleConfig_payload_variant_range_test_MSGTYPE ModuleConfig_RangeTestConfig #define ModuleConfig_payload_variant_telemetry_MSGTYPE ModuleConfig_TelemetryConfig #define ModuleConfig_payload_variant_canned_message_MSGTYPE ModuleConfig_CannedMessageConfig +#define ModuleConfig_payload_variant_audio_MSGTYPE ModuleConfig_AudioConfig #define ModuleConfig_MQTTConfig_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, BOOL, enabled, 1) \ @@ -252,6 +288,15 @@ X(a, STATIC, SINGULAR, BOOL, json_enabled, 6) #define ModuleConfig_MQTTConfig_CALLBACK NULL #define ModuleConfig_MQTTConfig_DEFAULT NULL +#define ModuleConfig_AudioConfig_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, BOOL, codec2_enabled, 1) \ +X(a, STATIC, SINGULAR, UINT32, mic_chan, 2) \ +X(a, STATIC, SINGULAR, UINT32, amp_pin, 3) \ +X(a, STATIC, SINGULAR, UINT32, ptt_pin, 4) \ +X(a, STATIC, SINGULAR, UENUM, bitrate, 5) +#define ModuleConfig_AudioConfig_CALLBACK NULL +#define ModuleConfig_AudioConfig_DEFAULT NULL + #define ModuleConfig_SerialConfig_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, BOOL, enabled, 1) \ X(a, STATIC, SINGULAR, BOOL, echo, 2) \ @@ -315,6 +360,7 @@ X(a, STATIC, SINGULAR, BOOL, send_bell, 11) extern const pb_msgdesc_t ModuleConfig_msg; extern const pb_msgdesc_t ModuleConfig_MQTTConfig_msg; +extern const pb_msgdesc_t ModuleConfig_AudioConfig_msg; extern const pb_msgdesc_t ModuleConfig_SerialConfig_msg; extern const pb_msgdesc_t ModuleConfig_ExternalNotificationConfig_msg; extern const pb_msgdesc_t ModuleConfig_StoreForwardConfig_msg; @@ -325,6 +371,7 @@ extern const pb_msgdesc_t ModuleConfig_CannedMessageConfig_msg; /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ #define ModuleConfig_fields &ModuleConfig_msg #define ModuleConfig_MQTTConfig_fields &ModuleConfig_MQTTConfig_msg +#define ModuleConfig_AudioConfig_fields &ModuleConfig_AudioConfig_msg #define ModuleConfig_SerialConfig_fields &ModuleConfig_SerialConfig_msg #define ModuleConfig_ExternalNotificationConfig_fields &ModuleConfig_ExternalNotificationConfig_msg #define ModuleConfig_StoreForwardConfig_fields &ModuleConfig_StoreForwardConfig_msg @@ -333,6 +380,7 @@ extern const pb_msgdesc_t ModuleConfig_CannedMessageConfig_msg; #define ModuleConfig_CannedMessageConfig_fields &ModuleConfig_CannedMessageConfig_msg /* Maximum encoded size of messages (where known) */ +#define ModuleConfig_AudioConfig_size 22 #define ModuleConfig_CannedMessageConfig_size 49 #define ModuleConfig_ExternalNotificationConfig_size 20 #define ModuleConfig_MQTTConfig_size 105 diff --git a/src/mesh/generated/portnums.pb.h b/src/mesh/generated/portnums.pb.h index d272fe2b9..ec7b7eaec 100644 --- a/src/mesh/generated/portnums.pb.h +++ b/src/mesh/generated/portnums.pb.h @@ -51,6 +51,9 @@ typedef enum _PortNum { /* Waypoint payloads. Payload is a [Waypoint](/docs/developers/protobufs/api#waypoint) message */ PortNum_WAYPOINT_APP = 8, + /* Audio Payloads. + Encapsulated codec2 packets. On 2.4 GHZ Bandwidths only for now */ + PortNum_AUDIO_APP = 9, /* Provides a 'ping' service that replies to any packet it receives. Also serves as a small example module. */ PortNum_REPLY_APP = 32, From 09cdc20440fab47b38a8d7960c803f7b187411eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 4 Nov 2022 19:56:44 +0100 Subject: [PATCH 12/32] manual merge of changes from Master --- src/main.cpp | 6 +- src/mesh/FloodingRouter.cpp | 4 +- src/modules/ExternalNotificationModule.cpp | 8 +- variants/feather_diy/platformio.ini | 2 +- variants/feather_diy/variant.cpp | 24 +++++ variants/feather_diy/variant.h | 106 +++++++++++++++++++-- 6 files changed, 133 insertions(+), 17 deletions(-) create mode 100644 variants/feather_diy/variant.cpp diff --git a/src/main.cpp b/src/main.cpp index 8836b6460..e0f0783d3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -37,7 +37,7 @@ #include "nimble/NimbleBluetooth.h" #endif -#if HAS_WIFI || defined(ARCH_PORTDUINO) +#if HAS_WIFI #include "mesh/wifi/WiFiServerAPI.h" #include "mqtt/MQTT.h" #endif @@ -293,6 +293,10 @@ void setup() * Boards with an PMU need to be powered on to correctly scan to the device address, such as t-beam-s3-core */ scanI2Cdevice(); + + // fixed screen override? + if (config.display.oled != Config_DisplayConfig_OledType_OLED_AUTO) + screen_model = config.display.oled; // Init our SPI controller (must be before screen and lora) initSPI(); diff --git a/src/mesh/FloodingRouter.cpp b/src/mesh/FloodingRouter.cpp index b6519abdb..818bacf45 100644 --- a/src/mesh/FloodingRouter.cpp +++ b/src/mesh/FloodingRouter.cpp @@ -29,8 +29,8 @@ bool FloodingRouter::shouldFilterReceived(MeshPacket *p) void FloodingRouter::sniffReceived(const MeshPacket *p, const Routing *c) { - PacketId ackId = ((c && c->error_reason == Routing_Error_NONE) || !c) ? p->decoded.request_id : 0; - if (ackId && p->to != getNodeNum()) { + bool isAck = ((c && c->error_reason == Routing_Error_NONE)); // consider only ROUTING_APP message without error as ACK + if (isAck && p->to != getNodeNum()) { // do not flood direct message that is ACKed DEBUG_MSG("Receiving an ACK not for me, but don't need to rebroadcast this direct message anymore.\n"); Router::cancelSending(p->to, p->decoded.request_id); // cancel rebroadcast for this DM diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 366ec6849..e5d371c1b 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -116,9 +116,6 @@ ExternalNotificationModule::ExternalNotificationModule() : SinglePortModule("ExternalNotificationModule", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread( "ExternalNotificationModule") { - // restrict to the admin channel for rx - boundChannel = Channels::gpioChannel; - /* Uncomment the preferences below if you want to use the module without having to configure it from the PythonAPI or WebUI. @@ -131,6 +128,11 @@ ExternalNotificationModule::ExternalNotificationModule() // moduleConfig.external_notification.alert_bell = 1; // moduleConfig.external_notification.output_ms = 1000; // moduleConfig.external_notification.output = 13; + + if (moduleConfig.external_notification.alert_message) { + // restrict to the gpio channel for rx + boundChannel = Channels::gpioChannel; + } if (moduleConfig.external_notification.enabled) { diff --git a/variants/feather_diy/platformio.ini b/variants/feather_diy/platformio.ini index 446011cb9..84c582ab0 100644 --- a/variants/feather_diy/platformio.ini +++ b/variants/feather_diy/platformio.ini @@ -2,7 +2,7 @@ [env:feather_diy] extends = nrf52840_base board = adafruit_feather_nrf52840 -build_flags = ${nrf52840_base.build_flags} -Ivariants/feather_diy -D feather_diy +build_flags = ${nrf52840_base.build_flags} -Ivariants/feather_diy -Dfeather_diy build_src_filter = ${nrf52_base.build_src_filter} +<../variants/feather_diy> lib_deps = ${nrf52840_base.lib_deps} diff --git a/variants/feather_diy/variant.cpp b/variants/feather_diy/variant.cpp new file mode 100644 index 000000000..7311c9019 --- /dev/null +++ b/variants/feather_diy/variant.cpp @@ -0,0 +1,24 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "nrf.h" +#include "wiring_constants.h" +#include "wiring_digital.h" diff --git a/variants/feather_diy/variant.h b/variants/feather_diy/variant.h index 8327e6050..92128add2 100644 --- a/variants/feather_diy/variant.h +++ b/variants/feather_diy/variant.h @@ -1,19 +1,95 @@ -// For OLED LCD -#define I2C_SDA 22 -#define I2C_SCL 23 +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) -#define BUTTON_PIN 7 + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_FEATHER_DIY_ +#define _VARIANT_FEATHER_DIY_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (48) +#define NUM_DIGITAL_PINS (48) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (0 + 12) //P0.12 22 +#define PIN_WIRE_SCL (0 + 11) //P0.12 23 + +#define PIN_LED1 (32 + 15) //P1.15 3 +#define PIN_LED2 (32 + 10) //P1.10 4 + +#define LED_BUILTIN PIN_LED1 + +#define LED_GREEN PIN_LED2 // Actually red +#define LED_BLUE PIN_LED1 + +#define LED_STATE_ON 1 // State when LED is litted + +#define BUTTON_PIN (32 + 2) //P1.02 7 + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (0 + 24) //P0.24 1 +#define PIN_SERIAL1_TX (0 + 25) //P0.25 0 + +#define PIN_SERIAL2_RX (-1) +#define PIN_SERIAL2_TX (-1) + +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (0 + 15) //P0.15 24 +#define PIN_SPI_MOSI (0 + 13) //P0.13 25 +#define PIN_SPI_SCK (0 + 14) //P0.14 26 + +#define SS 2 #define LORA_DIO0 -1 // a No connect on the SX1262/SX1268 module -#define LORA_RESET 13 // RST for SX1276, and for SX1262/SX1268 -#define LORA_DIO1 11 // IRQ for SX1262/SX1268 -#define LORA_DIO2 12 // BUSY for SX1262/SX1268 +#define LORA_RESET (32 + 9) //P1.09 13 // RST for SX1276, and for SX1262/SX1268 +#define LORA_DIO1 (0 + 6) //P0.06 11 // IRQ for SX1262/SX1268 +#define LORA_DIO2 (0 + 8) //P0.08 12 // BUSY for SX1262/SX1268 #define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262/SX1268, if DIO3 is high the TXCO is enabled #define RF95_SCK SCK #define RF95_MISO MI #define RF95_MOSI MO -#define RF95_NSS D2 +#define RF95_NSS SS + +// enables 3.3V periphery like GPS or IO Module +#define PIN_3V3_EN (-1) + +#undef USE_EINK // supported modules list #define USE_SX1262 @@ -23,11 +99,21 @@ #define SX126X_DIO1 LORA_DIO1 #define SX126X_BUSY LORA_DIO2 #define SX126X_RESET LORA_RESET -#define SX126X_RXEN 10 -#define SX126X_TXEN 9 +#define SX126X_RXEN (0 + 27) //P0.27 10 +#define SX126X_TXEN (0 + 26) //P0.26 9 #ifdef EBYTE_E22 // Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch // (which is the default for the sx1262interface code) #define SX126X_E22 #endif + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif From 8874a6e4883525ee3b81d75ab611a5d28660ff94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 5 Nov 2022 14:18:57 +0100 Subject: [PATCH 13/32] update protos --- protobufs | 2 +- src/mesh/generated/config.pb.c | 1 + src/mesh/generated/config.pb.h | 21 +++++++++++++++++---- src/mesh/generated/localonly.pb.h | 2 +- src/mesh/generated/mesh.pb.h | 4 ++-- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/protobufs b/protobufs index fa47c6455..7e102f0f3 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit fa47c64558473c806ca6535d407df7409acbc283 +Subproject commit 7e102f0f3c4d6a41e9ee42e4771ca3c35c517d56 diff --git a/src/mesh/generated/config.pb.c b/src/mesh/generated/config.pb.c index c5bc69552..2b75b7558 100644 --- a/src/mesh/generated/config.pb.c +++ b/src/mesh/generated/config.pb.c @@ -43,3 +43,4 @@ PB_BIND(Config_BluetoothConfig, Config_BluetoothConfig, AUTO) + diff --git a/src/mesh/generated/config.pb.h b/src/mesh/generated/config.pb.h index 6a8e56ad0..263b1e916 100644 --- a/src/mesh/generated/config.pb.h +++ b/src/mesh/generated/config.pb.h @@ -56,6 +56,12 @@ typedef enum _Config_DisplayConfig_DisplayUnits { Config_DisplayConfig_DisplayUnits_IMPERIAL = 1 } Config_DisplayConfig_DisplayUnits; +typedef enum _Config_DisplayConfig_OledType { + Config_DisplayConfig_OledType_OLED_AUTO = 0, + Config_DisplayConfig_OledType_OLED_SSD1306 = 1, + Config_DisplayConfig_OledType_OLED_SH1106 = 2 +} Config_DisplayConfig_OledType; + typedef enum _Config_LoRaConfig_RegionCode { Config_LoRaConfig_RegionCode_UNSET = 0, Config_LoRaConfig_RegionCode_US = 1, @@ -109,6 +115,7 @@ typedef struct _Config_DisplayConfig { bool compass_north_top; bool flip_screen; Config_DisplayConfig_DisplayUnits units; + Config_DisplayConfig_OledType oled; } Config_DisplayConfig; typedef struct _Config_LoRaConfig { @@ -205,6 +212,10 @@ typedef struct _Config { #define _Config_DisplayConfig_DisplayUnits_MAX Config_DisplayConfig_DisplayUnits_IMPERIAL #define _Config_DisplayConfig_DisplayUnits_ARRAYSIZE ((Config_DisplayConfig_DisplayUnits)(Config_DisplayConfig_DisplayUnits_IMPERIAL+1)) +#define _Config_DisplayConfig_OledType_MIN Config_DisplayConfig_OledType_OLED_AUTO +#define _Config_DisplayConfig_OledType_MAX Config_DisplayConfig_OledType_OLED_SH1106 +#define _Config_DisplayConfig_OledType_ARRAYSIZE ((Config_DisplayConfig_OledType)(Config_DisplayConfig_OledType_OLED_SH1106+1)) + #define _Config_LoRaConfig_RegionCode_MIN Config_LoRaConfig_RegionCode_UNSET #define _Config_LoRaConfig_RegionCode_MAX Config_LoRaConfig_RegionCode_LORA_24 #define _Config_LoRaConfig_RegionCode_ARRAYSIZE ((Config_LoRaConfig_RegionCode)(Config_LoRaConfig_RegionCode_LORA_24+1)) @@ -229,7 +240,7 @@ extern "C" { #define Config_PowerConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0} #define Config_NetworkConfig_init_default {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_default} #define Config_NetworkConfig_IpV4Config_init_default {0, 0, 0, 0} -#define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN} +#define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN} #define Config_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}} #define Config_BluetoothConfig_init_default {0, _Config_BluetoothConfig_PairingMode_MIN, 0} #define Config_init_zero {0, {Config_DeviceConfig_init_zero}} @@ -238,7 +249,7 @@ extern "C" { #define Config_PowerConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0} #define Config_NetworkConfig_init_zero {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_zero} #define Config_NetworkConfig_IpV4Config_init_zero {0, 0, 0, 0} -#define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN} +#define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN} #define Config_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}} #define Config_BluetoothConfig_init_zero {0, _Config_BluetoothConfig_PairingMode_MIN, 0} @@ -255,6 +266,7 @@ extern "C" { #define Config_DisplayConfig_compass_north_top_tag 4 #define Config_DisplayConfig_flip_screen_tag 5 #define Config_DisplayConfig_units_tag 6 +#define Config_DisplayConfig_oled_tag 7 #define Config_LoRaConfig_use_preset_tag 1 #define Config_LoRaConfig_modem_preset_tag 2 #define Config_LoRaConfig_bandwidth_tag 3 @@ -376,7 +388,8 @@ X(a, STATIC, SINGULAR, UENUM, gps_format, 2) \ X(a, STATIC, SINGULAR, UINT32, auto_screen_carousel_secs, 3) \ X(a, STATIC, SINGULAR, BOOL, compass_north_top, 4) \ X(a, STATIC, SINGULAR, BOOL, flip_screen, 5) \ -X(a, STATIC, SINGULAR, UENUM, units, 6) +X(a, STATIC, SINGULAR, UENUM, units, 6) \ +X(a, STATIC, SINGULAR, UENUM, oled, 7) #define Config_DisplayConfig_CALLBACK NULL #define Config_DisplayConfig_DEFAULT NULL @@ -427,7 +440,7 @@ extern const pb_msgdesc_t Config_BluetoothConfig_msg; /* Maximum encoded size of messages (where known) */ #define Config_BluetoothConfig_size 10 #define Config_DeviceConfig_size 6 -#define Config_DisplayConfig_size 20 +#define Config_DisplayConfig_size 22 #define Config_LoRaConfig_size 68 #define Config_NetworkConfig_IpV4Config_size 20 #define Config_NetworkConfig_size 161 diff --git a/src/mesh/generated/localonly.pb.h b/src/mesh/generated/localonly.pb.h index 76e713c1d..783c523c7 100644 --- a/src/mesh/generated/localonly.pb.h +++ b/src/mesh/generated/localonly.pb.h @@ -150,7 +150,7 @@ extern const pb_msgdesc_t LocalModuleConfig_msg; #define LocalModuleConfig_fields &LocalModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define LocalConfig_size 359 +#define LocalConfig_size 361 #define LocalModuleConfig_size 294 #ifdef __cplusplus diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index 812099166..c1c2bdd7b 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -501,7 +501,7 @@ typedef PB_BYTES_ARRAY_T(256) MeshPacket_encrypted_t; typedef struct _MeshPacket { /* The sending node number. Note: Our crypto implementation uses this field as well. - See [crypto](/docs/developers/firmware/encryption) for details. + See [crypto](/docs/about/overview/encryption) for details. FIXME - really should be fixed32 instead, this encoding only hurts the ble link though. */ uint32_t from; /* The (immediatSee Priority description for more details.y should be fixed32 instead, this encoding only @@ -529,7 +529,7 @@ typedef struct _MeshPacket { needs to be unique for a few minutes (long enough to last for the length of any ACK or the completion of a mesh broadcast flood). Note: Our crypto implementation uses this id as well. - See [crypto](/docs/developers/firmware/encryption) for details. + See [crypto](/docs/about/overview/encryption) for details. FIXME - really should be fixed32 instead, this encoding only hurts the ble link though. */ uint32_t id; From 1716c4d6f99b85ae7457fafd27ea77033cf92e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 5 Nov 2022 15:02:06 +0100 Subject: [PATCH 14/32] Allow static IP for WLAN and portentially fix reconnect issues --- protobufs | 2 +- src/mesh/generated/config.pb.h | 21 +++++++-------------- src/mesh/generated/localonly.pb.h | 2 +- src/mesh/http/WiFiAPClient.cpp | 9 ++++++--- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/protobufs b/protobufs index 7e102f0f3..2954e5b02 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 7e102f0f3c4d6a41e9ee42e4771ca3c35c517d56 +Subproject commit 2954e5b0228c85902c841bfb0f18add43980a2e2 diff --git a/src/mesh/generated/config.pb.h b/src/mesh/generated/config.pb.h index 263b1e916..a9005ddcd 100644 --- a/src/mesh/generated/config.pb.h +++ b/src/mesh/generated/config.pb.h @@ -31,12 +31,6 @@ typedef enum _Config_PositionConfig_PositionFlags { Config_PositionConfig_PositionFlags_SPEED = 512 } Config_PositionConfig_PositionFlags; -typedef enum _Config_NetworkConfig_WiFiMode { - Config_NetworkConfig_WiFiMode_CLIENT = 0, - Config_NetworkConfig_WiFiMode_ACCESS_POINT = 1, - Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN = 2 -} Config_NetworkConfig_WiFiMode; - typedef enum _Config_NetworkConfig_EthMode { Config_NetworkConfig_EthMode_DHCP = 0, Config_NetworkConfig_EthMode_STATIC = 1 @@ -164,6 +158,7 @@ typedef struct _Config_PowerConfig { typedef struct _Config_NetworkConfig { bool wifi_enabled; + Config_NetworkConfig_EthMode wifi_mode; char wifi_ssid[33]; char wifi_psk[64]; char ntp_server[33]; @@ -196,10 +191,6 @@ typedef struct _Config { #define _Config_PositionConfig_PositionFlags_MAX Config_PositionConfig_PositionFlags_SPEED #define _Config_PositionConfig_PositionFlags_ARRAYSIZE ((Config_PositionConfig_PositionFlags)(Config_PositionConfig_PositionFlags_SPEED+1)) -#define _Config_NetworkConfig_WiFiMode_MIN Config_NetworkConfig_WiFiMode_CLIENT -#define _Config_NetworkConfig_WiFiMode_MAX Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN -#define _Config_NetworkConfig_WiFiMode_ARRAYSIZE ((Config_NetworkConfig_WiFiMode)(Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN+1)) - #define _Config_NetworkConfig_EthMode_MIN Config_NetworkConfig_EthMode_DHCP #define _Config_NetworkConfig_EthMode_MAX Config_NetworkConfig_EthMode_STATIC #define _Config_NetworkConfig_EthMode_ARRAYSIZE ((Config_NetworkConfig_EthMode)(Config_NetworkConfig_EthMode_STATIC+1)) @@ -238,7 +229,7 @@ extern "C" { #define Config_DeviceConfig_init_default {_Config_DeviceConfig_Role_MIN, 0, 0} #define Config_PositionConfig_init_default {0, 0, 0, 0, 0, 0, 0} #define Config_PowerConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0} -#define Config_NetworkConfig_init_default {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_default} +#define Config_NetworkConfig_init_default {0, _Config_NetworkConfig_EthMode_MIN, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_default} #define Config_NetworkConfig_IpV4Config_init_default {0, 0, 0, 0} #define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN} #define Config_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}} @@ -247,7 +238,7 @@ extern "C" { #define Config_DeviceConfig_init_zero {_Config_DeviceConfig_Role_MIN, 0, 0} #define Config_PositionConfig_init_zero {0, 0, 0, 0, 0, 0, 0} #define Config_PowerConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0} -#define Config_NetworkConfig_init_zero {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_zero} +#define Config_NetworkConfig_init_zero {0, _Config_NetworkConfig_EthMode_MIN, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_zero} #define Config_NetworkConfig_IpV4Config_init_zero {0, 0, 0, 0} #define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN} #define Config_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}} @@ -299,6 +290,7 @@ extern "C" { #define Config_PowerConfig_ls_secs_tag 7 #define Config_PowerConfig_min_wake_secs_tag 8 #define Config_NetworkConfig_wifi_enabled_tag 1 +#define Config_NetworkConfig_wifi_mode_tag 2 #define Config_NetworkConfig_wifi_ssid_tag 3 #define Config_NetworkConfig_wifi_psk_tag 4 #define Config_NetworkConfig_ntp_server_tag 5 @@ -364,6 +356,7 @@ X(a, STATIC, SINGULAR, UINT32, min_wake_secs, 8) #define Config_NetworkConfig_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, BOOL, wifi_enabled, 1) \ +X(a, STATIC, SINGULAR, UENUM, wifi_mode, 2) \ X(a, STATIC, SINGULAR, STRING, wifi_ssid, 3) \ X(a, STATIC, SINGULAR, STRING, wifi_psk, 4) \ X(a, STATIC, SINGULAR, STRING, ntp_server, 5) \ @@ -443,10 +436,10 @@ extern const pb_msgdesc_t Config_BluetoothConfig_msg; #define Config_DisplayConfig_size 22 #define Config_LoRaConfig_size 68 #define Config_NetworkConfig_IpV4Config_size 20 -#define Config_NetworkConfig_size 161 +#define Config_NetworkConfig_size 163 #define Config_PositionConfig_size 30 #define Config_PowerConfig_size 43 -#define Config_size 164 +#define Config_size 166 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/localonly.pb.h b/src/mesh/generated/localonly.pb.h index 783c523c7..a69aefc10 100644 --- a/src/mesh/generated/localonly.pb.h +++ b/src/mesh/generated/localonly.pb.h @@ -150,7 +150,7 @@ extern const pb_msgdesc_t LocalModuleConfig_msg; #define LocalModuleConfig_fields &LocalModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define LocalConfig_size 361 +#define LocalConfig_size 363 #define LocalModuleConfig_size 294 #ifdef __cplusplus diff --git a/src/mesh/http/WiFiAPClient.cpp b/src/mesh/http/WiFiAPClient.cpp index a031414e3..6caad79c0 100644 --- a/src/mesh/http/WiFiAPClient.cpp +++ b/src/mesh/http/WiFiAPClient.cpp @@ -169,6 +169,11 @@ bool initWifi() WiFi.mode(WIFI_MODE_STA); WiFi.setHostname(ourHost); WiFi.onEvent(WiFiEvent); + WiFi.setAutoReconnect(true); + WiFi.setSleep(false); + if (config.network.wifi_mode == Config_NetworkConfig_EthMode_STATIC && config.network.ipv4_config.ip != 0) { + WiFi.config(config.network.ipv4_config.ip,config.network.ipv4_config.gateway,config.network.ipv4_config.subnet,config.network.ipv4_config.dns,config.network.ipv4_config.dns); + } // This is needed to improve performance. esp_wifi_set_ps(WIFI_PS_NONE); // Disable radio power saving @@ -222,8 +227,6 @@ static void WiFiEvent(WiFiEvent_t event) break; case SYSTEM_EVENT_STA_DISCONNECTED: DEBUG_MSG("Disconnected from WiFi access point\n"); - // Event 5 - needReconnect = true; break; case SYSTEM_EVENT_STA_AUTHMODE_CHANGE: @@ -236,6 +239,7 @@ static void WiFiEvent(WiFiEvent_t event) break; case SYSTEM_EVENT_STA_LOST_IP: DEBUG_MSG("Lost IP address and IP address is reset to 0\n"); + needReconnect = true; break; case SYSTEM_EVENT_STA_WPS_ER_SUCCESS: DEBUG_MSG("WiFi Protected Setup (WPS): succeeded in enrollee mode\n"); @@ -251,7 +255,6 @@ static void WiFiEvent(WiFiEvent_t event) break; case SYSTEM_EVENT_AP_START: DEBUG_MSG("WiFi access point started\n"); - onNetworkConnected(); break; case SYSTEM_EVENT_AP_STOP: From 950d5defda88abfd2d033410184e855c38fd4bc2 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 09:28:41 -0500 Subject: [PATCH 15/32] Master to develop (resolves conflicts) (#1903) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Rearranging deck chairs, 900M22S working, 30S not * We do have wire, just not where it's expected * Put more of the module specific pins in their blocks * tryfix compile with NO_SCREEN * Portduino only: don't continue to try rebooting (#1887) Co-authored-by: Thomas Göttgens * Support for TLORA 2.1-1.8 * Don't allow arbitrary channel name for admin (#1886) Co-authored-by: Ben Meadors * Experimental DIY nrf52840 feather support (#1884) * Experimental DIY nrf52840 feather support * Fix target * sx1262 wiring * Remove lib * Don't consider Response as ACK for FloodingRouter (#1885) Co-authored-by: Ben Meadors * Fix feather diy (#1892) * Fix variant * Fix feather diy target * [modules][external notifications] allow select channel to listen to * Fix feather diy pin mapping (#1894) Thanks to @markbirss * [create-pull-request] automated change * Override Screen Autodtect * Maybe fix crash of this board. * Fixes reset loop with new espressif32 platform on tlora-v2 Sending a pulse to the OLED_RESET Pin 16 results in a reset loop using recent version of the espressif32 platform. * Experiment with self hosted action runner * Fix MQTT on ETH * revert the tryfix * Cheating * Cleanup artifacts older than 1 month * Update cleanup_artifacts.yml * Update cleanup_artifacts.yml * Update cleanup_artifacts.yml * Delete cleanup_artifacts.yml * fix: use RF95_IRQ for wakeup source in doLightSleep (#1899) Co-authored-by: Thomas Göttgens Co-authored-by: Ben Meadors * Update protos * Update protos Co-authored-by: code8buster Co-authored-by: Thomas Göttgens Co-authored-by: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Co-authored-by: Mykhailo Lesyk Co-authored-by: Mykhailo Lesyk Co-authored-by: caveman99 Co-authored-by: he-leon Co-authored-by: Lars Weber --- src/mesh/Router.cpp | 6 +++--- src/mesh/generated/config.pb.c | 1 - src/sleep.cpp | 4 ++-- variants/tlora_v2/variant.h | 4 +--- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 815571b9b..e0746bdd9 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -11,7 +11,7 @@ extern "C" { #include "mesh/compression/unishox2.h" } -#if HAS_WIFI +#if HAS_WIFI || HAS_ETHERNET #include "mqtt/MQTT.h" #endif @@ -209,7 +209,7 @@ ErrorCode Router::send(MeshPacket *p) if (p->which_payload_variant == MeshPacket_decoded_tag) { ChannelIndex chIndex = p->channel; // keep as a local because we are about to change it -#if HAS_WIFI +#if HAS_WIFI || HAS_ETHERNET // check if we should send decrypted packets to mqtt // truth table: @@ -240,7 +240,7 @@ ErrorCode Router::send(MeshPacket *p) return encodeResult; // FIXME - this isn't a valid ErrorCode } -#if HAS_WIFI +#if HAS_WIFI || HAS_ETHERNET // the packet is now encrypted. // check if we should send encrypted packets to mqtt if (mqtt && shouldActuallyEncrypt) diff --git a/src/mesh/generated/config.pb.c b/src/mesh/generated/config.pb.c index 2b75b7558..c5bc69552 100644 --- a/src/mesh/generated/config.pb.c +++ b/src/mesh/generated/config.pb.c @@ -43,4 +43,3 @@ PB_BIND(Config_BluetoothConfig, Config_BluetoothConfig, AUTO) - diff --git a/src/sleep.cpp b/src/sleep.cpp index 055cf770d..390ab7f65 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -263,8 +263,8 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r #ifdef BUTTON_PIN gpio_wakeup_enable((gpio_num_t)BUTTON_PIN, GPIO_INTR_LOW_LEVEL); // when user presses, this button goes low #endif -#ifdef RF95_IRQ_GPIO - gpio_wakeup_enable((gpio_num_t)RF95_IRQ_GPIO, GPIO_INTR_HIGH_LEVEL); // RF95 interrupt, active high +#ifdef RF95_IRQ + gpio_wakeup_enable((gpio_num_t)RF95_IRQ, GPIO_INTR_HIGH_LEVEL); // RF95 interrupt, active high #endif #ifdef PMU_IRQ // wake due to PMU can happen repeatedly if there is no battery installed or the battery fills diff --git a/variants/tlora_v2/variant.h b/variants/tlora_v2/variant.h index 1bff09fb0..0c854e37a 100644 --- a/variants/tlora_v2/variant.h +++ b/variants/tlora_v2/variant.h @@ -8,8 +8,6 @@ #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 25 // If defined we will blink this LED #define BUTTON_PIN \ @@ -21,4 +19,4 @@ #define LORA_DIO0 26 // a No connect on the SX1262 module #define LORA_RESET 14 #define LORA_DIO1 35 // Not really used -#define LORA_DIO2 34 // Not really used \ No newline at end of file +#define LORA_DIO2 34 // Not really used From 087c7c19af3beaa55caab129d9e73487d972fbdd Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 09:34:33 -0500 Subject: [PATCH 16/32] Update protos --- src/mesh/generated/config.pb.c | 1 - src/mesh/generated/localonly.pb.h | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/mesh/generated/config.pb.c b/src/mesh/generated/config.pb.c index 2b75b7558..c5bc69552 100644 --- a/src/mesh/generated/config.pb.c +++ b/src/mesh/generated/config.pb.c @@ -43,4 +43,3 @@ PB_BIND(Config_BluetoothConfig, Config_BluetoothConfig, AUTO) - diff --git a/src/mesh/generated/localonly.pb.h b/src/mesh/generated/localonly.pb.h index dd633a961..a69aefc10 100644 --- a/src/mesh/generated/localonly.pb.h +++ b/src/mesh/generated/localonly.pb.h @@ -150,8 +150,8 @@ extern const pb_msgdesc_t LocalModuleConfig_msg; #define LocalModuleConfig_fields &LocalModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define LocalConfig_size 359 -#define LocalModuleConfig_size 270 +#define LocalConfig_size 363 +#define LocalModuleConfig_size 294 #ifdef __cplusplus } /* extern "C" */ From 3d9633a56cbf4520c81926d9229053563123657f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 5 Nov 2022 20:12:41 +0100 Subject: [PATCH 17/32] Different Sensor access, should prevent overheating/wrong measurements. --- src/modules/Telemetry/Sensor/BME280Sensor.cpp | 9 +++++++++ src/modules/Telemetry/Sensor/BMP280Sensor.cpp | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/modules/Telemetry/Sensor/BME280Sensor.cpp b/src/modules/Telemetry/Sensor/BME280Sensor.cpp index 15ec18007..4b6a50091 100644 --- a/src/modules/Telemetry/Sensor/BME280Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BME280Sensor.cpp @@ -16,6 +16,14 @@ int32_t BME280Sensor::runOnce() { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; } status = bme280.begin(nodeTelemetrySensorsMap[sensorType]); + + bme280.setSampling( Adafruit_BME280::MODE_FORCED, + Adafruit_BME280::SAMPLING_X1, // Temp. oversampling + Adafruit_BME280::SAMPLING_X1, // Pressure oversampling + Adafruit_BME280::SAMPLING_X1, // Humidity oversampling + Adafruit_BME280::FILTER_OFF, + Adafruit_BME280::STANDBY_MS_1000); + return initI2CSensor(); } @@ -23,6 +31,7 @@ void BME280Sensor::setup() { } bool BME280Sensor::getMetrics(Telemetry *measurement) { DEBUG_MSG("BME280Sensor::getMetrics\n"); + bme280.takeForcedMeasurement(); measurement->variant.environment_metrics.temperature = bme280.readTemperature(); measurement->variant.environment_metrics.relative_humidity = bme280.readHumidity(); measurement->variant.environment_metrics.barometric_pressure = bme280.readPressure() / 100.0F; diff --git a/src/modules/Telemetry/Sensor/BMP280Sensor.cpp b/src/modules/Telemetry/Sensor/BMP280Sensor.cpp index 4fecdf1a8..917c40d6f 100644 --- a/src/modules/Telemetry/Sensor/BMP280Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BMP280Sensor.cpp @@ -16,6 +16,13 @@ int32_t BMP280Sensor::runOnce() { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; } status = bmp280.begin(nodeTelemetrySensorsMap[sensorType]); + + bmp280.setSampling( Adafruit_BMP280::MODE_FORCED, + Adafruit_BMP280::SAMPLING_X1, // Temp. oversampling + Adafruit_BMP280::SAMPLING_X1, // Pressure oversampling + Adafruit_BMP280::FILTER_OFF, + Adafruit_BMP280::STANDBY_MS_1000); + return initI2CSensor(); } @@ -23,6 +30,7 @@ void BMP280Sensor::setup() { } bool BMP280Sensor::getMetrics(Telemetry *measurement) { DEBUG_MSG("BMP280Sensor::getMetrics\n"); + bmp280.takeForcedMeasurement(); measurement->variant.environment_metrics.temperature = bmp280.readTemperature(); measurement->variant.environment_metrics.barometric_pressure = bmp280.readPressure() / 100.0F; From 16444c190d965bf703b81708a19f5498504d18b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 5 Nov 2022 20:13:47 +0100 Subject: [PATCH 18/32] Ignore Band power limits for licensed HAMs --- src/mesh/RadioInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 81821ac19..97dd66fae 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -416,7 +416,7 @@ void RadioInterface::applyModemConfig() power = loraConfig.tx_power; assert(myRegion); // Should have been found in init - if ((power == 0) || (power > myRegion->powerLimit)) + if ((power == 0) || ((power > myRegion->powerLimit) && !devicestate.owner.is_licensed)) power = myRegion->powerLimit; if (power == 0) @@ -460,7 +460,7 @@ void RadioInterface::limitPower() if (myRegion->powerLimit) maxPower = myRegion->powerLimit; - if (power > maxPower) { + if ((power > maxPower) && !devicestate.owner.is_licensed) { DEBUG_MSG("Lowering transmit power because of regulatory limits\n"); power = maxPower; } From 7652253b8d4324ff07eab3276a3d5c8ca100dd9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 6 Nov 2022 10:37:14 +0100 Subject: [PATCH 19/32] optimize BME680 usage --- src/modules/Telemetry/Sensor/BME680Sensor.cpp | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/modules/Telemetry/Sensor/BME680Sensor.cpp b/src/modules/Telemetry/Sensor/BME680Sensor.cpp index 474c376dd..cab388e75 100644 --- a/src/modules/Telemetry/Sensor/BME680Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BME680Sensor.cpp @@ -14,25 +14,28 @@ int32_t BME680Sensor::runOnce() { if (!hasSensor()) { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; } - status = bme680.begin(nodeTelemetrySensorsMap[sensorType]); + status = bme680.begin(nodeTelemetrySensorsMap[sensorType], false); + + // Set up oversampling and filter initialization + bme680.setTemperatureOversampling(BME68X_OS_1X); + bme680.setHumidityOversampling(BME68X_OS_1X); + bme680.setPressureOversampling(BME68X_OS_1X); + bme680.setIIRFilterSize(BME68X_FILTER_OFF); + bme680.setODR(BME68X_ODR_1000_MS); + // BME68X_FORCED_MODE is done in Lib Init already + bme680.setGasHeater(320, 150); // 320*C for 150 ms + return initI2CSensor(); } -void BME680Sensor::setup() -{ - // Set up oversampling and filter initialization - bme680.setTemperatureOversampling(BME680_OS_8X); - bme680.setHumidityOversampling(BME680_OS_2X); - bme680.setPressureOversampling(BME680_OS_4X); - bme680.setIIRFilterSize(BME680_FILTER_SIZE_3); - bme680.setGasHeater(320, 150); // 320*C for 150 ms -} +void BME680Sensor::setup() { } bool BME680Sensor::getMetrics(Telemetry *measurement) { - measurement->variant.environment_metrics.temperature = bme680.readTemperature(); - measurement->variant.environment_metrics.relative_humidity = bme680.readHumidity(); - measurement->variant.environment_metrics.barometric_pressure = bme680.readPressure() / 100.0F; - measurement->variant.environment_metrics.gas_resistance = bme680.readGas() / 1000.0; + bme680.performReading(); + measurement->variant.environment_metrics.temperature = bme680.temperature; + measurement->variant.environment_metrics.relative_humidity = bme680.humidity; + measurement->variant.environment_metrics.barometric_pressure = bme680.pressure / 100.0F; + measurement->variant.environment_metrics.gas_resistance = bme680.gas_resistance / 1000.0; return true; } \ No newline at end of file From 8ab269e1b3f8beeb9292859f2878370b0597f9ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 6 Nov 2022 10:52:54 +0100 Subject: [PATCH 20/32] revert BME680 to default settings, they are working good. Our init was just replicating what's in the lib anyway. --- src/modules/Telemetry/Sensor/BME680Sensor.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/modules/Telemetry/Sensor/BME680Sensor.cpp b/src/modules/Telemetry/Sensor/BME680Sensor.cpp index cab388e75..a9171facf 100644 --- a/src/modules/Telemetry/Sensor/BME680Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BME680Sensor.cpp @@ -14,16 +14,7 @@ int32_t BME680Sensor::runOnce() { if (!hasSensor()) { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; } - status = bme680.begin(nodeTelemetrySensorsMap[sensorType], false); - - // Set up oversampling and filter initialization - bme680.setTemperatureOversampling(BME68X_OS_1X); - bme680.setHumidityOversampling(BME68X_OS_1X); - bme680.setPressureOversampling(BME68X_OS_1X); - bme680.setIIRFilterSize(BME68X_FILTER_OFF); - bme680.setODR(BME68X_ODR_1000_MS); - // BME68X_FORCED_MODE is done in Lib Init already - bme680.setGasHeater(320, 150); // 320*C for 150 ms + status = bme680.begin(nodeTelemetrySensorsMap[sensorType]); return initI2CSensor(); } From 7b378d36cc73e71ec05579035af8ca526ba38e58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 6 Nov 2022 13:29:01 +0100 Subject: [PATCH 21/32] try to make cppcheck happy again --- src/modules/esp32/AudioModule.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/esp32/AudioModule.h b/src/modules/esp32/AudioModule.h index fcd5d169e..b67f83c8b 100644 --- a/src/modules/esp32/AudioModule.h +++ b/src/modules/esp32/AudioModule.h @@ -11,8 +11,6 @@ #include #include #include -#else -typedef int FastAudioFIFO; #endif #define ADC_BUFFER_SIZE 320 // 40ms of voice in 8KHz sampling frequency @@ -20,6 +18,7 @@ typedef int FastAudioFIFO; class AudioModule : public SinglePortModule, private concurrency::OSThread { +#if defined(ARCH_ESP32) && defined(USE_SX1280) bool firstTime = 1; hw_timer_t* adcTimer = NULL; uint16_t adc_buffer[ADC_BUFFER_SIZE]; @@ -62,6 +61,7 @@ class AudioModule : public SinglePortModule, private concurrency::OSThread * @return ProcessMessage::STOP if you've guaranteed you've handled this message and no other handlers should be considered for it */ virtual ProcessMessage handleReceived(const MeshPacket &mp) override; +#endif }; extern AudioModule *audioModule; From 631db56a4467cc5186e39ba7e3f0d7c9c15d24ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 6 Nov 2022 14:32:02 +0100 Subject: [PATCH 22/32] Next try, plus change cppcheck defines back. --- platformio.ini | 4 ++-- src/modules/esp32/AudioModule.cpp | 23 +++++++---------------- src/modules/esp32/AudioModule.h | 12 ++++++------ 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/platformio.ini b/platformio.ini index 7c1ba6851..0021350dd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -59,8 +59,8 @@ lib_deps = check_tool = cppcheck check_skip_packages = yes check_flags = - --common-flag - cppcheck: --enable=--inline-suppr + -DAPP_VERSION=1.0.0 + --suppressions-list=suppressions.txt ; Common settings for conventional (non Portduino) Arduino targets [arduino_base] diff --git a/src/modules/esp32/AudioModule.cpp b/src/modules/esp32/AudioModule.cpp index 9328bdd81..7147db43c 100644 --- a/src/modules/esp32/AudioModule.cpp +++ b/src/modules/esp32/AudioModule.cpp @@ -42,11 +42,11 @@ #define AUDIO_MODULE_MODE 7 // 700B #define AUDIO_MODULE_ACK 1 +#if defined(ARCH_ESP32) && defined(USE_SX1280) + AudioModule *audioModule; -#if defined(ARCH_ESP32) && defined(USE_SX1280) ButterworthFilter hp_filter(240, 8000, ButterworthFilter::ButterworthFilter::Highpass, 1); -#endif //int16_t 1KHz sine test tone int16_t Sine1KHz[8] = { -21210 , -30000, -21210, 0 , 21210 , 30000 , 21210, 0 }; @@ -54,11 +54,12 @@ int Sine1KHz_index = 0; uint8_t rx_raw_audio_value = 127; -AudioModule::AudioModule() : SinglePortModule("AudioModule", PortNum_AUDIO_APP), concurrency::OSThread("AudioModule") {} +AudioModule::AudioModule() : SinglePortModule("AudioModule", PortNum_AUDIO_APP), concurrency::OSThread("AudioModule") { + audio_fifo.init(); +} void AudioModule::run_codec2() { -#if defined(ARCH_ESP32) && defined(USE_SX1280) if (state == State::tx) { for (int i = 0; i < ADC_BUFFER_SIZE; i++) @@ -91,7 +92,6 @@ void AudioModule::run_codec2() } } state = State::standby; -#endif } void AudioModule::handleInterrupt() @@ -101,7 +101,6 @@ void AudioModule::handleInterrupt() void AudioModule::onTimer() { -#if defined(ARCH_ESP32) && defined(USE_SX1280) if (state == State::tx) { adc_buffer[adc_buffer_index++] = (16 * adc1_get_raw(mic_chan)) - 32768; @@ -129,13 +128,10 @@ void AudioModule::onTimer() //Play dacWrite(moduleConfig.audio.amp_pin ? moduleConfig.audio.amp_pin : AAMP, rx_raw_audio_value); } -#endif } int32_t AudioModule::runOnce() { -#if defined(ARCH_ESP32) && defined(USE_SX1280) - if (moduleConfig.audio.codec2_enabled) { if (firstTime) { @@ -198,9 +194,6 @@ int32_t AudioModule::runOnce() return INT32_MAX; } -#else - return INT32_MAX; -#endif } MeshPacket *AudioModule::allocReply() @@ -227,8 +220,6 @@ void AudioModule::sendPayload(NodeNum dest, bool wantReplies) ProcessMessage AudioModule::handleReceived(const MeshPacket &mp) { -#if defined(ARCH_ESP32) && defined(USE_SX1280) - if (moduleConfig.audio.codec2_enabled) { auto &p = mp.decoded; if (getFrom(&mp) != nodeDB.getNodeNum()) { @@ -243,7 +234,7 @@ ProcessMessage AudioModule::handleReceived(const MeshPacket &mp) } } -#endif - return ProcessMessage::CONTINUE; } + +#endif \ No newline at end of file diff --git a/src/modules/esp32/AudioModule.h b/src/modules/esp32/AudioModule.h index b67f83c8b..d82af4d43 100644 --- a/src/modules/esp32/AudioModule.h +++ b/src/modules/esp32/AudioModule.h @@ -21,16 +21,16 @@ class AudioModule : public SinglePortModule, private concurrency::OSThread #if defined(ARCH_ESP32) && defined(USE_SX1280) bool firstTime = 1; hw_timer_t* adcTimer = NULL; - uint16_t adc_buffer[ADC_BUFFER_SIZE]; - int16_t speech[ADC_BUFFER_SIZE]; - int16_t output_buffer[ADC_BUFFER_SIZE]; - unsigned char rx_encode_frame[ENCODE_FRAME_SIZE]; - unsigned char tx_encode_frame[ENCODE_FRAME_SIZE]; + uint16_t adc_buffer[ADC_BUFFER_SIZE] = {}; + int16_t speech[ADC_BUFFER_SIZE] = {}; + int16_t output_buffer[ADC_BUFFER_SIZE] = {}; + unsigned char rx_encode_frame[ENCODE_FRAME_SIZE] = {}; + unsigned char tx_encode_frame[ENCODE_FRAME_SIZE] = {}; int tx_encode_frame_index = 0; FastAudioFIFO audio_fifo; uint16_t adc_buffer_index = 0; adc1_channel_t mic_chan = (adc1_channel_t)0; - struct CODEC2* codec2_state; + struct CODEC2* codec2_state = NULL; enum State { From 26a907444cc18ffb41aba706e5ada39461c8d79c Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 15:10:43 -0500 Subject: [PATCH 23/32] Fix for alpine linux builds --- src/gps/NMEAWPL.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gps/NMEAWPL.h b/src/gps/NMEAWPL.h index 853c850eb..44e081bf7 100644 --- a/src/gps/NMEAWPL.h +++ b/src/gps/NMEAWPL.h @@ -3,5 +3,5 @@ #include #include "main.h" -uint printWPL(char *buf, const Position &pos, const char *name); -uint printGGA(char *buf, const Position &pos); +uin32_t printWPL(char *buf, const Position &pos, const char *name); +uin32_t printGGA(char *buf, const Position &pos); From f9c376a5246ca66ae536821e05519dd75cef61a9 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 15:11:11 -0500 Subject: [PATCH 24/32] Update NMEAWPL.cpp --- src/gps/NMEAWPL.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gps/NMEAWPL.cpp b/src/gps/NMEAWPL.cpp index 95e69343b..d23e78182 100644 --- a/src/gps/NMEAWPL.cpp +++ b/src/gps/NMEAWPL.cpp @@ -15,7 +15,7 @@ * ------------------------------------------- */ -uint printWPL(char *buf, const Position &pos, const char *name) +uint32_t printWPL(char *buf, const Position &pos, const char *name) { uint len = sprintf(buf, "$GNWPL,%07.2f,%c,%08.2f,%c,%s", pos.latitude_i * 1e-5, pos.latitude_i < 0 ? 'S' : 'N', pos.longitude_i * 1e-5, pos.longitude_i < 0 ? 'W' : 'E', name); uint chk = 0; @@ -50,9 +50,9 @@ uint printWPL(char *buf, const Position &pos, const char *name) * ------------------------------------------- */ -uint printGGA(char *buf, const Position &pos) +uint32_t printGGA(char *buf, const Position &pos) { - uint len = sprintf(buf, "$GNGGA,%06u.%03u,%07.2f,%c,%08.2f,%c,%u,%02u,%04u,%04d,%c,%04d,%c,%d,%04d", + uint32_t len = sprintf(buf, "$GNGGA,%06u.%03u,%07.2f,%c,%08.2f,%c,%u,%02u,%04u,%04d,%c,%04d,%c,%d,%04d", pos.time / 1000, pos.time % 1000, pos.latitude_i * 1e-5, pos.latitude_i < 0 ? 'S' : 'N', @@ -67,10 +67,10 @@ uint printGGA(char *buf, const Position &pos) 0, 0); - uint chk = 0; - for (uint i = 1; i < len; i++) { + uint32_t chk = 0; + for (uint32_t i = 1; i < len; i++) { chk ^= buf[i]; } len += sprintf(buf + len, "*%02X\r\n", chk); return len; -} \ No newline at end of file +} From e1ce0375504b25b8a5264f2c52c933f742261408 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 15:14:08 -0500 Subject: [PATCH 25/32] Update NMEAWPL.cpp --- src/gps/NMEAWPL.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gps/NMEAWPL.cpp b/src/gps/NMEAWPL.cpp index d23e78182..666f9131b 100644 --- a/src/gps/NMEAWPL.cpp +++ b/src/gps/NMEAWPL.cpp @@ -17,8 +17,8 @@ uint32_t printWPL(char *buf, const Position &pos, const char *name) { - uint len = sprintf(buf, "$GNWPL,%07.2f,%c,%08.2f,%c,%s", pos.latitude_i * 1e-5, pos.latitude_i < 0 ? 'S' : 'N', pos.longitude_i * 1e-5, pos.longitude_i < 0 ? 'W' : 'E', name); - uint chk = 0; + uint32_t len = sprintf(buf, "$GNWPL,%07.2f,%c,%08.2f,%c,%s", pos.latitude_i * 1e-5, pos.latitude_i < 0 ? 'S' : 'N', pos.longitude_i * 1e-5, pos.longitude_i < 0 ? 'W' : 'E', name); + uint32_t chk = 0; for (uint i = 1; i < len; i++) { chk ^= buf[i]; } From d15edf1955f3d33368c0000e6dd18bad9e5f57bd Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 15:20:09 -0500 Subject: [PATCH 26/32] Update NMEAWPL.h --- src/gps/NMEAWPL.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gps/NMEAWPL.h b/src/gps/NMEAWPL.h index 44e081bf7..aaa18933c 100644 --- a/src/gps/NMEAWPL.h +++ b/src/gps/NMEAWPL.h @@ -3,5 +3,5 @@ #include #include "main.h" -uin32_t printWPL(char *buf, const Position &pos, const char *name); -uin32_t printGGA(char *buf, const Position &pos); +uint32_t printWPL(char *buf, const Position &pos, const char *name); +uint32_t printGGA(char *buf, const Position &pos); From 6694d31d07735ec9091c0929397b65cc630cabfb Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 15:34:54 -0500 Subject: [PATCH 27/32] Somehow I still missed one :-| --- src/gps/NMEAWPL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gps/NMEAWPL.cpp b/src/gps/NMEAWPL.cpp index 666f9131b..222a2d04c 100644 --- a/src/gps/NMEAWPL.cpp +++ b/src/gps/NMEAWPL.cpp @@ -19,7 +19,7 @@ uint32_t printWPL(char *buf, const Position &pos, const char *name) { uint32_t len = sprintf(buf, "$GNWPL,%07.2f,%c,%08.2f,%c,%s", pos.latitude_i * 1e-5, pos.latitude_i < 0 ? 'S' : 'N', pos.longitude_i * 1e-5, pos.longitude_i < 0 ? 'W' : 'E', name); uint32_t chk = 0; - for (uint i = 1; i < len; i++) { + for (uint32_t i = 1; i < len; i++) { chk ^= buf[i]; } len += sprintf(buf + len, "*%02X\r\n", chk); From 3ca6f645d48af15fc5a51e87c1706ffc74914b12 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 18:21:35 -0500 Subject: [PATCH 28/32] Portduino build flags --- variants/portduino/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/portduino/platformio.ini b/variants/portduino/platformio.ini index c95ae37fe..016ef61bd 100644 --- a/variants/portduino/platformio.ini +++ b/variants/portduino/platformio.ini @@ -1,6 +1,6 @@ [env:native] platform = https://github.com/meshtastic/platform-native.git -build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino +build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino -E framework = arduino board = cross_platform lib_deps = ${portduino_base.lib_deps} From 3562d3455574d400efe71b1aca8f706577b6ab5d Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 19:09:04 -0500 Subject: [PATCH 29/32] Remove flag --- variants/portduino/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/portduino/platformio.ini b/variants/portduino/platformio.ini index 016ef61bd..c95ae37fe 100644 --- a/variants/portduino/platformio.ini +++ b/variants/portduino/platformio.ini @@ -1,6 +1,6 @@ [env:native] platform = https://github.com/meshtastic/platform-native.git -build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino -E +build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino framework = arduino board = cross_platform lib_deps = ${portduino_base.lib_deps} From 12fa08007ddcf50cdf3fec7c7ffea651ed5231d6 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 21:08:29 -0500 Subject: [PATCH 30/32] Docker is back --- Dockerfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..45aa5df45 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM debian:bullseye-slim +RUN apt-get update +RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install wget python3 g++ zip python3-venv git vim +RUN wget https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py -O get-platformio.py; chmod +x get-platformio.py +RUN python3 get-platformio.py +RUN git clone https://github.com/meshtastic/firmware --recurse-submodules +RUN cd firmware +RUN chmod +x ./firmware/bin/build-native.sh +RUN . ~/.platformio/penv/bin/activate; cd firmware; sh ./bin/build-native.sh + +CMD ["/firmware/release/meshtasticd_linux_amd64"] From 057109dcac8f8d9b710aabe052dc8c551dc74cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 6 Nov 2022 14:49:02 +0100 Subject: [PATCH 31/32] Reduce retention to 30 days. --- .github/workflows/main_matrix.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 4736de06e..aacdc72af 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -170,7 +170,7 @@ jobs: path: | release/*.bin release/*.elf - retention-days: 90 + retention-days: 30 build-nrf52: strategy: @@ -229,7 +229,7 @@ jobs: release/*.uf2 release/*.elf release/*.zip - retention-days: 90 + retention-days: 30 build-rpi2040: strategy: @@ -283,7 +283,7 @@ jobs: path: | release/*.uf2 release/*.elf - retention-days: 90 + retention-days: 30 build-native: runs-on: ubuntu-latest @@ -342,7 +342,7 @@ jobs: release/meshtasticd_linux_amd64 release/device-*.sh release/device-*.bat - retention-days: 90 + retention-days: 30 after-checks: runs-on: ubuntu-latest From 3492d641773412bf235d2a28c1d7d34edb3aaa6b Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 6 Nov 2022 09:30:46 -0600 Subject: [PATCH 32/32] Alpine --- Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 45aa5df45..01d262ce3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:bullseye-slim +FROM debian:bullseye-slim AS builder RUN apt-get update RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install wget python3 g++ zip python3-venv git vim RUN wget https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py -O get-platformio.py; chmod +x get-platformio.py @@ -8,4 +8,8 @@ RUN cd firmware RUN chmod +x ./firmware/bin/build-native.sh RUN . ~/.platformio/penv/bin/activate; cd firmware; sh ./bin/build-native.sh -CMD ["/firmware/release/meshtasticd_linux_amd64"] +FROM frolvlad/alpine-glibc +WORKDIR /root/ +COPY --from=builder /firmware/release/meshtasticd_linux_amd64 ./ +RUN apk --update add --no-cache g++ +CMD ["./meshtasticd_linux_amd64"]