diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 2bdb8e176..849c38794 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -476,13 +476,6 @@ bool GPS::setup() } } - msglen = makeUBXPacket(0x06, 0x09, sizeof(_message_SAVE), _message_SAVE); - _serial_gps->write(UBXscratch, msglen); - if (getACK(0x06, 0x09, 2000) != GNSS_RESPONSE_OK) { - LOG_WARN("Unable to save GNSS module configuration.\n"); - } else { - LOG_INFO("GNSS module configuration saved!\n"); - } } else { // LOG_INFO("u-blox M10 hardware found.\n"); delay(1000); @@ -575,6 +568,13 @@ bool GPS::setup() // BBR will survive a restart, and power off for a while, but modules with small backup // batteries or super caps will not retain the config for a long power off time. } + msglen = makeUBXPacket(0x06, 0x09, sizeof(_message_SAVE), _message_SAVE); + _serial_gps->write(UBXscratch, msglen); + if (getACK(0x06, 0x09, 2000) != GNSS_RESPONSE_OK) { + LOG_WARN("Unable to save GNSS module configuration.\n"); + } else { + LOG_INFO("GNSS module configuration saved!\n"); + } } didSerialInit = true; } diff --git a/src/graphics/EInkDisplay2.cpp b/src/graphics/EInkDisplay2.cpp index d790e30c1..aee30c7f8 100644 --- a/src/graphics/EInkDisplay2.cpp +++ b/src/graphics/EInkDisplay2.cpp @@ -158,7 +158,7 @@ bool EInkDisplay::connect() } } -#elif defined(HELTEC_WIRELESS_PAPER_V1_0) +#elif defined(HELTEC_WIRELESS_PAPER_V1_0) || defined(HELTEC_WIRELESS_PAPER) { // Is this a normal boot, or a wake from deep sleep? esp_sleep_wakeup_cause_t wakeReason = esp_sleep_get_wakeup_cause(); @@ -194,19 +194,6 @@ bool EInkDisplay::connect() adafruitDisplay->init(); adafruitDisplay->setRotation(3); } -#elif defined(HELTEC_WIRELESS_PAPER) - { - hspi = new SPIClass(HSPI); - hspi->begin(PIN_EINK_SCLK, -1, PIN_EINK_MOSI, PIN_EINK_CS); // SCLK, MISO, MOSI, SS - delay(100); - pinMode(Vext, OUTPUT); - digitalWrite(Vext, LOW); - delay(100); - auto lowLevel = new EINK_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY, *hspi); - adafruitDisplay = new GxEPD2_BW(*lowLevel); - adafruitDisplay->init(); - adafruitDisplay->setRotation(3); - } #elif defined(PCA10059) { auto lowLevel = new EINK_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY); diff --git a/src/graphics/EInkDisplay2.h b/src/graphics/EInkDisplay2.h index 369378132..75770a3bc 100644 --- a/src/graphics/EInkDisplay2.h +++ b/src/graphics/EInkDisplay2.h @@ -5,7 +5,7 @@ #include "GxEPD2_BW.h" #include -#if defined(HELTEC_WIRELESS_PAPER_V1_0) +#if defined(HELTEC_WIRELESS_PAPER_V1_0) || defined(HELTEC_WIRELESS_PAPER) // Re-enable SPI after deep sleep: rtc_gpio_hold_dis() #include "driver/rtc_io.h" #endif diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 506adda5c..dc8d7540c 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -130,6 +130,9 @@ bool NodeDB::factoryReset() LOG_INFO("Performing factory reset!\n"); // first, remove the "/prefs" (this removes most prefs) rmDir("/prefs"); + if (FSCom.exists("/static/rangetest.csv") && !FSCom.remove("/static/rangetest.csv")) { + LOG_WARN("Could not remove rangetest.csv file\n"); + } // second, install default state (this will deal with the duplicate mac address issue) installDefaultDeviceState(); installDefaultConfig(); diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 4a6dc9007..1d6a2d96b 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -435,6 +435,7 @@ NodeNum Router::getNodeNum() */ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src) { + bool skipHandle = false; // Also, we should set the time from the ISR and it should have msec level resolution p->rx_time = getValidTime(RTCQualityFromNet); // store the arrival timestamp for the phone // Store a copy of encrypted packet for MQTT @@ -451,8 +452,17 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src) else printPacket("handleReceived(REMOTE)", p); + // Neighbor info module is disabled, ignore expensive neighbor info packets + if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag && + p->decoded.portnum == meshtastic_PortNum_NEIGHBORINFO_APP && + (!moduleConfig.has_neighbor_info || !moduleConfig.neighbor_info.enabled)) { + LOG_DEBUG("Neighbor info module is disabled, ignoring neighbor packet\n"); + cancelSending(p->from, p->id); + skipHandle = true; + } + // Publish received message to MQTT if we're not the original transmitter of the packet - if (moduleConfig.mqtt.enabled && getFrom(p) != nodeDB.getNodeNum() && mqtt) + if (!skipHandle && moduleConfig.mqtt.enabled && getFrom(p) != nodeDB.getNodeNum() && mqtt) mqtt->onSend(*p_encrypted, *p, p->channel); } else { printPacket("packet decoding failed or skipped (no PSK?)", p); @@ -461,7 +471,8 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src) packetPool.release(p_encrypted); // Release the encrypted packet // call modules here - MeshModule::callPlugins(*p, src); + if (!skipHandle) + MeshModule::callPlugins(*p, src); } void Router::perhapsHandleReceived(meshtastic_MeshPacket *p) diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index addff8966..4634f8fef 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -116,6 +116,11 @@ meshtastic_MeshPacket *PositionModule::allocReply() } localPosition.seq_number++; + if (localPosition.latitude_i == 0 && localPosition.longitude_i == 0) { + LOG_WARN("Skipping position send because lat/lon are zero!\n"); + return nullptr; + } + // lat/lon are unconditionally included - IF AVAILABLE! LOG_DEBUG("Sending location with precision %i\n", precision); if (precision < 32 && precision > 0) { @@ -176,11 +181,6 @@ meshtastic_MeshPacket *PositionModule::allocReply() LOG_INFO("Providing time to mesh %u\n", p.time); } - if (p.latitude_i == 0 && p.longitude_i == 0) { - LOG_WARN("Skipping position send because lat/lon are zero!\n"); - return nullptr; - } - LOG_INFO("Position reply: time=%i, latI=%i, lonI=%i\n", p.time, p.latitude_i, p.longitude_i); // TAK Tracker devices should send their position in a TAK packet over the ATAK port diff --git a/src/nimble/NimbleBluetooth.h b/src/nimble/NimbleBluetooth.h index 4080a7cbc..df2d3e45a 100644 --- a/src/nimble/NimbleBluetooth.h +++ b/src/nimble/NimbleBluetooth.h @@ -16,5 +16,5 @@ class NimbleBluetooth : BluetoothApi void startAdvertising(); }; -void setBluetoothEnable(bool on); -void clearNVS(); +void setBluetoothEnable(bool enable); +void clearNVS(); \ No newline at end of file diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp index c994eea48..f97f6d121 100644 --- a/src/platform/esp32/main-esp32.cpp +++ b/src/platform/esp32/main-esp32.cpp @@ -20,21 +20,21 @@ #if !defined(CONFIG_IDF_TARGET_ESP32S2) -void setBluetoothEnable(bool on) +void setBluetoothEnable(bool enable) { if (!isWifiAvailable() && config.bluetooth.enabled == true) { if (!nimbleBluetooth) { nimbleBluetooth = new NimbleBluetooth(); } - if (on && !nimbleBluetooth->isActive()) { + if (enable && !nimbleBluetooth->isActive()) { nimbleBluetooth->setup(); - } else if (!on) { + } else if (!enable) { nimbleBluetooth->shutdown(); } } } #else -void setBluetoothEnable(bool on) {} +void setBluetoothEnable(bool enable) {} void updateBatteryLevel(uint8_t level) {} #endif diff --git a/src/platform/nrf52/NRF52Bluetooth.cpp b/src/platform/nrf52/NRF52Bluetooth.cpp index dd81929c8..9a93f5cc6 100644 --- a/src/platform/nrf52/NRF52Bluetooth.cpp +++ b/src/platform/nrf52/NRF52Bluetooth.cpp @@ -210,8 +210,10 @@ void NRF52Bluetooth::shutdown() { // Shutdown bluetooth for minimum power draw LOG_INFO("Disable NRF52 bluetooth\n"); + if (connectionHandle != 0) { + Bluefruit.disconnect(connectionHandle); + } Bluefruit.Advertising.stop(); - Bluefruit.setTxPower(0); // Minimum power } bool NRF52Bluetooth::isConnected() @@ -289,6 +291,14 @@ void NRF52Bluetooth::setup() } } +void NRF52Bluetooth::resumeAdverising() +{ + Bluefruit.Advertising.restartOnDisconnect(true); + Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms + Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode + Bluefruit.Advertising.start(0); +} + /// Given a level between 0-100, update the BLE attribute void updateBatteryLevel(uint8_t level) { diff --git a/src/platform/nrf52/NRF52Bluetooth.h b/src/platform/nrf52/NRF52Bluetooth.h index 193e86cf8..fd27bbf04 100644 --- a/src/platform/nrf52/NRF52Bluetooth.h +++ b/src/platform/nrf52/NRF52Bluetooth.h @@ -8,6 +8,7 @@ class NRF52Bluetooth : BluetoothApi public: void setup(); void shutdown(); + void resumeAdverising(); void clearBonds(); bool isConnected(); int getRssi(); @@ -17,4 +18,4 @@ class NRF52Bluetooth : BluetoothApi void convertToUint8(uint8_t target[4], uint32_t source); static bool onPairingPasskey(uint16_t conn_handle, uint8_t const passkey[6], bool match_request); static void onPairingCompleted(uint16_t conn_handle, uint8_t auth_status); -}; +}; \ No newline at end of file diff --git a/src/platform/nrf52/main-nrf52.cpp b/src/platform/nrf52/main-nrf52.cpp index 63b014c46..9e8798e37 100644 --- a/src/platform/nrf52/main-nrf52.cpp +++ b/src/platform/nrf52/main-nrf52.cpp @@ -63,28 +63,29 @@ static void initBrownout() // We don't bother with setting up brownout if soft device is disabled - because during production we always use softdevice } -static bool bleOn = false; static const bool useSoftDevice = true; // Set to false for easier debugging -void setBluetoothEnable(bool on) +void setBluetoothEnable(bool enable) { - if (on != bleOn && config.bluetooth.enabled == true) { - if (on) { + if (enable && config.bluetooth.enabled) { + if (!useSoftDevice) { + LOG_INFO("DISABLING NRF52 BLUETOOTH WHILE DEBUGGING\n"); + } else { if (!nrf52Bluetooth) { - if (!useSoftDevice) - LOG_INFO("DISABLING NRF52 BLUETOOTH WHILE DEBUGGING\n"); - else { - nrf52Bluetooth = new NRF52Bluetooth(); - nrf52Bluetooth->setup(); + LOG_DEBUG("Initializing NRF52 Bluetooth\n"); + nrf52Bluetooth = new NRF52Bluetooth(); + nrf52Bluetooth->setup(); - // We delay brownout init until after BLE because BLE starts soft device - initBrownout(); - } + // We delay brownout init until after BLE because BLE starts soft device + initBrownout(); + } else { + nrf52Bluetooth->resumeAdverising(); } - } else if (nrf52Bluetooth) { + } + } else { + if (nrf52Bluetooth) { nrf52Bluetooth->shutdown(); } - bleOn = on; } } diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index c8fcc3d13..046509fab 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -20,7 +20,7 @@ std::map settingsStrings; char *configPath = nullptr; // FIXME - move setBluetoothEnable into a HALPlatform class -void setBluetoothEnable(bool on) +void setBluetoothEnable(bool enable) { // not needed } diff --git a/src/platform/rp2040/main-rp2040.cpp b/src/platform/rp2040/main-rp2040.cpp index 3359263e9..283b801f1 100644 --- a/src/platform/rp2040/main-rp2040.cpp +++ b/src/platform/rp2040/main-rp2040.cpp @@ -2,7 +2,7 @@ #include #include -void setBluetoothEnable(bool on) +void setBluetoothEnable(bool enable) { // not needed } diff --git a/src/platform/stm32wl/main-stm32wl.cpp b/src/platform/stm32wl/main-stm32wl.cpp index f57928c60..60c3cce10 100644 --- a/src/platform/stm32wl/main-stm32wl.cpp +++ b/src/platform/stm32wl/main-stm32wl.cpp @@ -3,7 +3,7 @@ #include #include -void setBluetoothEnable(bool on) {} +void setBluetoothEnable(bool enable) {} void playStartMelody() {} @@ -33,4 +33,4 @@ int _gettimeofday(struct timeval *tv, void *tzvp) { return -1; } -} +} \ No newline at end of file diff --git a/src/target_specific.h b/src/target_specific.h index 1e79df510..7404a3720 100644 --- a/src/target_specific.h +++ b/src/target_specific.h @@ -5,6 +5,6 @@ // Functions that are unique to particular target types (esp32, bare, nrf52 etc...) // Enable/disable bluetooth. -void setBluetoothEnable(bool on); +void setBluetoothEnable(bool enable); void getMacAddr(uint8_t *dmac); \ No newline at end of file diff --git a/variants/heltec_wireless_paper/platformio.ini b/variants/heltec_wireless_paper/platformio.ini index 56446dc8b..0abbe085e 100644 --- a/variants/heltec_wireless_paper/platformio.ini +++ b/variants/heltec_wireless_paper/platformio.ini @@ -8,9 +8,15 @@ build_flags = -D EINK_DISPLAY_MODEL=GxEPD2_213_FC1 -D EINK_WIDTH=250 -D EINK_HEIGHT=122 + -D USE_EINK_DYNAMICDISPLAY ; Enable Dynamic EInk + -D EINK_LIMIT_FASTREFRESH=10 ; How many consecutive fast-refreshes are permitted + -D EINK_LIMIT_RATE_BACKGROUND_SEC=30 ; Minimum interval between BACKGROUND updates + -D EINK_LIMIT_RATE_RESPONSIVE_SEC=1 ; Minimum interval between RESPONSIVE updates + -D EINK_LIMIT_GHOSTING_PX=2000 ; (Optional) How much image ghosting is tolerated + -D EINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached. lib_deps = ${esp32s3_base.lib_deps} - https://github.com/ixt/GxEPD2#39f325b677713eb04dfcc83b8e402e77523fb8bf + https://github.com/meshtastic/GxEPD2 adafruit/Adafruit BusIO@^1.13.2 lewisxhe/PCF8563_Library@^1.0.1 upload_speed = 115200 \ No newline at end of file diff --git a/variants/heltec_wireless_paper/variant.h b/variants/heltec_wireless_paper/variant.h index c2a030ed0..28bc8628a 100644 --- a/variants/heltec_wireless_paper/variant.h +++ b/variants/heltec_wireless_paper/variant.h @@ -5,6 +5,8 @@ #define I2C_SCL SCL #define USE_EINK +#define EINK_NO_HIBERNATE + /* * eink display pins */ diff --git a/variants/t-echo/variant.h b/variants/t-echo/variant.h index 345091c2f..1af68863e 100644 --- a/variants/t-echo/variant.h +++ b/variants/t-echo/variant.h @@ -43,9 +43,10 @@ extern "C" { #define NUM_ANALOG_OUTPUTS (0) // LEDs -#define PIN_LED1 (0 + 14) // blue (confirmed on boards marked v1.0, date 2021-6-28) -#define PIN_LED2 (32 + 1) // green -#define PIN_LED3 (32 + 3) // red +#define PIN_LED1 (0 + 14) // 13 red (confirmed on 1.0 board) +// Unused(by firmware) LEDs: +#define PIN_LED2 (0 + 15) // 14 blue +#define PIN_LED3 (0 + 13) // 15 green #define LED_RED PIN_LED3 #define LED_BLUE PIN_LED1