diff --git a/src/main.cpp b/src/main.cpp index a4caad3fd9..04461acef7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -553,7 +553,10 @@ void setup() readFromRTC(); // read the main CPU RTC at first (in case we can't get GPS time) - gps = GPS::createGps(); + if (config.device.role != meshtastic_Config_DeviceConfig_Role_REPEATER) { + gps = GPS::createGps(); + } + if (gps) { gpsStatus->observe(&gps->newStatus); } else { @@ -738,6 +741,10 @@ void setup() powerFSMthread = new PowerFSMThread(); setCPUFast(false); // 80MHz is fine for our slow peripherals + // Power saving Repeaters turn pretty much everything off except the radio and CPU + if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER && config.power.is_power_saving) { + setCpuLowPower(); + } } uint32_t rebootAtMsec; // If not zero we will reboot at this time (used to reboot shortly after the update completes) diff --git a/src/platform/nrf52/main-nrf52.cpp b/src/platform/nrf52/main-nrf52.cpp index 6b986c778f..29c6a6c91b 100644 --- a/src/platform/nrf52/main-nrf52.cpp +++ b/src/platform/nrf52/main-nrf52.cpp @@ -210,4 +210,33 @@ void clearBonds() nrf52Bluetooth->setup(); } nrf52Bluetooth->clearBonds(); +} + +void setCpuLowPower() +{ + LOG_DEBUG("Setting CPU to LOW power\n"); + // This may cause crashes as debug messages continue to flow. + Serial.end(); + +#ifdef PIN_SERIAL_RX1 + Serial1.end(); +#endif + setBluetoothEnable(false); + +#ifdef RAK4630 +#ifdef PIN_3V3_EN + digitalWrite(PIN_3V3_EN, LOW); +#endif +#ifndef USE_EINK + // RAK-12039 set pin for Air quality sensor + digitalWrite(AQ_SET_PIN, LOW); +#endif +#endif + sd_power_mode_set(NRF_POWER_MODE_LOWPWR); +} + +void setCpuHighPower() +{ + LOG_DEBUG("Setting CPU to HIGH power\n"); + sd_power_mode_set(NRF_POWER_MODE_CONSTLAT); } \ No newline at end of file diff --git a/src/target_specific.h b/src/target_specific.h index 1e79df510b..7675419c48 100644 --- a/src/target_specific.h +++ b/src/target_specific.h @@ -7,4 +7,8 @@ // Enable/disable bluetooth. void setBluetoothEnable(bool on); -void getMacAddr(uint8_t *dmac); \ No newline at end of file +void getMacAddr(uint8_t *dmac); + +void setCpuHighPower(); + +void setCpuLowPower(); \ No newline at end of file