From 21311bbeda61ec7ca9f052fdad37757727ef3707 Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Tue, 30 Apr 2024 01:54:57 +1200 Subject: [PATCH 01/18] T-Echo touch button no longer requires "wake on tap or motion" (#3745) --- src/ButtonThread.cpp | 14 ++++++-------- src/mesh/NodeDB.cpp | 3 --- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/ButtonThread.cpp b/src/ButtonThread.cpp index e9717521a..4566de924 100644 --- a/src/ButtonThread.cpp +++ b/src/ButtonThread.cpp @@ -196,15 +196,13 @@ int32_t ButtonThread::runOnce() #ifdef BUTTON_PIN_TOUCH case BUTTON_EVENT_TOUCH_LONG_PRESSED: { LOG_BUTTON("Touch press!\n"); - if (config.display.wake_on_tap_or_motion) { - if (screen) { - // Wake if asleep - if (powerFSM.getState() == &stateDARK) - powerFSM.trigger(EVENT_PRESS); + if (screen) { + // Wake if asleep + if (powerFSM.getState() == &stateDARK) + powerFSM.trigger(EVENT_PRESS); - // Update display (legacy behaviour) - screen->forceDisplay(); - } + // Update display (legacy behaviour) + screen->forceDisplay(); } break; } diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 39422b454..249db627e 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -352,9 +352,6 @@ void NodeDB::installDefaultModuleConfig() moduleConfig.external_notification.alert_message = true; moduleConfig.external_notification.output_ms = 100; moduleConfig.external_notification.active = true; -#endif -#ifdef TTGO_T_ECHO - config.display.wake_on_tap_or_motion = true; // Enable touch button for screen-on / refresh #endif moduleConfig.has_canned_message = true; From e51ee91c39903bc13e14f06fe4743d755f834580 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Wed, 1 May 2024 03:07:15 +0200 Subject: [PATCH 02/18] Optimization: stop relaying when reply is received (#3753) --- src/mesh/FloodingRouter.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/mesh/FloodingRouter.cpp b/src/mesh/FloodingRouter.cpp index 4cfe982d8..dd547a6f1 100644 --- a/src/mesh/FloodingRouter.cpp +++ b/src/mesh/FloodingRouter.cpp @@ -35,11 +35,10 @@ bool FloodingRouter::shouldFilterReceived(const meshtastic_MeshPacket *p) void FloodingRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Routing *c) { - bool isAck = - ((c && c->error_reason == meshtastic_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 - LOG_DEBUG("Receiving an ACK not for me, but don't need to rebroadcast this direct message anymore.\n"); + bool isAckorReply = (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) && (p->decoded.request_id != 0); + if (isAckorReply && p->to != getNodeNum() && p->to != NODENUM_BROADCAST) { + // do not flood direct message that is ACKed or replied to + LOG_DEBUG("Receiving an ACK or reply 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 } if ((p->to != getNodeNum()) && (p->hop_limit > 0) && (getFrom(p) != getNodeNum())) { From 3619ac87b8a78205d16de856f711abb49d83fa96 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 30 Apr 2024 20:14:38 -0500 Subject: [PATCH 03/18] [create-pull-request] automated change (#3754) Co-authored-by: thebentern --- protobufs | 2 +- src/mesh/generated/meshtastic/apponly.pb.h | 2 +- src/mesh/generated/meshtastic/channel.pb.h | 17 +++++++++++------ src/mesh/generated/meshtastic/deviceonly.pb.h | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/protobufs b/protobufs index 86640f20d..e21899aa6 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 86640f20db7b9b5be42949d18e8d96ad10d47a68 +Subproject commit e21899aa6b2b49863cfa2758e5e3b6faacf04bba diff --git a/src/mesh/generated/meshtastic/apponly.pb.h b/src/mesh/generated/meshtastic/apponly.pb.h index 54629f522..ba9f90873 100644 --- a/src/mesh/generated/meshtastic/apponly.pb.h +++ b/src/mesh/generated/meshtastic/apponly.pb.h @@ -55,7 +55,7 @@ extern const pb_msgdesc_t meshtastic_ChannelSet_msg; /* Maximum encoded size of messages (where known) */ #define MESHTASTIC_MESHTASTIC_APPONLY_PB_H_MAX_SIZE meshtastic_ChannelSet_size -#define meshtastic_ChannelSet_size 658 +#define meshtastic_ChannelSet_size 674 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/meshtastic/channel.pb.h b/src/mesh/generated/meshtastic/channel.pb.h index 185a47a98..d9c7d4ffa 100644 --- a/src/mesh/generated/meshtastic/channel.pb.h +++ b/src/mesh/generated/meshtastic/channel.pb.h @@ -34,6 +34,9 @@ typedef enum _meshtastic_Channel_Role { typedef struct _meshtastic_ModuleSettings { /* Bits of precision for the location sent in position packets. */ uint32_t position_precision; + /* Controls whether or not the phone / clients should mute the current channel + Useful for noisy public channels you don't necessarily want to disable */ + bool is_client_muted; } meshtastic_ModuleSettings; typedef PB_BYTES_ARRAY_T(32) meshtastic_ChannelSettings_psk_t; @@ -126,14 +129,15 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_ChannelSettings_init_default {0, {0, {0}}, "", 0, 0, 0, false, meshtastic_ModuleSettings_init_default} -#define meshtastic_ModuleSettings_init_default {0} +#define meshtastic_ModuleSettings_init_default {0, 0} #define meshtastic_Channel_init_default {0, false, meshtastic_ChannelSettings_init_default, _meshtastic_Channel_Role_MIN} #define meshtastic_ChannelSettings_init_zero {0, {0, {0}}, "", 0, 0, 0, false, meshtastic_ModuleSettings_init_zero} -#define meshtastic_ModuleSettings_init_zero {0} +#define meshtastic_ModuleSettings_init_zero {0, 0} #define meshtastic_Channel_init_zero {0, false, meshtastic_ChannelSettings_init_zero, _meshtastic_Channel_Role_MIN} /* Field tags (for use in manual encoding/decoding) */ #define meshtastic_ModuleSettings_position_precision_tag 1 +#define meshtastic_ModuleSettings_is_client_muted_tag 2 #define meshtastic_ChannelSettings_channel_num_tag 1 #define meshtastic_ChannelSettings_psk_tag 2 #define meshtastic_ChannelSettings_name_tag 3 @@ -159,7 +163,8 @@ X(a, STATIC, OPTIONAL, MESSAGE, module_settings, 7) #define meshtastic_ChannelSettings_module_settings_MSGTYPE meshtastic_ModuleSettings #define meshtastic_ModuleSettings_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, position_precision, 1) +X(a, STATIC, SINGULAR, UINT32, position_precision, 1) \ +X(a, STATIC, SINGULAR, BOOL, is_client_muted, 2) #define meshtastic_ModuleSettings_CALLBACK NULL #define meshtastic_ModuleSettings_DEFAULT NULL @@ -182,9 +187,9 @@ extern const pb_msgdesc_t meshtastic_Channel_msg; /* Maximum encoded size of messages (where known) */ #define MESHTASTIC_MESHTASTIC_CHANNEL_PB_H_MAX_SIZE meshtastic_Channel_size -#define meshtastic_ChannelSettings_size 70 -#define meshtastic_Channel_size 85 -#define meshtastic_ModuleSettings_size 6 +#define meshtastic_ChannelSettings_size 72 +#define meshtastic_Channel_size 87 +#define meshtastic_ModuleSettings_size 8 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/meshtastic/deviceonly.pb.h b/src/mesh/generated/meshtastic/deviceonly.pb.h index 2506ec647..b8cc80633 100644 --- a/src/mesh/generated/meshtastic/deviceonly.pb.h +++ b/src/mesh/generated/meshtastic/deviceonly.pb.h @@ -306,7 +306,7 @@ extern const pb_msgdesc_t meshtastic_OEMStore_msg; /* Maximum encoded size of messages (where known) */ /* meshtastic_DeviceState_size depends on runtime parameters */ #define MESHTASTIC_MESHTASTIC_DEVICEONLY_PB_H_MAX_SIZE meshtastic_OEMStore_size -#define meshtastic_ChannelFile_size 702 +#define meshtastic_ChannelFile_size 718 #define meshtastic_NodeInfoLite_size 166 #define meshtastic_OEMStore_size 3346 #define meshtastic_PositionLite_size 28 From 57da37cfbca4ef5b47c346e4f2de02d00f33a726 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 1 May 2024 08:05:26 -0500 Subject: [PATCH 04/18] Position module should enforce precision for phone originated position packets (#3752) --- src/modules/PositionModule.cpp | 17 +++++++++++++++++ src/modules/PositionModule.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index 658b8b5a7..7c459dc35 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -87,6 +87,23 @@ bool PositionModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes return false; // Let others look at this message also if they want } +void PositionModule::alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtastic_Position *p) +{ + // Phone position packets need to be truncated to the channel precision + if (nodeDB->getNodeNum() == getFrom(&mp) && (precision < 32 && precision > 0)) { + LOG_DEBUG("Truncating phone position to channel precision %i\n", precision); + p->latitude_i = p->latitude_i & (UINT32_MAX << (32 - precision)); + p->longitude_i = p->longitude_i & (UINT32_MAX << (32 - precision)); + + // We want the imprecise position to be the middle of the possible location, not + p->latitude_i += (1 << (31 - precision)); + p->longitude_i += (1 << (31 - precision)); + + mp.decoded.payload.size = + pb_encode_to_bytes(mp.decoded.payload.bytes, sizeof(mp.decoded.payload.bytes), &meshtastic_Position_msg, p); + } +} + void PositionModule::trySetRtc(meshtastic_Position p, bool isLocal) { struct timeval tv; diff --git a/src/modules/PositionModule.h b/src/modules/PositionModule.h index 89ff50c64..1161159f7 100644 --- a/src/modules/PositionModule.h +++ b/src/modules/PositionModule.h @@ -42,6 +42,8 @@ class PositionModule : public ProtobufModule, private concu */ virtual bool handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Position *p) override; + virtual void alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtastic_Position *p) override; + /** Messages can be received that have the want_response bit set. If set, this callback will be invoked * so that subclasses can (optionally) send a response back to the original sender. */ virtual meshtastic_MeshPacket *allocReply() override; From ec92f7a5a396657e6b475988d1df520ab9753cd5 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 1 May 2024 08:27:43 -0500 Subject: [PATCH 05/18] Remove phone nodenum warning and empty else clause (#3756) --- src/mesh/MeshService.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 6b8d37975..66a2e6952 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -193,10 +193,7 @@ void MeshService::handleToRadio(meshtastic_MeshPacket &p) } #endif if (p.from != 0) { // We don't let phones assign nodenums to their sent messages - LOG_WARN("phone tried to pick a nodenum, we don't allow that.\n"); p.from = 0; - } else { - // p.from = nodeDB->getNodeNum(); } if (p.id == 0) From 5095efc55fc17f1c67abc4b64e715c9c2b4acf58 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Wed, 1 May 2024 13:06:42 -0500 Subject: [PATCH 06/18] Pick up support for more than 64 GPIO lines under Portduino --- arch/portduino/portduino.ini | 2 +- src/platform/portduino/PortduinoGlue.cpp | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/arch/portduino/portduino.ini b/arch/portduino/portduino.ini index 4857933ec..ef99c7870 100644 --- a/arch/portduino/portduino.ini +++ b/arch/portduino/portduino.ini @@ -1,6 +1,6 @@ ; The Portduino based sim environment on top of any host OS, all hardware will be simulated [portduino_base] -platform = https://github.com/meshtastic/platform-native.git#659e49346aa33008b150dfb206b1817ddabc7132 +platform = https://github.com/meshtastic/platform-native.git#784007630ca43b4811c6637606440588bb5acf39 framework = arduino build_src_filter = diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index d86ac6677..8572f4cf2 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -76,7 +76,21 @@ void portduinoCustomInit() void portduinoSetup() { printf("Setting up Meshtastic on Portduino...\n"); - gpioInit(); + int max_GPIO = 0; + int GPIO_lines[] = {cs, + irq, + busy, + reset, + txen, + rxen, + displayDC, + displayCS, + displayBacklight, + displayBacklightPWMChannel, + displayReset, + touchscreenCS, + touchscreenIRQ, + user}; std::string gpioChipName = "gpiochip"; settingsStrings[i2cdev] = ""; @@ -245,6 +259,13 @@ void portduinoSetup() exit(EXIT_FAILURE); } + for (int i : GPIO_lines) { + if (i > max_GPIO) + max_GPIO = i; + } + + gpioInit(max_GPIO + 1); // Done here so we can inform Portduino how many GPIOs we need. + // Need to bind all the configured GPIO pins so they're not simulated if (settingsMap.count(cs) > 0 && settingsMap[cs] != RADIOLIB_NC) { if (initGPIOPin(settingsMap[cs], gpioChipName) != ERRNO_OK) { From 45c1b46bd0f03350106009bec03e4c3a6050895b Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Wed, 1 May 2024 13:20:26 -0500 Subject: [PATCH 07/18] Move native to spi_host to indicate spidev for LovyanGFX --- arch/portduino/portduino.ini | 2 +- src/graphics/TFTDisplay.cpp | 4 ++- src/main.cpp | 8 ++--- src/platform/portduino/PortduinoGlue.cpp | 46 +++++++++++++----------- src/platform/portduino/PortduinoGlue.h | 4 +-- 5 files changed, 34 insertions(+), 30 deletions(-) diff --git a/arch/portduino/portduino.ini b/arch/portduino/portduino.ini index ef99c7870..162411972 100644 --- a/arch/portduino/portduino.ini +++ b/arch/portduino/portduino.ini @@ -24,7 +24,7 @@ lib_deps = ${env.lib_deps} ${networking_base.lib_deps} rweather/Crypto@^0.4.0 - https://github.com/lovyan03/LovyanGFX.git#d35e60f269dfecbb18a8cb0fd07d594c2fb7e7a8 + https://github.com/lovyan03/LovyanGFX.git#5a39989aa2c9492572255b22f033843ec8900233 build_flags = ${arduino_base.build_flags} diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp index b529bf0e4..fac9a5796 100644 --- a/src/graphics/TFTDisplay.cpp +++ b/src/graphics/TFTDisplay.cpp @@ -356,7 +356,7 @@ class LGFX : public lgfx::LGFX_Device _panel_instance = new lgfx::Panel_ILI9341; auto buscfg = _bus_instance.config(); buscfg.spi_mode = 0; - _bus_instance.spi_device(DisplaySPI); + buscfg.spi_host = settingsMap[displayspidev]; buscfg.pin_dc = settingsMap[displayDC]; // Set SPI DC pin number (-1 = disable) @@ -397,6 +397,8 @@ class LGFX : public lgfx::LGFX_Device touch_cfg.offset_rotation = 1; if (settingsMap[touchscreenI2CAddr] != -1) { touch_cfg.i2c_addr = settingsMap[touchscreenI2CAddr]; + } else { + touch_cfg.spi_host = settingsMap[touchscreenspidev]; } _touch_instance->config(touch_cfg); diff --git a/src/main.cpp b/src/main.cpp index 4a663a8a0..063e9b355 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -729,7 +729,7 @@ void setup() if (settingsMap[use_sx1262]) { if (!rIf) { LOG_DEBUG("Attempting to activate sx1262 radio on SPI port %s\n", settingsStrings[spidev].c_str()); - LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(*LoraSPI, spiSettings); + LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings); rIf = new SX1262Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset], settingsMap[busy]); if (!rIf->init()) { @@ -743,7 +743,7 @@ void setup() } else if (settingsMap[use_rf95]) { if (!rIf) { LOG_DEBUG("Attempting to activate rf95 radio on SPI port %s\n", settingsStrings[spidev].c_str()); - LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(*LoraSPI, spiSettings); + LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings); rIf = new RF95Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset], settingsMap[busy]); if (!rIf->init()) { @@ -758,7 +758,7 @@ void setup() } else if (settingsMap[use_sx1280]) { if (!rIf) { LOG_DEBUG("Attempting to activate sx1280 radio on SPI port %s\n", settingsStrings[spidev].c_str()); - LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(*LoraSPI, spiSettings); + LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings); rIf = new SX1280Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset], settingsMap[busy]); if (!rIf->init()) { @@ -773,7 +773,7 @@ void setup() } else if (settingsMap[use_sx1268]) { if (!rIf) { LOG_DEBUG("Attempting to activate sx1268 radio on SPI port %s\n", settingsStrings[spidev].c_str()); - LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(*LoraSPI, spiSettings); + LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings); rIf = new SX1268Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset], settingsMap[busy]); if (!rIf->init()) { diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index 8572f4cf2..6151da227 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -15,8 +15,6 @@ #include #include -HardwareSPI *DisplaySPI; -HardwareSPI *LoraSPI; std::map settingsMap; std::map settingsStrings; char *configPath = nullptr; @@ -173,6 +171,15 @@ void portduinoSetup() gpioChipName += std::to_string(settingsMap[gpiochip]); settingsStrings[spidev] = "/dev/" + yamlConfig["Lora"]["spidev"].as("spidev0.0"); + if (settingsStrings[spidev].length() == 14) { + int x = settingsStrings[spidev].at(11) - '0'; + int y = settingsStrings[spidev].at(13) - '0'; + if (x >= 0 && x < 10 && y >= 0 && y < 10) { + settingsMap[spidev] = x + y << 4; + settingsMap[displayspidev] = settingsMap[spidev]; + settingsMap[touchscreenspidev] = settingsMap[spidev]; + } + } } if (yamlConfig["GPIO"]) { settingsMap[user] = yamlConfig["GPIO"]["User"].as(RADIOLIB_NC); @@ -222,6 +229,14 @@ void portduinoSetup() settingsMap[displayBusFrequency] = yamlConfig["Display"]["BusFrequency"].as(40000000); if (yamlConfig["Display"]["spidev"]) { settingsStrings[displayspidev] = "/dev/" + yamlConfig["Display"]["spidev"].as("spidev0.1"); + if (settingsStrings[displayspidev].length() == 14) { + int x = settingsStrings[displayspidev].at(11) - '0'; + int y = settingsStrings[displayspidev].at(13) - '0'; + if (x >= 0 && x < 10 && y >= 0 && y < 10) { + settingsMap[displayspidev] = x + y << 4; + settingsMap[touchscreenspidev] = settingsMap[displayspidev]; + } + } } } settingsMap[touchscreenModule] = no_touchscreen; @@ -241,6 +256,13 @@ void portduinoSetup() settingsMap[touchscreenI2CAddr] = yamlConfig["Touchscreen"]["I2CAddr"].as(-1); if (yamlConfig["Touchscreen"]["spidev"]) { settingsStrings[touchscreenspidev] = "/dev/" + yamlConfig["Touchscreen"]["spidev"].as(""); + if (settingsStrings[touchscreenspidev].length() == 14) { + int x = settingsStrings[touchscreenspidev].at(11) - '0'; + int y = settingsStrings[touchscreenspidev].at(13) - '0'; + if (x >= 0 && x < 10 && y >= 0 && y < 10) { + settingsMap[touchscreenspidev] = x + y << 4; + } + } } } if (yamlConfig["Input"]) { @@ -319,27 +341,9 @@ void portduinoSetup() if (settingsMap[touchscreenIRQ] > 0) initGPIOPin(settingsMap[touchscreenIRQ], gpioChipName); } - - // if we specify a touchscreen dev, that is SPI. - // else if we specify a screen dev, that is SPI - // else if we specify a LoRa dev, that is SPI. - if (settingsStrings[touchscreenspidev] != "") { - SPI.begin(settingsStrings[touchscreenspidev].c_str()); - DisplaySPI = new HardwareSPI; - DisplaySPI->begin(settingsStrings[displayspidev].c_str()); - LoraSPI = new HardwareSPI; - LoraSPI->begin(settingsStrings[spidev].c_str()); - } else if (settingsStrings[displayspidev] != "") { - SPI.begin(settingsStrings[displayspidev].c_str()); - DisplaySPI = &SPI; - LoraSPI = new HardwareSPI; - LoraSPI->begin(settingsStrings[spidev].c_str()); - } else { + if (settingsStrings[spidev] != "") { SPI.begin(settingsStrings[spidev].c_str()); - LoraSPI = &SPI; - DisplaySPI = &SPI; } - return; } diff --git a/src/platform/portduino/PortduinoGlue.h b/src/platform/portduino/PortduinoGlue.h index 94cdbf2f8..995793a21 100644 --- a/src/platform/portduino/PortduinoGlue.h +++ b/src/platform/portduino/PortduinoGlue.h @@ -56,6 +56,4 @@ enum { level_error, level_warn, level_info, level_debug }; extern std::map settingsMap; extern std::map settingsStrings; -int initGPIOPin(int pinNum, std::string gpioChipname); -extern HardwareSPI *DisplaySPI; -extern HardwareSPI *LoraSPI; \ No newline at end of file +int initGPIOPin(int pinNum, std::string gpioChipname); \ No newline at end of file From 0f4ac945591545cefb6c645573b1ef0a880cc745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 2 May 2024 12:48:50 +0200 Subject: [PATCH 08/18] fix building new TWC_mesh_v4 board --- variants/TWC_mesh_v4/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/TWC_mesh_v4/platformio.ini b/variants/TWC_mesh_v4/platformio.ini index 9cf25c685..481682143 100644 --- a/variants/TWC_mesh_v4/platformio.ini +++ b/variants/TWC_mesh_v4/platformio.ini @@ -1,6 +1,6 @@ [env:TWC_mesh_v4] extends = nrf52840_base -board = TWC_mesh_v4 +board = nordic_pca10059 board_level = extra build_flags = ${nrf52840_base.build_flags} -I variants/TWC_mesh_v4 -D TWC_mesh_v4 -L".pio\libdeps\TWC_mesh_v4\BSEC2 Software Library\src\cortex-m4\fpv4-sp-d16-hard" build_src_filter = ${nrf52_base.build_src_filter} +<../variants/TWC_mesh_v4> From 5f929a80244e7f5d4fda0df4571ecb0edbe55950 Mon Sep 17 00:00:00 2001 From: Andrew Yong Date: Thu, 2 May 2024 20:13:36 +0800 Subject: [PATCH 09/18] Publish fixed position updates and consider changes in only altitude as an updated point (#3758) * AdminModule: Publish fixed position updates Enabled GPS thread when fixed position is updated, to let the GPS thread run once and publish the new fixed position. Signed-off-by: Andrew Yong * GPS: Consider changes in only altitude as an updated point Signed-off-by: Andrew Yong --------- Signed-off-by: Andrew Yong --- src/gps/GPS.cpp | 2 +- src/modules/AdminModule.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 17e35a4b3..1c1aac7ad 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -1467,7 +1467,7 @@ bool GPS::lookForLocation() #endif // GPS_EXTRAVERBOSE // Is this a new point or are we re-reading the previous one? - if (!reader.location.isUpdated()) + if (!reader.location.isUpdated() && !reader.altitude.isUpdated()) return false; // check if a complete GPS solution set is available for reading diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 54eb577f7..37e798b3c 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -23,6 +23,10 @@ #include "mqtt/MQTT.h" #endif +#if !MESHTASTIC_EXCLUDE_GPS +#include "GPS.h" +#endif + AdminModule *adminModule; bool hasOpenEditTransaction; @@ -217,6 +221,10 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta nodeDB->setLocalPosition(r->set_fixed_position); config.position.fixed_position = true; saveChanges(SEGMENT_DEVICESTATE | SEGMENT_CONFIG, false); +#if !MESHTASTIC_EXCLUDE_GPS + if (gps != nullptr) + gps->enable(); +#endif } break; } From 0527fb10ce28fb054d74c9c0848717cdb2cc15e0 Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Fri, 3 May 2024 00:14:44 +1200 Subject: [PATCH 10/18] Init. battery voltage from ADC reading, instead of fixed value (#3761) --- src/Power.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Power.cpp b/src/Power.cpp index 2658b74a4..770bf4b5a 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -223,7 +223,17 @@ class AnalogBatteryLevel : public HasBatteryLevel raw = raw / BATTERY_SENSE_SAMPLES; scaled = operativeAdcMultiplier * ((1000 * AREF_VOLTAGE) / pow(2, BATTERY_SENSE_RESOLUTION_BITS)) * raw; #endif - last_read_value += (scaled - last_read_value) * 0.5; // Virtual LPF + + if (!initial_read_done) { + // Flush the smoothing filter with an ADC reading, if the reading is plausibly correct + if (scaled > last_read_value) + last_read_value = scaled; + initial_read_done = true; + } else { + // Already initialized - filter this reading + last_read_value += (scaled - last_read_value) * 0.5; // Virtual LPF + } + // LOG_DEBUG("battery gpio %d raw val=%u scaled=%u filtered=%u\n", BATTERY_PIN, raw, (uint32_t)(scaled), (uint32_t) // (last_read_value)); } @@ -357,6 +367,8 @@ class AnalogBatteryLevel : public HasBatteryLevel const float noBatVolt = (OCV[NUM_OCV_POINTS - 1] - 500) * NUM_CELLS; // Start value from minimum voltage for the filter to not start from 0 // that could trigger some events. + // This value is over-written by the first ADC reading, it the voltage seems reasonable. + bool initial_read_done = false; float last_read_value = (OCV[NUM_OCV_POINTS - 1] * NUM_CELLS); uint32_t last_read_time_ms = 0; From d1b6f1142909efb9e82c1983c92670bc08712bce Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Thu, 2 May 2024 14:27:25 +0800 Subject: [PATCH 11/18] Fix t-echo gps failure --- variants/t-echo/variant.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/variants/t-echo/variant.h b/variants/t-echo/variant.h index 6a5146dc0..2abeed16d 100644 --- a/variants/t-echo/variant.h +++ b/variants/t-echo/variant.h @@ -131,7 +131,7 @@ External serial flash WP25R1635FZUIL0 // Note DIO2 is attached internally to the module to an analog switch for TX/RX switching #define SX1262_DIO3 \ (0 + 21) // This is used as an *output* from the sx1262 and connected internally to power the tcxo, do not drive from the main - // CPU? +// CPU? #define SX126X_BUSY (0 + 17) #define SX126X_RESET (0 + 25) // Not really an E22 but TTGO seems to be trying to clone that @@ -177,13 +177,13 @@ External serial flash WP25R1635FZUIL0 #define PIN_GPS_STANDBY (32 + 2) // An output to wake GPS, low means allow sleep, high means force wake // Seems to be missing on this new board // #define PIN_GPS_PPS (32 + 4) // Pulse per second input from the GPS -#define PIN_GPS_TX (32 + 9) // This is for bits going TOWARDS the CPU -#define PIN_GPS_RX (32 + 8) // This is for bits going TOWARDS the GPS +#define GPS_TX_PIN (32 + 9) // This is for bits going TOWARDS the CPU +#define GPS_RX_PIN (32 + 8) // This is for bits going TOWARDS the GPS #define GPS_THREAD_INTERVAL 50 -#define PIN_SERIAL1_RX PIN_GPS_TX -#define PIN_SERIAL1_TX PIN_GPS_RX +#define PIN_SERIAL1_RX GPS_TX_PIN +#define PIN_SERIAL1_TX GPS_RX_PIN // PCF8563 RTC Module #define PCF8563_RTC 0x51 From 71400103b3e9f981cc1ac7f3dff4c24b663a93ab Mon Sep 17 00:00:00 2001 From: Oliver Seiler Date: Thu, 2 May 2024 18:39:18 +0000 Subject: [PATCH 12/18] set USB_CDC_ON_BOOT, udate arduinoespressif32 to 2.0.15 (#3764) --- boards/tbeam-s3-core.json | 1 + variants/tbeam-s3-core/platformio.ini | 2 ++ 2 files changed, 3 insertions(+) diff --git a/boards/tbeam-s3-core.json b/boards/tbeam-s3-core.json index 4c82a2789..8d2c3eed6 100644 --- a/boards/tbeam-s3-core.json +++ b/boards/tbeam-s3-core.json @@ -7,6 +7,7 @@ "extra_flags": [ "-DBOARD_HAS_PSRAM", "-DLILYGO_TBEAM_S3_CORE", + "-DARDUINO_USB_CDC_ON_BOOT=1", "-DARDUINO_USB_MODE=1", "-DARDUINO_RUNNING_CORE=1", "-DARDUINO_EVENT_RUNNING_CORE=1" diff --git a/variants/tbeam-s3-core/platformio.ini b/variants/tbeam-s3-core/platformio.ini index 99d315a69..926f15a39 100644 --- a/variants/tbeam-s3-core/platformio.ini +++ b/variants/tbeam-s3-core/platformio.ini @@ -3,6 +3,8 @@ extends = esp32s3_base board = tbeam-s3-core +platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.15 + lib_deps = ${esp32s3_base.lib_deps} lewisxhe/PCF8563_Library@1.0.1 From 06e7d2b8459f86e55cae1ab5a2bb5e2a21d7b118 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 2 May 2024 13:39:28 -0500 Subject: [PATCH 13/18] Track actual GPIO values, not just the enum values (#3768) * Track actual GPIO values, not just the enum values * trunk --- src/platform/portduino/PortduinoGlue.cpp | 34 ++++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index 6151da227..35cee2d2f 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -75,20 +75,20 @@ void portduinoSetup() { printf("Setting up Meshtastic on Portduino...\n"); int max_GPIO = 0; - int GPIO_lines[] = {cs, - irq, - busy, - reset, - txen, - rxen, - displayDC, - displayCS, - displayBacklight, - displayBacklightPWMChannel, - displayReset, - touchscreenCS, - touchscreenIRQ, - user}; + configNames GPIO_lines[] = {cs, + irq, + busy, + reset, + txen, + rxen, + displayDC, + displayCS, + displayBacklight, + displayBacklightPWMChannel, + displayReset, + touchscreenCS, + touchscreenIRQ, + user}; std::string gpioChipName = "gpiochip"; settingsStrings[i2cdev] = ""; @@ -281,9 +281,9 @@ void portduinoSetup() exit(EXIT_FAILURE); } - for (int i : GPIO_lines) { - if (i > max_GPIO) - max_GPIO = i; + for (configNames i : GPIO_lines) { + if (settingsMap[i] > max_GPIO) + max_GPIO = settingsMap[i]; } gpioInit(max_GPIO + 1); // Done here so we can inform Portduino how many GPIOs we need. From b69a1cada916bec7bf39cd970f9412e5de464cb7 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 2 May 2024 13:54:50 -0500 Subject: [PATCH 14/18] Portduino bump to pick up minor fix (#3770) --- arch/portduino/portduino.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/portduino/portduino.ini b/arch/portduino/portduino.ini index 162411972..63f5576b6 100644 --- a/arch/portduino/portduino.ini +++ b/arch/portduino/portduino.ini @@ -1,6 +1,6 @@ ; The Portduino based sim environment on top of any host OS, all hardware will be simulated [portduino_base] -platform = https://github.com/meshtastic/platform-native.git#784007630ca43b4811c6637606440588bb5acf39 +platform = https://github.com/meshtastic/platform-native.git#9881bf3721d610cccacf5ae8e3a07839cce75d63 framework = arduino build_src_filter = @@ -34,4 +34,4 @@ build_flags = -DPORTDUINO_LINUX_HARDWARE -lbluetooth -lgpiod - -lyaml-cpp \ No newline at end of file + -lyaml-cpp From 9501f3bda9de00db7c2804270f0f6fd366ac4ebf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 16:17:41 -0500 Subject: [PATCH 15/18] [create-pull-request] automated change (#3771) Co-authored-by: thebentern --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 36607a956..a7a7fb1bd 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 3 -build = 8 +build = 9 From 5dfa4b837fe87e08ea71b4c8ec0b1d6d65729015 Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Fri, 3 May 2024 12:11:13 +1200 Subject: [PATCH 16/18] Ensure LED is off when disabling heartbeat (#3772) --- src/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 063e9b355..c2c824968 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -693,6 +693,12 @@ void setup() // Now that the mesh service is created, create any modules setupModules(); +#ifdef LED_PIN + // Turn LED off after boot, if heartbeat by config + if (config.device.led_heartbeat_disabled) + digitalWrite(LED_PIN, LOW ^ LED_INVERTED); +#endif + // Do this after service.init (because that clears error_code) #ifdef HAS_PMU if (!pmu_found) From d490a332a7f2e6978a24a0033a5ebb4c29b5117a Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 2 May 2024 19:11:35 -0500 Subject: [PATCH 17/18] Update version.properties --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index a7a7fb1bd..36607a956 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 3 -build = 9 +build = 8 From 09080d76ad29dc40f450a9ba944ef4ed5f7a4f10 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 20:46:22 -0500 Subject: [PATCH 18/18] [create-pull-request] automated change (#3773) Co-authored-by: thebentern --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 36607a956..a7a7fb1bd 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 3 -build = 8 +build = 9