kopia lustrzana https://github.com/meshtastic/firmware
commit
601422e92b
|
@ -19,11 +19,13 @@
|
||||||
#endif
|
#endif
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#include "modules/esp32/RangeTestModule.h"
|
#include "modules/esp32/RangeTestModule.h"
|
||||||
#include "modules/esp32/SerialModule.h"
|
|
||||||
#include "modules/esp32/StoreForwardModule.h"
|
#include "modules/esp32/StoreForwardModule.h"
|
||||||
#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(TTGO_T_ECHO)
|
||||||
|
#include "modules/SerialModule.h"
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
* Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else)
|
* Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else)
|
||||||
|
|
|
@ -69,8 +69,7 @@ SerialModuleRadio::SerialModuleRadio() : SinglePortModule("SerialModuleRadio", P
|
||||||
|
|
||||||
int32_t SerialModule::runOnce()
|
int32_t SerialModule::runOnce()
|
||||||
{
|
{
|
||||||
#ifdef ARCH_ESP32
|
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Uncomment the preferences below if you want to use the module
|
Uncomment the preferences below if you want to use the module
|
||||||
without having to configure it from the PythonAPI or WebUI.
|
without having to configure it from the PythonAPI or WebUI.
|
||||||
|
@ -140,22 +139,29 @@ int32_t SerialModule::runOnce()
|
||||||
baud = 921600;
|
baud = 921600;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ARCH_ESP32
|
||||||
if (moduleConfig.serial.rxd && moduleConfig.serial.txd) {
|
if (moduleConfig.serial.rxd && moduleConfig.serial.txd) {
|
||||||
Serial2.begin(baud, SERIAL_8N1, moduleConfig.serial.rxd, moduleConfig.serial.txd);
|
Serial2.begin(baud, SERIAL_8N1, moduleConfig.serial.rxd, moduleConfig.serial.txd);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Serial2.begin(baud, SERIAL_8N1, RXD2, TXD2);
|
Serial2.begin(baud, SERIAL_8N1, RXD2, TXD2);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (moduleConfig.serial.rxd && moduleConfig.serial.txd)
|
||||||
|
Serial2.setPins(moduleConfig.serial.rxd, moduleConfig.serial.txd);
|
||||||
|
|
||||||
|
Serial2.begin(baud, SERIAL_8N1);
|
||||||
|
|
||||||
|
#endif
|
||||||
if (moduleConfig.serial.timeout) {
|
if (moduleConfig.serial.timeout) {
|
||||||
Serial2.setTimeout(
|
Serial2.setTimeout(moduleConfig.serial.timeout); // Number of MS to wait to set the timeout for the string.
|
||||||
moduleConfig.serial.timeout); // Number of MS to wait to set the timeout for the string.
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Serial2.setTimeout(TIMEOUT); // Number of MS to wait to set the timeout for the string.
|
Serial2.setTimeout(TIMEOUT); // Number of MS to wait to set the timeout for the string.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ARCH_ESP32
|
||||||
Serial2.setRxBufferSize(RX_BUFFER);
|
Serial2.setRxBufferSize(RX_BUFFER);
|
||||||
|
#endif
|
||||||
|
|
||||||
serialModuleRadio = new SerialModuleRadio();
|
serialModuleRadio = new SerialModuleRadio();
|
||||||
|
|
||||||
|
@ -209,8 +215,7 @@ void SerialModuleRadio::sendPayload(NodeNum dest, bool wantReplies)
|
||||||
|
|
||||||
ProcessMessage SerialModuleRadio::handleReceived(const MeshPacket &mp)
|
ProcessMessage SerialModuleRadio::handleReceived(const MeshPacket &mp)
|
||||||
{
|
{
|
||||||
#ifdef ARCH_ESP32
|
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO)
|
||||||
|
|
||||||
if (moduleConfig.serial.enabled) {
|
if (moduleConfig.serial.enabled) {
|
||||||
|
|
||||||
auto &p = mp.decoded;
|
auto &p = mp.decoded;
|
||||||
|
@ -244,6 +249,7 @@ ProcessMessage SerialModuleRadio::handleReceived(const MeshPacket &mp)
|
||||||
Serial2.printf("%s", p.payload.bytes);
|
Serial2.printf("%s", p.payload.bytes);
|
||||||
|
|
||||||
} else if (moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_PROTO) {
|
} else if (moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_PROTO) {
|
||||||
|
// TODO this needs to be implemented
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue