Skip to content

Commit 0952007

Browse files
authored
Make ExternalNotification show up in excluded_modules, more STM32 modules (#7797)
* Show ExternalNotification as excluded if it is * Enable ExternalNotification, SerialModule and RangeTest on STM32WL * Misc fixes for #7797 - ARCH_STM32 -> ARCH_STM32WL, use less flash by dropping weather station support for serialmodule, set tx/rx pins before begin * Enable Serial1 on RAK3172, make SerialModule use it (console is on LPUART1) * Fix SerialModule on RAK3172, fix board definition of RAK3172 to include the right pin mapping.
1 parent 7612799 commit 0952007

8 files changed

Lines changed: 38 additions & 20 deletions

File tree

boards/wiscore_rak3172.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
},
66
"core": "stm32",
77
"cpu": "cortex-m4",
8-
"extra_flags": "-DSTM32WLxx -DSTM32WLE5xx -DARDUINO_GENERIC_WLE5CCUX",
8+
"extra_flags": "-DSTM32WLxx -DSTM32WLE5xx -DARDUINO_RAK3172_MODULE",
99
"f_cpu": "48000000L",
1010
"mcu": "stm32wle5ccu",
1111
"variant": "STM32WLxx/WL54CCU_WL55CCU_WLE4C(8-B-C)U_WLE5C(8-B-C)U",

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ extern meshtastic_DeviceMetadata getDeviceMetadata()
15311531
#if ((!HAS_SCREEN || NO_EXT_GPIO) || MESHTASTIC_EXCLUDE_CANNEDMESSAGES) && !defined(MESHTASTIC_INCLUDE_NICHE_GRAPHICS)
15321532
deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_CANNEDMSG_CONFIG;
15331533
#endif
1534-
#if NO_EXT_GPIO
1534+
#if NO_EXT_GPIO || MESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION
15351535
deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_EXTNOTIF_CONFIG;
15361536
#endif
15371537
// Only edge case here is if we apply this a device with built in Accelerometer and want to detect interrupts

src/modules/ExternalNotificationModule.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,10 @@ ExternalNotificationModule::ExternalNotificationModule()
364364
// moduleConfig.external_notification.alert_message_buzzer = true;
365365

366366
if (moduleConfig.external_notification.enabled) {
367+
#if !defined(MESHTASTIC_EXCLUDE_INPUTBROKER)
367368
if (inputBroker) // put our callback in the inputObserver list
368369
inputObserver.observe(inputBroker);
369-
370+
#endif
370371
if (nodeDB->loadProto(rtttlConfigFile, meshtastic_RTTTLConfig_size, sizeof(meshtastic_RTTTLConfig),
371372
&meshtastic_RTTTLConfig_msg, &rtttlConfig) != LoadFileResult::LOAD_SUCCESS) {
372373
memset(rtttlConfig.ringtone, 0, sizeof(rtttlConfig.ringtone));

src/modules/Modules.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
#include "modules/StoreForwardModule.h"
8989
#endif
9090
#endif
91-
#if defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040) || defined(ARCH_PORTDUINO)
91+
9292
#if !MESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION
9393
#include "modules/ExternalNotificationModule.h"
9494
#endif
@@ -98,7 +98,6 @@
9898
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !MESHTASTIC_EXCLUDE_SERIAL
9999
#include "modules/SerialModule.h"
100100
#endif
101-
#endif
102101

103102
#if !MESHTASTIC_EXCLUDE_DROPZONE
104103
#include "modules/DropzoneModule.h"
@@ -246,8 +245,8 @@ void setupModules()
246245
#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_POWER_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
247246
new PowerTelemetryModule();
248247
#endif
249-
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040)) && !defined(CONFIG_IDF_TARGET_ESP32S2) && \
250-
!defined(CONFIG_IDF_TARGET_ESP32C3)
248+
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040) || defined(ARCH_STM32WL)) && \
249+
!defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
251250
#if !MESHTASTIC_EXCLUDE_SERIAL
252251
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
253252
new SerialModule();
@@ -268,13 +267,11 @@ void setupModules()
268267
storeForwardModule = new StoreForwardModule();
269268
#endif
270269
#endif
271-
#if defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040) || defined(ARCH_PORTDUINO)
272270
#if !MESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION
273271
externalNotificationModule = new ExternalNotificationModule();
274272
#endif
275273
#if !MESHTASTIC_EXCLUDE_RANGETEST && !MESHTASTIC_EXCLUDE_GPS
276274
new RangeTestModule();
277-
#endif
278275
#endif
279276
} else {
280277
#if !MESHTASTIC_EXCLUDE_ADMIN

src/modules/RangeTestModule.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ uint32_t packetSequence = 0;
3131

3232
int32_t RangeTestModule::runOnce()
3333
{
34-
#if defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_PORTDUINO)
34+
#if defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_STM32WL) || defined(ARCH_PORTDUINO)
3535

3636
/*
3737
Uncomment the preferences below if you want to use the module
@@ -130,7 +130,7 @@ void RangeTestModuleRadio::sendPayload(NodeNum dest, bool wantReplies)
130130

131131
ProcessMessage RangeTestModuleRadio::handleReceived(const meshtastic_MeshPacket &mp)
132132
{
133-
#if defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_PORTDUINO)
133+
#if defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_STM32WL) || defined(ARCH_PORTDUINO)
134134

135135
if (moduleConfig.range_test.enabled) {
136136

src/modules/SerialModule.cpp

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
#include "meshSolarApp.h"
5050
#endif
5151

52-
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040)) && !defined(CONFIG_IDF_TARGET_ESP32S2) && \
53-
!defined(CONFIG_IDF_TARGET_ESP32C3)
52+
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040) || defined(ARCH_STM32WL)) && \
53+
!defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
5454

5555
#define RX_BUFFER 256
5656
#define TIMEOUT 250
@@ -67,7 +67,7 @@ SerialModuleRadio *serialModuleRadio;
6767
defined(ELECROW_ThinkNode_M5) || defined(HELTEC_MESH_SOLAR) || defined(T_ECHO_LITE)
6868
SerialModule::SerialModule() : StreamAPI(&Serial), concurrency::OSThread("Serial") {}
6969
static Print *serialPrint = &Serial;
70-
#elif defined(CONFIG_IDF_TARGET_ESP32C6)
70+
#elif defined(CONFIG_IDF_TARGET_ESP32C6) || defined(RAK3172)
7171
SerialModule::SerialModule() : StreamAPI(&Serial1), concurrency::OSThread("Serial") {}
7272
static Print *serialPrint = &Serial1;
7373
#else
@@ -173,7 +173,18 @@ int32_t SerialModule::runOnce()
173173
Serial.begin(baud);
174174
Serial.setTimeout(moduleConfig.serial.timeout > 0 ? moduleConfig.serial.timeout : TIMEOUT);
175175
}
176-
176+
#elif defined(ARCH_STM32WL)
177+
#ifndef RAK3172
178+
HardwareSerial *serialInstance = &Serial2;
179+
#else
180+
HardwareSerial *serialInstance = &Serial1;
181+
#endif
182+
if (moduleConfig.serial.rxd && moduleConfig.serial.txd) {
183+
serialInstance->setTx(moduleConfig.serial.txd);
184+
serialInstance->setRx(moduleConfig.serial.rxd);
185+
}
186+
serialInstance->begin(baud);
187+
serialInstance->setTimeout(moduleConfig.serial.timeout > 0 ? moduleConfig.serial.timeout : TIMEOUT);
177188
#elif defined(ARCH_ESP32)
178189

179190
if (moduleConfig.serial.rxd && moduleConfig.serial.txd) {
@@ -260,8 +271,13 @@ int32_t SerialModule::runOnce()
260271
while (Serial1.available()) {
261272
serialPayloadSize = Serial1.readBytes(serialBytes, meshtastic_Constants_DATA_PAYLOAD_LEN);
262273
#else
263-
while (Serial2.available()) {
264-
serialPayloadSize = Serial2.readBytes(serialBytes, meshtastic_Constants_DATA_PAYLOAD_LEN);
274+
#ifndef RAK3172
275+
HardwareSerial *serialInstance = &Serial2;
276+
#else
277+
HardwareSerial *serialInstance = &Serial1;
278+
#endif
279+
while (serialInstance->available()) {
280+
serialPayloadSize = serialInstance->readBytes(serialBytes, meshtastic_Constants_DATA_PAYLOAD_LEN);
265281
#endif
266282
serialModuleRadio->sendPayload();
267283
}
@@ -511,7 +527,7 @@ ParsedLine parseLine(const char *line)
511527
void SerialModule::processWXSerial()
512528
{
513529
#if !defined(TTGO_T_ECHO) && !defined(T_ECHO_LITE) && !defined(CANARYONE) && !defined(CONFIG_IDF_TARGET_ESP32C6) && \
514-
!defined(MESHLINK) && !defined(ELECROW_ThinkNode_M1) && !defined(ELECROW_ThinkNode_M5)
530+
!defined(MESHLINK) && !defined(ELECROW_ThinkNode_M1) && !defined(ELECROW_ThinkNode_M5) && !defined(ARCH_STM32WL)
515531
static unsigned int lastAveraged = 0;
516532
static unsigned int averageIntervalMillis = 300000; // 5 minutes hard coded.
517533
static double dir_sum_sin = 0;

src/modules/SerialModule.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#include <Arduino.h>
99
#include <functional>
1010

11-
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040)) && !defined(CONFIG_IDF_TARGET_ESP32S2) && \
12-
!defined(CONFIG_IDF_TARGET_ESP32C3)
11+
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040) || defined(ARCH_STM32WL)) && \
12+
!defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
1313

1414
class SerialModule : public StreamAPI, private concurrency::OSThread
1515
{

variants/stm32/rak3172/platformio.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ board_upload.maximum_size = 233472 ; reserve the last 28KB for filesystem
66
build_flags =
77
${stm32_base.build_flags}
88
-Ivariants/stm32/rak3172
9+
-DRAK3172
10+
-DENABLE_HWSERIAL1
11+
-DPIN_SERIAL1_RX=PB7
12+
-DPIN_SERIAL1_TX=PB6
913
-DPIN_WIRE_SDA=PA11
1014
-DPIN_WIRE_SCL=PA12
1115
-DMESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR=1

0 commit comments

Comments
 (0)