From 905194c6040bce4c1f036f1d040d23ba9029b187 Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Mon, 16 Sep 2024 22:06:13 +0800 Subject: [PATCH 01/45] Remove lora_isp4520 (#4735) Per Ben: "We haven't supported any NRF5832 based board in quite some time. It's relatively resource constrained compared to the NRF52840" --- boards/lora_isp4520.json | 40 ------------ variants/lora_isp4520/platformio.ini | 18 ------ variants/lora_isp4520/variant.cpp | 52 --------------- variants/lora_isp4520/variant.h | 94 ---------------------------- 4 files changed, 204 deletions(-) delete mode 100644 boards/lora_isp4520.json delete mode 100644 variants/lora_isp4520/platformio.ini delete mode 100644 variants/lora_isp4520/variant.cpp delete mode 100644 variants/lora_isp4520/variant.h diff --git a/boards/lora_isp4520.json b/boards/lora_isp4520.json deleted file mode 100644 index 8125aa666..000000000 --- a/boards/lora_isp4520.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "build": { - "arduino": { - "ldscript": "nrf52832_s132_v6.ld" - }, - "core": "nRF5", - "cpu": "cortex-m4", - "extra_flags": "-DNRF52832_XXAA -DNRF52", - "f_cpu": "64000000L", - "mcu": "nrf52832", - "variant": "lora_isp4520", - "bsp": { - "name": "adafruit" - }, - "softdevice": { - "sd_flags": "-DS132", - "sd_name": "s132", - "sd_version": "6.1.1", - "sd_fwid": "0x00B7" - } - }, - "connectivity": ["bluetooth"], - "debug": { - "jlink_device": "nRF52832_xxAA", - "svd_path": "nrf52.svd", - "openocd_target": "nrf52840-mdk-rs" - }, - "frameworks": ["arduino"], - "name": "lora ISP4520", - "upload": { - "maximum_ram_size": 65536, - "maximum_size": 524288, - "require_upload_port": true, - "speed": 115200, - "protocol": "nrfutil", - "protocols": ["jlink", "nrfjprog", "nrfutil", "stlink"] - }, - "url": "", - "vendor": "PsiSoft" -} diff --git a/variants/lora_isp4520/platformio.ini b/variants/lora_isp4520/platformio.ini deleted file mode 100644 index 9d6563515..000000000 --- a/variants/lora_isp4520/platformio.ini +++ /dev/null @@ -1,18 +0,0 @@ -[env:lora_isp4520] -extends = nrf52_base -board = lora_isp4520 -board_level = extra - -# add our variants files to the include and src paths -build_flags = ${nrf52_base.build_flags} -Ivariants/lora_isp4520 - -# No screen and GPS on the board. We still need RTC.cpp for the RTC clock. -build_src_filter = ${nrf52_base.build_src_filter} +<../variants/lora_isp4520> - - + + -lib_ignore = ${nrf52_base.lib_ignore} - ESP8266_SSD1306 - SparkFun Ublox Arduino Library - AXP202X_Library - TinyGPSPlus - -upload_protocol = jlink -monitor_port = /dev/ttyUSB0 \ No newline at end of file diff --git a/variants/lora_isp4520/variant.cpp b/variants/lora_isp4520/variant.cpp deleted file mode 100644 index 41b31384a..000000000 --- a/variants/lora_isp4520/variant.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - 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" - -const uint32_t g_ADigitalPinMap[] = { - 25, // D0 SPI_MISO - 24, // D1 SPI_NSS - 23, // D2 SPI_SCK - 4, // D3 VBAT - 11, // D4 DIO1 - 27, // D5 BUSY - 19, // D6 NRESET - 12, // D7 BUTTON2 - 22, // D8 BUTTON3 - 26, // D9 SPI_MOSI - 31, // D10 UART_RX - 2, // D11 UART_TX - 10, // D12 LED1 GREEN - 17, // D13 LED2 RED - 9, // D14 BUZZER - 7, // D15 BUTTON1 -}; - -#include -void initVariant() -{ - for (int i : {PIN_LED1, PIN_LED2}) { - pinMode(i, OUTPUT); - ledOff(i); - } -} diff --git a/variants/lora_isp4520/variant.h b/variants/lora_isp4520/variant.h deleted file mode 100644 index 30b8fc169..000000000 --- a/variants/lora_isp4520/variant.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - 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 -*/ - -#ifndef _VARIANT_LORA_ISP4520_ -#define _VARIANT_LORA_ISP4520_ - -#define USE_SEGGER -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include "WVariant.h" - -#define USE_LFXO - -// #define USE_SEGGER - -// Number of pins defined in PinDescription array -#define PINS_COUNT (16) -#define NUM_DIGITAL_PINS (16) -#define NUM_ANALOG_INPUTS (1) -#define NUM_ANALOG_OUTPUTS (1) - -/* - * SPI Interfaces - */ -#define SPI_INTERFACES_COUNT 1 - -// These are in arduino pin numbers, -// translation in g_ADigitalPinMap in variants.cpp -#define PIN_SPI_MISO (0) -#define PIN_SPI_MOSI (9) -#define PIN_SPI_SCK (2) - -/* - * Wire Interfaces (I2C) - */ -#define WIRE_INTERFACES_COUNT 0 - -// GPIOs the SX1262 is connected -#define USE_SX1262 -#define SX126X_CS 1 // aka SPI_NSS -#define SX126X_DIO1 (4) -#define SX126X_BUSY (5) -#define SX126X_RESET (6) - -/* - * Serial interfaces - */ -#define PIN_SERIAL_RX (10) -#define PIN_SERIAL_TX (11) -// LEDs -#define PIN_LED1 (12) -#define PIN_LED2 (13) -#define PIN_BUZZER (14) - -#define LED_BUILTIN PIN_LED1 -#define LED_CONN PIN_LED2 - -#define LED_RED PIN_LED1 -#define LED_BLUE PIN_LED2 - -#define LED_STATE_ON 1 // State when LED is litted - -/* - * Buttons - */ -#define PIN_BUTTON1 (15) -#define PIN_BUTTON2 (7) -#define PIN_BUTTON3 (8) - -// ADC pin and voltage divider -#define BATTERY_PIN 3 -#define ADC_MULTIPLIER 1.436 - -#define SX126X_DIO2_AS_RF_SWITCH -#define SX126X_DIO3_TCXO_VOLTAGE 1.8 // Not really an E22 but this board clones using DIO3 for tcxo control - -#endif From f37276d5fcde65478194be334c1a0a7c05bd6978 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:32:21 -0500 Subject: [PATCH 02/45] [create-pull-request] automated change (#4736) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> --- protobufs | 2 +- src/mesh/generated/meshtastic/atak.pb.h | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/protobufs b/protobufs index 0acaec6ef..0c0d061ec 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 0acaec6eff00e748beeae89148093221f131cd9c +Subproject commit 0c0d061ec58dec08b80334fd007ecb6c82cd8ed9 diff --git a/src/mesh/generated/meshtastic/atak.pb.h b/src/mesh/generated/meshtastic/atak.pb.h index 5fd18f963..50b57cd04 100644 --- a/src/mesh/generated/meshtastic/atak.pb.h +++ b/src/mesh/generated/meshtastic/atak.pb.h @@ -120,6 +120,7 @@ typedef struct _meshtastic_PLI { uint16_t course; } meshtastic_PLI; +typedef PB_BYTES_ARRAY_T(220) meshtastic_TAKPacket_detail_t; /* Packets for the official ATAK Plugin */ typedef struct _meshtastic_TAKPacket { /* Are the payloads strings compressed for LoRA transport? */ @@ -139,6 +140,9 @@ typedef struct _meshtastic_TAKPacket { meshtastic_PLI pli; /* ATAK GeoChat message */ meshtastic_GeoChat chat; + /* Generic CoT detail XML + May be compressed / truncated by the sender */ + meshtastic_TAKPacket_detail_t detail; } payload_variant; } meshtastic_TAKPacket; @@ -199,6 +203,7 @@ extern "C" { #define meshtastic_TAKPacket_status_tag 4 #define meshtastic_TAKPacket_pli_tag 5 #define meshtastic_TAKPacket_chat_tag 6 +#define meshtastic_TAKPacket_detail_tag 7 /* Struct field encoding specification for nanopb */ #define meshtastic_TAKPacket_FIELDLIST(X, a) \ @@ -207,7 +212,8 @@ X(a, STATIC, OPTIONAL, MESSAGE, contact, 2) \ X(a, STATIC, OPTIONAL, MESSAGE, group, 3) \ X(a, STATIC, OPTIONAL, MESSAGE, status, 4) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,pli,payload_variant.pli), 5) \ -X(a, STATIC, ONEOF, MESSAGE, (payload_variant,chat,payload_variant.chat), 6) +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,chat,payload_variant.chat), 6) \ +X(a, STATIC, ONEOF, BYTES, (payload_variant,detail,payload_variant.detail), 7) #define meshtastic_TAKPacket_CALLBACK NULL #define meshtastic_TAKPacket_DEFAULT NULL #define meshtastic_TAKPacket_contact_MSGTYPE meshtastic_Contact From b3343303a9b77ce973bd253e138f21e7051e985e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 16 Sep 2024 21:36:54 +0200 Subject: [PATCH 03/45] write firmware version and hardware platform to Flash memory --- src/platform/esp32/main-esp32.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp index 1b997500a..0b6f7cf23 100644 --- a/src/platform/esp32/main-esp32.cpp +++ b/src/platform/esp32/main-esp32.cpp @@ -120,17 +120,24 @@ void esp32Setup() uint32_t rebootCounter = preferences.getUInt("rebootCounter", 0); rebootCounter++; preferences.putUInt("rebootCounter", rebootCounter); + // store firmware version and hwrevision for access from OTA firmware + String fwrev = preferences.getString("firmwareVersion", ""); + if (fwrev.compareTo(optstr(APP_VERSION)) != 0) + preferences.putString("firmwareVersion", optstr(APP_VERSION)); + uint8_t hwven = preferences.getUInt("hwVendor", 0); + if (hwven != HW_VENDOR) + preferences.putUInt("hwVendor", HW_VENDOR); preferences.end(); LOG_DEBUG("Number of Device Reboots: %d\n", rebootCounter); #if !MESHTASTIC_EXCLUDE_BLUETOOTH String BLEOTA = BleOta::getOtaAppVersion(); if (BLEOTA.isEmpty()) { - LOG_DEBUG("No OTA firmware available\n"); + LOG_INFO("No OTA firmware available\n"); } else { - LOG_DEBUG("OTA firmware version %s\n", BLEOTA.c_str()); + LOG_INFO("OTA firmware version %s\n", BLEOTA.c_str()); } #else - LOG_DEBUG("No OTA firmware available\n"); + LOG_INFO("No OTA firmware available\n"); #endif // enableModemSleep(); From 1e665d5181e68be033790ec400327e0a27c855b5 Mon Sep 17 00:00:00 2001 From: jhps Date: Mon, 16 Sep 2024 17:11:55 -0700 Subject: [PATCH 04/45] Update T114 LED definitions to include only one simple controllable LED and two NEOPIXELS. (#4710) --- variants/heltec_mesh_node_t114/variant.cpp | 8 +------- variants/heltec_mesh_node_t114/variant.h | 23 ++++++++++------------ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/variants/heltec_mesh_node_t114/variant.cpp b/variants/heltec_mesh_node_t114/variant.cpp index cae079b74..85c9f4a72 100644 --- a/variants/heltec_mesh_node_t114/variant.cpp +++ b/variants/heltec_mesh_node_t114/variant.cpp @@ -32,13 +32,7 @@ const uint32_t g_ADigitalPinMap[] = { void initVariant() { - // LED1 & LED2 + // LED1 pinMode(PIN_LED1, OUTPUT); ledOff(PIN_LED1); - - pinMode(PIN_LED2, OUTPUT); - ledOff(PIN_LED2); - - pinMode(PIN_LED3, OUTPUT); - ledOff(PIN_LED3); } diff --git a/variants/heltec_mesh_node_t114/variant.h b/variants/heltec_mesh_node_t114/variant.h index e8c305990..454e66931 100644 --- a/variants/heltec_mesh_node_t114/variant.h +++ b/variants/heltec_mesh_node_t114/variant.h @@ -67,20 +67,17 @@ extern "C" { #define NUM_ANALOG_OUTPUTS (0) // LEDs -#define PIN_LED1 (32 + 3) // 13 red (confirmed on 1.0 board) -// Unused(by firmware) LEDs: -#define PIN_LED2 (1 + 1) // 14 blue -#define PIN_LED3 (1 + 11) // 15 green - -#define LED_RED PIN_LED3 -#define LED_BLUE PIN_LED1 -#define LED_GREEN PIN_LED2 - -#define LED_BUILTIN LED_BLUE -#define LED_CONN PIN_GREEN - +#define PIN_LED1 (32 + 3) // green (confirmed on 1.0 board) +#define LED_BLUE PIN_LED1 // fake for bluefruit library +#define LED_GREEN PIN_LED1 +#define LED_BUILTIN LED_GREEN #define LED_STATE_ON 0 // State when LED is lit +#define HAS_NEOPIXEL // Enable the use of neopixels +#define NEOPIXEL_COUNT 2 // How many neopixels are connected +#define NEOPIXEL_DATA 14 // gpio pin used to send data to the neopixels +#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use + /* * Buttons */ @@ -206,4 +203,4 @@ No longer populated on PCB * Arduino objects - C++ only *----------------------------------------------------------------------------*/ -#endif \ No newline at end of file +#endif From 97fd189f43bbdc9b9467dcb161990960084c9960 Mon Sep 17 00:00:00 2001 From: Szetya Date: Thu, 12 Sep 2024 18:15:31 +0200 Subject: [PATCH 05/45] Compass update https://github.com/meshtastic/firmware/issues/4494 New compass arrow and replacement of the north marker with a small circle. --- src/graphics/Screen.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index ff1254812..6cf9e8f03 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -1285,8 +1285,8 @@ static int8_t prevFrame = -1; // Draw the arrow pointing to a node's location void Screen::drawNodeHeading(OLEDDisplay *display, int16_t compassX, int16_t compassY, uint16_t compassDiam, float headingRadian) { - Point tip(0.0f, 0.5f), tail(0.0f, -0.5f); // pointing up initially - float arrowOffsetX = 0.2f, arrowOffsetY = 0.2f; + Point tip(0.0f, 0.5f), tail(0.0f, -0.35f); // pointing up initially + float arrowOffsetX = 0.14f, arrowOffsetY = 1.0f; Point leftArrow(tip.x - arrowOffsetX, tip.y - arrowOffsetY), rightArrow(tip.x + arrowOffsetX, tip.y - arrowOffsetY); Point *arrowPoints[] = {&tip, &tail, &leftArrow, &rightArrow}; @@ -1296,9 +1296,15 @@ void Screen::drawNodeHeading(OLEDDisplay *display, int16_t compassX, int16_t com arrowPoints[i]->scale(compassDiam * 0.6); arrowPoints[i]->translate(compassX, compassY); } + /* Old arrow display->drawLine(tip.x, tip.y, tail.x, tail.y); display->drawLine(leftArrow.x, leftArrow.y, tip.x, tip.y); display->drawLine(rightArrow.x, rightArrow.y, tip.x, tip.y); + display->drawLine(leftArrow.x, leftArrow.y, tail.x, tail.y); + display->drawLine(rightArrow.x, rightArrow.y, tail.x, tail.y); + */ + display->fillTriangle(tip.x, tip.y, rightArrow.x, rightArrow.y, tail.x, tail.y); + display->drawTriangle(tip.x, tip.y, leftArrow.x, leftArrow.y, tail.x, tail.y); } // Get a string representation of the time passed since something happened @@ -1336,22 +1342,27 @@ void Screen::drawCompassNorth(OLEDDisplay *display, int16_t compassX, int16_t co // If north is supposed to be at the top of the compass we want rotation to be +0 if (config.display.compass_north_top) myHeading = -0; - - Point N1(-0.04f, 0.65f), N2(0.04f, 0.65f); + /* N sign points currently not deleted*/ + Point N1(-0.04f, 0.65f), N2(0.04f, 0.65f); //N sign points (N1-N4) Point N3(-0.04f, 0.55f), N4(0.04f, 0.55f); - Point *rosePoints[] = {&N1, &N2, &N3, &N4}; + Point NC1(0.00f, 0.50f); //north circle center point + Point *rosePoints[] = {&N1, &N2, &N3, &N4, &NC1}; uint16_t compassDiam = Screen::getCompassDiam(SCREEN_WIDTH, SCREEN_HEIGHT); - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 5; i++) { // North on compass will be negative of heading rosePoints[i]->rotate(-myHeading); rosePoints[i]->scale(compassDiam); rosePoints[i]->translate(compassX, compassY); } + + /* changed the N sign to a small circle on the compass circle. display->drawLine(N1.x, N1.y, N3.x, N3.y); display->drawLine(N2.x, N2.y, N4.x, N4.y); display->drawLine(N1.x, N1.y, N4.x, N4.y); + */ + display->drawCircle(NC1.x, NC1.y, 4); // North sign circle, 4px radius is sufficient for all displays. } uint16_t Screen::getCompassDiam(uint32_t displayWidth, uint32_t displayHeight) @@ -2756,4 +2767,4 @@ int Screen::handleAdminMessage(const meshtastic_AdminMessage *arg) } // namespace graphics #else graphics::Screen::Screen(ScanI2C::DeviceAddress, meshtastic_Config_DisplayConfig_OledType, OLEDDISPLAY_GEOMETRY) {} -#endif // HAS_SCREEN \ No newline at end of file +#endif // HAS_SCREEN From 33e6f7f6e03950ed3ae0219cf27a6f231cff5f2d Mon Sep 17 00:00:00 2001 From: Todd Herbert Date: Sat, 14 Sep 2024 21:29:46 +1200 Subject: [PATCH 06/45] Hollow triangle for E-Ink; trunk formatting --- src/graphics/Screen.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 6cf9e8f03..ae09ee408 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -1303,7 +1303,11 @@ void Screen::drawNodeHeading(OLEDDisplay *display, int16_t compassX, int16_t com display->drawLine(leftArrow.x, leftArrow.y, tail.x, tail.y); display->drawLine(rightArrow.x, rightArrow.y, tail.x, tail.y); */ +#ifdef USE_EINK + display->drawTriangle(tip.x, tip.y, rightArrow.x, rightArrow.y, tail.x, tail.y); +#else display->fillTriangle(tip.x, tip.y, rightArrow.x, rightArrow.y, tail.x, tail.y); +#endif display->drawTriangle(tip.x, tip.y, leftArrow.x, leftArrow.y, tail.x, tail.y); } @@ -1343,9 +1347,9 @@ void Screen::drawCompassNorth(OLEDDisplay *display, int16_t compassX, int16_t co if (config.display.compass_north_top) myHeading = -0; /* N sign points currently not deleted*/ - Point N1(-0.04f, 0.65f), N2(0.04f, 0.65f); //N sign points (N1-N4) + Point N1(-0.04f, 0.65f), N2(0.04f, 0.65f); // N sign points (N1-N4) Point N3(-0.04f, 0.55f), N4(0.04f, 0.55f); - Point NC1(0.00f, 0.50f); //north circle center point + Point NC1(0.00f, 0.50f); // north circle center point Point *rosePoints[] = {&N1, &N2, &N3, &N4, &NC1}; uint16_t compassDiam = Screen::getCompassDiam(SCREEN_WIDTH, SCREEN_HEIGHT); @@ -1356,13 +1360,13 @@ void Screen::drawCompassNorth(OLEDDisplay *display, int16_t compassX, int16_t co rosePoints[i]->scale(compassDiam); rosePoints[i]->translate(compassX, compassY); } - + /* changed the N sign to a small circle on the compass circle. display->drawLine(N1.x, N1.y, N3.x, N3.y); display->drawLine(N2.x, N2.y, N4.x, N4.y); display->drawLine(N1.x, N1.y, N4.x, N4.y); */ - display->drawCircle(NC1.x, NC1.y, 4); // North sign circle, 4px radius is sufficient for all displays. + display->drawCircle(NC1.x, NC1.y, 4); // North sign circle, 4px radius is sufficient for all displays. } uint16_t Screen::getCompassDiam(uint32_t displayWidth, uint32_t displayHeight) From 39c90dd581cbc742e2d55dc69936ab688471257d Mon Sep 17 00:00:00 2001 From: jp-bennett <5630967+jp-bennett@users.noreply.github.com> Date: Tue, 17 Sep 2024 02:53:44 +0000 Subject: [PATCH 07/45] [create-pull-request] automated change --- protobufs | 2 +- src/mesh/generated/meshtastic/config.pb.h | 8 ++++---- src/mesh/generated/meshtastic/deviceonly.pb.h | 2 +- src/mesh/generated/meshtastic/localonly.pb.h | 4 ++-- src/mesh/generated/meshtastic/mesh.pb.h | 10 +++++++--- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/protobufs b/protobufs index 0c0d061ec..c5108cfd6 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 0c0d061ec58dec08b80334fd007ecb6c82cd8ed9 +Subproject commit c5108cfd6bbc59adef44575dcec3067cbfbfeac1 diff --git a/src/mesh/generated/meshtastic/config.pb.h b/src/mesh/generated/meshtastic/config.pb.h index 66ffa0a4b..da2e43972 100644 --- a/src/mesh/generated/meshtastic/config.pb.h +++ b/src/mesh/generated/meshtastic/config.pb.h @@ -535,7 +535,7 @@ typedef struct _meshtastic_Config_SecurityConfig { meshtastic_Config_SecurityConfig_private_key_t private_key; /* The public key authorized to send admin messages to this node. */ pb_size_t admin_key_count; - meshtastic_Config_SecurityConfig_admin_key_t admin_key[1]; + meshtastic_Config_SecurityConfig_admin_key_t admin_key[3]; /* If true, device is considered to be "managed" by a mesh administrator via admin messages Device is managed by a mesh administrator. */ bool is_managed; @@ -660,7 +660,7 @@ extern "C" { #define meshtastic_Config_DisplayConfig_init_default {0, _meshtastic_Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _meshtastic_Config_DisplayConfig_DisplayUnits_MIN, _meshtastic_Config_DisplayConfig_OledType_MIN, _meshtastic_Config_DisplayConfig_DisplayMode_MIN, 0, 0, _meshtastic_Config_DisplayConfig_CompassOrientation_MIN} #define meshtastic_Config_LoRaConfig_init_default {0, _meshtastic_Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _meshtastic_Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0} #define meshtastic_Config_BluetoothConfig_init_default {0, _meshtastic_Config_BluetoothConfig_PairingMode_MIN, 0} -#define meshtastic_Config_SecurityConfig_init_default {{0, {0}}, {0, {0}}, 0, {{0, {0}}}, 0, 0, 0, 0} +#define meshtastic_Config_SecurityConfig_init_default {{0, {0}}, {0, {0}}, 0, {{0, {0}}, {0, {0}}, {0, {0}}}, 0, 0, 0, 0} #define meshtastic_Config_SessionkeyConfig_init_default {0} #define meshtastic_Config_init_zero {0, {meshtastic_Config_DeviceConfig_init_zero}} #define meshtastic_Config_DeviceConfig_init_zero {_meshtastic_Config_DeviceConfig_Role_MIN, 0, 0, 0, _meshtastic_Config_DeviceConfig_RebroadcastMode_MIN, 0, 0, 0, 0, "", 0} @@ -671,7 +671,7 @@ extern "C" { #define meshtastic_Config_DisplayConfig_init_zero {0, _meshtastic_Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _meshtastic_Config_DisplayConfig_DisplayUnits_MIN, _meshtastic_Config_DisplayConfig_OledType_MIN, _meshtastic_Config_DisplayConfig_DisplayMode_MIN, 0, 0, _meshtastic_Config_DisplayConfig_CompassOrientation_MIN} #define meshtastic_Config_LoRaConfig_init_zero {0, _meshtastic_Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _meshtastic_Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0} #define meshtastic_Config_BluetoothConfig_init_zero {0, _meshtastic_Config_BluetoothConfig_PairingMode_MIN, 0} -#define meshtastic_Config_SecurityConfig_init_zero {{0, {0}}, {0, {0}}, 0, {{0, {0}}}, 0, 0, 0, 0} +#define meshtastic_Config_SecurityConfig_init_zero {{0, {0}}, {0, {0}}, 0, {{0, {0}}, {0, {0}}, {0, {0}}}, 0, 0, 0, 0} #define meshtastic_Config_SessionkeyConfig_init_zero {0} /* Field tags (for use in manual encoding/decoding) */ @@ -953,7 +953,7 @@ extern const pb_msgdesc_t meshtastic_Config_SessionkeyConfig_msg; #define meshtastic_Config_NetworkConfig_size 196 #define meshtastic_Config_PositionConfig_size 62 #define meshtastic_Config_PowerConfig_size 52 -#define meshtastic_Config_SecurityConfig_size 111 +#define meshtastic_Config_SecurityConfig_size 178 #define meshtastic_Config_SessionkeyConfig_size 0 #define meshtastic_Config_size 199 diff --git a/src/mesh/generated/meshtastic/deviceonly.pb.h b/src/mesh/generated/meshtastic/deviceonly.pb.h index 209084220..f87c84abe 100644 --- a/src/mesh/generated/meshtastic/deviceonly.pb.h +++ b/src/mesh/generated/meshtastic/deviceonly.pb.h @@ -358,7 +358,7 @@ extern const pb_msgdesc_t meshtastic_OEMStore_msg; #define MESHTASTIC_MESHTASTIC_DEVICEONLY_PB_H_MAX_SIZE meshtastic_OEMStore_size #define meshtastic_ChannelFile_size 718 #define meshtastic_NodeInfoLite_size 183 -#define meshtastic_OEMStore_size 3500 +#define meshtastic_OEMStore_size 3568 #define meshtastic_PositionLite_size 28 #define meshtastic_UserLite_size 96 diff --git a/src/mesh/generated/meshtastic/localonly.pb.h b/src/mesh/generated/meshtastic/localonly.pb.h index 72f29500c..19600856f 100644 --- a/src/mesh/generated/meshtastic/localonly.pb.h +++ b/src/mesh/generated/meshtastic/localonly.pb.h @@ -186,8 +186,8 @@ extern const pb_msgdesc_t meshtastic_LocalModuleConfig_msg; #define meshtastic_LocalModuleConfig_fields &meshtastic_LocalModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define MESHTASTIC_MESHTASTIC_LOCALONLY_PB_H_MAX_SIZE meshtastic_LocalModuleConfig_size -#define meshtastic_LocalConfig_size 667 +#define MESHTASTIC_MESHTASTIC_LOCALONLY_PB_H_MAX_SIZE meshtastic_LocalConfig_size +#define meshtastic_LocalConfig_size 735 #define meshtastic_LocalModuleConfig_size 687 #ifdef __cplusplus diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index 948e89f22..f4e0a896b 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -316,7 +316,11 @@ typedef enum _meshtastic_Routing_Error { /* The client specified a PKI transport, but the node was unable to send the packet using PKI (and did not send the message at all) */ meshtastic_Routing_Error_PKI_FAILED = 34, /* The receiving node does not have a Public Key to decode with */ - meshtastic_Routing_Error_PKI_UNKNOWN_PUBKEY = 35 + meshtastic_Routing_Error_PKI_UNKNOWN_PUBKEY = 35, + /* Admin packet otherwise checks out, but uses a bogus or expired session key */ + meshtastic_Routing_Error_ADMIN_BAD_SESSION_KEY = 36, + /* Admin packet sent using PKC, but not from a public key on the admin key list */ + meshtastic_Routing_Error_ADMIN_PUBLIC_KEY_UNAUTHORIZED = 37 } meshtastic_Routing_Error; /* The priority of this message for sending. @@ -1026,8 +1030,8 @@ extern "C" { #define _meshtastic_Position_AltSource_ARRAYSIZE ((meshtastic_Position_AltSource)(meshtastic_Position_AltSource_ALT_BAROMETRIC+1)) #define _meshtastic_Routing_Error_MIN meshtastic_Routing_Error_NONE -#define _meshtastic_Routing_Error_MAX meshtastic_Routing_Error_PKI_UNKNOWN_PUBKEY -#define _meshtastic_Routing_Error_ARRAYSIZE ((meshtastic_Routing_Error)(meshtastic_Routing_Error_PKI_UNKNOWN_PUBKEY+1)) +#define _meshtastic_Routing_Error_MAX meshtastic_Routing_Error_ADMIN_PUBLIC_KEY_UNAUTHORIZED +#define _meshtastic_Routing_Error_ARRAYSIZE ((meshtastic_Routing_Error)(meshtastic_Routing_Error_ADMIN_PUBLIC_KEY_UNAUTHORIZED+1)) #define _meshtastic_MeshPacket_Priority_MIN meshtastic_MeshPacket_Priority_UNSET #define _meshtastic_MeshPacket_Priority_MAX meshtastic_MeshPacket_Priority_MAX From 6f1db6fc630a69ee506abc5b0c462488e450850d Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Tue, 17 Sep 2024 08:37:12 +0800 Subject: [PATCH 08/45] Fix I2C address for QMC5883L. QMC5883L and HMC5883L are 3-axis compasses which are often confused. As reported by @Africmod, we had the wrong I2C address for the QMC5883L. This patch fixes the address and adds its HMC5883L so we keep info about both. Fixes https://github.com/meshtastic/firmware/issues/4144 --- src/configuration.h | 5 +++-- src/detect/ScanI2C.h | 3 ++- src/detect/ScanI2CTwoWire.cpp | 1 + src/main.cpp | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/configuration.h b/src/configuration.h index 72420cc59..349bd2870 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -124,7 +124,8 @@ along with this program. If not, see . #define INA3221_ADDR 0x42 #define QMC6310_ADDR 0x1C #define QMI8658_ADDR 0x6B -#define QMC5883L_ADDR 0x1E +#define QMC5883L_ADDR 0x0D +#define HMC5883L_ADDR 0x1E #define SHTC3_ADDR 0x70 #define LPS22HB_ADDR 0x5C #define LPS22HB_ADDR_ALT 0x5D @@ -331,4 +332,4 @@ along with this program. If not, see . #endif #include "DebugConfiguration.h" -#include "RF95Configuration.h" \ No newline at end of file +#include "RF95Configuration.h" diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index 743de7a9a..090b1a968 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -36,6 +36,7 @@ class ScanI2C QMC6310, QMI8658, QMC5883L, + HMC5883L, PMSA0031, MPU6050, LIS3DH, @@ -118,4 +119,4 @@ class ScanI2C private: bool shouldSuppressScreen = false; -}; \ No newline at end of file +}; diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp index 48341034b..f09eb3b95 100644 --- a/src/detect/ScanI2CTwoWire.cpp +++ b/src/detect/ScanI2CTwoWire.cpp @@ -382,6 +382,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize) break; SCAN_SIMPLE_CASE(QMC5883L_ADDR, QMC5883L, "QMC5883L Highrate 3-Axis magnetic sensor found\n") + SCAN_SIMPLE_CASE(HMC5883L_ADDR, HMC5883L, "HMC5883L 3-Axis digital compass found\n") SCAN_SIMPLE_CASE(PMSA0031_ADDR, PMSA0031, "PMSA0031 air quality sensor found\n") SCAN_SIMPLE_CASE(MPU6050_ADDR, MPU6050, "MPU6050 accelerometer found\n"); diff --git a/src/main.cpp b/src/main.cpp index df90c4722..2c8c0dcb8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -560,6 +560,7 @@ void setup() SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::QMC6310, meshtastic_TelemetrySensorType_QMC6310) SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::QMI8658, meshtastic_TelemetrySensorType_QMI8658) SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::QMC5883L, meshtastic_TelemetrySensorType_QMC5883L) + SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::HMC5883L, meshtastic_TelemetrySensorType_QMC5883L) SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::PMSA0031, meshtastic_TelemetrySensorType_PMSA003I) SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::RCWL9620, meshtastic_TelemetrySensorType_RCWL9620) SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::VEML7700, meshtastic_TelemetrySensorType_VEML7700) @@ -1144,4 +1145,4 @@ void loop() } // if (didWake) LOG_DEBUG("wake!\n"); } -#endif \ No newline at end of file +#endif From b025eeb13cb299cfc9caa109cec29673929ddd6d Mon Sep 17 00:00:00 2001 From: S5NC <145265251+S5NC@users.noreply.github.com> Date: Thu, 12 Sep 2024 19:11:57 +0100 Subject: [PATCH 09/45] Update variant.h --- variants/rak11200/variant.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/variants/rak11200/variant.h b/variants/rak11200/variant.h index 259fa6e87..01edb8b73 100644 --- a/variants/rak11200/variant.h +++ b/variants/rak11200/variant.h @@ -70,12 +70,12 @@ static const uint8_t SCK = 33; #define LORA_CS SS #define USE_SX1262 -#define SX126X_ANT_SW WB_IO2 +#define SX126X_ANT_SW WB_IO3 #define SX126X_CS SS // NSS for SX126X #define SX126X_DIO1 LORA_DIO1 #define SX126X_BUSY LORA_DIO2 #define SX126X_RESET LORA_RESET -#define SX126X_POWER_EN WB_IO3 +#define SX126X_POWER_EN WB_IO2 // DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3 #define SX126X_DIO2_AS_RF_SWITCH #define SX126X_DIO3_TCXO_VOLTAGE 1.8 From cd6bd1e9a33c831c6220f997819ae78b2c9f1e21 Mon Sep 17 00:00:00 2001 From: S5NC <145265251+S5NC@users.noreply.github.com> Date: Thu, 12 Sep 2024 19:24:31 +0100 Subject: [PATCH 10/45] Update main.cpp --- src/main.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 2c8c0dcb8..b6cfd91aa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -764,10 +764,11 @@ void setup() screen->print("Started...\n"); -#ifdef SX126X_ANT_SW - // make analog PA vs not PA switch on SX126x eval board work properly +// FIXME: move to SX126XInterface.cpp +// Typically, the RF switch on SX126x boards is controlled by two signals, which are negations of each other (switched RFIO paths). The negation is usually dealt in hardware, or (suboptimal design) TXEN and RXEN are the two inputs to the RF switch. On some boards, there is no hardware negation between CTRL and ¬CTRL, but CTRL is internally connected to DIO2, and DIO2's switching is done by the SX126X itself. One solution would be to set that pin as SX126X_TXEN or SX126X_RXEN, but they may already be used for another purpose, such as controlling another PA/LNA. Keeping ¬CTRL high seems to work, as long CTRL=1, ¬CTRL=0 has the opposite and stable RF path effect as CTRL=1 and ¬CTRL=1, this depends on the RF switch, but for the cases where this works, this pin can be used. Better hardware design, which is done most the time, prevents this issue. +#ifdef SX126X_ANT_SW // Add RADIOLIB_NC check, and beforehand define as such if it is undefined. + digitalWrite(SX126X_ANT_SW, HIGH); pinMode(SX126X_ANT_SW, OUTPUT); - digitalWrite(SX126X_ANT_SW, 1); #endif #ifdef PIN_PWR_DELAY_MS From af3048561185a3450e044ff00467fe4e9917703e Mon Sep 17 00:00:00 2001 From: S5NC <145265251+S5NC@users.noreply.github.com> Date: Thu, 12 Sep 2024 19:27:45 +0100 Subject: [PATCH 11/45] Update main.cpp --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index b6cfd91aa..f88fa890e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -765,7 +765,7 @@ void setup() screen->print("Started...\n"); // FIXME: move to SX126XInterface.cpp -// Typically, the RF switch on SX126x boards is controlled by two signals, which are negations of each other (switched RFIO paths). The negation is usually dealt in hardware, or (suboptimal design) TXEN and RXEN are the two inputs to the RF switch. On some boards, there is no hardware negation between CTRL and ¬CTRL, but CTRL is internally connected to DIO2, and DIO2's switching is done by the SX126X itself. One solution would be to set that pin as SX126X_TXEN or SX126X_RXEN, but they may already be used for another purpose, such as controlling another PA/LNA. Keeping ¬CTRL high seems to work, as long CTRL=1, ¬CTRL=0 has the opposite and stable RF path effect as CTRL=1 and ¬CTRL=1, this depends on the RF switch, but for the cases where this works, this pin can be used. Better hardware design, which is done most the time, prevents this issue. +// Typically, the RF switch on SX126x boards is controlled by two signals, which are negations of each other (switched RFIO paths). The negation is usually performed in hardware, or (suboptimal design) TXEN and RXEN are the two inputs to this style of RF switch. On some boards, there is no hardware negation between CTRL and ¬CTRL, but CTRL is internally connected to DIO2, and DIO2's switching is done by the SX126X itself, so the MCU can't control ¬CTRL at exactly the same time. One solution would be to set ¬CTRL as SX126X_TXEN or SX126X_RXEN, but they may already be used for another purpose, such as controlling another PA/LNA. Keeping ¬CTRL high seems to work, as long CTRL=1, ¬CTRL=1 has the opposite and stable RF path effect as CTRL=0 and ¬CTRL=1, this depends on the RF switch, but it seems this usually works. Better hardware design, which is done most the time, means this workaround is not necessary. #ifdef SX126X_ANT_SW // Add RADIOLIB_NC check, and beforehand define as such if it is undefined. digitalWrite(SX126X_ANT_SW, HIGH); pinMode(SX126X_ANT_SW, OUTPUT); From 06cd9abd810781b991d17823ea7bb75a895d8570 Mon Sep 17 00:00:00 2001 From: S5NC <145265251+S5NC@users.noreply.github.com> Date: Thu, 12 Sep 2024 19:36:10 +0100 Subject: [PATCH 12/45] Update SX126xInterface.cpp --- src/mesh/SX126xInterface.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mesh/SX126xInterface.cpp b/src/mesh/SX126xInterface.cpp index fcb3e4edb..6f9a455b7 100644 --- a/src/mesh/SX126xInterface.cpp +++ b/src/mesh/SX126xInterface.cpp @@ -25,9 +25,16 @@ SX126xInterface::SX126xInterface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs /// \return true if initialisation succeeded. template bool SX126xInterface::init() { -#ifdef SX126X_POWER_EN - pinMode(SX126X_POWER_EN, OUTPUT); + +// Typically, the RF switch on SX126x boards is controlled by two signals, which are negations of each other (switched RFIO paths). The negation is usually performed in hardware, or (suboptimal design) TXEN and RXEN are the two inputs to this style of RF switch. On some boards, there is no hardware negation between CTRL and ¬CTRL, but CTRL is internally connected to DIO2, and DIO2's switching is done by the SX126X itself, so the MCU can't control ¬CTRL at exactly the same time. One solution would be to set ¬CTRL as SX126X_TXEN or SX126X_RXEN, but they may already be used for another purpose, such as controlling another PA/LNA. Keeping ¬CTRL high seems to work, as long CTRL=1, ¬CTRL=1 has the opposite and stable RF path effect as CTRL=0 and ¬CTRL=1, this depends on the RF switch, but it seems this usually works. Better hardware design, which is done most the time, means this workaround is not necessary. +#ifdef SX126X_ANT_SW // Perhaps add RADIOLIB_NC check, and beforehand define as such if it is undefined, but it is not commonly used and not part of the 'default' set of pin definitions. + digitalWrite(SX126X_ANT_SW, HIGH); + pinMode(SX126X_ANT_SW, OUTPUT); +#endif + +#ifdef SX126X_POWER_EN // Perhaps add RADIOLIB_NC check, and beforehand define as such if it is undefined, but it is not commonly used and not part of the 'default' set of pin definitions. digitalWrite(SX126X_POWER_EN, HIGH); + pinMode(SX126X_POWER_EN, OUTPUT); #endif #if ARCH_PORTDUINO From 34a543ec74967d6848ee7fb1fa73b4213845826e Mon Sep 17 00:00:00 2001 From: S5NC <145265251+S5NC@users.noreply.github.com> Date: Thu, 12 Sep 2024 19:36:52 +0100 Subject: [PATCH 13/45] Update main.cpp --- src/main.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f88fa890e..86268ecac 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -764,13 +764,6 @@ void setup() screen->print("Started...\n"); -// FIXME: move to SX126XInterface.cpp -// Typically, the RF switch on SX126x boards is controlled by two signals, which are negations of each other (switched RFIO paths). The negation is usually performed in hardware, or (suboptimal design) TXEN and RXEN are the two inputs to this style of RF switch. On some boards, there is no hardware negation between CTRL and ¬CTRL, but CTRL is internally connected to DIO2, and DIO2's switching is done by the SX126X itself, so the MCU can't control ¬CTRL at exactly the same time. One solution would be to set ¬CTRL as SX126X_TXEN or SX126X_RXEN, but they may already be used for another purpose, such as controlling another PA/LNA. Keeping ¬CTRL high seems to work, as long CTRL=1, ¬CTRL=1 has the opposite and stable RF path effect as CTRL=0 and ¬CTRL=1, this depends on the RF switch, but it seems this usually works. Better hardware design, which is done most the time, means this workaround is not necessary. -#ifdef SX126X_ANT_SW // Add RADIOLIB_NC check, and beforehand define as such if it is undefined. - digitalWrite(SX126X_ANT_SW, HIGH); - pinMode(SX126X_ANT_SW, OUTPUT); -#endif - #ifdef PIN_PWR_DELAY_MS // This may be required to give the peripherals time to power up. delay(PIN_PWR_DELAY_MS); From bc753e69032c022288d57019f3bf7151bb69afe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 12 Sep 2024 20:50:07 +0200 Subject: [PATCH 14/45] trunk fmt --- src/mesh/SX126xInterface.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/mesh/SX126xInterface.cpp b/src/mesh/SX126xInterface.cpp index 6f9a455b7..6d23206bd 100644 --- a/src/mesh/SX126xInterface.cpp +++ b/src/mesh/SX126xInterface.cpp @@ -26,13 +26,22 @@ SX126xInterface::SX126xInterface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs template bool SX126xInterface::init() { -// Typically, the RF switch on SX126x boards is controlled by two signals, which are negations of each other (switched RFIO paths). The negation is usually performed in hardware, or (suboptimal design) TXEN and RXEN are the two inputs to this style of RF switch. On some boards, there is no hardware negation between CTRL and ¬CTRL, but CTRL is internally connected to DIO2, and DIO2's switching is done by the SX126X itself, so the MCU can't control ¬CTRL at exactly the same time. One solution would be to set ¬CTRL as SX126X_TXEN or SX126X_RXEN, but they may already be used for another purpose, such as controlling another PA/LNA. Keeping ¬CTRL high seems to work, as long CTRL=1, ¬CTRL=1 has the opposite and stable RF path effect as CTRL=0 and ¬CTRL=1, this depends on the RF switch, but it seems this usually works. Better hardware design, which is done most the time, means this workaround is not necessary. -#ifdef SX126X_ANT_SW // Perhaps add RADIOLIB_NC check, and beforehand define as such if it is undefined, but it is not commonly used and not part of the 'default' set of pin definitions. +// Typically, the RF switch on SX126x boards is controlled by two signals, which are negations of each other (switched RFIO +// paths). The negation is usually performed in hardware, or (suboptimal design) TXEN and RXEN are the two inputs to this style of +// RF switch. On some boards, there is no hardware negation between CTRL and ¬CTRL, but CTRL is internally connected to DIO2, and +// DIO2's switching is done by the SX126X itself, so the MCU can't control ¬CTRL at exactly the same time. One solution would be +// to set ¬CTRL as SX126X_TXEN or SX126X_RXEN, but they may already be used for another purpose, such as controlling another +// PA/LNA. Keeping ¬CTRL high seems to work, as long CTRL=1, ¬CTRL=1 has the opposite and stable RF path effect as CTRL=0 and +// ¬CTRL=1, this depends on the RF switch, but it seems this usually works. Better hardware design, which is done most the time, +// means this workaround is not necessary. +#ifdef SX126X_ANT_SW // Perhaps add RADIOLIB_NC check, and beforehand define as such if it is undefined, but it is not commonly + // used and not part of the 'default' set of pin definitions. digitalWrite(SX126X_ANT_SW, HIGH); pinMode(SX126X_ANT_SW, OUTPUT); #endif - -#ifdef SX126X_POWER_EN // Perhaps add RADIOLIB_NC check, and beforehand define as such if it is undefined, but it is not commonly used and not part of the 'default' set of pin definitions. + +#ifdef SX126X_POWER_EN // Perhaps add RADIOLIB_NC check, and beforehand define as such if it is undefined, but it is not commonly + // used and not part of the 'default' set of pin definitions. digitalWrite(SX126X_POWER_EN, HIGH); pinMode(SX126X_POWER_EN, OUTPUT); #endif From 11378325e0d2c911d3bd35dbbfafbc6f818268e4 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 17 Sep 2024 06:29:18 -0500 Subject: [PATCH 15/45] Separate GPS and NTP RTCQuality logic and allow GPS time to always set us (#4721) --- src/gps/RTC.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gps/RTC.cpp b/src/gps/RTC.cpp index 42a98f568..728284242 100644 --- a/src/gps/RTC.cpp +++ b/src/gps/RTC.cpp @@ -124,8 +124,11 @@ bool perhapsSetRTC(RTCQuality q, const struct timeval *tv, bool forceUpdate) } else if (q > currentQuality) { shouldSet = true; LOG_DEBUG("Upgrading time to quality %s\n", RtcName(q)); - } else if (q >= RTCQualityNTP && (now - lastSetMsec) > (12 * 60 * 60 * 1000UL)) { - // Every 12 hrs we will slam in a new GPS or Phone GPS / NTP time, to correct for local RTC clock drift + } else if (q == RTCQualityGPS) { + shouldSet = true; + LOG_DEBUG("Reapplying GPS time: %ld secs\n", printableEpoch); + } else if (q == RTCQualityNTP && (now - lastSetMsec) > (12 * 60 * 60 * 1000UL)) { + // Every 12 hrs we will slam in a new NTP or Phone GPS / NTP time, to correct for local RTC clock drift shouldSet = true; LOG_DEBUG("Reapplying external time to correct clock drift %ld secs\n", printableEpoch); } else { From a967dd52f31a4ea00e79219dde18499fea803c76 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Tue, 17 Sep 2024 06:31:39 -0500 Subject: [PATCH 16/45] More useful PKC logging (#4742) --- src/mesh/CryptoEngine.cpp | 9 +++++---- src/mesh/Router.cpp | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/mesh/CryptoEngine.cpp b/src/mesh/CryptoEngine.cpp index a5322a65a..79666b321 100644 --- a/src/mesh/CryptoEngine.cpp +++ b/src/mesh/CryptoEngine.cpp @@ -84,7 +84,7 @@ bool CryptoEngine::encryptCurve25519(uint32_t toNode, uint32_t fromNode, uint64_ // Calculate the shared secret with the destination node and encrypt printBytes("Attempting encrypt using nonce: ", nonce, 13); - printBytes("Attempting encrypt using shared_key: ", shared_key, 32); + printBytes("Attempting encrypt using shared_key starting with: ", shared_key, 8); aes_ccm_ae(shared_key, 32, nonce, 8, bytes, numBytes, nullptr, 0, bytesOut, auth); // this can write up to 15 bytes longer than numbytes past bytesOut *extraNonce = extraNonceTmp; @@ -117,7 +117,7 @@ bool CryptoEngine::decryptCurve25519(uint32_t fromNode, uint64_t packetNum, size } initNonce(fromNode, packetNum, *extraNonce); printBytes("Attempting decrypt using nonce: ", nonce, 13); - printBytes("Attempting decrypt using shared_key: ", shared_key, 32); + printBytes("Attempting decrypt using shared_key starting with: ", shared_key, 8); return aes_ccm_ad(shared_key, 32, nonce, 8, bytes, numBytes - 12, nullptr, 0, auth, bytesOut); } @@ -137,11 +137,12 @@ bool CryptoEngine::setDHKey(uint32_t nodeNum) LOG_DEBUG("Node %d or their public_key not found\n", nodeNum); return false; } - + printBytes("Generating DH with remote pubkey: ", node->user.public_key.bytes, 32); + printBytes("And local pubkey: ", config.security.public_key.bytes, 32); if (!setDHPublicKey(node->user.public_key.bytes)) return false; - printBytes("DH Output: ", shared_key, 32); + // printBytes("DH Output: ", shared_key, 32); /** * D.J. Bernstein reccomends hashing the shared key. We want to do this because there are diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index deb4ef2bf..3cf30519b 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -347,8 +347,11 @@ bool perhapsDecode(meshtastic_MeshPacket *p) // memcpy(bytes, ScratchEncrypted, rawSize); // TODO: Rename the bytes buffers // chIndex = 8; } else { + LOG_ERROR("PKC Decrypted, but pb_decode failed!\n"); return false; } + } else { + LOG_WARN("PKC decrypt attempted but failed!\n"); } } #endif From be306cc3849d080bc2fb6549ee16c6b39e5ca94e Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Tue, 17 Sep 2024 19:48:56 +0800 Subject: [PATCH 17/45] Increase GPS FIFO Buffer Size for RP2040 (#4741) As discovered and tested by @Mictronics, default Serial FIFO size on the Pico is 32bytes, which is not enough for GPS messages. This patch increases the Serial GPS FIFO buffer size to 256 for the RP2040 Architecture fixes https://github.com/meshtastic/firmware/issues/3989 --- src/gps/GPS.cpp | 17 +++++++++++++++-- src/gps/GPS.h | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 8abb4edb1..01fa65816 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -26,6 +26,8 @@ #if defined(NRF52840_XXAA) || defined(NRF52833_XXAA) || defined(ARCH_ESP32) || defined(ARCH_PORTDUINO) HardwareSerial *GPS::_serial_gps = &Serial1; +#elif defined(ARCH_RP2040) +SerialUART *GPS::_serial_gps = &Serial1; #else HardwareSerial *GPS::_serial_gps = NULL; #endif @@ -1198,9 +1200,13 @@ int GPS::prepareDeepSleep(void *unused) GnssModel_t GPS::probe(int serialSpeed) { -#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_RP2040) || defined(ARCH_STM32WL) +#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_STM32WL) _serial_gps->end(); _serial_gps->begin(serialSpeed); +#elif defined(ARCH_RP2040) + _serial_gps->end(); + _serial_gps->setFIFOSize(256); + _serial_gps->begin(serialSpeed); #else if (_serial_gps->baudRate() != serialSpeed) { LOG_DEBUG("Setting Baud to %i\n", serialSpeed); @@ -1265,9 +1271,13 @@ GnssModel_t GPS::probe(int serialSpeed) _serial_gps->write(_message_prt, sizeof(_message_prt)); delay(500); serialSpeed = 9600; -#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_RP2040) || defined(ARCH_STM32WL) +#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_STM32WL) _serial_gps->end(); _serial_gps->begin(serialSpeed); +#elif defined(ARCH_RP2040) + _serial_gps->end(); + _serial_gps->setFIFOSize(256); + _serial_gps->begin(serialSpeed); #else _serial_gps->updateBaudRate(serialSpeed); #endif @@ -1428,6 +1438,9 @@ GPS *GPS::createGps() LOG_DEBUG("Using GPIO%d for GPS RX\n", new_gps->rx_gpio); LOG_DEBUG("Using GPIO%d for GPS TX\n", new_gps->tx_gpio); _serial_gps->begin(GPS_BAUDRATE, SERIAL_8N1, new_gps->rx_gpio, new_gps->tx_gpio); +#elif defined(ARCH_RP2040) + _serial_gps->setFIFOSize(256); + _serial_gps->begin(GPS_BAUDRATE); #else _serial_gps->begin(GPS_BAUDRATE); #endif diff --git a/src/gps/GPS.h b/src/gps/GPS.h index caff48f32..3423edb68 100644 --- a/src/gps/GPS.h +++ b/src/gps/GPS.h @@ -102,7 +102,7 @@ class GPS : private concurrency::OSThread public: /** If !NULL we will use this serial port to construct our GPS */ -#if defined(RPI_PICO_WAVESHARE) +#if defined(ARCH_RP2040) static SerialUART *_serial_gps; #else static HardwareSerial *_serial_gps; From db4dc88d6f1e624a03cf10e35233463a5620d60e Mon Sep 17 00:00:00 2001 From: Andre K Date: Tue, 17 Sep 2024 08:50:49 -0300 Subject: [PATCH 18/45] feat: enable remote admin to set/clear fixed positions (#4713) Co-authored-by: Ben Meadors --- src/modules/AdminModule.cpp | 38 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 4deb99eb7..7b96d9c43 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -257,34 +257,26 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta break; } case meshtastic_AdminMessage_set_fixed_position_tag: { - if (fromOthers) { - LOG_INFO("Ignoring set_fixed_position command from another node.\n"); - } else { - LOG_INFO("Client is receiving a set_fixed_position command.\n"); - meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeDB->getNodeNum()); - node->has_position = true; - node->position = TypeConversions::ConvertToPositionLite(r->set_fixed_position); - nodeDB->setLocalPosition(r->set_fixed_position); - config.position.fixed_position = true; - saveChanges(SEGMENT_DEVICESTATE | SEGMENT_CONFIG, false); + LOG_INFO("Client is receiving a set_fixed_position command.\n"); + meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeDB->getNodeNum()); + node->has_position = true; + node->position = TypeConversions::ConvertToPositionLite(r->set_fixed_position); + nodeDB->setLocalPosition(r->set_fixed_position); + config.position.fixed_position = true; + saveChanges(SEGMENT_DEVICESTATE | SEGMENT_CONFIG, false); #if !MESHTASTIC_EXCLUDE_GPS - if (gps != nullptr) - gps->enable(); - // Send our new fixed position to the mesh for good measure - positionModule->sendOurPosition(); + if (gps != nullptr) + gps->enable(); + // Send our new fixed position to the mesh for good measure + positionModule->sendOurPosition(); #endif - } break; } case meshtastic_AdminMessage_remove_fixed_position_tag: { - if (fromOthers) { - LOG_INFO("Ignoring remove_fixed_position command from another node.\n"); - } else { - LOG_INFO("Client is receiving a remove_fixed_position command.\n"); - nodeDB->clearLocalPosition(); - config.position.fixed_position = false; - saveChanges(SEGMENT_DEVICESTATE | SEGMENT_CONFIG, false); - } + LOG_INFO("Client is receiving a remove_fixed_position command.\n"); + nodeDB->clearLocalPosition(); + config.position.fixed_position = false; + saveChanges(SEGMENT_DEVICESTATE | SEGMENT_CONFIG, false); break; } case meshtastic_AdminMessage_set_time_only_tag: { From a47570d65a09275caac90be91956fd99be7af297 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 17 Sep 2024 06:52:42 -0500 Subject: [PATCH 19/45] [create-pull-request] automated change (#4746) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> --- protobufs | 2 +- src/mesh/generated/meshtastic/deviceonly.pb.h | 7 ++++--- src/mesh/generated/meshtastic/mesh.pb.h | 7 ++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/protobufs b/protobufs index c5108cfd6..1e212f113 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit c5108cfd6bbc59adef44575dcec3067cbfbfeac1 +Subproject commit 1e212f113583dfd8d21a0daa47a32b080d3f842f diff --git a/src/mesh/generated/meshtastic/deviceonly.pb.h b/src/mesh/generated/meshtastic/deviceonly.pb.h index f87c84abe..a905c4526 100644 --- a/src/mesh/generated/meshtastic/deviceonly.pb.h +++ b/src/mesh/generated/meshtastic/deviceonly.pb.h @@ -94,6 +94,7 @@ typedef struct _meshtastic_NodeInfoLite { /* True if we witnessed the node over MQTT instead of LoRA transport */ bool via_mqtt; /* Number of hops away from us this node is (0 if adjacent) */ + bool has_hops_away; uint8_t hops_away; /* True if node is in our favorites list Persists between NodeDB internal clean ups */ @@ -202,13 +203,13 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_PositionLite_init_default {0, 0, 0, 0, _meshtastic_Position_LocSource_MIN} #define meshtastic_UserLite_init_default {{0}, "", "", _meshtastic_HardwareModel_MIN, 0, _meshtastic_Config_DeviceConfig_Role_MIN, {0, {0}}} -#define meshtastic_NodeInfoLite_init_default {0, false, meshtastic_UserLite_init_default, false, meshtastic_PositionLite_init_default, 0, 0, false, meshtastic_DeviceMetrics_init_default, 0, 0, 0, 0} +#define meshtastic_NodeInfoLite_init_default {0, false, meshtastic_UserLite_init_default, false, meshtastic_PositionLite_init_default, 0, 0, false, meshtastic_DeviceMetrics_init_default, 0, 0, false, 0, 0} #define meshtastic_DeviceState_init_default {false, meshtastic_MyNodeInfo_init_default, false, meshtastic_User_init_default, 0, {meshtastic_MeshPacket_init_default}, false, meshtastic_MeshPacket_init_default, 0, 0, 0, false, meshtastic_MeshPacket_init_default, 0, {meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default}, {0}} #define meshtastic_ChannelFile_init_default {0, {meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default}, 0} #define meshtastic_OEMStore_init_default {0, 0, {0, {0}}, _meshtastic_ScreenFonts_MIN, "", {0, {0}}, false, meshtastic_LocalConfig_init_default, false, meshtastic_LocalModuleConfig_init_default} #define meshtastic_PositionLite_init_zero {0, 0, 0, 0, _meshtastic_Position_LocSource_MIN} #define meshtastic_UserLite_init_zero {{0}, "", "", _meshtastic_HardwareModel_MIN, 0, _meshtastic_Config_DeviceConfig_Role_MIN, {0, {0}}} -#define meshtastic_NodeInfoLite_init_zero {0, false, meshtastic_UserLite_init_zero, false, meshtastic_PositionLite_init_zero, 0, 0, false, meshtastic_DeviceMetrics_init_zero, 0, 0, 0, 0} +#define meshtastic_NodeInfoLite_init_zero {0, false, meshtastic_UserLite_init_zero, false, meshtastic_PositionLite_init_zero, 0, 0, false, meshtastic_DeviceMetrics_init_zero, 0, 0, false, 0, 0} #define meshtastic_DeviceState_init_zero {false, meshtastic_MyNodeInfo_init_zero, false, meshtastic_User_init_zero, 0, {meshtastic_MeshPacket_init_zero}, false, meshtastic_MeshPacket_init_zero, 0, 0, 0, false, meshtastic_MeshPacket_init_zero, 0, {meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero}, {0}} #define meshtastic_ChannelFile_init_zero {0, {meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero}, 0} #define meshtastic_OEMStore_init_zero {0, 0, {0, {0}}, _meshtastic_ScreenFonts_MIN, "", {0, {0}}, false, meshtastic_LocalConfig_init_zero, false, meshtastic_LocalModuleConfig_init_zero} @@ -287,7 +288,7 @@ X(a, STATIC, SINGULAR, FIXED32, last_heard, 5) \ X(a, STATIC, OPTIONAL, MESSAGE, device_metrics, 6) \ X(a, STATIC, SINGULAR, UINT32, channel, 7) \ X(a, STATIC, SINGULAR, BOOL, via_mqtt, 8) \ -X(a, STATIC, SINGULAR, UINT32, hops_away, 9) \ +X(a, STATIC, OPTIONAL, UINT32, hops_away, 9) \ X(a, STATIC, SINGULAR, BOOL, is_favorite, 10) #define meshtastic_NodeInfoLite_CALLBACK NULL #define meshtastic_NodeInfoLite_DEFAULT NULL diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index f4e0a896b..44159858b 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -745,6 +745,7 @@ typedef struct _meshtastic_NodeInfo { /* True if we witnessed the node over MQTT instead of LoRA transport */ bool via_mqtt; /* Number of hops away from us this node is (0 if adjacent) */ + bool has_hops_away; uint8_t hops_away; /* True if node is in our favorites list Persists between NodeDB internal clean ups */ @@ -1093,7 +1094,7 @@ extern "C" { #define meshtastic_Waypoint_init_default {0, false, 0, false, 0, 0, 0, "", "", 0} #define meshtastic_MqttClientProxyMessage_init_default {"", 0, {{0, {0}}}, 0} #define meshtastic_MeshPacket_init_default {0, 0, 0, 0, {meshtastic_Data_init_default}, 0, 0, 0, 0, 0, _meshtastic_MeshPacket_Priority_MIN, 0, _meshtastic_MeshPacket_Delayed_MIN, 0, 0, {0, {0}}, 0} -#define meshtastic_NodeInfo_init_default {0, false, meshtastic_User_init_default, false, meshtastic_Position_init_default, 0, 0, false, meshtastic_DeviceMetrics_init_default, 0, 0, 0, 0} +#define meshtastic_NodeInfo_init_default {0, false, meshtastic_User_init_default, false, meshtastic_Position_init_default, 0, 0, false, meshtastic_DeviceMetrics_init_default, 0, 0, false, 0, 0} #define meshtastic_MyNodeInfo_init_default {0, 0, 0} #define meshtastic_LogRecord_init_default {"", 0, "", _meshtastic_LogRecord_Level_MIN} #define meshtastic_QueueStatus_init_default {0, 0, 0, 0} @@ -1118,7 +1119,7 @@ extern "C" { #define meshtastic_Waypoint_init_zero {0, false, 0, false, 0, 0, 0, "", "", 0} #define meshtastic_MqttClientProxyMessage_init_zero {"", 0, {{0, {0}}}, 0} #define meshtastic_MeshPacket_init_zero {0, 0, 0, 0, {meshtastic_Data_init_zero}, 0, 0, 0, 0, 0, _meshtastic_MeshPacket_Priority_MIN, 0, _meshtastic_MeshPacket_Delayed_MIN, 0, 0, {0, {0}}, 0} -#define meshtastic_NodeInfo_init_zero {0, false, meshtastic_User_init_zero, false, meshtastic_Position_init_zero, 0, 0, false, meshtastic_DeviceMetrics_init_zero, 0, 0, 0, 0} +#define meshtastic_NodeInfo_init_zero {0, false, meshtastic_User_init_zero, false, meshtastic_Position_init_zero, 0, 0, false, meshtastic_DeviceMetrics_init_zero, 0, 0, false, 0, 0} #define meshtastic_MyNodeInfo_init_zero {0, 0, 0} #define meshtastic_LogRecord_init_zero {"", 0, "", _meshtastic_LogRecord_Level_MIN} #define meshtastic_QueueStatus_init_zero {0, 0, 0, 0} @@ -1415,7 +1416,7 @@ X(a, STATIC, SINGULAR, FIXED32, last_heard, 5) \ X(a, STATIC, OPTIONAL, MESSAGE, device_metrics, 6) \ X(a, STATIC, SINGULAR, UINT32, channel, 7) \ X(a, STATIC, SINGULAR, BOOL, via_mqtt, 8) \ -X(a, STATIC, SINGULAR, UINT32, hops_away, 9) \ +X(a, STATIC, OPTIONAL, UINT32, hops_away, 9) \ X(a, STATIC, SINGULAR, BOOL, is_favorite, 10) #define meshtastic_NodeInfo_CALLBACK NULL #define meshtastic_NodeInfo_DEFAULT NULL From 2a6921292e77194bb199a4697eace5c47a2c277c Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 17 Sep 2024 10:05:55 -0500 Subject: [PATCH 20/45] Implement CoT detail support in TAKPacket (#4748) * Implement CoT detail support in TAKPacket * dest, src * More coffee is needed * SAVE --- src/modules/AtakPluginModule.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/AtakPluginModule.cpp b/src/modules/AtakPluginModule.cpp index 437a341db..72d069619 100644 --- a/src/modules/AtakPluginModule.cpp +++ b/src/modules/AtakPluginModule.cpp @@ -52,6 +52,10 @@ meshtastic_TAKPacket AtakPluginModule::cloneTAKPacketData(meshtastic_TAKPacket * } else if (t->which_payload_variant == meshtastic_TAKPacket_chat_tag) { clone.which_payload_variant = meshtastic_TAKPacket_chat_tag; clone.payload_variant.chat = {0}; + } else if (t->which_payload_variant == meshtastic_TAKPacket_detail_tag) { + clone.which_payload_variant = meshtastic_TAKPacket_detail_tag; + clone.payload_variant.detail.size = t->payload_variant.detail.size; + memcpy(clone.payload_variant.detail.bytes, t->payload_variant.detail.bytes, t->payload_variant.detail.size); } return clone; From f5016763fdda5b428dd62caaf1ab9e2550bdd08d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Tue, 17 Sep 2024 17:33:21 +0200 Subject: [PATCH 21/45] change evaluation order to silence warning about "found" (#4749) --- src/mesh/NodeDB.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 5d1db88ae..7e8abb747 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -654,8 +654,8 @@ void NodeDB::pickNewNodeNum() } meshtastic_NodeInfoLite *found; - while ((nodeNum == NODENUM_BROADCAST || nodeNum < NUM_RESERVED) || - ((found = getMeshNode(nodeNum)) && memcmp(found->user.macaddr, ourMacAddr, sizeof(ourMacAddr)) != 0)) { + while (((found = getMeshNode(nodeNum)) && memcmp(found->user.macaddr, ourMacAddr, sizeof(ourMacAddr)) != 0) || + (nodeNum == NODENUM_BROADCAST || nodeNum < NUM_RESERVED)) { NodeNum candidate = random(NUM_RESERVED, LONG_MAX); // try a new random choice LOG_WARN("NOTE! Our desired nodenum 0x%x is invalid or in use, by MAC ending in 0x%02x%02x vs our 0x%02x%02x, so " "trying for 0x%x\n", From 50fb4ab22ac412f7aec766e7cad2313109f9510a Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 17 Sep 2024 12:08:04 -0500 Subject: [PATCH 22/45] Implement optional hops_away on NodeInfo/Lite (#4747) * Implement optional hops_away on NodeInfo/Lite * Trunk --- src/mesh/NodeDB.cpp | 4 +++- src/mesh/PhoneAPI.cpp | 2 +- src/mesh/TypeConversions.cpp | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 7e8abb747..dca639070 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -1112,8 +1112,10 @@ void NodeDB::updateFrom(const meshtastic_MeshPacket &mp) info->via_mqtt = mp.via_mqtt; // Store if we received this packet via MQTT // If hopStart was set and there wasn't someone messing with the limit in the middle, add hopsAway - if (mp.hop_start != 0 && mp.hop_limit <= mp.hop_start) + if (mp.hop_start != 0 && mp.hop_limit <= mp.hop_start) { + info->has_hops_away = true; info->hops_away = mp.hop_start - mp.hop_limit; + } } } diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index 30af9d7b0..742bdbf34 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -194,7 +194,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) auto us = nodeDB->readNextMeshNode(readIndex); if (us) { nodeInfoForPhone = TypeConversions::ConvertToNodeInfo(us); - nodeInfoForPhone.hops_away = 0; + nodeInfoForPhone.has_hops_away = false; nodeInfoForPhone.is_favorite = true; fromRadioScratch.which_payload_variant = meshtastic_FromRadio_node_info_tag; fromRadioScratch.node_info = nodeInfoForPhone; diff --git a/src/mesh/TypeConversions.cpp b/src/mesh/TypeConversions.cpp index 6a90ac703..550f87021 100644 --- a/src/mesh/TypeConversions.cpp +++ b/src/mesh/TypeConversions.cpp @@ -11,9 +11,13 @@ meshtastic_NodeInfo TypeConversions::ConvertToNodeInfo(const meshtastic_NodeInfo info.last_heard = lite->last_heard; info.channel = lite->channel; info.via_mqtt = lite->via_mqtt; - info.hops_away = lite->hops_away; info.is_favorite = lite->is_favorite; + if (lite->has_hops_away) { + info.has_hops_away = true; + info.hops_away = lite->hops_away; + } + if (lite->has_position) { info.has_position = true; if (lite->position.latitude_i != 0) From 923458bc18fc74462f8d09b3a9990fd543fb5611 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 17 Sep 2024 17:55:16 -0500 Subject: [PATCH 23/45] [create-pull-request] automated change (#4754) Co-authored-by: jp-bennett <5630967+jp-bennett@users.noreply.github.com> --- protobufs | 2 +- src/mesh/generated/meshtastic/mesh.pb.h | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/protobufs b/protobufs index 1e212f113..164e59873 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 1e212f113583dfd8d21a0daa47a32b080d3f842f +Subproject commit 164e598734a813ae00a2a74266e9e06438f030ce diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index 44159858b..921dfa55b 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -876,6 +876,8 @@ typedef struct _meshtastic_DeviceMetadata { meshtastic_HardwareModel hw_model; /* Has Remote Hardware enabled */ bool hasRemoteHardware; + /* Has PKC capabilities */ + bool hasPKC; } meshtastic_DeviceMetadata; /* Packets from the radio to the phone will appear on the fromRadio characteristic. @@ -1105,7 +1107,7 @@ extern "C" { #define meshtastic_Compressed_init_default {_meshtastic_PortNum_MIN, {0, {0}}} #define meshtastic_NeighborInfo_init_default {0, 0, 0, 0, {meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default}} #define meshtastic_Neighbor_init_default {0, 0, 0, 0} -#define meshtastic_DeviceMetadata_init_default {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN, 0} +#define meshtastic_DeviceMetadata_init_default {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN, 0, 0} #define meshtastic_Heartbeat_init_default {0} #define meshtastic_NodeRemoteHardwarePin_init_default {0, false, meshtastic_RemoteHardwarePin_init_default} #define meshtastic_ChunkedPayload_init_default {0, 0, 0, {0, {0}}} @@ -1130,7 +1132,7 @@ extern "C" { #define meshtastic_Compressed_init_zero {_meshtastic_PortNum_MIN, {0, {0}}} #define meshtastic_NeighborInfo_init_zero {0, 0, 0, 0, {meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero}} #define meshtastic_Neighbor_init_zero {0, 0, 0, 0} -#define meshtastic_DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN, 0} +#define meshtastic_DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN, 0, 0} #define meshtastic_Heartbeat_init_zero {0} #define meshtastic_NodeRemoteHardwarePin_init_zero {0, false, meshtastic_RemoteHardwarePin_init_zero} #define meshtastic_ChunkedPayload_init_zero {0, 0, 0, {0, {0}}} @@ -1261,6 +1263,7 @@ extern "C" { #define meshtastic_DeviceMetadata_position_flags_tag 8 #define meshtastic_DeviceMetadata_hw_model_tag 9 #define meshtastic_DeviceMetadata_hasRemoteHardware_tag 10 +#define meshtastic_DeviceMetadata_hasPKC_tag 11 #define meshtastic_FromRadio_id_tag 1 #define meshtastic_FromRadio_packet_tag 2 #define meshtastic_FromRadio_my_info_tag 3 @@ -1541,7 +1544,8 @@ X(a, STATIC, SINGULAR, BOOL, hasEthernet, 6) \ X(a, STATIC, SINGULAR, UENUM, role, 7) \ X(a, STATIC, SINGULAR, UINT32, position_flags, 8) \ X(a, STATIC, SINGULAR, UENUM, hw_model, 9) \ -X(a, STATIC, SINGULAR, BOOL, hasRemoteHardware, 10) +X(a, STATIC, SINGULAR, BOOL, hasRemoteHardware, 10) \ +X(a, STATIC, SINGULAR, BOOL, hasPKC, 11) #define meshtastic_DeviceMetadata_CALLBACK NULL #define meshtastic_DeviceMetadata_DEFAULT NULL @@ -1640,7 +1644,7 @@ extern const pb_msgdesc_t meshtastic_ChunkedPayloadResponse_msg; #define meshtastic_ClientNotification_size 415 #define meshtastic_Compressed_size 243 #define meshtastic_Data_size 273 -#define meshtastic_DeviceMetadata_size 46 +#define meshtastic_DeviceMetadata_size 48 #define meshtastic_FileInfo_size 236 #define meshtastic_FromRadio_size 510 #define meshtastic_Heartbeat_size 0 From c78302a2ee979925e7aa9d008350c0495110a424 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Tue, 17 Sep 2024 19:34:05 -0500 Subject: [PATCH 24/45] Add hasPKC to deviceMetadata (#4755) --- src/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 86268ecac..a6e6ad631 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1091,6 +1091,9 @@ extern meshtastic_DeviceMetadata getDeviceMetadata() deviceMetadata.position_flags = config.position.position_flags; deviceMetadata.hw_model = HW_VENDOR; deviceMetadata.hasRemoteHardware = moduleConfig.remote_hardware.enabled; +#if !(MESHTASTIC_EXCLUDE_PKI) + deviceMetadata.hasPKC = true; +#endif return deviceMetadata; } #ifndef PIO_UNIT_TESTING From 2d52803dbde083d3e2ddce29cc3314e75d9f2fb5 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Tue, 17 Sep 2024 21:09:24 -0500 Subject: [PATCH 25/45] Add new admin error types (#4750) Co-authored-by: Ben Meadors --- src/modules/AdminModule.cpp | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 7b96d9c43..48048b054 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -73,12 +73,38 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta meshtastic_Channel *ch = &channels.getByIndex(mp.channel); // Could tighten this up further by tracking the last public_key we went an AdminMessage request to // and only allowing responses from that remote. - if (!((mp.from == 0 && !config.security.is_managed) || messageIsResponse(r) || - (strcasecmp(ch->settings.name, Channels::adminChannel) == 0 && config.security.admin_channel_enabled) || - (mp.pki_encrypted && memcmp(mp.public_key.bytes, config.security.admin_key[0].bytes, 32) == 0))) { - LOG_INFO("Ignoring admin payload %i\n", r->which_payload_variant); + if (messageIsResponse(r)) { + LOG_DEBUG("Allowing admin response message\n"); + } else if (mp.from == 0) { + if (config.security.is_managed) { + LOG_INFO("Ignoring local admin payload because is_managed.\n"); + return handled; + } + } else if (strcasecmp(ch->settings.name, Channels::adminChannel) == 0) { + if (!config.security.admin_channel_enabled) { + LOG_INFO("Ignoring admin channel, as legacy admin is disabled.\n"); + myReply = allocErrorResponse(meshtastic_Routing_Error_NOT_AUTHORIZED, &mp); + return handled; + } + } else if (mp.pki_encrypted) { + if ((config.security.admin_key[0].size == 32 && + memcmp(mp.public_key.bytes, config.security.admin_key[0].bytes, 32) == 0) || + (config.security.admin_key[1].size == 32 && + memcmp(mp.public_key.bytes, config.security.admin_key[1].bytes, 32) == 0) || + (config.security.admin_key[2].size == 32 && + memcmp(mp.public_key.bytes, config.security.admin_key[2].bytes, 32) == 0)) { + LOG_INFO("PKC admin payload with authorized sender key.\n"); + } else { + myReply = allocErrorResponse(meshtastic_Routing_Error_ADMIN_PUBLIC_KEY_UNAUTHORIZED, &mp); + LOG_INFO("Received PKC admin payload, but the sender public key does not match the admin authorized key!\n"); + return handled; + } + } else { + LOG_INFO("Ignoring unauthorized admin payload %i\n", r->which_payload_variant); + myReply = allocErrorResponse(meshtastic_Routing_Error_NOT_AUTHORIZED, &mp); return handled; } + LOG_INFO("Handling admin payload %i\n", r->which_payload_variant); // all of the get and set messages, including those for other modules, flow through here first. @@ -86,6 +112,7 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta if (mp.from != 0 && !messageIsRequest(r) && !messageIsResponse(r)) { if (!checkPassKey(r)) { LOG_WARN("Admin message without session_key!\n"); + myReply = allocErrorResponse(meshtastic_Routing_Error_ADMIN_BAD_SESSION_KEY, &mp); return handled; } } From 4289cb089b92024a0945a1c8fbbe55cb66b88bcd Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Wed, 18 Sep 2024 00:17:48 -0500 Subject: [PATCH 26/45] Update package_raspbian.yml to build on self-hosted (#4761) * Update package_raspbian.yml to build on self-hosted * Update package_raspbian_armv7l.yml to use self hosted --- .github/workflows/package_raspbian.yml | 2 +- .github/workflows/package_raspbian_armv7l.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package_raspbian.yml b/.github/workflows/package_raspbian.yml index 5471332c5..ab541899f 100644 --- a/.github/workflows/package_raspbian.yml +++ b/.github/workflows/package_raspbian.yml @@ -13,7 +13,7 @@ jobs: uses: ./.github/workflows/build_raspbian.yml package-raspbian: - runs-on: ubuntu-latest + runs-on: [linux] needs: build-raspbian steps: - name: Checkout code diff --git a/.github/workflows/package_raspbian_armv7l.yml b/.github/workflows/package_raspbian_armv7l.yml index 5b9c9aa71..cadce17c3 100644 --- a/.github/workflows/package_raspbian_armv7l.yml +++ b/.github/workflows/package_raspbian_armv7l.yml @@ -13,7 +13,7 @@ jobs: uses: ./.github/workflows/build_raspbian_armv7l.yml package-raspbian_armv7l: - runs-on: ubuntu-latest + runs-on: [linux] needs: build-raspbian_armv7l steps: - name: Checkout code From 3eebdcefa417619549163469aa70624c6178f777 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Wed, 18 Sep 2024 00:28:54 -0500 Subject: [PATCH 27/45] More CI fun --- .github/workflows/build_esp32.yml | 2 +- .github/workflows/package_raspbian.yml | 2 +- .github/workflows/package_raspbian_armv7l.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_esp32.yml b/.github/workflows/build_esp32.yml index 4cbb4c7a4..68525fc7d 100644 --- a/.github/workflows/build_esp32.yml +++ b/.github/workflows/build_esp32.yml @@ -9,7 +9,7 @@ on: jobs: build-esp32: - runs-on: ubuntu-latest + runs-on: [linux, x64] steps: - uses: actions/checkout@v4 - name: Build base diff --git a/.github/workflows/package_raspbian.yml b/.github/workflows/package_raspbian.yml index ab541899f..5471332c5 100644 --- a/.github/workflows/package_raspbian.yml +++ b/.github/workflows/package_raspbian.yml @@ -13,7 +13,7 @@ jobs: uses: ./.github/workflows/build_raspbian.yml package-raspbian: - runs-on: [linux] + runs-on: ubuntu-latest needs: build-raspbian steps: - name: Checkout code diff --git a/.github/workflows/package_raspbian_armv7l.yml b/.github/workflows/package_raspbian_armv7l.yml index cadce17c3..5b9c9aa71 100644 --- a/.github/workflows/package_raspbian_armv7l.yml +++ b/.github/workflows/package_raspbian_armv7l.yml @@ -13,7 +13,7 @@ jobs: uses: ./.github/workflows/build_raspbian_armv7l.yml package-raspbian_armv7l: - runs-on: [linux] + runs-on: ubuntu-latest needs: build-raspbian_armv7l steps: - name: Checkout code From c6196b226062fa650c943d1778d590f9415bb43c Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Wed, 18 Sep 2024 01:11:08 -0500 Subject: [PATCH 28/45] Update build_esp32.yml -- less CI fun --- .github/workflows/build_esp32.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_esp32.yml b/.github/workflows/build_esp32.yml index 68525fc7d..4cbb4c7a4 100644 --- a/.github/workflows/build_esp32.yml +++ b/.github/workflows/build_esp32.yml @@ -9,7 +9,7 @@ on: jobs: build-esp32: - runs-on: [linux, x64] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Build base From 19c57e8ec6746d1769533ca1d2615eda0313222a Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Wed, 18 Sep 2024 22:05:32 +0800 Subject: [PATCH 29/45] Fix Chatter 2 blank screen on boot (#4759) As reported by @eureekasigns and @GPSFan, Chatter 2 had begun to show a blank screen on boot after recent TFT display changes. Setting TFT_BACKLIGHT_ON LOW resolves the issue. Fixes https://github.com/meshtastic/firmware/issues/4751 --- variants/chatter2/variant.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/variants/chatter2/variant.h b/variants/chatter2/variant.h index b7f946970..5c27e2fb5 100644 --- a/variants/chatter2/variant.h +++ b/variants/chatter2/variant.h @@ -66,6 +66,7 @@ #define SCREEN_ROTATE #define SCREEN_TRANSITION_FRAMERATE 5 // fps #define DISPLAY_FORCE_SMALL_FONTS +#define TFT_BACKLIGHT_ON LOW // Battery @@ -121,4 +122,4 @@ // cannot serve any extra function even if requested to LORA_DIO3 value is never used in src (as we are not using RF95), so no // need to define, and DIO3_AS_TCXO_AT_1V8 is set so it cannot serve any extra function even if requested to (from 13.3.2.1 // DioxMask in SX1262 datasheet: Note that if DIO2 or DIO3 are used to control the RF Switch or the TCXO, the IRQ will not be -// generated even if it is mapped to the pins.) \ No newline at end of file +// generated even if it is mapped to the pins.) From 35e1c401e2f6b041a87546c44f3f79fd624c33d4 Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Wed, 18 Sep 2024 23:12:49 +0800 Subject: [PATCH 30/45] PMSA0031 sensors require ~3secs before coming up on I2C (#4743) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * PMSA0031 sensors require ~3secs before coming up on I2C As reported by @MALAONE1 and debugged by @shodan8192 , PMSA0031s on a RAK4631 take 3 seconds before they can become detectable on I2c. Add a delay(4000) before I2C scan if the air quality sensor pin is defined. Fixes https://github.com/meshtastic/firmware/issues/3690 * Remove 4 second wait and rescan during air quality init for the sensor * works without but this triggers my OCD --------- Co-authored-by: Thomas Göttgens Co-authored-by: Ben Meadors --- src/main.cpp | 4 +-- src/modules/Telemetry/AirQualityTelemetry.cpp | 25 +++++++++++++++---- src/modules/Telemetry/AirQualityTelemetry.h | 2 +- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a6e6ad631..e24ba68b3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -390,7 +390,7 @@ void setup() #endif #ifdef AQ_SET_PIN - // RAK-12039 set pin for Air quality sensor + // RAK-12039 set pin for Air quality sensor. Detectable on I2C after ~3 seconds, so we need to rescan later pinMode(AQ_SET_PIN, OUTPUT); digitalWrite(AQ_SET_PIN, HIGH); #endif @@ -1142,4 +1142,4 @@ void loop() } // if (didWake) LOG_DEBUG("wake!\n"); } -#endif +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/AirQualityTelemetry.cpp b/src/modules/Telemetry/AirQualityTelemetry.cpp index d07296710..56d308cfa 100644 --- a/src/modules/Telemetry/AirQualityTelemetry.cpp +++ b/src/modules/Telemetry/AirQualityTelemetry.cpp @@ -10,11 +10,11 @@ #include "PowerFSM.h" #include "RTC.h" #include "Router.h" +#include "detect/ScanI2CTwoWire.h" #include "main.h" int32_t AirQualityTelemetryModule::runOnce() { - int32_t result = INT32_MAX; /* Uncomment the preferences below if you want to use the module without having to configure it from the PythonAPI or WebUI. @@ -29,21 +29,36 @@ int32_t AirQualityTelemetryModule::runOnce() if (firstTime) { // This is the first time the OSThread library has called this function, so do some setup - firstTime = 0; + firstTime = false; if (moduleConfig.telemetry.air_quality_enabled) { LOG_INFO("Air quality Telemetry: Initializing\n"); if (!aqi.begin_I2C()) { - LOG_WARN("Could not establish i2c connection to AQI sensor\n"); + LOG_WARN("Could not establish i2c connection to AQI sensor. Rescanning...\n"); + // rescan for late arriving sensors. AQI Module starts about 10 seconds into the boot so this is plenty. + uint8_t i2caddr_scan[] = {PMSA0031_ADDR}; + uint8_t i2caddr_asize = 1; + auto i2cScanner = std::unique_ptr(new ScanI2CTwoWire()); +#if defined(I2C_SDA1) + i2cScanner->scanPort(ScanI2C::I2CPort::WIRE1, i2caddr_scan, i2caddr_asize); +#endif + i2cScanner->scanPort(ScanI2C::I2CPort::WIRE, i2caddr_scan, i2caddr_asize); + auto found = i2cScanner->find(ScanI2C::DeviceType::PMSA0031); + if (found.type != ScanI2C::DeviceType::NONE) { + nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_PMSA003I].first = found.address.address; + nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_PMSA003I].second = + i2cScanner->fetchI2CBus(found.address); + return 1000; + } return disable(); } return 1000; } - return result; + return disable(); } else { // if we somehow got to a second run of this module with measurement disabled, then just wait forever if (!moduleConfig.telemetry.air_quality_enabled) - return result; + return disable(); uint32_t now = millis(); if (((lastSentToMesh == 0) || diff --git a/src/modules/Telemetry/AirQualityTelemetry.h b/src/modules/Telemetry/AirQualityTelemetry.h index 23df6ac58..fb8edd07e 100644 --- a/src/modules/Telemetry/AirQualityTelemetry.h +++ b/src/modules/Telemetry/AirQualityTelemetry.h @@ -44,7 +44,7 @@ class AirQualityTelemetryModule : private concurrency::OSThread, public Protobuf private: Adafruit_PM25AQI aqi; PM25_AQI_Data data = {0}; - bool firstTime = 1; + bool firstTime = true; meshtastic_MeshPacket *lastMeasurementPacket; uint32_t sendToPhoneIntervalMs = SECONDS_IN_MINUTE * 1000; // Send to phone every minute uint32_t lastSentToMesh = 0; From 777bcf691a1a033cc31f96820aa1681499493e85 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 18 Sep 2024 10:13:07 -0500 Subject: [PATCH 31/45] Initial PhoneAPI rate-limiting of messages on certain ports (#4756) --- src/mesh/Default.h | 2 ++ src/mesh/PhoneAPI.cpp | 26 +++++++++++++++++++++++++- src/mesh/PhoneAPI.h | 10 ++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/mesh/Default.h b/src/mesh/Default.h index bafa60898..5641b5d25 100644 --- a/src/mesh/Default.h +++ b/src/mesh/Default.h @@ -3,6 +3,8 @@ #include #define ONE_DAY 24 * 60 * 60 #define ONE_MINUTE_MS 60 * 1000 +#define THIRTY_SECONDS_MS 30 * 1000 +#define FIVE_SECONDS_MS 5 * 1000 #define default_gps_update_interval IF_ROUTER(ONE_DAY, 2 * 60) #define default_telemetry_broadcast_interval_secs IF_ROUTER(ONE_DAY / 2, 30 * 60) diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index 742bdbf34..121687c49 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -25,6 +25,7 @@ #if !MESHTASTIC_EXCLUDE_MQTT #include "mqtt/MQTT.h" #endif +#include PhoneAPI::PhoneAPI() { @@ -541,14 +542,37 @@ bool PhoneAPI::available() return false; } +void PhoneAPI::sendNotification(meshtastic_LogRecord_Level level, uint32_t replyId, const char *message) +{ + meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed(); + cn->has_reply_id = true; + cn->reply_id = replyId; + cn->level = meshtastic_LogRecord_Level_WARNING; + cn->time = getValidTime(RTCQualityFromNet); + strncpy(cn->message, message, sizeof(cn->message)); + service->sendClientNotification(cn); + delete cn; +} + /** * Handle a packet that the phone wants us to send. It is our responsibility to free the packet to the pool */ bool PhoneAPI::handleToRadioPacket(meshtastic_MeshPacket &p) { printPacket("PACKET FROM PHONE", &p); + if (p.decoded.portnum == meshtastic_PortNum_TRACEROUTE_APP && lastPortNumToRadio[p.decoded.portnum] && + (millis() - lastPortNumToRadio[p.decoded.portnum]) < (THIRTY_SECONDS_MS)) { + LOG_WARN("Rate limiting portnum %d\n", p.decoded.portnum); + sendNotification(meshtastic_LogRecord_Level_WARNING, p.id, "TraceRoute can only be sent once every 30 seconds"); + return false; + } else if (p.decoded.portnum == meshtastic_PortNum_POSITION_APP && lastPortNumToRadio[p.decoded.portnum] && + (millis() - lastPortNumToRadio[p.decoded.portnum]) < (FIVE_SECONDS_MS)) { + LOG_WARN("Rate limiting portnum %d\n", p.decoded.portnum); + sendNotification(meshtastic_LogRecord_Level_WARNING, p.id, "Position can only be sent once every 5 seconds"); + return false; + } + lastPortNumToRadio[p.decoded.portnum] = millis(); service->handleToRadio(p); - return true; } diff --git a/src/mesh/PhoneAPI.h b/src/mesh/PhoneAPI.h index 5feb1c4bf..1e09b9535 100644 --- a/src/mesh/PhoneAPI.h +++ b/src/mesh/PhoneAPI.h @@ -2,8 +2,10 @@ #include "Observer.h" #include "mesh-pb-constants.h" +#include "meshtastic/portnums.pb.h" #include #include +#include #include // Make sure that we never let our packets grow too large for one BLE packet @@ -48,6 +50,9 @@ class PhoneAPI uint8_t config_state = 0; + // Hashmap of timestamps for last time we received a packet on the API per portnum + std::unordered_map lastPortNumToRadio; + /** * Each packet sent to the phone has an incrementing count */ @@ -99,6 +104,11 @@ class PhoneAPI */ virtual bool handleToRadio(const uint8_t *buf, size_t len); + /** + * Send a (client)notification to the phone + */ + virtual void sendNotification(meshtastic_LogRecord_Level level, uint32_t replyId, const char *message); + /** * Get the next packet we want to send to the phone * From deada41ceec0a783cb2c2770c935cd4fcd8abb36 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 18 Sep 2024 10:49:12 -0500 Subject: [PATCH 32/45] [create-pull-request] automated change (#4765) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> --- protobufs | 2 +- src/mesh/generated/meshtastic/clientonly.pb.h | 23 ++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/protobufs b/protobufs index 164e59873..5709c0a05 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 164e598734a813ae00a2a74266e9e06438f030ce +Subproject commit 5709c0a05eaefccbc9cb8ed3917adbf5fd134197 diff --git a/src/mesh/generated/meshtastic/clientonly.pb.h b/src/mesh/generated/meshtastic/clientonly.pb.h index dc323292a..5720c1c02 100644 --- a/src/mesh/generated/meshtastic/clientonly.pb.h +++ b/src/mesh/generated/meshtastic/clientonly.pb.h @@ -5,6 +5,7 @@ #define PB_MESHTASTIC_MESHTASTIC_CLIENTONLY_PB_H_INCLUDED #include #include "meshtastic/localonly.pb.h" +#include "meshtastic/mesh.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -28,6 +29,15 @@ typedef struct _meshtastic_DeviceProfile { /* The ModuleConfig of the node */ bool has_module_config; meshtastic_LocalModuleConfig module_config; + /* Fixed position data */ + bool has_fixed_position; + meshtastic_Position fixed_position; + /* Ringtone for ExternalNotification */ + bool has_ringtone; + char ringtone[231]; + /* Predefined messages for CannedMessage */ + bool has_canned_messages; + char canned_messages[201]; } meshtastic_DeviceProfile; @@ -36,8 +46,8 @@ extern "C" { #endif /* Initializer values for message structs */ -#define meshtastic_DeviceProfile_init_default {false, "", false, "", {{NULL}, NULL}, false, meshtastic_LocalConfig_init_default, false, meshtastic_LocalModuleConfig_init_default} -#define meshtastic_DeviceProfile_init_zero {false, "", false, "", {{NULL}, NULL}, false, meshtastic_LocalConfig_init_zero, false, meshtastic_LocalModuleConfig_init_zero} +#define meshtastic_DeviceProfile_init_default {false, "", false, "", {{NULL}, NULL}, false, meshtastic_LocalConfig_init_default, false, meshtastic_LocalModuleConfig_init_default, false, meshtastic_Position_init_default, false, "", false, ""} +#define meshtastic_DeviceProfile_init_zero {false, "", false, "", {{NULL}, NULL}, false, meshtastic_LocalConfig_init_zero, false, meshtastic_LocalModuleConfig_init_zero, false, meshtastic_Position_init_zero, false, "", false, ""} /* Field tags (for use in manual encoding/decoding) */ #define meshtastic_DeviceProfile_long_name_tag 1 @@ -45,6 +55,9 @@ extern "C" { #define meshtastic_DeviceProfile_channel_url_tag 3 #define meshtastic_DeviceProfile_config_tag 4 #define meshtastic_DeviceProfile_module_config_tag 5 +#define meshtastic_DeviceProfile_fixed_position_tag 6 +#define meshtastic_DeviceProfile_ringtone_tag 7 +#define meshtastic_DeviceProfile_canned_messages_tag 8 /* Struct field encoding specification for nanopb */ #define meshtastic_DeviceProfile_FIELDLIST(X, a) \ @@ -52,11 +65,15 @@ X(a, STATIC, OPTIONAL, STRING, long_name, 1) \ X(a, STATIC, OPTIONAL, STRING, short_name, 2) \ X(a, CALLBACK, OPTIONAL, STRING, channel_url, 3) \ X(a, STATIC, OPTIONAL, MESSAGE, config, 4) \ -X(a, STATIC, OPTIONAL, MESSAGE, module_config, 5) +X(a, STATIC, OPTIONAL, MESSAGE, module_config, 5) \ +X(a, STATIC, OPTIONAL, MESSAGE, fixed_position, 6) \ +X(a, STATIC, OPTIONAL, STRING, ringtone, 7) \ +X(a, STATIC, OPTIONAL, STRING, canned_messages, 8) #define meshtastic_DeviceProfile_CALLBACK pb_default_field_callback #define meshtastic_DeviceProfile_DEFAULT NULL #define meshtastic_DeviceProfile_config_MSGTYPE meshtastic_LocalConfig #define meshtastic_DeviceProfile_module_config_MSGTYPE meshtastic_LocalModuleConfig +#define meshtastic_DeviceProfile_fixed_position_MSGTYPE meshtastic_Position extern const pb_msgdesc_t meshtastic_DeviceProfile_msg; From 2ebfcea94eaf8e4826ce52795c43c316aada0a39 Mon Sep 17 00:00:00 2001 From: Augusto Zanellato Date: Wed, 18 Sep 2024 19:43:13 +0200 Subject: [PATCH 33/45] DetectionSensor: broadcast all state changes Closes #4753 --- src/modules/DetectionSensorModule.cpp | 14 ++++++++++---- src/modules/DetectionSensorModule.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/modules/DetectionSensorModule.cpp b/src/modules/DetectionSensorModule.cpp index 20d91a381..d637fa7c6 100644 --- a/src/modules/DetectionSensorModule.cpp +++ b/src/modules/DetectionSensorModule.cpp @@ -49,10 +49,16 @@ int32_t DetectionSensorModule::runOnce() // LOG_DEBUG("Detection Sensor Module: Current pin state: %i\n", digitalRead(moduleConfig.detection_sensor.monitor_pin)); - if ((millis() - lastSentToMesh) >= Default::getConfiguredOrDefaultMs(moduleConfig.detection_sensor.minimum_broadcast_secs) && - hasDetectionEvent()) { - sendDetectionMessage(); - return DELAYED_INTERVAL; + if ((millis() - lastSentToMesh) >= Default::getConfiguredOrDefaultMs(moduleConfig.detection_sensor.minimum_broadcast_secs)) { + if (hasDetectionEvent()) { + wasDetected = true; + sendDetectionMessage(); + return DELAYED_INTERVAL; + } else if (wasDetected) { + wasDetected = false; + sendCurrentStateMessage(); + return DELAYED_INTERVAL; + } } // Even if we haven't detected an event, broadcast our current state to the mesh on the scheduled interval as a sort // of heartbeat. We only do this if the minimum broadcast interval is greater than zero, otherwise we'll only broadcast state diff --git a/src/modules/DetectionSensorModule.h b/src/modules/DetectionSensorModule.h index ed6cddda5..eb17bf3a2 100644 --- a/src/modules/DetectionSensorModule.h +++ b/src/modules/DetectionSensorModule.h @@ -15,6 +15,7 @@ class DetectionSensorModule : public SinglePortModule, private concurrency::OSTh private: bool firstTime = true; uint32_t lastSentToMesh = 0; + bool wasDetected = false; void sendDetectionMessage(); void sendCurrentStateMessage(); bool hasDetectionEvent(); From cc89e85e712fec5fbf16d62a9207ca9636da6b6a Mon Sep 17 00:00:00 2001 From: David Huang Date: Thu, 19 Sep 2024 00:53:33 -0500 Subject: [PATCH 34/45] Another missed define for the T114 --- boards/heltec_mesh_node_t114.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/heltec_mesh_node_t114.json b/boards/heltec_mesh_node_t114.json index 5c97d8c75..2bd306eb9 100644 --- a/boards/heltec_mesh_node_t114.json +++ b/boards/heltec_mesh_node_t114.json @@ -5,7 +5,7 @@ }, "core": "nRF5", "cpu": "cortex-m4", - "extra_flags": "-DARDUINO_NRF52840_PCA10056 -DNRF52840_XXAA", + "extra_flags": "-DHELTEC_T114 -DNRF52840_XXAA", "f_cpu": "64000000L", "hwids": [ ["0x239A", "0x4405"], From 7c32ab3023c3e1a19c97bf9d4b724743124e2d48 Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Thu, 19 Sep 2024 08:20:53 +0200 Subject: [PATCH 35/45] Update ms24sf1.json --- boards/ms24sf1.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/ms24sf1.json b/boards/ms24sf1.json index 4e28507da..8356e3012 100644 --- a/boards/ms24sf1.json +++ b/boards/ms24sf1.json @@ -5,7 +5,7 @@ }, "core": "nRF5", "cpu": "cortex-m4", - "extra_flags": "-DARDUINO_WIO_WM1110 -DNRF52840_XXAA", + "extra_flags": "-DMS24SF1 -DNRF52840_XXAA", "f_cpu": "64000000L", "hwids": [ ["0x239A", "0x8029"], From 7289b295e85caf13c28930c795c525a0aab4a396 Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Thu, 19 Sep 2024 08:20:57 +0200 Subject: [PATCH 36/45] Update me25ls01-4y10td.json --- boards/me25ls01-4y10td.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/me25ls01-4y10td.json b/boards/me25ls01-4y10td.json index 46c526a7c..9e1d63265 100644 --- a/boards/me25ls01-4y10td.json +++ b/boards/me25ls01-4y10td.json @@ -5,7 +5,7 @@ }, "core": "nRF5", "cpu": "cortex-m4", - "extra_flags": "-DARDUINO_WIO_WM1110 -DNRF52840_XXAA", + "extra_flags": "-DME25LS01_4Y10TD -DNRF52840_XXAA", "f_cpu": "64000000L", "hwids": [ ["0x239A", "0x8029"], From 5c4c0965af040878e9270f8030673c0b3d099b0e Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Thu, 19 Sep 2024 08:21:00 +0200 Subject: [PATCH 37/45] Update nordic_pca10059.json --- boards/nordic_pca10059.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/nordic_pca10059.json b/boards/nordic_pca10059.json index b99e3c763..6540817a2 100644 --- a/boards/nordic_pca10059.json +++ b/boards/nordic_pca10059.json @@ -5,7 +5,7 @@ }, "core": "nRF5", "cpu": "cortex-m4", - "extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA", + "extra_flags": "-DNORDIC_PCA10059 -DNRF52840_XXAA", "f_cpu": "64000000L", "hwids": [ ["0x239A", "0x8029"], From 6473cf0b698176fe0dc2fb8e88155b1087cfc7fb Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Thu, 19 Sep 2024 19:48:22 +0800 Subject: [PATCH 38/45] Update RadioLib to 7.0.0 (#4771) We were not too many commits behind, and the changes since then were either for LoraWAN or useful minor bug fixes for SX1280. --- platformio.ini | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/platformio.ini b/platformio.ini index d561aaf74..f38ec41e4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -88,8 +88,7 @@ monitor_speed = 115200 monitor_filters = direct lib_deps = -; jgromes/RadioLib@~6.6.0 - https://github.com/jgromes/RadioLib.git#3115fc2d6700a9aee05888791ac930a910f2628f + jgromes/RadioLib@~7.0.0 https://github.com/meshtastic/esp8266-oled-ssd1306.git#e16cee124fe26490cb14880c679321ad8ac89c95 ; ESP8266_SSD1306 https://github.com/mathertel/OneButton@~2.6.1 ; OneButton library for non-blocking button debounce https://github.com/meshtastic/arduino-fsm.git#7db3702bf0cfe97b783d6c72595e3f38e0b19159 @@ -162,4 +161,4 @@ lib_deps = https://github.com/meshtastic/DFRobot_LarkWeatherStation#dee914270dc7cb3e43fbf034edd85a63a16a12ee - https://github.com/gjelsoe/STK8xxx-Accelerometer.git#v0.1.1 \ No newline at end of file + https://github.com/gjelsoe/STK8xxx-Accelerometer.git#v0.1.1 From 91b4199f9d63526f254f1ced374c20194a98b749 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 19 Sep 2024 10:46:18 -0500 Subject: [PATCH 39/45] Revert "DetectionSensor: broadcast all state changes" (#4776) --- src/modules/DetectionSensorModule.cpp | 14 ++++---------- src/modules/DetectionSensorModule.h | 1 - 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/modules/DetectionSensorModule.cpp b/src/modules/DetectionSensorModule.cpp index d637fa7c6..20d91a381 100644 --- a/src/modules/DetectionSensorModule.cpp +++ b/src/modules/DetectionSensorModule.cpp @@ -49,16 +49,10 @@ int32_t DetectionSensorModule::runOnce() // LOG_DEBUG("Detection Sensor Module: Current pin state: %i\n", digitalRead(moduleConfig.detection_sensor.monitor_pin)); - if ((millis() - lastSentToMesh) >= Default::getConfiguredOrDefaultMs(moduleConfig.detection_sensor.minimum_broadcast_secs)) { - if (hasDetectionEvent()) { - wasDetected = true; - sendDetectionMessage(); - return DELAYED_INTERVAL; - } else if (wasDetected) { - wasDetected = false; - sendCurrentStateMessage(); - return DELAYED_INTERVAL; - } + if ((millis() - lastSentToMesh) >= Default::getConfiguredOrDefaultMs(moduleConfig.detection_sensor.minimum_broadcast_secs) && + hasDetectionEvent()) { + sendDetectionMessage(); + return DELAYED_INTERVAL; } // Even if we haven't detected an event, broadcast our current state to the mesh on the scheduled interval as a sort // of heartbeat. We only do this if the minimum broadcast interval is greater than zero, otherwise we'll only broadcast state diff --git a/src/modules/DetectionSensorModule.h b/src/modules/DetectionSensorModule.h index eb17bf3a2..ed6cddda5 100644 --- a/src/modules/DetectionSensorModule.h +++ b/src/modules/DetectionSensorModule.h @@ -15,7 +15,6 @@ class DetectionSensorModule : public SinglePortModule, private concurrency::OSTh private: bool firstTime = true; uint32_t lastSentToMesh = 0; - bool wasDetected = false; void sendDetectionMessage(); void sendCurrentStateMessage(); bool hasDetectionEvent(); From d3a293a0d82d044bee9c9894011862f0a38dafa6 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 19 Sep 2024 12:10:39 -0500 Subject: [PATCH 40/45] Flag semgrep to not run on self-hosted The semgrep action runs inside a docker container, and docker in podman just doesn't work. --- .github/workflows/sec_sast_semgrep_pull.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sec_sast_semgrep_pull.yml b/.github/workflows/sec_sast_semgrep_pull.yml index b6c288494..2575cbf01 100644 --- a/.github/workflows/sec_sast_semgrep_pull.yml +++ b/.github/workflows/sec_sast_semgrep_pull.yml @@ -4,7 +4,7 @@ on: pull_request jobs: semgrep-diff: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 container: image: returntocorp/semgrep From 114df8cb1bfa1c7d124935b48e7faec0fba99fb3 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 19 Sep 2024 13:29:17 -0500 Subject: [PATCH 41/45] Pin sensorlib version --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index f38ec41e4..9b869a036 100644 --- a/platformio.ini +++ b/platformio.ini @@ -156,7 +156,7 @@ lib_deps = https://github.com/boschsensortec/Bosch-BSEC2-Library#v1.7.2502 boschsensortec/BME68x Sensor Library@^1.1.40407 https://github.com/KodinLanewave/INA3221@^1.0.0 - lewisxhe/SensorLib@^0.2.0 + lewisxhe/SensorLib@0.2.0 mprograms/QMC5883LCompass@^1.2.0 From 0f3450ad441f766bd451e9f2d2cfea09b5730431 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 19 Sep 2024 18:21:30 -0500 Subject: [PATCH 42/45] Mark package workflows for gh hosted runners --- .github/workflows/package_amd64.yml | 2 +- .github/workflows/package_raspbian.yml | 2 +- .github/workflows/package_raspbian_armv7l.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/package_amd64.yml b/.github/workflows/package_amd64.yml index ae7bf3242..0b5093f24 100644 --- a/.github/workflows/package_amd64.yml +++ b/.github/workflows/package_amd64.yml @@ -13,7 +13,7 @@ jobs: uses: ./.github/workflows/build_native.yml package-native: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: build-native steps: - name: Checkout code diff --git a/.github/workflows/package_raspbian.yml b/.github/workflows/package_raspbian.yml index 5471332c5..bcbda53e2 100644 --- a/.github/workflows/package_raspbian.yml +++ b/.github/workflows/package_raspbian.yml @@ -13,7 +13,7 @@ jobs: uses: ./.github/workflows/build_raspbian.yml package-raspbian: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: build-raspbian steps: - name: Checkout code diff --git a/.github/workflows/package_raspbian_armv7l.yml b/.github/workflows/package_raspbian_armv7l.yml index 5b9c9aa71..1308fe925 100644 --- a/.github/workflows/package_raspbian_armv7l.yml +++ b/.github/workflows/package_raspbian_armv7l.yml @@ -13,7 +13,7 @@ jobs: uses: ./.github/workflows/build_raspbian_armv7l.yml package-raspbian_armv7l: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: build-raspbian_armv7l steps: - name: Checkout code From 921d92c649be1f7088e74e7d32cd0bed1fcfd373 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 20 Sep 2024 06:55:16 -0500 Subject: [PATCH 43/45] Drop received packets from self --- src/mqtt/MQTT.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 0f4c5a8c5..c15ac3325 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -158,6 +158,11 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length) meshtastic_MeshPacket *p = packetPool.allocCopy(*e.packet); p->via_mqtt = true; // Mark that the packet was received via MQTT + if (p->from == 0 || p->from == nodeDB->getNodeNum()) { + LOG_INFO("Ignoring downlink message we originally sent.\n"); + packetPool.release(p); + return; + } if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) { p->channel = ch.index; } From 85d722232e470ed22720b97e634098616350354a Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 20 Sep 2024 07:22:11 -0500 Subject: [PATCH 44/45] Additional decoded packet ignores --- src/mqtt/MQTT.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index c15ac3325..6840700e5 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -164,6 +164,16 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length) return; } if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) { + if (moduleConfig.mqtt.encryption_enabled) { + LOG_INFO("Ignoring decoded message on MQTT, encryption is enabled.\n"); + packetPool.release(p); + return; + } + if (p->decoded.portnum == meshtastic_PortNum_ADMIN_APP) { + LOG_INFO("Ignoring decoded admin packet.\n"); + packetPool.release(p); + return; + } p->channel = ch.index; } From 6ffdc9875bfadb2da05fffbcb9f6a3371bd9c448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 12 Sep 2024 22:42:10 +0200 Subject: [PATCH 45/45] First stab at ESP32-C6 support for TLora-C6 --- arch/esp32/esp32c6.ini | 47 ++++++++++++++++++++++++ src/gps/GPS.cpp | 5 ++- src/graphics/Screen.cpp | 28 +++++++------- src/main.cpp | 14 ++++--- src/mesh/NodeDB.cpp | 2 +- src/mesh/TypedQueue.h | 2 +- src/mesh/api/ServerAPI.cpp | 2 +- src/mesh/wifi/WiFiAPClient.cpp | 3 +- src/modules/ExternalNotificationModule.h | 2 +- src/modules/PositionModule.cpp | 16 ++++---- src/modules/SerialModule.cpp | 21 ++++++++++- src/mqtt/MQTT.cpp | 4 ++ src/mqtt/MQTT.h | 4 ++ src/platform/esp32/main-esp32.cpp | 12 +++++- src/power.h | 1 + src/serialization/JSON.cpp | 2 +- src/sleep.cpp | 4 +- variants/tlora_c6/platformio.ini | 5 +++ variants/tlora_c6/variant.h | 16 ++++++++ 19 files changed, 150 insertions(+), 40 deletions(-) create mode 100644 arch/esp32/esp32c6.ini create mode 100644 variants/tlora_c6/platformio.ini create mode 100644 variants/tlora_c6/variant.h diff --git a/arch/esp32/esp32c6.ini b/arch/esp32/esp32c6.ini new file mode 100644 index 000000000..a7bcdc0e8 --- /dev/null +++ b/arch/esp32/esp32c6.ini @@ -0,0 +1,47 @@ +[esp32c6_base] +extends = esp32_base +platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF5 +build_flags = + ${arduino_base.build_flags} + -Wall + -Wextra + -Isrc/platform/esp32 + -std=c++11 + -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG + -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG + -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL + -DAXP_DEBUG_PORT=Serial + -DCONFIG_BT_NIMBLE_ENABLED + -DCONFIG_NIMBLE_CPP_LOG_LEVEL=2 + -DESP_OPENSSL_SUPPRESS_LEGACY_WARNING + -DSERIAL_BUFFER_SIZE=4096 + -DLIBPAX_ARDUINO + -DLIBPAX_WIFI + -DLIBPAX_BLE + -DMESHTASTIC_EXCLUDE_WEBSERVER + ;-DDEBUG_HEAP + ; TEMP + -DHAS_BLUETOOTH=0 + -DMESHTASTIC_EXCLUDE_PAXCOUNTER + -DMESHTASTIC_EXCLUDE_BLUETOOTH + -DMESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + +lib_deps = + ${arduino_base.lib_deps} + ${networking_base.lib_deps} + ${environmental_base.lib_deps} + https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6 + https://github.com/meshtastic/ESP32_Codec2.git#633326c78ac251c059ab3a8c430fcdf25b41672f + rweather/Crypto@^0.4.0 + +build_src_filter = + ${esp32_base.build_src_filter} - + +monitor_speed = 115200 +monitor_filters = esp32_c3_exception_decoder + +lib_ignore = + NonBlockingRTTTL + NimBLE-Arduino + libpax + \ No newline at end of file diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 01fa65816..19cfa0044 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -60,7 +60,8 @@ const char *getGPSPowerStateString(GPSPowerState state) case GPS_OFF: return "OFF"; default: - assert(false); // Unhandled enum value.. + assert(false); // Unhandled enum value.. + return "FALSE"; // to make new ESP-IDF happy } } @@ -330,7 +331,7 @@ int GPS::getACK(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t { uint16_t ubxFrameCounter = 0; uint32_t startTime = millis(); - uint16_t needRead; + uint16_t needRead = 0; while (millis() - startTime < waitMillis) { if (_serial_gps->available()) { diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index ae09ee408..07fb5d28e 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -1004,55 +1004,55 @@ static void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state display->setColor(WHITE); #ifndef EXCLUDE_EMOJI - if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), u8"\U0001F44D") == 0) { + if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), "\U0001F44D") == 0) { display->drawXbm(x + (SCREEN_WIDTH - thumbs_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - thumbs_height) / 2 + 2 + 5, thumbs_width, thumbs_height, thumbup); - } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), u8"\U0001F44E") == 0) { + } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), "\U0001F44E") == 0) { display->drawXbm(x + (SCREEN_WIDTH - thumbs_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - thumbs_height) / 2 + 2 + 5, thumbs_width, thumbs_height, thumbdown); - } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), u8"❓") == 0) { + } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), "❓") == 0) { display->drawXbm(x + (SCREEN_WIDTH - question_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - question_height) / 2 + 2 + 5, question_width, question_height, question); - } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), u8"‼️") == 0) { + } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), "‼️") == 0) { display->drawXbm(x + (SCREEN_WIDTH - bang_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - bang_height) / 2 + 2 + 5, bang_width, bang_height, bang); - } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), u8"\U0001F4A9") == 0) { + } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), "\U0001F4A9") == 0) { display->drawXbm(x + (SCREEN_WIDTH - poo_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - poo_height) / 2 + 2 + 5, poo_width, poo_height, poo); } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), "\xf0\x9f\xa4\xa3") == 0) { display->drawXbm(x + (SCREEN_WIDTH - haha_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - haha_height) / 2 + 2 + 5, haha_width, haha_height, haha); - } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), u8"\U0001F44B") == 0) { + } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), "\U0001F44B") == 0) { display->drawXbm(x + (SCREEN_WIDTH - wave_icon_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - wave_icon_height) / 2 + 2 + 5, wave_icon_width, wave_icon_height, wave_icon); - } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), u8"\U0001F920") == 0) { + } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), "\U0001F920") == 0) { display->drawXbm(x + (SCREEN_WIDTH - cowboy_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - cowboy_height) / 2 + 2 + 5, cowboy_width, cowboy_height, cowboy); - } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), u8"\U0001F42D") == 0) { + } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), "\U0001F42D") == 0) { display->drawXbm(x + (SCREEN_WIDTH - deadmau5_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - deadmau5_height) / 2 + 2 + 5, deadmau5_width, deadmau5_height, deadmau5); - } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), u8"\xE2\x98\x80\xEF\xB8\x8F") == 0) { + } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), "\xE2\x98\x80\xEF\xB8\x8F") == 0) { display->drawXbm(x + (SCREEN_WIDTH - sun_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - sun_height) / 2 + 2 + 5, sun_width, sun_height, sun); - } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), u8"\u2614") == 0) { + } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), "\u2614") == 0) { display->drawXbm(x + (SCREEN_WIDTH - rain_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - rain_height) / 2 + 2 + 10, rain_width, rain_height, rain); - } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), u8"☁️") == 0) { + } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), "☁️") == 0) { display->drawXbm(x + (SCREEN_WIDTH - cloud_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - cloud_height) / 2 + 2 + 5, cloud_width, cloud_height, cloud); - } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), u8"🌫️") == 0) { + } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), "🌫️") == 0) { display->drawXbm(x + (SCREEN_WIDTH - fog_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - fog_height) / 2 + 2 + 5, fog_width, fog_height, fog); - } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), u8"\xf0\x9f\x98\x88") == 0) { + } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), "\xf0\x9f\x98\x88") == 0) { display->drawXbm(x + (SCREEN_WIDTH - devil_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - devil_height) / 2 + 2 + 5, devil_width, devil_height, devil); - } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), u8"♥️") == 0) { + } else if (strcmp(reinterpret_cast(mp.decoded.payload.bytes), "♥️") == 0) { display->drawXbm(x + (SCREEN_WIDTH - heart_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - heart_height) / 2 + 2 + 5, heart_width, heart_height, heart); } else { diff --git a/src/main.cpp b/src/main.cpp index e24ba68b3..5057d7f57 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -322,15 +322,19 @@ void setup() #ifdef BUTTON_PIN #ifdef ARCH_ESP32 - // If the button is connected to GPIO 12, don't enable the ability to use - // meshtasticAdmin on the device. - pinMode(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN, INPUT); - +#if ESP_ARDUINO_VERSION_MAJOR >= 3 +#ifdef BUTTON_NEED_PULLUP + pinMode(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN, INPUT_PULLUP); +#else + pinMode(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN, INPUT); // default to BUTTON_PIN +#endif +#else + pinMode(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN, INPUT); // default to BUTTON_PIN #ifdef BUTTON_NEED_PULLUP gpio_pullup_en((gpio_num_t)(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN)); delay(10); #endif - +#endif #endif #endif diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index dca639070..12b731ab1 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -49,7 +49,7 @@ NodeDB *nodeDB = nullptr; // we have plenty of ram so statically alloc this tempbuf (for now) -EXT_RAM_ATTR meshtastic_DeviceState devicestate; +EXT_RAM_BSS_ATTR meshtastic_DeviceState devicestate; meshtastic_MyNodeInfo &myNodeInfo = devicestate.my_node; meshtastic_LocalConfig config; meshtastic_LocalModuleConfig moduleConfig; diff --git a/src/mesh/TypedQueue.h b/src/mesh/TypedQueue.h index c96edae8e..f7d016f10 100644 --- a/src/mesh/TypedQueue.h +++ b/src/mesh/TypedQueue.h @@ -14,7 +14,7 @@ */ template class TypedQueue { - static_assert(std::is_pod::value, "T must be pod"); + static_assert(std::is_standard_layout::value, "T must be standard layout"); QueueHandle_t h; concurrency::OSThread *reader = NULL; diff --git a/src/mesh/api/ServerAPI.cpp b/src/mesh/api/ServerAPI.cpp index 3a483aac1..097f4fa21 100644 --- a/src/mesh/api/ServerAPI.cpp +++ b/src/mesh/api/ServerAPI.cpp @@ -45,7 +45,7 @@ template void APIServerPort::init() template int32_t APIServerPort::runOnce() { - auto client = U::available(); + auto client = U::accept(); if (client) { // Close any previous connection (see FIXME in header file) if (openAPI) { diff --git a/src/mesh/wifi/WiFiAPClient.cpp b/src/mesh/wifi/WiFiAPClient.cpp index 07b03222e..e3203e6f7 100644 --- a/src/mesh/wifi/WiFiAPClient.cpp +++ b/src/mesh/wifi/WiFiAPClient.cpp @@ -309,7 +309,8 @@ static void WiFiEvent(WiFiEvent_t event) onNetworkConnected(); break; case ARDUINO_EVENT_WIFI_STA_GOT_IP6: - LOG_INFO("Obtained IP6 address: %s\n", WiFi.localIPv6().toString().c_str()); + LOG_INFO("Obtained Local IP6 address: %s\n", WiFi.linkLocalIPv6().toString().c_str()); + LOG_INFO("Obtained GlobalIP6 address: %s\n", WiFi.globalIPv6().toString().c_str()); break; case ARDUINO_EVENT_WIFI_STA_LOST_IP: LOG_INFO("Lost IP address and IP address is reset to 0\n"); diff --git a/src/modules/ExternalNotificationModule.h b/src/modules/ExternalNotificationModule.h index 08e72c35a..a5dff3651 100644 --- a/src/modules/ExternalNotificationModule.h +++ b/src/modules/ExternalNotificationModule.h @@ -3,7 +3,7 @@ #include "SinglePortModule.h" #include "concurrency/OSThread.h" #include "configuration.h" -#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) +#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(CONFIG_IDF_TARGET_ESP32C6) #include #else // Noop class for portduino. diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index cb6a58b2e..2a962c268 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -273,7 +273,7 @@ meshtastic_MeshPacket *PositionModule::allocAtakPli() meshtastic_TAKPacket takPacket = {.is_compressed = true, .has_contact = true, - .contact = {0}, + .contact = meshtastic_Contact_init_default, .has_group = true, .group = {meshtastic_MemberRole_TeamMember, meshtastic_Team_Cyan}, .has_status = true, @@ -282,13 +282,13 @@ meshtastic_MeshPacket *PositionModule::allocAtakPli() .battery = powerStatus->getBatteryChargePercent(), }, .which_payload_variant = meshtastic_TAKPacket_pli_tag, - {.pli = { - .latitude_i = localPosition.latitude_i, - .longitude_i = localPosition.longitude_i, - .altitude = localPosition.altitude_hae, - .speed = localPosition.ground_speed, - .course = static_cast(localPosition.ground_track), - }}}; + .payload_variant = {.pli = { + .latitude_i = localPosition.latitude_i, + .longitude_i = localPosition.longitude_i, + .altitude = localPosition.altitude_hae, + .speed = localPosition.ground_speed, + .course = static_cast(localPosition.ground_track), + }}}; auto length = unishox2_compress_lines(owner.long_name, strlen(owner.long_name), takPacket.contact.device_callsign, sizeof(takPacket.contact.device_callsign) - 1, USX_PSET_DFLT, NULL); diff --git a/src/modules/SerialModule.cpp b/src/modules/SerialModule.cpp index f0ba64f65..549fcf1d7 100644 --- a/src/modules/SerialModule.cpp +++ b/src/modules/SerialModule.cpp @@ -62,6 +62,9 @@ SerialModuleRadio *serialModuleRadio; #if defined(TTGO_T_ECHO) || defined(CANARYONE) SerialModule::SerialModule() : StreamAPI(&Serial), concurrency::OSThread("SerialModule") {} static Print *serialPrint = &Serial; +#elif defined(CONFIG_IDF_TARGET_ESP32C6) +SerialModule::SerialModule() : StreamAPI(&Serial1), concurrency::OSThread("SerialModule") {} +static Print *serialPrint = &Serial1; #else SerialModule::SerialModule() : StreamAPI(&Serial2), concurrency::OSThread("SerialModule") {} static Print *serialPrint = &Serial2; @@ -137,7 +140,16 @@ int32_t SerialModule::runOnce() // Give it a chance to flush out 💩 delay(10); } -#ifdef ARCH_ESP32 +#if defined(CONFIG_IDF_TARGET_ESP32C6) + if (moduleConfig.serial.rxd && moduleConfig.serial.txd) { + Serial1.setRxBufferSize(RX_BUFFER); + Serial1.begin(baud, SERIAL_8N1, moduleConfig.serial.rxd, moduleConfig.serial.txd); + } else { + Serial.begin(baud); + Serial.setTimeout(moduleConfig.serial.timeout > 0 ? moduleConfig.serial.timeout : TIMEOUT); + } + +#elif defined(ARCH_ESP32) if (moduleConfig.serial.rxd && moduleConfig.serial.txd) { Serial2.setRxBufferSize(RX_BUFFER); @@ -205,8 +217,13 @@ int32_t SerialModule::runOnce() processWXSerial(); } else { +#if defined(CONFIG_IDF_TARGET_ESP32C6) + while (Serial1.available()) { + serialPayloadSize = Serial1.readBytes(serialBytes, meshtastic_Constants_DATA_PAYLOAD_LEN); +#else while (Serial2.available()) { serialPayloadSize = Serial2.readBytes(serialBytes, meshtastic_Constants_DATA_PAYLOAD_LEN); +#endif serialModuleRadio->sendPayload(); } } @@ -392,7 +409,7 @@ uint32_t SerialModule::getBaudRate() */ void SerialModule::processWXSerial() { -#if !defined(TTGO_T_ECHO) && !defined(CANARYONE) +#if !defined(TTGO_T_ECHO) && !defined(CANARYONE) && !defined(CONFIG_IDF_TARGET_ESP32C6) static unsigned int lastAveraged = 0; static unsigned int averageIntervalMillis = 300000; // 5 minutes hard coded. static double dir_sum_sin = 0; diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 6840700e5..240fae0f9 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -325,6 +325,7 @@ void MQTT::reconnect() mqttPassword = moduleConfig.mqtt.password; } #if HAS_WIFI && !defined(ARCH_PORTDUINO) +#ifndef CONFIG_IDF_TARGET_ESP32C6 if (moduleConfig.mqtt.tls_enabled) { // change default for encrypted to 8883 try { @@ -340,6 +341,9 @@ void MQTT::reconnect() LOG_INFO("Using non-TLS-encrypted session\n"); pubSub.setClient(mqttClient); } +#else + pubSub.setClient(mqttClient); +#endif #elif HAS_NETWORKING pubSub.setClient(mqttClient); #endif diff --git a/src/mqtt/MQTT.h b/src/mqtt/MQTT.h index ba0987783..c827e12ca 100644 --- a/src/mqtt/MQTT.h +++ b/src/mqtt/MQTT.h @@ -9,9 +9,11 @@ #if HAS_WIFI #include #if !defined(ARCH_PORTDUINO) +#if defined(ESP_ARDUINO_VERSION_MAJOR) && ESP_ARDUINO_VERSION_MAJOR < 3 #include #endif #endif +#endif #if HAS_ETHERNET #include #endif @@ -33,9 +35,11 @@ class MQTT : private concurrency::OSThread #if HAS_WIFI WiFiClient mqttClient; #if !defined(ARCH_PORTDUINO) +#if defined(ESP_ARDUINO_VERSION_MAJOR) && ESP_ARDUINO_VERSION_MAJOR < 3 WiFiClientSecure wifiSecureClient; #endif #endif +#endif #if HAS_ETHERNET EthernetClient mqttClient; #endif diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp index 0b6f7cf23..f16accab6 100644 --- a/src/platform/esp32/main-esp32.cpp +++ b/src/platform/esp32/main-esp32.cpp @@ -13,6 +13,7 @@ #include "mesh/wifi/WiFiAPClient.h" #endif +#include "esp_mac.h" #include "meshUtils.h" #include "sleep.h" #include "soc/rtc.h" @@ -147,9 +148,16 @@ void esp32Setup() // #define APP_WATCHDOG_SECS 45 #define APP_WATCHDOG_SECS 90 +#ifdef CONFIG_IDF_TARGET_ESP32C6 + esp_task_wdt_config_t *wdt_config = (esp_task_wdt_config_t *)malloc(sizeof(esp_task_wdt_config_t)); + wdt_config->timeout_ms = APP_WATCHDOG_SECS * 1000; + wdt_config->trigger_panic = true; + res = esp_task_wdt_init(wdt_config); + assert(res == ESP_OK); +#else res = esp_task_wdt_init(APP_WATCHDOG_SECS, true); assert(res == ESP_OK); - +#endif res = esp_task_wdt_add(NULL); assert(res == ESP_OK); @@ -223,7 +231,7 @@ void cpuDeepSleep(uint32_t msecToWake) // to detect wake and in normal operation the external part drives them hard. #ifdef BUTTON_PIN // Only GPIOs which are have RTC functionality can be used in this bit map: 0,2,4,12-15,25-27,32-39. -#if SOC_RTCIO_HOLD_SUPPORTED +#if SOC_RTCIO_HOLD_SUPPORTED && SOC_PM_SUPPORT_EXT_WAKEUP uint64_t gpioMask = (1ULL << (config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN)); #endif diff --git a/src/power.h b/src/power.h index a4307ee07..5a41b55f2 100644 --- a/src/power.h +++ b/src/power.h @@ -5,6 +5,7 @@ #include "configuration.h" #ifdef ARCH_ESP32 +// "legacy adc calibration driver is deprecated, please migrate to use esp_adc/adc_cali.h and esp_adc/adc_cali_scheme.h #include #include #endif diff --git a/src/serialization/JSON.cpp b/src/serialization/JSON.cpp index e98bf47b9..42e615108 100644 --- a/src/serialization/JSON.cpp +++ b/src/serialization/JSON.cpp @@ -184,7 +184,7 @@ bool JSON::ExtractString(const char **data, std::string &str) // End of the string? else if (next_char == '"') { (*data)++; - str.reserve(); // Remove unused capacity + str.shrink_to_fit(); // Remove unused capacity return true; } diff --git a/src/sleep.cpp b/src/sleep.cpp index 27e81ce54..b0802c624 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -446,12 +446,14 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r */ void enableModemSleep() { - static esp_pm_config_esp32_t esp32_config; // filled with zeros because bss + static esp_pm_config_t esp32_config; // filled with zeros because bss #if CONFIG_IDF_TARGET_ESP32S3 esp32_config.max_freq_mhz = CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ; #elif CONFIG_IDF_TARGET_ESP32S2 esp32_config.max_freq_mhz = CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ; +#elif CONFIG_IDF_TARGET_ESP32C6 + esp32_config.max_freq_mhz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ; #elif CONFIG_IDF_TARGET_ESP32C3 esp32_config.max_freq_mhz = CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ; #else diff --git a/variants/tlora_c6/platformio.ini b/variants/tlora_c6/platformio.ini new file mode 100644 index 000000000..977e8ba86 --- /dev/null +++ b/variants/tlora_c6/platformio.ini @@ -0,0 +1,5 @@ +[env:tlora-c6] +extends = esp32c6_base +board = esp32-c6-devkitm-1 +build_flags = + ${esp32c6_base.build_flags} -D PRIVATE_HW -D TLORA_C6 -I variants/tlora_c6 \ No newline at end of file diff --git a/variants/tlora_c6/variant.h b/variants/tlora_c6/variant.h new file mode 100644 index 000000000..08fefa809 --- /dev/null +++ b/variants/tlora_c6/variant.h @@ -0,0 +1,16 @@ +#define I2C_SDA 4 // I2C pins for this board +#define I2C_SCL 15 + +#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller + +#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost +#define LED_PIN 2 // If defined we will blink this LED +#define BUTTON_PIN 0 // If defined, this will be used for user button presses +#define BUTTON_NEED_PULLUP +#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module. + +#define USE_RF95 +#define LORA_DIO0 26 // a No connect on the SX1262 module +#define LORA_RESET 14 +#define LORA_DIO1 33 // Must be manually wired: https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436 +#define LORA_DIO2 32 // Not really used \ No newline at end of file