kopia lustrzana https://github.com/meshtastic/firmware
Open up Serial Module to T-Echo (#2533)
* Remove macro guards for T-Echo * Missed a spot * Gaurd serial2 * Didn't mean to circumcize that declarationpull/2534/head
rodzic
110ec85137
commit
b1398d0770
|
@ -27,7 +27,7 @@
|
||||||
#endif
|
#endif
|
||||||
#if defined(ARCH_ESP32) || defined(ARCH_NRF52)
|
#if defined(ARCH_ESP32) || defined(ARCH_NRF52)
|
||||||
#include "modules/ExternalNotificationModule.h"
|
#include "modules/ExternalNotificationModule.h"
|
||||||
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2)
|
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(CONFIG_IDF_TARGET_ESP32S2)
|
||||||
#include "modules/SerialModule.h"
|
#include "modules/SerialModule.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -72,8 +72,7 @@ void setupModules()
|
||||||
new AirQualityTelemetryModule();
|
new AirQualityTelemetryModule();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && \
|
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
|
||||||
!defined(CONFIG_IDF_TARGET_ESP32C3)
|
|
||||||
new SerialModule();
|
new SerialModule();
|
||||||
#endif
|
#endif
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
|
|
|
@ -39,13 +39,12 @@
|
||||||
KNOWN PROBLEMS
|
KNOWN PROBLEMS
|
||||||
* Until the module is initilized by the startup sequence, the TX pin is in a floating
|
* Until the module is initilized by the startup sequence, the TX pin is in a floating
|
||||||
state. Device connected to that pin may see this as "noise".
|
state. Device connected to that pin may see this as "noise".
|
||||||
* Will not work on T-Echo and the Linux device targets.
|
* Will not work on Linux device targets.
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && \
|
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
|
||||||
!defined(CONFIG_IDF_TARGET_ESP32C3)
|
|
||||||
|
|
||||||
#define RX_BUFFER 128
|
#define RX_BUFFER 128
|
||||||
#define TIMEOUT 250
|
#define TIMEOUT 250
|
||||||
|
@ -58,11 +57,16 @@
|
||||||
SerialModule *serialModule;
|
SerialModule *serialModule;
|
||||||
SerialModuleRadio *serialModuleRadio;
|
SerialModuleRadio *serialModuleRadio;
|
||||||
|
|
||||||
|
#ifdef TTGO_T_ECHO
|
||||||
|
SerialModule::SerialModule() : StreamAPI(&Serial), concurrency::OSThread("SerialModule") {}
|
||||||
|
static Print *serialPrint = &Serial;
|
||||||
|
#else
|
||||||
SerialModule::SerialModule() : StreamAPI(&Serial2), concurrency::OSThread("SerialModule") {}
|
SerialModule::SerialModule() : StreamAPI(&Serial2), concurrency::OSThread("SerialModule") {}
|
||||||
|
static Print *serialPrint = &Serial2;
|
||||||
|
#endif
|
||||||
|
|
||||||
char serialBytes[meshtastic_Constants_DATA_PAYLOAD_LEN];
|
char serialBytes[meshtastic_Constants_DATA_PAYLOAD_LEN];
|
||||||
size_t serialPayloadSize;
|
size_t serialPayloadSize;
|
||||||
static Print *serialPrint = &Serial2;
|
|
||||||
|
|
||||||
SerialModuleRadio::SerialModuleRadio() : MeshModule("SerialModuleRadio")
|
SerialModuleRadio::SerialModuleRadio() : MeshModule("SerialModuleRadio")
|
||||||
{
|
{
|
||||||
|
@ -119,8 +123,6 @@ int32_t SerialModule::runOnce()
|
||||||
serialPrint = &Serial;
|
serialPrint = &Serial;
|
||||||
// Give it a chance to flush out 💩
|
// Give it a chance to flush out 💩
|
||||||
delay(10);
|
delay(10);
|
||||||
} else {
|
|
||||||
serialPrint = &Serial2;
|
|
||||||
}
|
}
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
|
|
||||||
|
@ -131,7 +133,7 @@ int32_t SerialModule::runOnce()
|
||||||
Serial.begin(baud);
|
Serial.begin(baud);
|
||||||
Serial.setTimeout(moduleConfig.serial.timeout > 0 ? moduleConfig.serial.timeout : TIMEOUT);
|
Serial.setTimeout(moduleConfig.serial.timeout > 0 ? moduleConfig.serial.timeout : TIMEOUT);
|
||||||
}
|
}
|
||||||
#else
|
#elif !defined(TTGO_T_ECHO)
|
||||||
if (moduleConfig.serial.rxd && moduleConfig.serial.txd) {
|
if (moduleConfig.serial.rxd && moduleConfig.serial.txd) {
|
||||||
Serial2.setPins(moduleConfig.serial.rxd, moduleConfig.serial.txd);
|
Serial2.setPins(moduleConfig.serial.rxd, moduleConfig.serial.txd);
|
||||||
Serial2.begin(baud, SERIAL_8N1);
|
Serial2.begin(baud, SERIAL_8N1);
|
||||||
|
@ -140,6 +142,9 @@ int32_t SerialModule::runOnce()
|
||||||
Serial.begin(baud, SERIAL_8N1);
|
Serial.begin(baud, SERIAL_8N1);
|
||||||
Serial.setTimeout(moduleConfig.serial.timeout > 0 ? moduleConfig.serial.timeout : TIMEOUT);
|
Serial.setTimeout(moduleConfig.serial.timeout > 0 ? moduleConfig.serial.timeout : TIMEOUT);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
Serial.begin(baud, SERIAL_8N1);
|
||||||
|
Serial.setTimeout(moduleConfig.serial.timeout > 0 ? moduleConfig.serial.timeout : TIMEOUT);
|
||||||
#endif
|
#endif
|
||||||
serialModuleRadio = new SerialModuleRadio();
|
serialModuleRadio = new SerialModuleRadio();
|
||||||
|
|
||||||
|
@ -170,12 +175,15 @@ int32_t SerialModule::runOnce()
|
||||||
tempNodeInfo = nodeDB.readNextInfo(readIndex);
|
tempNodeInfo = nodeDB.readNextInfo(readIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
#ifndef TTGO_T_ECHO
|
||||||
|
else {
|
||||||
while (Serial2.available()) {
|
while (Serial2.available()) {
|
||||||
serialPayloadSize = Serial2.readBytes(serialBytes, meshtastic_Constants_DATA_PAYLOAD_LEN);
|
serialPayloadSize = Serial2.readBytes(serialBytes, meshtastic_Constants_DATA_PAYLOAD_LEN);
|
||||||
serialModuleRadio->sendPayload();
|
serialModuleRadio->sendPayload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return (10);
|
return (10);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -8,8 +8,7 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && \
|
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
|
||||||
!defined(CONFIG_IDF_TARGET_ESP32C3)
|
|
||||||
|
|
||||||
class SerialModule : public StreamAPI, private concurrency::OSThread
|
class SerialModule : public StreamAPI, private concurrency::OSThread
|
||||||
{
|
{
|
||||||
|
|
Ładowanie…
Reference in New Issue