mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-28 20:52:02 +00:00
Initial serialModule cleanup (#9465)
* Initial serialModule cleanup * Move SERIAL_PRINT_PORT definition to variant.h * Add missed c6 check * Update src/modules/SerialModule.cpp Compile error for invalid SERIAL_PRINT_OBJECT value Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -63,29 +63,26 @@
|
||||
SerialModule *serialModule;
|
||||
SerialModuleRadio *serialModuleRadio;
|
||||
|
||||
#if defined(TTGO_T_ECHO) || defined(TTGO_T_ECHO_PLUS) || defined(CANARYONE) || defined(MESHLINK) || \
|
||||
defined(ELECROW_ThinkNode_M1) || defined(ELECROW_ThinkNode_M4) || defined(ELECROW_ThinkNode_M5) || \
|
||||
defined(HELTEC_MESH_SOLAR) || defined(T_ECHO_LITE) || defined(ELECROW_ThinkNode_M3) || defined(MUZI_BASE)
|
||||
|
||||
SerialModule::SerialModule() : StreamAPI(&Serial), concurrency::OSThread("Serial")
|
||||
{
|
||||
api_type = TYPE_SERIAL;
|
||||
}
|
||||
static Print *serialPrint = &Serial;
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C6) || defined(RAK3172) || defined(EBYTE_E77_MBL)
|
||||
SerialModule::SerialModule() : StreamAPI(&Serial1), concurrency::OSThread("Serial")
|
||||
{
|
||||
api_type = TYPE_SERIAL;
|
||||
}
|
||||
static Print *serialPrint = &Serial1;
|
||||
#else
|
||||
SerialModule::SerialModule() : StreamAPI(&Serial2), concurrency::OSThread("Serial")
|
||||
{
|
||||
api_type = TYPE_SERIAL;
|
||||
}
|
||||
static Print *serialPrint = &Serial2;
|
||||
#ifndef SERIAL_PRINT_PORT
|
||||
#define SERIAL_PRINT_PORT 2
|
||||
#endif
|
||||
|
||||
#if SERIAL_PRINT_PORT == 0
|
||||
#define SERIAL_PRINT_OBJECT Serial
|
||||
#elif SERIAL_PRINT_PORT == 1
|
||||
#define SERIAL_PRINT_OBJECT Serial1
|
||||
#elif SERIAL_PRINT_PORT == 2
|
||||
#define SERIAL_PRINT_OBJECT Serial2
|
||||
#else
|
||||
#error "Unsupported SERIAL_PRINT_PORT value. Allowed values are 0, 1, or 2."
|
||||
#endif
|
||||
|
||||
SerialModule::SerialModule() : StreamAPI(&SERIAL_PRINT_OBJECT), concurrency::OSThread("Serial")
|
||||
{
|
||||
api_type = TYPE_SERIAL;
|
||||
}
|
||||
static Print *serialPrint = &SERIAL_PRINT_OBJECT;
|
||||
|
||||
char serialBytes[512];
|
||||
size_t serialPayloadSize;
|
||||
|
||||
@@ -205,9 +202,7 @@ int32_t SerialModule::runOnce()
|
||||
Serial.begin(baud);
|
||||
Serial.setTimeout(moduleConfig.serial.timeout > 0 ? moduleConfig.serial.timeout : TIMEOUT);
|
||||
}
|
||||
#elif !defined(TTGO_T_ECHO) && !defined(TTGO_T_ECHO_PLUS) && !defined(T_ECHO_LITE) && !defined(CANARYONE) && \
|
||||
!defined(MESHLINK) && !defined(ELECROW_ThinkNode_M1) && !defined(ELECROW_ThinkNode_M3) && !defined(ELECROW_ThinkNode_M4) && \
|
||||
!defined(ELECROW_ThinkNode_M5) && !defined(MUZI_BASE)
|
||||
#elif SERIAL_PRINT_PORT != 0
|
||||
|
||||
if (moduleConfig.serial.rxd && moduleConfig.serial.txd) {
|
||||
#ifdef ARCH_RP2040
|
||||
@@ -264,9 +259,7 @@ int32_t SerialModule::runOnce()
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(TTGO_T_ECHO) && !defined(TTGO_T_ECHO_PLUS) && !defined(T_ECHO_LITE) && !defined(CANARYONE) && !defined(MESHLINK) && \
|
||||
!defined(ELECROW_ThinkNode_M1) && !defined(ELECROW_ThinkNode_M3) && !defined(ELECROW_ThinkNode_M4) && \
|
||||
!defined(ELECROW_ThinkNode_M5) && !defined(MUZI_BASE)
|
||||
#if SERIAL_PRINT_PORT != 0
|
||||
else if ((moduleConfig.serial.mode == meshtastic_ModuleConfig_SerialConfig_Serial_Mode_WS85)) {
|
||||
processWXSerial();
|
||||
|
||||
@@ -540,11 +533,7 @@ ParsedLine parseLine(const char *line)
|
||||
*/
|
||||
void SerialModule::processWXSerial()
|
||||
{
|
||||
#if !defined(TTGO_T_ECHO) && !defined(TTGO_T_ECHO_PLUS) && !defined(T_ECHO_LITE) && !defined(CANARYONE) && \
|
||||
!defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(MESHLINK) && !defined(ELECROW_ThinkNode_M1) && \
|
||||
!defined(ELECROW_ThinkNode_M3) && \
|
||||
!defined(ELECROW_ThinkNode_M4) && \
|
||||
!defined(ELECROW_ThinkNode_M5) && !defined(ARCH_STM32WL) && !defined(MUZI_BASE)
|
||||
#if SERIAL_PRINT_PORT != 0 && !defined(ARCH_STM32WL) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||
|
||||
static unsigned int lastAveraged = 0;
|
||||
static unsigned int averageIntervalMillis = 300000; // 5 minutes hard coded.
|
||||
|
||||
@@ -50,3 +50,5 @@ void c6l_init();
|
||||
#endif
|
||||
#define SCREEN_TRANSITION_FRAMERATE 10
|
||||
#define BRIGHTNESS_DEFAULT 130 // Medium Low Brightness
|
||||
|
||||
#define SERIAL_PRINT_PORT 1
|
||||
|
||||
@@ -19,3 +19,5 @@
|
||||
#define SX126X_TXEN 14
|
||||
#define SX126X_DIO2_AS_RF_SWITCH
|
||||
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
||||
|
||||
#define SERIAL_PRINT_PORT 1
|
||||
|
||||
@@ -81,4 +81,6 @@
|
||||
|
||||
#define BUTTON_PIN PIN_BUTTON1
|
||||
#define BUTTON_PIN_ALT PIN_BUTTON2
|
||||
|
||||
#define SERIAL_PRINT_PORT 0
|
||||
#endif
|
||||
|
||||
@@ -159,6 +159,8 @@ External serial flash WP25R1635FZUIL0
|
||||
#define PIN_SERIAL1_TX GPS_TX_PIN
|
||||
#define PIN_SERIAL1_RX GPS_RX_PIN
|
||||
|
||||
#define SERIAL_PRINT_PORT 0
|
||||
|
||||
/*
|
||||
* SPI Interfaces
|
||||
*/
|
||||
|
||||
@@ -113,6 +113,8 @@ extern "C" {
|
||||
#define LR11X0_DIO3_TCXO_VOLTAGE 3.3
|
||||
#define LR11X0_DIO_AS_RF_SWITCH
|
||||
|
||||
#define SERIAL_PRINT_PORT 0
|
||||
|
||||
// PCF8563 RTC Module
|
||||
// REVISIT https://github.com/meshtastic/firmware/pull/9084
|
||||
// #define PCF8563_RTC 0x51
|
||||
|
||||
@@ -135,6 +135,8 @@ static const uint8_t A0 = PIN_A0;
|
||||
#define PIN_SERIAL1_RX GPS_RX_PIN
|
||||
#define PIN_SERIAL1_TX GPS_TX_PIN
|
||||
|
||||
#define SERIAL_PRINT_PORT 0
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -170,6 +170,8 @@ static const uint8_t A0 = PIN_A0;
|
||||
#define VBAT_AR_INTERNAL AR_INTERNAL_3_0
|
||||
#define ADC_MULTIPLIER (2.0F)
|
||||
|
||||
#define SERIAL_PRINT_PORT 0
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -142,6 +142,8 @@ No longer populated on PCB
|
||||
#define BQ4050_SCL_PIN (32 + 0) // I2C clock line pin
|
||||
#define BQ4050_EMERGENCY_SHUTDOWN_PIN (32 + 3) // Emergency shutdown pin
|
||||
|
||||
#define SERIAL_PRINT_PORT 0
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -54,6 +54,7 @@ extern "C" {
|
||||
*/
|
||||
#define PIN_SERIAL1_RX (32 + 8)
|
||||
#define PIN_SERIAL1_TX (7)
|
||||
#define SERIAL_PRINT_PORT 0
|
||||
|
||||
/*
|
||||
* SPI Interfaces
|
||||
|
||||
@@ -176,6 +176,8 @@ extern "C" {
|
||||
#define EXTERNAL_FLASH_DEVICES W25Q32JVSS
|
||||
#define EXTERNAL_FLASH_USE_QSPI
|
||||
|
||||
#define SERIAL_PRINT_PORT 0
|
||||
|
||||
// NFC is disabled via CONFIG_NFCT_PINS_AS_GPIOS=1 build flag
|
||||
// This configures P0.09 and P0.10 as regular GPIO pins instead of NFC pins
|
||||
|
||||
|
||||
@@ -171,6 +171,8 @@ static const uint8_t A0 = PIN_A0;
|
||||
#define VBAT_AR_INTERNAL AR_INTERNAL_3_0
|
||||
#define ADC_MULTIPLIER (2.0F)
|
||||
|
||||
#define SERIAL_PRINT_PORT 0
|
||||
|
||||
// #define NO_EXT_GPIO 1
|
||||
// PINs back side
|
||||
// Batt & solar connector left up corner
|
||||
|
||||
@@ -138,6 +138,8 @@ static const uint8_t A0 = PIN_A0;
|
||||
// Battery / ADC already defined above
|
||||
#define HAS_RTC 1
|
||||
|
||||
#define SERIAL_PRINT_PORT 0
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -88,6 +88,7 @@ static const uint8_t A0 = PIN_A0;
|
||||
/*
|
||||
* Serial interfaces
|
||||
*/
|
||||
#define SERIAL_PRINT_PORT 0
|
||||
|
||||
/*
|
||||
No longer populated on PCB
|
||||
|
||||
@@ -19,5 +19,7 @@ Do not expect a working Meshtastic device with this target.
|
||||
// #define LED_PIN PB3 // LED2
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
#define SERIAL_PRINT_PORT 1
|
||||
|
||||
#define EBYTE_E77_MBL
|
||||
#endif
|
||||
|
||||
@@ -17,5 +17,6 @@ Do not expect a working Meshtastic device with this target.
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
#define RAK3172
|
||||
#define SERIAL_PRINT_PORT 1
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user