From be8da851a6c67a98c5faa5af9b85285f47a8fe43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 22 Oct 2022 11:55:01 +0200 Subject: [PATCH 001/133] fix json filebrowser in web server --- src/mesh/http/ContentHandler.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index 91f88dda0..50e82f58f 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -251,7 +251,7 @@ void htmlDeleteDir(const char *dirname) std::vector> *htmlListDir(std::vector> *fileList, const char *dirname, uint8_t levels) { - File root = FSCom.open(dirname); + File root = FSCom.open(dirname, FILE_O_READ); if (!root) { return NULL; } @@ -264,14 +264,27 @@ std::vector> *htmlListDir(std::vector thisFileMap; thisFileMap[strdup("size")] = strdup(String(file.size()).c_str()); +#ifdef ARCH_ESP32 + thisFileMap[strdup("name")] = strdup(String(file.path()).substring(1).c_str()); +#else thisFileMap[strdup("name")] = strdup(String(file.name()).substring(1).c_str()); +#endif if (String(file.name()).substring(1).endsWith(".gz")) { +#ifdef ARCH_ESP32 + String modifiedFile = String(file.path()).substring(1); +#else String modifiedFile = String(file.name()).substring(1); +#endif modifiedFile.remove((modifiedFile.length() - 3), 3); thisFileMap[strdup("nameModified")] = strdup(modifiedFile.c_str()); } @@ -291,7 +304,7 @@ void handleFsBrowseStatic(HTTPRequest *req, HTTPResponse *res) res->setHeader("Access-Control-Allow-Methods", "GET"); using namespace json11; - auto fileList = htmlListDir(new std::vector>(), "/", 10); + auto fileList = htmlListDir(new std::vector>(), "/static", 10); // create json output structure Json filesystemObj = Json::object{ From d4ddcdd91e7a5fc82bae82c37713410d136ea5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 22 Oct 2022 13:35:34 +0200 Subject: [PATCH 002/133] use PWM buzzer on notification module. To activate set moduleConfig.external_notification.output equal to the PIN_BUZZER. If another value is set, the traditional digital mode is used --- src/modules/ExternalNotificationModule.cpp | 48 ++++++++++++++-------- src/modules/ExternalNotificationModule.h | 2 + 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 7e776f172..dbe8e01f4 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -3,9 +3,14 @@ #include "NodeDB.h" #include "RTC.h" #include "Router.h" +#include "buzz/buzz.h" #include "configuration.h" #include +#ifndef PIN_BUZZER +#define PIN_BUZZER false +#endif + //#include /* @@ -75,7 +80,9 @@ int32_t ExternalNotificationModule::runOnce() : EXT_NOTIFICATION_MODULE_OUTPUT_MS) < millis()) { DEBUG_MSG("Turning off external notification\n"); - setExternalOff(); + if (output != PIN_BUZZER) { + setExternalOff(); + } } } @@ -88,9 +95,7 @@ void ExternalNotificationModule::setExternalOn() externalCurrentState = 1; externalTurnedOn = millis(); - digitalWrite((moduleConfig.external_notification.output - ? moduleConfig.external_notification.output - : EXT_NOTIFICATION_MODULE_OUTPUT), + digitalWrite(output, (moduleConfig.external_notification.active ? true : false)); #endif } @@ -100,9 +105,7 @@ void ExternalNotificationModule::setExternalOff() #ifdef EXT_NOTIFY_OUT externalCurrentState = 0; - digitalWrite((moduleConfig.external_notification.output - ? moduleConfig.external_notification.output - : EXT_NOTIFICATION_MODULE_OUTPUT), + digitalWrite(output, (moduleConfig.external_notification.active ? false : true)); #endif } @@ -135,14 +138,19 @@ ExternalNotificationModule::ExternalNotificationModule() DEBUG_MSG("Initializing External Notification Module\n"); - // Set the direction of a pin - pinMode((moduleConfig.external_notification.output - ? moduleConfig.external_notification.output - : EXT_NOTIFICATION_MODULE_OUTPUT), - OUTPUT); + output = moduleConfig.external_notification.output + ? moduleConfig.external_notification.output + : EXT_NOTIFICATION_MODULE_OUTPUT; - // Turn off the pin - setExternalOff(); + if (output != PIN_BUZZER) { + // Set the direction of a pin + DEBUG_MSG("Using Pin %i in digital mode\n", output); + pinMode(output, OUTPUT); + // Turn off the pin + setExternalOff(); + } else{ + DEBUG_MSG("Using Pin %i in PWM mode\n", output); + } } else { DEBUG_MSG("External Notification Module Disabled\n"); enabled = false; @@ -165,14 +173,22 @@ ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp) DEBUG_MSG("externalNotificationModule - Notification Bell\n"); for (int i = 0; i < p.payload.size; i++) { if (p.payload.bytes[i] == ASCII_BELL) { - setExternalOn(); + if (output != PIN_BUZZER) { + setExternalOn(); + } else { + playBeep(); + } } } } if (moduleConfig.external_notification.alert_message) { DEBUG_MSG("externalNotificationModule - Notification Module\n"); - setExternalOn(); + if (output != PIN_BUZZER) { + setExternalOn(); + } else { + playBeep(); + } } } diff --git a/src/modules/ExternalNotificationModule.h b/src/modules/ExternalNotificationModule.h index a671d67c2..6fb45e7e2 100644 --- a/src/modules/ExternalNotificationModule.h +++ b/src/modules/ExternalNotificationModule.h @@ -12,6 +12,8 @@ */ class ExternalNotificationModule : public SinglePortModule, private concurrency::OSThread { + uint32_t output = EXT_NOTIFY_OUT; + public: ExternalNotificationModule(); From d8178892552be507b0bd527ba5f3bc032067cbda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 22 Oct 2022 13:45:43 +0200 Subject: [PATCH 003/133] don't depend on EXT_NOTIFY_OUT being defined. --- src/modules/ExternalNotificationModule.cpp | 10 ---------- src/modules/ExternalNotificationModule.h | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index dbe8e01f4..90fbf28f0 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -91,23 +91,19 @@ int32_t ExternalNotificationModule::runOnce() void ExternalNotificationModule::setExternalOn() { -#ifdef EXT_NOTIFY_OUT externalCurrentState = 1; externalTurnedOn = millis(); digitalWrite(output, (moduleConfig.external_notification.active ? true : false)); -#endif } void ExternalNotificationModule::setExternalOff() { -#ifdef EXT_NOTIFY_OUT externalCurrentState = 0; digitalWrite(output, (moduleConfig.external_notification.active ? false : true)); -#endif } // -------- @@ -119,8 +115,6 @@ ExternalNotificationModule::ExternalNotificationModule() // restrict to the admin channel for rx boundChannel = Channels::gpioChannel; -#ifdef EXT_NOTIFY_OUT - /* Uncomment the preferences below if you want to use the module without having to configure it from the PythonAPI or WebUI. @@ -155,13 +149,10 @@ ExternalNotificationModule::ExternalNotificationModule() DEBUG_MSG("External Notification Module Disabled\n"); enabled = false; } -#endif } ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp) { -#ifdef EXT_NOTIFY_OUT - if (moduleConfig.external_notification.enabled) { if (getFrom(&mp) != nodeDB.getNodeNum()) { @@ -195,7 +186,6 @@ ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp) } else { DEBUG_MSG("External Notification Module Disabled\n"); } -#endif return ProcessMessage::CONTINUE; // Let others look at this message also if they want } diff --git a/src/modules/ExternalNotificationModule.h b/src/modules/ExternalNotificationModule.h index 6fb45e7e2..b5ab64b3c 100644 --- a/src/modules/ExternalNotificationModule.h +++ b/src/modules/ExternalNotificationModule.h @@ -12,8 +12,8 @@ */ class ExternalNotificationModule : public SinglePortModule, private concurrency::OSThread { - uint32_t output = EXT_NOTIFY_OUT; - + uint32_t output = 0; + public: ExternalNotificationModule(); From 62b350900951ac714b8c7dc0e648c7aac30f2fec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 22 Oct 2022 14:13:45 +0200 Subject: [PATCH 004/133] missed one --- src/modules/ExternalNotificationModule.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 90fbf28f0..56a0db941 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -49,7 +49,11 @@ */ // Default configurations +#ifdef EXT_NOTIFY_OUT #define EXT_NOTIFICATION_MODULE_OUTPUT EXT_NOTIFY_OUT +#else +#define EXT_NOTIFICATION_MODULE_OUTPUT 0 +#endif #define EXT_NOTIFICATION_MODULE_OUTPUT_MS 1000 #define ASCII_BELL 0x07 From f7655f3abe4552f4dd7f4548d4f64620f8c14201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 22 Oct 2022 14:18:47 +0200 Subject: [PATCH 005/133] fix compiler warning --- src/RedirectablePrint.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RedirectablePrint.cpp b/src/RedirectablePrint.cpp index de9b95027..0d14b4562 100644 --- a/src/RedirectablePrint.cpp +++ b/src/RedirectablePrint.cpp @@ -44,7 +44,7 @@ size_t RedirectablePrint::vprintf(const char *format, va_list arg) static char printBuf[160]; va_copy(copy, arg); - int len = vsnprintf(printBuf, sizeof(printBuf), format, copy); + size_t len = vsnprintf(printBuf, sizeof(printBuf), format, copy); va_end(copy); if (len < 0) return 0; From a9d6ef599052202470b76775f59d3f7551a2f071 Mon Sep 17 00:00:00 2001 From: thebentern Date: Sat, 22 Oct 2022 13:28:36 +0000 Subject: [PATCH 006/133] [create-pull-request] automated change --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 750a9609f..3d2355d7b 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 1 minor = 3 -build = 47 +build = 48 From cb26bc38716c9fef9d615456a8f69ca713849d9a Mon Sep 17 00:00:00 2001 From: caveman99 Date: Sat, 22 Oct 2022 14:18:18 +0000 Subject: [PATCH 007/133] [create-pull-request] automated change --- protobufs | 2 +- src/mesh/generated/config.pb.c | 4 ++ src/mesh/generated/config.pb.h | 78 ++++++++++++++++++++++++------- src/mesh/generated/localonly.pb.h | 2 +- src/mesh/generated/mesh.pb.h | 2 +- 5 files changed, 68 insertions(+), 20 deletions(-) diff --git a/protobufs b/protobufs index d0559bfa3..863a1d799 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit d0559bfa3c31023ed2f2aa3807b6a0a1da9a6feb +Subproject commit 863a1d7997ae54471cbeea9baeb877924cc850cf diff --git a/src/mesh/generated/config.pb.c b/src/mesh/generated/config.pb.c index 7d2efe91d..f29dd7012 100644 --- a/src/mesh/generated/config.pb.c +++ b/src/mesh/generated/config.pb.c @@ -21,6 +21,9 @@ PB_BIND(Config_PowerConfig, Config_PowerConfig, AUTO) PB_BIND(Config_NetworkConfig, Config_NetworkConfig, AUTO) +PB_BIND(Config_NetworkConfig_NetworkConfig, Config_NetworkConfig_NetworkConfig, AUTO) + + PB_BIND(Config_DisplayConfig, Config_DisplayConfig, AUTO) @@ -39,3 +42,4 @@ PB_BIND(Config_BluetoothConfig, Config_BluetoothConfig, AUTO) + diff --git a/src/mesh/generated/config.pb.h b/src/mesh/generated/config.pb.h index 940771580..e98aff60a 100644 --- a/src/mesh/generated/config.pb.h +++ b/src/mesh/generated/config.pb.h @@ -37,6 +37,11 @@ typedef enum _Config_NetworkConfig_WiFiMode { Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN = 2 } Config_NetworkConfig_WiFiMode; +typedef enum _Config_NetworkConfig_EthMode { + Config_NetworkConfig_EthMode_DHCP = 0, + Config_NetworkConfig_EthMode_STATIC = 1 +} Config_NetworkConfig_EthMode; + typedef enum _Config_DisplayConfig_GpsCoordinateFormat { Config_DisplayConfig_GpsCoordinateFormat_DEC = 0, Config_DisplayConfig_GpsCoordinateFormat_DMS = 1, @@ -122,13 +127,12 @@ typedef struct _Config_LoRaConfig { uint32_t ignore_incoming[3]; } Config_LoRaConfig; -typedef struct _Config_NetworkConfig { - bool wifi_enabled; - Config_NetworkConfig_WiFiMode wifi_mode; - char wifi_ssid[33]; - char wifi_psk[64]; - char ntp_server[33]; -} Config_NetworkConfig; +typedef struct _Config_NetworkConfig_NetworkConfig { + uint32_t ip; + uint32_t gateway; + uint32_t subnet; + uint32_t dns; +} Config_NetworkConfig_NetworkConfig; typedef struct _Config_PositionConfig { uint32_t position_broadcast_secs; @@ -151,6 +155,18 @@ typedef struct _Config_PowerConfig { uint32_t min_wake_secs; } Config_PowerConfig; +typedef struct _Config_NetworkConfig { + bool wifi_enabled; + Config_NetworkConfig_WiFiMode wifi_mode; + char wifi_ssid[33]; + char wifi_psk[64]; + char ntp_server[33]; + bool eth_enabled; + Config_NetworkConfig_EthMode eth_mode; + bool has_eth_config; + Config_NetworkConfig_NetworkConfig eth_config; +} Config_NetworkConfig; + typedef struct _Config { pb_size_t which_payload_variant; union { @@ -178,6 +194,10 @@ typedef struct _Config { #define _Config_NetworkConfig_WiFiMode_MAX Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN #define _Config_NetworkConfig_WiFiMode_ARRAYSIZE ((Config_NetworkConfig_WiFiMode)(Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN+1)) +#define _Config_NetworkConfig_EthMode_MIN Config_NetworkConfig_EthMode_DHCP +#define _Config_NetworkConfig_EthMode_MAX Config_NetworkConfig_EthMode_STATIC +#define _Config_NetworkConfig_EthMode_ARRAYSIZE ((Config_NetworkConfig_EthMode)(Config_NetworkConfig_EthMode_STATIC+1)) + #define _Config_DisplayConfig_GpsCoordinateFormat_MIN Config_DisplayConfig_GpsCoordinateFormat_DEC #define _Config_DisplayConfig_GpsCoordinateFormat_MAX Config_DisplayConfig_GpsCoordinateFormat_OSGR #define _Config_DisplayConfig_GpsCoordinateFormat_ARRAYSIZE ((Config_DisplayConfig_GpsCoordinateFormat)(Config_DisplayConfig_GpsCoordinateFormat_OSGR+1)) @@ -208,7 +228,8 @@ extern "C" { #define Config_DeviceConfig_init_default {_Config_DeviceConfig_Role_MIN, 0, 0} #define Config_PositionConfig_init_default {0, 0, 0, 0, 0, 0, 0} #define Config_PowerConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0} -#define Config_NetworkConfig_init_default {0, _Config_NetworkConfig_WiFiMode_MIN, "", "", ""} +#define Config_NetworkConfig_init_default {0, _Config_NetworkConfig_WiFiMode_MIN, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_NetworkConfig_init_default} +#define Config_NetworkConfig_NetworkConfig_init_default {0, 0, 0, 0} #define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN} #define Config_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}} #define Config_BluetoothConfig_init_default {0, _Config_BluetoothConfig_PairingMode_MIN, 0} @@ -216,7 +237,8 @@ extern "C" { #define Config_DeviceConfig_init_zero {_Config_DeviceConfig_Role_MIN, 0, 0} #define Config_PositionConfig_init_zero {0, 0, 0, 0, 0, 0, 0} #define Config_PowerConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0} -#define Config_NetworkConfig_init_zero {0, _Config_NetworkConfig_WiFiMode_MIN, "", "", ""} +#define Config_NetworkConfig_init_zero {0, _Config_NetworkConfig_WiFiMode_MIN, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_NetworkConfig_init_zero} +#define Config_NetworkConfig_NetworkConfig_init_zero {0, 0, 0, 0} #define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN} #define Config_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}} #define Config_BluetoothConfig_init_zero {0, _Config_BluetoothConfig_PairingMode_MIN, 0} @@ -246,11 +268,10 @@ extern "C" { #define Config_LoRaConfig_tx_power_tag 10 #define Config_LoRaConfig_channel_num_tag 11 #define Config_LoRaConfig_ignore_incoming_tag 103 -#define Config_NetworkConfig_wifi_enabled_tag 1 -#define Config_NetworkConfig_wifi_mode_tag 2 -#define Config_NetworkConfig_wifi_ssid_tag 3 -#define Config_NetworkConfig_wifi_psk_tag 4 -#define Config_NetworkConfig_ntp_server_tag 5 +#define Config_NetworkConfig_NetworkConfig_ip_tag 1 +#define Config_NetworkConfig_NetworkConfig_gateway_tag 2 +#define Config_NetworkConfig_NetworkConfig_subnet_tag 3 +#define Config_NetworkConfig_NetworkConfig_dns_tag 4 #define Config_PositionConfig_position_broadcast_secs_tag 1 #define Config_PositionConfig_position_broadcast_smart_enabled_tag 2 #define Config_PositionConfig_fixed_position_tag 3 @@ -266,6 +287,14 @@ extern "C" { #define Config_PowerConfig_sds_secs_tag 6 #define Config_PowerConfig_ls_secs_tag 7 #define Config_PowerConfig_min_wake_secs_tag 8 +#define Config_NetworkConfig_wifi_enabled_tag 1 +#define Config_NetworkConfig_wifi_mode_tag 2 +#define Config_NetworkConfig_wifi_ssid_tag 3 +#define Config_NetworkConfig_wifi_psk_tag 4 +#define Config_NetworkConfig_ntp_server_tag 5 +#define Config_NetworkConfig_eth_enabled_tag 6 +#define Config_NetworkConfig_eth_mode_tag 7 +#define Config_NetworkConfig_eth_config_tag 8 #define Config_device_tag 1 #define Config_position_tag 2 #define Config_power_tag 3 @@ -328,9 +357,21 @@ X(a, STATIC, SINGULAR, BOOL, wifi_enabled, 1) \ X(a, STATIC, SINGULAR, UENUM, wifi_mode, 2) \ X(a, STATIC, SINGULAR, STRING, wifi_ssid, 3) \ X(a, STATIC, SINGULAR, STRING, wifi_psk, 4) \ -X(a, STATIC, SINGULAR, STRING, ntp_server, 5) +X(a, STATIC, SINGULAR, STRING, ntp_server, 5) \ +X(a, STATIC, SINGULAR, BOOL, eth_enabled, 6) \ +X(a, STATIC, SINGULAR, UENUM, eth_mode, 7) \ +X(a, STATIC, OPTIONAL, MESSAGE, eth_config, 8) #define Config_NetworkConfig_CALLBACK NULL #define Config_NetworkConfig_DEFAULT NULL +#define Config_NetworkConfig_eth_config_MSGTYPE Config_NetworkConfig_NetworkConfig + +#define Config_NetworkConfig_NetworkConfig_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, FIXED32, ip, 1) \ +X(a, STATIC, SINGULAR, FIXED32, gateway, 2) \ +X(a, STATIC, SINGULAR, FIXED32, subnet, 3) \ +X(a, STATIC, SINGULAR, FIXED32, dns, 4) +#define Config_NetworkConfig_NetworkConfig_CALLBACK NULL +#define Config_NetworkConfig_NetworkConfig_DEFAULT NULL #define Config_DisplayConfig_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, UINT32, screen_on_secs, 1) \ @@ -370,6 +411,7 @@ extern const pb_msgdesc_t Config_DeviceConfig_msg; extern const pb_msgdesc_t Config_PositionConfig_msg; extern const pb_msgdesc_t Config_PowerConfig_msg; extern const pb_msgdesc_t Config_NetworkConfig_msg; +extern const pb_msgdesc_t Config_NetworkConfig_NetworkConfig_msg; extern const pb_msgdesc_t Config_DisplayConfig_msg; extern const pb_msgdesc_t Config_LoRaConfig_msg; extern const pb_msgdesc_t Config_BluetoothConfig_msg; @@ -380,6 +422,7 @@ extern const pb_msgdesc_t Config_BluetoothConfig_msg; #define Config_PositionConfig_fields &Config_PositionConfig_msg #define Config_PowerConfig_fields &Config_PowerConfig_msg #define Config_NetworkConfig_fields &Config_NetworkConfig_msg +#define Config_NetworkConfig_NetworkConfig_fields &Config_NetworkConfig_NetworkConfig_msg #define Config_DisplayConfig_fields &Config_DisplayConfig_msg #define Config_LoRaConfig_fields &Config_LoRaConfig_msg #define Config_BluetoothConfig_fields &Config_BluetoothConfig_msg @@ -389,10 +432,11 @@ extern const pb_msgdesc_t Config_BluetoothConfig_msg; #define Config_DeviceConfig_size 6 #define Config_DisplayConfig_size 20 #define Config_LoRaConfig_size 68 -#define Config_NetworkConfig_size 137 +#define Config_NetworkConfig_NetworkConfig_size 20 +#define Config_NetworkConfig_size 163 #define Config_PositionConfig_size 30 #define Config_PowerConfig_size 43 -#define Config_size 140 +#define Config_size 166 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/localonly.pb.h b/src/mesh/generated/localonly.pb.h index d4c5fb012..8e4199d48 100644 --- a/src/mesh/generated/localonly.pb.h +++ b/src/mesh/generated/localonly.pb.h @@ -144,7 +144,7 @@ extern const pb_msgdesc_t LocalModuleConfig_msg; #define LocalModuleConfig_fields &LocalModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define LocalConfig_size 335 +#define LocalConfig_size 361 #define LocalModuleConfig_size 270 #ifdef __cplusplus diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index ee72ff504..d4407a2f1 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -352,7 +352,7 @@ typedef struct _MyNodeInfo { /* a gps position */ typedef struct _Position { - /* The new preferred location encoding, divide by 1e-7 to get degrees + /* The new preferred location encoding, multiply by 1e-7 to get degrees in floating point */ int32_t latitude_i; /* TODO: REPLACE */ From f3fee5f4fbe5546047c8e3ce1acefc5d93ca8aa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 22 Oct 2022 16:29:50 +0200 Subject: [PATCH 008/133] first murmurs of ethernet support --- arch/esp32/esp32.ini | 2 +- arch/esp32/esp32s3.ini | 2 +- src/RedirectablePrint.cpp | 2 -- src/configuration.h | 3 ++ src/main.cpp | 4 +++ src/mesh/eth/ethClient.cpp | 55 +++++++++++++++++++++++++++++++++ src/mesh/eth/ethClient.h | 8 +++++ src/network-stubs.cpp | 27 ++++++++++++++++ src/wifi-stubs.cpp | 19 ------------ variants/rak4631/platformio.ini | 1 + variants/rak4631/variant.h | 2 ++ 11 files changed, 102 insertions(+), 23 deletions(-) create mode 100644 src/mesh/eth/ethClient.cpp create mode 100644 src/mesh/eth/ethClient.h create mode 100644 src/network-stubs.cpp delete mode 100644 src/wifi-stubs.cpp diff --git a/arch/esp32/esp32.ini b/arch/esp32/esp32.ini index 798fb3d5a..1b57ffb8b 100644 --- a/arch/esp32/esp32.ini +++ b/arch/esp32/esp32.ini @@ -3,7 +3,7 @@ extends = arduino_base platform = platformio/espressif32@^5.2.0 build_src_filter = - ${arduino_base.build_src_filter} - - - + ${arduino_base.build_src_filter} - - - - upload_speed = 921600 debug_init_break = tbreak setup monitor_filters = esp32_exception_decoder diff --git a/arch/esp32/esp32s3.ini b/arch/esp32/esp32s3.ini index 8dc6d0b62..286d9950e 100644 --- a/arch/esp32/esp32s3.ini +++ b/arch/esp32/esp32s3.ini @@ -2,7 +2,7 @@ extends = arduino_base platform = platformio/espressif32@^5.2.0 build_src_filter = - ${arduino_base.build_src_filter} - - - + ${arduino_base.build_src_filter} - - - - upload_speed = 961200 monitor_speed = 115200 debug_init_break = tbreak setup diff --git a/src/RedirectablePrint.cpp b/src/RedirectablePrint.cpp index 0d14b4562..66c83171a 100644 --- a/src/RedirectablePrint.cpp +++ b/src/RedirectablePrint.cpp @@ -47,8 +47,6 @@ size_t RedirectablePrint::vprintf(const char *format, va_list arg) size_t len = vsnprintf(printBuf, sizeof(printBuf), format, copy); va_end(copy); - if (len < 0) return 0; - // If the resulting string is longer than sizeof(printBuf)-1 characters, the remaining characters are still counted for the return value if (len > sizeof(printBuf) - 1) { diff --git a/src/configuration.h b/src/configuration.h index 9374c29d4..6ad5f8ff9 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -142,6 +142,9 @@ along with this program. If not, see . #ifndef HAS_WIFI #define HAS_WIFI 0 #endif +#ifndef HAS_ETHERNET + #define ETHERNET 0 +#endif #ifndef HAS_SCREEN #define HAS_SCREEN 0 #endif diff --git a/src/main.cpp b/src/main.cpp index 104731ef3..2e231dec3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,6 +30,7 @@ // #include #include "mesh/http/WiFiAPClient.h" +#include "mesh/eth/ethClient.h" #ifdef ARCH_ESP32 #include "mesh/http/WebServer.h" @@ -440,6 +441,9 @@ void setup() // Initialize Wifi initWifi(forceSoftAP); + // Initialize Ethernet + initEthernet(); + #ifdef ARCH_ESP32 // Start web server thread. webServerThread = new WebServerThread(); diff --git a/src/mesh/eth/ethClient.cpp b/src/mesh/eth/ethClient.cpp new file mode 100644 index 000000000..92c1997e4 --- /dev/null +++ b/src/mesh/eth/ethClient.cpp @@ -0,0 +1,55 @@ +#include "mesh/eth/ethClient.h" +#include "NodeDB.h" +#include +#include +#include "target_specific.h" + +// Startup Ethernet +bool initEthernet() +{ + if (config.network.eth_enabled) { + + Ethernet.init( SS ); + + uint8_t mac[6]; + + getMacAddr(mac); // FIXME use the BLE MAC for now... + + if (Ethernet.hardwareStatus() == EthernetNoHardware) { + DEBUG_MSG("Ethernet shield was not found.\n"); + } else if (Ethernet.linkStatus() == LinkOFF) { + DEBUG_MSG("Ethernet cable is not connected.\n"); + } else if (config.network.eth_mode == Config_NetworkConfig_EthMode_DHCP) { + DEBUG_MSG("starting Ethernet DHCP\n"); + if (Ethernet.begin(mac) == 0) { + DEBUG_MSG("DHCP failed\n"); + } else{ + DEBUG_MSG("DHCP assigned IP %s\n",Ethernet.localIP()); + } + } else if (config.network.eth_mode == Config_NetworkConfig_EthMode_STATIC) { + DEBUG_MSG("starting Ethernet Static\n"); + Ethernet.begin(mac, config.network.eth_config.ip, config.network.eth_config.dns, config.network.eth_config.subnet); + } else { + DEBUG_MSG("Ethernet Disabled\n"); + return false; + } + return true; + + } else { + + DEBUG_MSG("Not using Ethernet\n"); + return false; + } +} + +bool isEthernetAvailable() { + if (!config.network.eth_enabled) { + return false; + } else if (Ethernet.hardwareStatus() == EthernetNoHardware) { + return false; + } else if (Ethernet.linkStatus() == LinkOFF) { + return false; + } else { + return true; + } +} \ No newline at end of file diff --git a/src/mesh/eth/ethClient.h b/src/mesh/eth/ethClient.h new file mode 100644 index 000000000..9e1745b9f --- /dev/null +++ b/src/mesh/eth/ethClient.h @@ -0,0 +1,8 @@ +#pragma once + +#include "configuration.h" +#include +#include + +bool initEthernet(); +bool isEthernetAvailable(); diff --git a/src/network-stubs.cpp b/src/network-stubs.cpp new file mode 100644 index 000000000..b7b4c146f --- /dev/null +++ b/src/network-stubs.cpp @@ -0,0 +1,27 @@ +#include "configuration.h" + +#if (HAS_WIFI == 0) + +bool initWifi(bool forceSoftAP) { + return false; +} + +void deinitWifi() {} + +bool isWifiAvailable() { + return false; +} + +#endif + +#if (HAS_ETHERNET == 0) + +bool initEthernet() { + return false; +} + +bool isEthernetAvailable() { + return false; +} + +#endif diff --git a/src/wifi-stubs.cpp b/src/wifi-stubs.cpp deleted file mode 100644 index faf58b620..000000000 --- a/src/wifi-stubs.cpp +++ /dev/null @@ -1,19 +0,0 @@ -//#include "mesh/wifi/WebServer.h" -#include "configuration.h" - -#ifndef ARCH_ESP32 - -//#include "mesh/wifi/WiFiAPClient.h" - -bool initWifi(bool forceSoftAP) { - return false; -} - -void deinitWifi() {} - -bool isWifiAvailable() -{ - return false; -} - -#endif diff --git a/variants/rak4631/platformio.ini b/variants/rak4631/platformio.ini index d8e2ba3e9..247cef6f6 100644 --- a/variants/rak4631/platformio.ini +++ b/variants/rak4631/platformio.ini @@ -7,6 +7,7 @@ build_src_filter = ${nrf52_base.build_src_filter} +<../variants/rak4631> lib_deps = ${nrf52840_base.lib_deps} melopero/Melopero RV3028@^1.1.0 + beegee-tokyo/RAK13800-W5100S@^1.0.1 debug_tool = jlink ; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) ;upload_protocol = jlink \ No newline at end of file diff --git a/variants/rak4631/variant.h b/variants/rak4631/variant.h index 3648b8510..902165333 100644 --- a/variants/rak4631/variant.h +++ b/variants/rak4631/variant.h @@ -226,6 +226,8 @@ static const uint8_t SCK = PIN_SPI_SCK; #define HAS_RTC 1 +#define HAS_ETHERNET 1 + #ifdef __cplusplus } #endif From 103c82bc2cfb5ef139244c7f6389366c0340aff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 22 Oct 2022 16:42:36 +0200 Subject: [PATCH 009/133] only build on vanilla RAK4631 for now. --- arch/nrf52/nrf52.ini | 2 +- arch/portduino/portduino.ini | 3 ++- arch/rp2040/rp2040.ini | 2 +- arch/stm32/stm32wl5e.ini | 2 +- variants/rak4631/platformio.ini | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/nrf52/nrf52.ini b/arch/nrf52/nrf52.ini index f4e2af236..46f946530 100644 --- a/arch/nrf52/nrf52.ini +++ b/arch/nrf52/nrf52.ini @@ -8,7 +8,7 @@ build_flags = ${arduino_base.build_flags} -Wno-unused-variable -Isrc/platform/nrf52 build_src_filter = - ${arduino_base.build_src_filter} - - - - - - - - + ${arduino_base.build_src_filter} - - - - - - - - - lib_ignore = BluetoothOTA diff --git a/arch/portduino/portduino.ini b/arch/portduino/portduino.ini index eb65322d4..b61071007 100644 --- a/arch/portduino/portduino.ini +++ b/arch/portduino/portduino.ini @@ -7,7 +7,8 @@ build_src_filter = - - - - - + - + - - - +<../variants/portduino> diff --git a/arch/rp2040/rp2040.ini b/arch/rp2040/rp2040.ini index 9eea340bf..8b7bdbff9 100644 --- a/arch/rp2040/rp2040.ini +++ b/arch/rp2040/rp2040.ini @@ -10,7 +10,7 @@ build_flags = -D__PLAT_RP2040__ # -D _POSIX_THREADS build_src_filter = - ${arduino_base.build_src_filter} - - - - - - - - + ${arduino_base.build_src_filter} - - - - - - - - - lib_ignore = BluetoothOTA lib_deps = diff --git a/arch/stm32/stm32wl5e.ini b/arch/stm32/stm32wl5e.ini index d13750fdb..3fc7583ad 100644 --- a/arch/stm32/stm32wl5e.ini +++ b/arch/stm32/stm32wl5e.ini @@ -10,7 +10,7 @@ build_flags = # Arduino/PlatformIO framework-arduinoststm32 package does not presently have SUBGHZSPI support # -DPIN_SPI_MOSI=PINSUBGHZSPIMOSI -DPIN_SPI_MISO=PINSUBGHZSPIMISO -DPIN_SPI_SCK=PINSUBGHZSPISCK build_src_filter = - ${arduino_base.build_src_filter} - - - - - - - - - - - - - + ${arduino_base.build_src_filter} - - - - - - - - - - - - - - lib_deps = ${env.lib_deps} https://github.com/kokke/tiny-AES-c.git#f06ac37fc31dfdaca2e0d9bec83f90d5663c319b diff --git a/variants/rak4631/platformio.ini b/variants/rak4631/platformio.ini index 247cef6f6..3d4e46d30 100644 --- a/variants/rak4631/platformio.ini +++ b/variants/rak4631/platformio.ini @@ -3,7 +3,7 @@ extends = nrf52840_base board = wiscore_rak4631 build_flags = ${nrf52840_base.build_flags} -Ivariants/rak4631 -D RAK_4631 -build_src_filter = ${nrf52_base.build_src_filter} +<../variants/rak4631> +build_src_filter = ${nrf52_base.build_src_filter} +<../variants/rak4631> + lib_deps = ${nrf52840_base.lib_deps} melopero/Melopero RV3028@^1.1.0 From 1e97dcbb4c35b03336f5840eac5d0c0c20dcdca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 22 Oct 2022 16:53:57 +0200 Subject: [PATCH 010/133] Portduino is always special. --- src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 2e231dec3..5d73e0252 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -438,11 +438,13 @@ void setup() mqttInit(); #endif +#ifndef ARCH_PORTDUINO // Initialize Wifi initWifi(forceSoftAP); // Initialize Ethernet initEthernet(); +#endif #ifdef ARCH_ESP32 // Start web server thread. From 2c1bbf1ac6dcddba89b70764276fe94b91ee6b73 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 22 Oct 2022 15:42:21 -0500 Subject: [PATCH 011/133] When we init default, set use_preset to true (#1843) --- src/mesh/Channels.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/Channels.cpp b/src/mesh/Channels.cpp index 200184720..f7fc35929 100644 --- a/src/mesh/Channels.cpp +++ b/src/mesh/Channels.cpp @@ -79,7 +79,7 @@ void Channels::initDefaultChannel(ChannelIndex chIndex) Config_LoRaConfig &loraConfig = config.lora; loraConfig.modem_preset = Config_LoRaConfig_ModemPreset_LONG_FAST; // Default to Long Range & Fast - + loraConfig.use_preset = true; loraConfig.tx_power = 0; // default uint8_t defaultpskIndex = 1; channelSettings.psk.bytes[0] = defaultpskIndex; From 568434d0fa4556cad0472285f252d464a2d07453 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 22 Oct 2022 18:51:22 -0500 Subject: [PATCH 012/133] Use preset wiring (#1845) * When we init default, set use_preset to true * Only use modem_preset when we use_preset * When we init default, set use_preset to true (#1843) (#1844) --- src/mesh/RadioInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 07bb01108..81821ac19 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -361,7 +361,7 @@ void RadioInterface::applyModemConfig() // Set up default configuration // No Sync Words in LORA mode Config_LoRaConfig &loraConfig = config.lora; - if (loraConfig.spread_factor == 0) { + if (loraConfig.use_preset) { switch (loraConfig.modem_preset) { case Config_LoRaConfig_ModemPreset_SHORT_FAST: From 41267a42f77e3e863cc2eddbf93e2197bf652ab7 Mon Sep 17 00:00:00 2001 From: Mykhailo Lesyk Date: Sat, 22 Oct 2022 17:55:34 -0700 Subject: [PATCH 013/133] [rak4630] enable 3.3v periphery before scan for i2c devices (#1847) Co-authored-by: Ben Meadors --- src/main.cpp | 6 ++++++ variants/rak4631/variant.h | 5 ++++- variants/rak4631_epaper/variant.h | 5 ++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 104731ef3..d40a1bdf0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -242,6 +242,12 @@ void setup() delay(1); #endif +#ifdef RAK4630 + // We need to enable 3.3V periphery in order to scan it + pinMode(PIN_3V3_EN, OUTPUT); + digitalWrite(PIN_3V3_EN, 1); +#endif + // We need to scan here to decide if we have a screen for nodeDB.init() scanI2Cdevice(); #ifdef RAK4630 diff --git a/variants/rak4631/variant.h b/variants/rak4631/variant.h index 3648b8510..b42163fbb 100644 --- a/variants/rak4631/variant.h +++ b/variants/rak4631/variant.h @@ -185,6 +185,9 @@ static const uint8_t SCK = PIN_SPI_SCK; #define SX126X_RXEN (37) #define SX126X_E22 // DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3 +// enables 3.3V periphery like GPS or IO Module +#define PIN_3V3_EN (34) + // RAK1910 GPS module // If using the wisblock GPS module and pluged into Port A on WisBlock base // IO1 is hooked to PPS (pin 12 on header) = gpio 17 @@ -192,7 +195,7 @@ static const uint8_t SCK = PIN_SPI_SCK; // Therefore must be 1 to keep peripherals powered // Power is on the controllable 3V3_S rail // #define PIN_GPS_RESET (34) -#define PIN_GPS_EN (34) +#define PIN_GPS_EN PIN_3V3_EN #define PIN_GPS_PPS (17) // Pulse per second input from the GPS #define GPS_RX_PIN PIN_SERIAL1_RX diff --git a/variants/rak4631_epaper/variant.h b/variants/rak4631_epaper/variant.h index df68dac41..cf1b8b07d 100644 --- a/variants/rak4631_epaper/variant.h +++ b/variants/rak4631_epaper/variant.h @@ -185,6 +185,9 @@ static const uint8_t SCK = PIN_SPI_SCK; #define SX126X_RXEN (37) #define SX126X_E22 // DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3 +// enables 3.3V periphery like GPS or IO Module +#define PIN_3V3_EN (34) + // RAK1910 GPS module // If using the wisblock GPS module and pluged into Port A on WisBlock base // IO1 is hooked to PPS (pin 12 on header) = gpio 17 @@ -192,7 +195,7 @@ static const uint8_t SCK = PIN_SPI_SCK; // Therefore must be 1 to keep peripherals powered // Power is on the controllable 3V3_S rail // #define PIN_GPS_RESET (34) -#define PIN_GPS_EN (34) +#define PIN_GPS_EN PIN_3V3_EN #define PIN_GPS_PPS (17) // Pulse per second input from the GPS #define GPS_RX_PIN PIN_SERIAL1_RX From c47401d72935959d62636d7623d5a0f2ab2946c9 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 24 Oct 2022 07:16:13 -0500 Subject: [PATCH 014/133] Remove setting fixed pin on double-click (#1851) * Remove setting fixed pin on double-click * Remove disablePin method --- src/ButtonThread.h | 4 +--- src/nimble/NimbleBluetooth.cpp | 29 ++--------------------------- src/nimble/NimbleBluetooth.h | 1 - 3 files changed, 3 insertions(+), 31 deletions(-) diff --git a/src/ButtonThread.h b/src/ButtonThread.h index af0a8e1ec..4114679ad 100644 --- a/src/ButtonThread.h +++ b/src/ButtonThread.h @@ -159,9 +159,7 @@ class ButtonThread : public concurrency::OSThread static void userButtonDoublePressed() { -#ifdef ARCH_ESP32 - disablePin(); -#elif defined(USE_EINK) +#if defined(USE_EINK) digitalWrite(PIN_EINK_EN, digitalRead(PIN_EINK_EN) == LOW); #endif } diff --git a/src/nimble/NimbleBluetooth.cpp b/src/nimble/NimbleBluetooth.cpp index b2a4e3970..6dabbc36f 100644 --- a/src/nimble/NimbleBluetooth.cpp +++ b/src/nimble/NimbleBluetooth.cpp @@ -71,12 +71,8 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks { virtual uint32_t onPassKeyRequest() { uint32_t passkey = config.bluetooth.fixed_pin; - - if (doublepressed > 0 && (doublepressed + (30 * 1000)) > millis()) { - DEBUG_MSG("User has set BLE pairing mode to fixed-pin\n"); - config.bluetooth.mode = Config_BluetoothConfig_PairingMode_FIXED_PIN; - nodeDB.saveToDisk(SEGMENT_CONFIG); - } else if (config.bluetooth.mode == Config_BluetoothConfig_PairingMode_RANDOM_PIN) { + + if (config.bluetooth.mode == Config_BluetoothConfig_PairingMode_RANDOM_PIN) { DEBUG_MSG("Using random passkey\n"); // This is the passkey to be entered on peer - we pick a number >100,000 to ensure 6 digits passkey = random(100000, 999999); @@ -202,24 +198,3 @@ void clearNVS() ESP.restart(); #endif } - -void disablePin() -{ - DEBUG_MSG("User Override, disabling bluetooth pin requirement\n"); - // keep track of when it was pressed, so we know it was within X seconds - - // Flash the LED - setLed(true); - delay(100); - setLed(false); - delay(100); - setLed(true); - delay(100); - setLed(false); - delay(100); - setLed(true); - delay(100); - setLed(false); - - doublepressed = millis(); -} diff --git a/src/nimble/NimbleBluetooth.h b/src/nimble/NimbleBluetooth.h index 5592b6d69..ec0fe0841 100644 --- a/src/nimble/NimbleBluetooth.h +++ b/src/nimble/NimbleBluetooth.h @@ -15,4 +15,3 @@ class NimbleBluetooth void setBluetoothEnable(bool on); void clearNVS(); -void disablePin(); From 761804b17a5021c7cb67e07a3e89f0a0c15f72e0 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 24 Oct 2022 11:03:54 -0500 Subject: [PATCH 015/133] Send network ping on triple-click (#1852) * Send network ping on multi-press * Refresh myNodeInfo before sending * Cleanup and screen print * Update ButtonThread.h --- src/ButtonThread.h | 9 +++------ src/nimble/NimbleBluetooth.cpp | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/ButtonThread.h b/src/ButtonThread.h index 4114679ad..c1fd770bc 100644 --- a/src/ButtonThread.h +++ b/src/ButtonThread.h @@ -166,12 +166,9 @@ class ButtonThread : public concurrency::OSThread static void userButtonMultiPressed() { -#ifdef ARCH_ESP32 - clearNVS(); -#endif -#ifdef ARCH_NRF52 - clearBonds(); -#endif + screen->print("Sent ad-hoc ping\n"); + service.refreshMyNodeInfo(); + service.sendNetworkPing(NODENUM_BROADCAST, true); } static void userButtonPressedLongStart() diff --git a/src/nimble/NimbleBluetooth.cpp b/src/nimble/NimbleBluetooth.cpp index 6dabbc36f..c74c73316 100644 --- a/src/nimble/NimbleBluetooth.cpp +++ b/src/nimble/NimbleBluetooth.cpp @@ -12,7 +12,6 @@ NimBLECharacteristic *fromNumCharacteristic; NimBLEServer *bleServer; static bool passkeyShowing; -static uint32_t doublepressed; class BluetoothPhoneAPI : public PhoneAPI { From 338c9c1e0c232143ab112b60e791f4850e336987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Tue, 25 Oct 2022 11:53:22 +0200 Subject: [PATCH 016/133] Remove Captive Portal and SoftAP Mode --- src/graphics/Screen.cpp | 40 +--------- src/main.cpp | 10 +-- src/mesh/http/ContentHandler.cpp | 20 ++--- src/mesh/http/WebServer.cpp | 4 - src/mesh/http/WiFiAPClient.cpp | 125 +++++++------------------------ src/mesh/http/WiFiAPClient.h | 7 +- 6 files changed, 41 insertions(+), 165 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 0f6c96f0f..4ddbe10d4 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -1390,7 +1390,6 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i { #if HAS_WIFI const char *wifiName = config.network.wifi_ssid; - const char *wifiPsw = config.network.wifi_psk; displayedNodeNum = 0; // Not currently showing a node pane @@ -1399,11 +1398,7 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i // The coordinates define the left starting point of the text display->setTextAlignment(TEXT_ALIGN_LEFT); - if (isSoftAPForced()) { - display->drawString(x, y, String("WiFi: Software AP (Admin)")); - } else if (config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT || config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN) { - display->drawString(x, y, String("WiFi: Software AP")); - } else if (WiFi.status() != WL_CONNECTED) { + if (WiFi.status() != WL_CONNECTED) { display->drawString(x, y, String("WiFi: Not Connected")); } else { display->drawString(x, y, String("WiFi: Connected")); @@ -1424,25 +1419,14 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i - WL_NO_SHIELD: assigned when no WiFi shield is present; */ - if (WiFi.status() == WL_CONNECTED || isSoftAPForced() || config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT || config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN) { - if (config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT || config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN || isSoftAPForced()) { - display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "IP: " + String(WiFi.softAPIP().toString().c_str())); - - // Number of connections to the AP. Default max for the esp32 is 4 - display->drawString(x + SCREEN_WIDTH - display->getStringWidth("(" + String(WiFi.softAPgetStationNum()) + "/4)"), - y + FONT_HEIGHT_SMALL * 1, "(" + String(WiFi.softAPgetStationNum()) + "/4)"); - } else { - display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "IP: " + String(WiFi.localIP().toString().c_str())); - } - + if (WiFi.status() == WL_CONNECTED) { + display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "IP: " + String(WiFi.localIP().toString().c_str())); } else if (WiFi.status() == WL_NO_SSID_AVAIL) { display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "SSID Not Found"); } else if (WiFi.status() == WL_CONNECTION_LOST) { display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "Connection Lost"); } else if (WiFi.status() == WL_CONNECT_FAILED) { display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "Connection Failed"); - //} else if (WiFi.status() == WL_DISCONNECTED) { - // display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "Disconnected"); } else if (WiFi.status() == WL_IDLE_STATUS) { display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "Idle ... Reconnecting"); } else { @@ -1509,24 +1493,8 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i } } - if (isSoftAPForced()) { - if ((millis() / 10000) % 2) { - display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: meshtasticAdmin"); - } else { - display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "PWD: 12345678"); - } + display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName)); - } else { - if (config.network.wifi_mode== Config_NetworkConfig_WiFiMode_ACCESS_POINT || config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN) { - if ((millis() / 10000) % 2) { - display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName)); - } else { - display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "PWD: " + String(wifiPsw)); - } - } else { - display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName)); - } - } display->drawString(x, y + FONT_HEIGHT_SMALL * 3, "http://meshtastic.local"); /* Display a heartbeat pixel that blinks every time the frame is redrawn */ diff --git a/src/main.cpp b/src/main.cpp index d40a1bdf0..69c880e70 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -191,8 +191,6 @@ void setup() digitalWrite(RESET_OLED, 1); #endif - bool forceSoftAP = 0; - #ifdef BUTTON_PIN #ifdef ARCH_ESP32 @@ -205,12 +203,6 @@ void setup() delay(10); #endif - // BUTTON_PIN is pulled high by a 12k resistor. - if (!digitalRead(BUTTON_PIN)) { - forceSoftAP = 1; - DEBUG_MSG("Setting forceSoftAP = 1\n"); - } - #endif #endif @@ -444,7 +436,7 @@ void setup() #endif // Initialize Wifi - initWifi(forceSoftAP); + initWifi(); #ifdef ARCH_ESP32 // Start web server thread. diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index 50e82f58f..ddc67e16d 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -75,8 +75,8 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer) ResourceNode *nodeAPIv1ToRadio = new ResourceNode("/api/v1/toradio", "PUT", &handleAPIv1ToRadio); ResourceNode *nodeAPIv1FromRadio = new ResourceNode("/api/v1/fromradio", "GET", &handleAPIv1FromRadio); - ResourceNode *nodeHotspotApple = new ResourceNode("/hotspot-detect.html", "GET", &handleHotspot); - ResourceNode *nodeHotspotAndroid = new ResourceNode("/generate_204", "GET", &handleHotspot); +// ResourceNode *nodeHotspotApple = new ResourceNode("/hotspot-detect.html", "GET", &handleHotspot); +// ResourceNode *nodeHotspotAndroid = new ResourceNode("/generate_204", "GET", &handleHotspot); ResourceNode *nodeAdmin = new ResourceNode("/admin", "GET", &handleAdmin); // ResourceNode *nodeAdminSettings = new ResourceNode("/admin/settings", "GET", &handleAdminSettings); @@ -100,8 +100,8 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer) secureServer->registerNode(nodeAPIv1ToRadioOptions); secureServer->registerNode(nodeAPIv1ToRadio); secureServer->registerNode(nodeAPIv1FromRadio); - secureServer->registerNode(nodeHotspotApple); - secureServer->registerNode(nodeHotspotAndroid); + // secureServer->registerNode(nodeHotspotApple); + // secureServer->registerNode(nodeHotspotAndroid); secureServer->registerNode(nodeRestart); secureServer->registerNode(nodeFormUpload); secureServer->registerNode(nodeJsonScanNetworks); @@ -121,8 +121,8 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer) insecureServer->registerNode(nodeAPIv1ToRadioOptions); insecureServer->registerNode(nodeAPIv1ToRadio); insecureServer->registerNode(nodeAPIv1FromRadio); - insecureServer->registerNode(nodeHotspotApple); - insecureServer->registerNode(nodeHotspotAndroid); + // insecureServer->registerNode(nodeHotspotApple); + // insecureServer->registerNode(nodeHotspotAndroid); insecureServer->registerNode(nodeRestart); insecureServer->registerNode(nodeFormUpload); insecureServer->registerNode(nodeJsonScanNetworks); @@ -620,12 +620,8 @@ void handleReport(HTTPRequest *req, HTTPResponse *res) }; // data->wifi - String ipStr; - if (config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT || config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN || isSoftAPForced()) { - ipStr = String(WiFi.softAPIP().toString()); - } else { - ipStr = String(WiFi.localIP().toString()); - } + String ipStr = String(WiFi.localIP().toString()); + Json jsonObjWifi = Json::object{{"rssi", String(WiFi.RSSI())}, {"ip", ipStr.c_str()}}; // data->memory diff --git a/src/mesh/http/WebServer.cpp b/src/mesh/http/WebServer.cpp index 48e084ed2..c1844b0cb 100644 --- a/src/mesh/http/WebServer.cpp +++ b/src/mesh/http/WebServer.cpp @@ -55,10 +55,6 @@ static void handleWebResponse() if (isWifiAvailable()) { if (isWebServerReady) { - // We're going to handle the DNS responder here so it - // will be ignored by the NRF boards. - handleDNSResponse(); - if (secureServer) secureServer->loop(); insecureServer->loop(); diff --git a/src/mesh/http/WiFiAPClient.cpp b/src/mesh/http/WiFiAPClient.cpp index 4a4ac05a9..a031414e3 100644 --- a/src/mesh/http/WiFiAPClient.cpp +++ b/src/mesh/http/WiFiAPClient.cpp @@ -8,7 +8,6 @@ #include "mesh/wifi/WiFiServerAPI.h" #include "mqtt/MQTT.h" #include "target_specific.h" -#include #include #include #include @@ -22,9 +21,6 @@ using namespace concurrency; static void WiFiEvent(WiFiEvent_t event); -// DNS Server for the Captive Portal -DNSServer dnsServer; - // NTP WiFiUDP ntpUDP; @@ -37,8 +33,6 @@ uint8_t wifiDisconnectReason = 0; // Stores our hostname char ourHost[16]; -bool forcedSoftAP = 0; - bool APStartupComplete = 0; static bool needReconnect = true; // If we create our reconnector, run it once at the beginning @@ -88,16 +82,10 @@ static int32_t reconnectWiFi() static Periodic *wifiReconnect; -bool isSoftAPForced() -{ - return forcedSoftAP; -} - bool isWifiAvailable() { - if (config.network.wifi_enabled && ((config.network.wifi_ssid[0]) || forcedSoftAP)) { - + if (config.network.wifi_enabled && (config.network.wifi_ssid[0])) { return true; } else { return false; @@ -161,100 +149,48 @@ static void onNetworkConnected() } // Startup WiFi -bool initWifi(bool forceSoftAP) +bool initWifi() { - forcedSoftAP = forceSoftAP; + if (config.network.wifi_enabled && config.network.wifi_ssid[0]) { - if (config.network.wifi_enabled && ((config.network.wifi_ssid[0]) || forceSoftAP)) { - // if ((radioConfig.has_preferences && config.wifi.ssid[0]) || forceSoftAP) { const char *wifiName = config.network.wifi_ssid; const char *wifiPsw = config.network.wifi_psk; - if (forceSoftAP) { - DEBUG_MSG("WiFi ... Forced AP Mode\n"); - } else if (config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT) { - DEBUG_MSG("WiFi ... AP Mode\n"); - } else if (config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN) { - DEBUG_MSG("WiFi ... Hidden AP Mode\n"); - } else if (config.network.wifi_mode == Config_NetworkConfig_WiFiMode_CLIENT) { - DEBUG_MSG("WiFi ... Client Mode\n"); - } else { - DEBUG_MSG("WiFi ... WiFi Disabled\n"); - } - createSSLCert(); if (!*wifiPsw) // Treat empty password as no password wifiPsw = NULL; - if (*wifiName || forceSoftAP) { - if (config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT || config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN || forceSoftAP) { + if (*wifiName) { + uint8_t dmac[6]; + getMacAddr(dmac); + sprintf(ourHost, "Meshtastic-%02x%02x", dmac[4], dmac[5]); - IPAddress apIP(192, 168, 42, 1); - WiFi.onEvent(WiFiEvent); - WiFi.mode(WIFI_AP); + WiFi.mode(WIFI_MODE_STA); + WiFi.setHostname(ourHost); + WiFi.onEvent(WiFiEvent); - if (forcedSoftAP) { - const char *softAPssid = "meshtasticAdmin"; - const char *softAPpasswd = "12345678"; - int ok = WiFi.softAP(softAPssid, softAPpasswd); - DEBUG_MSG("Starting (Forced) WIFI AP: ssid=%s, ok=%d\n", softAPssid, ok); + // This is needed to improve performance. + esp_wifi_set_ps(WIFI_PS_NONE); // Disable radio power saving - } else { + WiFi.onEvent( + [](WiFiEvent_t event, WiFiEventInfo_t info) { + Serial.print("\nWiFi lost connection. Reason: "); + Serial.println(info.wifi_sta_disconnected.reason); - // If AP is configured to be hidden hidden - if (config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN) { + /* + If we are disconnected from the AP for some reason, + save the error code. - // The configurations on softAP are from the espresif library - int ok = WiFi.softAP(wifiName, wifiPsw, 1, 1, 4); - DEBUG_MSG("Starting hidden WIFI AP: ssid=%s, ok=%d\n", wifiName, ok); - } else { - int ok = WiFi.softAP(wifiName, wifiPsw); - DEBUG_MSG("Starting WIFI AP: ssid=%s, ok=%d\n", wifiName, ok); - } - int ok = WiFi.softAP(wifiName, wifiPsw); - DEBUG_MSG("Starting WIFI AP: ssid=%s, ok=%d\n", wifiName, ok); - } + For a reference to the codes: + https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html#wi-fi-reason-code + */ + wifiDisconnectReason = info.wifi_sta_disconnected.reason; + }, + WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED); - WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0)); - DEBUG_MSG("MY IP AP ADDRESS: %s\n", WiFi.softAPIP().toString().c_str()); - - // This is needed to improve performance. - esp_wifi_set_ps(WIFI_PS_NONE); // Disable radio power saving - - dnsServer.start(53, "*", apIP); - - } else { - uint8_t dmac[6]; - getMacAddr(dmac); - sprintf(ourHost, "Meshtastic-%02x%02x", dmac[4], dmac[5]); - - WiFi.mode(WIFI_MODE_STA); - WiFi.setHostname(ourHost); - WiFi.onEvent(WiFiEvent); - - // This is needed to improve performance. - esp_wifi_set_ps(WIFI_PS_NONE); // Disable radio power saving - - WiFi.onEvent( - [](WiFiEvent_t event, WiFiEventInfo_t info) { - Serial.print("\nWiFi lost connection. Reason: "); - Serial.println(info.wifi_sta_disconnected.reason); - - /* - If we are disconnected from the AP for some reason, - save the error code. - - For a reference to the codes: - https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html#wi-fi-reason-code - */ - wifiDisconnectReason = info.wifi_sta_disconnected.reason; - }, - WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED); - - DEBUG_MSG("JOINING WIFI soon: ssid=%s\n", wifiName); - wifiReconnect = new Periodic("WifiConnect", reconnectWiFi); - } + DEBUG_MSG("JOINING WIFI soon: ssid=%s\n", wifiName); + wifiReconnect = new Periodic("WifiConnect", reconnectWiFi); } return true; } else { @@ -356,13 +292,6 @@ static void WiFiEvent(WiFiEvent_t event) } } -void handleDNSResponse() -{ - if (config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT || config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN || isSoftAPForced()) { - dnsServer.processNextRequest(); - } -} - uint8_t getWifiDisconnectReason() { return wifiDisconnectReason; diff --git a/src/mesh/http/WiFiAPClient.h b/src/mesh/http/WiFiAPClient.h index 2c6bc912c..9729c24b5 100644 --- a/src/mesh/http/WiFiAPClient.h +++ b/src/mesh/http/WiFiAPClient.h @@ -5,19 +5,14 @@ #include #ifdef ARCH_ESP32 -#include #include #endif /// @return true if wifi is now in use -bool initWifi(bool forceSoftAP); +bool initWifi(); void deinitWifi(); bool isWifiAvailable(); -void handleDNSResponse(); - -bool isSoftAPForced(); - uint8_t getWifiDisconnectReason(); From 602e65d8986a389afb7ce85229b7769936c8fc14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Tue, 25 Oct 2022 12:42:08 +0200 Subject: [PATCH 017/133] fix non-ESP32 builds --- src/wifi-stubs.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/wifi-stubs.cpp b/src/wifi-stubs.cpp index faf58b620..f17e7ddae 100644 --- a/src/wifi-stubs.cpp +++ b/src/wifi-stubs.cpp @@ -1,11 +1,8 @@ -//#include "mesh/wifi/WebServer.h" #include "configuration.h" #ifndef ARCH_ESP32 -//#include "mesh/wifi/WiFiAPClient.h" - -bool initWifi(bool forceSoftAP) { +bool initWifi() { return false; } From a66538fe559c401339840d96e9b2428151dff26d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 26 Oct 2022 00:07:02 +0200 Subject: [PATCH 018/133] MQTT is working over ethernet --- src/buzz/buzz.cpp | 19 ++++++------ src/main.cpp | 9 ++++-- src/mesh/eth/ethClient.cpp | 51 ++++++++++++++++++++++++--------- src/mqtt/MQTT.cpp | 17 +++++++---- src/mqtt/MQTT.h | 10 +++++++ variants/rak4631/platformio.ini | 5 ++-- variants/rak4631/variant.h | 4 +++ 7 files changed, 84 insertions(+), 31 deletions(-) diff --git a/src/buzz/buzz.cpp b/src/buzz/buzz.cpp index 059630bfe..f8314fe51 100644 --- a/src/buzz/buzz.cpp +++ b/src/buzz/buzz.cpp @@ -1,5 +1,6 @@ #include "buzz.h" #include "configuration.h" +#include "NodeDB.h" #ifndef PIN_BUZZER @@ -42,17 +43,19 @@ const int DURATION_1_8 = 125; // 1/8 note const int DURATION_1_4 = 250; // 1/4 note void playTones(const ToneDuration *tone_durations, int size) { - for (int i = 0; i < size; i++) { - const auto &tone_duration = tone_durations[i]; + if (config.network.eth_enabled != true) { + for (int i = 0; i < size; i++) { + const auto &tone_duration = tone_durations[i]; #ifdef M5STACK - Tone.tone(tone_duration.frequency_khz); - delay(tone_duration.duration_ms); - Tone.mute(); + Tone.tone(tone_duration.frequency_khz); + delay(tone_duration.duration_ms); + Tone.mute(); #else - tone(PIN_BUZZER, tone_duration.frequency_khz, tone_duration.duration_ms); + tone(PIN_BUZZER, tone_duration.frequency_khz, tone_duration.duration_ms); #endif - // to distinguish the notes, set a minimum time between them. - delay(1.3 * tone_duration.duration_ms); + // to distinguish the notes, set a minimum time between them. + delay(1.3 * tone_duration.duration_ms); + } } } diff --git a/src/main.cpp b/src/main.cpp index 6ecd71baa..a783f023b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,6 +42,10 @@ #include "mqtt/MQTT.h" #endif +#if HAS_ETHERNET +#include "mqtt/MQTT.h" +#endif + #include "LLCC68Interface.h" #include "RF95Interface.h" #include "SX1262Interface.h" @@ -279,11 +283,12 @@ void setup() #ifdef ARCH_NRF52 nrf52Setup(); #endif - playStartMelody(); // We do this as early as possible because this loads preferences from flash // but we need to do this after main cpu iniot (esp32setup), because we need the random seed set nodeDB.init(); + playStartMelody(); + // Currently only the tbeam has a PMU power = new Power(); power->setStatusHandler(powerStatus); @@ -440,7 +445,7 @@ void setup() } #endif -#if HAS_WIFI +#if HAS_WIFI || HAS_ETHERNET mqttInit(); #endif diff --git a/src/mesh/eth/ethClient.cpp b/src/mesh/eth/ethClient.cpp index 92c1997e4..86e4e56c9 100644 --- a/src/mesh/eth/ethClient.cpp +++ b/src/mesh/eth/ethClient.cpp @@ -7,25 +7,30 @@ // Startup Ethernet bool initEthernet() { + + config.network.eth_enabled = true; + config.network.eth_mode = Config_NetworkConfig_EthMode_DHCP; + if (config.network.eth_enabled) { - Ethernet.init( SS ); +#ifdef PIN_ETHERNET_RESET + pinMode(PIN_ETHERNET_RESET, OUTPUT); + digitalWrite(PIN_ETHERNET_RESET, LOW); // Reset Time. + delay(100); + digitalWrite(PIN_ETHERNET_RESET, HIGH); // Reset Time. +#endif + + Ethernet.init( ETH_SPI_PORT, PIN_ETHERNET_SS ); uint8_t mac[6]; + int status = 0; + getMacAddr(mac); // FIXME use the BLE MAC for now... - - if (Ethernet.hardwareStatus() == EthernetNoHardware) { - DEBUG_MSG("Ethernet shield was not found.\n"); - } else if (Ethernet.linkStatus() == LinkOFF) { - DEBUG_MSG("Ethernet cable is not connected.\n"); - } else if (config.network.eth_mode == Config_NetworkConfig_EthMode_DHCP) { + + if (config.network.eth_mode == Config_NetworkConfig_EthMode_DHCP) { DEBUG_MSG("starting Ethernet DHCP\n"); - if (Ethernet.begin(mac) == 0) { - DEBUG_MSG("DHCP failed\n"); - } else{ - DEBUG_MSG("DHCP assigned IP %s\n",Ethernet.localIP()); - } + status = Ethernet.begin(mac); } else if (config.network.eth_mode == Config_NetworkConfig_EthMode_STATIC) { DEBUG_MSG("starting Ethernet Static\n"); Ethernet.begin(mac, config.network.eth_config.ip, config.network.eth_config.dns, config.network.eth_config.subnet); @@ -33,16 +38,34 @@ bool initEthernet() DEBUG_MSG("Ethernet Disabled\n"); return false; } + + if (status == 0) { + if (Ethernet.hardwareStatus() == EthernetNoHardware) { + DEBUG_MSG("Ethernet shield was not found.\n"); + return false; + } else if (Ethernet.linkStatus() == LinkOFF) { + DEBUG_MSG("Ethernet cable is not connected.\n"); + return false; + } else{ + DEBUG_MSG("Unknown Ethernet error.\n"); + return false; + } + } else { + DEBUG_MSG("Local IP %u.%u.%u.%u\n",Ethernet.localIP()[0], Ethernet.localIP()[1], Ethernet.localIP()[2], Ethernet.localIP()[3]); + DEBUG_MSG("Subnet Mask %u.%u.%u.%u\n",Ethernet.subnetMask()[0], Ethernet.subnetMask()[1], Ethernet.subnetMask()[2], Ethernet.subnetMask()[3]); + DEBUG_MSG("Gateway IP %u.%u.%u.%u\n",Ethernet.gatewayIP()[0], Ethernet.gatewayIP()[1], Ethernet.gatewayIP()[2], Ethernet.gatewayIP()[3]); + DEBUG_MSG("DNS Server IP %u.%u.%u.%u\n",Ethernet.dnsServerIP()[0], Ethernet.dnsServerIP()[1], Ethernet.dnsServerIP()[2], Ethernet.dnsServerIP()[3]); + } return true; } else { - DEBUG_MSG("Not using Ethernet\n"); return false; } } bool isEthernetAvailable() { + if (!config.network.eth_enabled) { return false; } else if (Ethernet.hardwareStatus() == EthernetNoHardware) { @@ -52,4 +75,4 @@ bool isEthernetAvailable() { } else { return true; } -} \ No newline at end of file +} diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 7deba4668..9d6c68225 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -8,7 +8,9 @@ #include "mesh/generated/mqtt.pb.h" #include "mesh/generated/telemetry.pb.h" #include "sleep.h" +#if HAS_WIFI #include +#endif #include #include @@ -189,7 +191,12 @@ bool MQTT::wantsLink() const } } +#if HAS_WIFI return hasChannel && WiFi.isConnected(); +#endif +#if HAS_ETHERNET + return hasChannel && (Ethernet.linkStatus() == LinkON); +#endif } int32_t MQTT::runOnce() @@ -346,9 +353,9 @@ std::string MQTT::downstreamPacketToJson(MeshPacket *mp) msgPayload = Json::object{ {"time", (int)decoded->time}, {"pos_timestamp", (int)decoded->timestamp}, - {"latitude_i", decoded->latitude_i}, - {"longitude_i", decoded->longitude_i}, - {"altitude", decoded->altitude} + {"latitude_i", (int)decoded->latitude_i}, + {"longitude_i", (int)decoded->longitude_i}, + {"altitude", (int)decoded->altitude} }; } else { DEBUG_MSG("Error decoding protobuf for position message!\n"); @@ -371,8 +378,8 @@ std::string MQTT::downstreamPacketToJson(MeshPacket *mp) {"description", decoded->description}, {"expire", (int)decoded->expire}, {"locked", decoded->locked}, - {"latitude_i", decoded->latitude_i}, - {"longitude_i", decoded->longitude_i}, + {"latitude_i", (int)decoded->latitude_i}, + {"longitude_i", (int)decoded->longitude_i}, }; } else { DEBUG_MSG("Error decoding protobuf for position message!\n"); diff --git a/src/mqtt/MQTT.h b/src/mqtt/MQTT.h index 9d80c7d91..4412e9526 100644 --- a/src/mqtt/MQTT.h +++ b/src/mqtt/MQTT.h @@ -5,7 +5,12 @@ #include "concurrency/OSThread.h" #include "mesh/Channels.h" #include +#if HAS_WIFI #include +#endif +#if HAS_ETHERNET +#include +#endif /** * Our wrapper/singleton for sending/receiving MQTT "udp" packets. This object isolates the MQTT protocol implementation from @@ -16,7 +21,12 @@ class MQTT : private concurrency::OSThread // supposedly the current version is busted: // http://www.iotsharing.com/2017/08/how-to-use-esp32-mqtts-with-mqtts-mosquitto-broker-tls-ssl.html // WiFiClientSecure wifiClient; +#if HAS_WIFI WiFiClient mqttClient; +#endif +#if HAS_ETHERNET + EthernetClient mqttClient; +#endif PubSubClient pubSub; // instead we supress sleep from our runOnce() callback diff --git a/variants/rak4631/platformio.ini b/variants/rak4631/platformio.ini index 3d4e46d30..fccffb51f 100644 --- a/variants/rak4631/platformio.ini +++ b/variants/rak4631/platformio.ini @@ -3,11 +3,12 @@ extends = nrf52840_base board = wiscore_rak4631 build_flags = ${nrf52840_base.build_flags} -Ivariants/rak4631 -D RAK_4631 -build_src_filter = ${nrf52_base.build_src_filter} +<../variants/rak4631> + +build_src_filter = ${nrf52_base.build_src_filter} +<../variants/rak4631> + + lib_deps = ${nrf52840_base.lib_deps} + ${networking_base.lib_deps} melopero/Melopero RV3028@^1.1.0 - beegee-tokyo/RAK13800-W5100S@^1.0.1 + https://github.com/caveman99/RAK13800-W5100S.git#main debug_tool = jlink ; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) ;upload_protocol = jlink \ No newline at end of file diff --git a/variants/rak4631/variant.h b/variants/rak4631/variant.h index c0bc2e5c1..904491b6a 100644 --- a/variants/rak4631/variant.h +++ b/variants/rak4631/variant.h @@ -231,6 +231,10 @@ static const uint8_t SCK = PIN_SPI_SCK; #define HAS_ETHERNET 1 +#define PIN_ETHERNET_RESET 21 +#define PIN_ETHERNET_SS PIN_EINK_CS +#define ETH_SPI_PORT SPI1 + #ifdef __cplusplus } #endif From a7fb88e293106e15cf03caae0e8c2003f434895a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 26 Oct 2022 09:16:54 +0200 Subject: [PATCH 019/133] make cppcheck happy about stuff it shouldn't care for --- src/mqtt/MQTT.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 9d6c68225..2e8008ac2 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -197,6 +197,7 @@ bool MQTT::wantsLink() const #if HAS_ETHERNET return hasChannel && (Ethernet.linkStatus() == LinkON); #endif + return false; } int32_t MQTT::runOnce() From b7ebe03ca8128e9ddf99b60775dfb804ee19aa66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 26 Oct 2022 11:09:59 +0200 Subject: [PATCH 020/133] API Server and DHCP Lease Management --- arch/esp32/esp32.ini | 3 +- arch/esp32/esp32s3.ini | 1 - platformio.ini | 1 + src/main.cpp | 1 + src/mesh/eth/ethClient.cpp | 92 ++++++++++++++++++++++++++++++++++- src/mesh/eth/ethServerAPI.cpp | 82 +++++++++++++++++++++++++++++++ src/mesh/eth/ethServerAPI.h | 58 ++++++++++++++++++++++ src/mqtt/MQTT.cpp | 6 +++ src/mqtt/MQTT.h | 2 + 9 files changed, 241 insertions(+), 5 deletions(-) create mode 100644 src/mesh/eth/ethServerAPI.cpp create mode 100644 src/mesh/eth/ethServerAPI.h diff --git a/arch/esp32/esp32.ini b/arch/esp32/esp32.ini index 1b57ffb8b..ba98a6b1f 100644 --- a/arch/esp32/esp32.ini +++ b/arch/esp32/esp32.ini @@ -33,8 +33,7 @@ lib_deps = ${environmental_base.lib_deps} https://github.com/meshtastic/esp32_https_server.git#657509856ce97e9dddeffb89a559f544faefd5cd h2zero/NimBLE-Arduino@^1.4.0 - arduino-libraries/NTPClient@^3.1.0 - https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6 + https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6 lib_ignore = segger_rtt diff --git a/arch/esp32/esp32s3.ini b/arch/esp32/esp32s3.ini index 286d9950e..f5338d9a9 100644 --- a/arch/esp32/esp32s3.ini +++ b/arch/esp32/esp32s3.ini @@ -33,7 +33,6 @@ lib_deps = ${environmental_base.lib_deps} https://github.com/meshtastic/esp32_https_server.git#657509856ce97e9dddeffb89a559f544faefd5cd h2zero/NimBLE-Arduino@^1.4.0 - arduino-libraries/NTPClient@^3.1.0 https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6 lib_ignore = diff --git a/platformio.ini b/platformio.ini index 1f97cfb19..527bce0d0 100644 --- a/platformio.ini +++ b/platformio.ini @@ -79,6 +79,7 @@ build_src_filter = ${env.build_src_filter} - [networking_base] lib_deps = knolleary/PubSubClient@^2.8 + arduino-libraries/NTPClient@^3.1.0 meshtastic/json11@^1.0.2 ; Common libs for environmental measurements in telemetry module diff --git a/src/main.cpp b/src/main.cpp index a783f023b..d2505d816 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,6 +43,7 @@ #endif #if HAS_ETHERNET +#include "mesh/eth/ethServerAPI.h" #include "mqtt/MQTT.h" #endif diff --git a/src/mesh/eth/ethClient.cpp b/src/mesh/eth/ethClient.cpp index 86e4e56c9..1bd8ea96e 100644 --- a/src/mesh/eth/ethClient.cpp +++ b/src/mesh/eth/ethClient.cpp @@ -1,15 +1,98 @@ #include "mesh/eth/ethClient.h" #include "NodeDB.h" +#include "RTC.h" +#include "concurrency/Periodic.h" #include #include #include "target_specific.h" +#include "mesh/eth/ethServerAPI.h" +#include "mqtt/MQTT.h" + +#ifndef DISABLE_NTP +#include + +// NTP +EthernetUDP ntpUDP; + +NTPClient timeClient(ntpUDP, config.network.ntp_server); + +uint32_t ntp_renew = 0; +#endif + +// Stores our hostname +char ourHost[16]; + +bool ethStartupComplete = 0; + +using namespace concurrency; + +static Periodic *ethEvent; + +static int32_t reconnectETH() +{ + if (config.network.eth_enabled) { + Ethernet.maintain(); + if (!ethStartupComplete) { + // Start web server + DEBUG_MSG("... Starting network services\n"); + + // // start mdns + // if (!MDNS.begin("Meshtastic")) { + // DEBUG_MSG("Error setting up MDNS responder!\n"); + // } else { + // DEBUG_MSG("mDNS responder started\n"); + // DEBUG_MSG("mDNS Host: Meshtastic.local\n"); + // MDNS.addService("http", "tcp", 80); + // MDNS.addService("https", "tcp", 443); + // } + + #ifndef DISABLE_NTP + DEBUG_MSG("Starting NTP time client\n"); + timeClient.begin(); + timeClient.setUpdateInterval(60 * 60); // Update once an hour + #endif + + // initWebServer(); + initApiServer(); + + ethStartupComplete = true; + } + + // FIXME this is kinda yucky, instead we should just have an observable for 'wifireconnected' + if (mqtt && !mqtt->connected()) { + mqtt->reconnect(); + } + } + +#ifndef DISABLE_NTP + if (isEthernetAvailable() && (ntp_renew < millis())) { + DEBUG_MSG("Updating NTP time\n"); + if (timeClient.update()) { + DEBUG_MSG("NTP Request Success - Setting RTCQualityNTP if needed\n"); + + struct timeval tv; + tv.tv_sec = timeClient.getEpochTime(); + tv.tv_usec = 0; + + perhapsSetRTC(RTCQualityNTP, &tv); + + ntp_renew = millis() + 43200 * 1000; // every 12 hours + + } else { + DEBUG_MSG("NTP Update failed\n"); + } + } +#endif + + return 5000; // every 5 seconds +} // Startup Ethernet bool initEthernet() { - config.network.eth_enabled = true; - config.network.eth_mode = Config_NetworkConfig_EthMode_DHCP; + // config.network.eth_enabled = true; + // config.network.eth_mode = Config_NetworkConfig_EthMode_DHCP; if (config.network.eth_enabled) { @@ -26,6 +109,8 @@ bool initEthernet() int status = 0; + // createSSLCert(); + getMacAddr(mac); // FIXME use the BLE MAC for now... if (config.network.eth_mode == Config_NetworkConfig_EthMode_DHCP) { @@ -56,6 +141,9 @@ bool initEthernet() DEBUG_MSG("Gateway IP %u.%u.%u.%u\n",Ethernet.gatewayIP()[0], Ethernet.gatewayIP()[1], Ethernet.gatewayIP()[2], Ethernet.gatewayIP()[3]); DEBUG_MSG("DNS Server IP %u.%u.%u.%u\n",Ethernet.dnsServerIP()[0], Ethernet.dnsServerIP()[1], Ethernet.dnsServerIP()[2], Ethernet.dnsServerIP()[3]); } + + ethEvent = new Periodic("ethConnect", reconnectETH); + return true; } else { diff --git a/src/mesh/eth/ethServerAPI.cpp b/src/mesh/eth/ethServerAPI.cpp new file mode 100644 index 000000000..bb7dd927d --- /dev/null +++ b/src/mesh/eth/ethServerAPI.cpp @@ -0,0 +1,82 @@ +#include "ethServerAPI.h" +#include "configuration.h" +#include + +static ethServerPort *apiPort; + +void initApiServer(int port) +{ + // Start API server on port 4403 + if (!apiPort) { + apiPort = new ethServerPort(port); + DEBUG_MSG("API server listening on TCP port %d\n", port); + apiPort->init(); + } +} + +ethServerAPI::ethServerAPI(EthernetClient &_client) : StreamAPI(&client), client(_client) +{ + DEBUG_MSG("Incoming ethernet connection\n"); +} + +ethServerAPI::~ethServerAPI() +{ + client.stop(); + + // FIXME - delete this if the client dropps the connection! +} + +/// override close to also shutdown the TCP link +void ethServerAPI::close() +{ + client.stop(); // drop tcp connection + StreamAPI::close(); +} + +/// Check the current underlying physical link to see if the client is currently connected +bool ethServerAPI::checkIsConnected() +{ + return client.connected(); +} + +int32_t ethServerAPI::runOnce() +{ + if (client.connected()) { + return StreamAPI::runOnce(); + } else { + DEBUG_MSG("Client dropped connection, suspending API service\n"); + enabled = false; // we no longer need to run + return 0; + } +} + +/// If an api server is running, we try to spit out debug 'serial' characters there +void ethServerPort::debugOut(char c) +{ + if (apiPort && apiPort->openAPI) + apiPort->openAPI->debugOut(c); +} + + +ethServerPort::ethServerPort(int port) : EthernetServer(port), concurrency::OSThread("ApiServer") {} + +void ethServerPort::init() +{ + begin(); +} + +int32_t ethServerPort::runOnce() +{ + auto client = available(); + if (client) { + // Close any previous connection (see FIXME in header file) + if (openAPI) { + DEBUG_MSG("Force closing previous TCP connection\n"); + delete openAPI; + } + + openAPI = new ethServerAPI(client); + } + + return 100; // only check occasionally for incoming connections +} diff --git a/src/mesh/eth/ethServerAPI.h b/src/mesh/eth/ethServerAPI.h new file mode 100644 index 000000000..c92ab2f17 --- /dev/null +++ b/src/mesh/eth/ethServerAPI.h @@ -0,0 +1,58 @@ +#pragma once + +#include "StreamAPI.h" +#include + +/** + * Provides both debug printing and, if the client starts sending protobufs to us, switches to send/receive protobufs + * (and starts dropping debug printing - FIXME, eventually those prints should be encapsulated in protobufs). + */ +class ethServerAPI : public StreamAPI +{ + private: + EthernetClient client; + + public: + explicit ethServerAPI(EthernetClient &_client); + + virtual ~ethServerAPI(); + + /// override close to also shutdown the TCP link + virtual void close(); + + protected: + /// We override this method to prevent publishing EVENT_SERIAL_CONNECTED/DISCONNECTED for wifi links (we want the board to + /// stay in the POWERED state to prevent disabling wifi) + virtual void onConnectionChanged(bool connected) override {} + + virtual int32_t runOnce() override; // Check for dropped client connections + + /// Check the current underlying physical link to see if the client is currently connected + virtual bool checkIsConnected() override; +}; + +/** + * Listens for incoming connections and does accepts and creates instances of WiFiServerAPI as needed + */ +class ethServerPort : public EthernetServer, private concurrency::OSThread +{ + /** The currently open port + * + * FIXME: We currently only allow one open TCP connection at a time, because we depend on the loop() call in this class to + * delegate to the worker. Once coroutines are implemented we can relax this restriction. + */ + ethServerAPI *openAPI = NULL; + + public: + explicit ethServerPort(int port); + + void init(); + + /// If an api server is running, we try to spit out debug 'serial' characters there + static void debugOut(char c); + + protected: + int32_t runOnce() override; +}; + +void initApiServer(int port=4403); diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 9d6c68225..e77e82e54 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -107,6 +107,11 @@ MQTT::MQTT() : concurrency::OSThread("mqtt"), pubSub(mqttClient) // preflightSleepObserver.observe(&preflightSleep); } +bool MQTT::connected() +{ + return pubSub.connected(); +} + void MQTT::reconnect() { if (wantsLink()) { @@ -197,6 +202,7 @@ bool MQTT::wantsLink() const #if HAS_ETHERNET return hasChannel && (Ethernet.linkStatus() == LinkON); #endif + return false; } int32_t MQTT::runOnce() diff --git a/src/mqtt/MQTT.h b/src/mqtt/MQTT.h index 4412e9526..c8381574c 100644 --- a/src/mqtt/MQTT.h +++ b/src/mqtt/MQTT.h @@ -48,6 +48,8 @@ class MQTT : private concurrency::OSThread /** Attempt to connect to server if necessary */ void reconnect(); + + bool connected(); protected: virtual int32_t runOnce() override; From 497c0b7a477ceb84ad80050f58c2634c9fac7ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 26 Oct 2022 17:38:53 +0200 Subject: [PATCH 021/133] don't rush failed time updates --- src/mesh/eth/ethClient.cpp | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/src/mesh/eth/ethClient.cpp b/src/mesh/eth/ethClient.cpp index 1bd8ea96e..935793b36 100644 --- a/src/mesh/eth/ethClient.cpp +++ b/src/mesh/eth/ethClient.cpp @@ -4,6 +4,7 @@ #include "concurrency/Periodic.h" #include #include +#include #include "target_specific.h" #include "mesh/eth/ethServerAPI.h" #include "mqtt/MQTT.h" @@ -13,15 +14,10 @@ // NTP EthernetUDP ntpUDP; - NTPClient timeClient(ntpUDP, config.network.ntp_server); - uint32_t ntp_renew = 0; #endif -// Stores our hostname -char ourHost[16]; - bool ethStartupComplete = 0; using namespace concurrency; @@ -36,22 +32,11 @@ static int32_t reconnectETH() // Start web server DEBUG_MSG("... Starting network services\n"); - // // start mdns - // if (!MDNS.begin("Meshtastic")) { - // DEBUG_MSG("Error setting up MDNS responder!\n"); - // } else { - // DEBUG_MSG("mDNS responder started\n"); - // DEBUG_MSG("mDNS Host: Meshtastic.local\n"); - // MDNS.addService("http", "tcp", 80); - // MDNS.addService("https", "tcp", 443); - // } - - #ifndef DISABLE_NTP +#ifndef DISABLE_NTP DEBUG_MSG("Starting NTP time client\n"); timeClient.begin(); timeClient.setUpdateInterval(60 * 60); // Update once an hour - #endif - +#endif // initWebServer(); initApiServer(); @@ -66,7 +51,8 @@ static int32_t reconnectETH() #ifndef DISABLE_NTP if (isEthernetAvailable() && (ntp_renew < millis())) { - DEBUG_MSG("Updating NTP time\n"); + + DEBUG_MSG("Updating NTP time from %s\n", config.network.ntp_server); if (timeClient.update()) { DEBUG_MSG("NTP Request Success - Setting RTCQualityNTP if needed\n"); @@ -76,10 +62,11 @@ static int32_t reconnectETH() perhapsSetRTC(RTCQualityNTP, &tv); - ntp_renew = millis() + 43200 * 1000; // every 12 hours + ntp_renew = millis() + 43200 * 1000; // success, refresh every 12 hours } else { DEBUG_MSG("NTP Update failed\n"); + ntp_renew = millis() + 300 * 1000; // failure, retry every 5 minutes } } #endif @@ -91,8 +78,8 @@ static int32_t reconnectETH() bool initEthernet() { - // config.network.eth_enabled = true; - // config.network.eth_mode = Config_NetworkConfig_EthMode_DHCP; + config.network.eth_enabled = true; + config.network.eth_mode = Config_NetworkConfig_EthMode_DHCP; if (config.network.eth_enabled) { @@ -112,6 +99,7 @@ bool initEthernet() // createSSLCert(); getMacAddr(mac); // FIXME use the BLE MAC for now... + sprintf(ourHost, "Meshtastic-%02x%02x", mac[4], mac[5]); if (config.network.eth_mode == Config_NetworkConfig_EthMode_DHCP) { DEBUG_MSG("starting Ethernet DHCP\n"); From 0c3ec9254d8d2648a1404e3b0a06cc66ce1c98dd Mon Sep 17 00:00:00 2001 From: caveman99 Date: Wed, 26 Oct 2022 15:56:26 +0000 Subject: [PATCH 022/133] [create-pull-request] automated change --- protobufs | 2 +- src/mesh/generated/config.pb.h | 11 ++++------- src/mesh/generated/localonly.pb.h | 2 +- src/mesh/generated/mesh.pb.c | 3 --- src/mesh/generated/mesh.pb.h | 30 +++--------------------------- 5 files changed, 9 insertions(+), 39 deletions(-) diff --git a/protobufs b/protobufs index 863a1d799..579a36afd 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 863a1d7997ae54471cbeea9baeb877924cc850cf +Subproject commit 579a36afded1edca9b0ba94f278ad1f637d56bf5 diff --git a/src/mesh/generated/config.pb.h b/src/mesh/generated/config.pb.h index e98aff60a..c83d97d51 100644 --- a/src/mesh/generated/config.pb.h +++ b/src/mesh/generated/config.pb.h @@ -157,7 +157,6 @@ typedef struct _Config_PowerConfig { typedef struct _Config_NetworkConfig { bool wifi_enabled; - Config_NetworkConfig_WiFiMode wifi_mode; char wifi_ssid[33]; char wifi_psk[64]; char ntp_server[33]; @@ -228,7 +227,7 @@ extern "C" { #define Config_DeviceConfig_init_default {_Config_DeviceConfig_Role_MIN, 0, 0} #define Config_PositionConfig_init_default {0, 0, 0, 0, 0, 0, 0} #define Config_PowerConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0} -#define Config_NetworkConfig_init_default {0, _Config_NetworkConfig_WiFiMode_MIN, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_NetworkConfig_init_default} +#define Config_NetworkConfig_init_default {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_NetworkConfig_init_default} #define Config_NetworkConfig_NetworkConfig_init_default {0, 0, 0, 0} #define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN} #define Config_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}} @@ -237,7 +236,7 @@ extern "C" { #define Config_DeviceConfig_init_zero {_Config_DeviceConfig_Role_MIN, 0, 0} #define Config_PositionConfig_init_zero {0, 0, 0, 0, 0, 0, 0} #define Config_PowerConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0} -#define Config_NetworkConfig_init_zero {0, _Config_NetworkConfig_WiFiMode_MIN, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_NetworkConfig_init_zero} +#define Config_NetworkConfig_init_zero {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_NetworkConfig_init_zero} #define Config_NetworkConfig_NetworkConfig_init_zero {0, 0, 0, 0} #define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN} #define Config_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}} @@ -288,7 +287,6 @@ extern "C" { #define Config_PowerConfig_ls_secs_tag 7 #define Config_PowerConfig_min_wake_secs_tag 8 #define Config_NetworkConfig_wifi_enabled_tag 1 -#define Config_NetworkConfig_wifi_mode_tag 2 #define Config_NetworkConfig_wifi_ssid_tag 3 #define Config_NetworkConfig_wifi_psk_tag 4 #define Config_NetworkConfig_ntp_server_tag 5 @@ -354,7 +352,6 @@ X(a, STATIC, SINGULAR, UINT32, min_wake_secs, 8) #define Config_NetworkConfig_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, BOOL, wifi_enabled, 1) \ -X(a, STATIC, SINGULAR, UENUM, wifi_mode, 2) \ X(a, STATIC, SINGULAR, STRING, wifi_ssid, 3) \ X(a, STATIC, SINGULAR, STRING, wifi_psk, 4) \ X(a, STATIC, SINGULAR, STRING, ntp_server, 5) \ @@ -433,10 +430,10 @@ extern const pb_msgdesc_t Config_BluetoothConfig_msg; #define Config_DisplayConfig_size 20 #define Config_LoRaConfig_size 68 #define Config_NetworkConfig_NetworkConfig_size 20 -#define Config_NetworkConfig_size 163 +#define Config_NetworkConfig_size 161 #define Config_PositionConfig_size 30 #define Config_PowerConfig_size 43 -#define Config_size 166 +#define Config_size 164 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/localonly.pb.h b/src/mesh/generated/localonly.pb.h index 8e4199d48..b691ee408 100644 --- a/src/mesh/generated/localonly.pb.h +++ b/src/mesh/generated/localonly.pb.h @@ -144,7 +144,7 @@ extern const pb_msgdesc_t LocalModuleConfig_msg; #define LocalModuleConfig_fields &LocalModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define LocalConfig_size 361 +#define LocalConfig_size 359 #define LocalModuleConfig_size 270 #ifdef __cplusplus diff --git a/src/mesh/generated/mesh.pb.c b/src/mesh/generated/mesh.pb.c index 2d46c960c..f98316a5d 100644 --- a/src/mesh/generated/mesh.pb.c +++ b/src/mesh/generated/mesh.pb.c @@ -42,9 +42,6 @@ PB_BIND(FromRadio, FromRadio, 2) PB_BIND(ToRadio, ToRadio, 2) -PB_BIND(ToRadio_PeerInfo, ToRadio_PeerInfo, AUTO) - - PB_BIND(Compressed, Compressed, AUTO) diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index d4407a2f1..3f2a8839c 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -243,8 +243,11 @@ typedef enum _LogRecord_Level { /* Struct definitions */ typedef PB_BYTES_ARRAY_T(237) Compressed_data_t; +/* Compressed message payload */ typedef struct _Compressed { + /* PortNum to determine the how to handle the compressed payload. */ PortNum portnum; + /* Compressed data. */ Compressed_data_t data; } Compressed; @@ -425,14 +428,6 @@ typedef struct _RouteDiscovery { uint32_t route[8]; } RouteDiscovery; -/* Compressed message payload */ -typedef struct _ToRadio_PeerInfo { - /* PortNum to determine the how to handle the compressed payload. */ - uint32_t app_version; - /* Compressed data. */ - bool mqtt_gateway; -} ToRadio_PeerInfo; - /* Broadcast when a newly powered mesh node wants to find a node num it can use Sent from the phone over bluetooth to set the user id for the owner of this node. Also sent from nodes to each other when a new node signs on (so all clients can have this info) @@ -665,9 +660,6 @@ typedef struct _ToRadio { union { /* Send this packet on the mesh */ MeshPacket packet; - /* Information about the peer, sent after the phone sneds want_config_id. - Old clients do not send this, which is fine. */ - ToRadio_PeerInfo peer_info; /* Phone wants radio to send full node db to the phone, This is typically the first packet sent to the radio when the phone gets a bluetooth connection. The radio will respond by sending back a @@ -740,7 +732,6 @@ extern "C" { #define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN} #define FromRadio_init_default {0, 0, {MeshPacket_init_default}} #define ToRadio_init_default {0, {MeshPacket_init_default}} -#define ToRadio_PeerInfo_init_default {0, 0} #define Compressed_init_default {_PortNum_MIN, {0, {0}}} #define Position_init_zero {0, 0, 0, 0, _Position_LocSource_MIN, _Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define User_init_zero {"", "", "", {0}, _HardwareModel_MIN, 0} @@ -754,7 +745,6 @@ extern "C" { #define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN} #define FromRadio_init_zero {0, 0, {MeshPacket_init_zero}} #define ToRadio_init_zero {0, {MeshPacket_init_zero}} -#define ToRadio_PeerInfo_init_zero {0, 0} #define Compressed_init_zero {_PortNum_MIN, {0, {0}}} /* Field tags (for use in manual encoding/decoding) */ @@ -811,8 +801,6 @@ extern "C" { #define Position_next_update_tag 21 #define Position_seq_number_tag 22 #define RouteDiscovery_route_tag 1 -#define ToRadio_PeerInfo_app_version_tag 1 -#define ToRadio_PeerInfo_mqtt_gateway_tag 2 #define User_id_tag 1 #define User_long_name_tag 2 #define User_short_name_tag 3 @@ -859,7 +847,6 @@ extern "C" { #define FromRadio_moduleConfig_tag 9 #define FromRadio_channel_tag 10 #define ToRadio_packet_tag 1 -#define ToRadio_peer_info_tag 2 #define ToRadio_want_config_id_tag 3 #define ToRadio_disconnect_tag 4 @@ -1019,19 +1006,11 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,channel,channel), 10) #define ToRadio_FIELDLIST(X, a) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,packet,packet), 1) \ -X(a, STATIC, ONEOF, MESSAGE, (payload_variant,peer_info,peer_info), 2) \ X(a, STATIC, ONEOF, UINT32, (payload_variant,want_config_id,want_config_id), 3) \ X(a, STATIC, ONEOF, BOOL, (payload_variant,disconnect,disconnect), 4) #define ToRadio_CALLBACK NULL #define ToRadio_DEFAULT NULL #define ToRadio_payload_variant_packet_MSGTYPE MeshPacket -#define ToRadio_payload_variant_peer_info_MSGTYPE ToRadio_PeerInfo - -#define ToRadio_PeerInfo_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, app_version, 1) \ -X(a, STATIC, SINGULAR, BOOL, mqtt_gateway, 2) -#define ToRadio_PeerInfo_CALLBACK NULL -#define ToRadio_PeerInfo_DEFAULT NULL #define Compressed_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, UENUM, portnum, 1) \ @@ -1051,7 +1030,6 @@ extern const pb_msgdesc_t MyNodeInfo_msg; extern const pb_msgdesc_t LogRecord_msg; extern const pb_msgdesc_t FromRadio_msg; extern const pb_msgdesc_t ToRadio_msg; -extern const pb_msgdesc_t ToRadio_PeerInfo_msg; extern const pb_msgdesc_t Compressed_msg; /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ @@ -1067,7 +1045,6 @@ extern const pb_msgdesc_t Compressed_msg; #define LogRecord_fields &LogRecord_msg #define FromRadio_fields &FromRadio_msg #define ToRadio_fields &ToRadio_msg -#define ToRadio_PeerInfo_fields &ToRadio_PeerInfo_msg #define Compressed_fields &Compressed_msg /* Maximum encoded size of messages (where known) */ @@ -1081,7 +1058,6 @@ extern const pb_msgdesc_t Compressed_msg; #define Position_size 137 #define RouteDiscovery_size 40 #define Routing_size 42 -#define ToRadio_PeerInfo_size 8 #define ToRadio_size 324 #define User_size 77 #define Waypoint_size 156 From 04225826f6ba93843e2c54835b3daa7a014ff260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 26 Oct 2022 18:12:31 +0200 Subject: [PATCH 023/133] Bump ConfigDB Version. this forces a factory reset on upgrade. --- src/mesh/NodeDB.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 6b9744565..dcd518191 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -18,7 +18,7 @@ DeviceState versions used to be defined in the .proto file but really only this #define SEGMENT_DEVICESTATE 4 #define SEGMENT_CHANNELS 8 -#define DEVICESTATE_CUR_VER 19 +#define DEVICESTATE_CUR_VER 20 #define DEVICESTATE_MIN_VER DEVICESTATE_CUR_VER extern DeviceState devicestate; From a1256818d96a560f316e2a0c700b2766dd624536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 26 Oct 2022 18:25:31 +0200 Subject: [PATCH 024/133] update library location --- platformio.ini | 2 +- variants/rak4631/platformio.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 527bce0d0..034cff8bc 100644 --- a/platformio.ini +++ b/platformio.ini @@ -68,7 +68,7 @@ lib_deps = ${env.lib_deps} ; Portduino is using meshtastic fork for now jgromes/RadioLib@5.4.1 - https://github.com/caveman99/SparkFun_ATECCX08a_Arduino_Library.git#008e7f9d40bad66b2f7a0074aaac05b7c424339d + https://github.com/meshtastic/SparkFun_ATECCX08a_Arduino_Library.git#52b5282639d08a8cbd4b748363089eed6102dc76 build_flags = ${env.build_flags} -Os -DRADIOLIB_SPI_PARANOID=0 diff --git a/variants/rak4631/platformio.ini b/variants/rak4631/platformio.ini index fccffb51f..3521a43ff 100644 --- a/variants/rak4631/platformio.ini +++ b/variants/rak4631/platformio.ini @@ -8,7 +8,7 @@ lib_deps = ${nrf52840_base.lib_deps} ${networking_base.lib_deps} melopero/Melopero RV3028@^1.1.0 - https://github.com/caveman99/RAK13800-W5100S.git#main + https://github.com/meshtastic/RAK13800-W5100S.git#b680706eb8006cd62c919ac74c8af1950eb82c81 debug_tool = jlink ; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) ;upload_protocol = jlink \ No newline at end of file From d5c407c098607fae89fd5ff30f42271876e7e8ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 26 Oct 2022 18:36:41 +0200 Subject: [PATCH 025/133] remove accidental commit --- src/mesh/eth/ethClient.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesh/eth/ethClient.cpp b/src/mesh/eth/ethClient.cpp index 935793b36..a082925dc 100644 --- a/src/mesh/eth/ethClient.cpp +++ b/src/mesh/eth/ethClient.cpp @@ -4,7 +4,6 @@ #include "concurrency/Periodic.h" #include #include -#include #include "target_specific.h" #include "mesh/eth/ethServerAPI.h" #include "mqtt/MQTT.h" From 74177294820d5693734f4e2bd52ee9bef12dfc04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 26 Oct 2022 18:37:20 +0200 Subject: [PATCH 026/133] debug removed --- src/mesh/eth/ethClient.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/mesh/eth/ethClient.cpp b/src/mesh/eth/ethClient.cpp index a082925dc..c055206b1 100644 --- a/src/mesh/eth/ethClient.cpp +++ b/src/mesh/eth/ethClient.cpp @@ -76,10 +76,6 @@ static int32_t reconnectETH() // Startup Ethernet bool initEthernet() { - - config.network.eth_enabled = true; - config.network.eth_mode = Config_NetworkConfig_EthMode_DHCP; - if (config.network.eth_enabled) { #ifdef PIN_ETHERNET_RESET From d5a9e3114abf5aa4f416d8d7883da1b8ba5ee9d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 26 Oct 2022 18:37:51 +0200 Subject: [PATCH 027/133] Update ethClient.cpp --- src/mesh/eth/ethClient.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesh/eth/ethClient.cpp b/src/mesh/eth/ethClient.cpp index c055206b1..cbfc1c554 100644 --- a/src/mesh/eth/ethClient.cpp +++ b/src/mesh/eth/ethClient.cpp @@ -94,7 +94,6 @@ bool initEthernet() // createSSLCert(); getMacAddr(mac); // FIXME use the BLE MAC for now... - sprintf(ourHost, "Meshtastic-%02x%02x", mac[4], mac[5]); if (config.network.eth_mode == Config_NetworkConfig_EthMode_DHCP) { DEBUG_MSG("starting Ethernet DHCP\n"); From 23c9fa0b56d1138ce5c022fec73518aa2ec9a640 Mon Sep 17 00:00:00 2001 From: thebentern Date: Wed, 26 Oct 2022 21:29:46 +0000 Subject: [PATCH 028/133] [create-pull-request] automated change --- protobufs | 2 +- src/mesh/generated/config.pb.c | 2 +- src/mesh/generated/config.pb.h | 42 +++++++++++++++++----------------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/protobufs b/protobufs index 579a36afd..a79e3aef8 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 579a36afded1edca9b0ba94f278ad1f637d56bf5 +Subproject commit a79e3aef8117dad642b1a011ec0438619616740c diff --git a/src/mesh/generated/config.pb.c b/src/mesh/generated/config.pb.c index f29dd7012..c5bc69552 100644 --- a/src/mesh/generated/config.pb.c +++ b/src/mesh/generated/config.pb.c @@ -21,7 +21,7 @@ PB_BIND(Config_PowerConfig, Config_PowerConfig, AUTO) PB_BIND(Config_NetworkConfig, Config_NetworkConfig, AUTO) -PB_BIND(Config_NetworkConfig_NetworkConfig, Config_NetworkConfig_NetworkConfig, AUTO) +PB_BIND(Config_NetworkConfig_IpV4Config, Config_NetworkConfig_IpV4Config, AUTO) PB_BIND(Config_DisplayConfig, Config_DisplayConfig, AUTO) diff --git a/src/mesh/generated/config.pb.h b/src/mesh/generated/config.pb.h index c83d97d51..6a8e56ad0 100644 --- a/src/mesh/generated/config.pb.h +++ b/src/mesh/generated/config.pb.h @@ -127,12 +127,12 @@ typedef struct _Config_LoRaConfig { uint32_t ignore_incoming[3]; } Config_LoRaConfig; -typedef struct _Config_NetworkConfig_NetworkConfig { +typedef struct _Config_NetworkConfig_IpV4Config { uint32_t ip; uint32_t gateway; uint32_t subnet; uint32_t dns; -} Config_NetworkConfig_NetworkConfig; +} Config_NetworkConfig_IpV4Config; typedef struct _Config_PositionConfig { uint32_t position_broadcast_secs; @@ -162,8 +162,8 @@ typedef struct _Config_NetworkConfig { char ntp_server[33]; bool eth_enabled; Config_NetworkConfig_EthMode eth_mode; - bool has_eth_config; - Config_NetworkConfig_NetworkConfig eth_config; + bool has_ipv4_config; + Config_NetworkConfig_IpV4Config ipv4_config; } Config_NetworkConfig; typedef struct _Config { @@ -227,8 +227,8 @@ extern "C" { #define Config_DeviceConfig_init_default {_Config_DeviceConfig_Role_MIN, 0, 0} #define Config_PositionConfig_init_default {0, 0, 0, 0, 0, 0, 0} #define Config_PowerConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0} -#define Config_NetworkConfig_init_default {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_NetworkConfig_init_default} -#define Config_NetworkConfig_NetworkConfig_init_default {0, 0, 0, 0} +#define Config_NetworkConfig_init_default {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_default} +#define Config_NetworkConfig_IpV4Config_init_default {0, 0, 0, 0} #define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN} #define Config_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}} #define Config_BluetoothConfig_init_default {0, _Config_BluetoothConfig_PairingMode_MIN, 0} @@ -236,8 +236,8 @@ extern "C" { #define Config_DeviceConfig_init_zero {_Config_DeviceConfig_Role_MIN, 0, 0} #define Config_PositionConfig_init_zero {0, 0, 0, 0, 0, 0, 0} #define Config_PowerConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0} -#define Config_NetworkConfig_init_zero {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_NetworkConfig_init_zero} -#define Config_NetworkConfig_NetworkConfig_init_zero {0, 0, 0, 0} +#define Config_NetworkConfig_init_zero {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_zero} +#define Config_NetworkConfig_IpV4Config_init_zero {0, 0, 0, 0} #define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN} #define Config_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}} #define Config_BluetoothConfig_init_zero {0, _Config_BluetoothConfig_PairingMode_MIN, 0} @@ -267,10 +267,10 @@ extern "C" { #define Config_LoRaConfig_tx_power_tag 10 #define Config_LoRaConfig_channel_num_tag 11 #define Config_LoRaConfig_ignore_incoming_tag 103 -#define Config_NetworkConfig_NetworkConfig_ip_tag 1 -#define Config_NetworkConfig_NetworkConfig_gateway_tag 2 -#define Config_NetworkConfig_NetworkConfig_subnet_tag 3 -#define Config_NetworkConfig_NetworkConfig_dns_tag 4 +#define Config_NetworkConfig_IpV4Config_ip_tag 1 +#define Config_NetworkConfig_IpV4Config_gateway_tag 2 +#define Config_NetworkConfig_IpV4Config_subnet_tag 3 +#define Config_NetworkConfig_IpV4Config_dns_tag 4 #define Config_PositionConfig_position_broadcast_secs_tag 1 #define Config_PositionConfig_position_broadcast_smart_enabled_tag 2 #define Config_PositionConfig_fixed_position_tag 3 @@ -292,7 +292,7 @@ extern "C" { #define Config_NetworkConfig_ntp_server_tag 5 #define Config_NetworkConfig_eth_enabled_tag 6 #define Config_NetworkConfig_eth_mode_tag 7 -#define Config_NetworkConfig_eth_config_tag 8 +#define Config_NetworkConfig_ipv4_config_tag 8 #define Config_device_tag 1 #define Config_position_tag 2 #define Config_power_tag 3 @@ -357,18 +357,18 @@ X(a, STATIC, SINGULAR, STRING, wifi_psk, 4) \ X(a, STATIC, SINGULAR, STRING, ntp_server, 5) \ X(a, STATIC, SINGULAR, BOOL, eth_enabled, 6) \ X(a, STATIC, SINGULAR, UENUM, eth_mode, 7) \ -X(a, STATIC, OPTIONAL, MESSAGE, eth_config, 8) +X(a, STATIC, OPTIONAL, MESSAGE, ipv4_config, 8) #define Config_NetworkConfig_CALLBACK NULL #define Config_NetworkConfig_DEFAULT NULL -#define Config_NetworkConfig_eth_config_MSGTYPE Config_NetworkConfig_NetworkConfig +#define Config_NetworkConfig_ipv4_config_MSGTYPE Config_NetworkConfig_IpV4Config -#define Config_NetworkConfig_NetworkConfig_FIELDLIST(X, a) \ +#define Config_NetworkConfig_IpV4Config_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, FIXED32, ip, 1) \ X(a, STATIC, SINGULAR, FIXED32, gateway, 2) \ X(a, STATIC, SINGULAR, FIXED32, subnet, 3) \ X(a, STATIC, SINGULAR, FIXED32, dns, 4) -#define Config_NetworkConfig_NetworkConfig_CALLBACK NULL -#define Config_NetworkConfig_NetworkConfig_DEFAULT NULL +#define Config_NetworkConfig_IpV4Config_CALLBACK NULL +#define Config_NetworkConfig_IpV4Config_DEFAULT NULL #define Config_DisplayConfig_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, UINT32, screen_on_secs, 1) \ @@ -408,7 +408,7 @@ extern const pb_msgdesc_t Config_DeviceConfig_msg; extern const pb_msgdesc_t Config_PositionConfig_msg; extern const pb_msgdesc_t Config_PowerConfig_msg; extern const pb_msgdesc_t Config_NetworkConfig_msg; -extern const pb_msgdesc_t Config_NetworkConfig_NetworkConfig_msg; +extern const pb_msgdesc_t Config_NetworkConfig_IpV4Config_msg; extern const pb_msgdesc_t Config_DisplayConfig_msg; extern const pb_msgdesc_t Config_LoRaConfig_msg; extern const pb_msgdesc_t Config_BluetoothConfig_msg; @@ -419,7 +419,7 @@ extern const pb_msgdesc_t Config_BluetoothConfig_msg; #define Config_PositionConfig_fields &Config_PositionConfig_msg #define Config_PowerConfig_fields &Config_PowerConfig_msg #define Config_NetworkConfig_fields &Config_NetworkConfig_msg -#define Config_NetworkConfig_NetworkConfig_fields &Config_NetworkConfig_NetworkConfig_msg +#define Config_NetworkConfig_IpV4Config_fields &Config_NetworkConfig_IpV4Config_msg #define Config_DisplayConfig_fields &Config_DisplayConfig_msg #define Config_LoRaConfig_fields &Config_LoRaConfig_msg #define Config_BluetoothConfig_fields &Config_BluetoothConfig_msg @@ -429,7 +429,7 @@ extern const pb_msgdesc_t Config_BluetoothConfig_msg; #define Config_DeviceConfig_size 6 #define Config_DisplayConfig_size 20 #define Config_LoRaConfig_size 68 -#define Config_NetworkConfig_NetworkConfig_size 20 +#define Config_NetworkConfig_IpV4Config_size 20 #define Config_NetworkConfig_size 161 #define Config_PositionConfig_size 30 #define Config_PowerConfig_size 43 From 82bcd391cd4703d4888d9c59e27271688ff1eda3 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 26 Oct 2022 16:50:58 -0500 Subject: [PATCH 029/133] Fix those refs --- src/mesh/eth/ethClient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/eth/ethClient.cpp b/src/mesh/eth/ethClient.cpp index cbfc1c554..793a86125 100644 --- a/src/mesh/eth/ethClient.cpp +++ b/src/mesh/eth/ethClient.cpp @@ -100,7 +100,7 @@ bool initEthernet() status = Ethernet.begin(mac); } else if (config.network.eth_mode == Config_NetworkConfig_EthMode_STATIC) { DEBUG_MSG("starting Ethernet Static\n"); - Ethernet.begin(mac, config.network.eth_config.ip, config.network.eth_config.dns, config.network.eth_config.subnet); + Ethernet.begin(mac, config.network.ipv4_config.ip, config.network.ipv4_config.dns, config.network.ipv4_config.subnet); } else { DEBUG_MSG("Ethernet Disabled\n"); return false; From d5ded53f0566acb6a482a5fd67f149d39ecf0745 Mon Sep 17 00:00:00 2001 From: thebentern Date: Wed, 26 Oct 2022 22:21:43 +0000 Subject: [PATCH 030/133] [create-pull-request] automated change --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 3d2355d7b..0dbcdca97 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 1 minor = 3 -build = 48 +build = 49 From f474953b513ed8ec3b4cef5e9af76186c746359b Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Thu, 27 Oct 2022 08:56:04 +0200 Subject: [PATCH 031/133] RAK14000 2.13 inch b/w E-Ink partial update support Changed from GxEPD2_213_B74 (which was not going to give partial update support on this display) to GxEPD2_213_BN - RAK14000 2.13 inch b/w 250x122 --- src/graphics/EInkDisplay2.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/graphics/EInkDisplay2.cpp b/src/graphics/EInkDisplay2.cpp index 9062fc018..a555efedc 100644 --- a/src/graphics/EInkDisplay2.cpp +++ b/src/graphics/EInkDisplay2.cpp @@ -14,8 +14,8 @@ #define TECHO_DISPLAY_MODEL GxEPD2_154_D67 #elif defined(RAK4630) -//GxEPD2_213_B74 - RAK14000 2.13 inch b/w 250x128 -#define TECHO_DISPLAY_MODEL GxEPD2_213_B74 +//GxEPD2_213_BN - RAK14000 2.13 inch b/w 250x122 - changed from GxEPD2_213_B74 - which was not going to give partial update support +#define TECHO_DISPLAY_MODEL GxEPD2_213_BN //4.2 inch 300x400 - GxEPD2_420_M01 //#define TECHO_DISPLAY_MODEL GxEPD2_420_M01 @@ -46,9 +46,9 @@ EInkDisplay::EInkDisplay(uint8_t address, int sda, int scl) setGeometry(GEOMETRY_RAWMODE, TECHO_DISPLAY_MODEL::WIDTH, TECHO_DISPLAY_MODEL::HEIGHT); #elif defined(RAK4630) - //GxEPD2_213_B74 - RAK14000 2.13 inch b/w 250x128 + //GxEPD2_213_BN - RAK14000 2.13 inch b/w 250x122 setGeometry(GEOMETRY_RAWMODE, 250, 122); - + //GxEPD2_420_M01 //setGeometry(GEOMETRY_RAWMODE, 300, 400); @@ -110,14 +110,17 @@ bool EInkDisplay::forceDisplay(uint32_t msecLimit) adafruitDisplay->display(false); // FIXME, use partial update mode #elif defined(RAK4630) - //RAK14000 2.13 inch b/w 250x122 does not support partial updates - adafruitDisplay->display(false); // FIXME, use partial update mode + //RAK14000 2.13 inch b/w 250x122 actually now does support partial updates + + //Full update mode (slow) + //adafruitDisplay->display(false); // FIXME, use partial update mode //Only enable for e-Paper with support for partial updates and comment out above adafruitDisplay->display(false); // 1.54 inch 200x200 - GxEPD2_154_M09 + // 2.13 inch 250x122 - GxEPD2_213_BN // 2.9 inch 296x128 - GxEPD2_290_T5D // 4.2 inch 300x400 - GxEPD2_420_M01 - //adafruitDisplay->nextPage(); + adafruitDisplay->nextPage(); #elif defined(PCA10059) || defined(M5_COREINK) adafruitDisplay->nextPage(); @@ -194,7 +197,7 @@ bool EInkDisplay::connect() adafruitDisplay->setRotation(3); //For 1.54, 2.9 and 4.2 //adafruitDisplay->setRotation(1); - //adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight); + adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight); } else { (void)adafruitDisplay; } From 8a1bf8cd86ab58e9ace8cd0634f6624077453c81 Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Thu, 27 Oct 2022 08:59:39 +0200 Subject: [PATCH 032/133] RAK14000 2.13" b/w E-Ink partial update support Changed from GxEPD2_213_B74 (which was not going to give partial update support on this display) to GxEPD2_213_BN - RAK14000 2.13 inch b/w 250x122 --- src/graphics/EInkDisplay2.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/graphics/EInkDisplay2.cpp b/src/graphics/EInkDisplay2.cpp index a555efedc..9e0834954 100644 --- a/src/graphics/EInkDisplay2.cpp +++ b/src/graphics/EInkDisplay2.cpp @@ -193,9 +193,9 @@ bool EInkDisplay::connect() adafruitDisplay->init(115200, true, 10, false, SPI1, SPISettings(4000000, MSBFIRST, SPI_MODE0)); - //RAK14000 2.13 inch b/w 250x122 does not support partial updates + //RAK14000 2.13 inch b/w 250x122 does actually now support partial updates adafruitDisplay->setRotation(3); - //For 1.54, 2.9 and 4.2 + //Partial update support for 1.54, 2.13 RAK14000 b/w , 2.9 and 4.2 //adafruitDisplay->setRotation(1); adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight); } else { From 154b7d256c3f84f5df24568e47918932df105d4f Mon Sep 17 00:00:00 2001 From: Tim O'Brien Date: Thu, 27 Oct 2022 11:03:27 -0700 Subject: [PATCH 033/133] Powers off eink backlights before shutdown - t-echo boards in particular need this - follows the existing defines structure --- src/Power.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Power.cpp b/src/Power.cpp index d3782a2a4..744b6360a 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -234,6 +234,9 @@ bool Power::setup() void Power::shutdown() { +#if defined(USE_EINK) + digitalWrite(PIN_EINK_EN, LOW); //power off backlight first +#endif #ifdef HAS_PMU DEBUG_MSG("Shutting down\n"); From 8a4341fec4c7d32c818146ff85ed52827f6c618d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 28 Oct 2022 02:15:16 +0200 Subject: [PATCH 034/133] use new lora.use_preset bool (#1868) --- src/mesh/Channels.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/Channels.cpp b/src/mesh/Channels.cpp index f7fc35929..d869de752 100644 --- a/src/mesh/Channels.cpp +++ b/src/mesh/Channels.cpp @@ -218,7 +218,7 @@ const char *Channels::getName(size_t chIndex) // Per mesh.proto spec, if bandwidth is specified we must ignore modemPreset enum, we assume that in that case // the app fucked up and forgot to set channelSettings.name - if (config.lora.bandwidth != 0) + if (config.lora.use_preset) channelName = "Custom"; else switch (config.lora.modem_preset) { From 6146b773cf2678ee53947de49ada884bac16752e Mon Sep 17 00:00:00 2001 From: timo Date: Thu, 27 Oct 2022 17:59:53 -0700 Subject: [PATCH 035/133] Better #define guard for PIN_EINK_EN --- src/ButtonThread.h | 2 +- src/Power.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ButtonThread.h b/src/ButtonThread.h index c1fd770bc..088642099 100644 --- a/src/ButtonThread.h +++ b/src/ButtonThread.h @@ -159,7 +159,7 @@ class ButtonThread : public concurrency::OSThread static void userButtonDoublePressed() { -#if defined(USE_EINK) +#if defined(USE_EINK) && defined(PIN_EINK_EN) digitalWrite(PIN_EINK_EN, digitalRead(PIN_EINK_EN) == LOW); #endif } diff --git a/src/Power.cpp b/src/Power.cpp index 744b6360a..7443fc428 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -234,7 +234,7 @@ bool Power::setup() void Power::shutdown() { -#if defined(USE_EINK) +#if defined(USE_EINK) && defined(PIN_EINK_EN) digitalWrite(PIN_EINK_EN, LOW); //power off backlight first #endif From d6c9327aefaca838526c0fdc860ae8e493a7ce70 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 29 Oct 2022 11:40:05 -0500 Subject: [PATCH 036/133] Opposite logic for use_preset based channel name (#1871) --- src/mesh/Channels.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mesh/Channels.cpp b/src/mesh/Channels.cpp index d869de752..0af92a5c9 100644 --- a/src/mesh/Channels.cpp +++ b/src/mesh/Channels.cpp @@ -218,9 +218,7 @@ const char *Channels::getName(size_t chIndex) // Per mesh.proto spec, if bandwidth is specified we must ignore modemPreset enum, we assume that in that case // the app fucked up and forgot to set channelSettings.name - if (config.lora.use_preset) - channelName = "Custom"; - else + if (config.lora.use_preset) { switch (config.lora.modem_preset) { case Config_LoRaConfig_ModemPreset_SHORT_SLOW: channelName = "ShortSlow"; @@ -247,6 +245,10 @@ const char *Channels::getName(size_t chIndex) channelName = "Invalid"; break; } + } + else { + channelName = "Custom"; + } } return channelName; From 1f9db0a8fe177540ec3b0d5693af4979ea3c822d Mon Sep 17 00:00:00 2001 From: code8buster Date: Sat, 29 Oct 2022 21:37:27 +0000 Subject: [PATCH 037/133] Disaster.radio dev board support update (#1873) * Bringing changes from 1.2-legacy over to the new structure in 1.3/2.0 * Add meshtastic-dr-dev to CI artifact workflow --- .github/workflows/main_matrix.yml | 2 + platformio.ini | 1 + src/platform/esp32/architecture.h | 2 + variants/diy/dr-dev/variant.h | 69 +++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 variants/diy/dr-dev/variant.h diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index fd4acbdba..c50adb941 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -33,6 +33,7 @@ jobs: - board: heltec-v2.1 - board: tbeam0.7 - board: meshtastic-diy-v1 + - board: meshtastic-dr-dev - board: rak4631 - board: rak4631_eink - board: t-echo @@ -96,6 +97,7 @@ jobs: - board: heltec-v2.1 - board: tbeam0.7 - board: meshtastic-diy-v1 + - board: meshtastic-dr-dev - board: nano-g1 - board: station-g1 - board: m5stack-core diff --git a/platformio.ini b/platformio.ini index 034cff8bc..7c1ba6851 100644 --- a/platformio.ini +++ b/platformio.ini @@ -22,6 +22,7 @@ ;default_envs = pca10059_diy_eink ;default_envs = meshtastic-diy-v1 ;default_envs = meshtastic-diy-v1.1 +;default_envs = meshtastic-dr-dev ;default_envs = m5stack-coreink ;default_envs = rak4631 diff --git a/src/platform/esp32/architecture.h b/src/platform/esp32/architecture.h index 527f2947e..18253abe5 100644 --- a/src/platform/esp32/architecture.h +++ b/src/platform/esp32/architecture.h @@ -80,6 +80,8 @@ #define HW_VENDOR HardwareModel_M5STACK #elif defined(STATION_G1) #define HW_VENDOR HardwareModel_STATION_G1 +#elif defined(DR_DEV) + #define HW_VENDOR HardwareModel_DR_DEV #endif // diff --git a/variants/diy/dr-dev/variant.h b/variants/diy/dr-dev/variant.h new file mode 100644 index 000000000..6356cad14 --- /dev/null +++ b/variants/diy/dr-dev/variant.h @@ -0,0 +1,69 @@ +// For OLED LCD +#define I2C_SDA 21 +#define I2C_SCL 22 + +// GPS +#undef GPS_RX_PIN +#define GPS_RX_PIN NOT_A_PIN +#undef WANT_GPS + +#define BUTTON_PIN 2 // The middle button GPIO on the T-Beam +#define BUTTON_NEED_PULLUP +#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975). + +#define LORA_DIO0 -1 // a No connect on the SX1262/SX1268 module +#define LORA_RESET -1 // RST for SX1276, and for SX1262/SX1268 +#define LORA_DIO1 27 // IRQ for SX1262/SX1268 (IO26 FOR 22S) +#define LORA_DIO2 NOT_A_PIN // BUSY for SX1262/SX1268 +#define LORA_DIO3 // Not connected on PCB, but internally on the SX1262/SX1268, if DIO3 is high the TXCO is enabled + +// In transmitting, set TXEN as high communication level,RXEN pin is low level; +// In receiving, set RXEN as high communication level, TXEN is lowlevel; +// Before powering off, set TXEN、RXEN as low level. +#define LORA_RXEN 17 // Input - RF switch RX control, connecting external MCU IO, valid in high level +#define LORA_TXEN -1 // Input - RF switch TX control, connecting external MCU IO or DIO2, valid in high level +/* --PINS FOR THE 900M22S +#undef RF95_SCK +#define RF95_SCK 18 +#undef RF95_MISO +#define RF95_MISO 19 +#undef RF95_MOSI +#define RF95_MOSI 23 +#undef RF95_NSS +#define RF95_NSS 16 +*/ + +// PINS FOR THE 900M30S +#undef RF95_SCK +#define RF95_SCK 18 +#undef RF95_MISO +#define RF95_MISO 19 +#undef RF95_MOSI +#define RF95_MOSI 23 +#undef RF95_NSS +#define RF95_NSS 33 + +// RX/TX for RFM95/SX127x +#define RF95_RXEN LORA_RXEN +#define RF95_TXEN LORA_TXEN +// #define RF95_TCXO + +// common pinouts for SX126X modules +#define SX126X_CS 33 +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY 35 +#define SX126X_RESET LORA_RESET +#define SX126X_RXEN LORA_RXEN +#define SX126X_TXEN LORA_TXEN + +// supported modules list +#define USE_RF95 // RFM95/SX127x +#define USE_SX1262 +#define USE_SX1268 +#define USE_LLCC68 + +#ifdef EBYTE_E22 +// Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch +// (which is the default for the sx1262interface code) +#define SX126X_E22 +#endif From 311835a2310fc108307ef8289abad06d03e336fc Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 30 Oct 2022 10:02:11 -0500 Subject: [PATCH 038/133] Implement extended device metadata (#1874) * Implement extended device metadata * HAS_BLUETOOTH should be global --- protobufs | 2 +- src/configuration.h | 8 +++++++- src/mesh/generated/device_metadata.pb.h | 24 ++++++++++++++++++++---- src/modules/AdminModule.cpp | 4 ++++ src/platform/nrf52/architecture.h | 3 +++ 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/protobufs b/protobufs index a79e3aef8..46bc0afe0 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit a79e3aef8117dad642b1a011ec0438619616740c +Subproject commit 46bc0afe050a836b6ec8b235c3ff55e9e037efcb diff --git a/src/configuration.h b/src/configuration.h index 6ad5f8ff9..4b157611d 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -143,7 +143,7 @@ along with this program. If not, see . #define HAS_WIFI 0 #endif #ifndef HAS_ETHERNET - #define ETHERNET 0 + #define HAS_ETHERNET 0 #endif #ifndef HAS_SCREEN #define HAS_SCREEN 0 @@ -166,6 +166,12 @@ along with this program. If not, see . #ifndef HAS_RTC #define HAS_RTC 0 #endif +#ifndef HAS_CPU_SHUTDOWN + #define HAS_CPU_SHUTDOWN 0 +#endif +#ifndef HAS_BLUETOOTH + #define HAS_BLUETOOTH 0 +#endif #include "RF95Configuration.h" #include "DebugConfiguration.h" diff --git a/src/mesh/generated/device_metadata.pb.h b/src/mesh/generated/device_metadata.pb.h index 7bd32979e..1f4c81c5b 100644 --- a/src/mesh/generated/device_metadata.pb.h +++ b/src/mesh/generated/device_metadata.pb.h @@ -16,6 +16,14 @@ typedef struct _DeviceMetadata { char firmware_version[18]; /* Device state version */ uint32_t device_state_version; + /* Indicates whether the device can shutdown CPU natively or via power management chip */ + bool canShutdown; + /* Indicates that the device has native wifi capability */ + bool hasWifi; + /* Indicates that the device has native bluetooth capability */ + bool hasBluetooth; + /* Indicates that the device has an ethernet peripheral */ + bool hasEthernet; } DeviceMetadata; @@ -24,17 +32,25 @@ extern "C" { #endif /* Initializer values for message structs */ -#define DeviceMetadata_init_default {"", 0} -#define DeviceMetadata_init_zero {"", 0} +#define DeviceMetadata_init_default {"", 0, 0, 0, 0, 0} +#define DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0} /* Field tags (for use in manual encoding/decoding) */ #define DeviceMetadata_firmware_version_tag 1 #define DeviceMetadata_device_state_version_tag 2 +#define DeviceMetadata_canShutdown_tag 3 +#define DeviceMetadata_hasWifi_tag 4 +#define DeviceMetadata_hasBluetooth_tag 5 +#define DeviceMetadata_hasEthernet_tag 6 /* Struct field encoding specification for nanopb */ #define DeviceMetadata_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, STRING, firmware_version, 1) \ -X(a, STATIC, SINGULAR, UINT32, device_state_version, 2) +X(a, STATIC, SINGULAR, UINT32, device_state_version, 2) \ +X(a, STATIC, SINGULAR, BOOL, canShutdown, 3) \ +X(a, STATIC, SINGULAR, BOOL, hasWifi, 4) \ +X(a, STATIC, SINGULAR, BOOL, hasBluetooth, 5) \ +X(a, STATIC, SINGULAR, BOOL, hasEthernet, 6) #define DeviceMetadata_CALLBACK NULL #define DeviceMetadata_DEFAULT NULL @@ -44,7 +60,7 @@ extern const pb_msgdesc_t DeviceMetadata_msg; #define DeviceMetadata_fields &DeviceMetadata_msg /* Maximum encoded size of messages (where known) */ -#define DeviceMetadata_size 25 +#define DeviceMetadata_size 33 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 6a10c618a..16ce47cec 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -441,6 +441,10 @@ void AdminModule::handleGetDeviceMetadata(const MeshPacket &req) { DeviceMetadata deviceMetadata; strncpy(deviceMetadata.firmware_version, myNodeInfo.firmware_version, 18); deviceMetadata.device_state_version = DEVICESTATE_CUR_VER; + deviceMetadata.canShutdown = pmu_found || HAS_CPU_SHUTDOWN; + deviceMetadata.hasBluetooth = HAS_BLUETOOTH; + deviceMetadata.hasWifi = HAS_WIFI; + deviceMetadata.hasEthernet = HAS_ETHERNET; r.get_device_metadata_response = deviceMetadata; r.which_payload_variant = AdminMessage_get_device_metadata_response_tag; diff --git a/src/platform/nrf52/architecture.h b/src/platform/nrf52/architecture.h index 63e173434..47d95c92d 100644 --- a/src/platform/nrf52/architecture.h +++ b/src/platform/nrf52/architecture.h @@ -26,6 +26,9 @@ #ifndef HAS_RADIO #define HAS_RADIO 1 #endif +#ifdef HAS_CPU_SHUTDOWN + #define HAS_CPU_SHUTDOWN 1 +#endif // // set HW_VENDOR From afafb3ba3272c5e2bd688a049e812166e4bd9efd Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 30 Oct 2022 20:40:30 -0500 Subject: [PATCH 039/133] Fixing a number of T-Beam poweroff display issues (#1876) --- src/Power.cpp | 14 +++++++------- src/graphics/Screen.h | 3 +-- src/shutdown.h | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index 7443fc428..af10acb5e 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -233,14 +233,14 @@ bool Power::setup() void Power::shutdown() { - + screen->setOn(false); #if defined(USE_EINK) && defined(PIN_EINK_EN) digitalWrite(PIN_EINK_EN, LOW); //power off backlight first #endif #ifdef HAS_PMU DEBUG_MSG("Shutting down\n"); - if(PMU){ + if(PMU) { PMU->setChargingLedMode(XPOWERS_CHG_LED_OFF); PMU->shutdown(); } @@ -315,7 +315,7 @@ int32_t Power::runOnce() #ifdef HAS_PMU // WE no longer use the IRQ line to wake the CPU (due to false wakes from sleep), but we do poll // the IRQ status by reading the registers over I2C - if(PMU){ + if(PMU) { PMU->getIrqStatus(); @@ -344,10 +344,11 @@ int32_t Power::runOnce() if (PMU->isBatRemoveIrq()) { DEBUG_MSG("Battery removed\n"); } - if (PMU->isPekeyShortPressIrq()) { - DEBUG_MSG("PEK short button press\n"); - } */ + if (PMU->isPekeyLongPressIrq()) { + DEBUG_MSG("PEK long button press\n"); + screen->setOn(false); + } PMU->clearIrqStatus(); } @@ -454,7 +455,6 @@ bool Power::axpChipInit() // Set constant current charging current PMU->setChargerConstantCurr(XPOWERS_AXP192_CHG_CUR_450MA); - } else if (PMU->getChipModel() == XPOWERS_AXP2101) { // t-beam s3 core diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index ab8d44430..cee00f174 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -131,8 +131,7 @@ class Screen : public concurrency::OSThread void setOn(bool on) { if (!on) - handleSetOn( - false); // We handle off commands immediately, because they might be called because the CPU is shutting down + handleSetOn(false); // We handle off commands immediately, because they might be called because the CPU is shutting down else enqueueCmd(ScreenCmd{.cmd = on ? Cmd::SET_ON : Cmd::SET_OFF}); } diff --git a/src/shutdown.h b/src/shutdown.h index f37339641..678a1401c 100644 --- a/src/shutdown.h +++ b/src/shutdown.h @@ -17,7 +17,7 @@ void powerCommandsCheck() #endif } -#if defined(ARCH_NRF52) +#if defined(ARCH_NRF52) || defined(HAS_PMU) if (shutdownAtMsec) { screen->startShutdownScreen(); playBeep(); From 309a3d5396a4d421f5a74c17b80aa1605e74a714 Mon Sep 17 00:00:00 2001 From: code8buster Date: Sun, 30 Oct 2022 22:27:16 -0400 Subject: [PATCH 040/133] Rearranging deck chairs, 900M22S working, 30S not --- variants/diy/dr-dev/variant.h | 51 ++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/variants/diy/dr-dev/variant.h b/variants/diy/dr-dev/variant.h index 6356cad14..e670c5a91 100644 --- a/variants/diy/dr-dev/variant.h +++ b/variants/diy/dr-dev/variant.h @@ -1,47 +1,54 @@ // For OLED LCD -#define I2C_SDA 21 -#define I2C_SCL 22 +#define HAS_WIRE 0 +#define HAS_SCREEN 0 +#define I2C_SDA 4 +#define I2C_SCL 5 // GPS #undef GPS_RX_PIN #define GPS_RX_PIN NOT_A_PIN -#undef WANT_GPS +#define HAS_GPS 0 -#define BUTTON_PIN 2 // The middle button GPIO on the T-Beam +#define BUTTON_PIN 13 // The middle button GPIO on the T-Beam #define BUTTON_NEED_PULLUP #define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975). -#define LORA_DIO0 -1 // a No connect on the SX1262/SX1268 module -#define LORA_RESET -1 // RST for SX1276, and for SX1262/SX1268 -#define LORA_DIO1 27 // IRQ for SX1262/SX1268 (IO26 FOR 22S) -#define LORA_DIO2 NOT_A_PIN // BUSY for SX1262/SX1268 -#define LORA_DIO3 // Not connected on PCB, but internally on the SX1262/SX1268, if DIO3 is high the TXCO is enabled +#define LORA_DIO0 NOT_A_PIN // a No connect on the SX1262/SX1268 module +#define LORA_RESET NOT_A_PIN // RST for SX1276, and for SX1262/SX1268 +#define LORA_DIO3 NOT_A_PIN // Not connected on PCB, but internally on the SX1262/SX1268, if DIO3 is high the TXCO is enabled // In transmitting, set TXEN as high communication level,RXEN pin is low level; // In receiving, set RXEN as high communication level, TXEN is lowlevel; // Before powering off, set TXEN、RXEN as low level. -#define LORA_RXEN 17 // Input - RF switch RX control, connecting external MCU IO, valid in high level -#define LORA_TXEN -1 // Input - RF switch TX control, connecting external MCU IO or DIO2, valid in high level -/* --PINS FOR THE 900M22S + #undef RF95_SCK #define RF95_SCK 18 #undef RF95_MISO #define RF95_MISO 19 #undef RF95_MOSI #define RF95_MOSI 23 + +// --PINS FOR THE 900M22S + +#define LORA_DIO1 26 // IRQ for SX1262/SX1268 +#define LORA_DIO2 22 // BUSY for SX1262/SX1268 +#define LORA_TXEN NOT_A_PIN // Input - RF switch TX control, connecting external MCU IO or DIO2, valid in high level +#define LORA_RXEN 17 // Input - RF switch RX control, connecting external MCU IO, valid in high level #undef RF95_NSS #define RF95_NSS 16 -*/ +#define SX126X_BUSY 22 + // PINS FOR THE 900M30S -#undef RF95_SCK -#define RF95_SCK 18 -#undef RF95_MISO -#define RF95_MISO 19 -#undef RF95_MOSI -#define RF95_MOSI 23 +/* +#define LORA_DIO1 27 // IRQ for SX1262/SX1268 +#define LORA_RXEN 21 // Input - RF switch RX control, connecting external MCU IO, valid in high level +#define LORA_DIO2 35 // BUSY for SX1262/SX1268 +#define LORA_TXEN NOT_A_PIN // Input - RF switch TX control, connecting external MCU IO or DIO2, valid in high level #undef RF95_NSS #define RF95_NSS 33 +#define SX126X_BUSY 35 +*/ // RX/TX for RFM95/SX127x #define RF95_RXEN LORA_RXEN @@ -51,7 +58,6 @@ // common pinouts for SX126X modules #define SX126X_CS 33 #define SX126X_DIO1 LORA_DIO1 -#define SX126X_BUSY 35 #define SX126X_RESET LORA_RESET #define SX126X_RXEN LORA_RXEN #define SX126X_TXEN LORA_TXEN @@ -61,9 +67,4 @@ #define USE_SX1262 #define USE_SX1268 #define USE_LLCC68 - -#ifdef EBYTE_E22 -// Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch -// (which is the default for the sx1262interface code) #define SX126X_E22 -#endif From 8fa71afb72689255cc0f3cade37f0303efb30824 Mon Sep 17 00:00:00 2001 From: code8buster Date: Sun, 30 Oct 2022 22:30:33 -0400 Subject: [PATCH 041/133] We do have wire, just not where it's expected --- variants/diy/dr-dev/variant.h | 1 - 1 file changed, 1 deletion(-) diff --git a/variants/diy/dr-dev/variant.h b/variants/diy/dr-dev/variant.h index e670c5a91..b756536af 100644 --- a/variants/diy/dr-dev/variant.h +++ b/variants/diy/dr-dev/variant.h @@ -1,5 +1,4 @@ // For OLED LCD -#define HAS_WIRE 0 #define HAS_SCREEN 0 #define I2C_SDA 4 #define I2C_SCL 5 From b24caa1e062fd79b52357648ea953df111c610a3 Mon Sep 17 00:00:00 2001 From: Sacha Weatherstone Date: Mon, 31 Oct 2022 17:32:38 +1000 Subject: [PATCH 042/133] Update links --- README.md | 9 ++++----- bin/promote-release.sh | 3 --- bin/regen-protos.sh | 2 +- src/PowerFSM.cpp | 2 +- src/mesh/Channels.cpp | 2 +- src/mesh/Channels.h | 2 +- src/mesh/generated/portnums.pb.h | 2 +- src/modules/ExternalNotificationModule.cpp | 4 ++-- 8 files changed, 11 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 39aebf9d7..b9d95d485 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Meshtastic Firmware -![GitHub release downloads](https://img.shields.io/github/downloads/meshtastic/meshtastic-device/total) -[![CI](https://img.shields.io/github/workflow/status/meshtastic/Meshtastic-device/CI?label=actions&logo=github&color=yellow)](https://github.com/meshtastic/repo/actions/workflows/main_matrix.yml) -[![CLA assistant](https://cla-assistant.io/readme/badge/meshtastic/Meshtastic-device)](https://cla-assistant.io/meshtastic/Meshtastic-device) +![GitHub release downloads](https://img.shields.io/github/downloads/meshtastic/firmware/total) +[![CI](https://img.shields.io/github/workflow/status/meshtastic/firmware/CI?label=actions&logo=github&color=yellow)](https://github.com/meshtastic/repo/actions/workflows/main_matrix.yml) +[![CLA assistant](https://cla-assistant.io/readme/badge/meshtastic/firmware)](https://cla-assistant.io/meshtastic/firmware) [![Fiscal Contributors](https://opencollective.com/meshtastic/tiers/badge.svg?label=Fiscal%20Contributors&color=deeppink)](https://opencollective.com/meshtastic/) [![Vercel](https://img.shields.io/static/v1?label=Powered%20by&message=Vercel&style=flat&logo=vercel&color=000000)](https://vercel.com?utm_source=meshtastic&utm_campaign=oss) @@ -10,10 +10,9 @@ This repository contains the device firmware for the Meshtastic project. - **[Building Instructions](https://meshtastic.org/docs/developers/Firmware/build)** **[Flashing Instructions](https://meshtastic.org/docs/getting-started/flashing-firmware/)** ## Stats -![Alt](https://repobeats.axiom.co/api/embed/99a2cf5622bb4807f9e8c3b86589f1133cce58a2.svg 'Repobeats analytics image') +![Alt](https://repobeats.axiom.co/api/embed/99a2cf5622bb4807f9e8c3b86589f1133cce58a2.svg "Repobeats analytics image") diff --git a/bin/promote-release.sh b/bin/promote-release.sh index b9380b02b..f96d2a568 100755 --- a/bin/promote-release.sh +++ b/bin/promote-release.sh @@ -9,9 +9,6 @@ VERSION=`bin/buildinfo.py long` # Must have a V prefix to trigger github git tag "v${VERSION}" -# Commented out per https://github.com/meshtastic/Meshtastic-device/issues/947 -#git push root "v${VERSION}" # push the tag - git push origin "v${VERSION}" # push the tag echo "Tag ${VERSION} pushed to github, github actions should now be building the draft release. If it seems good, click to publish it" diff --git a/bin/regen-protos.sh b/bin/regen-protos.sh index 9c16591e3..2734c213b 100755 --- a/bin/regen-protos.sh +++ b/bin/regen-protos.sh @@ -3,7 +3,7 @@ set -e echo "This script requires https://jpa.kapsi.fi/nanopb/download/ version 0.4.6 to be located in the" -echo "meshtastic-device root directory if the following step fails, you should download the correct" +echo "firmware root directory if the following step fails, you should download the correct" echo "prebuilt binaries for your computer into nanopb-0.4.6" # the nanopb tool seems to require that the .options file be in the current directory! diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index c16f52592..dd3992a14 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -337,7 +337,7 @@ void PowerFSM_setup() #ifdef ARCH_ESP32 // We never enter light-sleep or NB states on NRF52 (because the CPU uses so little power normally) - // See: https://github.com/meshtastic/Meshtastic-device/issues/1071 + // See: https://github.com/meshtastic/firmware/issues/1071 if (isRouter || config.power.is_power_saving) { powerFSM.add_timed_transition(&stateNB, &stateLS, getConfiguredOrDefaultMs(config.power.min_wake_secs, default_min_wake_secs), NULL, "Min wake timeout"); powerFSM.add_timed_transition(&stateDARK, &stateLS, getConfiguredOrDefaultMs(config.power.wait_bluetooth_secs, default_wait_bluetooth_secs), NULL, "Bluetooth timeout"); diff --git a/src/mesh/Channels.cpp b/src/mesh/Channels.cpp index 0af92a5c9..9ae211e6e 100644 --- a/src/mesh/Channels.cpp +++ b/src/mesh/Channels.cpp @@ -267,7 +267,7 @@ their nodes * * This function will also need to be implemented in GUI apps that talk to the radio. * -* https://github.com/meshtastic/Meshtastic-device/issues/269 +* https://github.com/meshtastic/firmware/issues/269 */ const char *Channels::getPrimaryName() { diff --git a/src/mesh/Channels.h b/src/mesh/Channels.h index 5c5af0ec2..ebf08d32c 100644 --- a/src/mesh/Channels.h +++ b/src/mesh/Channels.h @@ -74,7 +74,7 @@ class Channels * * This function will also need to be implemented in GUI apps that talk to the radio. * - * https://github.com/meshtastic/Meshtastic-device/issues/269 + * https://github.com/meshtastic/firmware/issues/269 */ const char *getPrimaryName(); diff --git a/src/mesh/generated/portnums.pb.h b/src/mesh/generated/portnums.pb.h index 3c68e9bb0..d272fe2b9 100644 --- a/src/mesh/generated/portnums.pb.h +++ b/src/mesh/generated/portnums.pb.h @@ -81,7 +81,7 @@ typedef enum _PortNum { PortNum_SIMULATOR_APP = 69, /* Private applications should use portnums >= 256. To simplify initial development and testing you can use "PRIVATE_APP" - in your code without needing to rebuild protobuf files (via [regen-protos.sh](https://github.com/meshtastic/Meshtastic-device/blob/master/bin/regen-protos.sh)) */ + in your code without needing to rebuild protobuf files (via [regen-protos.sh](https://github.com/meshtastic/firmware/blob/master/bin/regen-protos.sh)) */ PortNum_PRIVATE_APP = 256, /* ATAK Forwarder Module https://github.com/paulmandal/atak-forwarder */ PortNum_ATAK_FORWARDER = 257, diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 56a0db941..366ec6849 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -16,10 +16,10 @@ /* Documentation: - https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/modules/ExternalNotificationModule.md + https://github.com/meshtastic/firmware/blob/master/docs/software/modules/ExternalNotificationModule.md This module supports: - https://github.com/meshtastic/Meshtastic-device/issues/654 + https://github.com/meshtastic/firmware/issues/654 Quick reference: From 0149171e1a064a06c2f84062225918e932a4a91b Mon Sep 17 00:00:00 2001 From: Sacha Weatherstone Date: Mon, 31 Oct 2022 18:21:10 +1000 Subject: [PATCH 043/133] update repobeats url --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b9d95d485..8d08e200e 100644 --- a/README.md +++ b/README.md @@ -15,4 +15,4 @@ This repository contains the device firmware for the Meshtastic project. ## Stats -![Alt](https://repobeats.axiom.co/api/embed/99a2cf5622bb4807f9e8c3b86589f1133cce58a2.svg "Repobeats analytics image") +![Alt](https://repobeats.axiom.co/api/embed/a92f097d9197ae853e780ec53d7d126e545629ab.svg "Repobeats analytics image") From 5b648be2a5823512abf50faaa09ebaf6e66d77ef Mon Sep 17 00:00:00 2001 From: Sacha Weatherstone Date: Mon, 31 Oct 2022 18:47:10 +1000 Subject: [PATCH 044/133] More renaming --- .github/workflows/main_matrix.yml | 21 ++++++++++----------- .gitmodules | 2 +- src/mesh/http/ContentHandler.cpp | 14 ++++++-------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index c50adb941..e3d1dbadb 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -43,7 +43,7 @@ jobs: - board: m5stack-coreink - board: tbeam-s3-core # - board: pico - + runs-on: ubuntu-latest steps: - name: Checkout code @@ -133,11 +133,11 @@ jobs: - name: Upgrade platformio run: | pio upgrade - + - name: Pull web ui uses: dsaltares/fetch-gh-release-asset@master with: - repo: "meshtastic/meshtastic-web" + repo: "meshtastic/web" file: "build.tar" target: "build.tar" token: ${{ secrets.GITHUB_TOKEN }} @@ -149,7 +149,7 @@ jobs: - name: Build ESP32 run: bin/build-esp32.sh ${{ matrix.board }} - + - name: Pull OTA Firmware uses: dsaltares/fetch-gh-release-asset@master with: @@ -157,7 +157,7 @@ jobs: file: "firmware.bin" target: "release/bleota.bin" token: ${{ secrets.GITHUB_TOKEN }} - + - name: Get release version string run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT id: version @@ -394,7 +394,7 @@ jobs: # For diagnostics - name: Show artifacts run: ls -lR - + - name: Device scripts permissions run: | chmod +x ./output/device-install.sh @@ -429,7 +429,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - + - name: Setup Python uses: actions/setup-python@v4 with: @@ -443,7 +443,7 @@ jobs: with: name: firmware-${{ steps.version.outputs.version }} path: ./output - + - name: Device scripts permissions run: | chmod +x ./output/device-install.sh @@ -456,7 +456,7 @@ jobs: with: name: debug-elfs-${{ steps.version.outputs.version }}.zip path: ./elfs - + - name: Zip Elfs run: zip -j -r ./debug-elfs-${{ steps.version.outputs.version }}.zip ./elfs @@ -500,10 +500,9 @@ jobs: - name: Bump version.properties run: >- bin/bump_version.py - + - name: Create version.properties pull request uses: peter-evans/create-pull-request@v3 with: add-paths: | version.properties - diff --git a/.gitmodules b/.gitmodules index 489f01bea..e6f376a0b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "protobufs"] path = protobufs - url = https://github.com/meshtastic/Meshtastic-protobufs.git + url = https://github.com/meshtastic/protobufs.git diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index ddc67e16d..82ac8feef 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -58,8 +58,6 @@ char contentTypes[][2][32] = {{".txt", "text/plain"}, {".html", "text/html"} {".css", "text/css"}, {".ico", "image/vnd.microsoft.icon"}, {".svg", "image/svg+xml"}, {"", ""}}; -// const char *tarURL = "https://www.casler.org/temp/meshtastic-web.tar"; -// const char *tarURL = "https://api-production-871d.up.railway.app/mirror/webui"; // const char *certificate = NULL; // change this as needed, leave as is for no TLS check (yolo security) // Our API to handle messages to and from the radio. @@ -75,8 +73,8 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer) ResourceNode *nodeAPIv1ToRadio = new ResourceNode("/api/v1/toradio", "PUT", &handleAPIv1ToRadio); ResourceNode *nodeAPIv1FromRadio = new ResourceNode("/api/v1/fromradio", "GET", &handleAPIv1FromRadio); -// ResourceNode *nodeHotspotApple = new ResourceNode("/hotspot-detect.html", "GET", &handleHotspot); -// ResourceNode *nodeHotspotAndroid = new ResourceNode("/generate_204", "GET", &handleHotspot); + // ResourceNode *nodeHotspotApple = new ResourceNode("/hotspot-detect.html", "GET", &handleHotspot); + // ResourceNode *nodeHotspotAndroid = new ResourceNode("/generate_204", "GET", &handleHotspot); ResourceNode *nodeAdmin = new ResourceNode("/admin", "GET", &handleAdmin); // ResourceNode *nodeAdminSettings = new ResourceNode("/admin/settings", "GET", &handleAdminSettings); @@ -160,7 +158,7 @@ void handleAPIv1FromRadio(HTTPRequest *req, HTTPResponse *res) res->setHeader("Content-Type", "application/x-protobuf"); res->setHeader("Access-Control-Allow-Origin", "*"); res->setHeader("Access-Control-Allow-Methods", "GET"); - res->setHeader("X-Protobuf-Schema", "https://raw.githubusercontent.com/meshtastic/Meshtastic-protobufs/master/mesh.proto"); + res->setHeader("X-Protobuf-Schema", "https://raw.githubusercontent.com/meshtastic/protobufs/master/mesh.proto"); uint8_t txBuf[MAX_STREAM_BUF_SIZE]; uint32_t len = 1; @@ -204,7 +202,7 @@ void handleAPIv1ToRadio(HTTPRequest *req, HTTPResponse *res) res->setHeader("Access-Control-Allow-Headers", "Content-Type"); res->setHeader("Access-Control-Allow-Origin", "*"); res->setHeader("Access-Control-Allow-Methods", "PUT, OPTIONS"); - res->setHeader("X-Protobuf-Schema", "https://raw.githubusercontent.com/meshtastic/Meshtastic-protobufs/master/mesh.proto"); + res->setHeader("X-Protobuf-Schema", "https://raw.githubusercontent.com/meshtastic/protobufs/master/mesh.proto"); if (req->getMethod() == "OPTIONS") { res->setStatusCode(204); // Success with no content @@ -266,7 +264,7 @@ std::vector> *htmlListDir(std::vector> *htmlListDir(std::vector thisFileMap; thisFileMap[strdup("size")] = strdup(String(file.size()).c_str()); -#ifdef ARCH_ESP32 +#ifdef ARCH_ESP32 thisFileMap[strdup("name")] = strdup(String(file.path()).substring(1).c_str()); #else thisFileMap[strdup("name")] = strdup(String(file.name()).substring(1).c_str()); From 60e95ef3bdc89f20e00e8f23355cf7b7b3011cae Mon Sep 17 00:00:00 2001 From: Sacha Weatherstone Date: Mon, 31 Oct 2022 18:54:47 +1000 Subject: [PATCH 045/133] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d08e200e..6432803e4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Meshtastic Firmware ![GitHub release downloads](https://img.shields.io/github/downloads/meshtastic/firmware/total) -[![CI](https://img.shields.io/github/workflow/status/meshtastic/firmware/CI?label=actions&logo=github&color=yellow)](https://github.com/meshtastic/repo/actions/workflows/main_matrix.yml) +[![CI](https://img.shields.io/github/workflow/status/meshtastic/firmware/CI?label=actions&logo=github&color=yellow)](https://github.com/meshtastic/firmware/actions/workflows/main_matrix.yml) [![CLA assistant](https://cla-assistant.io/readme/badge/meshtastic/firmware)](https://cla-assistant.io/meshtastic/firmware) [![Fiscal Contributors](https://opencollective.com/meshtastic/tiers/badge.svg?label=Fiscal%20Contributors&color=deeppink)](https://opencollective.com/meshtastic/) [![Vercel](https://img.shields.io/static/v1?label=Powered%20by&message=Vercel&style=flat&logo=vercel&color=000000)](https://vercel.com?utm_source=meshtastic&utm_campaign=oss) From a1ed5cdffc5ea378ddbebdf58f86e33e79c12ea3 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 31 Oct 2022 07:51:44 -0500 Subject: [PATCH 046/133] 2.0 (To be merged Nov 1) (#1870) * 2.0 * Catch the right version of the common files --- .github/workflows/main_matrix.yml | 2 +- version.properties | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index e3d1dbadb..20d71f833 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -371,7 +371,7 @@ jobs: id: version - name: Move files up - run: mv -b -t ./ ./*tbeam-1*/littlefs*.bin ./*tbeam-1*/bleota.bin ./**/firmware*.bin ./*t-echo*/Meshtastic_nRF52_factory_erase.uf2 ./**/firmware-*.uf2 ./**/firmware-*-ota.zip ./**/*.elf ./**/meshtasticd_linux_amd64 ./*native*/*device-*.sh ./*native*/*device-*.bat + run: mv -b -t ./ ./*tbeam-2*/littlefs*.bin ./*tbeam-2*/bleota.bin ./**/firmware*.bin ./*t-echo*/Meshtastic_nRF52_factory_erase.uf2 ./**/firmware-*.uf2 ./**/firmware-*-ota.zip ./**/*.elf ./**/meshtasticd_linux_amd64 ./*native*/*device-*.sh ./*native*/*device-*.bat - name: Repackage in single firmware zip uses: actions/upload-artifact@v3 diff --git a/version.properties b/version.properties index 0dbcdca97..7d6851090 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] -major = 1 -minor = 3 -build = 49 +major = 2 +minor = 0 +build = 0 From 18ab8749ffb669c292ef1e948cb6cfabf2666f40 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 31 Oct 2022 08:09:22 -0500 Subject: [PATCH 047/133] Update protobuf ref --- protobufs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protobufs b/protobufs index 46bc0afe0..ed9f2499d 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 46bc0afe050a836b6ec8b235c3ff55e9e037efcb +Subproject commit ed9f2499d692925461facd64c6af2d2a7672245a From b4d6c8f37b59fda4608624d668a7244189bd8d61 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 31 Oct 2022 08:32:21 -0500 Subject: [PATCH 048/133] Update verbiage --- .github/workflows/main_matrix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 20d71f833..068283dd7 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -470,7 +470,7 @@ jobs: with: draft: true prerelease: true - release_name: Meshtastic Device ${{ steps.version.outputs.version }} Alpha + release_name: Meshtastic Firmware ${{ steps.version.outputs.version }} tag_name: v${{ steps.version.outputs.version }} body: | Autogenerated by github action, developer should edit as required before publishing... From b7ef63230be5567734d72ffc077e92deaef81caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 31 Oct 2022 14:50:31 +0100 Subject: [PATCH 049/133] new location of ota firmware --- .github/workflows/main_matrix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 068283dd7..06a229312 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -153,7 +153,7 @@ jobs: - name: Pull OTA Firmware uses: dsaltares/fetch-gh-release-asset@master with: - repo: "meshtastic/Meshtastic-OTA" + repo: "meshtastic/firmware-ota" file: "firmware.bin" target: "release/bleota.bin" token: ${{ secrets.GITHUB_TOKEN }} From 3d8e6aead291e80b6bb8add8645a7041a5496cf2 Mon Sep 17 00:00:00 2001 From: code8buster Date: Mon, 31 Oct 2022 21:39:11 -0400 Subject: [PATCH 050/133] Put more of the module specific pins in their blocks --- variants/diy/dr-dev/variant.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/variants/diy/dr-dev/variant.h b/variants/diy/dr-dev/variant.h index b756536af..7d0625907 100644 --- a/variants/diy/dr-dev/variant.h +++ b/variants/diy/dr-dev/variant.h @@ -1,4 +1,4 @@ -// For OLED LCD +// Initialize i2c bus on sd_dat and esp_led pins, respectively. We need a bus to not hang on boot #define HAS_SCREEN 0 #define I2C_SDA 4 #define I2C_SCL 5 @@ -27,7 +27,7 @@ #undef RF95_MOSI #define RF95_MOSI 23 -// --PINS FOR THE 900M22S +// PINS FOR THE 900M22S #define LORA_DIO1 26 // IRQ for SX1262/SX1268 #define LORA_DIO2 22 // BUSY for SX1262/SX1268 @@ -36,17 +36,19 @@ #undef RF95_NSS #define RF95_NSS 16 #define SX126X_BUSY 22 +#define SX126X_CS 16 // PINS FOR THE 900M30S /* #define LORA_DIO1 27 // IRQ for SX1262/SX1268 -#define LORA_RXEN 21 // Input - RF switch RX control, connecting external MCU IO, valid in high level #define LORA_DIO2 35 // BUSY for SX1262/SX1268 #define LORA_TXEN NOT_A_PIN // Input - RF switch TX control, connecting external MCU IO or DIO2, valid in high level +#define LORA_RXEN 21 // Input - RF switch RX control, connecting external MCU IO, valid in high level #undef RF95_NSS #define RF95_NSS 33 #define SX126X_BUSY 35 +#define SX126X_CS 33 */ // RX/TX for RFM95/SX127x @@ -55,15 +57,15 @@ // #define RF95_TCXO // common pinouts for SX126X modules -#define SX126X_CS 33 + #define SX126X_DIO1 LORA_DIO1 #define SX126X_RESET LORA_RESET #define SX126X_RXEN LORA_RXEN #define SX126X_TXEN LORA_TXEN // supported modules list -#define USE_RF95 // RFM95/SX127x +//#define USE_RF95 // RFM95/SX127x #define USE_SX1262 -#define USE_SX1268 -#define USE_LLCC68 +//#define USE_SX1268 +//#define USE_LLCC68 #define SX126X_E22 From 32ad8aaa4e84f2b2968accacc6e07927bb08e3ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 2 Nov 2022 10:17:59 +0100 Subject: [PATCH 051/133] tryfix compile with NO_SCREEN --- src/graphics/Screen.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index cee00f174..23828b3ee 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -10,7 +10,7 @@ namespace graphics class Screen { public: - Screen(char){} + explicit Screen(char){} void onPress() {} void setup() {} void setOn(bool) {} From 85b541bfd93c4397201070efb3a3053a41d132d4 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Wed, 2 Nov 2022 12:58:14 +0100 Subject: [PATCH 052/133] Portduino only: don't continue to try rebooting (#1887) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Thomas Göttgens --- src/shutdown.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/shutdown.h b/src/shutdown.h index 678a1401c..3927825fb 100644 --- a/src/shutdown.h +++ b/src/shutdown.h @@ -13,7 +13,8 @@ void powerCommandsCheck() #elif defined(ARCH_NRF52) NVIC_SystemReset(); #else - DEBUG_MSG("FIXME implement reboot for this platform"); + rebootAtMsec = -1; + DEBUG_MSG("FIXME implement reboot for this platform. Skipping for now.\n"); #endif } From 12df55c3d472fb363d299db2b7d5248363ac3944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 2 Nov 2022 13:12:15 +0100 Subject: [PATCH 053/133] Support for TLORA 2.1-1.8 --- src/main.cpp | 10 +++--- src/mesh/InterfacesTemplates.cpp | 2 +- ...X1281Interface.cpp => SX1280Interface.cpp} | 4 +-- .../{SX1281Interface.h => SX1280Interface.h} | 6 ++-- src/mesh/SX128xInterface.h | 2 +- src/platform/esp32/architecture.h | 2 ++ variants/tlora_v2_1_18/platformio.ini | 7 ++++ variants/tlora_v2_1_18/variant.h | 33 +++++++++++++++++++ 8 files changed, 54 insertions(+), 12 deletions(-) rename src/mesh/{SX1281Interface.cpp => SX1280Interface.cpp} (72%) rename src/mesh/{SX1281Interface.h => SX1280Interface.h} (52%) create mode 100644 variants/tlora_v2_1_18/platformio.ini create mode 100644 variants/tlora_v2_1_18/variant.h diff --git a/src/main.cpp b/src/main.cpp index 20bbcd085..8836b6460 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,7 +51,7 @@ #include "RF95Interface.h" #include "SX1262Interface.h" #include "SX1268Interface.h" -#include "SX1281Interface.h" +#include "SX1280Interface.h" #if !HAS_RADIO && defined(ARCH_PORTDUINO) #include "platform/portduino/SimRadio.h" #endif @@ -372,15 +372,15 @@ void setup() } #endif -#if defined(USE_SX1281) && !defined(ARCH_PORTDUINO) +#if defined(USE_SX1280) && !defined(ARCH_PORTDUINO) if (!rIf) { - rIf = new SX1281Interface(SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY, SPI); + rIf = new SX1280Interface(SX128X_CS, SX128X_DIO1, SX128X_RESET, SX128X_BUSY, SPI); if (!rIf->init()) { - DEBUG_MSG("Warning: Failed to find SX1281 radio\n"); + DEBUG_MSG("Warning: Failed to find SX1280 radio\n"); delete rIf; rIf = NULL; } else { - DEBUG_MSG("SX1281 Radio init succeeded, using SX1281 radio\n"); + DEBUG_MSG("SX1280 Radio init succeeded, using SX1280 radio\n"); rIf_wide_lora = true; } } diff --git a/src/mesh/InterfacesTemplates.cpp b/src/mesh/InterfacesTemplates.cpp index 6707813db..ccef2df23 100644 --- a/src/mesh/InterfacesTemplates.cpp +++ b/src/mesh/InterfacesTemplates.cpp @@ -9,5 +9,5 @@ template class SX126xInterface; template class SX126xInterface; #if !defined(ARCH_PORTDUINO) -template class SX128xInterface; +template class SX128xInterface; #endif \ No newline at end of file diff --git a/src/mesh/SX1281Interface.cpp b/src/mesh/SX1280Interface.cpp similarity index 72% rename from src/mesh/SX1281Interface.cpp rename to src/mesh/SX1280Interface.cpp index 50805cfe0..37aad1d40 100644 --- a/src/mesh/SX1281Interface.cpp +++ b/src/mesh/SX1280Interface.cpp @@ -1,10 +1,10 @@ #include "configuration.h" -#include "SX1281Interface.h" +#include "SX1280Interface.h" #include "error.h" #if !defined(ARCH_PORTDUINO) -SX1281Interface::SX1281Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy, +SX1280Interface::SX1280Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy, SPIClass &spi) : SX128xInterface(cs, irq, rst, busy, spi) { diff --git a/src/mesh/SX1281Interface.h b/src/mesh/SX1280Interface.h similarity index 52% rename from src/mesh/SX1281Interface.h rename to src/mesh/SX1280Interface.h index 3bd65309a..1c2e24900 100644 --- a/src/mesh/SX1281Interface.h +++ b/src/mesh/SX1280Interface.h @@ -3,15 +3,15 @@ #include "SX128xInterface.h" /** - * Our adapter for SX1281 radios + * Our adapter for SX1280 radios */ #if !defined(ARCH_PORTDUINO) -class SX1281Interface : public SX128xInterface +class SX1280Interface : public SX128xInterface { public: - SX1281Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy, SPIClass &spi); + SX1280Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy, SPIClass &spi); }; #endif \ No newline at end of file diff --git a/src/mesh/SX128xInterface.h b/src/mesh/SX128xInterface.h index d01dfc510..f712b8bc4 100644 --- a/src/mesh/SX128xInterface.h +++ b/src/mesh/SX128xInterface.h @@ -6,7 +6,7 @@ /** * \brief Adapter for SX128x radio family. Implements common logic for child classes. - * \tparam T RadioLib module type for SX128x: SX1281. + * \tparam T RadioLib module type for SX128x: SX1280. */ template class SX128xInterface : public RadioLibInterface diff --git a/src/platform/esp32/architecture.h b/src/platform/esp32/architecture.h index 18253abe5..00d221691 100644 --- a/src/platform/esp32/architecture.h +++ b/src/platform/esp32/architecture.h @@ -70,6 +70,8 @@ #define HW_VENDOR HardwareModel_TLORA_V1_1P3 #elif defined(TLORA_V2_1_16) #define HW_VENDOR HardwareModel_TLORA_V2_1_1P6 +#elif defined(TLORA_V2_1_18) + #define HW_VENDOR HardwareModel_TLORA_V2_1_1P8 #elif defined(GENIEBLOCKS) #define HW_VENDOR HardwareModel_GENIEBLOCKS #elif defined(PRIVATE_HW) diff --git a/variants/tlora_v2_1_18/platformio.ini b/variants/tlora_v2_1_18/platformio.ini new file mode 100644 index 000000000..2cb1c3d2f --- /dev/null +++ b/variants/tlora_v2_1_18/platformio.ini @@ -0,0 +1,7 @@ +[env:tlora-v2-1-1.8] +extends = esp32_base +board = ttgo-lora32-v21 +lib_deps = + ${esp32_base.lib_deps} +build_flags = + ${esp32_base.build_flags} -D TLORA_V2_1_18 -I variants/tlora_v2_1_18 \ No newline at end of file diff --git a/variants/tlora_v2_1_18/variant.h b/variants/tlora_v2_1_18/variant.h new file mode 100644 index 000000000..cd693a3d2 --- /dev/null +++ b/variants/tlora_v2_1_18/variant.h @@ -0,0 +1,33 @@ +#undef GPS_RX_PIN +#undef GPS_TX_PIN +#define GPS_RX_PIN 15 // per @der_bear on the forum, 36 is incorrect for this board type and 15 is a better pick +#define GPS_TX_PIN 13 + +#define EXT_NOTIFY_OUT 2 // Default pin to use for Ext Notify Module. + +#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +// ratio of voltage divider = 2.0 (R42=100k, R43=100k) +#define ADC_MULTIPLIER 2.11 // 2.0 + 10% for correction of display undervoltage. + +#define I2C_SDA 21 // I2C pins for this board +#define I2C_SCL 22 + +// #define RESET_OLED 16 // If defined, this pin will be used to reset the display controller. Crashes on newer ESP-IDF and not needed per schematic + +#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost +#define LED_PIN 25 // If defined we will blink this LED +#define BUTTON_PIN 12 // If defined, this will be used for user button presses, + +#define BUTTON_NEED_PULLUP + +#define USE_SX1280 +#define LORA_DIO0 26 // a No connect on the SX1262 module +#define LORA_RESET 23 + +#define SX128X_CS 18 // FIXME - we really should define LORA_CS instead +#define SX128X_DIO1 33 +#define SX128X_BUSY 32 +#define SX128X_RESET LORA_RESET +#define SX128X_E22 // Not really an E22 but TTGO seems to be trying to clone that +// Internally the TTGO module hooks the SX1280-DIO2 in to control the TX/RX switch (which is the default for the sx1280interface +// code) From b2969b2faf8f07df2f3856b6e3f0572a05c9bbfa Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Wed, 2 Nov 2022 13:18:15 +0100 Subject: [PATCH 054/133] Don't allow arbitrary channel name for admin (#1886) Co-authored-by: Ben Meadors --- src/mesh/MeshModule.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/mesh/MeshModule.cpp b/src/mesh/MeshModule.cpp index 7b204ae49..ca1fb5b50 100644 --- a/src/mesh/MeshModule.cpp +++ b/src/mesh/MeshModule.cpp @@ -109,10 +109,7 @@ void MeshModule::callPlugins(const MeshPacket &mp, RxSource src) /// Also: if a packet comes in on the local PC interface, we don't check for bound channels, because it is TRUSTED and it needs to /// to be able to fetch the initial admin packets without yet knowing any channels. - bool rxChannelOk = !pi.boundChannel || (mp.from == 0) || - !ch || - strlen(ch->settings.name) > 0 || - (strcasecmp(ch->settings.name, pi.boundChannel) == 0); + bool rxChannelOk = !pi.boundChannel || (mp.from == 0) || (strcasecmp(ch->settings.name, pi.boundChannel) == 0); if (!rxChannelOk) { // no one should have already replied! From 39c1637030da260eeefe30eba3f32f53d987af36 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 2 Nov 2022 07:48:14 -0500 Subject: [PATCH 055/133] Experimental DIY nrf52840 feather support (#1884) * Experimental DIY nrf52840 feather support * Fix target * sx1262 wiring * Remove lib --- .github/workflows/main_matrix.yml | 2 ++ src/platform/nrf52/architecture.h | 2 +- variants/feather_diy/platformio.ini | 11 ++++++++++ variants/feather_diy/variant.h | 33 +++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 variants/feather_diy/platformio.ini create mode 100644 variants/feather_diy/variant.h diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 06a229312..66bf7539c 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -42,6 +42,7 @@ jobs: - board: m5stack-core - board: m5stack-coreink - board: tbeam-s3-core + - board: feather_diy # - board: pico runs-on: ubuntu-latest @@ -181,6 +182,7 @@ jobs: - board: rak4631_eink - board: t-echo - board: pca10059_diy_eink + - board: feather_diy runs-on: ubuntu-latest steps: diff --git a/src/platform/nrf52/architecture.h b/src/platform/nrf52/architecture.h index 47d95c92d..986a864c9 100644 --- a/src/platform/nrf52/architecture.h +++ b/src/platform/nrf52/architecture.h @@ -45,7 +45,7 @@ #define HW_VENDOR HardwareModel_T_ECHO #elif defined(NORDIC_PCA10059) #define HW_VENDOR HardwareModel_NRF52840_PCA10059 -#elif defined(PRIVATE_HW) +#elif defined(PRIVATE_HW) || defined(FEATHER_DIY) #define HW_VENDOR HardwareModel_PRIVATE_HW #else #define HW_VENDOR HardwareModel_NRF52_UNKNOWN diff --git a/variants/feather_diy/platformio.ini b/variants/feather_diy/platformio.ini new file mode 100644 index 000000000..446011cb9 --- /dev/null +++ b/variants/feather_diy/platformio.ini @@ -0,0 +1,11 @@ +; The very slick RAK wireless RAK 4631 / 4630 board - Unified firmware for 5005/19003, with or without OLED RAK 1921 +[env:feather_diy] +extends = nrf52840_base +board = adafruit_feather_nrf52840 +build_flags = ${nrf52840_base.build_flags} -Ivariants/feather_diy -D feather_diy +build_src_filter = ${nrf52_base.build_src_filter} +<../variants/feather_diy> +lib_deps = + ${nrf52840_base.lib_deps} +debug_tool = jlink +; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) +;upload_protocol = jlink \ No newline at end of file diff --git a/variants/feather_diy/variant.h b/variants/feather_diy/variant.h new file mode 100644 index 000000000..8327e6050 --- /dev/null +++ b/variants/feather_diy/variant.h @@ -0,0 +1,33 @@ +// For OLED LCD +#define I2C_SDA 22 +#define I2C_SCL 23 + +#define BUTTON_PIN 7 + +#define LORA_DIO0 -1 // a No connect on the SX1262/SX1268 module +#define LORA_RESET 13 // RST for SX1276, and for SX1262/SX1268 +#define LORA_DIO1 11 // IRQ for SX1262/SX1268 +#define LORA_DIO2 12 // BUSY for SX1262/SX1268 +#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262/SX1268, if DIO3 is high the TXCO is enabled + +#define RF95_SCK SCK +#define RF95_MISO MI +#define RF95_MOSI MO +#define RF95_NSS D2 + +// supported modules list +#define USE_SX1262 + +// common pinouts for SX126X modules +#define SX126X_CS RF95_NSS // NSS for SX126X +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY LORA_DIO2 +#define SX126X_RESET LORA_RESET +#define SX126X_RXEN 10 +#define SX126X_TXEN 9 + +#ifdef EBYTE_E22 +// Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch +// (which is the default for the sx1262interface code) +#define SX126X_E22 +#endif From 05b9fd04c6a393221ab8cf6e13979b762b3c0bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 2 Nov 2022 15:08:49 +0100 Subject: [PATCH 056/133] switch submodule branch to develop --- .gitmodules | 1 + protobufs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index e6f376a0b..238eda7de 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "protobufs"] path = protobufs url = https://github.com/meshtastic/protobufs.git + branch = develop diff --git a/protobufs b/protobufs index ed9f2499d..fa47c6455 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit ed9f2499d692925461facd64c6af2d2a7672245a +Subproject commit fa47c64558473c806ca6535d407df7409acbc283 From cae75dcb6da79e43e52856a25f29d652f3c7f863 Mon Sep 17 00:00:00 2001 From: code8buster Date: Sun, 30 Oct 2022 22:27:16 -0400 Subject: [PATCH 057/133] Rearranging deck chairs, 900M22S working, 30S not --- variants/diy/dr-dev/variant.h | 51 ++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/variants/diy/dr-dev/variant.h b/variants/diy/dr-dev/variant.h index 6356cad14..e670c5a91 100644 --- a/variants/diy/dr-dev/variant.h +++ b/variants/diy/dr-dev/variant.h @@ -1,47 +1,54 @@ // For OLED LCD -#define I2C_SDA 21 -#define I2C_SCL 22 +#define HAS_WIRE 0 +#define HAS_SCREEN 0 +#define I2C_SDA 4 +#define I2C_SCL 5 // GPS #undef GPS_RX_PIN #define GPS_RX_PIN NOT_A_PIN -#undef WANT_GPS +#define HAS_GPS 0 -#define BUTTON_PIN 2 // The middle button GPIO on the T-Beam +#define BUTTON_PIN 13 // The middle button GPIO on the T-Beam #define BUTTON_NEED_PULLUP #define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975). -#define LORA_DIO0 -1 // a No connect on the SX1262/SX1268 module -#define LORA_RESET -1 // RST for SX1276, and for SX1262/SX1268 -#define LORA_DIO1 27 // IRQ for SX1262/SX1268 (IO26 FOR 22S) -#define LORA_DIO2 NOT_A_PIN // BUSY for SX1262/SX1268 -#define LORA_DIO3 // Not connected on PCB, but internally on the SX1262/SX1268, if DIO3 is high the TXCO is enabled +#define LORA_DIO0 NOT_A_PIN // a No connect on the SX1262/SX1268 module +#define LORA_RESET NOT_A_PIN // RST for SX1276, and for SX1262/SX1268 +#define LORA_DIO3 NOT_A_PIN // Not connected on PCB, but internally on the SX1262/SX1268, if DIO3 is high the TXCO is enabled // In transmitting, set TXEN as high communication level,RXEN pin is low level; // In receiving, set RXEN as high communication level, TXEN is lowlevel; // Before powering off, set TXEN、RXEN as low level. -#define LORA_RXEN 17 // Input - RF switch RX control, connecting external MCU IO, valid in high level -#define LORA_TXEN -1 // Input - RF switch TX control, connecting external MCU IO or DIO2, valid in high level -/* --PINS FOR THE 900M22S + #undef RF95_SCK #define RF95_SCK 18 #undef RF95_MISO #define RF95_MISO 19 #undef RF95_MOSI #define RF95_MOSI 23 + +// --PINS FOR THE 900M22S + +#define LORA_DIO1 26 // IRQ for SX1262/SX1268 +#define LORA_DIO2 22 // BUSY for SX1262/SX1268 +#define LORA_TXEN NOT_A_PIN // Input - RF switch TX control, connecting external MCU IO or DIO2, valid in high level +#define LORA_RXEN 17 // Input - RF switch RX control, connecting external MCU IO, valid in high level #undef RF95_NSS #define RF95_NSS 16 -*/ +#define SX126X_BUSY 22 + // PINS FOR THE 900M30S -#undef RF95_SCK -#define RF95_SCK 18 -#undef RF95_MISO -#define RF95_MISO 19 -#undef RF95_MOSI -#define RF95_MOSI 23 +/* +#define LORA_DIO1 27 // IRQ for SX1262/SX1268 +#define LORA_RXEN 21 // Input - RF switch RX control, connecting external MCU IO, valid in high level +#define LORA_DIO2 35 // BUSY for SX1262/SX1268 +#define LORA_TXEN NOT_A_PIN // Input - RF switch TX control, connecting external MCU IO or DIO2, valid in high level #undef RF95_NSS #define RF95_NSS 33 +#define SX126X_BUSY 35 +*/ // RX/TX for RFM95/SX127x #define RF95_RXEN LORA_RXEN @@ -51,7 +58,6 @@ // common pinouts for SX126X modules #define SX126X_CS 33 #define SX126X_DIO1 LORA_DIO1 -#define SX126X_BUSY 35 #define SX126X_RESET LORA_RESET #define SX126X_RXEN LORA_RXEN #define SX126X_TXEN LORA_TXEN @@ -61,9 +67,4 @@ #define USE_SX1262 #define USE_SX1268 #define USE_LLCC68 - -#ifdef EBYTE_E22 -// Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch -// (which is the default for the sx1262interface code) #define SX126X_E22 -#endif From 15a8710e694c9b6ec5f7d36673d61bdfdd04cfac Mon Sep 17 00:00:00 2001 From: code8buster Date: Sun, 30 Oct 2022 22:30:33 -0400 Subject: [PATCH 058/133] We do have wire, just not where it's expected --- variants/diy/dr-dev/variant.h | 1 - 1 file changed, 1 deletion(-) diff --git a/variants/diy/dr-dev/variant.h b/variants/diy/dr-dev/variant.h index e670c5a91..b756536af 100644 --- a/variants/diy/dr-dev/variant.h +++ b/variants/diy/dr-dev/variant.h @@ -1,5 +1,4 @@ // For OLED LCD -#define HAS_WIRE 0 #define HAS_SCREEN 0 #define I2C_SDA 4 #define I2C_SCL 5 From 0ce018cf97bd153e19bdbe45442106b1852d4259 Mon Sep 17 00:00:00 2001 From: code8buster Date: Mon, 31 Oct 2022 21:39:11 -0400 Subject: [PATCH 059/133] Put more of the module specific pins in their blocks --- variants/diy/dr-dev/variant.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/variants/diy/dr-dev/variant.h b/variants/diy/dr-dev/variant.h index b756536af..7d0625907 100644 --- a/variants/diy/dr-dev/variant.h +++ b/variants/diy/dr-dev/variant.h @@ -1,4 +1,4 @@ -// For OLED LCD +// Initialize i2c bus on sd_dat and esp_led pins, respectively. We need a bus to not hang on boot #define HAS_SCREEN 0 #define I2C_SDA 4 #define I2C_SCL 5 @@ -27,7 +27,7 @@ #undef RF95_MOSI #define RF95_MOSI 23 -// --PINS FOR THE 900M22S +// PINS FOR THE 900M22S #define LORA_DIO1 26 // IRQ for SX1262/SX1268 #define LORA_DIO2 22 // BUSY for SX1262/SX1268 @@ -36,17 +36,19 @@ #undef RF95_NSS #define RF95_NSS 16 #define SX126X_BUSY 22 +#define SX126X_CS 16 // PINS FOR THE 900M30S /* #define LORA_DIO1 27 // IRQ for SX1262/SX1268 -#define LORA_RXEN 21 // Input - RF switch RX control, connecting external MCU IO, valid in high level #define LORA_DIO2 35 // BUSY for SX1262/SX1268 #define LORA_TXEN NOT_A_PIN // Input - RF switch TX control, connecting external MCU IO or DIO2, valid in high level +#define LORA_RXEN 21 // Input - RF switch RX control, connecting external MCU IO, valid in high level #undef RF95_NSS #define RF95_NSS 33 #define SX126X_BUSY 35 +#define SX126X_CS 33 */ // RX/TX for RFM95/SX127x @@ -55,15 +57,15 @@ // #define RF95_TCXO // common pinouts for SX126X modules -#define SX126X_CS 33 + #define SX126X_DIO1 LORA_DIO1 #define SX126X_RESET LORA_RESET #define SX126X_RXEN LORA_RXEN #define SX126X_TXEN LORA_TXEN // supported modules list -#define USE_RF95 // RFM95/SX127x +//#define USE_RF95 // RFM95/SX127x #define USE_SX1262 -#define USE_SX1268 -#define USE_LLCC68 +//#define USE_SX1268 +//#define USE_LLCC68 #define SX126X_E22 From 57ca5fea81d572879f8dc48f5b8775c0a6291cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 2 Nov 2022 10:17:59 +0100 Subject: [PATCH 060/133] tryfix compile with NO_SCREEN --- src/graphics/Screen.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index cee00f174..23828b3ee 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -10,7 +10,7 @@ namespace graphics class Screen { public: - Screen(char){} + explicit Screen(char){} void onPress() {} void setup() {} void setOn(bool) {} From b1f2025558601066ba3bd914fcbb22b63ac85bf5 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Wed, 2 Nov 2022 12:58:14 +0100 Subject: [PATCH 061/133] Portduino only: don't continue to try rebooting (#1887) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Thomas Göttgens --- src/shutdown.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/shutdown.h b/src/shutdown.h index 678a1401c..3927825fb 100644 --- a/src/shutdown.h +++ b/src/shutdown.h @@ -13,7 +13,8 @@ void powerCommandsCheck() #elif defined(ARCH_NRF52) NVIC_SystemReset(); #else - DEBUG_MSG("FIXME implement reboot for this platform"); + rebootAtMsec = -1; + DEBUG_MSG("FIXME implement reboot for this platform. Skipping for now.\n"); #endif } From 3e82cd7dd46e0368671fa42acbfab9af9167e904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 2 Nov 2022 13:12:15 +0100 Subject: [PATCH 062/133] Support for TLORA 2.1-1.8 --- src/main.cpp | 10 +++--- src/mesh/InterfacesTemplates.cpp | 2 +- ...X1281Interface.cpp => SX1280Interface.cpp} | 4 +-- .../{SX1281Interface.h => SX1280Interface.h} | 6 ++-- src/mesh/SX128xInterface.h | 2 +- src/platform/esp32/architecture.h | 2 ++ variants/tlora_v2_1_18/platformio.ini | 7 ++++ variants/tlora_v2_1_18/variant.h | 33 +++++++++++++++++++ 8 files changed, 54 insertions(+), 12 deletions(-) rename src/mesh/{SX1281Interface.cpp => SX1280Interface.cpp} (72%) rename src/mesh/{SX1281Interface.h => SX1280Interface.h} (52%) create mode 100644 variants/tlora_v2_1_18/platformio.ini create mode 100644 variants/tlora_v2_1_18/variant.h diff --git a/src/main.cpp b/src/main.cpp index 20bbcd085..8836b6460 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,7 +51,7 @@ #include "RF95Interface.h" #include "SX1262Interface.h" #include "SX1268Interface.h" -#include "SX1281Interface.h" +#include "SX1280Interface.h" #if !HAS_RADIO && defined(ARCH_PORTDUINO) #include "platform/portduino/SimRadio.h" #endif @@ -372,15 +372,15 @@ void setup() } #endif -#if defined(USE_SX1281) && !defined(ARCH_PORTDUINO) +#if defined(USE_SX1280) && !defined(ARCH_PORTDUINO) if (!rIf) { - rIf = new SX1281Interface(SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY, SPI); + rIf = new SX1280Interface(SX128X_CS, SX128X_DIO1, SX128X_RESET, SX128X_BUSY, SPI); if (!rIf->init()) { - DEBUG_MSG("Warning: Failed to find SX1281 radio\n"); + DEBUG_MSG("Warning: Failed to find SX1280 radio\n"); delete rIf; rIf = NULL; } else { - DEBUG_MSG("SX1281 Radio init succeeded, using SX1281 radio\n"); + DEBUG_MSG("SX1280 Radio init succeeded, using SX1280 radio\n"); rIf_wide_lora = true; } } diff --git a/src/mesh/InterfacesTemplates.cpp b/src/mesh/InterfacesTemplates.cpp index 6707813db..ccef2df23 100644 --- a/src/mesh/InterfacesTemplates.cpp +++ b/src/mesh/InterfacesTemplates.cpp @@ -9,5 +9,5 @@ template class SX126xInterface; template class SX126xInterface; #if !defined(ARCH_PORTDUINO) -template class SX128xInterface; +template class SX128xInterface; #endif \ No newline at end of file diff --git a/src/mesh/SX1281Interface.cpp b/src/mesh/SX1280Interface.cpp similarity index 72% rename from src/mesh/SX1281Interface.cpp rename to src/mesh/SX1280Interface.cpp index 50805cfe0..37aad1d40 100644 --- a/src/mesh/SX1281Interface.cpp +++ b/src/mesh/SX1280Interface.cpp @@ -1,10 +1,10 @@ #include "configuration.h" -#include "SX1281Interface.h" +#include "SX1280Interface.h" #include "error.h" #if !defined(ARCH_PORTDUINO) -SX1281Interface::SX1281Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy, +SX1280Interface::SX1280Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy, SPIClass &spi) : SX128xInterface(cs, irq, rst, busy, spi) { diff --git a/src/mesh/SX1281Interface.h b/src/mesh/SX1280Interface.h similarity index 52% rename from src/mesh/SX1281Interface.h rename to src/mesh/SX1280Interface.h index 3bd65309a..1c2e24900 100644 --- a/src/mesh/SX1281Interface.h +++ b/src/mesh/SX1280Interface.h @@ -3,15 +3,15 @@ #include "SX128xInterface.h" /** - * Our adapter for SX1281 radios + * Our adapter for SX1280 radios */ #if !defined(ARCH_PORTDUINO) -class SX1281Interface : public SX128xInterface +class SX1280Interface : public SX128xInterface { public: - SX1281Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy, SPIClass &spi); + SX1280Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy, SPIClass &spi); }; #endif \ No newline at end of file diff --git a/src/mesh/SX128xInterface.h b/src/mesh/SX128xInterface.h index d01dfc510..f712b8bc4 100644 --- a/src/mesh/SX128xInterface.h +++ b/src/mesh/SX128xInterface.h @@ -6,7 +6,7 @@ /** * \brief Adapter for SX128x radio family. Implements common logic for child classes. - * \tparam T RadioLib module type for SX128x: SX1281. + * \tparam T RadioLib module type for SX128x: SX1280. */ template class SX128xInterface : public RadioLibInterface diff --git a/src/platform/esp32/architecture.h b/src/platform/esp32/architecture.h index 18253abe5..00d221691 100644 --- a/src/platform/esp32/architecture.h +++ b/src/platform/esp32/architecture.h @@ -70,6 +70,8 @@ #define HW_VENDOR HardwareModel_TLORA_V1_1P3 #elif defined(TLORA_V2_1_16) #define HW_VENDOR HardwareModel_TLORA_V2_1_1P6 +#elif defined(TLORA_V2_1_18) + #define HW_VENDOR HardwareModel_TLORA_V2_1_1P8 #elif defined(GENIEBLOCKS) #define HW_VENDOR HardwareModel_GENIEBLOCKS #elif defined(PRIVATE_HW) diff --git a/variants/tlora_v2_1_18/platformio.ini b/variants/tlora_v2_1_18/platformio.ini new file mode 100644 index 000000000..2cb1c3d2f --- /dev/null +++ b/variants/tlora_v2_1_18/platformio.ini @@ -0,0 +1,7 @@ +[env:tlora-v2-1-1.8] +extends = esp32_base +board = ttgo-lora32-v21 +lib_deps = + ${esp32_base.lib_deps} +build_flags = + ${esp32_base.build_flags} -D TLORA_V2_1_18 -I variants/tlora_v2_1_18 \ No newline at end of file diff --git a/variants/tlora_v2_1_18/variant.h b/variants/tlora_v2_1_18/variant.h new file mode 100644 index 000000000..cd693a3d2 --- /dev/null +++ b/variants/tlora_v2_1_18/variant.h @@ -0,0 +1,33 @@ +#undef GPS_RX_PIN +#undef GPS_TX_PIN +#define GPS_RX_PIN 15 // per @der_bear on the forum, 36 is incorrect for this board type and 15 is a better pick +#define GPS_TX_PIN 13 + +#define EXT_NOTIFY_OUT 2 // Default pin to use for Ext Notify Module. + +#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +// ratio of voltage divider = 2.0 (R42=100k, R43=100k) +#define ADC_MULTIPLIER 2.11 // 2.0 + 10% for correction of display undervoltage. + +#define I2C_SDA 21 // I2C pins for this board +#define I2C_SCL 22 + +// #define RESET_OLED 16 // If defined, this pin will be used to reset the display controller. Crashes on newer ESP-IDF and not needed per schematic + +#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost +#define LED_PIN 25 // If defined we will blink this LED +#define BUTTON_PIN 12 // If defined, this will be used for user button presses, + +#define BUTTON_NEED_PULLUP + +#define USE_SX1280 +#define LORA_DIO0 26 // a No connect on the SX1262 module +#define LORA_RESET 23 + +#define SX128X_CS 18 // FIXME - we really should define LORA_CS instead +#define SX128X_DIO1 33 +#define SX128X_BUSY 32 +#define SX128X_RESET LORA_RESET +#define SX128X_E22 // Not really an E22 but TTGO seems to be trying to clone that +// Internally the TTGO module hooks the SX1280-DIO2 in to control the TX/RX switch (which is the default for the sx1280interface +// code) From ac4e88e0d2676da8b8a605aef11efffedf73142e Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Wed, 2 Nov 2022 13:18:15 +0100 Subject: [PATCH 063/133] Don't allow arbitrary channel name for admin (#1886) Co-authored-by: Ben Meadors --- src/mesh/MeshModule.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/mesh/MeshModule.cpp b/src/mesh/MeshModule.cpp index 7b204ae49..ca1fb5b50 100644 --- a/src/mesh/MeshModule.cpp +++ b/src/mesh/MeshModule.cpp @@ -109,10 +109,7 @@ void MeshModule::callPlugins(const MeshPacket &mp, RxSource src) /// Also: if a packet comes in on the local PC interface, we don't check for bound channels, because it is TRUSTED and it needs to /// to be able to fetch the initial admin packets without yet knowing any channels. - bool rxChannelOk = !pi.boundChannel || (mp.from == 0) || - !ch || - strlen(ch->settings.name) > 0 || - (strcasecmp(ch->settings.name, pi.boundChannel) == 0); + bool rxChannelOk = !pi.boundChannel || (mp.from == 0) || (strcasecmp(ch->settings.name, pi.boundChannel) == 0); if (!rxChannelOk) { // no one should have already replied! From ef18b173cdee1cb1482561ff6cb28353ac1e7758 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 2 Nov 2022 07:48:14 -0500 Subject: [PATCH 064/133] Experimental DIY nrf52840 feather support (#1884) * Experimental DIY nrf52840 feather support * Fix target * sx1262 wiring * Remove lib --- .github/workflows/main_matrix.yml | 2 ++ src/platform/nrf52/architecture.h | 2 +- variants/feather_diy/platformio.ini | 11 ++++++++++ variants/feather_diy/variant.h | 33 +++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 variants/feather_diy/platformio.ini create mode 100644 variants/feather_diy/variant.h diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 06a229312..66bf7539c 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -42,6 +42,7 @@ jobs: - board: m5stack-core - board: m5stack-coreink - board: tbeam-s3-core + - board: feather_diy # - board: pico runs-on: ubuntu-latest @@ -181,6 +182,7 @@ jobs: - board: rak4631_eink - board: t-echo - board: pca10059_diy_eink + - board: feather_diy runs-on: ubuntu-latest steps: diff --git a/src/platform/nrf52/architecture.h b/src/platform/nrf52/architecture.h index 47d95c92d..986a864c9 100644 --- a/src/platform/nrf52/architecture.h +++ b/src/platform/nrf52/architecture.h @@ -45,7 +45,7 @@ #define HW_VENDOR HardwareModel_T_ECHO #elif defined(NORDIC_PCA10059) #define HW_VENDOR HardwareModel_NRF52840_PCA10059 -#elif defined(PRIVATE_HW) +#elif defined(PRIVATE_HW) || defined(FEATHER_DIY) #define HW_VENDOR HardwareModel_PRIVATE_HW #else #define HW_VENDOR HardwareModel_NRF52_UNKNOWN diff --git a/variants/feather_diy/platformio.ini b/variants/feather_diy/platformio.ini new file mode 100644 index 000000000..446011cb9 --- /dev/null +++ b/variants/feather_diy/platformio.ini @@ -0,0 +1,11 @@ +; The very slick RAK wireless RAK 4631 / 4630 board - Unified firmware for 5005/19003, with or without OLED RAK 1921 +[env:feather_diy] +extends = nrf52840_base +board = adafruit_feather_nrf52840 +build_flags = ${nrf52840_base.build_flags} -Ivariants/feather_diy -D feather_diy +build_src_filter = ${nrf52_base.build_src_filter} +<../variants/feather_diy> +lib_deps = + ${nrf52840_base.lib_deps} +debug_tool = jlink +; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) +;upload_protocol = jlink \ No newline at end of file diff --git a/variants/feather_diy/variant.h b/variants/feather_diy/variant.h new file mode 100644 index 000000000..8327e6050 --- /dev/null +++ b/variants/feather_diy/variant.h @@ -0,0 +1,33 @@ +// For OLED LCD +#define I2C_SDA 22 +#define I2C_SCL 23 + +#define BUTTON_PIN 7 + +#define LORA_DIO0 -1 // a No connect on the SX1262/SX1268 module +#define LORA_RESET 13 // RST for SX1276, and for SX1262/SX1268 +#define LORA_DIO1 11 // IRQ for SX1262/SX1268 +#define LORA_DIO2 12 // BUSY for SX1262/SX1268 +#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262/SX1268, if DIO3 is high the TXCO is enabled + +#define RF95_SCK SCK +#define RF95_MISO MI +#define RF95_MOSI MO +#define RF95_NSS D2 + +// supported modules list +#define USE_SX1262 + +// common pinouts for SX126X modules +#define SX126X_CS RF95_NSS // NSS for SX126X +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY LORA_DIO2 +#define SX126X_RESET LORA_RESET +#define SX126X_RXEN 10 +#define SX126X_TXEN 9 + +#ifdef EBYTE_E22 +// Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch +// (which is the default for the sx1262interface code) +#define SX126X_E22 +#endif From 09ddde177c430b86bb26a963b80d674361a0b825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 2 Nov 2022 18:23:41 +0100 Subject: [PATCH 065/133] codec2 Audio Support for SX1280 (untested) --- src/modules/Modules.cpp | 12 +- src/modules/esp32/AudioModule.cpp | 249 ++++++++++++++++++++++++++ src/modules/esp32/AudioModule.h | 68 +++++++ variants/tlora_v2_1_18/platformio.ini | 1 + 4 files changed, 325 insertions(+), 5 deletions(-) create mode 100644 src/modules/esp32/AudioModule.cpp create mode 100644 src/modules/esp32/AudioModule.h diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index 986a375df..d24fa8f26 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -19,6 +19,9 @@ #ifdef ARCH_ESP32 #include "modules/esp32/RangeTestModule.h" #include "modules/esp32/StoreForwardModule.h" +#ifdef USE_SX1280 +#include "modules/esp32/AudioModule.h" +#endif #endif #if defined(ARCH_ESP32) || defined(ARCH_NRF52) #include "modules/ExternalNotificationModule.h" @@ -65,17 +68,16 @@ void setupModules() #endif #ifdef ARCH_ESP32 // Only run on an esp32 based device. - - /* - Maintained by MC Hamster (Jm Casler) jm@casler.org - */ +#ifdef USE_SX1280 + new AudioModule(); +#endif new ExternalNotificationModule(); storeForwardModule = new StoreForwardModule(); new RangeTestModule(); #elif defined(ARCH_NRF52) -new ExternalNotificationModule(); + new ExternalNotificationModule(); #endif // NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra acks diff --git a/src/modules/esp32/AudioModule.cpp b/src/modules/esp32/AudioModule.cpp new file mode 100644 index 000000000..9328bdd81 --- /dev/null +++ b/src/modules/esp32/AudioModule.cpp @@ -0,0 +1,249 @@ +#include "configuration.h" +#include "AudioModule.h" +#include "MeshService.h" +#include "NodeDB.h" +#include "RTC.h" +#include "Router.h" +#include "FSCommon.h" + +#include + +/* + AudioModule + A interface to send raw codec2 audio data over the mesh network. Based on the example code from the ESP32_codec2 project. + https://github.com/deulis/ESP32_Codec2 + + Codec 2 is a low-bitrate speech audio codec (speech coding) + that is patent free and open source develop by David Grant Rowe. + http://www.rowetel.com/ and https://github.com/drowe67/codec2 + + Basic Usage: + 1) Enable the module by setting audio.codec2_enabled to 1. + 2) Set the pins (audio.mic_pin / audio.amp_pin) for your preferred microphone and amplifier GPIO pins. + On tbeam, recommend to use: + audio.mic_chan 7 (GPIO 35) + audio.amp_pin 25 (GPIO 25) + 3) Set audio.timeout to the amount of time to wait before we consider + your voice stream as "done". + 4) Set audio.bitrate to the desired codec2 rate (CODEC2_3200, CODEC2_2400, CODEC2_1600, CODEC2_1400, CODEC2_1300, CODEC2_1200, CODEC2_700, CODEC2_700B) + + KNOWN PROBLEMS + * Until the module is initilized by the startup sequence, the amp_pin pin is in a floating + state. This may produce a bit of "noise". + * Will not work on NRF and the Linux device targets. +*/ + +#define AMIC 7 +#define AAMP 25 +#define PTT_PIN 39 + +#define AUDIO_MODULE_RX_BUFFER 128 +#define AUDIO_MODULE_DATA_MAX Constants_DATA_PAYLOAD_LEN +#define AUDIO_MODULE_MODE 7 // 700B +#define AUDIO_MODULE_ACK 1 + +AudioModule *audioModule; + +#if defined(ARCH_ESP32) && defined(USE_SX1280) +ButterworthFilter hp_filter(240, 8000, ButterworthFilter::ButterworthFilter::Highpass, 1); +#endif + +//int16_t 1KHz sine test tone +int16_t Sine1KHz[8] = { -21210 , -30000, -21210, 0 , 21210 , 30000 , 21210, 0 }; +int Sine1KHz_index = 0; + +uint8_t rx_raw_audio_value = 127; + +AudioModule::AudioModule() : SinglePortModule("AudioModule", PortNum_AUDIO_APP), concurrency::OSThread("AudioModule") {} + +void AudioModule::run_codec2() +{ +#if defined(ARCH_ESP32) && defined(USE_SX1280) + if (state == State::tx) + { + for (int i = 0; i < ADC_BUFFER_SIZE; i++) + speech[i] = (int16_t)hp_filter.Update((float)speech[i]); + + codec2_encode(codec2_state, tx_encode_frame + tx_encode_frame_index, speech); + + //increment the pointer where the encoded frame must be saved + tx_encode_frame_index += 8; + + //If it is the 5th time then we have a ready trasnmission frame + if (tx_encode_frame_index == ENCODE_FRAME_SIZE) + { + tx_encode_frame_index = 0; + //Transmit it + sendPayload(); + } + } + if (state == State::rx) //Receiving + { + //Make a cycle to get each codec2 frame from the received frame + for (int i = 0; i < ENCODE_FRAME_SIZE; i += 8) + { + //Decode the codec2 frame + codec2_decode(codec2_state, output_buffer, rx_encode_frame + i); + + // Add to the audio buffer the 320 samples resulting of the decode of the codec2 frame. + for (int g = 0; g < ADC_BUFFER_SIZE; g++) + audio_fifo.put(output_buffer[g]); + } + } + state = State::standby; +#endif +} + +void AudioModule::handleInterrupt() +{ + audioModule->onTimer(); +} + +void AudioModule::onTimer() +{ +#if defined(ARCH_ESP32) && defined(USE_SX1280) + if (state == State::tx) { + adc_buffer[adc_buffer_index++] = (16 * adc1_get_raw(mic_chan)) - 32768; + + //If you want to test with a 1KHz tone, comment the line above and descomment the three lines below + + // adc_buffer[adc_buffer_index++] = Sine1KHz[Sine1KHz_index++]; + // if (Sine1KHz_index >= 8) + // Sine1KHz_index = 0; + + if (adc_buffer_index == ADC_BUFFER_SIZE) { + adc_buffer_index = 0; + memcpy((void*)speech, (void*)adc_buffer, 2 * ADC_BUFFER_SIZE); + audioModule->setIntervalFromNow(0); // process buffer immediately + } + } else if (state == State::rx) { + + int16_t v; + + //Get a value from audio_fifo and convert it to 0 - 255 to play it in the ADC + //If none value is available the DAC will play the last one that was read, that's + //why the rx_raw_audio_value variable is a global one. + if (audio_fifo.get(&v)) + rx_raw_audio_value = (uint8_t)((v + 32768) / 256); + + //Play + dacWrite(moduleConfig.audio.amp_pin ? moduleConfig.audio.amp_pin : AAMP, rx_raw_audio_value); + } +#endif +} + +int32_t AudioModule::runOnce() +{ +#if defined(ARCH_ESP32) && defined(USE_SX1280) + + if (moduleConfig.audio.codec2_enabled) { + + if (firstTime) { + + DEBUG_MSG("Initializing ADC on Channel %u\n", moduleConfig.audio.mic_chan ? moduleConfig.audio.mic_chan : AMIC); + + mic_chan = moduleConfig.audio.mic_chan ? (adc1_channel_t)(int)moduleConfig.audio.mic_chan : (adc1_channel_t)AMIC; + adc1_config_width(ADC_WIDTH_12Bit); + adc1_config_channel_atten(mic_chan, ADC_ATTEN_DB_6); + + // Start a timer at 8kHz to sample the ADC and play the audio on the DAC. + uint32_t cpufreq = getCpuFrequencyMhz(); + switch (cpufreq){ + case 160: + adcTimer = timerBegin(3, 1000, true); // 160 MHz / 1000 = 160KHz + break; + case 240: + adcTimer = timerBegin(3, 1500, true); // 240 MHz / 1500 = 160KHz + break; + case 320: + adcTimer = timerBegin(3, 2000, true); // 320 MHz / 2000 = 160KHz + break; + case 80: + default: + adcTimer = timerBegin(3, 500, true); // 80 MHz / 500 = 160KHz + break; + } + timerAttachInterrupt(adcTimer, &AudioModule::handleInterrupt, true); + timerAlarmWrite(adcTimer, 20, true); // Interrupts when counter == 20, 8.000 times a second + timerAlarmEnable(adcTimer); + + DEBUG_MSG("Initializing DAC on Pin %u\n", moduleConfig.audio.amp_pin ? moduleConfig.audio.amp_pin : AAMP); + DEBUG_MSG("Initializing PTT on Pin %u\n", moduleConfig.audio.ptt_pin ? moduleConfig.audio.ptt_pin : PTT_PIN); + + // Configure PTT input + pinMode(moduleConfig.audio.ptt_pin ? moduleConfig.audio.ptt_pin : PTT_PIN, INPUT_PULLUP); + + state = State::rx; + + DEBUG_MSG("Setting up codec2 in mode %u\n", moduleConfig.audio.bitrate ? moduleConfig.audio.bitrate : AUDIO_MODULE_MODE); + + codec2_state = codec2_create(moduleConfig.audio.bitrate ? moduleConfig.audio.bitrate : AUDIO_MODULE_MODE); + codec2_set_lpc_post_filter(codec2_state, 1, 0, 0.8, 0.2); + + firstTime = 0; + } else { + // Check if we have a PTT press + if (digitalRead(moduleConfig.audio.ptt_pin ? moduleConfig.audio.ptt_pin : PTT_PIN) == LOW) { + // PTT pressed, recording + state = State::tx; + } + if (state != State::standby) { + run_codec2(); + } + } + + return 100; + } else { + DEBUG_MSG("Audio Module Disabled\n"); + + return INT32_MAX; + } +#else + return INT32_MAX; +#endif +} + +MeshPacket *AudioModule::allocReply() +{ + + auto reply = allocDataPacket(); // Allocate a packet for sending + + return reply; +} + +void AudioModule::sendPayload(NodeNum dest, bool wantReplies) +{ + MeshPacket *p = allocReply(); + p->to = dest; + p->decoded.want_response = wantReplies; + + p->want_ack = AUDIO_MODULE_ACK; + + p->decoded.payload.size = ENCODE_FRAME_SIZE; + memcpy(p->decoded.payload.bytes, tx_encode_frame, p->decoded.payload.size); + + service.sendToMesh(p); +} + +ProcessMessage AudioModule::handleReceived(const MeshPacket &mp) +{ +#if defined(ARCH_ESP32) && defined(USE_SX1280) + + if (moduleConfig.audio.codec2_enabled) { + auto &p = mp.decoded; + if (getFrom(&mp) != nodeDB.getNodeNum()) { + if (p.payload.size == ENCODE_FRAME_SIZE) { + memcpy(rx_encode_frame, p.payload.bytes, p.payload.size); + state = State::rx; + audioModule->setIntervalFromNow(0); + run_codec2(); + } else { + DEBUG_MSG("Invalid payload size %u != %u\n", p.payload.size, ENCODE_FRAME_SIZE); + } + } + } + +#endif + + return ProcessMessage::CONTINUE; +} diff --git a/src/modules/esp32/AudioModule.h b/src/modules/esp32/AudioModule.h new file mode 100644 index 000000000..fcd5d169e --- /dev/null +++ b/src/modules/esp32/AudioModule.h @@ -0,0 +1,68 @@ +#pragma once + +#include "SinglePortModule.h" +#include "concurrency/OSThread.h" +#include "configuration.h" +#include "NodeDB.h" +#include +#include +#include +#if defined(ARCH_ESP32) && defined(USE_SX1280) +#include +#include +#include +#else +typedef int FastAudioFIFO; +#endif + +#define ADC_BUFFER_SIZE 320 // 40ms of voice in 8KHz sampling frequency +#define ENCODE_FRAME_SIZE 40 // 5 codec2 frames of 8 bytes each + +class AudioModule : public SinglePortModule, private concurrency::OSThread +{ + bool firstTime = 1; + hw_timer_t* adcTimer = NULL; + uint16_t adc_buffer[ADC_BUFFER_SIZE]; + int16_t speech[ADC_BUFFER_SIZE]; + int16_t output_buffer[ADC_BUFFER_SIZE]; + unsigned char rx_encode_frame[ENCODE_FRAME_SIZE]; + unsigned char tx_encode_frame[ENCODE_FRAME_SIZE]; + int tx_encode_frame_index = 0; + FastAudioFIFO audio_fifo; + uint16_t adc_buffer_index = 0; + adc1_channel_t mic_chan = (adc1_channel_t)0; + struct CODEC2* codec2_state; + + enum State + { + standby, rx, tx + }; + volatile State state = State::tx; + + public: + AudioModule(); + + /** + * Send our payload into the mesh + */ + void sendPayload(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false); + + protected: + virtual int32_t runOnce() override; + + static void handleInterrupt(); + + void onTimer(); + + void run_codec2(); + + virtual MeshPacket *allocReply() override; + + /** Called to handle a particular incoming message + * @return ProcessMessage::STOP if you've guaranteed you've handled this message and no other handlers should be considered for it + */ + virtual ProcessMessage handleReceived(const MeshPacket &mp) override; +}; + +extern AudioModule *audioModule; + diff --git a/variants/tlora_v2_1_18/platformio.ini b/variants/tlora_v2_1_18/platformio.ini index 2cb1c3d2f..4160be5de 100644 --- a/variants/tlora_v2_1_18/platformio.ini +++ b/variants/tlora_v2_1_18/platformio.ini @@ -3,5 +3,6 @@ extends = esp32_base board = ttgo-lora32-v21 lib_deps = ${esp32_base.lib_deps} + caveman99/ESP32 Codec2@^1.0.1 build_flags = ${esp32_base.build_flags} -D TLORA_V2_1_18 -I variants/tlora_v2_1_18 \ No newline at end of file From 5715ddc3613fc52d048f1028a4e3c48a338b9d1c Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Wed, 2 Nov 2022 20:32:18 +0100 Subject: [PATCH 066/133] Don't consider Response as ACK for FloodingRouter (#1885) Co-authored-by: Ben Meadors --- src/mesh/FloodingRouter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesh/FloodingRouter.cpp b/src/mesh/FloodingRouter.cpp index b6519abdb..818bacf45 100644 --- a/src/mesh/FloodingRouter.cpp +++ b/src/mesh/FloodingRouter.cpp @@ -29,8 +29,8 @@ bool FloodingRouter::shouldFilterReceived(MeshPacket *p) void FloodingRouter::sniffReceived(const MeshPacket *p, const Routing *c) { - PacketId ackId = ((c && c->error_reason == Routing_Error_NONE) || !c) ? p->decoded.request_id : 0; - if (ackId && p->to != getNodeNum()) { + bool isAck = ((c && c->error_reason == Routing_Error_NONE)); // consider only ROUTING_APP message without error as ACK + if (isAck && p->to != getNodeNum()) { // do not flood direct message that is ACKed DEBUG_MSG("Receiving an ACK not for me, but don't need to rebroadcast this direct message anymore.\n"); Router::cancelSending(p->to, p->decoded.request_id); // cancel rebroadcast for this DM From 593301146e6beaaf41a2885c396b564e7f3ea7dc Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 2 Nov 2022 15:57:47 -0500 Subject: [PATCH 067/133] Fix feather diy (#1892) * Fix variant * Fix feather diy target --- variants/feather_diy/platformio.ini | 2 +- variants/feather_diy/variant.cpp | 24 ++++++++ variants/feather_diy/variant.h | 94 +++++++++++++++++++++++++++-- 3 files changed, 115 insertions(+), 5 deletions(-) create mode 100644 variants/feather_diy/variant.cpp diff --git a/variants/feather_diy/platformio.ini b/variants/feather_diy/platformio.ini index 446011cb9..84c582ab0 100644 --- a/variants/feather_diy/platformio.ini +++ b/variants/feather_diy/platformio.ini @@ -2,7 +2,7 @@ [env:feather_diy] extends = nrf52840_base board = adafruit_feather_nrf52840 -build_flags = ${nrf52840_base.build_flags} -Ivariants/feather_diy -D feather_diy +build_flags = ${nrf52840_base.build_flags} -Ivariants/feather_diy -Dfeather_diy build_src_filter = ${nrf52_base.build_src_filter} +<../variants/feather_diy> lib_deps = ${nrf52840_base.lib_deps} diff --git a/variants/feather_diy/variant.cpp b/variants/feather_diy/variant.cpp new file mode 100644 index 000000000..7311c9019 --- /dev/null +++ b/variants/feather_diy/variant.cpp @@ -0,0 +1,24 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "nrf.h" +#include "wiring_constants.h" +#include "wiring_digital.h" diff --git a/variants/feather_diy/variant.h b/variants/feather_diy/variant.h index 8327e6050..703d32202 100644 --- a/variants/feather_diy/variant.h +++ b/variants/feather_diy/variant.h @@ -1,9 +1,80 @@ -// For OLED LCD -#define I2C_SDA 22 -#define I2C_SCL 23 +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_FEATHER_DIY_ +#define _VARIANT_FEATHER_DIY_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (48) +#define NUM_DIGITAL_PINS (48) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA 22 +#define PIN_WIRE_SCL 23 + +#define PIN_LED1 3 +#define PIN_LED2 4 + +#define LED_BUILTIN PIN_LED1 + +#define LED_GREEN PIN_LED2 // Actually red +#define LED_BLUE PIN_LED1 + +#define LED_STATE_ON 1 // State when LED is litted #define BUTTON_PIN 7 +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX 1 +#define PIN_SERIAL1_TX 0 + +#define PIN_SERIAL2_RX (-1) +#define PIN_SERIAL2_TX (-1) + +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO 24 +#define PIN_SPI_MOSI 25 +#define PIN_SPI_SCK 26 + +#define SS 2 + #define LORA_DIO0 -1 // a No connect on the SX1262/SX1268 module #define LORA_RESET 13 // RST for SX1276, and for SX1262/SX1268 #define LORA_DIO1 11 // IRQ for SX1262/SX1268 @@ -13,7 +84,12 @@ #define RF95_SCK SCK #define RF95_MISO MI #define RF95_MOSI MO -#define RF95_NSS D2 +#define RF95_NSS SS + +// enables 3.3V periphery like GPS or IO Module +#define PIN_3V3_EN (34) + +#undef USE_EINK // supported modules list #define USE_SX1262 @@ -31,3 +107,13 @@ // (which is the default for the sx1262interface code) #define SX126X_E22 #endif + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif From 25a3a09d5f6ecd60d491b61ac42f6ede41b39931 Mon Sep 17 00:00:00 2001 From: Mykhailo Lesyk Date: Mon, 31 Oct 2022 16:13:21 -0700 Subject: [PATCH 068/133] [modules][external notifications] allow select channel to listen to --- src/modules/ExternalNotificationModule.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 56a0db941..4951d635e 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -116,9 +116,6 @@ ExternalNotificationModule::ExternalNotificationModule() : SinglePortModule("ExternalNotificationModule", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread( "ExternalNotificationModule") { - // restrict to the admin channel for rx - boundChannel = Channels::gpioChannel; - /* Uncomment the preferences below if you want to use the module without having to configure it from the PythonAPI or WebUI. @@ -131,6 +128,11 @@ ExternalNotificationModule::ExternalNotificationModule() // moduleConfig.external_notification.alert_bell = 1; // moduleConfig.external_notification.output_ms = 1000; // moduleConfig.external_notification.output = 13; + + if (moduleConfig.external_notification.alert_message) { + // restrict to the gpio channel for rx + boundChannel = Channels::gpioChannel; + } if (moduleConfig.external_notification.enabled) { From 20686cc66a5844c8d7a1a2ba86d4d7bc09e5c210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 3 Nov 2022 09:46:32 +0100 Subject: [PATCH 069/133] Show boot logo / OEM Logo longer - 5 seconds each now. --- src/graphics/Screen.cpp | 17 +++++---- src/mesh/generated/admin.pb.h | 7 ++-- src/mesh/generated/localonly.pb.h | 14 +++++--- src/mesh/generated/mesh.pb.h | 2 ++ src/mesh/generated/module_config.pb.c | 4 +++ src/mesh/generated/module_config.pb.h | 50 ++++++++++++++++++++++++++- src/mesh/generated/portnums.pb.h | 3 ++ 7 files changed, 83 insertions(+), 14 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 4ddbe10d4..d6e90c6f9 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -50,8 +50,6 @@ along with this program. If not, see . using namespace meshtastic; /** @todo remove */ -extern bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct); - namespace graphics { @@ -67,6 +65,8 @@ namespace graphics static FrameCallback normalFrames[MAX_NUM_NODES + NUM_EXTRA_FRAMES]; static uint32_t targetFramerate = IDLE_FRAMERATE; static char btPIN[16] = "888888"; + +uint32_t logo_timeout = 5000; // 4 seconds for EACH logo // This image definition is here instead of images.h because it's modified dynamically by the drawBattery function uint8_t imgBattery[16] = {0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xE7, 0x3C}; @@ -944,6 +944,9 @@ void Screen::setup() // Set the utf8 conversion function dispdev.setFontTableLookupFunction(customFontTableLookup); + if (strlen(oemStore.oem_text) > 0) + logo_timeout *= 2; + // Add frames. static FrameCallback bootFrames[] = {drawBootScreen}; static const int bootFrameCount = sizeof(bootFrames) / sizeof(bootFrames[0]); @@ -1012,26 +1015,28 @@ int32_t Screen::runOnce() return RUN_SAME; } - // Show boot screen for first 5 seconds, then switch to normal operation. + // Show boot screen for first logo_timeout seconds, then switch to normal operation. // serialSinceMsec adjusts for additional serial wait time during nRF52 bootup static bool showingBootScreen = true; - if (showingBootScreen && (millis() > (5000 + serialSinceMsec))) { + if (showingBootScreen && (millis() > (logo_timeout + serialSinceMsec))) { DEBUG_MSG("Done with boot screen...\n"); stopBootScreen(); showingBootScreen = false; } - // If we have an OEM Boot screen, toggle after 2,5 seconds + // If we have an OEM Boot screen, toggle after logo_timeout seconds if (strlen(oemStore.oem_text) > 0) { static bool showingOEMBootScreen = true; - if (showingOEMBootScreen && (millis() > (2500 + serialSinceMsec))) { + if (showingOEMBootScreen && (millis() > ((logo_timeout / 2) + serialSinceMsec))) { DEBUG_MSG("Switch to OEM screen...\n"); // Change frames. static FrameCallback bootOEMFrames[] = {drawOEMBootScreen}; static const int bootOEMFrameCount = sizeof(bootOEMFrames) / sizeof(bootOEMFrames[0]); ui.setFrames(bootOEMFrames, bootOEMFrameCount); ui.update(); +#ifndef USE_EINK ui.update(); +#endif showingOEMBootScreen = false; } } diff --git a/src/mesh/generated/admin.pb.h b/src/mesh/generated/admin.pb.h index 9b93bfd44..b5dc769ca 100644 --- a/src/mesh/generated/admin.pb.h +++ b/src/mesh/generated/admin.pb.h @@ -32,7 +32,8 @@ typedef enum _AdminMessage_ModuleConfigType { AdminMessage_ModuleConfigType_STOREFORWARD_CONFIG = 3, AdminMessage_ModuleConfigType_RANGETEST_CONFIG = 4, AdminMessage_ModuleConfigType_TELEMETRY_CONFIG = 5, - AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG = 6 + AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG = 6, + AdminMessage_ModuleConfigType_AUDIO_CONFIG = 7 } AdminMessage_ModuleConfigType; /* Struct definitions */ @@ -116,8 +117,8 @@ typedef struct _AdminMessage { #define _AdminMessage_ConfigType_ARRAYSIZE ((AdminMessage_ConfigType)(AdminMessage_ConfigType_BLUETOOTH_CONFIG+1)) #define _AdminMessage_ModuleConfigType_MIN AdminMessage_ModuleConfigType_MQTT_CONFIG -#define _AdminMessage_ModuleConfigType_MAX AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG -#define _AdminMessage_ModuleConfigType_ARRAYSIZE ((AdminMessage_ModuleConfigType)(AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG+1)) +#define _AdminMessage_ModuleConfigType_MAX AdminMessage_ModuleConfigType_AUDIO_CONFIG +#define _AdminMessage_ModuleConfigType_ARRAYSIZE ((AdminMessage_ModuleConfigType)(AdminMessage_ModuleConfigType_AUDIO_CONFIG+1)) #ifdef __cplusplus diff --git a/src/mesh/generated/localonly.pb.h b/src/mesh/generated/localonly.pb.h index b691ee408..76e713c1d 100644 --- a/src/mesh/generated/localonly.pb.h +++ b/src/mesh/generated/localonly.pb.h @@ -66,6 +66,9 @@ typedef struct _LocalModuleConfig { incompatible changes This integer is set at build time and is private to NodeDB.cpp in the device code. */ uint32_t version; + /* The part of the config that is specific to the Audio module */ + bool has_audio; + ModuleConfig_AudioConfig audio; } LocalModuleConfig; @@ -75,9 +78,9 @@ extern "C" { /* Initializer values for message structs */ #define LocalConfig_init_default {false, Config_DeviceConfig_init_default, false, Config_PositionConfig_init_default, false, Config_PowerConfig_init_default, false, Config_NetworkConfig_init_default, false, Config_DisplayConfig_init_default, false, Config_LoRaConfig_init_default, false, Config_BluetoothConfig_init_default, 0} -#define LocalModuleConfig_init_default {false, ModuleConfig_MQTTConfig_init_default, false, ModuleConfig_SerialConfig_init_default, false, ModuleConfig_ExternalNotificationConfig_init_default, false, ModuleConfig_StoreForwardConfig_init_default, false, ModuleConfig_RangeTestConfig_init_default, false, ModuleConfig_TelemetryConfig_init_default, false, ModuleConfig_CannedMessageConfig_init_default, 0} +#define LocalModuleConfig_init_default {false, ModuleConfig_MQTTConfig_init_default, false, ModuleConfig_SerialConfig_init_default, false, ModuleConfig_ExternalNotificationConfig_init_default, false, ModuleConfig_StoreForwardConfig_init_default, false, ModuleConfig_RangeTestConfig_init_default, false, ModuleConfig_TelemetryConfig_init_default, false, ModuleConfig_CannedMessageConfig_init_default, 0, false, ModuleConfig_AudioConfig_init_default} #define LocalConfig_init_zero {false, Config_DeviceConfig_init_zero, false, Config_PositionConfig_init_zero, false, Config_PowerConfig_init_zero, false, Config_NetworkConfig_init_zero, false, Config_DisplayConfig_init_zero, false, Config_LoRaConfig_init_zero, false, Config_BluetoothConfig_init_zero, 0} -#define LocalModuleConfig_init_zero {false, ModuleConfig_MQTTConfig_init_zero, false, ModuleConfig_SerialConfig_init_zero, false, ModuleConfig_ExternalNotificationConfig_init_zero, false, ModuleConfig_StoreForwardConfig_init_zero, false, ModuleConfig_RangeTestConfig_init_zero, false, ModuleConfig_TelemetryConfig_init_zero, false, ModuleConfig_CannedMessageConfig_init_zero, 0} +#define LocalModuleConfig_init_zero {false, ModuleConfig_MQTTConfig_init_zero, false, ModuleConfig_SerialConfig_init_zero, false, ModuleConfig_ExternalNotificationConfig_init_zero, false, ModuleConfig_StoreForwardConfig_init_zero, false, ModuleConfig_RangeTestConfig_init_zero, false, ModuleConfig_TelemetryConfig_init_zero, false, ModuleConfig_CannedMessageConfig_init_zero, 0, false, ModuleConfig_AudioConfig_init_zero} /* Field tags (for use in manual encoding/decoding) */ #define LocalConfig_device_tag 1 @@ -96,6 +99,7 @@ extern "C" { #define LocalModuleConfig_telemetry_tag 6 #define LocalModuleConfig_canned_message_tag 7 #define LocalModuleConfig_version_tag 8 +#define LocalModuleConfig_audio_tag 9 /* Struct field encoding specification for nanopb */ #define LocalConfig_FIELDLIST(X, a) \ @@ -125,7 +129,8 @@ X(a, STATIC, OPTIONAL, MESSAGE, store_forward, 4) \ X(a, STATIC, OPTIONAL, MESSAGE, range_test, 5) \ X(a, STATIC, OPTIONAL, MESSAGE, telemetry, 6) \ X(a, STATIC, OPTIONAL, MESSAGE, canned_message, 7) \ -X(a, STATIC, SINGULAR, UINT32, version, 8) +X(a, STATIC, SINGULAR, UINT32, version, 8) \ +X(a, STATIC, OPTIONAL, MESSAGE, audio, 9) #define LocalModuleConfig_CALLBACK NULL #define LocalModuleConfig_DEFAULT NULL #define LocalModuleConfig_mqtt_MSGTYPE ModuleConfig_MQTTConfig @@ -135,6 +140,7 @@ X(a, STATIC, SINGULAR, UINT32, version, 8) #define LocalModuleConfig_range_test_MSGTYPE ModuleConfig_RangeTestConfig #define LocalModuleConfig_telemetry_MSGTYPE ModuleConfig_TelemetryConfig #define LocalModuleConfig_canned_message_MSGTYPE ModuleConfig_CannedMessageConfig +#define LocalModuleConfig_audio_MSGTYPE ModuleConfig_AudioConfig extern const pb_msgdesc_t LocalConfig_msg; extern const pb_msgdesc_t LocalModuleConfig_msg; @@ -145,7 +151,7 @@ extern const pb_msgdesc_t LocalModuleConfig_msg; /* Maximum encoded size of messages (where known) */ #define LocalConfig_size 359 -#define LocalModuleConfig_size 270 +#define LocalModuleConfig_size 294 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index 3f2a8839c..812099166 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -52,6 +52,8 @@ typedef enum _HardwareModel { HardwareModel_RAK11200 = 13, /* B&Q Consulting Nano Edition G1: https://uniteng.com/wiki/doku.php?id=meshtastic:nano */ HardwareModel_NANO_G1 = 14, + /* TODO: REPLACE */ + HardwareModel_TLORA_V2_1_1P8 = 15, /* B&Q Consulting Station Edition G1: https://uniteng.com/wiki/doku.php?id=meshtastic:station */ HardwareModel_STATION_G1 = 25, /* Less common/prototype boards listed here (needs one more byte over the air) */ diff --git a/src/mesh/generated/module_config.pb.c b/src/mesh/generated/module_config.pb.c index a3e4ddfbe..381ce6351 100644 --- a/src/mesh/generated/module_config.pb.c +++ b/src/mesh/generated/module_config.pb.c @@ -12,6 +12,9 @@ PB_BIND(ModuleConfig, ModuleConfig, AUTO) PB_BIND(ModuleConfig_MQTTConfig, ModuleConfig_MQTTConfig, AUTO) +PB_BIND(ModuleConfig_AudioConfig, ModuleConfig_AudioConfig, AUTO) + + PB_BIND(ModuleConfig_SerialConfig, ModuleConfig_SerialConfig, AUTO) @@ -34,3 +37,4 @@ PB_BIND(ModuleConfig_CannedMessageConfig, ModuleConfig_CannedMessageConfig, AUTO + diff --git a/src/mesh/generated/module_config.pb.h b/src/mesh/generated/module_config.pb.h index b0f14eea2..af4d4dce9 100644 --- a/src/mesh/generated/module_config.pb.h +++ b/src/mesh/generated/module_config.pb.h @@ -10,6 +10,18 @@ #endif /* Enum definitions */ +typedef enum _ModuleConfig_AudioConfig_Audio_Baud { + ModuleConfig_AudioConfig_Audio_Baud_CODEC2_DEFAULT = 0, + ModuleConfig_AudioConfig_Audio_Baud_CODEC2_3200 = 1, + ModuleConfig_AudioConfig_Audio_Baud_CODEC2_2400 = 2, + ModuleConfig_AudioConfig_Audio_Baud_CODEC2_1600 = 3, + ModuleConfig_AudioConfig_Audio_Baud_CODEC2_1400 = 4, + ModuleConfig_AudioConfig_Audio_Baud_CODEC2_1300 = 5, + ModuleConfig_AudioConfig_Audio_Baud_CODEC2_1200 = 6, + ModuleConfig_AudioConfig_Audio_Baud_CODEC2_700 = 7, + ModuleConfig_AudioConfig_Audio_Baud_CODEC2_700B = 8 +} ModuleConfig_AudioConfig_Audio_Baud; + typedef enum _ModuleConfig_SerialConfig_Serial_Baud { ModuleConfig_SerialConfig_Serial_Baud_BAUD_DEFAULT = 0, ModuleConfig_SerialConfig_Serial_Baud_BAUD_110 = 1, @@ -49,6 +61,14 @@ typedef enum _ModuleConfig_CannedMessageConfig_InputEventChar { } ModuleConfig_CannedMessageConfig_InputEventChar; /* Struct definitions */ +typedef struct _ModuleConfig_AudioConfig { + bool codec2_enabled; + uint32_t mic_chan; + uint32_t amp_pin; + uint32_t ptt_pin; + ModuleConfig_AudioConfig_Audio_Baud bitrate; +} ModuleConfig_AudioConfig; + typedef struct _ModuleConfig_CannedMessageConfig { bool rotary1_enabled; uint32_t inputbroker_pin_a; @@ -131,11 +151,17 @@ typedef struct _ModuleConfig { ModuleConfig_TelemetryConfig telemetry; /* TODO: REPLACE */ ModuleConfig_CannedMessageConfig canned_message; + /* TODO: REPLACE */ + ModuleConfig_AudioConfig audio; } payload_variant; } ModuleConfig; /* Helper constants for enums */ +#define _ModuleConfig_AudioConfig_Audio_Baud_MIN ModuleConfig_AudioConfig_Audio_Baud_CODEC2_DEFAULT +#define _ModuleConfig_AudioConfig_Audio_Baud_MAX ModuleConfig_AudioConfig_Audio_Baud_CODEC2_700B +#define _ModuleConfig_AudioConfig_Audio_Baud_ARRAYSIZE ((ModuleConfig_AudioConfig_Audio_Baud)(ModuleConfig_AudioConfig_Audio_Baud_CODEC2_700B+1)) + #define _ModuleConfig_SerialConfig_Serial_Baud_MIN ModuleConfig_SerialConfig_Serial_Baud_BAUD_DEFAULT #define _ModuleConfig_SerialConfig_Serial_Baud_MAX ModuleConfig_SerialConfig_Serial_Baud_BAUD_921600 #define _ModuleConfig_SerialConfig_Serial_Baud_ARRAYSIZE ((ModuleConfig_SerialConfig_Serial_Baud)(ModuleConfig_SerialConfig_Serial_Baud_BAUD_921600+1)) @@ -156,6 +182,7 @@ extern "C" { /* Initializer values for message structs */ #define ModuleConfig_init_default {0, {ModuleConfig_MQTTConfig_init_default}} #define ModuleConfig_MQTTConfig_init_default {0, "", "", "", 0, 0} +#define ModuleConfig_AudioConfig_init_default {0, 0, 0, 0, _ModuleConfig_AudioConfig_Audio_Baud_MIN} #define ModuleConfig_SerialConfig_init_default {0, 0, 0, 0, _ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _ModuleConfig_SerialConfig_Serial_Mode_MIN} #define ModuleConfig_ExternalNotificationConfig_init_default {0, 0, 0, 0, 0, 0} #define ModuleConfig_StoreForwardConfig_init_default {0, 0, 0, 0, 0} @@ -164,6 +191,7 @@ extern "C" { #define ModuleConfig_CannedMessageConfig_init_default {0, 0, 0, 0, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, 0, 0, "", 0} #define ModuleConfig_init_zero {0, {ModuleConfig_MQTTConfig_init_zero}} #define ModuleConfig_MQTTConfig_init_zero {0, "", "", "", 0, 0} +#define ModuleConfig_AudioConfig_init_zero {0, 0, 0, 0, _ModuleConfig_AudioConfig_Audio_Baud_MIN} #define ModuleConfig_SerialConfig_init_zero {0, 0, 0, 0, _ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _ModuleConfig_SerialConfig_Serial_Mode_MIN} #define ModuleConfig_ExternalNotificationConfig_init_zero {0, 0, 0, 0, 0, 0} #define ModuleConfig_StoreForwardConfig_init_zero {0, 0, 0, 0, 0} @@ -172,6 +200,11 @@ extern "C" { #define ModuleConfig_CannedMessageConfig_init_zero {0, 0, 0, 0, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, 0, 0, "", 0} /* Field tags (for use in manual encoding/decoding) */ +#define ModuleConfig_AudioConfig_codec2_enabled_tag 1 +#define ModuleConfig_AudioConfig_mic_chan_tag 2 +#define ModuleConfig_AudioConfig_amp_pin_tag 3 +#define ModuleConfig_AudioConfig_ptt_pin_tag 4 +#define ModuleConfig_AudioConfig_bitrate_tag 5 #define ModuleConfig_CannedMessageConfig_rotary1_enabled_tag 1 #define ModuleConfig_CannedMessageConfig_inputbroker_pin_a_tag 2 #define ModuleConfig_CannedMessageConfig_inputbroker_pin_b_tag 3 @@ -222,6 +255,7 @@ extern "C" { #define ModuleConfig_range_test_tag 5 #define ModuleConfig_telemetry_tag 6 #define ModuleConfig_canned_message_tag 7 +#define ModuleConfig_audio_tag 8 /* Struct field encoding specification for nanopb */ #define ModuleConfig_FIELDLIST(X, a) \ @@ -231,7 +265,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,external_notification,payloa X(a, STATIC, ONEOF, MESSAGE, (payload_variant,store_forward,payload_variant.store_forward), 4) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,range_test,payload_variant.range_test), 5) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,telemetry,payload_variant.telemetry), 6) \ -X(a, STATIC, ONEOF, MESSAGE, (payload_variant,canned_message,payload_variant.canned_message), 7) +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,canned_message,payload_variant.canned_message), 7) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,audio,payload_variant.audio), 8) #define ModuleConfig_CALLBACK NULL #define ModuleConfig_DEFAULT NULL #define ModuleConfig_payload_variant_mqtt_MSGTYPE ModuleConfig_MQTTConfig @@ -241,6 +276,7 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,canned_message,payload_varia #define ModuleConfig_payload_variant_range_test_MSGTYPE ModuleConfig_RangeTestConfig #define ModuleConfig_payload_variant_telemetry_MSGTYPE ModuleConfig_TelemetryConfig #define ModuleConfig_payload_variant_canned_message_MSGTYPE ModuleConfig_CannedMessageConfig +#define ModuleConfig_payload_variant_audio_MSGTYPE ModuleConfig_AudioConfig #define ModuleConfig_MQTTConfig_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, BOOL, enabled, 1) \ @@ -252,6 +288,15 @@ X(a, STATIC, SINGULAR, BOOL, json_enabled, 6) #define ModuleConfig_MQTTConfig_CALLBACK NULL #define ModuleConfig_MQTTConfig_DEFAULT NULL +#define ModuleConfig_AudioConfig_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, BOOL, codec2_enabled, 1) \ +X(a, STATIC, SINGULAR, UINT32, mic_chan, 2) \ +X(a, STATIC, SINGULAR, UINT32, amp_pin, 3) \ +X(a, STATIC, SINGULAR, UINT32, ptt_pin, 4) \ +X(a, STATIC, SINGULAR, UENUM, bitrate, 5) +#define ModuleConfig_AudioConfig_CALLBACK NULL +#define ModuleConfig_AudioConfig_DEFAULT NULL + #define ModuleConfig_SerialConfig_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, BOOL, enabled, 1) \ X(a, STATIC, SINGULAR, BOOL, echo, 2) \ @@ -315,6 +360,7 @@ X(a, STATIC, SINGULAR, BOOL, send_bell, 11) extern const pb_msgdesc_t ModuleConfig_msg; extern const pb_msgdesc_t ModuleConfig_MQTTConfig_msg; +extern const pb_msgdesc_t ModuleConfig_AudioConfig_msg; extern const pb_msgdesc_t ModuleConfig_SerialConfig_msg; extern const pb_msgdesc_t ModuleConfig_ExternalNotificationConfig_msg; extern const pb_msgdesc_t ModuleConfig_StoreForwardConfig_msg; @@ -325,6 +371,7 @@ extern const pb_msgdesc_t ModuleConfig_CannedMessageConfig_msg; /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ #define ModuleConfig_fields &ModuleConfig_msg #define ModuleConfig_MQTTConfig_fields &ModuleConfig_MQTTConfig_msg +#define ModuleConfig_AudioConfig_fields &ModuleConfig_AudioConfig_msg #define ModuleConfig_SerialConfig_fields &ModuleConfig_SerialConfig_msg #define ModuleConfig_ExternalNotificationConfig_fields &ModuleConfig_ExternalNotificationConfig_msg #define ModuleConfig_StoreForwardConfig_fields &ModuleConfig_StoreForwardConfig_msg @@ -333,6 +380,7 @@ extern const pb_msgdesc_t ModuleConfig_CannedMessageConfig_msg; #define ModuleConfig_CannedMessageConfig_fields &ModuleConfig_CannedMessageConfig_msg /* Maximum encoded size of messages (where known) */ +#define ModuleConfig_AudioConfig_size 22 #define ModuleConfig_CannedMessageConfig_size 49 #define ModuleConfig_ExternalNotificationConfig_size 20 #define ModuleConfig_MQTTConfig_size 105 diff --git a/src/mesh/generated/portnums.pb.h b/src/mesh/generated/portnums.pb.h index d272fe2b9..ec7b7eaec 100644 --- a/src/mesh/generated/portnums.pb.h +++ b/src/mesh/generated/portnums.pb.h @@ -51,6 +51,9 @@ typedef enum _PortNum { /* Waypoint payloads. Payload is a [Waypoint](/docs/developers/protobufs/api#waypoint) message */ PortNum_WAYPOINT_APP = 8, + /* Audio Payloads. + Encapsulated codec2 packets. On 2.4 GHZ Bandwidths only for now */ + PortNum_AUDIO_APP = 9, /* Provides a 'ping' service that replies to any packet it receives. Also serves as a small example module. */ PortNum_REPLY_APP = 32, From a3eced53bbd61ad9e2da90767e1bd8835f53c988 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 3 Nov 2022 14:28:49 -0500 Subject: [PATCH 070/133] Fix feather diy pin mapping (#1894) Thanks to @markbirss --- variants/feather_diy/variant.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/variants/feather_diy/variant.h b/variants/feather_diy/variant.h index 703d32202..92128add2 100644 --- a/variants/feather_diy/variant.h +++ b/variants/feather_diy/variant.h @@ -43,11 +43,11 @@ extern "C" { #define WIRE_INTERFACES_COUNT 1 -#define PIN_WIRE_SDA 22 -#define PIN_WIRE_SCL 23 +#define PIN_WIRE_SDA (0 + 12) //P0.12 22 +#define PIN_WIRE_SCL (0 + 11) //P0.12 23 -#define PIN_LED1 3 -#define PIN_LED2 4 +#define PIN_LED1 (32 + 15) //P1.15 3 +#define PIN_LED2 (32 + 10) //P1.10 4 #define LED_BUILTIN PIN_LED1 @@ -56,29 +56,29 @@ extern "C" { #define LED_STATE_ON 1 // State when LED is litted -#define BUTTON_PIN 7 +#define BUTTON_PIN (32 + 2) //P1.02 7 /* * Serial interfaces */ -#define PIN_SERIAL1_RX 1 -#define PIN_SERIAL1_TX 0 +#define PIN_SERIAL1_RX (0 + 24) //P0.24 1 +#define PIN_SERIAL1_TX (0 + 25) //P0.25 0 #define PIN_SERIAL2_RX (-1) #define PIN_SERIAL2_TX (-1) #define SPI_INTERFACES_COUNT 1 -#define PIN_SPI_MISO 24 -#define PIN_SPI_MOSI 25 -#define PIN_SPI_SCK 26 +#define PIN_SPI_MISO (0 + 15) //P0.15 24 +#define PIN_SPI_MOSI (0 + 13) //P0.13 25 +#define PIN_SPI_SCK (0 + 14) //P0.14 26 #define SS 2 #define LORA_DIO0 -1 // a No connect on the SX1262/SX1268 module -#define LORA_RESET 13 // RST for SX1276, and for SX1262/SX1268 -#define LORA_DIO1 11 // IRQ for SX1262/SX1268 -#define LORA_DIO2 12 // BUSY for SX1262/SX1268 +#define LORA_RESET (32 + 9) //P1.09 13 // RST for SX1276, and for SX1262/SX1268 +#define LORA_DIO1 (0 + 6) //P0.06 11 // IRQ for SX1262/SX1268 +#define LORA_DIO2 (0 + 8) //P0.08 12 // BUSY for SX1262/SX1268 #define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262/SX1268, if DIO3 is high the TXCO is enabled #define RF95_SCK SCK @@ -87,7 +87,7 @@ extern "C" { #define RF95_NSS SS // enables 3.3V periphery like GPS or IO Module -#define PIN_3V3_EN (34) +#define PIN_3V3_EN (-1) #undef USE_EINK @@ -99,8 +99,8 @@ extern "C" { #define SX126X_DIO1 LORA_DIO1 #define SX126X_BUSY LORA_DIO2 #define SX126X_RESET LORA_RESET -#define SX126X_RXEN 10 -#define SX126X_TXEN 9 +#define SX126X_RXEN (0 + 27) //P0.27 10 +#define SX126X_TXEN (0 + 26) //P0.26 9 #ifdef EBYTE_E22 // Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch From f1afbf2c0fb0fcc3682aa5d84c4f5136cea86d68 Mon Sep 17 00:00:00 2001 From: caveman99 Date: Thu, 3 Nov 2022 21:35:06 +0000 Subject: [PATCH 071/133] [create-pull-request] automated change --- protobufs | 2 +- src/mesh/generated/config.pb.c | 1 + src/mesh/generated/config.pb.h | 21 +++++++++++++++++---- src/mesh/generated/localonly.pb.h | 2 +- src/mesh/generated/mesh.pb.h | 2 ++ 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/protobufs b/protobufs index ed9f2499d..a0fe9ec86 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit ed9f2499d692925461facd64c6af2d2a7672245a +Subproject commit a0fe9ec8614cd27af7691869ccbd20c39e48a086 diff --git a/src/mesh/generated/config.pb.c b/src/mesh/generated/config.pb.c index c5bc69552..2b75b7558 100644 --- a/src/mesh/generated/config.pb.c +++ b/src/mesh/generated/config.pb.c @@ -43,3 +43,4 @@ PB_BIND(Config_BluetoothConfig, Config_BluetoothConfig, AUTO) + diff --git a/src/mesh/generated/config.pb.h b/src/mesh/generated/config.pb.h index 6a8e56ad0..263b1e916 100644 --- a/src/mesh/generated/config.pb.h +++ b/src/mesh/generated/config.pb.h @@ -56,6 +56,12 @@ typedef enum _Config_DisplayConfig_DisplayUnits { Config_DisplayConfig_DisplayUnits_IMPERIAL = 1 } Config_DisplayConfig_DisplayUnits; +typedef enum _Config_DisplayConfig_OledType { + Config_DisplayConfig_OledType_OLED_AUTO = 0, + Config_DisplayConfig_OledType_OLED_SSD1306 = 1, + Config_DisplayConfig_OledType_OLED_SH1106 = 2 +} Config_DisplayConfig_OledType; + typedef enum _Config_LoRaConfig_RegionCode { Config_LoRaConfig_RegionCode_UNSET = 0, Config_LoRaConfig_RegionCode_US = 1, @@ -109,6 +115,7 @@ typedef struct _Config_DisplayConfig { bool compass_north_top; bool flip_screen; Config_DisplayConfig_DisplayUnits units; + Config_DisplayConfig_OledType oled; } Config_DisplayConfig; typedef struct _Config_LoRaConfig { @@ -205,6 +212,10 @@ typedef struct _Config { #define _Config_DisplayConfig_DisplayUnits_MAX Config_DisplayConfig_DisplayUnits_IMPERIAL #define _Config_DisplayConfig_DisplayUnits_ARRAYSIZE ((Config_DisplayConfig_DisplayUnits)(Config_DisplayConfig_DisplayUnits_IMPERIAL+1)) +#define _Config_DisplayConfig_OledType_MIN Config_DisplayConfig_OledType_OLED_AUTO +#define _Config_DisplayConfig_OledType_MAX Config_DisplayConfig_OledType_OLED_SH1106 +#define _Config_DisplayConfig_OledType_ARRAYSIZE ((Config_DisplayConfig_OledType)(Config_DisplayConfig_OledType_OLED_SH1106+1)) + #define _Config_LoRaConfig_RegionCode_MIN Config_LoRaConfig_RegionCode_UNSET #define _Config_LoRaConfig_RegionCode_MAX Config_LoRaConfig_RegionCode_LORA_24 #define _Config_LoRaConfig_RegionCode_ARRAYSIZE ((Config_LoRaConfig_RegionCode)(Config_LoRaConfig_RegionCode_LORA_24+1)) @@ -229,7 +240,7 @@ extern "C" { #define Config_PowerConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0} #define Config_NetworkConfig_init_default {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_default} #define Config_NetworkConfig_IpV4Config_init_default {0, 0, 0, 0} -#define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN} +#define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN} #define Config_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}} #define Config_BluetoothConfig_init_default {0, _Config_BluetoothConfig_PairingMode_MIN, 0} #define Config_init_zero {0, {Config_DeviceConfig_init_zero}} @@ -238,7 +249,7 @@ extern "C" { #define Config_PowerConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0} #define Config_NetworkConfig_init_zero {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_zero} #define Config_NetworkConfig_IpV4Config_init_zero {0, 0, 0, 0} -#define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN} +#define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN} #define Config_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}} #define Config_BluetoothConfig_init_zero {0, _Config_BluetoothConfig_PairingMode_MIN, 0} @@ -255,6 +266,7 @@ extern "C" { #define Config_DisplayConfig_compass_north_top_tag 4 #define Config_DisplayConfig_flip_screen_tag 5 #define Config_DisplayConfig_units_tag 6 +#define Config_DisplayConfig_oled_tag 7 #define Config_LoRaConfig_use_preset_tag 1 #define Config_LoRaConfig_modem_preset_tag 2 #define Config_LoRaConfig_bandwidth_tag 3 @@ -376,7 +388,8 @@ X(a, STATIC, SINGULAR, UENUM, gps_format, 2) \ X(a, STATIC, SINGULAR, UINT32, auto_screen_carousel_secs, 3) \ X(a, STATIC, SINGULAR, BOOL, compass_north_top, 4) \ X(a, STATIC, SINGULAR, BOOL, flip_screen, 5) \ -X(a, STATIC, SINGULAR, UENUM, units, 6) +X(a, STATIC, SINGULAR, UENUM, units, 6) \ +X(a, STATIC, SINGULAR, UENUM, oled, 7) #define Config_DisplayConfig_CALLBACK NULL #define Config_DisplayConfig_DEFAULT NULL @@ -427,7 +440,7 @@ extern const pb_msgdesc_t Config_BluetoothConfig_msg; /* Maximum encoded size of messages (where known) */ #define Config_BluetoothConfig_size 10 #define Config_DeviceConfig_size 6 -#define Config_DisplayConfig_size 20 +#define Config_DisplayConfig_size 22 #define Config_LoRaConfig_size 68 #define Config_NetworkConfig_IpV4Config_size 20 #define Config_NetworkConfig_size 161 diff --git a/src/mesh/generated/localonly.pb.h b/src/mesh/generated/localonly.pb.h index b691ee408..8e4199d48 100644 --- a/src/mesh/generated/localonly.pb.h +++ b/src/mesh/generated/localonly.pb.h @@ -144,7 +144,7 @@ extern const pb_msgdesc_t LocalModuleConfig_msg; #define LocalModuleConfig_fields &LocalModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define LocalConfig_size 359 +#define LocalConfig_size 361 #define LocalModuleConfig_size 270 #ifdef __cplusplus diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index 3f2a8839c..812099166 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -52,6 +52,8 @@ typedef enum _HardwareModel { HardwareModel_RAK11200 = 13, /* B&Q Consulting Nano Edition G1: https://uniteng.com/wiki/doku.php?id=meshtastic:nano */ HardwareModel_NANO_G1 = 14, + /* TODO: REPLACE */ + HardwareModel_TLORA_V2_1_1P8 = 15, /* B&Q Consulting Station Edition G1: https://uniteng.com/wiki/doku.php?id=meshtastic:station */ HardwareModel_STATION_G1 = 25, /* Less common/prototype boards listed here (needs one more byte over the air) */ From acfa186d44bc9761ad4103d5b4dc8752d621c275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 3 Nov 2022 22:44:22 +0100 Subject: [PATCH 072/133] Override Screen Autodtect --- src/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 8836b6460..d7abdb2a9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -293,6 +293,10 @@ void setup() * Boards with an PMU need to be powered on to correctly scan to the device address, such as t-beam-s3-core */ scanI2Cdevice(); + + // fixed screen override? + if (config.display.oled != Config_DisplayConfig_OledType_OLED_AUTO) + screen_model = config.display.oled; // Init our SPI controller (must be before screen and lora) initSPI(); From 04a478a5ad596831b2727b4923c185e1205e39d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 3 Nov 2022 22:50:54 +0100 Subject: [PATCH 073/133] Maybe fix crash of this board. --- variants/tlora_v2/variant.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/variants/tlora_v2/variant.h b/variants/tlora_v2/variant.h index 1bff09fb0..af91e0eea 100644 --- a/variants/tlora_v2/variant.h +++ b/variants/tlora_v2/variant.h @@ -1,7 +1,5 @@ #undef GPS_RX_PIN #undef GPS_TX_PIN -#define GPS_RX_PIN 36 -#define GPS_TX_PIN 13 // per @eugene #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage From 8b84ac8a6c579469e61b7dadca42e35e984a0c30 Mon Sep 17 00:00:00 2001 From: he-leon Date: Fri, 4 Nov 2022 16:48:49 +0100 Subject: [PATCH 074/133] Fixes reset loop with new espressif32 platform on tlora-v2 Sending a pulse to the OLED_RESET Pin 16 results in a reset loop using recent version of the espressif32 platform. --- variants/tlora_v2/variant.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/variants/tlora_v2/variant.h b/variants/tlora_v2/variant.h index 1bff09fb0..0c854e37a 100644 --- a/variants/tlora_v2/variant.h +++ b/variants/tlora_v2/variant.h @@ -8,8 +8,6 @@ #define I2C_SDA 21 // I2C pins for this board #define I2C_SCL 22 -#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller - #define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost #define LED_PIN 25 // If defined we will blink this LED #define BUTTON_PIN \ @@ -21,4 +19,4 @@ #define LORA_DIO0 26 // a No connect on the SX1262 module #define LORA_RESET 14 #define LORA_DIO1 35 // Not really used -#define LORA_DIO2 34 // Not really used \ No newline at end of file +#define LORA_DIO2 34 // Not really used From b2e540b114f594ea960daf9ce346710287d5aee6 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 4 Nov 2022 13:43:16 -0500 Subject: [PATCH 075/133] Experiment with self hosted action runner --- .github/workflows/main_matrix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 66bf7539c..640b88e51 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -105,7 +105,7 @@ jobs: - board: m5stack-coreink - board: tbeam-s3-core - runs-on: ubuntu-latest + runs-on: [self-hosted, ubuntu-latest] steps: - name: Checkout code uses: actions/checkout@v3 From 4ccb4393c56f7eea1ee5fee48e0ff4a687e62922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 4 Nov 2022 19:44:45 +0100 Subject: [PATCH 076/133] Fix MQTT on ETH --- src/main.cpp | 2 +- src/mesh/Router.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index d7abdb2a9..e0f0783d3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -37,7 +37,7 @@ #include "nimble/NimbleBluetooth.h" #endif -#if HAS_WIFI || defined(ARCH_PORTDUINO) +#if HAS_WIFI #include "mesh/wifi/WiFiServerAPI.h" #include "mqtt/MQTT.h" #endif diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 815571b9b..e0746bdd9 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -11,7 +11,7 @@ extern "C" { #include "mesh/compression/unishox2.h" } -#if HAS_WIFI +#if HAS_WIFI || HAS_ETHERNET #include "mqtt/MQTT.h" #endif @@ -209,7 +209,7 @@ ErrorCode Router::send(MeshPacket *p) if (p->which_payload_variant == MeshPacket_decoded_tag) { ChannelIndex chIndex = p->channel; // keep as a local because we are about to change it -#if HAS_WIFI +#if HAS_WIFI || HAS_ETHERNET // check if we should send decrypted packets to mqtt // truth table: @@ -240,7 +240,7 @@ ErrorCode Router::send(MeshPacket *p) return encodeResult; // FIXME - this isn't a valid ErrorCode } -#if HAS_WIFI +#if HAS_WIFI || HAS_ETHERNET // the packet is now encrypted. // check if we should send encrypted packets to mqtt if (mqtt && shouldActuallyEncrypt) From 7c692444e5107ff17e7e8a8b9f43ccf8b27b7ef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 4 Nov 2022 19:48:28 +0100 Subject: [PATCH 077/133] revert the tryfix --- variants/tlora_v2/variant.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/variants/tlora_v2/variant.h b/variants/tlora_v2/variant.h index 6a09839d6..0c854e37a 100644 --- a/variants/tlora_v2/variant.h +++ b/variants/tlora_v2/variant.h @@ -1,5 +1,7 @@ #undef GPS_RX_PIN #undef GPS_TX_PIN +#define GPS_RX_PIN 36 +#define GPS_TX_PIN 13 // per @eugene #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage From 09cdc20440fab47b38a8d7960c803f7b187411eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 4 Nov 2022 19:56:44 +0100 Subject: [PATCH 078/133] manual merge of changes from Master --- src/main.cpp | 6 +- src/mesh/FloodingRouter.cpp | 4 +- src/modules/ExternalNotificationModule.cpp | 8 +- variants/feather_diy/platformio.ini | 2 +- variants/feather_diy/variant.cpp | 24 +++++ variants/feather_diy/variant.h | 106 +++++++++++++++++++-- 6 files changed, 133 insertions(+), 17 deletions(-) create mode 100644 variants/feather_diy/variant.cpp diff --git a/src/main.cpp b/src/main.cpp index 8836b6460..e0f0783d3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -37,7 +37,7 @@ #include "nimble/NimbleBluetooth.h" #endif -#if HAS_WIFI || defined(ARCH_PORTDUINO) +#if HAS_WIFI #include "mesh/wifi/WiFiServerAPI.h" #include "mqtt/MQTT.h" #endif @@ -293,6 +293,10 @@ void setup() * Boards with an PMU need to be powered on to correctly scan to the device address, such as t-beam-s3-core */ scanI2Cdevice(); + + // fixed screen override? + if (config.display.oled != Config_DisplayConfig_OledType_OLED_AUTO) + screen_model = config.display.oled; // Init our SPI controller (must be before screen and lora) initSPI(); diff --git a/src/mesh/FloodingRouter.cpp b/src/mesh/FloodingRouter.cpp index b6519abdb..818bacf45 100644 --- a/src/mesh/FloodingRouter.cpp +++ b/src/mesh/FloodingRouter.cpp @@ -29,8 +29,8 @@ bool FloodingRouter::shouldFilterReceived(MeshPacket *p) void FloodingRouter::sniffReceived(const MeshPacket *p, const Routing *c) { - PacketId ackId = ((c && c->error_reason == Routing_Error_NONE) || !c) ? p->decoded.request_id : 0; - if (ackId && p->to != getNodeNum()) { + bool isAck = ((c && c->error_reason == Routing_Error_NONE)); // consider only ROUTING_APP message without error as ACK + if (isAck && p->to != getNodeNum()) { // do not flood direct message that is ACKed DEBUG_MSG("Receiving an ACK not for me, but don't need to rebroadcast this direct message anymore.\n"); Router::cancelSending(p->to, p->decoded.request_id); // cancel rebroadcast for this DM diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 366ec6849..e5d371c1b 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -116,9 +116,6 @@ ExternalNotificationModule::ExternalNotificationModule() : SinglePortModule("ExternalNotificationModule", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread( "ExternalNotificationModule") { - // restrict to the admin channel for rx - boundChannel = Channels::gpioChannel; - /* Uncomment the preferences below if you want to use the module without having to configure it from the PythonAPI or WebUI. @@ -131,6 +128,11 @@ ExternalNotificationModule::ExternalNotificationModule() // moduleConfig.external_notification.alert_bell = 1; // moduleConfig.external_notification.output_ms = 1000; // moduleConfig.external_notification.output = 13; + + if (moduleConfig.external_notification.alert_message) { + // restrict to the gpio channel for rx + boundChannel = Channels::gpioChannel; + } if (moduleConfig.external_notification.enabled) { diff --git a/variants/feather_diy/platformio.ini b/variants/feather_diy/platformio.ini index 446011cb9..84c582ab0 100644 --- a/variants/feather_diy/platformio.ini +++ b/variants/feather_diy/platformio.ini @@ -2,7 +2,7 @@ [env:feather_diy] extends = nrf52840_base board = adafruit_feather_nrf52840 -build_flags = ${nrf52840_base.build_flags} -Ivariants/feather_diy -D feather_diy +build_flags = ${nrf52840_base.build_flags} -Ivariants/feather_diy -Dfeather_diy build_src_filter = ${nrf52_base.build_src_filter} +<../variants/feather_diy> lib_deps = ${nrf52840_base.lib_deps} diff --git a/variants/feather_diy/variant.cpp b/variants/feather_diy/variant.cpp new file mode 100644 index 000000000..7311c9019 --- /dev/null +++ b/variants/feather_diy/variant.cpp @@ -0,0 +1,24 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "nrf.h" +#include "wiring_constants.h" +#include "wiring_digital.h" diff --git a/variants/feather_diy/variant.h b/variants/feather_diy/variant.h index 8327e6050..92128add2 100644 --- a/variants/feather_diy/variant.h +++ b/variants/feather_diy/variant.h @@ -1,19 +1,95 @@ -// For OLED LCD -#define I2C_SDA 22 -#define I2C_SCL 23 +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) -#define BUTTON_PIN 7 + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_FEATHER_DIY_ +#define _VARIANT_FEATHER_DIY_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (48) +#define NUM_DIGITAL_PINS (48) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (0 + 12) //P0.12 22 +#define PIN_WIRE_SCL (0 + 11) //P0.12 23 + +#define PIN_LED1 (32 + 15) //P1.15 3 +#define PIN_LED2 (32 + 10) //P1.10 4 + +#define LED_BUILTIN PIN_LED1 + +#define LED_GREEN PIN_LED2 // Actually red +#define LED_BLUE PIN_LED1 + +#define LED_STATE_ON 1 // State when LED is litted + +#define BUTTON_PIN (32 + 2) //P1.02 7 + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (0 + 24) //P0.24 1 +#define PIN_SERIAL1_TX (0 + 25) //P0.25 0 + +#define PIN_SERIAL2_RX (-1) +#define PIN_SERIAL2_TX (-1) + +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (0 + 15) //P0.15 24 +#define PIN_SPI_MOSI (0 + 13) //P0.13 25 +#define PIN_SPI_SCK (0 + 14) //P0.14 26 + +#define SS 2 #define LORA_DIO0 -1 // a No connect on the SX1262/SX1268 module -#define LORA_RESET 13 // RST for SX1276, and for SX1262/SX1268 -#define LORA_DIO1 11 // IRQ for SX1262/SX1268 -#define LORA_DIO2 12 // BUSY for SX1262/SX1268 +#define LORA_RESET (32 + 9) //P1.09 13 // RST for SX1276, and for SX1262/SX1268 +#define LORA_DIO1 (0 + 6) //P0.06 11 // IRQ for SX1262/SX1268 +#define LORA_DIO2 (0 + 8) //P0.08 12 // BUSY for SX1262/SX1268 #define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262/SX1268, if DIO3 is high the TXCO is enabled #define RF95_SCK SCK #define RF95_MISO MI #define RF95_MOSI MO -#define RF95_NSS D2 +#define RF95_NSS SS + +// enables 3.3V periphery like GPS or IO Module +#define PIN_3V3_EN (-1) + +#undef USE_EINK // supported modules list #define USE_SX1262 @@ -23,11 +99,21 @@ #define SX126X_DIO1 LORA_DIO1 #define SX126X_BUSY LORA_DIO2 #define SX126X_RESET LORA_RESET -#define SX126X_RXEN 10 -#define SX126X_TXEN 9 +#define SX126X_RXEN (0 + 27) //P0.27 10 +#define SX126X_TXEN (0 + 26) //P0.26 9 #ifdef EBYTE_E22 // Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch // (which is the default for the sx1262interface code) #define SX126X_E22 #endif + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif From a49355133c5c3171d424eb63593e94978bedf11e Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 4 Nov 2022 14:23:22 -0500 Subject: [PATCH 079/133] Cheating --- .github/workflows/main_matrix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 640b88e51..66bf7539c 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -105,7 +105,7 @@ jobs: - board: m5stack-coreink - board: tbeam-s3-core - runs-on: [self-hosted, ubuntu-latest] + runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 From 176072801ba01e7ba6ec73e7c63af46b29c905c5 Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 5 Nov 2022 09:58:10 +0100 Subject: [PATCH 080/133] Change preambleLength to 8 symbols to reduce airtime --- src/mesh/RadioInterface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/RadioInterface.h b/src/mesh/RadioInterface.h index e9f725c89..8570d7b39 100644 --- a/src/mesh/RadioInterface.h +++ b/src/mesh/RadioInterface.h @@ -65,7 +65,7 @@ class RadioInterface - Tx/Rx turnaround time (maximum of SX126x and SX127x); - MAC processing time (measured on T-beam) */ uint32_t slotTimeMsec = 8.5 * pow(2, sf)/bw + 0.2 + 0.4 + 7; - uint16_t preambleLength = 32; // 8 is default, but we use longer to increase the amount of sleep time when receiving + uint16_t preambleLength = 8; // 8 is default const uint32_t PROCESSING_TIME_MSEC = 4500; // time to construct, process and construct a packet again (empirically determined) const uint8_t CWmin = 2; // minimum CWsize const uint8_t CWmax = 8; // maximum CWsize From a547a791ba11b59e02570ea859cbdcd4c6b5c0f5 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 06:42:53 -0500 Subject: [PATCH 081/133] Cleanup artifacts older than 1 month --- .github/workflows/cleanup_artifacts.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/cleanup_artifacts.yml diff --git a/.github/workflows/cleanup_artifacts.yml b/.github/workflows/cleanup_artifacts.yml new file mode 100644 index 000000000..183d1dc7e --- /dev/null +++ b/.github/workflows/cleanup_artifacts.yml @@ -0,0 +1,17 @@ +name: Remove old artifacts + +on: + schedule: + # Every day at 1am + - cron: '0 1 * * *' + +jobs: + remove-old-artifacts: + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Remove old artifacts + uses: c-hive/gha-remove-artifacts@v1 + with: + age: '1 month' From 4c931967c7d08f26dca891382e2177fb6432cc44 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 06:44:08 -0500 Subject: [PATCH 082/133] Update cleanup_artifacts.yml --- .github/workflows/cleanup_artifacts.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cleanup_artifacts.yml b/.github/workflows/cleanup_artifacts.yml index 183d1dc7e..7fef005f1 100644 --- a/.github/workflows/cleanup_artifacts.yml +++ b/.github/workflows/cleanup_artifacts.yml @@ -4,6 +4,8 @@ on: schedule: # Every day at 1am - cron: '0 1 * * *' + + workflow_dispatch: jobs: remove-old-artifacts: From 764b48e04a3d6917821ea15fa4b3176e47dbccb8 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 06:47:00 -0500 Subject: [PATCH 083/133] Update cleanup_artifacts.yml --- .github/workflows/cleanup_artifacts.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cleanup_artifacts.yml b/.github/workflows/cleanup_artifacts.yml index 7fef005f1..d95304ccf 100644 --- a/.github/workflows/cleanup_artifacts.yml +++ b/.github/workflows/cleanup_artifacts.yml @@ -16,4 +16,5 @@ jobs: - name: Remove old artifacts uses: c-hive/gha-remove-artifacts@v1 with: - age: '1 month' + age: '1 month' + skip-tags: true From 3dc6ed5672348b9dd0a8c092f536fdbeb509080f Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 06:57:47 -0500 Subject: [PATCH 084/133] Update cleanup_artifacts.yml --- .github/workflows/cleanup_artifacts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cleanup_artifacts.yml b/.github/workflows/cleanup_artifacts.yml index d95304ccf..df55e4273 100644 --- a/.github/workflows/cleanup_artifacts.yml +++ b/.github/workflows/cleanup_artifacts.yml @@ -16,5 +16,5 @@ jobs: - name: Remove old artifacts uses: c-hive/gha-remove-artifacts@v1 with: - age: '1 month' + age: '2 month' skip-tags: true From 01381057c5dc16758953b4748422b293619883b6 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 08:06:28 -0500 Subject: [PATCH 085/133] Delete cleanup_artifacts.yml --- .github/workflows/cleanup_artifacts.yml | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 .github/workflows/cleanup_artifacts.yml diff --git a/.github/workflows/cleanup_artifacts.yml b/.github/workflows/cleanup_artifacts.yml deleted file mode 100644 index df55e4273..000000000 --- a/.github/workflows/cleanup_artifacts.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Remove old artifacts - -on: - schedule: - # Every day at 1am - - cron: '0 1 * * *' - - workflow_dispatch: - -jobs: - remove-old-artifacts: - runs-on: ubuntu-latest - timeout-minutes: 10 - - steps: - - name: Remove old artifacts - uses: c-hive/gha-remove-artifacts@v1 - with: - age: '2 month' - skip-tags: true From 8874a6e4883525ee3b81d75ab611a5d28660ff94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 5 Nov 2022 14:18:57 +0100 Subject: [PATCH 086/133] update protos --- protobufs | 2 +- src/mesh/generated/config.pb.c | 1 + src/mesh/generated/config.pb.h | 21 +++++++++++++++++---- src/mesh/generated/localonly.pb.h | 2 +- src/mesh/generated/mesh.pb.h | 4 ++-- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/protobufs b/protobufs index fa47c6455..7e102f0f3 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit fa47c64558473c806ca6535d407df7409acbc283 +Subproject commit 7e102f0f3c4d6a41e9ee42e4771ca3c35c517d56 diff --git a/src/mesh/generated/config.pb.c b/src/mesh/generated/config.pb.c index c5bc69552..2b75b7558 100644 --- a/src/mesh/generated/config.pb.c +++ b/src/mesh/generated/config.pb.c @@ -43,3 +43,4 @@ PB_BIND(Config_BluetoothConfig, Config_BluetoothConfig, AUTO) + diff --git a/src/mesh/generated/config.pb.h b/src/mesh/generated/config.pb.h index 6a8e56ad0..263b1e916 100644 --- a/src/mesh/generated/config.pb.h +++ b/src/mesh/generated/config.pb.h @@ -56,6 +56,12 @@ typedef enum _Config_DisplayConfig_DisplayUnits { Config_DisplayConfig_DisplayUnits_IMPERIAL = 1 } Config_DisplayConfig_DisplayUnits; +typedef enum _Config_DisplayConfig_OledType { + Config_DisplayConfig_OledType_OLED_AUTO = 0, + Config_DisplayConfig_OledType_OLED_SSD1306 = 1, + Config_DisplayConfig_OledType_OLED_SH1106 = 2 +} Config_DisplayConfig_OledType; + typedef enum _Config_LoRaConfig_RegionCode { Config_LoRaConfig_RegionCode_UNSET = 0, Config_LoRaConfig_RegionCode_US = 1, @@ -109,6 +115,7 @@ typedef struct _Config_DisplayConfig { bool compass_north_top; bool flip_screen; Config_DisplayConfig_DisplayUnits units; + Config_DisplayConfig_OledType oled; } Config_DisplayConfig; typedef struct _Config_LoRaConfig { @@ -205,6 +212,10 @@ typedef struct _Config { #define _Config_DisplayConfig_DisplayUnits_MAX Config_DisplayConfig_DisplayUnits_IMPERIAL #define _Config_DisplayConfig_DisplayUnits_ARRAYSIZE ((Config_DisplayConfig_DisplayUnits)(Config_DisplayConfig_DisplayUnits_IMPERIAL+1)) +#define _Config_DisplayConfig_OledType_MIN Config_DisplayConfig_OledType_OLED_AUTO +#define _Config_DisplayConfig_OledType_MAX Config_DisplayConfig_OledType_OLED_SH1106 +#define _Config_DisplayConfig_OledType_ARRAYSIZE ((Config_DisplayConfig_OledType)(Config_DisplayConfig_OledType_OLED_SH1106+1)) + #define _Config_LoRaConfig_RegionCode_MIN Config_LoRaConfig_RegionCode_UNSET #define _Config_LoRaConfig_RegionCode_MAX Config_LoRaConfig_RegionCode_LORA_24 #define _Config_LoRaConfig_RegionCode_ARRAYSIZE ((Config_LoRaConfig_RegionCode)(Config_LoRaConfig_RegionCode_LORA_24+1)) @@ -229,7 +240,7 @@ extern "C" { #define Config_PowerConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0} #define Config_NetworkConfig_init_default {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_default} #define Config_NetworkConfig_IpV4Config_init_default {0, 0, 0, 0} -#define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN} +#define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN} #define Config_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}} #define Config_BluetoothConfig_init_default {0, _Config_BluetoothConfig_PairingMode_MIN, 0} #define Config_init_zero {0, {Config_DeviceConfig_init_zero}} @@ -238,7 +249,7 @@ extern "C" { #define Config_PowerConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0} #define Config_NetworkConfig_init_zero {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_zero} #define Config_NetworkConfig_IpV4Config_init_zero {0, 0, 0, 0} -#define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN} +#define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN} #define Config_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}} #define Config_BluetoothConfig_init_zero {0, _Config_BluetoothConfig_PairingMode_MIN, 0} @@ -255,6 +266,7 @@ extern "C" { #define Config_DisplayConfig_compass_north_top_tag 4 #define Config_DisplayConfig_flip_screen_tag 5 #define Config_DisplayConfig_units_tag 6 +#define Config_DisplayConfig_oled_tag 7 #define Config_LoRaConfig_use_preset_tag 1 #define Config_LoRaConfig_modem_preset_tag 2 #define Config_LoRaConfig_bandwidth_tag 3 @@ -376,7 +388,8 @@ X(a, STATIC, SINGULAR, UENUM, gps_format, 2) \ X(a, STATIC, SINGULAR, UINT32, auto_screen_carousel_secs, 3) \ X(a, STATIC, SINGULAR, BOOL, compass_north_top, 4) \ X(a, STATIC, SINGULAR, BOOL, flip_screen, 5) \ -X(a, STATIC, SINGULAR, UENUM, units, 6) +X(a, STATIC, SINGULAR, UENUM, units, 6) \ +X(a, STATIC, SINGULAR, UENUM, oled, 7) #define Config_DisplayConfig_CALLBACK NULL #define Config_DisplayConfig_DEFAULT NULL @@ -427,7 +440,7 @@ extern const pb_msgdesc_t Config_BluetoothConfig_msg; /* Maximum encoded size of messages (where known) */ #define Config_BluetoothConfig_size 10 #define Config_DeviceConfig_size 6 -#define Config_DisplayConfig_size 20 +#define Config_DisplayConfig_size 22 #define Config_LoRaConfig_size 68 #define Config_NetworkConfig_IpV4Config_size 20 #define Config_NetworkConfig_size 161 diff --git a/src/mesh/generated/localonly.pb.h b/src/mesh/generated/localonly.pb.h index 76e713c1d..783c523c7 100644 --- a/src/mesh/generated/localonly.pb.h +++ b/src/mesh/generated/localonly.pb.h @@ -150,7 +150,7 @@ extern const pb_msgdesc_t LocalModuleConfig_msg; #define LocalModuleConfig_fields &LocalModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define LocalConfig_size 359 +#define LocalConfig_size 361 #define LocalModuleConfig_size 294 #ifdef __cplusplus diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index 812099166..c1c2bdd7b 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -501,7 +501,7 @@ typedef PB_BYTES_ARRAY_T(256) MeshPacket_encrypted_t; typedef struct _MeshPacket { /* The sending node number. Note: Our crypto implementation uses this field as well. - See [crypto](/docs/developers/firmware/encryption) for details. + See [crypto](/docs/about/overview/encryption) for details. FIXME - really should be fixed32 instead, this encoding only hurts the ble link though. */ uint32_t from; /* The (immediatSee Priority description for more details.y should be fixed32 instead, this encoding only @@ -529,7 +529,7 @@ typedef struct _MeshPacket { needs to be unique for a few minutes (long enough to last for the length of any ACK or the completion of a mesh broadcast flood). Note: Our crypto implementation uses this id as well. - See [crypto](/docs/developers/firmware/encryption) for details. + See [crypto](/docs/about/overview/encryption) for details. FIXME - really should be fixed32 instead, this encoding only hurts the ble link though. */ uint32_t id; From ed26ab801c8e6edbca8bb6fbc04561f77572e28b Mon Sep 17 00:00:00 2001 From: Lars Weber Date: Sat, 5 Nov 2022 14:37:00 +0100 Subject: [PATCH 087/133] fix: use RF95_IRQ for wakeup source in doLightSleep (#1899) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Thomas Göttgens Co-authored-by: Ben Meadors --- src/sleep.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sleep.cpp b/src/sleep.cpp index 055cf770d..390ab7f65 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -263,8 +263,8 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r #ifdef BUTTON_PIN gpio_wakeup_enable((gpio_num_t)BUTTON_PIN, GPIO_INTR_LOW_LEVEL); // when user presses, this button goes low #endif -#ifdef RF95_IRQ_GPIO - gpio_wakeup_enable((gpio_num_t)RF95_IRQ_GPIO, GPIO_INTR_HIGH_LEVEL); // RF95 interrupt, active high +#ifdef RF95_IRQ + gpio_wakeup_enable((gpio_num_t)RF95_IRQ, GPIO_INTR_HIGH_LEVEL); // RF95 interrupt, active high #endif #ifdef PMU_IRQ // wake due to PMU can happen repeatedly if there is no battery installed or the battery fills From cda7a6073440148000d6da5f94f4dfb0b980b1da Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 08:43:44 -0500 Subject: [PATCH 088/133] Update protos --- protobufs | 2 +- src/mesh/generated/mesh.pb.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/protobufs b/protobufs index a0fe9ec86..6b46e42a6 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit a0fe9ec8614cd27af7691869ccbd20c39e48a086 +Subproject commit 6b46e42a656dd3aab74c373e79b70e699eeac834 diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index 812099166..c1c2bdd7b 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -501,7 +501,7 @@ typedef PB_BYTES_ARRAY_T(256) MeshPacket_encrypted_t; typedef struct _MeshPacket { /* The sending node number. Note: Our crypto implementation uses this field as well. - See [crypto](/docs/developers/firmware/encryption) for details. + See [crypto](/docs/about/overview/encryption) for details. FIXME - really should be fixed32 instead, this encoding only hurts the ble link though. */ uint32_t from; /* The (immediatSee Priority description for more details.y should be fixed32 instead, this encoding only @@ -529,7 +529,7 @@ typedef struct _MeshPacket { needs to be unique for a few minutes (long enough to last for the length of any ACK or the completion of a mesh broadcast flood). Note: Our crypto implementation uses this id as well. - See [crypto](/docs/developers/firmware/encryption) for details. + See [crypto](/docs/about/overview/encryption) for details. FIXME - really should be fixed32 instead, this encoding only hurts the ble link though. */ uint32_t id; From 1716c4d6f99b85ae7457fafd27ea77033cf92e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 5 Nov 2022 15:02:06 +0100 Subject: [PATCH 089/133] Allow static IP for WLAN and portentially fix reconnect issues --- protobufs | 2 +- src/mesh/generated/config.pb.h | 21 +++++++-------------- src/mesh/generated/localonly.pb.h | 2 +- src/mesh/http/WiFiAPClient.cpp | 9 ++++++--- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/protobufs b/protobufs index 7e102f0f3..2954e5b02 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 7e102f0f3c4d6a41e9ee42e4771ca3c35c517d56 +Subproject commit 2954e5b0228c85902c841bfb0f18add43980a2e2 diff --git a/src/mesh/generated/config.pb.h b/src/mesh/generated/config.pb.h index 263b1e916..a9005ddcd 100644 --- a/src/mesh/generated/config.pb.h +++ b/src/mesh/generated/config.pb.h @@ -31,12 +31,6 @@ typedef enum _Config_PositionConfig_PositionFlags { Config_PositionConfig_PositionFlags_SPEED = 512 } Config_PositionConfig_PositionFlags; -typedef enum _Config_NetworkConfig_WiFiMode { - Config_NetworkConfig_WiFiMode_CLIENT = 0, - Config_NetworkConfig_WiFiMode_ACCESS_POINT = 1, - Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN = 2 -} Config_NetworkConfig_WiFiMode; - typedef enum _Config_NetworkConfig_EthMode { Config_NetworkConfig_EthMode_DHCP = 0, Config_NetworkConfig_EthMode_STATIC = 1 @@ -164,6 +158,7 @@ typedef struct _Config_PowerConfig { typedef struct _Config_NetworkConfig { bool wifi_enabled; + Config_NetworkConfig_EthMode wifi_mode; char wifi_ssid[33]; char wifi_psk[64]; char ntp_server[33]; @@ -196,10 +191,6 @@ typedef struct _Config { #define _Config_PositionConfig_PositionFlags_MAX Config_PositionConfig_PositionFlags_SPEED #define _Config_PositionConfig_PositionFlags_ARRAYSIZE ((Config_PositionConfig_PositionFlags)(Config_PositionConfig_PositionFlags_SPEED+1)) -#define _Config_NetworkConfig_WiFiMode_MIN Config_NetworkConfig_WiFiMode_CLIENT -#define _Config_NetworkConfig_WiFiMode_MAX Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN -#define _Config_NetworkConfig_WiFiMode_ARRAYSIZE ((Config_NetworkConfig_WiFiMode)(Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN+1)) - #define _Config_NetworkConfig_EthMode_MIN Config_NetworkConfig_EthMode_DHCP #define _Config_NetworkConfig_EthMode_MAX Config_NetworkConfig_EthMode_STATIC #define _Config_NetworkConfig_EthMode_ARRAYSIZE ((Config_NetworkConfig_EthMode)(Config_NetworkConfig_EthMode_STATIC+1)) @@ -238,7 +229,7 @@ extern "C" { #define Config_DeviceConfig_init_default {_Config_DeviceConfig_Role_MIN, 0, 0} #define Config_PositionConfig_init_default {0, 0, 0, 0, 0, 0, 0} #define Config_PowerConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0} -#define Config_NetworkConfig_init_default {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_default} +#define Config_NetworkConfig_init_default {0, _Config_NetworkConfig_EthMode_MIN, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_default} #define Config_NetworkConfig_IpV4Config_init_default {0, 0, 0, 0} #define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN} #define Config_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}} @@ -247,7 +238,7 @@ extern "C" { #define Config_DeviceConfig_init_zero {_Config_DeviceConfig_Role_MIN, 0, 0} #define Config_PositionConfig_init_zero {0, 0, 0, 0, 0, 0, 0} #define Config_PowerConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0} -#define Config_NetworkConfig_init_zero {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_zero} +#define Config_NetworkConfig_init_zero {0, _Config_NetworkConfig_EthMode_MIN, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_zero} #define Config_NetworkConfig_IpV4Config_init_zero {0, 0, 0, 0} #define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN} #define Config_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}} @@ -299,6 +290,7 @@ extern "C" { #define Config_PowerConfig_ls_secs_tag 7 #define Config_PowerConfig_min_wake_secs_tag 8 #define Config_NetworkConfig_wifi_enabled_tag 1 +#define Config_NetworkConfig_wifi_mode_tag 2 #define Config_NetworkConfig_wifi_ssid_tag 3 #define Config_NetworkConfig_wifi_psk_tag 4 #define Config_NetworkConfig_ntp_server_tag 5 @@ -364,6 +356,7 @@ X(a, STATIC, SINGULAR, UINT32, min_wake_secs, 8) #define Config_NetworkConfig_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, BOOL, wifi_enabled, 1) \ +X(a, STATIC, SINGULAR, UENUM, wifi_mode, 2) \ X(a, STATIC, SINGULAR, STRING, wifi_ssid, 3) \ X(a, STATIC, SINGULAR, STRING, wifi_psk, 4) \ X(a, STATIC, SINGULAR, STRING, ntp_server, 5) \ @@ -443,10 +436,10 @@ extern const pb_msgdesc_t Config_BluetoothConfig_msg; #define Config_DisplayConfig_size 22 #define Config_LoRaConfig_size 68 #define Config_NetworkConfig_IpV4Config_size 20 -#define Config_NetworkConfig_size 161 +#define Config_NetworkConfig_size 163 #define Config_PositionConfig_size 30 #define Config_PowerConfig_size 43 -#define Config_size 164 +#define Config_size 166 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/localonly.pb.h b/src/mesh/generated/localonly.pb.h index 783c523c7..a69aefc10 100644 --- a/src/mesh/generated/localonly.pb.h +++ b/src/mesh/generated/localonly.pb.h @@ -150,7 +150,7 @@ extern const pb_msgdesc_t LocalModuleConfig_msg; #define LocalModuleConfig_fields &LocalModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define LocalConfig_size 361 +#define LocalConfig_size 363 #define LocalModuleConfig_size 294 #ifdef __cplusplus diff --git a/src/mesh/http/WiFiAPClient.cpp b/src/mesh/http/WiFiAPClient.cpp index a031414e3..6caad79c0 100644 --- a/src/mesh/http/WiFiAPClient.cpp +++ b/src/mesh/http/WiFiAPClient.cpp @@ -169,6 +169,11 @@ bool initWifi() WiFi.mode(WIFI_MODE_STA); WiFi.setHostname(ourHost); WiFi.onEvent(WiFiEvent); + WiFi.setAutoReconnect(true); + WiFi.setSleep(false); + if (config.network.wifi_mode == Config_NetworkConfig_EthMode_STATIC && config.network.ipv4_config.ip != 0) { + WiFi.config(config.network.ipv4_config.ip,config.network.ipv4_config.gateway,config.network.ipv4_config.subnet,config.network.ipv4_config.dns,config.network.ipv4_config.dns); + } // This is needed to improve performance. esp_wifi_set_ps(WIFI_PS_NONE); // Disable radio power saving @@ -222,8 +227,6 @@ static void WiFiEvent(WiFiEvent_t event) break; case SYSTEM_EVENT_STA_DISCONNECTED: DEBUG_MSG("Disconnected from WiFi access point\n"); - // Event 5 - needReconnect = true; break; case SYSTEM_EVENT_STA_AUTHMODE_CHANGE: @@ -236,6 +239,7 @@ static void WiFiEvent(WiFiEvent_t event) break; case SYSTEM_EVENT_STA_LOST_IP: DEBUG_MSG("Lost IP address and IP address is reset to 0\n"); + needReconnect = true; break; case SYSTEM_EVENT_STA_WPS_ER_SUCCESS: DEBUG_MSG("WiFi Protected Setup (WPS): succeeded in enrollee mode\n"); @@ -251,7 +255,6 @@ static void WiFiEvent(WiFiEvent_t event) break; case SYSTEM_EVENT_AP_START: DEBUG_MSG("WiFi access point started\n"); - onNetworkConnected(); break; case SYSTEM_EVENT_AP_STOP: From c6f060a24fed4c9ff0e3eed81110b8bb07c85bc3 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 09:21:51 -0500 Subject: [PATCH 090/133] Add develop to CI --- .github/workflows/main_matrix.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 66bf7539c..4736de06e 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -2,14 +2,14 @@ name: CI on: # # Triggers the workflow on push but only for the master branch push: - branches: [master] + branches: [master, develop] paths-ignore: - "**.md" - "version.properties" # Note: This is different from "pull_request". Need to specify ref when doing checkouts. pull_request_target: - branches: [master] + branches: [master, develop] paths-ignore: - "**.md" #- "**.yml" From 950d5defda88abfd2d033410184e855c38fd4bc2 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 09:28:41 -0500 Subject: [PATCH 091/133] Master to develop (resolves conflicts) (#1903) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Rearranging deck chairs, 900M22S working, 30S not * We do have wire, just not where it's expected * Put more of the module specific pins in their blocks * tryfix compile with NO_SCREEN * Portduino only: don't continue to try rebooting (#1887) Co-authored-by: Thomas Göttgens * Support for TLORA 2.1-1.8 * Don't allow arbitrary channel name for admin (#1886) Co-authored-by: Ben Meadors * Experimental DIY nrf52840 feather support (#1884) * Experimental DIY nrf52840 feather support * Fix target * sx1262 wiring * Remove lib * Don't consider Response as ACK for FloodingRouter (#1885) Co-authored-by: Ben Meadors * Fix feather diy (#1892) * Fix variant * Fix feather diy target * [modules][external notifications] allow select channel to listen to * Fix feather diy pin mapping (#1894) Thanks to @markbirss * [create-pull-request] automated change * Override Screen Autodtect * Maybe fix crash of this board. * Fixes reset loop with new espressif32 platform on tlora-v2 Sending a pulse to the OLED_RESET Pin 16 results in a reset loop using recent version of the espressif32 platform. * Experiment with self hosted action runner * Fix MQTT on ETH * revert the tryfix * Cheating * Cleanup artifacts older than 1 month * Update cleanup_artifacts.yml * Update cleanup_artifacts.yml * Update cleanup_artifacts.yml * Delete cleanup_artifacts.yml * fix: use RF95_IRQ for wakeup source in doLightSleep (#1899) Co-authored-by: Thomas Göttgens Co-authored-by: Ben Meadors * Update protos * Update protos Co-authored-by: code8buster Co-authored-by: Thomas Göttgens Co-authored-by: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Co-authored-by: Mykhailo Lesyk Co-authored-by: Mykhailo Lesyk Co-authored-by: caveman99 Co-authored-by: he-leon Co-authored-by: Lars Weber --- src/mesh/Router.cpp | 6 +++--- src/mesh/generated/config.pb.c | 1 - src/sleep.cpp | 4 ++-- variants/tlora_v2/variant.h | 4 +--- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 815571b9b..e0746bdd9 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -11,7 +11,7 @@ extern "C" { #include "mesh/compression/unishox2.h" } -#if HAS_WIFI +#if HAS_WIFI || HAS_ETHERNET #include "mqtt/MQTT.h" #endif @@ -209,7 +209,7 @@ ErrorCode Router::send(MeshPacket *p) if (p->which_payload_variant == MeshPacket_decoded_tag) { ChannelIndex chIndex = p->channel; // keep as a local because we are about to change it -#if HAS_WIFI +#if HAS_WIFI || HAS_ETHERNET // check if we should send decrypted packets to mqtt // truth table: @@ -240,7 +240,7 @@ ErrorCode Router::send(MeshPacket *p) return encodeResult; // FIXME - this isn't a valid ErrorCode } -#if HAS_WIFI +#if HAS_WIFI || HAS_ETHERNET // the packet is now encrypted. // check if we should send encrypted packets to mqtt if (mqtt && shouldActuallyEncrypt) diff --git a/src/mesh/generated/config.pb.c b/src/mesh/generated/config.pb.c index 2b75b7558..c5bc69552 100644 --- a/src/mesh/generated/config.pb.c +++ b/src/mesh/generated/config.pb.c @@ -43,4 +43,3 @@ PB_BIND(Config_BluetoothConfig, Config_BluetoothConfig, AUTO) - diff --git a/src/sleep.cpp b/src/sleep.cpp index 055cf770d..390ab7f65 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -263,8 +263,8 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r #ifdef BUTTON_PIN gpio_wakeup_enable((gpio_num_t)BUTTON_PIN, GPIO_INTR_LOW_LEVEL); // when user presses, this button goes low #endif -#ifdef RF95_IRQ_GPIO - gpio_wakeup_enable((gpio_num_t)RF95_IRQ_GPIO, GPIO_INTR_HIGH_LEVEL); // RF95 interrupt, active high +#ifdef RF95_IRQ + gpio_wakeup_enable((gpio_num_t)RF95_IRQ, GPIO_INTR_HIGH_LEVEL); // RF95 interrupt, active high #endif #ifdef PMU_IRQ // wake due to PMU can happen repeatedly if there is no battery installed or the battery fills diff --git a/variants/tlora_v2/variant.h b/variants/tlora_v2/variant.h index 1bff09fb0..0c854e37a 100644 --- a/variants/tlora_v2/variant.h +++ b/variants/tlora_v2/variant.h @@ -8,8 +8,6 @@ #define I2C_SDA 21 // I2C pins for this board #define I2C_SCL 22 -#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller - #define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost #define LED_PIN 25 // If defined we will blink this LED #define BUTTON_PIN \ @@ -21,4 +19,4 @@ #define LORA_DIO0 26 // a No connect on the SX1262 module #define LORA_RESET 14 #define LORA_DIO1 35 // Not really used -#define LORA_DIO2 34 // Not really used \ No newline at end of file +#define LORA_DIO2 34 // Not really used From 087c7c19af3beaa55caab129d9e73487d972fbdd Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 09:34:33 -0500 Subject: [PATCH 092/133] Update protos --- src/mesh/generated/config.pb.c | 1 - src/mesh/generated/localonly.pb.h | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/mesh/generated/config.pb.c b/src/mesh/generated/config.pb.c index 2b75b7558..c5bc69552 100644 --- a/src/mesh/generated/config.pb.c +++ b/src/mesh/generated/config.pb.c @@ -43,4 +43,3 @@ PB_BIND(Config_BluetoothConfig, Config_BluetoothConfig, AUTO) - diff --git a/src/mesh/generated/localonly.pb.h b/src/mesh/generated/localonly.pb.h index dd633a961..a69aefc10 100644 --- a/src/mesh/generated/localonly.pb.h +++ b/src/mesh/generated/localonly.pb.h @@ -150,8 +150,8 @@ extern const pb_msgdesc_t LocalModuleConfig_msg; #define LocalModuleConfig_fields &LocalModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define LocalConfig_size 359 -#define LocalModuleConfig_size 270 +#define LocalConfig_size 363 +#define LocalModuleConfig_size 294 #ifdef __cplusplus } /* extern "C" */ From 3d9633a56cbf4520c81926d9229053563123657f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 5 Nov 2022 20:12:41 +0100 Subject: [PATCH 093/133] Different Sensor access, should prevent overheating/wrong measurements. --- src/modules/Telemetry/Sensor/BME280Sensor.cpp | 9 +++++++++ src/modules/Telemetry/Sensor/BMP280Sensor.cpp | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/modules/Telemetry/Sensor/BME280Sensor.cpp b/src/modules/Telemetry/Sensor/BME280Sensor.cpp index 15ec18007..4b6a50091 100644 --- a/src/modules/Telemetry/Sensor/BME280Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BME280Sensor.cpp @@ -16,6 +16,14 @@ int32_t BME280Sensor::runOnce() { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; } status = bme280.begin(nodeTelemetrySensorsMap[sensorType]); + + bme280.setSampling( Adafruit_BME280::MODE_FORCED, + Adafruit_BME280::SAMPLING_X1, // Temp. oversampling + Adafruit_BME280::SAMPLING_X1, // Pressure oversampling + Adafruit_BME280::SAMPLING_X1, // Humidity oversampling + Adafruit_BME280::FILTER_OFF, + Adafruit_BME280::STANDBY_MS_1000); + return initI2CSensor(); } @@ -23,6 +31,7 @@ void BME280Sensor::setup() { } bool BME280Sensor::getMetrics(Telemetry *measurement) { DEBUG_MSG("BME280Sensor::getMetrics\n"); + bme280.takeForcedMeasurement(); measurement->variant.environment_metrics.temperature = bme280.readTemperature(); measurement->variant.environment_metrics.relative_humidity = bme280.readHumidity(); measurement->variant.environment_metrics.barometric_pressure = bme280.readPressure() / 100.0F; diff --git a/src/modules/Telemetry/Sensor/BMP280Sensor.cpp b/src/modules/Telemetry/Sensor/BMP280Sensor.cpp index 4fecdf1a8..917c40d6f 100644 --- a/src/modules/Telemetry/Sensor/BMP280Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BMP280Sensor.cpp @@ -16,6 +16,13 @@ int32_t BMP280Sensor::runOnce() { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; } status = bmp280.begin(nodeTelemetrySensorsMap[sensorType]); + + bmp280.setSampling( Adafruit_BMP280::MODE_FORCED, + Adafruit_BMP280::SAMPLING_X1, // Temp. oversampling + Adafruit_BMP280::SAMPLING_X1, // Pressure oversampling + Adafruit_BMP280::FILTER_OFF, + Adafruit_BMP280::STANDBY_MS_1000); + return initI2CSensor(); } @@ -23,6 +30,7 @@ void BMP280Sensor::setup() { } bool BMP280Sensor::getMetrics(Telemetry *measurement) { DEBUG_MSG("BMP280Sensor::getMetrics\n"); + bmp280.takeForcedMeasurement(); measurement->variant.environment_metrics.temperature = bmp280.readTemperature(); measurement->variant.environment_metrics.barometric_pressure = bmp280.readPressure() / 100.0F; From 16444c190d965bf703b81708a19f5498504d18b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 5 Nov 2022 20:13:47 +0100 Subject: [PATCH 094/133] Ignore Band power limits for licensed HAMs --- src/mesh/RadioInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 81821ac19..97dd66fae 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -416,7 +416,7 @@ void RadioInterface::applyModemConfig() power = loraConfig.tx_power; assert(myRegion); // Should have been found in init - if ((power == 0) || (power > myRegion->powerLimit)) + if ((power == 0) || ((power > myRegion->powerLimit) && !devicestate.owner.is_licensed)) power = myRegion->powerLimit; if (power == 0) @@ -460,7 +460,7 @@ void RadioInterface::limitPower() if (myRegion->powerLimit) maxPower = myRegion->powerLimit; - if (power > maxPower) { + if ((power > maxPower) && !devicestate.owner.is_licensed) { DEBUG_MSG("Lowering transmit power because of regulatory limits\n"); power = maxPower; } From 30e5706eaa313966fe8a636606fb85cfa12aad7a Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 15:10:43 -0500 Subject: [PATCH 095/133] Fix for alpine linux builds --- src/gps/NMEAWPL.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gps/NMEAWPL.h b/src/gps/NMEAWPL.h index 853c850eb..44e081bf7 100644 --- a/src/gps/NMEAWPL.h +++ b/src/gps/NMEAWPL.h @@ -3,5 +3,5 @@ #include #include "main.h" -uint printWPL(char *buf, const Position &pos, const char *name); -uint printGGA(char *buf, const Position &pos); +uin32_t printWPL(char *buf, const Position &pos, const char *name); +uin32_t printGGA(char *buf, const Position &pos); From a08ac5a47e0d21d5cd3dba20ad97e88e915ed01a Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 15:11:11 -0500 Subject: [PATCH 096/133] Update NMEAWPL.cpp --- src/gps/NMEAWPL.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gps/NMEAWPL.cpp b/src/gps/NMEAWPL.cpp index 95e69343b..d23e78182 100644 --- a/src/gps/NMEAWPL.cpp +++ b/src/gps/NMEAWPL.cpp @@ -15,7 +15,7 @@ * ------------------------------------------- */ -uint printWPL(char *buf, const Position &pos, const char *name) +uint32_t printWPL(char *buf, const Position &pos, const char *name) { uint len = sprintf(buf, "$GNWPL,%07.2f,%c,%08.2f,%c,%s", pos.latitude_i * 1e-5, pos.latitude_i < 0 ? 'S' : 'N', pos.longitude_i * 1e-5, pos.longitude_i < 0 ? 'W' : 'E', name); uint chk = 0; @@ -50,9 +50,9 @@ uint printWPL(char *buf, const Position &pos, const char *name) * ------------------------------------------- */ -uint printGGA(char *buf, const Position &pos) +uint32_t printGGA(char *buf, const Position &pos) { - uint len = sprintf(buf, "$GNGGA,%06u.%03u,%07.2f,%c,%08.2f,%c,%u,%02u,%04u,%04d,%c,%04d,%c,%d,%04d", + uint32_t len = sprintf(buf, "$GNGGA,%06u.%03u,%07.2f,%c,%08.2f,%c,%u,%02u,%04u,%04d,%c,%04d,%c,%d,%04d", pos.time / 1000, pos.time % 1000, pos.latitude_i * 1e-5, pos.latitude_i < 0 ? 'S' : 'N', @@ -67,10 +67,10 @@ uint printGGA(char *buf, const Position &pos) 0, 0); - uint chk = 0; - for (uint i = 1; i < len; i++) { + uint32_t chk = 0; + for (uint32_t i = 1; i < len; i++) { chk ^= buf[i]; } len += sprintf(buf + len, "*%02X\r\n", chk); return len; -} \ No newline at end of file +} From a7a020f431cc153932e783ef7ba35d1f44b7085a Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 15:14:08 -0500 Subject: [PATCH 097/133] Update NMEAWPL.cpp --- src/gps/NMEAWPL.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gps/NMEAWPL.cpp b/src/gps/NMEAWPL.cpp index d23e78182..666f9131b 100644 --- a/src/gps/NMEAWPL.cpp +++ b/src/gps/NMEAWPL.cpp @@ -17,8 +17,8 @@ uint32_t printWPL(char *buf, const Position &pos, const char *name) { - uint len = sprintf(buf, "$GNWPL,%07.2f,%c,%08.2f,%c,%s", pos.latitude_i * 1e-5, pos.latitude_i < 0 ? 'S' : 'N', pos.longitude_i * 1e-5, pos.longitude_i < 0 ? 'W' : 'E', name); - uint chk = 0; + uint32_t len = sprintf(buf, "$GNWPL,%07.2f,%c,%08.2f,%c,%s", pos.latitude_i * 1e-5, pos.latitude_i < 0 ? 'S' : 'N', pos.longitude_i * 1e-5, pos.longitude_i < 0 ? 'W' : 'E', name); + uint32_t chk = 0; for (uint i = 1; i < len; i++) { chk ^= buf[i]; } From d641adc0fc677548753af2d1571441c27997913a Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 15:20:09 -0500 Subject: [PATCH 098/133] Update NMEAWPL.h --- src/gps/NMEAWPL.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gps/NMEAWPL.h b/src/gps/NMEAWPL.h index 44e081bf7..aaa18933c 100644 --- a/src/gps/NMEAWPL.h +++ b/src/gps/NMEAWPL.h @@ -3,5 +3,5 @@ #include #include "main.h" -uin32_t printWPL(char *buf, const Position &pos, const char *name); -uin32_t printGGA(char *buf, const Position &pos); +uint32_t printWPL(char *buf, const Position &pos, const char *name); +uint32_t printGGA(char *buf, const Position &pos); From 9c0483975c2406a0c13333037a08c62432beb04c Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 15:34:54 -0500 Subject: [PATCH 099/133] Somehow I still missed one :-| --- src/gps/NMEAWPL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gps/NMEAWPL.cpp b/src/gps/NMEAWPL.cpp index 666f9131b..222a2d04c 100644 --- a/src/gps/NMEAWPL.cpp +++ b/src/gps/NMEAWPL.cpp @@ -19,7 +19,7 @@ uint32_t printWPL(char *buf, const Position &pos, const char *name) { uint32_t len = sprintf(buf, "$GNWPL,%07.2f,%c,%08.2f,%c,%s", pos.latitude_i * 1e-5, pos.latitude_i < 0 ? 'S' : 'N', pos.longitude_i * 1e-5, pos.longitude_i < 0 ? 'W' : 'E', name); uint32_t chk = 0; - for (uint i = 1; i < len; i++) { + for (uint32_t i = 1; i < len; i++) { chk ^= buf[i]; } len += sprintf(buf + len, "*%02X\r\n", chk); From d74bcd3583ced44764301a045d133c0ea5f0c68f Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 18:21:35 -0500 Subject: [PATCH 100/133] Portduino build flags --- variants/portduino/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/portduino/platformio.ini b/variants/portduino/platformio.ini index c95ae37fe..016ef61bd 100644 --- a/variants/portduino/platformio.ini +++ b/variants/portduino/platformio.ini @@ -1,6 +1,6 @@ [env:native] platform = https://github.com/meshtastic/platform-native.git -build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino +build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino -E framework = arduino board = cross_platform lib_deps = ${portduino_base.lib_deps} From e1e607cba3f9c30c6f9b7ea31ac727886d7e9143 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 19:09:04 -0500 Subject: [PATCH 101/133] Remove flag --- variants/portduino/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/portduino/platformio.ini b/variants/portduino/platformio.ini index 016ef61bd..c95ae37fe 100644 --- a/variants/portduino/platformio.ini +++ b/variants/portduino/platformio.ini @@ -1,6 +1,6 @@ [env:native] platform = https://github.com/meshtastic/platform-native.git -build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino -E +build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino framework = arduino board = cross_platform lib_deps = ${portduino_base.lib_deps} From 9805319940a2499386a1c84fa6030c9e9f579818 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 21:08:29 -0500 Subject: [PATCH 102/133] Docker is back --- Dockerfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..45aa5df45 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM debian:bullseye-slim +RUN apt-get update +RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install wget python3 g++ zip python3-venv git vim +RUN wget https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py -O get-platformio.py; chmod +x get-platformio.py +RUN python3 get-platformio.py +RUN git clone https://github.com/meshtastic/firmware --recurse-submodules +RUN cd firmware +RUN chmod +x ./firmware/bin/build-native.sh +RUN . ~/.platformio/penv/bin/activate; cd firmware; sh ./bin/build-native.sh + +CMD ["/firmware/release/meshtasticd_linux_amd64"] From 7652253b8d4324ff07eab3276a3d5c8ca100dd9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 6 Nov 2022 10:37:14 +0100 Subject: [PATCH 103/133] optimize BME680 usage --- src/modules/Telemetry/Sensor/BME680Sensor.cpp | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/modules/Telemetry/Sensor/BME680Sensor.cpp b/src/modules/Telemetry/Sensor/BME680Sensor.cpp index 474c376dd..cab388e75 100644 --- a/src/modules/Telemetry/Sensor/BME680Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BME680Sensor.cpp @@ -14,25 +14,28 @@ int32_t BME680Sensor::runOnce() { if (!hasSensor()) { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; } - status = bme680.begin(nodeTelemetrySensorsMap[sensorType]); + status = bme680.begin(nodeTelemetrySensorsMap[sensorType], false); + + // Set up oversampling and filter initialization + bme680.setTemperatureOversampling(BME68X_OS_1X); + bme680.setHumidityOversampling(BME68X_OS_1X); + bme680.setPressureOversampling(BME68X_OS_1X); + bme680.setIIRFilterSize(BME68X_FILTER_OFF); + bme680.setODR(BME68X_ODR_1000_MS); + // BME68X_FORCED_MODE is done in Lib Init already + bme680.setGasHeater(320, 150); // 320*C for 150 ms + return initI2CSensor(); } -void BME680Sensor::setup() -{ - // Set up oversampling and filter initialization - bme680.setTemperatureOversampling(BME680_OS_8X); - bme680.setHumidityOversampling(BME680_OS_2X); - bme680.setPressureOversampling(BME680_OS_4X); - bme680.setIIRFilterSize(BME680_FILTER_SIZE_3); - bme680.setGasHeater(320, 150); // 320*C for 150 ms -} +void BME680Sensor::setup() { } bool BME680Sensor::getMetrics(Telemetry *measurement) { - measurement->variant.environment_metrics.temperature = bme680.readTemperature(); - measurement->variant.environment_metrics.relative_humidity = bme680.readHumidity(); - measurement->variant.environment_metrics.barometric_pressure = bme680.readPressure() / 100.0F; - measurement->variant.environment_metrics.gas_resistance = bme680.readGas() / 1000.0; + bme680.performReading(); + measurement->variant.environment_metrics.temperature = bme680.temperature; + measurement->variant.environment_metrics.relative_humidity = bme680.humidity; + measurement->variant.environment_metrics.barometric_pressure = bme680.pressure / 100.0F; + measurement->variant.environment_metrics.gas_resistance = bme680.gas_resistance / 1000.0; return true; } \ No newline at end of file From 8ab269e1b3f8beeb9292859f2878370b0597f9ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 6 Nov 2022 10:52:54 +0100 Subject: [PATCH 104/133] revert BME680 to default settings, they are working good. Our init was just replicating what's in the lib anyway. --- src/modules/Telemetry/Sensor/BME680Sensor.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/modules/Telemetry/Sensor/BME680Sensor.cpp b/src/modules/Telemetry/Sensor/BME680Sensor.cpp index cab388e75..a9171facf 100644 --- a/src/modules/Telemetry/Sensor/BME680Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BME680Sensor.cpp @@ -14,16 +14,7 @@ int32_t BME680Sensor::runOnce() { if (!hasSensor()) { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; } - status = bme680.begin(nodeTelemetrySensorsMap[sensorType], false); - - // Set up oversampling and filter initialization - bme680.setTemperatureOversampling(BME68X_OS_1X); - bme680.setHumidityOversampling(BME68X_OS_1X); - bme680.setPressureOversampling(BME68X_OS_1X); - bme680.setIIRFilterSize(BME68X_FILTER_OFF); - bme680.setODR(BME68X_ODR_1000_MS); - // BME68X_FORCED_MODE is done in Lib Init already - bme680.setGasHeater(320, 150); // 320*C for 150 ms + status = bme680.begin(nodeTelemetrySensorsMap[sensorType]); return initI2CSensor(); } From 7b378d36cc73e71ec05579035af8ca526ba38e58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 6 Nov 2022 13:29:01 +0100 Subject: [PATCH 105/133] try to make cppcheck happy again --- src/modules/esp32/AudioModule.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/esp32/AudioModule.h b/src/modules/esp32/AudioModule.h index fcd5d169e..b67f83c8b 100644 --- a/src/modules/esp32/AudioModule.h +++ b/src/modules/esp32/AudioModule.h @@ -11,8 +11,6 @@ #include #include #include -#else -typedef int FastAudioFIFO; #endif #define ADC_BUFFER_SIZE 320 // 40ms of voice in 8KHz sampling frequency @@ -20,6 +18,7 @@ typedef int FastAudioFIFO; class AudioModule : public SinglePortModule, private concurrency::OSThread { +#if defined(ARCH_ESP32) && defined(USE_SX1280) bool firstTime = 1; hw_timer_t* adcTimer = NULL; uint16_t adc_buffer[ADC_BUFFER_SIZE]; @@ -62,6 +61,7 @@ class AudioModule : public SinglePortModule, private concurrency::OSThread * @return ProcessMessage::STOP if you've guaranteed you've handled this message and no other handlers should be considered for it */ virtual ProcessMessage handleReceived(const MeshPacket &mp) override; +#endif }; extern AudioModule *audioModule; From 631db56a4467cc5186e39ba7e3f0d7c9c15d24ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 6 Nov 2022 14:32:02 +0100 Subject: [PATCH 106/133] Next try, plus change cppcheck defines back. --- platformio.ini | 4 ++-- src/modules/esp32/AudioModule.cpp | 23 +++++++---------------- src/modules/esp32/AudioModule.h | 12 ++++++------ 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/platformio.ini b/platformio.ini index 7c1ba6851..0021350dd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -59,8 +59,8 @@ lib_deps = check_tool = cppcheck check_skip_packages = yes check_flags = - --common-flag - cppcheck: --enable=--inline-suppr + -DAPP_VERSION=1.0.0 + --suppressions-list=suppressions.txt ; Common settings for conventional (non Portduino) Arduino targets [arduino_base] diff --git a/src/modules/esp32/AudioModule.cpp b/src/modules/esp32/AudioModule.cpp index 9328bdd81..7147db43c 100644 --- a/src/modules/esp32/AudioModule.cpp +++ b/src/modules/esp32/AudioModule.cpp @@ -42,11 +42,11 @@ #define AUDIO_MODULE_MODE 7 // 700B #define AUDIO_MODULE_ACK 1 +#if defined(ARCH_ESP32) && defined(USE_SX1280) + AudioModule *audioModule; -#if defined(ARCH_ESP32) && defined(USE_SX1280) ButterworthFilter hp_filter(240, 8000, ButterworthFilter::ButterworthFilter::Highpass, 1); -#endif //int16_t 1KHz sine test tone int16_t Sine1KHz[8] = { -21210 , -30000, -21210, 0 , 21210 , 30000 , 21210, 0 }; @@ -54,11 +54,12 @@ int Sine1KHz_index = 0; uint8_t rx_raw_audio_value = 127; -AudioModule::AudioModule() : SinglePortModule("AudioModule", PortNum_AUDIO_APP), concurrency::OSThread("AudioModule") {} +AudioModule::AudioModule() : SinglePortModule("AudioModule", PortNum_AUDIO_APP), concurrency::OSThread("AudioModule") { + audio_fifo.init(); +} void AudioModule::run_codec2() { -#if defined(ARCH_ESP32) && defined(USE_SX1280) if (state == State::tx) { for (int i = 0; i < ADC_BUFFER_SIZE; i++) @@ -91,7 +92,6 @@ void AudioModule::run_codec2() } } state = State::standby; -#endif } void AudioModule::handleInterrupt() @@ -101,7 +101,6 @@ void AudioModule::handleInterrupt() void AudioModule::onTimer() { -#if defined(ARCH_ESP32) && defined(USE_SX1280) if (state == State::tx) { adc_buffer[adc_buffer_index++] = (16 * adc1_get_raw(mic_chan)) - 32768; @@ -129,13 +128,10 @@ void AudioModule::onTimer() //Play dacWrite(moduleConfig.audio.amp_pin ? moduleConfig.audio.amp_pin : AAMP, rx_raw_audio_value); } -#endif } int32_t AudioModule::runOnce() { -#if defined(ARCH_ESP32) && defined(USE_SX1280) - if (moduleConfig.audio.codec2_enabled) { if (firstTime) { @@ -198,9 +194,6 @@ int32_t AudioModule::runOnce() return INT32_MAX; } -#else - return INT32_MAX; -#endif } MeshPacket *AudioModule::allocReply() @@ -227,8 +220,6 @@ void AudioModule::sendPayload(NodeNum dest, bool wantReplies) ProcessMessage AudioModule::handleReceived(const MeshPacket &mp) { -#if defined(ARCH_ESP32) && defined(USE_SX1280) - if (moduleConfig.audio.codec2_enabled) { auto &p = mp.decoded; if (getFrom(&mp) != nodeDB.getNodeNum()) { @@ -243,7 +234,7 @@ ProcessMessage AudioModule::handleReceived(const MeshPacket &mp) } } -#endif - return ProcessMessage::CONTINUE; } + +#endif \ No newline at end of file diff --git a/src/modules/esp32/AudioModule.h b/src/modules/esp32/AudioModule.h index b67f83c8b..d82af4d43 100644 --- a/src/modules/esp32/AudioModule.h +++ b/src/modules/esp32/AudioModule.h @@ -21,16 +21,16 @@ class AudioModule : public SinglePortModule, private concurrency::OSThread #if defined(ARCH_ESP32) && defined(USE_SX1280) bool firstTime = 1; hw_timer_t* adcTimer = NULL; - uint16_t adc_buffer[ADC_BUFFER_SIZE]; - int16_t speech[ADC_BUFFER_SIZE]; - int16_t output_buffer[ADC_BUFFER_SIZE]; - unsigned char rx_encode_frame[ENCODE_FRAME_SIZE]; - unsigned char tx_encode_frame[ENCODE_FRAME_SIZE]; + uint16_t adc_buffer[ADC_BUFFER_SIZE] = {}; + int16_t speech[ADC_BUFFER_SIZE] = {}; + int16_t output_buffer[ADC_BUFFER_SIZE] = {}; + unsigned char rx_encode_frame[ENCODE_FRAME_SIZE] = {}; + unsigned char tx_encode_frame[ENCODE_FRAME_SIZE] = {}; int tx_encode_frame_index = 0; FastAudioFIFO audio_fifo; uint16_t adc_buffer_index = 0; adc1_channel_t mic_chan = (adc1_channel_t)0; - struct CODEC2* codec2_state; + struct CODEC2* codec2_state = NULL; enum State { From f1416ac9f779e5713504af7816285e33574bc18c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 6 Nov 2022 14:49:02 +0100 Subject: [PATCH 107/133] Reduce retention to 30 days. --- .github/workflows/main_matrix.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 4736de06e..aacdc72af 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -170,7 +170,7 @@ jobs: path: | release/*.bin release/*.elf - retention-days: 90 + retention-days: 30 build-nrf52: strategy: @@ -229,7 +229,7 @@ jobs: release/*.uf2 release/*.elf release/*.zip - retention-days: 90 + retention-days: 30 build-rpi2040: strategy: @@ -283,7 +283,7 @@ jobs: path: | release/*.uf2 release/*.elf - retention-days: 90 + retention-days: 30 build-native: runs-on: ubuntu-latest @@ -342,7 +342,7 @@ jobs: release/meshtasticd_linux_amd64 release/device-*.sh release/device-*.bat - retention-days: 90 + retention-days: 30 after-checks: runs-on: ubuntu-latest From 9513209b70baa5286917b1791ae3deccb268f81e Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 6 Nov 2022 09:30:46 -0600 Subject: [PATCH 108/133] Alpine --- Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 45aa5df45..01d262ce3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:bullseye-slim +FROM debian:bullseye-slim AS builder RUN apt-get update RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install wget python3 g++ zip python3-venv git vim RUN wget https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py -O get-platformio.py; chmod +x get-platformio.py @@ -8,4 +8,8 @@ RUN cd firmware RUN chmod +x ./firmware/bin/build-native.sh RUN . ~/.platformio/penv/bin/activate; cd firmware; sh ./bin/build-native.sh -CMD ["/firmware/release/meshtasticd_linux_amd64"] +FROM frolvlad/alpine-glibc +WORKDIR /root/ +COPY --from=builder /firmware/release/meshtasticd_linux_amd64 ./ +RUN apk --update add --no-cache g++ +CMD ["./meshtasticd_linux_amd64"] From 26a907444cc18ffb41aba706e5ada39461c8d79c Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 15:10:43 -0500 Subject: [PATCH 109/133] Fix for alpine linux builds --- src/gps/NMEAWPL.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gps/NMEAWPL.h b/src/gps/NMEAWPL.h index 853c850eb..44e081bf7 100644 --- a/src/gps/NMEAWPL.h +++ b/src/gps/NMEAWPL.h @@ -3,5 +3,5 @@ #include #include "main.h" -uint printWPL(char *buf, const Position &pos, const char *name); -uint printGGA(char *buf, const Position &pos); +uin32_t printWPL(char *buf, const Position &pos, const char *name); +uin32_t printGGA(char *buf, const Position &pos); From f9c376a5246ca66ae536821e05519dd75cef61a9 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 15:11:11 -0500 Subject: [PATCH 110/133] Update NMEAWPL.cpp --- src/gps/NMEAWPL.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gps/NMEAWPL.cpp b/src/gps/NMEAWPL.cpp index 95e69343b..d23e78182 100644 --- a/src/gps/NMEAWPL.cpp +++ b/src/gps/NMEAWPL.cpp @@ -15,7 +15,7 @@ * ------------------------------------------- */ -uint printWPL(char *buf, const Position &pos, const char *name) +uint32_t printWPL(char *buf, const Position &pos, const char *name) { uint len = sprintf(buf, "$GNWPL,%07.2f,%c,%08.2f,%c,%s", pos.latitude_i * 1e-5, pos.latitude_i < 0 ? 'S' : 'N', pos.longitude_i * 1e-5, pos.longitude_i < 0 ? 'W' : 'E', name); uint chk = 0; @@ -50,9 +50,9 @@ uint printWPL(char *buf, const Position &pos, const char *name) * ------------------------------------------- */ -uint printGGA(char *buf, const Position &pos) +uint32_t printGGA(char *buf, const Position &pos) { - uint len = sprintf(buf, "$GNGGA,%06u.%03u,%07.2f,%c,%08.2f,%c,%u,%02u,%04u,%04d,%c,%04d,%c,%d,%04d", + uint32_t len = sprintf(buf, "$GNGGA,%06u.%03u,%07.2f,%c,%08.2f,%c,%u,%02u,%04u,%04d,%c,%04d,%c,%d,%04d", pos.time / 1000, pos.time % 1000, pos.latitude_i * 1e-5, pos.latitude_i < 0 ? 'S' : 'N', @@ -67,10 +67,10 @@ uint printGGA(char *buf, const Position &pos) 0, 0); - uint chk = 0; - for (uint i = 1; i < len; i++) { + uint32_t chk = 0; + for (uint32_t i = 1; i < len; i++) { chk ^= buf[i]; } len += sprintf(buf + len, "*%02X\r\n", chk); return len; -} \ No newline at end of file +} From e1ce0375504b25b8a5264f2c52c933f742261408 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 15:14:08 -0500 Subject: [PATCH 111/133] Update NMEAWPL.cpp --- src/gps/NMEAWPL.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gps/NMEAWPL.cpp b/src/gps/NMEAWPL.cpp index d23e78182..666f9131b 100644 --- a/src/gps/NMEAWPL.cpp +++ b/src/gps/NMEAWPL.cpp @@ -17,8 +17,8 @@ uint32_t printWPL(char *buf, const Position &pos, const char *name) { - uint len = sprintf(buf, "$GNWPL,%07.2f,%c,%08.2f,%c,%s", pos.latitude_i * 1e-5, pos.latitude_i < 0 ? 'S' : 'N', pos.longitude_i * 1e-5, pos.longitude_i < 0 ? 'W' : 'E', name); - uint chk = 0; + uint32_t len = sprintf(buf, "$GNWPL,%07.2f,%c,%08.2f,%c,%s", pos.latitude_i * 1e-5, pos.latitude_i < 0 ? 'S' : 'N', pos.longitude_i * 1e-5, pos.longitude_i < 0 ? 'W' : 'E', name); + uint32_t chk = 0; for (uint i = 1; i < len; i++) { chk ^= buf[i]; } From d15edf1955f3d33368c0000e6dd18bad9e5f57bd Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 15:20:09 -0500 Subject: [PATCH 112/133] Update NMEAWPL.h --- src/gps/NMEAWPL.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gps/NMEAWPL.h b/src/gps/NMEAWPL.h index 44e081bf7..aaa18933c 100644 --- a/src/gps/NMEAWPL.h +++ b/src/gps/NMEAWPL.h @@ -3,5 +3,5 @@ #include #include "main.h" -uin32_t printWPL(char *buf, const Position &pos, const char *name); -uin32_t printGGA(char *buf, const Position &pos); +uint32_t printWPL(char *buf, const Position &pos, const char *name); +uint32_t printGGA(char *buf, const Position &pos); From 6694d31d07735ec9091c0929397b65cc630cabfb Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 15:34:54 -0500 Subject: [PATCH 113/133] Somehow I still missed one :-| --- src/gps/NMEAWPL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gps/NMEAWPL.cpp b/src/gps/NMEAWPL.cpp index 666f9131b..222a2d04c 100644 --- a/src/gps/NMEAWPL.cpp +++ b/src/gps/NMEAWPL.cpp @@ -19,7 +19,7 @@ uint32_t printWPL(char *buf, const Position &pos, const char *name) { uint32_t len = sprintf(buf, "$GNWPL,%07.2f,%c,%08.2f,%c,%s", pos.latitude_i * 1e-5, pos.latitude_i < 0 ? 'S' : 'N', pos.longitude_i * 1e-5, pos.longitude_i < 0 ? 'W' : 'E', name); uint32_t chk = 0; - for (uint i = 1; i < len; i++) { + for (uint32_t i = 1; i < len; i++) { chk ^= buf[i]; } len += sprintf(buf + len, "*%02X\r\n", chk); From 3ca6f645d48af15fc5a51e87c1706ffc74914b12 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 18:21:35 -0500 Subject: [PATCH 114/133] Portduino build flags --- variants/portduino/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/portduino/platformio.ini b/variants/portduino/platformio.ini index c95ae37fe..016ef61bd 100644 --- a/variants/portduino/platformio.ini +++ b/variants/portduino/platformio.ini @@ -1,6 +1,6 @@ [env:native] platform = https://github.com/meshtastic/platform-native.git -build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino +build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino -E framework = arduino board = cross_platform lib_deps = ${portduino_base.lib_deps} From 3562d3455574d400efe71b1aca8f706577b6ab5d Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 19:09:04 -0500 Subject: [PATCH 115/133] Remove flag --- variants/portduino/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/portduino/platformio.ini b/variants/portduino/platformio.ini index 016ef61bd..c95ae37fe 100644 --- a/variants/portduino/platformio.ini +++ b/variants/portduino/platformio.ini @@ -1,6 +1,6 @@ [env:native] platform = https://github.com/meshtastic/platform-native.git -build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino -E +build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino framework = arduino board = cross_platform lib_deps = ${portduino_base.lib_deps} From 12fa08007ddcf50cdf3fec7c7ffea651ed5231d6 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 5 Nov 2022 21:08:29 -0500 Subject: [PATCH 116/133] Docker is back --- Dockerfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..45aa5df45 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM debian:bullseye-slim +RUN apt-get update +RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install wget python3 g++ zip python3-venv git vim +RUN wget https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py -O get-platformio.py; chmod +x get-platformio.py +RUN python3 get-platformio.py +RUN git clone https://github.com/meshtastic/firmware --recurse-submodules +RUN cd firmware +RUN chmod +x ./firmware/bin/build-native.sh +RUN . ~/.platformio/penv/bin/activate; cd firmware; sh ./bin/build-native.sh + +CMD ["/firmware/release/meshtasticd_linux_amd64"] From 057109dcac8f8d9b710aabe052dc8c551dc74cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 6 Nov 2022 14:49:02 +0100 Subject: [PATCH 117/133] Reduce retention to 30 days. --- .github/workflows/main_matrix.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 4736de06e..aacdc72af 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -170,7 +170,7 @@ jobs: path: | release/*.bin release/*.elf - retention-days: 90 + retention-days: 30 build-nrf52: strategy: @@ -229,7 +229,7 @@ jobs: release/*.uf2 release/*.elf release/*.zip - retention-days: 90 + retention-days: 30 build-rpi2040: strategy: @@ -283,7 +283,7 @@ jobs: path: | release/*.uf2 release/*.elf - retention-days: 90 + retention-days: 30 build-native: runs-on: ubuntu-latest @@ -342,7 +342,7 @@ jobs: release/meshtasticd_linux_amd64 release/device-*.sh release/device-*.bat - retention-days: 90 + retention-days: 30 after-checks: runs-on: ubuntu-latest From 3492d641773412bf235d2a28c1d7d34edb3aaa6b Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 6 Nov 2022 09:30:46 -0600 Subject: [PATCH 118/133] Alpine --- Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 45aa5df45..01d262ce3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:bullseye-slim +FROM debian:bullseye-slim AS builder RUN apt-get update RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install wget python3 g++ zip python3-venv git vim RUN wget https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py -O get-platformio.py; chmod +x get-platformio.py @@ -8,4 +8,8 @@ RUN cd firmware RUN chmod +x ./firmware/bin/build-native.sh RUN . ~/.platformio/penv/bin/activate; cd firmware; sh ./bin/build-native.sh -CMD ["/firmware/release/meshtasticd_linux_amd64"] +FROM frolvlad/alpine-glibc +WORKDIR /root/ +COPY --from=builder /firmware/release/meshtasticd_linux_amd64 ./ +RUN apk --update add --no-cache g++ +CMD ["./meshtasticd_linux_amd64"] From 6934e0bce7a18fb087e54c8f443ef14f04c5d300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 6 Nov 2022 18:36:17 +0100 Subject: [PATCH 119/133] Fix assert --- src/mesh/RadioLibInterface.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index 262a10c18..c08220555 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -317,7 +317,13 @@ ErrorCode RadioLibInterface::send(MeshPacket *p) void RadioLibInterface::handleReceiveInterrupt() { uint32_t xmitMsec; - assert(isReceiving); + + // when this is called, we should be in receive mode - if we are not, just jump out instead of bombing. Possible Race Condition? + if (!isReceiving) { + DEBUG_MSG("*** WAS_ASSERT *** handleReceiveInterrupt called when not in receive mode\n"); + return; + } + isReceiving = false; // read the number of actually received bytes From 0832cc50a89d03f06e5bf223989b4c62913d5d57 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 6 Nov 2022 13:19:49 -0600 Subject: [PATCH 120/133] Add a docker-compose --- docker-compose.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..28b8c2ebd --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,5 @@ +version: "3.7" + +services: + meshtastic-device: + build: . From f0f5107a5dbab4745f8f1e64df2a76f6bd9e355e Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 6 Nov 2022 19:22:20 -0600 Subject: [PATCH 121/133] Added docker compose 4 nodes example --- docker-compose.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 28b8c2ebd..ea1e01a85 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,23 @@ version: "3.7" services: - meshtastic-device: + meshtastic-node-1: build: . + command: ["./meshtasticd_linux_amd64", "--hwid", "12:2E:9C:CF:65:7C"] + ports: + - 4403:4403 + meshtastic-node-2: + build: . + command: ["./meshtasticd_linux_amd64", "--hwid", "93:DD:85:BB:36:54"] + ports: + - 4404:4403 + meshtastic-node-3: + build: . + command: ["./meshtasticd_linux_amd64", "--hwid", "05:97:96:0A:0B:B4"] + ports: + - 4405:4403 + meshtastic-node-4: + build: . + command: ["./meshtasticd_linux_amd64", "--hwid", "07:67:32:9D:84:00"] + ports: + - 4406:4403 From b13eaee6b3501da771ed1cb7aee90da72f3e168a Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 7 Nov 2022 13:28:37 -0600 Subject: [PATCH 122/133] More fun --- Dockerfile | 5 +++-- docker-compose.yml | 28 +++++++++------------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index 01d262ce3..20460b175 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,5 +11,6 @@ RUN . ~/.platformio/penv/bin/activate; cd firmware; sh ./bin/build-native.sh FROM frolvlad/alpine-glibc WORKDIR /root/ COPY --from=builder /firmware/release/meshtasticd_linux_amd64 ./ -RUN apk --update add --no-cache g++ -CMD ["./meshtasticd_linux_amd64"] +RUN apk --update add --no-cache g++ && \ + apk add openssl +CMD sh -cx "./meshtasticd_linux_amd64 --hwid '$RANDOM'" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index ea1e01a85..f137139c2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,23 +1,13 @@ version: "3.7" services: - meshtastic-node-1: + meshtastic-node: build: . - command: ["./meshtasticd_linux_amd64", "--hwid", "12:2E:9C:CF:65:7C"] - ports: - - 4403:4403 - meshtastic-node-2: - build: . - command: ["./meshtasticd_linux_amd64", "--hwid", "93:DD:85:BB:36:54"] - ports: - - 4404:4403 - meshtastic-node-3: - build: . - command: ["./meshtasticd_linux_amd64", "--hwid", "05:97:96:0A:0B:B4"] - ports: - - 4405:4403 - meshtastic-node-4: - build: . - command: ["./meshtasticd_linux_amd64", "--hwid", "07:67:32:9D:84:00"] - ports: - - 4406:4403 + deploy: + mode: replicated + replicas: 80 + networks: + - mesh + +networks: + mesh: \ No newline at end of file From e122232761826a096e9dc68f479edc74019245fe Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 7 Nov 2022 13:29:34 -0600 Subject: [PATCH 123/133] Removed defunct line --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 20460b175..0ce4e3326 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,5 @@ RUN . ~/.platformio/penv/bin/activate; cd firmware; sh ./bin/build-native.sh FROM frolvlad/alpine-glibc WORKDIR /root/ COPY --from=builder /firmware/release/meshtasticd_linux_amd64 ./ -RUN apk --update add --no-cache g++ && \ - apk add openssl +RUN apk --update add --no-cache g++ CMD sh -cx "./meshtasticd_linux_amd64 --hwid '$RANDOM'" \ No newline at end of file From 2331226bb659319a4b44f404e64d073730a998e3 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 8 Nov 2022 07:27:48 -0600 Subject: [PATCH 124/133] Bump version --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 7d6851090..da0d02a6d 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 0 -build = 0 +build = 1 From 9f9bd40343383426c3455d7723f3ded399ec6d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Tue, 8 Nov 2022 21:53:44 +0100 Subject: [PATCH 125/133] rename wifi_mode to eth_mode --- src/mesh/http/WiFiAPClient.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mesh/http/WiFiAPClient.cpp b/src/mesh/http/WiFiAPClient.cpp index 6caad79c0..09f5acf48 100644 --- a/src/mesh/http/WiFiAPClient.cpp +++ b/src/mesh/http/WiFiAPClient.cpp @@ -171,8 +171,12 @@ bool initWifi() WiFi.onEvent(WiFiEvent); WiFi.setAutoReconnect(true); WiFi.setSleep(false); - if (config.network.wifi_mode == Config_NetworkConfig_EthMode_STATIC && config.network.ipv4_config.ip != 0) { - WiFi.config(config.network.ipv4_config.ip,config.network.ipv4_config.gateway,config.network.ipv4_config.subnet,config.network.ipv4_config.dns,config.network.ipv4_config.dns); + if (config.network.eth_mode == Config_NetworkConfig_EthMode_STATIC && config.network.ipv4_config.ip != 0) { + WiFi.config(config.network.ipv4_config.ip, + config.network.ipv4_config.gateway, + config.network.ipv4_config.subnet, + config.network.ipv4_config.dns, + config.network.ipv4_config.dns); // Wifi wants two DNS servers... set both to the same value } // This is needed to improve performance. From 32223a818cfaa17e8461cbee873006810ea56253 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 8 Nov 2022 15:04:24 -0600 Subject: [PATCH 126/133] Updated admin module and protobufs --- protobufs | 2 +- src/mesh/PhoneAPI.cpp | 6 +++++- src/mesh/generated/config.pb.h | 11 ++++------- src/mesh/generated/localonly.pb.h | 2 +- src/modules/AdminModule.cpp | 10 ++++++++++ 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/protobufs b/protobufs index 2954e5b02..c82c15aac 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 2954e5b0228c85902c841bfb0f18add43980a2e2 +Subproject commit c82c15aac71b9134d96c03dbe319916739cc8314 diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index 2f060889a..ea08bf769 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -249,11 +249,15 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) fromRadioScratch.moduleConfig.which_payload_variant = ModuleConfig_canned_message_tag; fromRadioScratch.moduleConfig.payload_variant.canned_message = moduleConfig.canned_message; break; + case ModuleConfig_audio_tag: + fromRadioScratch.moduleConfig.which_payload_variant = ModuleConfig_audio_tag; + fromRadioScratch.moduleConfig.payload_variant.audio = moduleConfig.audio; + break; } config_state++; // Advance when we have sent all of our ModuleConfig objects - if (config_state > ModuleConfig_canned_message_tag) { + if (config_state > ModuleConfig_audio_tag) { state = STATE_SEND_COMPLETE_ID; config_state = 0; } diff --git a/src/mesh/generated/config.pb.h b/src/mesh/generated/config.pb.h index a9005ddcd..9748383cb 100644 --- a/src/mesh/generated/config.pb.h +++ b/src/mesh/generated/config.pb.h @@ -158,7 +158,6 @@ typedef struct _Config_PowerConfig { typedef struct _Config_NetworkConfig { bool wifi_enabled; - Config_NetworkConfig_EthMode wifi_mode; char wifi_ssid[33]; char wifi_psk[64]; char ntp_server[33]; @@ -229,7 +228,7 @@ extern "C" { #define Config_DeviceConfig_init_default {_Config_DeviceConfig_Role_MIN, 0, 0} #define Config_PositionConfig_init_default {0, 0, 0, 0, 0, 0, 0} #define Config_PowerConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0} -#define Config_NetworkConfig_init_default {0, _Config_NetworkConfig_EthMode_MIN, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_default} +#define Config_NetworkConfig_init_default {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_default} #define Config_NetworkConfig_IpV4Config_init_default {0, 0, 0, 0} #define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN} #define Config_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}} @@ -238,7 +237,7 @@ extern "C" { #define Config_DeviceConfig_init_zero {_Config_DeviceConfig_Role_MIN, 0, 0} #define Config_PositionConfig_init_zero {0, 0, 0, 0, 0, 0, 0} #define Config_PowerConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0} -#define Config_NetworkConfig_init_zero {0, _Config_NetworkConfig_EthMode_MIN, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_zero} +#define Config_NetworkConfig_init_zero {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_zero} #define Config_NetworkConfig_IpV4Config_init_zero {0, 0, 0, 0} #define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN} #define Config_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}} @@ -290,7 +289,6 @@ extern "C" { #define Config_PowerConfig_ls_secs_tag 7 #define Config_PowerConfig_min_wake_secs_tag 8 #define Config_NetworkConfig_wifi_enabled_tag 1 -#define Config_NetworkConfig_wifi_mode_tag 2 #define Config_NetworkConfig_wifi_ssid_tag 3 #define Config_NetworkConfig_wifi_psk_tag 4 #define Config_NetworkConfig_ntp_server_tag 5 @@ -356,7 +354,6 @@ X(a, STATIC, SINGULAR, UINT32, min_wake_secs, 8) #define Config_NetworkConfig_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, BOOL, wifi_enabled, 1) \ -X(a, STATIC, SINGULAR, UENUM, wifi_mode, 2) \ X(a, STATIC, SINGULAR, STRING, wifi_ssid, 3) \ X(a, STATIC, SINGULAR, STRING, wifi_psk, 4) \ X(a, STATIC, SINGULAR, STRING, ntp_server, 5) \ @@ -436,10 +433,10 @@ extern const pb_msgdesc_t Config_BluetoothConfig_msg; #define Config_DisplayConfig_size 22 #define Config_LoRaConfig_size 68 #define Config_NetworkConfig_IpV4Config_size 20 -#define Config_NetworkConfig_size 163 +#define Config_NetworkConfig_size 161 #define Config_PositionConfig_size 30 #define Config_PowerConfig_size 43 -#define Config_size 166 +#define Config_size 164 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/localonly.pb.h b/src/mesh/generated/localonly.pb.h index a69aefc10..783c523c7 100644 --- a/src/mesh/generated/localonly.pb.h +++ b/src/mesh/generated/localonly.pb.h @@ -150,7 +150,7 @@ extern const pb_msgdesc_t LocalModuleConfig_msg; #define LocalModuleConfig_fields &LocalModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define LocalConfig_size 363 +#define LocalConfig_size 361 #define LocalModuleConfig_size 294 #ifdef __cplusplus diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 16ce47cec..4a76faf6f 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -295,6 +295,11 @@ void AdminModule::handleSetModuleConfig(const ModuleConfig &c) moduleConfig.has_canned_message = true; moduleConfig.canned_message = c.payload_variant.canned_message; break; + case ModuleConfig_audio_tag: + DEBUG_MSG("Setting module config: Audio\n"); + moduleConfig.has_audio = true; + moduleConfig.audio = c.payload_variant.audio; + break; } service.reloadConfig(SEGMENT_MODULECONFIG); @@ -421,6 +426,11 @@ void AdminModule::handleGetModuleConfig(const MeshPacket &req, const uint32_t co res.get_module_config_response.which_payload_variant = ModuleConfig_canned_message_tag; res.get_module_config_response.payload_variant.canned_message = moduleConfig.canned_message; break; + case AdminMessage_ModuleConfigType_AUDIO_CONFIG: + DEBUG_MSG("Getting module config: Audio\n"); + res.get_module_config_response.which_payload_variant = ModuleConfig_audio_tag; + res.get_module_config_response.payload_variant.audio = moduleConfig.audio; + break; } // NOTE: The phone app needs to know the ls_secsvalue so it can properly expect sleep behavior. From 7a3ad0afba25970d5bebba949e243d49ba7fbfdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Tue, 8 Nov 2022 22:32:53 +0100 Subject: [PATCH 127/133] fix #1916 --- src/mqtt/MQTT.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index e77e82e54..194683939 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -69,22 +69,25 @@ void MQTT::onPublish(char *topic, byte *payload, unsigned int length) DEBUG_MSG("Invalid MQTT service envelope, topic %s, len %u!\n", topic, length); } } else { - pb_decode_from_bytes(payload, length, ServiceEnvelope_fields, &e); - if (strcmp(e.gateway_id, owner.id) == 0) - DEBUG_MSG("Ignoring downlink message we originally sent.\n"); - else { - if (e.packet) { - DEBUG_MSG("Received MQTT topic %s, len=%u\n", topic, length); - MeshPacket *p = packetPool.allocCopy(*e.packet); + if (!pb_decode_from_bytes(payload, length, ServiceEnvelope_fields, &e)) { + DEBUG_MSG("Invalid MQTT service envelope, topic %s, len %u!\n", topic, length); + return; + }else { + if (strcmp(e.gateway_id, owner.id) == 0) + DEBUG_MSG("Ignoring downlink message we originally sent.\n"); + else { + if (e.packet) { + DEBUG_MSG("Received MQTT topic %s, len=%u\n", topic, length); + MeshPacket *p = packetPool.allocCopy(*e.packet); - // ignore messages sent by us or if we don't have the channel key - if (router && p->from != nodeDB.getNodeNum() && perhapsDecode(p)) - router->enqueueReceivedMessage(p); - else - packetPool.release(p); + // ignore messages sent by us or if we don't have the channel key + if (router && p->from != nodeDB.getNodeNum() && perhapsDecode(p)) + router->enqueueReceivedMessage(p); + else + packetPool.release(p); + } } } - // make sure to free both strings and the MeshPacket (passing in NULL is acceptable) free(e.channel_id); free(e.gateway_id); From 728fc8cbad46ef1e0c1836c7b792499e3e13a3dd Mon Sep 17 00:00:00 2001 From: thebentern Date: Tue, 8 Nov 2022 22:51:44 +0000 Subject: [PATCH 128/133] [create-pull-request] automated change --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index da0d02a6d..6f548b7bd 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 0 -build = 1 +build = 2 From cb283f4c5754bbb7af67b211aad71a28f9e4b75c Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 9 Nov 2022 07:14:08 -0600 Subject: [PATCH 129/133] Build cleanup and update deprecated platformio cmd --- bin/build-all.sh.legacy | 109 ---------------------------------------- bin/build-esp32.sh | 2 +- bin/build-native.sh | 2 +- bin/build-nrf52.sh | 2 +- bin/build-rpi2040.sh | 2 +- 5 files changed, 4 insertions(+), 113 deletions(-) delete mode 100755 bin/build-all.sh.legacy diff --git a/bin/build-all.sh.legacy b/bin/build-all.sh.legacy deleted file mode 100755 index 55c151da1..000000000 --- a/bin/build-all.sh.legacy +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env bash - -set -e - -VERSION=`bin/buildinfo.py long` -SHORT_VERSION=`bin/buildinfo.py short` - -BOARDS_ESP32="rak11200 tlora-v2 tlora-v1 tlora_v1_3 tlora-v2-1-1.6 tbeam heltec-v1 heltec-v2.0 heltec-v2.1 tbeam0.7 meshtastic-diy-v1 nano-g1 station-g1 m5stack-core m5stack-coreink" -#BOARDS_ESP32=tbeam - -# FIXME note nrf52840dk build is for some reason only generating a BIN file but not a HEX file nrf52840dk-geeksville is fine -BOARDS_NRF52="rak4631 rak4631_eink t-echo pca10059_diy_eink" -#BOARDS_NRF52="" - -OUTDIR=release/latest - -# We keep all old builds (and their map files in the archive dir) -ARCHIVEDIR=release/archive - -rm -f $OUTDIR/firmware* - -mkdir -p $OUTDIR/bins $ARCHIVEDIR -rm -r $OUTDIR/bins/* || true -mkdir -p $OUTDIR/bins/universal $OUTDIR/elfs/universal - -# build the named environment and copy the bins to the release directory -function do_build() { - BOARD=$1 - isNrf=$3 - - echo "Building for $BOARD ($isNrf) with $PLATFORMIO_BUILD_FLAGS" - rm -f .pio/build/$BOARD/firmware.* - - # The shell vars the build tool expects to find - export APP_VERSION=$VERSION - - basename=universal/firmware-$BOARD-$VERSION - - pio run --environment $BOARD # -v - SRCELF=.pio/build/$BOARD/firmware.elf - cp $SRCELF $OUTDIR/elfs/$basename.elf - - if [ "$isNrf" = "false" ] - then - echo "Copying ESP32 bin file" - SRCBIN=.pio/build/$BOARD/firmware.bin - cp $SRCBIN $OUTDIR/bins/$basename.bin - else - echo "Generating NRF52 uf2 file" - SRCHEX=.pio/build/$BOARD/firmware.hex - bin/uf2conv.py $SRCHEX -c -o $OUTDIR/bins/$basename.uf2 -f 0xADA52840 - fi -} - -function do_boards() { - declare boards=$1 - declare isNrf=$2 - for board in $boards; do - # Build universal - echo "about to build $board $isNrf" - do_build $board "" "$isNrf" - done -} - -# Make sure our submodules are current -git submodule update - -# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale -platformio lib update - -do_boards "$BOARDS_ESP32" "false" -do_boards "$BOARDS_NRF52" "true" - -pio run --environment native -cp .pio/build/native/program $OUTDIR/bins/universal/meshtasticd_linux_amd64 - -echo "Building Filesystem for ESP32 targets" -pio run --environment tbeam -t buildfs -cp .pio/build/tbeam/spiffs.bin $OUTDIR/bins/universal/littlefs-$VERSION.bin - -# keep the bins in archive also -cp $OUTDIR/bins/universal/littlefs* $OUTDIR/bins/universal/firmware* $OUTDIR/elfs/universal/firmware* $ARCHIVEDIR - -echo Updating android bins $OUTDIR/forandroid -rm -rf $OUTDIR/forandroid -mkdir -p $OUTDIR/forandroid -cp -a $OUTDIR/bins/universal/*.bin $OUTDIR/forandroid/ - -cat >$OUTDIR/curfirmwareversion.xml < - - - - - $VERSION - $SHORT_VERSION - -XML - -echo Generating $ARCHIVEDIR/firmware-$VERSION.zip -rm -f $ARCHIVEDIR/firmware-$VERSION.zip -zip --junk-paths $ARCHIVEDIR/firmware-$VERSION.zip $ARCHIVEDIR/littlefs-$VERSION.bin $OUTDIR/bins/universal/firmware-*-$VERSION.* $OUTDIR/bins/universal/meshtasticd* images/system-info.bin bin/device-install.* bin/device-update.* -echo Generating $ARCHIVEDIR/elfs-$VERSION.zip -rm -f $ARCHIVEDIR/elfs-$VERSION.zip -zip --junk-paths $ARCHIVEDIR/elfs-$VERSION.zip $OUTDIR/elfs/universal/firmware-*-$VERSION.* - -echo BUILT ALL diff --git a/bin/build-esp32.sh b/bin/build-esp32.sh index 40a6c3aee..12961864f 100755 --- a/bin/build-esp32.sh +++ b/bin/build-esp32.sh @@ -14,7 +14,7 @@ rm -r $OUTDIR/* || true git submodule update # Important to pull latest version of libs into all device flavors, otherwise some devices might be stale -platformio lib update +platformio pkg update echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS" rm -f .pio/build/$1/firmware.* diff --git a/bin/build-native.sh b/bin/build-native.sh index 31ef01155..b620a01d8 100755 --- a/bin/build-native.sh +++ b/bin/build-native.sh @@ -16,7 +16,7 @@ rm -r $OUTDIR/* || true git submodule update # Important to pull latest version of libs into all device flavors, otherwise some devices might be stale -platformio lib update +platformio pkg update pio run --environment native cp .pio/build/native/program $OUTDIR/meshtasticd_linux_amd64 diff --git a/bin/build-nrf52.sh b/bin/build-nrf52.sh index 76972b100..6c723e28f 100755 --- a/bin/build-nrf52.sh +++ b/bin/build-nrf52.sh @@ -14,7 +14,7 @@ rm -r $OUTDIR/* || true git submodule update # Important to pull latest version of libs into all device flavors, otherwise some devices might be stale -platformio lib update +platformio pkg update echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS" rm -f .pio/build/$1/firmware.* diff --git a/bin/build-rpi2040.sh b/bin/build-rpi2040.sh index 04fe7106b..670f570f1 100755 --- a/bin/build-rpi2040.sh +++ b/bin/build-rpi2040.sh @@ -14,7 +14,7 @@ rm -r $OUTDIR/* || true git submodule update # Important to pull latest version of libs into all device flavors, otherwise some devices might be stale -platformio lib update +platformio pkg update echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS" rm -f .pio/build/$1/firmware.* From d77bc239c17c7cba08143b532cf37ab10461517c Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 9 Nov 2022 07:20:53 -0600 Subject: [PATCH 130/133] Changed retention policy --- .github/workflows/main_matrix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index aacdc72af..62a2477bf 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -410,7 +410,7 @@ jobs: with: name: debug-elfs-${{ steps.version.outputs.version }}.zip path: ./*.elf - retention-days: 90 + retention-days: 30 - name: Create request artifacts if: ${{ github.event_name == 'pull_request_target' || github.event_name == 'pull_request' }} From 1213ec2d5794af4682c117ab723f2460411b7c26 Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Wed, 9 Nov 2022 21:21:50 +0100 Subject: [PATCH 131/133] Set preamble length back to 32 --- src/mesh/RadioInterface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/RadioInterface.h b/src/mesh/RadioInterface.h index 8570d7b39..e9f725c89 100644 --- a/src/mesh/RadioInterface.h +++ b/src/mesh/RadioInterface.h @@ -65,7 +65,7 @@ class RadioInterface - Tx/Rx turnaround time (maximum of SX126x and SX127x); - MAC processing time (measured on T-beam) */ uint32_t slotTimeMsec = 8.5 * pow(2, sf)/bw + 0.2 + 0.4 + 7; - uint16_t preambleLength = 8; // 8 is default + uint16_t preambleLength = 32; // 8 is default, but we use longer to increase the amount of sleep time when receiving const uint32_t PROCESSING_TIME_MSEC = 4500; // time to construct, process and construct a packet again (empirically determined) const uint8_t CWmin = 2; // minimum CWsize const uint8_t CWmax = 8; // maximum CWsize From 2247e71a52c5ae5f1b53ea1bd71c6ab14c857dca Mon Sep 17 00:00:00 2001 From: thebentern Date: Wed, 9 Nov 2022 21:39:27 +0000 Subject: [PATCH 132/133] [create-pull-request] automated change --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 6f548b7bd..303bb9783 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 0 -build = 2 +build = 3 From 30a87e31457f9bf80ab2c842c303b50f8b766c23 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 10 Nov 2022 07:26:28 -0600 Subject: [PATCH 133/133] Switch to a smaller sample of devices for cppcheck --- .github/workflows/main_matrix.yml | 9 --------- protobufs | 2 +- src/mesh/generated/mesh.pb.h | 4 ++-- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 62a2477bf..15a372f29 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -23,26 +23,17 @@ jobs: matrix: include: - board: rak11200 - - board: tlora-v2 - board: tlora-v1 - - board: tlora_v1_3 - board: tlora-v2-1-1.6 - board: tbeam - - board: heltec-v1 - - board: heltec-v2.0 - board: heltec-v2.1 - - board: tbeam0.7 - board: meshtastic-diy-v1 - - board: meshtastic-dr-dev - board: rak4631 - - board: rak4631_eink - board: t-echo - board: nano-g1 - board: station-g1 - - board: m5stack-core - board: m5stack-coreink - board: tbeam-s3-core - - board: feather_diy # - board: pico runs-on: ubuntu-latest diff --git a/protobufs b/protobufs index c82c15aac..5b892e4c1 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit c82c15aac71b9134d96c03dbe319916739cc8314 +Subproject commit 5b892e4c196f8620f2009cdef219eb2c237cc636 diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index c1c2bdd7b..8e73a0972 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -501,7 +501,7 @@ typedef PB_BYTES_ARRAY_T(256) MeshPacket_encrypted_t; typedef struct _MeshPacket { /* The sending node number. Note: Our crypto implementation uses this field as well. - See [crypto](/docs/about/overview/encryption) for details. + See [crypto](/docs/overview/encryption) for details. FIXME - really should be fixed32 instead, this encoding only hurts the ble link though. */ uint32_t from; /* The (immediatSee Priority description for more details.y should be fixed32 instead, this encoding only @@ -529,7 +529,7 @@ typedef struct _MeshPacket { needs to be unique for a few minutes (long enough to last for the length of any ACK or the completion of a mesh broadcast flood). Note: Our crypto implementation uses this id as well. - See [crypto](/docs/about/overview/encryption) for details. + See [crypto](/docs/overview/encryption) for details. FIXME - really should be fixed32 instead, this encoding only hurts the ble link though. */ uint32_t id;