diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 4368bc3a7..1b7c8511f 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -190,7 +190,6 @@ bool GPS::setupGPS() // Switch to Vehicle Mode, since SoftRF enables Aviation < 2g _serial_gps->write("$PCAS11,3*1E\r\n"); delay(250); - } else if (gnssModel == GNSS_MODEL_UBLOX) { /* @@ -429,6 +428,10 @@ void GPS::publishUpdate() int32_t GPS::runOnce() { + // Repeaters have no need for GPS + if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER) + disable(); + if (whileIdle()) { // if we have received valid NMEA claim we are connected setConnected(); diff --git a/src/main.cpp b/src/main.cpp index c91a71719..4f65ff51b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -310,6 +310,10 @@ void setup() // but we need to do this after main cpu iniot (esp32setup), because we need the random seed set nodeDB.init(); + // If we're taking on the repeater role, use flood router + if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER) + router = new FloodingRouter(); + playStartMelody(); // fixed screen override? diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 0cb7ee8be..e729a225d 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -367,7 +367,6 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p) { // If the packet is not yet encrypted, do so now if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) { - size_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), &meshtastic_Data_msg, &p->decoded); // Only allow encryption on the text message app. diff --git a/src/mesh/Router.h b/src/mesh/Router.h index 8e116dca0..f43f92158 100644 --- a/src/mesh/Router.h +++ b/src/mesh/Router.h @@ -73,9 +73,6 @@ class Router : protected concurrency::OSThread */ void enqueueReceivedMessage(meshtastic_MeshPacket *p); - protected: - friend class RoutingModule; - /** * Send a packet on a suitable interface. This routine will * later free() the packet to pool. This routine is not allowed to stall. @@ -85,6 +82,9 @@ class Router : protected concurrency::OSThread */ virtual ErrorCode send(meshtastic_MeshPacket *p); + protected: + friend class RoutingModule; + /** * Should this incoming filter be dropped? * diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index aacb77151..b0e4bd2b1 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -33,51 +33,56 @@ */ void setupModules() { + if (config.device.role != meshtastic_Config_DeviceConfig_Role_REPEATER) { #if HAS_BUTTON - inputBroker = new InputBroker(); + inputBroker = new InputBroker(); #endif - adminModule = new AdminModule(); - nodeInfoModule = new NodeInfoModule(); - positionModule = new PositionModule(); - waypointModule = new WaypointModule(); - textMessageModule = new TextMessageModule(); - traceRouteModule = new TraceRouteModule(); + adminModule = new AdminModule(); + nodeInfoModule = new NodeInfoModule(); + positionModule = new PositionModule(); + waypointModule = new WaypointModule(); + textMessageModule = new TextMessageModule(); + traceRouteModule = new TraceRouteModule(); - // Note: if the rest of meshtastic doesn't need to explicitly use your module, you do not need to assign the instance - // to a global variable. + // Note: if the rest of meshtastic doesn't need to explicitly use your module, you do not need to assign the instance + // to a global variable. - new RemoteHardwareModule(); - new ReplyModule(); + new RemoteHardwareModule(); + new ReplyModule(); #if HAS_BUTTON - rotaryEncoderInterruptImpl1 = new RotaryEncoderInterruptImpl1(); - rotaryEncoderInterruptImpl1->init(); - upDownInterruptImpl1 = new UpDownInterruptImpl1(); - upDownInterruptImpl1->init(); - cardKbI2cImpl = new CardKbI2cImpl(); - cardKbI2cImpl->init(); + rotaryEncoderInterruptImpl1 = new RotaryEncoderInterruptImpl1(); + rotaryEncoderInterruptImpl1->init(); + upDownInterruptImpl1 = new UpDownInterruptImpl1(); + upDownInterruptImpl1->init(); + cardKbI2cImpl = new CardKbI2cImpl(); + cardKbI2cImpl->init(); #endif #if HAS_SCREEN - cannedMessageModule = new CannedMessageModule(); + cannedMessageModule = new CannedMessageModule(); #endif #if HAS_TELEMETRY - new DeviceTelemetryModule(); - new EnvironmentTelemetryModule(); + new DeviceTelemetryModule(); + new EnvironmentTelemetryModule(); #endif #if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) - new SerialModule(); + new SerialModule(); #endif #ifdef ARCH_ESP32 - // Only run on an esp32 based device. - audioModule = new AudioModule(); - externalNotificationModule = new ExternalNotificationModule(); + // Only run on an esp32 based device. + audioModule = new AudioModule(); + externalNotificationModule = new ExternalNotificationModule(); - storeForwardModule = new StoreForwardModule(); + storeForwardModule = new StoreForwardModule(); - new RangeTestModule(); + new RangeTestModule(); #elif defined(ARCH_NRF52) - externalNotificationModule = new ExternalNotificationModule(); + externalNotificationModule = new ExternalNotificationModule(); #endif - // NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra acks + // NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra + // acks + } else { + adminModule = new AdminModule(); + } routingModule = new RoutingModule(); } diff --git a/src/modules/RoutingModule.cpp b/src/modules/RoutingModule.cpp index bf3739f2c..f91d32a20 100644 --- a/src/modules/RoutingModule.cpp +++ b/src/modules/RoutingModule.cpp @@ -24,6 +24,8 @@ bool RoutingModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mesh meshtastic_MeshPacket *RoutingModule::allocReply() { + if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER) + return NULL; assert(currentRequest); // We only consider making replies if the request was a legit routing packet (not just something we were sniffing)