diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml
index 555d4d0927..0853df19f8 100644
--- a/.github/workflows/main_matrix.yml
+++ b/.github/workflows/main_matrix.yml
@@ -134,8 +134,8 @@ jobs:
package-raspbian-armv7l:
uses: ./.github/workflows/package_raspbian_armv7l.yml
- # package-native:
- # uses: ./.github/workflows/package_amd64.yml
+ package-native:
+ uses: ./.github/workflows/package_amd64.yml
after-checks:
runs-on: ubuntu-latest
@@ -249,7 +249,7 @@ jobs:
gather-artifacts,
package-raspbian,
package-raspbian-armv7l,
- # package-native,
+ package-native,
]
steps:
- name: Checkout
@@ -308,15 +308,15 @@ jobs:
asset_name: meshtasticd_${{ steps.version.outputs.version }}_armhf.deb
asset_content_type: application/vnd.debian.binary-package
- # - name: Add raspbian amd64 .deb
- # uses: actions/upload-release-asset@v1
- # env:
- # GITHUB_TOKEN: ${{ github.token }}
- # with:
- # upload_url: ${{ steps.create_release.outputs.upload_url }}
- # asset_path: ./output/meshtasticd_${{ steps.version.outputs.version }}_amd64.deb
- # asset_name: meshtasticd_${{ steps.version.outputs.version }}_amd64.deb
- # asset_content_type: application/vnd.debian.binary-package
+ - name: Add raspbian amd64 .deb
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ github.token }}
+ with:
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
+ asset_path: ./output/meshtasticd_${{ steps.version.outputs.version }}_amd64.deb
+ asset_name: meshtasticd_${{ steps.version.outputs.version }}_amd64.deb
+ asset_content_type: application/vnd.debian.binary-package
- name: Bump version.properties
run: >-
diff --git a/arch/rp2xx0/rp2040.ini b/arch/rp2xx0/rp2040.ini
index 5b4ec74d2d..c004a3becb 100644
--- a/arch/rp2xx0/rp2040.ini
+++ b/arch/rp2xx0/rp2040.ini
@@ -1,14 +1,16 @@
; Common settings for rp2040 Processor based targets
[rp2040_base]
-platform = https://github.com/maxgerhardt/platform-raspberrypi.git#60d6ae81fcc73c34b1493ca9e261695e471bc0c2
+platform = https://github.com/maxgerhardt/platform-raspberrypi.git#v1.2.0-gcc12
extends = arduino_base
-platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#3.7.2
+platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#4.0.3
board_build.core = earlephilhower
board_build.filesystem_size = 0.5m
build_flags =
${arduino_base.build_flags} -Wno-unused-variable -Wcast-align
-Isrc/platform/rp2xx0
+ -Isrc/platform/rp2xx0/hardware_rosc/include
+ -Isrc/platform/rp2xx0/pico_sleep/include
-D__PLAT_RP2040__
# -D _POSIX_THREADS
build_src_filter =
diff --git a/bin/config-dist.yaml b/bin/config-dist.yaml
index 3a470b7bbe..a755954b1f 100644
--- a/bin/config-dist.yaml
+++ b/bin/config-dist.yaml
@@ -20,6 +20,7 @@ Lora:
# CS: 0
# IRQ: 10
# Busy: 11
+# DIO2_AS_RF_SWITCH: true
# spidev: spidev0.1
# Module: RF95 # Adafruit RFM9x
@@ -154,4 +155,4 @@ Webserver:
General:
MaxNodes: 200
- MaxMessageQueue: 100
\ No newline at end of file
+ MaxMessageQueue: 100
diff --git a/bin/meshtasticd.service b/bin/meshtasticd.service
index f15fdc8714..1e8ee98b8a 100644
--- a/bin/meshtasticd.service
+++ b/bin/meshtasticd.service
@@ -1,12 +1,16 @@
[Unit]
Description=Meshtastic Native Daemon
After=network-online.target
+StartLimitInterval=200
+StartLimitBurst=5
[Service]
User=root
Group=root
Type=simple
ExecStart=/usr/sbin/meshtasticd
+Restart=always
+RestartSec=3
[Install]
-WantedBy=multi-user.target
\ No newline at end of file
+WantedBy=multi-user.target
diff --git a/bin/native-install.sh b/bin/native-install.sh
index ba71c4f46b..a8fcc29a6a 100755
--- a/bin/native-install.sh
+++ b/bin/native-install.sh
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
cp "release/meshtasticd_linux_$(uname -m)" /usr/sbin/meshtasticd
-mkdir /etc/meshtasticd
+mkdir -p /etc/meshtasticd
if [[ -f "/etc/meshtasticd/config.yaml" ]]; then
cp bin/config-dist.yaml /etc/meshtasticd/config-upgrade.yaml
else
diff --git a/images/compass.png b/images/compass.png
index 8639dde524..c4e5b589bc 100644
Binary files a/images/compass.png and b/images/compass.png differ
diff --git a/images/face-24px.svg b/images/face-24px.svg
index 293468664d..08e8f5ffcc 100644
--- a/images/face-24px.svg
+++ b/images/face-24px.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/images/face.png b/images/face.png
index 036e29f734..eb6b91e13b 100644
Binary files a/images/face.png and b/images/face.png differ
diff --git a/images/location_searching-24px.svg b/images/location_searching-24px.svg
index 7f72a31bc7..abef0ef788 100644
--- a/images/location_searching-24px.svg
+++ b/images/location_searching-24px.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/images/pin.png b/images/pin.png
index 112a7ce8ed..3c91a726c3 100644
Binary files a/images/pin.png and b/images/pin.png differ
diff --git a/images/room-24px.svg b/images/room-24px.svg
index 79a4807e7c..48e55ab80e 100644
--- a/images/room-24px.svg
+++ b/images/room-24px.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/images/textsms-24px.svg b/images/textsms-24px.svg
index 4455f047e3..84c4fdcc1d 100644
--- a/images/textsms-24px.svg
+++ b/images/textsms-24px.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/platformio.ini b/platformio.ini
index 5dcf61afdf..2e3ee56f95 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -27,6 +27,7 @@ default_envs = tbeam
;default_envs = meshtastic-dr-dev
;default_envs = m5stack-coreink
;default_envs = rak4631
+;default_envs = rak4631_eth_gw
;default_envs = rak2560
;default_envs = rak10701
;default_envs = wio-e5
@@ -95,7 +96,7 @@ lib_deps =
https://github.com/meshtastic/ArduinoThread.git#1ae8778c85d0a2a729f989e0b1e7d7c4dc84eef0
nanopb/Nanopb@^0.4.9
erriez/ErriezCRC32@^1.0.1
-
+
; Used for the code analysis in PIO Home / Inspect
check_tool = cppcheck
check_skip_packages = yes
@@ -152,6 +153,8 @@ lib_deps =
ClosedCube OPT3001@^1.1.2
emotibit/EmotiBit MLX90632@^1.0.8
dfrobot/DFRobot_RTU@^1.0.3
+ sparkfun/SparkFun MAX3010x Pulse and Proximity Sensor Library@^1.1.2
+ adafruit/Adafruit MLX90614 Library@^2.1.5
https://github.com/boschsensortec/Bosch-BSEC2-Library#v1.7.2502
boschsensortec/BME68x Sensor Library@^1.1.40407
diff --git a/protobufs b/protobufs
index c9ae7fd478..7dc7a6d219 160000
--- a/protobufs
+++ b/protobufs
@@ -1 +1 @@
-Subproject commit c9ae7fd478bffe5f954b30de6cb140821fe9ff52
+Subproject commit 7dc7a6d21991efe362c7cbb556573f6bb285e407
diff --git a/src/AmbientLightingThread.h b/src/AmbientLightingThread.h
index fdd4b53fac..07764e66e2 100644
--- a/src/AmbientLightingThread.h
+++ b/src/AmbientLightingThread.h
@@ -42,18 +42,18 @@ class AmbientLightingThread : public concurrency::OSThread
#ifdef HAS_NCP5623
_type = type;
if (_type == ScanI2C::DeviceType::NONE) {
- LOG_DEBUG("AmbientLightingThread disabling due to no RGB leds found on I2C bus\n");
+ LOG_DEBUG("AmbientLightingThread disabling due to no RGB leds found on I2C bus");
disable();
return;
}
#endif
#if defined(HAS_NCP5623) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE)
if (!moduleConfig.ambient_lighting.led_state) {
- LOG_DEBUG("AmbientLightingThread disabling due to moduleConfig.ambient_lighting.led_state OFF\n");
+ LOG_DEBUG("AmbientLightingThread disabling due to moduleConfig.ambient_lighting.led_state OFF");
disable();
return;
}
- LOG_DEBUG("AmbientLightingThread initializing\n");
+ LOG_DEBUG("AmbientLightingThread initializing");
#ifdef HAS_NCP5623
if (_type == ScanI2C::NCP5623) {
rgb.begin();
@@ -106,27 +106,27 @@ class AmbientLightingThread : public concurrency::OSThread
rgb.setRed(0);
rgb.setGreen(0);
rgb.setBlue(0);
- LOG_INFO("Turn Off NCP5623 Ambient lighting.\n");
+ LOG_INFO("Turn Off NCP5623 Ambient lighting.");
#endif
#ifdef HAS_NEOPIXEL
pixels.clear();
pixels.show();
- LOG_INFO("Turn Off NeoPixel Ambient lighting.\n");
+ LOG_INFO("Turn Off NeoPixel Ambient lighting.");
#endif
#ifdef RGBLED_CA
analogWrite(RGBLED_RED, 255 - 0);
analogWrite(RGBLED_GREEN, 255 - 0);
analogWrite(RGBLED_BLUE, 255 - 0);
- LOG_INFO("Turn Off Ambient lighting RGB Common Anode.\n");
+ LOG_INFO("Turn Off Ambient lighting RGB Common Anode.");
#elif defined(RGBLED_RED)
analogWrite(RGBLED_RED, 0);
analogWrite(RGBLED_GREEN, 0);
analogWrite(RGBLED_BLUE, 0);
- LOG_INFO("Turn Off Ambient lighting RGB Common Cathode.\n");
+ LOG_INFO("Turn Off Ambient lighting RGB Common Cathode.");
#endif
#ifdef UNPHONE
unphone.rgb(0, 0, 0);
- LOG_INFO("Turn Off unPhone Ambient lighting.\n");
+ LOG_INFO("Turn Off unPhone Ambient lighting.");
#endif
return 0;
}
@@ -138,7 +138,7 @@ class AmbientLightingThread : public concurrency::OSThread
rgb.setRed(moduleConfig.ambient_lighting.red);
rgb.setGreen(moduleConfig.ambient_lighting.green);
rgb.setBlue(moduleConfig.ambient_lighting.blue);
- LOG_DEBUG("Initializing NCP5623 Ambient lighting w/ current=%d, red=%d, green=%d, blue=%d\n",
+ LOG_DEBUG("Initializing NCP5623 Ambient lighting w/ current=%d, red=%d, green=%d, blue=%d",
moduleConfig.ambient_lighting.current, moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green,
moduleConfig.ambient_lighting.blue);
#endif
@@ -158,7 +158,7 @@ class AmbientLightingThread : public concurrency::OSThread
#endif
#endif
pixels.show();
- LOG_DEBUG("Initializing NeoPixel Ambient lighting w/ brightness(current)=%d, red=%d, green=%d, blue=%d\n",
+ LOG_DEBUG("Initializing NeoPixel Ambient lighting w/ brightness(current)=%d, red=%d, green=%d, blue=%d",
moduleConfig.ambient_lighting.current, moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green,
moduleConfig.ambient_lighting.blue);
#endif
@@ -166,18 +166,18 @@ class AmbientLightingThread : public concurrency::OSThread
analogWrite(RGBLED_RED, 255 - moduleConfig.ambient_lighting.red);
analogWrite(RGBLED_GREEN, 255 - moduleConfig.ambient_lighting.green);
analogWrite(RGBLED_BLUE, 255 - moduleConfig.ambient_lighting.blue);
- LOG_DEBUG("Initializing Ambient lighting RGB Common Anode w/ red=%d, green=%d, blue=%d\n",
+ LOG_DEBUG("Initializing Ambient lighting RGB Common Anode w/ red=%d, green=%d, blue=%d",
moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue);
#elif defined(RGBLED_RED)
analogWrite(RGBLED_RED, moduleConfig.ambient_lighting.red);
analogWrite(RGBLED_GREEN, moduleConfig.ambient_lighting.green);
analogWrite(RGBLED_BLUE, moduleConfig.ambient_lighting.blue);
- LOG_DEBUG("Initializing Ambient lighting RGB Common Cathode w/ red=%d, green=%d, blue=%d\n",
+ LOG_DEBUG("Initializing Ambient lighting RGB Common Cathode w/ red=%d, green=%d, blue=%d",
moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue);
#endif
#ifdef UNPHONE
unphone.rgb(moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue);
- LOG_DEBUG("Initializing unPhone Ambient lighting w/ red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.red,
+ LOG_DEBUG("Initializing unPhone Ambient lighting w/ red=%d, green=%d, blue=%d", moduleConfig.ambient_lighting.red,
moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue);
#endif
}
diff --git a/src/ButtonThread.cpp b/src/ButtonThread.cpp
index 9e6ef55f51..ca4d40e158 100644
--- a/src/ButtonThread.cpp
+++ b/src/ButtonThread.cpp
@@ -36,7 +36,7 @@ ButtonThread::ButtonThread() : OSThread("Button")
#if defined(ARCH_PORTDUINO)
if (settingsMap.count(user) != 0 && settingsMap[user] != RADIOLIB_NC) {
this->userButton = OneButton(settingsMap[user], true, true);
- LOG_DEBUG("Using GPIO%02d for button\n", settingsMap[user]);
+ LOG_DEBUG("Using GPIO%02d for button", settingsMap[user]);
}
#elif defined(BUTTON_PIN)
int pin = config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN; // Resolved button pin
@@ -47,7 +47,7 @@ ButtonThread::ButtonThread() : OSThread("Button")
#else
this->userButton = OneButton(pin, true, true);
#endif
- LOG_DEBUG("Using GPIO%02d for button\n", pin);
+ LOG_DEBUG("Using GPIO%02d for button", pin);
#endif
#ifdef INPUT_PULLUP_SENSE
@@ -123,7 +123,7 @@ int32_t ButtonThread::runOnce()
if (btnEvent != BUTTON_EVENT_NONE) {
switch (btnEvent) {
case BUTTON_EVENT_PRESSED: {
- LOG_BUTTON("press!\n");
+ LOG_BUTTON("press!");
// If a nag notification is running, stop it and prevent other actions
if (moduleConfig.external_notification.enabled && (externalNotificationModule->nagCycleCutoff != UINT32_MAX)) {
externalNotificationModule->stopNow();
@@ -148,7 +148,7 @@ int32_t ButtonThread::runOnce()
}
case BUTTON_EVENT_DOUBLE_PRESSED: {
- LOG_BUTTON("Double press!\n");
+ LOG_BUTTON("Double press!");
service->refreshLocalMeshNode();
auto sentPosition = service->trySendPosition(NODENUM_BROADCAST, true);
if (screen) {
@@ -162,7 +162,7 @@ int32_t ButtonThread::runOnce()
}
case BUTTON_EVENT_MULTI_PRESSED: {
- LOG_BUTTON("Mulitipress! %hux\n", multipressClickCount);
+ LOG_BUTTON("Mulitipress! %hux", multipressClickCount);
switch (multipressClickCount) {
#if HAS_GPS
// 3 clicks: toggle GPS
@@ -189,7 +189,7 @@ int32_t ButtonThread::runOnce()
} // end multipress event
case BUTTON_EVENT_LONG_PRESSED: {
- LOG_BUTTON("Long press!\n");
+ LOG_BUTTON("Long press!");
powerFSM.trigger(EVENT_PRESS);
if (screen) {
screen->startAlert("Shutting down...");
@@ -201,7 +201,7 @@ int32_t ButtonThread::runOnce()
// Do actual shutdown when button released, otherwise the button release
// may wake the board immediatedly.
case BUTTON_EVENT_LONG_RELEASED: {
- LOG_INFO("Shutdown from long press\n");
+ LOG_INFO("Shutdown from long press");
playShutdownMelody();
delay(3000);
power->shutdown();
@@ -210,7 +210,7 @@ int32_t ButtonThread::runOnce()
#ifdef BUTTON_PIN_TOUCH
case BUTTON_EVENT_TOUCH_LONG_PRESSED: {
- LOG_BUTTON("Touch press!\n");
+ LOG_BUTTON("Touch press!");
if (screen) {
// Wake if asleep
if (powerFSM.getState() == &stateDARK)
diff --git a/src/FSCommon.cpp b/src/FSCommon.cpp
index 24d3f477e6..cea1130aaa 100644
--- a/src/FSCommon.cpp
+++ b/src/FSCommon.cpp
@@ -53,7 +53,7 @@ bool lfs_assert_failed =
extern "C" void lfs_assert(const char *reason)
{
- LOG_ERROR("LFS assert: %s\n", reason);
+ LOG_ERROR("LFS assert: %s", reason);
lfs_assert_failed = true;
}
@@ -75,19 +75,19 @@ bool copyFile(const char *from, const char *to)
r = OSFS::getFile(from, cbuffer);
if (r == notfound) {
- LOG_ERROR("Failed to open source file %s\n", from);
+ LOG_ERROR("Failed to open source file %s", from);
return false;
} else if (r == noerr) {
r = OSFS::newFile(to, cbuffer, true);
if (r == noerr) {
return true;
} else {
- LOG_ERROR("OSFS Error %d\n", r);
+ LOG_ERROR("OSFS Error %d", r);
return false;
}
} else {
- LOG_ERROR("OSFS Error %d\n", r);
+ LOG_ERROR("OSFS Error %d", r);
return false;
}
return true;
@@ -97,13 +97,13 @@ bool copyFile(const char *from, const char *to)
File f1 = FSCom.open(from, FILE_O_READ);
if (!f1) {
- LOG_ERROR("Failed to open source file %s\n", from);
+ LOG_ERROR("Failed to open source file %s", from);
return false;
}
File f2 = FSCom.open(to, FILE_O_WRITE);
if (!f2) {
- LOG_ERROR("Failed to open destination file %s\n", to);
+ LOG_ERROR("Failed to open destination file %s", to);
return false;
}
@@ -231,7 +231,7 @@ void listDir(const char *dirname, uint8_t levels, bool del)
#ifdef ARCH_ESP32
listDir(file.path(), levels - 1, del);
if (del) {
- LOG_DEBUG("Removing %s\n", file.path());
+ LOG_DEBUG("Removing %s", file.path());
strncpy(buffer, file.path(), sizeof(buffer));
file.close();
FSCom.rmdir(buffer);
@@ -241,7 +241,7 @@ void listDir(const char *dirname, uint8_t levels, bool del)
#elif (defined(ARCH_RP2040) || defined(ARCH_PORTDUINO))
listDir(file.name(), levels - 1, del);
if (del) {
- LOG_DEBUG("Removing %s\n", file.name());
+ LOG_DEBUG("Removing %s", file.name());
strncpy(buffer, file.name(), sizeof(buffer));
file.close();
FSCom.rmdir(buffer);
@@ -249,7 +249,7 @@ void listDir(const char *dirname, uint8_t levels, bool del)
file.close();
}
#else
- LOG_DEBUG(" %s (directory)\n", file.name());
+ LOG_DEBUG(" %s (directory)", file.name());
listDir(file.name(), levels - 1, del);
file.close();
#endif
@@ -257,26 +257,26 @@ void listDir(const char *dirname, uint8_t levels, bool del)
} else {
#ifdef ARCH_ESP32
if (del) {
- LOG_DEBUG("Deleting %s\n", file.path());
+ LOG_DEBUG("Deleting %s", file.path());
strncpy(buffer, file.path(), sizeof(buffer));
file.close();
FSCom.remove(buffer);
} else {
- LOG_DEBUG(" %s (%i Bytes)\n", file.path(), file.size());
+ LOG_DEBUG(" %s (%i Bytes)", file.path(), file.size());
file.close();
}
#elif (defined(ARCH_RP2040) || defined(ARCH_PORTDUINO))
if (del) {
- LOG_DEBUG("Deleting %s\n", file.name());
+ LOG_DEBUG("Deleting %s", file.name());
strncpy(buffer, file.name(), sizeof(buffer));
file.close();
FSCom.remove(buffer);
} else {
- LOG_DEBUG(" %s (%i Bytes)\n", file.name(), file.size());
+ LOG_DEBUG(" %s (%i Bytes)", file.name(), file.size());
file.close();
}
#else
- LOG_DEBUG(" %s (%i Bytes)\n", file.name(), file.size());
+ LOG_DEBUG(" %s (%i Bytes)", file.name(), file.size());
file.close();
#endif
}
@@ -284,7 +284,7 @@ void listDir(const char *dirname, uint8_t levels, bool del)
}
#ifdef ARCH_ESP32
if (del) {
- LOG_DEBUG("Removing %s\n", root.path());
+ LOG_DEBUG("Removing %s", root.path());
strncpy(buffer, root.path(), sizeof(buffer));
root.close();
FSCom.rmdir(buffer);
@@ -293,7 +293,7 @@ void listDir(const char *dirname, uint8_t levels, bool del)
}
#elif (defined(ARCH_RP2040) || defined(ARCH_PORTDUINO))
if (del) {
- LOG_DEBUG("Removing %s\n", root.name());
+ LOG_DEBUG("Removing %s", root.name());
strncpy(buffer, root.name(), sizeof(buffer));
root.close();
FSCom.rmdir(buffer);
@@ -329,13 +329,13 @@ void fsInit()
{
#ifdef FSCom
if (!FSBegin()) {
- LOG_ERROR("Filesystem mount Failed.\n");
+ LOG_ERROR("Filesystem mount Failed.");
// assert(0); This auto-formats the partition, so no need to fail here.
}
#if defined(ARCH_ESP32)
- LOG_DEBUG("Filesystem files (%d/%d Bytes):\n", FSCom.usedBytes(), FSCom.totalBytes());
+ LOG_DEBUG("Filesystem files (%d/%d Bytes):", FSCom.usedBytes(), FSCom.totalBytes());
#else
- LOG_DEBUG("Filesystem files:\n");
+ LOG_DEBUG("Filesystem files:");
#endif
listDir("/", 10);
#endif
@@ -350,28 +350,28 @@ void setupSDCard()
SDHandler.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
if (!SD.begin(SDCARD_CS, SDHandler)) {
- LOG_DEBUG("No SD_MMC card detected\n");
+ LOG_DEBUG("No SD_MMC card detected");
return;
}
uint8_t cardType = SD.cardType();
if (cardType == CARD_NONE) {
- LOG_DEBUG("No SD_MMC card attached\n");
+ LOG_DEBUG("No SD_MMC card attached");
return;
}
LOG_DEBUG("SD_MMC Card Type: ");
if (cardType == CARD_MMC) {
- LOG_DEBUG("MMC\n");
+ LOG_DEBUG("MMC");
} else if (cardType == CARD_SD) {
- LOG_DEBUG("SDSC\n");
+ LOG_DEBUG("SDSC");
} else if (cardType == CARD_SDHC) {
- LOG_DEBUG("SDHC\n");
+ LOG_DEBUG("SDHC");
} else {
- LOG_DEBUG("UNKNOWN\n");
+ LOG_DEBUG("UNKNOWN");
}
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
- LOG_DEBUG("SD Card Size: %lu MB\n", (uint32_t)cardSize);
- LOG_DEBUG("Total space: %lu MB\n", (uint32_t)(SD.totalBytes() / (1024 * 1024)));
- LOG_DEBUG("Used space: %lu MB\n", (uint32_t)(SD.usedBytes() / (1024 * 1024)));
+ LOG_DEBUG("SD Card Size: %lu MB", (uint32_t)cardSize);
+ LOG_DEBUG("Total space: %lu MB", (uint32_t)(SD.totalBytes() / (1024 * 1024)));
+ LOG_DEBUG("Used space: %lu MB", (uint32_t)(SD.usedBytes() / (1024 * 1024)));
#endif
}
\ No newline at end of file
diff --git a/src/GPSStatus.h b/src/GPSStatus.h
index c2ab16c86f..12f302baa8 100644
--- a/src/GPSStatus.h
+++ b/src/GPSStatus.h
@@ -51,7 +51,7 @@ class GPSStatus : public Status
{
if (config.position.fixed_position) {
#ifdef GPS_EXTRAVERBOSE
- LOG_WARN("Using fixed latitude\n");
+ LOG_WARN("Using fixed latitude");
#endif
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeDB->getNodeNum());
return node->position.latitude_i;
@@ -64,7 +64,7 @@ class GPSStatus : public Status
{
if (config.position.fixed_position) {
#ifdef GPS_EXTRAVERBOSE
- LOG_WARN("Using fixed longitude\n");
+ LOG_WARN("Using fixed longitude");
#endif
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeDB->getNodeNum());
return node->position.longitude_i;
@@ -77,7 +77,7 @@ class GPSStatus : public Status
{
if (config.position.fixed_position) {
#ifdef GPS_EXTRAVERBOSE
- LOG_WARN("Using fixed altitude\n");
+ LOG_WARN("Using fixed altitude");
#endif
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeDB->getNodeNum());
return node->position.altitude;
@@ -95,7 +95,7 @@ class GPSStatus : public Status
bool matches(const GPSStatus *newStatus) const
{
#ifdef GPS_EXTRAVERBOSE
- LOG_DEBUG("GPSStatus.match() new pos@%x to old pos@%x\n", newStatus->p.timestamp, p.timestamp);
+ LOG_DEBUG("GPSStatus.match() new pos@%x to old pos@%x", newStatus->p.timestamp, p.timestamp);
#endif
return (newStatus->hasLock != hasLock || newStatus->isConnected != isConnected ||
newStatus->isPowerSaving != isPowerSaving || newStatus->p.latitude_i != p.latitude_i ||
@@ -112,7 +112,7 @@ class GPSStatus : public Status
if (isDirty && p.timestamp && (newStatus->p.timestamp == p.timestamp)) {
// We can NEVER be in two locations at the same time! (also PR #886)
- LOG_ERROR("BUG: Positional timestamp unchanged from prev solution\n");
+ LOG_ERROR("BUG: Positional timestamp unchanged from prev solution");
}
initialized = true;
@@ -124,11 +124,11 @@ class GPSStatus : public Status
if (isDirty) {
if (hasLock) {
// In debug logs, identify position by @timestamp:stage (stage 3 = notify)
- LOG_DEBUG("New GPS pos@%x:3 lat=%f lon=%f alt=%d pdop=%.2f track=%.2f speed=%.2f sats=%d\n", p.timestamp,
+ LOG_DEBUG("New GPS pos@%x:3 lat=%f lon=%f alt=%d pdop=%.2f track=%.2f speed=%.2f sats=%d", p.timestamp,
p.latitude_i * 1e-7, p.longitude_i * 1e-7, p.altitude, p.PDOP * 1e-2, p.ground_track * 1e-5,
p.ground_speed * 1e-2, p.sats_in_view);
} else {
- LOG_DEBUG("No GPS lock\n");
+ LOG_DEBUG("No GPS lock");
}
onNewStatus.notifyObservers(this);
}
diff --git a/src/GpioLogic.cpp b/src/GpioLogic.cpp
index cbe26fc600..ba01d482da 100644
--- a/src/GpioLogic.cpp
+++ b/src/GpioLogic.cpp
@@ -12,7 +12,7 @@ void GpioVirtPin::set(bool value)
void GpioHwPin::set(bool value)
{
- // if (num == 3) LOG_DEBUG("Setting pin %d to %d\n", num, value);
+ // if (num == 3) LOG_DEBUG("Setting pin %d to %d", num, value);
pinMode(num, OUTPUT);
digitalWrite(num, value);
}
@@ -88,7 +88,7 @@ void GpioBinaryTransformer::update()
newValue = (GpioVirtPin::PinState)(p1 && p2);
break;
case Or:
- // LOG_DEBUG("Doing GPIO OR\n");
+ // LOG_DEBUG("Doing GPIO OR");
newValue = (GpioVirtPin::PinState)(p1 || p2);
break;
case Xor:
diff --git a/src/NodeStatus.h b/src/NodeStatus.h
index e6bf31aed1..60d1bdd982 100644
--- a/src/NodeStatus.h
+++ b/src/NodeStatus.h
@@ -56,7 +56,7 @@ class NodeStatus : public Status
numTotal = newStatus->getNumTotal();
}
if (isDirty || newStatus->forceUpdate) {
- LOG_DEBUG("Node status update: %d online, %d total\n", numOnline, numTotal);
+ LOG_DEBUG("Node status update: %d online, %d total", numOnline, numTotal);
onNewStatus.notifyObservers(this);
}
return 0;
diff --git a/src/Power.cpp b/src/Power.cpp
index 2f5f441ae3..02a07e620c 100644
--- a/src/Power.cpp
+++ b/src/Power.cpp
@@ -240,7 +240,7 @@ class AnalogBatteryLevel : public HasBatteryLevel
#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(HAS_PMU) && \
!MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
if (hasINA()) {
- LOG_DEBUG("Using INA on I2C addr 0x%x for device battery voltage\n", config.power.device_battery_ina_address);
+ LOG_DEBUG("Using INA on I2C addr 0x%x for device battery voltage", config.power.device_battery_ina_address);
return getINAVoltage();
}
#endif
@@ -290,7 +290,7 @@ class AnalogBatteryLevel : public HasBatteryLevel
last_read_value += (scaled - last_read_value) * 0.5; // Virtual LPF
}
- // LOG_DEBUG("battery gpio %d raw val=%u scaled=%u filtered=%u\n", BATTERY_PIN, raw, (uint32_t)(scaled), (uint32_t)
+ // LOG_DEBUG("battery gpio %d raw val=%u scaled=%u filtered=%u", BATTERY_PIN, raw, (uint32_t)(scaled), (uint32_t)
// (last_read_value));
}
return last_read_value;
@@ -335,7 +335,7 @@ class AnalogBatteryLevel : public HasBatteryLevel
raw += adc_buf;
raw_c++; // Count valid samples
} else {
- LOG_DEBUG("An attempt to sample ADC2 failed\n");
+ LOG_DEBUG("An attempt to sample ADC2 failed");
}
}
@@ -360,7 +360,12 @@ class AnalogBatteryLevel : public HasBatteryLevel
/**
* return true if there is a battery installed in this unit
*/
+ // if we have a integrated device with a battery, we can assume that the battery is always connected
+#ifdef BATTERY_IMMUTABLE
+ virtual bool isBatteryConnect() override { return true; }
+#else
virtual bool isBatteryConnect() override { return getBatteryPercent() != -1; }
+#endif
/// If we see a battery voltage higher than physics allows - assume charger is pumping
/// in power
@@ -495,7 +500,7 @@ bool Power::analogInit()
#endif
#ifdef BATTERY_PIN
- LOG_DEBUG("Using analog input %d for battery level\n", BATTERY_PIN);
+ LOG_DEBUG("Using analog input %d for battery level", BATTERY_PIN);
// disable any internal pullups
pinMode(BATTERY_PIN, INPUT);
@@ -526,18 +531,18 @@ bool Power::analogInit()
esp_adc_cal_value_t val_type = esp_adc_cal_characterize(unit, atten, width, DEFAULT_VREF, adc_characs);
// show ADC characterization base
if (val_type == ESP_ADC_CAL_VAL_EFUSE_TP) {
- LOG_INFO("ADCmod: ADC characterization based on Two Point values stored in eFuse\n");
+ LOG_INFO("ADCmod: ADC characterization based on Two Point values stored in eFuse");
} else if (val_type == ESP_ADC_CAL_VAL_EFUSE_VREF) {
- LOG_INFO("ADCmod: ADC characterization based on reference voltage stored in eFuse\n");
+ LOG_INFO("ADCmod: ADC characterization based on reference voltage stored in eFuse");
}
#ifdef CONFIG_IDF_TARGET_ESP32S3
// ESP32S3
else if (val_type == ESP_ADC_CAL_VAL_EFUSE_TP_FIT) {
- LOG_INFO("ADCmod: ADC Characterization based on Two Point values and fitting curve coefficients stored in eFuse\n");
+ LOG_INFO("ADCmod: ADC Characterization based on Two Point values and fitting curve coefficients stored in eFuse");
}
#endif
else {
- LOG_INFO("ADCmod: ADC characterization based on default reference voltage\n");
+ LOG_INFO("ADCmod: ADC characterization based on default reference voltage");
}
#endif // ARCH_ESP32
@@ -586,9 +591,9 @@ bool Power::setup()
void Power::shutdown()
{
- LOG_INFO("Shutting down\n");
+ LOG_INFO("Shutting down");
-#if defined(ARCH_NRF52) || defined(ARCH_ESP32)
+#if defined(ARCH_NRF52) || defined(ARCH_ESP32) || defined(ARCH_RP2040)
#ifdef PIN_LED1
ledOff(PIN_LED1);
#endif
@@ -641,7 +646,7 @@ void Power::readPowerStatus()
// changes.
nrfx_power_usb_state_t nrf_usb_state = nrfx_power_usbstatus_get();
- // LOG_DEBUG("NRF Power %d\n", nrf_usb_state);
+ // LOG_DEBUG("NRF Power %d", nrf_usb_state);
// If changed to DISCONNECTED
if (nrf_usb_state == NRFX_POWER_USB_STATE_DISCONNECTED)
@@ -654,22 +659,22 @@ void Power::readPowerStatus()
// Notify any status instances that are observing us
const PowerStatus powerStatus2 = PowerStatus(hasBattery, usbPowered, isCharging, batteryVoltageMv, batteryChargePercent);
- LOG_DEBUG("Battery: usbPower=%d, isCharging=%d, batMv=%d, batPct=%d\n", powerStatus2.getHasUSB(),
- powerStatus2.getIsCharging(), powerStatus2.getBatteryVoltageMv(), powerStatus2.getBatteryChargePercent());
+ LOG_DEBUG("Battery: usbPower=%d, isCharging=%d, batMv=%d, batPct=%d", powerStatus2.getHasUSB(), powerStatus2.getIsCharging(),
+ powerStatus2.getBatteryVoltageMv(), powerStatus2.getBatteryChargePercent());
newStatus.notifyObservers(&powerStatus2);
#ifdef DEBUG_HEAP
if (lastheap != memGet.getFreeHeap()) {
- LOG_DEBUG("Threads running:");
+ std::string threadlist = "Threads running:";
int running = 0;
for (int i = 0; i < MAX_THREADS; i++) {
auto thread = concurrency::mainController.get(i);
if ((thread != nullptr) && (thread->enabled)) {
- LOG_DEBUG(" %s", thread->ThreadName.c_str());
+ threadlist += vformat(" %s", thread->ThreadName.c_str());
running++;
}
}
- LOG_DEBUG("\n");
- LOG_DEBUG("Heap status: %d/%d bytes free (%d), running %d/%d threads\n", memGet.getFreeHeap(), memGet.getHeapSize(),
+ LOG_DEBUG(threadlist.c_str());
+ LOG_DEBUG("Heap status: %d/%d bytes free (%d), running %d/%d threads", memGet.getFreeHeap(), memGet.getHeapSize(),
memGet.getFreeHeap() - lastheap, running, concurrency::mainController.size(false));
lastheap = memGet.getFreeHeap();
}
@@ -702,13 +707,13 @@ void Power::readPowerStatus()
if (batteryLevel && powerStatus2.getHasBattery() && !powerStatus2.getHasUSB()) {
if (batteryLevel->getBattVoltage() < OCV[NUM_OCV_POINTS - 1]) {
low_voltage_counter++;
- LOG_DEBUG("Low voltage counter: %d/10\n", low_voltage_counter);
+ LOG_DEBUG("Low voltage counter: %d/10", low_voltage_counter);
if (low_voltage_counter > 10) {
#ifdef ARCH_NRF52
// We can't trigger deep sleep on NRF52, it's freezing the board
- LOG_DEBUG("Low voltage detected, but not triggering deep sleep\n");
+ LOG_DEBUG("Low voltage detected, but not triggering deep sleep");
#else
- LOG_INFO("Low voltage detected, triggering deep sleep\n");
+ LOG_INFO("Low voltage detected, triggering deep sleep");
powerFSM.trigger(EVENT_LOW_BATTERY);
#endif
}
@@ -730,12 +735,12 @@ int32_t Power::runOnce()
PMU->getIrqStatus();
if (PMU->isVbusRemoveIrq()) {
- LOG_INFO("USB unplugged\n");
+ LOG_INFO("USB unplugged");
powerFSM.trigger(EVENT_POWER_DISCONNECTED);
}
if (PMU->isVbusInsertIrq()) {
- LOG_INFO("USB plugged In\n");
+ LOG_INFO("USB plugged In");
powerFSM.trigger(EVENT_POWER_CONNECTED);
}
@@ -743,21 +748,21 @@ int32_t Power::runOnce()
Other things we could check if we cared...
if (PMU->isBatChagerStartIrq()) {
- LOG_DEBUG("Battery start charging\n");
+ LOG_DEBUG("Battery start charging");
}
if (PMU->isBatChagerDoneIrq()) {
- LOG_DEBUG("Battery fully charged\n");
+ LOG_DEBUG("Battery fully charged");
}
if (PMU->isBatInsertIrq()) {
- LOG_DEBUG("Battery inserted\n");
+ LOG_DEBUG("Battery inserted");
}
if (PMU->isBatRemoveIrq()) {
- LOG_DEBUG("Battery removed\n");
+ LOG_DEBUG("Battery removed");
}
*/
#ifndef T_WATCH_S3 // FIXME - why is this triggering on the T-Watch S3?
if (PMU->isPekeyLongPressIrq()) {
- LOG_DEBUG("PEK long button press\n");
+ LOG_DEBUG("PEK long button press");
screen->setOn(false);
}
#endif
@@ -800,22 +805,22 @@ bool Power::axpChipInit()
if (!PMU) {
PMU = new XPowersAXP2101(*w);
if (!PMU->init()) {
- LOG_WARN("Failed to find AXP2101 power management\n");
+ LOG_WARN("Failed to find AXP2101 power management");
delete PMU;
PMU = NULL;
} else {
- LOG_INFO("AXP2101 PMU init succeeded, using AXP2101 PMU\n");
+ LOG_INFO("AXP2101 PMU init succeeded, using AXP2101 PMU");
}
}
if (!PMU) {
PMU = new XPowersAXP192(*w);
if (!PMU->init()) {
- LOG_WARN("Failed to find AXP192 power management\n");
+ LOG_WARN("Failed to find AXP192 power management");
delete PMU;
PMU = NULL;
} else {
- LOG_INFO("AXP192 PMU init succeeded, using AXP192 PMU\n");
+ LOG_INFO("AXP192 PMU init succeeded, using AXP192 PMU");
}
}
@@ -972,51 +977,51 @@ bool Power::axpChipInit()
PMU->enableBattVoltageMeasure();
if (PMU->isChannelAvailable(XPOWERS_DCDC1)) {
- LOG_DEBUG("DC1 : %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_DCDC1) ? "+" : "-",
+ LOG_DEBUG("DC1 : %s Voltage:%u mV ", PMU->isPowerChannelEnable(XPOWERS_DCDC1) ? "+" : "-",
PMU->getPowerChannelVoltage(XPOWERS_DCDC1));
}
if (PMU->isChannelAvailable(XPOWERS_DCDC2)) {
- LOG_DEBUG("DC2 : %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_DCDC2) ? "+" : "-",
+ LOG_DEBUG("DC2 : %s Voltage:%u mV ", PMU->isPowerChannelEnable(XPOWERS_DCDC2) ? "+" : "-",
PMU->getPowerChannelVoltage(XPOWERS_DCDC2));
}
if (PMU->isChannelAvailable(XPOWERS_DCDC3)) {
- LOG_DEBUG("DC3 : %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_DCDC3) ? "+" : "-",
+ LOG_DEBUG("DC3 : %s Voltage:%u mV ", PMU->isPowerChannelEnable(XPOWERS_DCDC3) ? "+" : "-",
PMU->getPowerChannelVoltage(XPOWERS_DCDC3));
}
if (PMU->isChannelAvailable(XPOWERS_DCDC4)) {
- LOG_DEBUG("DC4 : %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_DCDC4) ? "+" : "-",
+ LOG_DEBUG("DC4 : %s Voltage:%u mV ", PMU->isPowerChannelEnable(XPOWERS_DCDC4) ? "+" : "-",
PMU->getPowerChannelVoltage(XPOWERS_DCDC4));
}
if (PMU->isChannelAvailable(XPOWERS_LDO2)) {
- LOG_DEBUG("LDO2 : %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_LDO2) ? "+" : "-",
+ LOG_DEBUG("LDO2 : %s Voltage:%u mV ", PMU->isPowerChannelEnable(XPOWERS_LDO2) ? "+" : "-",
PMU->getPowerChannelVoltage(XPOWERS_LDO2));
}
if (PMU->isChannelAvailable(XPOWERS_LDO3)) {
- LOG_DEBUG("LDO3 : %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_LDO3) ? "+" : "-",
+ LOG_DEBUG("LDO3 : %s Voltage:%u mV ", PMU->isPowerChannelEnable(XPOWERS_LDO3) ? "+" : "-",
PMU->getPowerChannelVoltage(XPOWERS_LDO3));
}
if (PMU->isChannelAvailable(XPOWERS_ALDO1)) {
- LOG_DEBUG("ALDO1: %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_ALDO1) ? "+" : "-",
+ LOG_DEBUG("ALDO1: %s Voltage:%u mV ", PMU->isPowerChannelEnable(XPOWERS_ALDO1) ? "+" : "-",
PMU->getPowerChannelVoltage(XPOWERS_ALDO1));
}
if (PMU->isChannelAvailable(XPOWERS_ALDO2)) {
- LOG_DEBUG("ALDO2: %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_ALDO2) ? "+" : "-",
+ LOG_DEBUG("ALDO2: %s Voltage:%u mV ", PMU->isPowerChannelEnable(XPOWERS_ALDO2) ? "+" : "-",
PMU->getPowerChannelVoltage(XPOWERS_ALDO2));
}
if (PMU->isChannelAvailable(XPOWERS_ALDO3)) {
- LOG_DEBUG("ALDO3: %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_ALDO3) ? "+" : "-",
+ LOG_DEBUG("ALDO3: %s Voltage:%u mV ", PMU->isPowerChannelEnable(XPOWERS_ALDO3) ? "+" : "-",
PMU->getPowerChannelVoltage(XPOWERS_ALDO3));
}
if (PMU->isChannelAvailable(XPOWERS_ALDO4)) {
- LOG_DEBUG("ALDO4: %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_ALDO4) ? "+" : "-",
+ LOG_DEBUG("ALDO4: %s Voltage:%u mV ", PMU->isPowerChannelEnable(XPOWERS_ALDO4) ? "+" : "-",
PMU->getPowerChannelVoltage(XPOWERS_ALDO4));
}
if (PMU->isChannelAvailable(XPOWERS_BLDO1)) {
- LOG_DEBUG("BLDO1: %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_BLDO1) ? "+" : "-",
+ LOG_DEBUG("BLDO1: %s Voltage:%u mV ", PMU->isPowerChannelEnable(XPOWERS_BLDO1) ? "+" : "-",
PMU->getPowerChannelVoltage(XPOWERS_BLDO1));
}
if (PMU->isChannelAvailable(XPOWERS_BLDO2)) {
- LOG_DEBUG("BLDO2: %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_BLDO2) ? "+" : "-",
+ LOG_DEBUG("BLDO2: %s Voltage:%u mV ", PMU->isPowerChannelEnable(XPOWERS_BLDO2) ? "+" : "-",
PMU->getPowerChannelVoltage(XPOWERS_BLDO2));
}
@@ -1124,7 +1129,7 @@ LipoBatteryLevel lipoLevel;
bool Power::lipoInit()
{
bool result = lipoLevel.runOnce();
- LOG_DEBUG("Power::lipoInit lipo sensor is %s\n", result ? "ready" : "not ready yet");
+ LOG_DEBUG("Power::lipoInit lipo sensor is %s", result ? "ready" : "not ready yet");
if (!result)
return false;
batteryLevel = &lipoLevel;
diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp
index 8bf7d32183..35ef2624a7 100644
--- a/src/PowerFSM.cpp
+++ b/src/PowerFSM.cpp
@@ -53,7 +53,7 @@ static bool isPowered()
static void sdsEnter()
{
- LOG_DEBUG("Enter state: SDS\n");
+ LOG_DEBUG("Enter state: SDS");
// FIXME - make sure GPS and LORA radio are off first - because we want close to zero current draw
doDeepSleep(Default::getConfiguredOrDefaultMs(config.power.sds_secs), false);
}
@@ -62,7 +62,7 @@ extern Power *power;
static void shutdownEnter()
{
- LOG_DEBUG("Enter state: SHUTDOWN\n");
+ LOG_DEBUG("Enter state: SHUTDOWN");
power->shutdown();
}
@@ -72,16 +72,16 @@ static uint32_t secsSlept;
static void lsEnter()
{
- LOG_INFO("lsEnter begin, ls_secs=%u\n", config.power.ls_secs);
+ LOG_INFO("lsEnter begin, ls_secs=%u", config.power.ls_secs);
screen->setOn(false);
secsSlept = 0; // How long have we been sleeping this time
- // LOG_INFO("lsEnter end\n");
+ // LOG_INFO("lsEnter end");
}
static void lsIdle()
{
- // LOG_INFO("lsIdle begin ls_secs=%u\n", getPref_ls_secs());
+ // LOG_INFO("lsIdle begin ls_secs=%u", getPref_ls_secs());
#ifdef ARCH_ESP32
@@ -105,7 +105,7 @@ static void lsIdle()
wakeCause2 = doLightSleep(100); // leave led on for 1ms
secsSlept += sleepTime;
- // LOG_INFO("sleeping, flash led!\n");
+ // LOG_INFO("sleeping, flash led!");
break;
case ESP_SLEEP_WAKEUP_UART:
@@ -137,7 +137,7 @@ static void lsIdle()
} else {
// Time to stop sleeping!
ledBlink.set(false);
- LOG_INFO("Reached ls_secs, servicing loop()\n");
+ LOG_INFO("Reached ls_secs, servicing loop()");
powerFSM.trigger(EVENT_WAKE_TIMER);
}
#endif
@@ -145,12 +145,12 @@ static void lsIdle()
static void lsExit()
{
- LOG_INFO("Exit state: LS\n");
+ LOG_INFO("Exit state: LS");
}
static void nbEnter()
{
- LOG_DEBUG("Enter state: NB\n");
+ LOG_DEBUG("Enter state: NB");
screen->setOn(false);
#ifdef ARCH_ESP32
// Only ESP32 should turn off bluetooth
@@ -168,7 +168,7 @@ static void darkEnter()
static void serialEnter()
{
- LOG_DEBUG("Enter state: SERIAL\n");
+ LOG_DEBUG("Enter state: SERIAL");
setBluetoothEnable(false);
screen->setOn(true);
screen->print("Serial connected\n");
@@ -183,10 +183,10 @@ static void serialExit()
static void powerEnter()
{
- // LOG_DEBUG("Enter state: POWER\n");
+ // LOG_DEBUG("Enter state: POWER");
if (!isPowered()) {
// If we got here, we are in the wrong state - we should be in powered, let that state ahndle things
- LOG_INFO("Loss of power in Powered\n");
+ LOG_INFO("Loss of power in Powered");
powerFSM.trigger(EVENT_POWER_DISCONNECTED);
} else {
screen->setOn(true);
@@ -205,7 +205,7 @@ static void powerIdle()
{
if (!isPowered()) {
// If we got here, we are in the wrong state
- LOG_INFO("Loss of power in Powered\n");
+ LOG_INFO("Loss of power in Powered");
powerFSM.trigger(EVENT_POWER_DISCONNECTED);
}
}
@@ -222,7 +222,7 @@ static void powerExit()
static void onEnter()
{
- LOG_DEBUG("Enter state: ON\n");
+ LOG_DEBUG("Enter state: ON");
screen->setOn(true);
setBluetoothEnable(true);
}
@@ -242,7 +242,7 @@ static void screenPress()
static void bootEnter()
{
- LOG_DEBUG("Enter state: BOOT\n");
+ LOG_DEBUG("Enter state: BOOT");
}
State stateSHUTDOWN(shutdownEnter, NULL, NULL, "SHUTDOWN");
@@ -264,7 +264,7 @@ void PowerFSM_setup()
config.device.role == meshtastic_Config_DeviceConfig_Role_SENSOR;
bool hasPower = isPowered();
- LOG_INFO("PowerFSM init, USB power=%d\n", hasPower ? 1 : 0);
+ LOG_INFO("PowerFSM init, USB power=%d", hasPower ? 1 : 0);
powerFSM.add_timed_transition(&stateBOOT, hasPower ? &statePOWER : &stateON, 3 * 1000, NULL, "boot timeout");
// wake timer expired or a packet arrived
diff --git a/src/PowerMon.cpp b/src/PowerMon.cpp
index 16909262df..38740b6ae9 100644
--- a/src/PowerMon.cpp
+++ b/src/PowerMon.cpp
@@ -35,7 +35,7 @@ void PowerMon::emitLog(const char *reason)
{
#ifdef USE_POWERMON
// The nrf52 printf doesn't understand 64 bit ints, so if we ever reach that point this function will need to change.
- LOG_INFO("S:PM:0x%08lx,%s\n", (uint32_t)states, reason);
+ LOG_INFO("S:PM:0x%08lx,%s", (uint32_t)states, reason);
#endif
}
diff --git a/src/PowerStatus.h b/src/PowerStatus.h
index 592a033280..fe4543e08d 100644
--- a/src/PowerStatus.h
+++ b/src/PowerStatus.h
@@ -91,7 +91,7 @@ class PowerStatus : public Status
isCharging = newStatus->isCharging;
}
if (isDirty) {
- // LOG_DEBUG("Battery %dmV %d%%\n", batteryVoltageMv, batteryChargePercent);
+ // LOG_DEBUG("Battery %dmV %d%%", batteryVoltageMv, batteryChargePercent);
onNewStatus.notifyObservers(this);
}
return 0;
diff --git a/src/RedirectablePrint.cpp b/src/RedirectablePrint.cpp
index 6eb6f8319a..57f53019db 100644
--- a/src/RedirectablePrint.cpp
+++ b/src/RedirectablePrint.cpp
@@ -98,81 +98,75 @@ void RedirectablePrint::log_to_serial(const char *logLevel, const char *format,
{
size_t r = 0;
- // Cope with 0 len format strings, but look for new line terminator
- bool hasNewline = *format && format[strlen(format) - 1] == '\n';
#ifdef ARCH_PORTDUINO
bool color = !settingsMap[ascii_logs];
#else
bool color = true;
#endif
- // If we are the first message on a report, include the header
- if (!isContinuationMessage) {
- if (color) {
- if (strcmp(logLevel, MESHTASTIC_LOG_LEVEL_DEBUG) == 0)
- Print::write("\u001b[34m", 6);
- if (strcmp(logLevel, MESHTASTIC_LOG_LEVEL_INFO) == 0)
- Print::write("\u001b[32m", 6);
- if (strcmp(logLevel, MESHTASTIC_LOG_LEVEL_WARN) == 0)
- Print::write("\u001b[33m", 6);
- if (strcmp(logLevel, MESHTASTIC_LOG_LEVEL_ERROR) == 0)
- Print::write("\u001b[31m", 6);
- if (strcmp(logLevel, MESHTASTIC_LOG_LEVEL_TRACE) == 0)
- Print::write("\u001b[35m", 6);
- }
+ // include the header
+ if (color) {
+ if (strcmp(logLevel, MESHTASTIC_LOG_LEVEL_DEBUG) == 0)
+ Print::write("\u001b[34m", 6);
+ if (strcmp(logLevel, MESHTASTIC_LOG_LEVEL_INFO) == 0)
+ Print::write("\u001b[32m", 6);
+ if (strcmp(logLevel, MESHTASTIC_LOG_LEVEL_WARN) == 0)
+ Print::write("\u001b[33m", 6);
+ if (strcmp(logLevel, MESHTASTIC_LOG_LEVEL_ERROR) == 0)
+ Print::write("\u001b[31m", 6);
+ if (strcmp(logLevel, MESHTASTIC_LOG_LEVEL_TRACE) == 0)
+ Print::write("\u001b[35m", 6);
+ }
- uint32_t rtc_sec = getValidTime(RTCQuality::RTCQualityDevice, true); // display local time on logfile
- if (rtc_sec > 0) {
- long hms = rtc_sec % SEC_PER_DAY;
- // hms += tz.tz_dsttime * SEC_PER_HOUR;
- // hms -= tz.tz_minuteswest * SEC_PER_MIN;
- // mod `hms` to ensure in positive range of [0...SEC_PER_DAY)
- hms = (hms + SEC_PER_DAY) % SEC_PER_DAY;
+ uint32_t rtc_sec = getValidTime(RTCQuality::RTCQualityDevice, true); // display local time on logfile
+ if (rtc_sec > 0) {
+ long hms = rtc_sec % SEC_PER_DAY;
+ // hms += tz.tz_dsttime * SEC_PER_HOUR;
+ // hms -= tz.tz_minuteswest * SEC_PER_MIN;
+ // mod `hms` to ensure in positive range of [0...SEC_PER_DAY)
+ hms = (hms + SEC_PER_DAY) % SEC_PER_DAY;
- // Tear apart hms into h:m:s
- int hour = hms / SEC_PER_HOUR;
- int min = (hms % SEC_PER_HOUR) / SEC_PER_MIN;
- int sec = (hms % SEC_PER_HOUR) % SEC_PER_MIN; // or hms % SEC_PER_MIN
+ // Tear apart hms into h:m:s
+ int hour = hms / SEC_PER_HOUR;
+ int min = (hms % SEC_PER_HOUR) / SEC_PER_MIN;
+ int sec = (hms % SEC_PER_HOUR) % SEC_PER_MIN; // or hms % SEC_PER_MIN
#ifdef ARCH_PORTDUINO
- ::printf("%s ", logLevel);
- if (color) {
- ::printf("\u001b[0m");
- }
- ::printf("| %02d:%02d:%02d %u ", hour, min, sec, millis() / 1000);
+ ::printf("%s ", logLevel);
+ if (color) {
+ ::printf("\u001b[0m");
+ }
+ ::printf("| %02d:%02d:%02d %u ", hour, min, sec, millis() / 1000);
#else
- printf("%s ", logLevel);
- if (color) {
- printf("\u001b[0m");
- }
- printf("| %02d:%02d:%02d %u ", hour, min, sec, millis() / 1000);
+ printf("%s ", logLevel);
+ if (color) {
+ printf("\u001b[0m");
+ }
+ printf("| %02d:%02d:%02d %u ", hour, min, sec, millis() / 1000);
#endif
- } else {
+ } else {
#ifdef ARCH_PORTDUINO
- ::printf("%s ", logLevel);
- if (color) {
- ::printf("\u001b[0m");
- }
- ::printf("| ??:??:?? %u ", millis() / 1000);
-#else
- printf("%s ", logLevel);
- if (color) {
- printf("\u001b[0m");
- }
- printf("| ??:??:?? %u ", millis() / 1000);
-#endif
+ ::printf("%s ", logLevel);
+ if (color) {
+ ::printf("\u001b[0m");
}
- auto thread = concurrency::OSThread::currentThread;
- if (thread) {
- print("[");
- // printf("%p ", thread);
- // assert(thread->ThreadName.length());
- print(thread->ThreadName);
- print("] ");
+ ::printf("| ??:??:?? %u ", millis() / 1000);
+#else
+ printf("%s ", logLevel);
+ if (color) {
+ printf("\u001b[0m");
}
+ printf("| ??:??:?? %u ", millis() / 1000);
+#endif
+ }
+ auto thread = concurrency::OSThread::currentThread;
+ if (thread) {
+ print("[");
+ // printf("%p ", thread);
+ // assert(thread->ThreadName.length());
+ print(thread->ThreadName);
+ print("] ");
}
r += vprintf(logLevel, format, arg);
-
- isContinuationMessage = !hasNewline;
}
void RedirectablePrint::log_to_syslog(const char *logLevel, const char *format, va_list arg)
@@ -283,6 +277,14 @@ meshtastic_LogRecord_Level RedirectablePrint::getLogLevel(const char *logLevel)
void RedirectablePrint::log(const char *logLevel, const char *format, ...)
{
+
+ // append \n to format
+ size_t len = strlen(format);
+ char *newFormat = new char[len + 2];
+ strcpy(newFormat, format);
+ newFormat[len] = '\n';
+ newFormat[len + 1] = '\0';
+
#if ARCH_PORTDUINO
// level trace is special, two possible ways to handle it.
if (strcmp(logLevel, MESHTASTIC_LOG_LEVEL_TRACE) == 0) {
@@ -295,17 +297,24 @@ void RedirectablePrint::log(const char *logLevel, const char *format, ...)
}
va_end(arg);
}
- if (settingsMap[logoutputlevel] < level_trace && strcmp(logLevel, MESHTASTIC_LOG_LEVEL_TRACE) == 0)
+ if (settingsMap[logoutputlevel] < level_trace && strcmp(logLevel, MESHTASTIC_LOG_LEVEL_TRACE) == 0) {
+ delete[] newFormat;
return;
+ }
}
- if (settingsMap[logoutputlevel] < level_debug && strcmp(logLevel, MESHTASTIC_LOG_LEVEL_DEBUG) == 0)
+ if (settingsMap[logoutputlevel] < level_debug && strcmp(logLevel, MESHTASTIC_LOG_LEVEL_DEBUG) == 0) {
+ delete[] newFormat;
return;
- else if (settingsMap[logoutputlevel] < level_info && strcmp(logLevel, MESHTASTIC_LOG_LEVEL_INFO) == 0)
+ } else if (settingsMap[logoutputlevel] < level_info && strcmp(logLevel, MESHTASTIC_LOG_LEVEL_INFO) == 0) {
+ delete[] newFormat;
return;
- else if (settingsMap[logoutputlevel] < level_warn && strcmp(logLevel, MESHTASTIC_LOG_LEVEL_WARN) == 0)
+ } else if (settingsMap[logoutputlevel] < level_warn && strcmp(logLevel, MESHTASTIC_LOG_LEVEL_WARN) == 0) {
+ delete[] newFormat;
return;
+ }
#endif
if (moduleConfig.serial.override_console_serial_port && strcmp(logLevel, MESHTASTIC_LOG_LEVEL_DEBUG) == 0) {
+ delete[] newFormat;
return;
}
@@ -319,9 +328,9 @@ void RedirectablePrint::log(const char *logLevel, const char *format, ...)
va_list arg;
va_start(arg, format);
- log_to_serial(logLevel, format, arg);
- log_to_syslog(logLevel, format, arg);
- log_to_ble(logLevel, format, arg);
+ log_to_serial(logLevel, newFormat, arg);
+ log_to_syslog(logLevel, newFormat, arg);
+ log_to_ble(logLevel, newFormat, arg);
va_end(arg);
#ifdef HAS_FREE_RTOS
@@ -331,17 +340,18 @@ void RedirectablePrint::log(const char *logLevel, const char *format, ...)
#endif
}
+ delete[] newFormat;
return;
}
void RedirectablePrint::hexDump(const char *logLevel, unsigned char *buf, uint16_t len)
{
const char alphabet[17] = "0123456789abcdef";
- log(logLevel, " +------------------------------------------------+ +----------------+\n");
- log(logLevel, " |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | | ASCII |\n");
+ log(logLevel, " +------------------------------------------------+ +----------------+");
+ log(logLevel, " |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | | ASCII |");
for (uint16_t i = 0; i < len; i += 16) {
if (i % 128 == 0)
- log(logLevel, " +------------------------------------------------+ +----------------+\n");
+ log(logLevel, " +------------------------------------------------+ +----------------+");
char s[] = "| | | |\n";
uint8_t ix = 1, iy = 52;
for (uint8_t j = 0; j < 16; j++) {
@@ -363,7 +373,7 @@ void RedirectablePrint::hexDump(const char *logLevel, unsigned char *buf, uint16
log(logLevel, ".");
log(logLevel, s);
}
- log(logLevel, " +------------------------------------------------+ +----------------+\n");
+ log(logLevel, " +------------------------------------------------+ +----------------+");
}
std::string RedirectablePrint::mt_sprintf(const std::string fmt_str, ...)
diff --git a/src/RedirectablePrint.h b/src/RedirectablePrint.h
index 23ae3c44de..45b62b7af2 100644
--- a/src/RedirectablePrint.h
+++ b/src/RedirectablePrint.h
@@ -15,9 +15,6 @@ class RedirectablePrint : public Print
{
Print *dest;
- /// Used to allow multiple logDebug messages to appear on a single log line
- bool isContinuationMessage = false;
-
#ifdef HAS_FREE_RTOS
SemaphoreHandle_t inDebugPrint = nullptr;
StaticSemaphore_t _MutexStorageSpace;
@@ -54,9 +51,9 @@ class RedirectablePrint : public Print
protected:
/// Subclasses can override if they need to change how we format over the serial port
virtual void log_to_serial(const char *logLevel, const char *format, va_list arg);
+ meshtastic_LogRecord_Level getLogLevel(const char *logLevel);
private:
void log_to_syslog(const char *logLevel, const char *format, va_list arg);
void log_to_ble(const char *logLevel, const char *format, va_list arg);
- meshtastic_LogRecord_Level getLogLevel(const char *logLevel);
};
\ No newline at end of file
diff --git a/src/SafeFile.cpp b/src/SafeFile.cpp
index c17d422bd3..c76ff8054a 100644
--- a/src/SafeFile.cpp
+++ b/src/SafeFile.cpp
@@ -59,14 +59,14 @@ bool SafeFile::close()
// brief window of risk here ;-)
if (fullAtomic && FSCom.exists(filename.c_str()) && !FSCom.remove(filename.c_str())) {
- LOG_ERROR("Can't remove old pref file\n");
+ LOG_ERROR("Can't remove old pref file");
return false;
}
String filenameTmp = filename;
filenameTmp += ".tmp";
if (!renameFile(filenameTmp.c_str(), filename.c_str())) {
- LOG_ERROR("Error: can't rename new pref file\n");
+ LOG_ERROR("Error: can't rename new pref file");
return false;
}
@@ -83,7 +83,7 @@ bool SafeFile::testReadback()
filenameTmp += ".tmp";
auto f2 = FSCom.open(filenameTmp.c_str(), FILE_O_READ);
if (!f2) {
- LOG_ERROR("Can't open tmp file for readback\n");
+ LOG_ERROR("Can't open tmp file for readback");
return false;
}
@@ -95,7 +95,7 @@ bool SafeFile::testReadback()
f2.close();
if (test_hash != hash) {
- LOG_ERROR("Readback failed hash mismatch\n");
+ LOG_ERROR("Readback failed hash mismatch");
return false;
}
diff --git a/src/SerialConsole.cpp b/src/SerialConsole.cpp
index fe6ccdefe1..68c41980d0 100644
--- a/src/SerialConsole.cpp
+++ b/src/SerialConsole.cpp
@@ -99,25 +99,7 @@ bool SerialConsole::handleToRadio(const uint8_t *buf, size_t len)
void SerialConsole::log_to_serial(const char *logLevel, const char *format, va_list arg)
{
if (usingProtobufs && config.security.debug_log_api_enabled) {
- meshtastic_LogRecord_Level ll = meshtastic_LogRecord_Level_UNSET; // default to unset
- switch (logLevel[0]) {
- case 'D':
- ll = meshtastic_LogRecord_Level_DEBUG;
- break;
- case 'I':
- ll = meshtastic_LogRecord_Level_INFO;
- break;
- case 'W':
- ll = meshtastic_LogRecord_Level_WARNING;
- break;
- case 'E':
- ll = meshtastic_LogRecord_Level_ERROR;
- break;
- case 'C':
- ll = meshtastic_LogRecord_Level_CRITICAL;
- break;
- }
-
+ meshtastic_LogRecord_Level ll = RedirectablePrint::getLogLevel(logLevel);
auto thread = concurrency::OSThread::currentThread;
emitLogRecord(ll, thread ? thread->ThreadName.c_str() : "", format, arg);
} else
diff --git a/src/airtime.cpp b/src/airtime.cpp
index fcda054682..7478debb94 100644
--- a/src/airtime.cpp
+++ b/src/airtime.cpp
@@ -13,17 +13,17 @@ void AirTime::logAirtime(reportTypes reportType, uint32_t airtime_ms)
{
if (reportType == TX_LOG) {
- LOG_DEBUG("Packet transmitted : %ums\n", airtime_ms);
+ LOG_DEBUG("Packet transmitted : %ums", airtime_ms);
this->airtimes.periodTX[0] = this->airtimes.periodTX[0] + airtime_ms;
air_period_tx[0] = air_period_tx[0] + airtime_ms;
this->utilizationTX[this->getPeriodUtilHour()] = this->utilizationTX[this->getPeriodUtilHour()] + airtime_ms;
} else if (reportType == RX_LOG) {
- LOG_DEBUG("Packet received : %ums\n", airtime_ms);
+ LOG_DEBUG("Packet received : %ums", airtime_ms);
this->airtimes.periodRX[0] = this->airtimes.periodRX[0] + airtime_ms;
air_period_rx[0] = air_period_rx[0] + airtime_ms;
} else if (reportType == RX_ALL_LOG) {
- LOG_DEBUG("Packet received (noise?) : %ums\n", airtime_ms);
+ LOG_DEBUG("Packet received (noise?) : %ums", airtime_ms);
this->airtimes.periodRX_ALL[0] = this->airtimes.periodRX_ALL[0] + airtime_ms;
}
@@ -50,7 +50,7 @@ void AirTime::airtimeRotatePeriod()
{
if (this->airtimes.lastPeriodIndex != this->currentPeriodIndex()) {
- LOG_DEBUG("Rotating airtimes to a new period = %u\n", this->currentPeriodIndex());
+ LOG_DEBUG("Rotating airtimes to a new period = %u", this->currentPeriodIndex());
for (int i = PERIODS_TO_LOG - 2; i >= 0; --i) {
this->airtimes.periodTX[i + 1] = this->airtimes.periodTX[i];
@@ -105,7 +105,7 @@ float AirTime::channelUtilizationPercent()
uint32_t sum = 0;
for (uint32_t i = 0; i < CHANNEL_UTILIZATION_PERIODS; i++) {
sum += this->channelUtilization[i];
- // LOG_DEBUG("ChanUtilArray %u %u\n", i, this->channelUtilization[i]);
+ // LOG_DEBUG("ChanUtilArray %u %u", i, this->channelUtilization[i]);
}
return (float(sum) / float(CHANNEL_UTILIZATION_PERIODS * 10 * 1000)) * 100;
@@ -127,7 +127,7 @@ bool AirTime::isTxAllowedChannelUtil(bool polite)
if (channelUtilizationPercent() < percentage) {
return true;
} else {
- LOG_WARN("Channel utilization is >%d percent. Skipping this opportunity to send.\n", percentage);
+ LOG_WARN("Channel utilization is >%d percent. Skipping this opportunity to send.", percentage);
return false;
}
}
@@ -138,7 +138,7 @@ bool AirTime::isTxAllowedAirUtil()
if (utilizationTXPercent() < myRegion->dutyCycle * polite_duty_cycle_percent / 100) {
return true;
} else {
- LOG_WARN("Tx air utilization is >%f percent. Skipping this opportunity to send.\n",
+ LOG_WARN("Tx air utilization is >%f percent. Skipping this opportunity to send.",
myRegion->dutyCycle * polite_duty_cycle_percent / 100);
return false;
}
@@ -209,13 +209,13 @@ int32_t AirTime::runOnce()
}
}
/*
- LOG_DEBUG("utilPeriodTX %d TX Airtime %3.2f%\n", utilPeriodTX, airTime->utilizationTXPercent());
+ LOG_DEBUG("utilPeriodTX %d TX Airtime %3.2f%", utilPeriodTX, airTime->utilizationTXPercent());
for (uint32_t i = 0; i < MINUTES_IN_HOUR; i++) {
LOG_DEBUG(
"%d,", this->utilizationTX[i]
);
}
- LOG_DEBUG("\n");
+ LOG_DEBUG("");
*/
return (1000 * 1);
}
\ No newline at end of file
diff --git a/src/buzz/buzz.cpp b/src/buzz/buzz.cpp
index e42a9c203f..8db9602bc3 100644
--- a/src/buzz/buzz.cpp
+++ b/src/buzz/buzz.cpp
@@ -55,6 +55,18 @@ void playBeep()
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
}
+void playGPSEnableBeep()
+{
+ ToneDuration melody[] = {{NOTE_C3, DURATION_1_8}, {NOTE_FS3, DURATION_1_4}, {NOTE_CS4, DURATION_1_4}};
+ playTones(melody, sizeof(melody) / sizeof(ToneDuration));
+}
+
+void playGPSDisableBeep()
+{
+ ToneDuration melody[] = {{NOTE_CS4, DURATION_1_8}, {NOTE_FS3, DURATION_1_4}, {NOTE_C3, DURATION_1_4}};
+ playTones(melody, sizeof(melody) / sizeof(ToneDuration));
+}
+
void playStartMelody()
{
ToneDuration melody[] = {{NOTE_FS3, DURATION_1_8}, {NOTE_AS3, DURATION_1_8}, {NOTE_CS4, DURATION_1_4}};
diff --git a/src/buzz/buzz.h b/src/buzz/buzz.h
index 3883bd057c..c52c3020cd 100644
--- a/src/buzz/buzz.h
+++ b/src/buzz/buzz.h
@@ -3,3 +3,5 @@
void playBeep();
void playStartMelody();
void playShutdownMelody();
+void playGPSEnableBeep();
+void playGPSDisableBeep();
\ No newline at end of file
diff --git a/src/concurrency/InterruptableDelay.cpp b/src/concurrency/InterruptableDelay.cpp
index b9606e23a4..8bc85436ba 100644
--- a/src/concurrency/InterruptableDelay.cpp
+++ b/src/concurrency/InterruptableDelay.cpp
@@ -18,7 +18,7 @@ bool InterruptableDelay::delay(uint32_t msec)
// sem take will return false if we timed out (i.e. were not interrupted)
bool r = semaphore.take(msec);
- // LOG_DEBUG("interrupt=%d\n", r);
+ // LOG_DEBUG("interrupt=%d", r);
return !r;
}
diff --git a/src/concurrency/NotifiedWorkerThread.cpp b/src/concurrency/NotifiedWorkerThread.cpp
index 271e3e60d5..d84ff0903c 100644
--- a/src/concurrency/NotifiedWorkerThread.cpp
+++ b/src/concurrency/NotifiedWorkerThread.cpp
@@ -32,12 +32,12 @@ IRAM_ATTR bool NotifiedWorkerThread::notifyCommon(uint32_t v, bool overwrite)
notification = v;
if (debugNotification) {
- LOG_DEBUG("setting notification %d\n", v);
+ LOG_DEBUG("setting notification %d", v);
}
return true;
} else {
if (debugNotification) {
- LOG_DEBUG("dropping notification %d\n", v);
+ LOG_DEBUG("dropping notification %d", v);
}
return false;
}
@@ -67,7 +67,7 @@ bool NotifiedWorkerThread::notifyLater(uint32_t delay, uint32_t v, bool overwrit
if (didIt) { // If we didn't already have something queued, override the delay to be larger
setIntervalFromNow(delay); // a new version of setInterval relative to the current time
if (debugNotification) {
- LOG_DEBUG("delaying notification %u\n", delay);
+ LOG_DEBUG("delaying notification %u", delay);
}
}
diff --git a/src/concurrency/OSThread.cpp b/src/concurrency/OSThread.cpp
index f23cbe1dce..d9bb901b2f 100644
--- a/src/concurrency/OSThread.cpp
+++ b/src/concurrency/OSThread.cpp
@@ -62,15 +62,15 @@ bool OSThread::shouldRun(unsigned long time)
bool r = Thread::shouldRun(time);
if (showRun && r) {
- LOG_DEBUG("Thread %s: run\n", ThreadName.c_str());
+ LOG_DEBUG("Thread %s: run", ThreadName.c_str());
}
if (showWaiting && enabled && !r) {
- LOG_DEBUG("Thread %s: wait %lu\n", ThreadName.c_str(), interval);
+ LOG_DEBUG("Thread %s: wait %lu", ThreadName.c_str(), interval);
}
if (showDisabled && !enabled) {
- LOG_DEBUG("Thread %s: disabled\n", ThreadName.c_str());
+ LOG_DEBUG("Thread %s: disabled", ThreadName.c_str());
}
return r;
@@ -86,9 +86,9 @@ void OSThread::run()
#ifdef DEBUG_HEAP
auto newHeap = memGet.getFreeHeap();
if (newHeap < heap)
- LOG_DEBUG("------ Thread %s leaked heap %d -> %d (%d) ------\n", ThreadName.c_str(), heap, newHeap, newHeap - heap);
+ LOG_DEBUG("------ Thread %s leaked heap %d -> %d (%d) ------", ThreadName.c_str(), heap, newHeap, newHeap - heap);
if (heap < newHeap)
- LOG_DEBUG("++++++ Thread %s freed heap %d -> %d (%d) ++++++\n", ThreadName.c_str(), heap, newHeap, newHeap - heap);
+ LOG_DEBUG("++++++ Thread %s freed heap %d -> %d (%d) ++++++", ThreadName.c_str(), heap, newHeap, newHeap - heap);
#endif
runned();
diff --git a/src/configuration.h b/src/configuration.h
index 3cd93ec83d..cb2326470c 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -114,6 +114,7 @@ along with this program. If not, see .
#define CARDKB_ADDR 0x5F
#define TDECK_KB_ADDR 0x55
#define BBQ10_KB_ADDR 0x1F
+#define MPR121_KB_ADDR 0x5A
// -----------------------------------------------------------------------------
// SENSOR
@@ -135,6 +136,7 @@ along with this program. If not, see .
#define LPS22HB_ADDR_ALT 0x5D
#define SHT31_4x_ADDR 0x44
#define PMSA0031_ADDR 0x12
+#define QMA6100P_ADDR 0x12
#define AHT10_ADDR 0x38
#define RCWL9620_ADDR 0x57
#define VEML7700_ADDR 0x10
@@ -144,6 +146,8 @@ along with this program. If not, see .
#define MLX90632_ADDR 0x3A
#define DFROBOT_LARK_ADDR 0x42
#define NAU7802_ADDR 0x2A
+#define MAX30102_ADDR 0x57
+#define MLX90614_ADDR_DEF 0x5A
// -----------------------------------------------------------------------------
// ACCELEROMETER
@@ -185,6 +189,11 @@ along with this program. If not, see .
// -----------------------------------------------------------------------------
#define FT6336U_ADDR 0x48
+// -----------------------------------------------------------------------------
+// BIAS-T Generator
+// -----------------------------------------------------------------------------
+#define TPS65233_ADDR 0x60
+
// convert 24-bit color to 16-bit (56K)
#define COLOR565(r, g, b) (((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3))
diff --git a/src/detect/ScanI2C.cpp b/src/detect/ScanI2C.cpp
index a9d70edaa9..4caa0f730b 100644
--- a/src/detect/ScanI2C.cpp
+++ b/src/detect/ScanI2C.cpp
@@ -31,14 +31,14 @@ ScanI2C::FoundDevice ScanI2C::firstRTC() const
ScanI2C::FoundDevice ScanI2C::firstKeyboard() const
{
- ScanI2C::DeviceType types[] = {CARDKB, TDECKKB, BBQ10KB, RAK14004};
- return firstOfOrNONE(4, types);
+ ScanI2C::DeviceType types[] = {CARDKB, TDECKKB, BBQ10KB, RAK14004, MPR121KB};
+ return firstOfOrNONE(5, types);
}
ScanI2C::FoundDevice ScanI2C::firstAccelerometer() const
{
- ScanI2C::DeviceType types[] = {MPU6050, LIS3DH, BMA423, LSM6DS3, BMX160, STK8BAXX, ICM20948};
- return firstOfOrNONE(7, types);
+ ScanI2C::DeviceType types[] = {MPU6050, LIS3DH, BMA423, LSM6DS3, BMX160, STK8BAXX, ICM20948, QMA6100P};
+ return firstOfOrNONE(8, types);
}
ScanI2C::FoundDevice ScanI2C::find(ScanI2C::DeviceType) const
diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h
index 3b49026ced..8591b8433c 100644
--- a/src/detect/ScanI2C.h
+++ b/src/detect/ScanI2C.h
@@ -39,6 +39,7 @@ class ScanI2C
QMC5883L,
HMC5883L,
PMSA0031,
+ QMA6100P,
MPU6050,
LIS3DH,
BMA423,
@@ -52,13 +53,17 @@ class ScanI2C
TSL2591,
OPT3001,
MLX90632,
+ MLX90614,
AHT10,
BMX160,
DFROBOT_LARK,
NAU7802,
FT6336U,
STK8BAXX,
- ICM20948
+ ICM20948,
+ MAX30102,
+ TPS65233,
+ MPR121KB
} DeviceType;
// typedef uint8_t DeviceAddress;
diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp
index 43340765aa..d39c9899c5 100644
--- a/src/detect/ScanI2CTwoWire.cpp
+++ b/src/detect/ScanI2CTwoWire.cpp
@@ -7,7 +7,8 @@
#include "linux/LinuxHardwareI2C.h"
#endif
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
-#include "main.h" // atecc
+#include "main.h" // atecc
+#include "meshUtils.h" // vformat
#endif
// AXP192 and AXP2101 have the same device address, we just need to identify it in Power.cpp
@@ -71,15 +72,15 @@ ScanI2C::DeviceType ScanI2CTwoWire::probeOLED(ScanI2C::DeviceAddress addr) const
r &= 0x0f;
if (r == 0x08 || r == 0x00) {
- LOG_INFO("sh1106 display found\n");
+ LOG_INFO("sh1106 display found");
o_probe = SCREEN_SH1106; // SH1106
} else if (r == 0x03 || r == 0x04 || r == 0x06 || r == 0x07) {
- LOG_INFO("ssd1306 display found\n");
+ LOG_INFO("ssd1306 display found");
o_probe = SCREEN_SSD1306; // SSD1306
}
c++;
} while ((r != r_prev) && (c < 4));
- LOG_DEBUG("0x%x subtype probed in %i tries \n", r, c);
+ LOG_DEBUG("0x%x subtype probed in %i tries ", r, c);
return o_probe;
}
@@ -88,31 +89,31 @@ void ScanI2CTwoWire::printATECCInfo() const
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
atecc.readConfigZone(false);
- LOG_DEBUG("ATECC608B Serial Number: ");
+ std::string atecc_numbers = "ATECC608B Serial Number: ";
for (int i = 0; i < 9; i++) {
- LOG_DEBUG("%02x", atecc.serialNumber[i]);
+ atecc_numbers += vformat("%02x", atecc.serialNumber[i]);
}
- LOG_DEBUG(", Rev Number: ");
+ atecc_numbers += ", Rev Number: ";
for (int i = 0; i < 4; i++) {
- LOG_DEBUG("%02x", atecc.revisionNumber[i]);
+ atecc_numbers += vformat("%02x", atecc.revisionNumber[i]);
}
- LOG_DEBUG("\n");
+ LOG_DEBUG(atecc_numbers.c_str());
- LOG_DEBUG("ATECC608B Config %s", atecc.configLockStatus ? "Locked" : "Unlocked");
- LOG_DEBUG(", Data %s", atecc.dataOTPLockStatus ? "Locked" : "Unlocked");
- LOG_DEBUG(", Slot 0 %s\n", atecc.slot0LockStatus ? "Locked" : "Unlocked");
+ LOG_DEBUG("ATECC608B Config %s, Data %s, Slot 0 %s", atecc.configLockStatus ? "Locked" : "Unlocked",
+ atecc.dataOTPLockStatus ? "Locked" : "Unlocked", atecc.slot0LockStatus ? "Locked" : "Unlocked");
+ std::string atecc_publickey = "";
if (atecc.configLockStatus && atecc.dataOTPLockStatus && atecc.slot0LockStatus) {
if (atecc.generatePublicKey() == false) {
- LOG_DEBUG("ATECC608B Error generating public key\n");
+ atecc_publickey += "ATECC608B Error generating public key";
} else {
- LOG_DEBUG("ATECC608B Public Key: ");
+ atecc_publickey += "ATECC608B Public Key: ";
for (int i = 0; i < 64; i++) {
- LOG_DEBUG("%02x", atecc.publicKey64Bytes[i]);
+ atecc_publickey += vformat("%02x", atecc.publicKey64Bytes[i]);
}
- LOG_DEBUG("\n");
}
+ LOG_DEBUG(atecc_publickey.c_str());
}
#endif
}
@@ -128,7 +129,7 @@ uint16_t ScanI2CTwoWire::getRegisterValue(const ScanI2CTwoWire::RegisterLocation
i2cBus->endTransmission();
delay(20);
i2cBus->requestFrom(registerLocation.i2cAddress.address, responseWidth);
- LOG_DEBUG("Wire.available() = %d\n", i2cBus->available());
+ LOG_DEBUG("Wire.available() = %d", i2cBus->available());
if (i2cBus->available() == 2) {
// Read MSB, then LSB
value = (uint16_t)i2cBus->read() << 8;
@@ -149,7 +150,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
{
concurrency::LockGuard guard((concurrency::Lock *)&lock);
- LOG_DEBUG("Scanning for I2C devices on port %d\n", port);
+ LOG_DEBUG("Scanning for I2C devices on port %d", port);
uint8_t err;
@@ -172,11 +173,20 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
}
#endif
- for (addr.address = 1; addr.address < 127; addr.address++) {
+ // We only need to scan 112 addresses, the rest is reserved for special purposes
+ // 0x00 General Call
+ // 0x01 CBUS addresses
+ // 0x02 Reserved for different bus formats
+ // 0x03 Reserved for future purposes
+ // 0x04-0x07 High Speed Master Code
+ // 0x78-0x7B 10-bit slave addressing
+ // 0x7C-0x7F Reserved for future purposes
+
+ for (addr.address = 8; addr.address < 120; addr.address++) {
if (asize != 0) {
if (!in_array(address, asize, addr.address))
continue;
- LOG_DEBUG("Scanning address 0x%x\n", addr.address);
+ LOG_DEBUG("Scanning address 0x%x", addr.address);
}
i2cBus->beginTransmission(addr.address);
#ifdef ARCH_PORTDUINO
@@ -189,7 +199,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
#endif
type = NONE;
if (err == 0) {
- LOG_DEBUG("I2C device found at address 0x%x\n", addr.address);
+ LOG_DEBUG("I2C device found at address 0x%x", addr.address);
switch (addr.address) {
case SSD1306_ADDRESS:
@@ -205,9 +215,9 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
#endif
{
- LOG_INFO("ATECC608B initialized\n");
+ LOG_INFO("ATECC608B initialized");
} else {
- LOG_WARN("ATECC608B initialization failed\n");
+ LOG_WARN("ATECC608B initialization failed");
}
printATECCInfo();
break;
@@ -217,7 +227,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
case RV3028_RTC:
// foundDevices[addr] = RTC_RV3028;
type = RTC_RV3028;
- LOG_INFO("RV3028 RTC found\n");
+ LOG_INFO("RV3028 RTC found");
rtc.initI2C(*i2cBus);
rtc.writeToRegister(0x35, 0x07); // no Clkout
rtc.writeToRegister(0x37, 0xB4);
@@ -225,7 +235,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
#endif
#ifdef PCF8563_RTC
- SCAN_SIMPLE_CASE(PCF8563_RTC, RTC_PCF8563, "PCF8563 RTC found\n")
+ SCAN_SIMPLE_CASE(PCF8563_RTC, RTC_PCF8563, "PCF8563 RTC found")
#endif
case CARDKB_ADDR:
@@ -233,49 +243,50 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x04), 1);
if (registerValue == 0x02) {
// KEYPAD_VERSION
- LOG_INFO("RAK14004 found\n");
+ LOG_INFO("RAK14004 found");
type = RAK14004;
} else {
- LOG_INFO("m5 cardKB found\n");
+ LOG_INFO("m5 cardKB found");
type = CARDKB;
}
break;
- SCAN_SIMPLE_CASE(TDECK_KB_ADDR, TDECKKB, "T-Deck keyboard found\n");
- SCAN_SIMPLE_CASE(BBQ10_KB_ADDR, BBQ10KB, "BB Q10 keyboard found\n");
- SCAN_SIMPLE_CASE(ST7567_ADDRESS, SCREEN_ST7567, "st7567 display found\n");
+ SCAN_SIMPLE_CASE(TDECK_KB_ADDR, TDECKKB, "T-Deck keyboard found");
+ SCAN_SIMPLE_CASE(BBQ10_KB_ADDR, BBQ10KB, "BB Q10 keyboard found");
+
+ SCAN_SIMPLE_CASE(ST7567_ADDRESS, SCREEN_ST7567, "st7567 display found");
#ifdef HAS_NCP5623
- SCAN_SIMPLE_CASE(NCP5623_ADDR, NCP5623, "NCP5623 RGB LED found\n");
+ SCAN_SIMPLE_CASE(NCP5623_ADDR, NCP5623, "NCP5623 RGB LED found");
#endif
#ifdef HAS_PMU
- SCAN_SIMPLE_CASE(XPOWERS_AXP192_AXP2101_ADDRESS, PMU_AXP192_AXP2101, "axp192/axp2101 PMU found\n")
+ SCAN_SIMPLE_CASE(XPOWERS_AXP192_AXP2101_ADDRESS, PMU_AXP192_AXP2101, "axp192/axp2101 PMU found")
#endif
case BME_ADDR:
case BME_ADDR_ALTERNATE:
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0xD0), 1); // GET_ID
switch (registerValue) {
case 0x61:
- LOG_INFO("BME-680 sensor found at address 0x%x\n", (uint8_t)addr.address);
+ LOG_INFO("BME-680 sensor found at address 0x%x", (uint8_t)addr.address);
type = BME_680;
break;
case 0x60:
- LOG_INFO("BME-280 sensor found at address 0x%x\n", (uint8_t)addr.address);
+ LOG_INFO("BME-280 sensor found at address 0x%x", (uint8_t)addr.address);
type = BME_280;
break;
case 0x55:
- LOG_INFO("BMP-085 or BMP-180 sensor found at address 0x%x\n", (uint8_t)addr.address);
+ LOG_INFO("BMP-085 or BMP-180 sensor found at address 0x%x", (uint8_t)addr.address);
type = BMP_085;
break;
default:
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x00), 1); // GET_ID
switch (registerValue) {
case 0x50: // BMP-388 should be 0x50
- LOG_INFO("BMP-388 sensor found at address 0x%x\n", (uint8_t)addr.address);
+ LOG_INFO("BMP-388 sensor found at address 0x%x", (uint8_t)addr.address);
type = BMP_3XX;
break;
case 0x58: // BMP-280 should be 0x58
default:
- LOG_INFO("BMP-280 sensor found at address 0x%x\n", (uint8_t)addr.address);
+ LOG_INFO("BMP-280 sensor found at address 0x%x", (uint8_t)addr.address);
type = BMP_280;
break;
}
@@ -284,7 +295,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
break;
#ifndef HAS_NCP5623
case AHT10_ADDR:
- LOG_INFO("AHT10 sensor found at address 0x%x\n", (uint8_t)addr.address);
+ LOG_INFO("AHT10 sensor found at address 0x%x", (uint8_t)addr.address);
type = AHT10;
break;
#endif
@@ -292,23 +303,23 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
case INA_ADDR_ALTERNATE:
case INA_ADDR_WAVESHARE_UPS:
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0xFE), 2);
- LOG_DEBUG("Register MFG_UID: 0x%x\n", registerValue);
+ LOG_DEBUG("Register MFG_UID: 0x%x", registerValue);
if (registerValue == 0x5449) {
- LOG_INFO("INA260 sensor found at address 0x%x\n", (uint8_t)addr.address);
+ LOG_INFO("INA260 sensor found at address 0x%x", (uint8_t)addr.address);
type = INA260;
} else { // Assume INA219 if INA260 ID is not found
- LOG_INFO("INA219 sensor found at address 0x%x\n", (uint8_t)addr.address);
+ LOG_INFO("INA219 sensor found at address 0x%x", (uint8_t)addr.address);
type = INA219;
}
break;
case INA3221_ADDR:
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0xFE), 2);
- LOG_DEBUG("Register MFG_UID: 0x%x\n", registerValue);
+ LOG_DEBUG("Register MFG_UID: 0x%x", registerValue);
if (registerValue == 0x5449) {
- LOG_INFO("INA3221 sensor found at address 0x%x\n", (uint8_t)addr.address);
+ LOG_INFO("INA3221 sensor found at address 0x%x", (uint8_t)addr.address);
type = INA3221;
} else {
- LOG_INFO("DFRobot Lark weather station found at address 0x%x\n", (uint8_t)addr.address);
+ LOG_INFO("DFRobot Lark weather station found at address 0x%x", (uint8_t)addr.address);
type = DFROBOT_LARK;
}
break;
@@ -320,7 +331,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x00), 2);
if (registerValue == 0x8700) {
type = STK8BAXX;
- LOG_INFO("STK8BAXX accelerometer found\n");
+ LOG_INFO("STK8BAXX accelerometer found");
break;
}
@@ -328,7 +339,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x07), 2);
if (registerValue == 0x0400) {
type = MCP9808;
- LOG_INFO("MCP9808 sensor found\n");
+ LOG_INFO("MCP9808 sensor found");
break;
}
@@ -336,7 +347,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x0F), 2);
if (registerValue == 0x3300 || registerValue == 0x3333) { // RAK4631 WisBlock has LIS3DH register at 0x3333
type = LIS3DH;
- LOG_INFO("LIS3DH accelerometer found\n");
+ LOG_INFO("LIS3DH accelerometer found");
}
break;
}
@@ -344,80 +355,109 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x89), 2);
if (registerValue == 0x11a2 || registerValue == 0x11da || registerValue == 0xe9c) {
type = SHT4X;
- LOG_INFO("SHT4X sensor found\n");
+ LOG_INFO("SHT4X sensor found");
} else if (getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x7E), 2) == 0x5449) {
type = OPT3001;
- LOG_INFO("OPT3001 light sensor found\n");
+ LOG_INFO("OPT3001 light sensor found");
} else {
type = SHT31;
- LOG_INFO("SHT31 sensor found\n");
+ LOG_INFO("SHT31 sensor found");
}
break;
- SCAN_SIMPLE_CASE(SHTC3_ADDR, SHTC3, "SHTC3 sensor found\n")
- SCAN_SIMPLE_CASE(RCWL9620_ADDR, RCWL9620, "RCWL9620 sensor found\n")
+ SCAN_SIMPLE_CASE(SHTC3_ADDR, SHTC3, "SHTC3 sensor found")
+ case RCWL9620_ADDR:
+ // get MAX30102 PARTID
+ registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0xFF), 1);
+ if (registerValue == 0x15) {
+ type = MAX30102;
+ LOG_INFO("MAX30102 Health sensor found");
+ break;
+ } else {
+ type = RCWL9620;
+ LOG_INFO("RCWL9620 sensor found");
+ }
+ break;
case LPS22HB_ADDR_ALT:
- SCAN_SIMPLE_CASE(LPS22HB_ADDR, LPS22HB, "LPS22HB sensor found\n")
+ SCAN_SIMPLE_CASE(LPS22HB_ADDR, LPS22HB, "LPS22HB sensor found")
- SCAN_SIMPLE_CASE(QMC6310_ADDR, QMC6310, "QMC6310 Highrate 3-Axis magnetic sensor found\n")
+ SCAN_SIMPLE_CASE(QMC6310_ADDR, QMC6310, "QMC6310 Highrate 3-Axis magnetic sensor found")
case QMI8658_ADDR:
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x0A), 1); // get ID
if (registerValue == 0xC0) {
type = BQ24295;
- LOG_INFO("BQ24295 PMU found\n");
+ LOG_INFO("BQ24295 PMU found");
break;
}
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x0F), 1); // get ID
if (registerValue == 0x6A) {
type = LSM6DS3;
- LOG_INFO("LSM6DS3 accelerometer found at address 0x%x\n", (uint8_t)addr.address);
+ LOG_INFO("LSM6DS3 accelerometer found at address 0x%x", (uint8_t)addr.address);
} else {
type = QMI8658;
- LOG_INFO("QMI8658 Highrate 6-Axis inertial measurement sensor found\n");
+ LOG_INFO("QMI8658 Highrate 6-Axis inertial measurement sensor found");
}
break;
- SCAN_SIMPLE_CASE(QMC5883L_ADDR, QMC5883L, "QMC5883L Highrate 3-Axis magnetic sensor found\n")
- SCAN_SIMPLE_CASE(HMC5883L_ADDR, HMC5883L, "HMC5883L 3-Axis digital compass found\n")
- SCAN_SIMPLE_CASE(PMSA0031_ADDR, PMSA0031, "PMSA0031 air quality sensor found\n")
- SCAN_SIMPLE_CASE(BMA423_ADDR, BMA423, "BMA423 accelerometer found\n");
- SCAN_SIMPLE_CASE(LSM6DS3_ADDR, LSM6DS3, "LSM6DS3 accelerometer found at address 0x%x\n", (uint8_t)addr.address);
- SCAN_SIMPLE_CASE(TCA9535_ADDR, TCA9535, "TCA9535 I2C expander found\n");
- SCAN_SIMPLE_CASE(TCA9555_ADDR, TCA9555, "TCA9555 I2C expander found\n");
- SCAN_SIMPLE_CASE(VEML7700_ADDR, VEML7700, "VEML7700 light sensor found\n");
- SCAN_SIMPLE_CASE(TSL25911_ADDR, TSL2591, "TSL2591 light sensor found\n");
- SCAN_SIMPLE_CASE(OPT3001_ADDR, OPT3001, "OPT3001 light sensor found\n");
- SCAN_SIMPLE_CASE(MLX90632_ADDR, MLX90632, "MLX90632 IR temp sensor found\n");
- SCAN_SIMPLE_CASE(NAU7802_ADDR, NAU7802, "NAU7802 based scale found\n");
- SCAN_SIMPLE_CASE(FT6336U_ADDR, FT6336U, "FT6336U touchscreen found\n");
- SCAN_SIMPLE_CASE(MAX1704X_ADDR, MAX17048, "MAX17048 lipo fuel gauge found\n");
+ SCAN_SIMPLE_CASE(QMC5883L_ADDR, QMC5883L, "QMC5883L Highrate 3-Axis magnetic sensor found")
+ SCAN_SIMPLE_CASE(HMC5883L_ADDR, HMC5883L, "HMC5883L 3-Axis digital compass found")
+#ifdef HAS_QMA6100P
+ SCAN_SIMPLE_CASE(QMA6100P_ADDR, QMA6100P, "QMA6100P accelerometer found")
+#else
+ SCAN_SIMPLE_CASE(PMSA0031_ADDR, PMSA0031, "PMSA0031 air quality sensor found")
+#endif
+ SCAN_SIMPLE_CASE(BMA423_ADDR, BMA423, "BMA423 accelerometer found");
+ SCAN_SIMPLE_CASE(LSM6DS3_ADDR, LSM6DS3, "LSM6DS3 accelerometer found at address 0x%x", (uint8_t)addr.address);
+ SCAN_SIMPLE_CASE(TCA9535_ADDR, TCA9535, "TCA9535 I2C expander found");
+ SCAN_SIMPLE_CASE(TCA9555_ADDR, TCA9555, "TCA9555 I2C expander found");
+ SCAN_SIMPLE_CASE(VEML7700_ADDR, VEML7700, "VEML7700 light sensor found");
+ SCAN_SIMPLE_CASE(TSL25911_ADDR, TSL2591, "TSL2591 light sensor found");
+ SCAN_SIMPLE_CASE(OPT3001_ADDR, OPT3001, "OPT3001 light sensor found");
+ SCAN_SIMPLE_CASE(MLX90632_ADDR, MLX90632, "MLX90632 IR temp sensor found");
+ SCAN_SIMPLE_CASE(NAU7802_ADDR, NAU7802, "NAU7802 based scale found");
+ SCAN_SIMPLE_CASE(FT6336U_ADDR, FT6336U, "FT6336U touchscreen found");
+ SCAN_SIMPLE_CASE(MAX1704X_ADDR, MAX17048, "MAX17048 lipo fuel gauge found");
+#ifdef HAS_TPS65233
+ SCAN_SIMPLE_CASE(TPS65233_ADDR, TPS65233, "TPS65233 BIAS-T found");
+#endif
+
+ case MLX90614_ADDR_DEF:
+ registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x0e), 1);
+ if (registerValue == 0x5a) {
+ type = MLX90614;
+ LOG_INFO("MLX90614 IR temp sensor found");
+ } else {
+ type = MPR121KB;
+ LOG_INFO("MPR121KB keyboard found");
+ }
+ break;
case ICM20948_ADDR: // same as BMX160_ADDR
case ICM20948_ADDR_ALT: // same as MPU6050_ADDR
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x00), 1);
if (registerValue == 0xEA) {
type = ICM20948;
- LOG_INFO("ICM20948 9-dof motion processor found\n");
+ LOG_INFO("ICM20948 9-dof motion processor found");
break;
} else if (addr.address == BMX160_ADDR) {
type = BMX160;
- LOG_INFO("BMX160 accelerometer found\n");
+ LOG_INFO("BMX160 accelerometer found");
break;
} else {
type = MPU6050;
- LOG_INFO("MPU6050 accelerometer found\n");
+ LOG_INFO("MPU6050 accelerometer found");
break;
}
break;
default:
- LOG_INFO("Device found at address 0x%x was not able to be enumerated\n", addr.address);
+ LOG_INFO("Device found at address 0x%x was not able to be enumerated", addr.address);
}
} else if (err == 4) {
- LOG_ERROR("Unknown error at address 0x%x\n", addr.address);
+ LOG_ERROR("Unknown error at address 0x%x", addr.address);
}
// Check if a type was found for the enumerated device - save, if so
diff --git a/src/detect/axpDebug.h b/src/detect/axpDebug.h
deleted file mode 100644
index fc95447aa5..0000000000
--- a/src/detect/axpDebug.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#if 0
-// Turn off for now
-uint32_t axpDebugRead()
-{
- axp.debugCharging();
- LOG_DEBUG("vbus current %f\n", axp.getVbusCurrent());
- LOG_DEBUG("charge current %f\n", axp.getBattChargeCurrent());
- LOG_DEBUG("bat voltage %f\n", axp.getBattVoltage());
- LOG_DEBUG("batt pct %d\n", axp.getBattPercentage());
- LOG_DEBUG("is battery connected %d\n", axp.isBatteryConnect());
- LOG_DEBUG("is USB connected %d\n", axp.isVBUSPlug());
- LOG_DEBUG("is charging %d\n", axp.isChargeing());
-
- return 30 * 1000;
-}
-
-Periodic axpDebugOutput(axpDebugRead);
-axpDebugOutput.setup();
-#endif
\ No newline at end of file
diff --git a/src/detect/einkScan.h b/src/detect/einkScan.h
index 6915709de2..d20c7b6e59 100644
--- a/src/detect/einkScan.h
+++ b/src/detect/einkScan.h
@@ -59,9 +59,9 @@ void scanEInkDevice(void)
d_writeCommand(0x20);
eink_found = (d_waitWhileBusy(150) > 0) ? true : false;
if (eink_found)
- LOG_DEBUG("EInk display found\n");
+ LOG_DEBUG("EInk display found");
else
- LOG_DEBUG("EInk display not found\n");
+ LOG_DEBUG("EInk display not found");
SPI1.end();
}
#endif
\ No newline at end of file
diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp
index 33c21c5bbe..3a9516c842 100644
--- a/src/gps/GPS.cpp
+++ b/src/gps/GPS.cpp
@@ -7,6 +7,7 @@
#include "PowerMon.h"
#include "RTC.h"
#include "Throttle.h"
+#include "buzz.h"
#include "meshUtils.h"
#include "main.h" // pmu_found
@@ -154,7 +155,7 @@ uint8_t GPS::makeCASPacket(uint8_t class_id, uint8_t msg_id, uint8_t payload_siz
CASChecksum(UBXscratch, (payload_size + 10));
#if defined(GPS_DEBUG) && defined(DEBUG_PORT)
- LOG_DEBUG("Constructed CAS packet: \n");
+ LOG_DEBUG("Constructed CAS packet: ");
DEBUG_PORT.hexDump(MESHTASTIC_LOG_LEVEL_DEBUG, UBXscratch, payload_size + 10);
#endif
return (payload_size + 10);
@@ -166,33 +167,33 @@ GPS_RESPONSE GPS::getACK(const char *message, uint32_t waitMillis)
uint8_t b;
int bytesRead = 0;
uint32_t startTimeout = millis() + waitMillis;
+#ifdef GPS_DEBUG
+ std::string debugmsg = "";
+#endif
while (millis() < startTimeout) {
if (_serial_gps->available()) {
b = _serial_gps->read();
#ifdef GPS_DEBUG
- LOG_DEBUG("%c", (b >= 32 && b <= 126) ? b : '.');
+ debugmsg += vformat("%c", (b >= 32 && b <= 126) ? b : '.');
#endif
buffer[bytesRead] = b;
bytesRead++;
if ((bytesRead == 767) || (b == '\r')) {
if (strnstr((char *)buffer, message, bytesRead) != nullptr) {
#ifdef GPS_DEBUG
- LOG_DEBUG("\r\nFound: %s\r\n", message); // Log the found message
+ LOG_DEBUG("Found: %s", message); // Log the found message
#endif
return GNSS_RESPONSE_OK;
} else {
bytesRead = 0;
#ifdef GPS_DEBUG
- LOG_DEBUG("\r\n");
+ LOG_DEBUG(debugmsg.c_str());
#endif
}
}
}
}
-#ifdef GPS_DEBUG
- LOG_DEBUG("\n");
-#endif
return GNSS_RESPONSE_NONE;
}
@@ -235,7 +236,7 @@ GPS_RESPONSE GPS::getACKCas(uint8_t class_id, uint8_t msg_id, uint32_t waitMilli
// Check for an ACK-ACK for the specified class and message id
if ((msg_cls == 0x05) && (msg_msg_id == 0x01) && payload_cls == class_id && payload_msg == msg_id) {
#ifdef GPS_DEBUG
- LOG_INFO("Got ACK for class %02X message %02X in %d millis.\n", class_id, msg_id, millis() - startTime);
+ LOG_INFO("Got ACK for class %02X message %02X in %d millis.", class_id, msg_id, millis() - startTime);
#endif
return GNSS_RESPONSE_OK;
}
@@ -243,7 +244,7 @@ GPS_RESPONSE GPS::getACKCas(uint8_t class_id, uint8_t msg_id, uint32_t waitMilli
// Check for an ACK-NACK for the specified class and message id
if ((msg_cls == 0x05) && (msg_msg_id == 0x00) && payload_cls == class_id && payload_msg == msg_id) {
#ifdef GPS_DEBUG
- LOG_WARN("Got NACK for class %02X message %02X in %d millis.\n", class_id, msg_id, millis() - startTime);
+ LOG_WARN("Got NACK for class %02X message %02X in %d millis.", class_id, msg_id, millis() - startTime);
#endif
return GNSS_RESPONSE_NAK;
}
@@ -266,6 +267,9 @@ GPS_RESPONSE GPS::getACK(uint8_t class_id, uint8_t msg_id, uint32_t waitMillis)
uint32_t startTime = millis();
const char frame_errors[] = "More than 100 frame errors";
int sCounter = 0;
+#ifdef GPS_DEBUG
+ std::string debugmsg = "";
+#endif
for (int j = 2; j < 6; j++) {
buf[8] += buf[j];
@@ -281,8 +285,8 @@ GPS_RESPONSE GPS::getACK(uint8_t class_id, uint8_t msg_id, uint32_t waitMillis)
while (Throttle::isWithinTimespanMs(startTime, waitMillis)) {
if (ack > 9) {
#ifdef GPS_DEBUG
- LOG_DEBUG("\n");
- LOG_INFO("Got ACK for class %02X message %02X in %d millis.\n", class_id, msg_id, millis() - startTime);
+ LOG_DEBUG("");
+ LOG_INFO("Got ACK for class %02X message %02X in %d millis.", class_id, msg_id, millis() - startTime);
#endif
return GNSS_RESPONSE_OK; // ACK received
}
@@ -291,22 +295,26 @@ GPS_RESPONSE GPS::getACK(uint8_t class_id, uint8_t msg_id, uint32_t waitMillis)
if (b == frame_errors[sCounter]) {
sCounter++;
if (sCounter == 26) {
+#ifdef GPS_DEBUG
+
+ LOG_DEBUG(debugmsg.c_str());
+#endif
return GNSS_RESPONSE_FRAME_ERRORS;
}
} else {
sCounter = 0;
}
#ifdef GPS_DEBUG
- LOG_DEBUG("%02X", b);
+ debugmsg += vformat("%02X", b);
#endif
if (b == buf[ack]) {
ack++;
} else {
if (ack == 3 && b == 0x00) { // UBX-ACK-NAK message
#ifdef GPS_DEBUG
- LOG_DEBUG("\n");
+ LOG_DEBUG(debugmsg.c_str());
#endif
- LOG_WARN("Got NAK for class %02X message %02X\n", class_id, msg_id);
+ LOG_WARN("Got NAK for class %02X message %02X", class_id, msg_id);
return GNSS_RESPONSE_NAK; // NAK received
}
ack = 0; // Reset the acknowledgement counter
@@ -314,8 +322,8 @@ GPS_RESPONSE GPS::getACK(uint8_t class_id, uint8_t msg_id, uint32_t waitMillis)
}
}
#ifdef GPS_DEBUG
- LOG_DEBUG("\n");
- LOG_WARN("No response for class %02X message %02X\n", class_id, msg_id);
+ LOG_DEBUG(debugmsg.c_str());
+ LOG_WARN("No response for class %02X message %02X", class_id, msg_id);
#endif
return GNSS_RESPONSE_NONE; // No response received within timeout
}
@@ -388,7 +396,7 @@ int GPS::getACK(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t
} else {
// return payload length
#ifdef GPS_DEBUG
- LOG_INFO("Got ACK for class %02X message %02X in %d millis.\n", requestedClass, requestedID,
+ LOG_INFO("Got ACK for class %02X message %02X in %d millis.", requestedClass, requestedID,
millis() - startTime);
#endif
return needRead;
@@ -400,7 +408,7 @@ int GPS::getACK(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t
}
}
}
- // LOG_WARN("No response for class %02X message %02X\n", requestedClass, requestedID);
+ // LOG_WARN("No response for class %02X message %02X", requestedClass, requestedID);
return 0;
}
@@ -416,13 +424,13 @@ bool GPS::setup()
speedSelect = std::find(serialSpeeds, std::end(serialSpeeds), GPS_BAUDRATE) - serialSpeeds;
}
- LOG_DEBUG("Probing for GPS at %d \n", serialSpeeds[speedSelect]);
+ LOG_DEBUG("Probing for GPS at %d", serialSpeeds[speedSelect]);
gnssModel = probe(serialSpeeds[speedSelect]);
if (gnssModel == GNSS_MODEL_UNKNOWN) {
if (++speedSelect == sizeof(serialSpeeds) / sizeof(int)) {
speedSelect = 0;
if (--probeTries == 0) {
- LOG_WARN("Giving up on GPS probe and setting to 9600.\n");
+ LOG_WARN("Giving up on GPS probe and setting to 9600.");
return true;
}
}
@@ -491,15 +499,15 @@ bool GPS::setup()
msglen = makeCASPacket(0x06, 0x01, sizeof(cas_cfg_msg_packet), cas_cfg_msg_packet);
_serial_gps->write(UBXscratch, msglen);
if (getACKCas(0x06, 0x01, 250) != GNSS_RESPONSE_OK) {
- LOG_WARN("ATGM336H - Could not enable NMEA MSG: %d\n", fields[i]);
+ LOG_WARN("ATGM336H - Could not enable NMEA MSG: %d", fields[i]);
}
}
} else if (gnssModel == GNSS_MODEL_UC6580) {
// The Unicore UC6580 can use a lot of sat systems, enable it to
- // use GPS L1 & L5 + BDS B1I & B2a + GLONASS L1 + GALILEO E1 & E5a + SBAS
+ // use GPS L1 & L5 + BDS B1I & B2a + GLONASS L1 + GALILEO E1 & E5a + SBAS + QZSS
// This will reset the receiver, so wait a bit afterwards
// The paranoid will wait for the OK*04 confirmation response after each command.
- _serial_gps->write("$CFGSYS,h25155\r\n");
+ _serial_gps->write("$CFGSYS,h35155\r\n");
delay(750);
// Must be done after the CFGSYS command
// Turn off GSV messages, we don't really care about which and where the sats are, maybe someday.
@@ -551,13 +559,13 @@ 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");
+ LOG_WARN("Unable to save GNSS module configuration.");
} else {
- LOG_INFO("GNSS module configuration saved!\n");
+ LOG_INFO("GNSS module configuration saved!");
}
} else if (IS_ONE_OF(gnssModel, GNSS_MODEL_UBLOX7, GNSS_MODEL_UBLOX8, GNSS_MODEL_UBLOX9)) {
if (gnssModel == GNSS_MODEL_UBLOX7) {
- LOG_DEBUG("Setting GPS+SBAS\n");
+ LOG_DEBUG("Setting GPS+SBAS");
msglen = makeUBXPacket(0x06, 0x3e, sizeof(_message_GNSS_7), _message_GNSS_7);
_serial_gps->write(UBXscratch, msglen);
} else { // 8,9
@@ -567,12 +575,12 @@ bool GPS::setup()
if (getACK(0x06, 0x3e, 800) == GNSS_RESPONSE_NAK) {
// It's not critical if the module doesn't acknowledge this configuration.
- LOG_INFO("reconfigure GNSS - defaults maintained. Is this module GPS-only?\n");
+ LOG_INFO("reconfigure GNSS - defaults maintained. Is this module GPS-only?");
} else {
if (gnssModel == GNSS_MODEL_UBLOX7) {
- LOG_INFO("GNSS configured for GPS+SBAS.\n");
+ LOG_INFO("GNSS configured for GPS+SBAS.");
} else { // 8,9
- LOG_INFO("GNSS configured for GPS+SBAS+GLONASS+Galileo.\n");
+ LOG_INFO("GNSS configured for GPS+SBAS+GLONASS+Galileo.");
}
// Documentation say, we need wait atleast 0.5s after reconfiguration of GNSS module, before sending next
// commands for the M8 it tends to be more... 1 sec should be enough ;>)
@@ -620,9 +628,9 @@ 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");
+ LOG_WARN("Unable to save GNSS module configuration.");
} else {
- LOG_INFO("GNSS module configuration saved!\n");
+ LOG_INFO("GNSS module configuration saved!");
}
} else if (gnssModel == GNSS_MODEL_UBLOX10) {
delay(1000);
@@ -667,9 +675,9 @@ bool GPS::setup()
msglen = makeUBXPacket(0x06, 0x09, sizeof(_message_SAVE_10), _message_SAVE_10);
_serial_gps->write(UBXscratch, msglen);
if (getACK(0x06, 0x09, 2000) != GNSS_RESPONSE_OK) {
- LOG_WARN("Unable to save GNSS module configuration.\n");
+ LOG_WARN("Unable to save GNSS module configuration.");
} else {
- LOG_INFO("GNSS module configuration saved!\n");
+ LOG_INFO("GNSS module configuration saved!");
}
}
didSerialInit = true;
@@ -691,7 +699,7 @@ void GPS::setPowerState(GPSPowerState newState, uint32_t sleepTime)
// Update the stored GPSPowerstate, and create local copies
GPSPowerState oldState = powerState;
powerState = newState;
- LOG_INFO("GPS power state moving from %s to %s\n", getGPSPowerStateString(oldState), getGPSPowerStateString(newState));
+ LOG_INFO("GPS power state moving from %s to %s", getGPSPowerStateString(oldState), getGPSPowerStateString(newState));
#ifdef HELTEC_MESH_NODE_T114
if ((oldState == GPS_OFF || oldState == GPS_HARDSLEEP) && (newState != GPS_OFF && newState != GPS_HARDSLEEP)) {
@@ -761,7 +769,7 @@ void GPS::writePinEN(bool on)
// Write and log
enablePin->set(on);
#ifdef GPS_EXTRAVERBOSE
- LOG_DEBUG("Pin EN %s\n", val == HIGH ? "HIGH" : "LOW");
+ LOG_DEBUG("Pin EN %s", val == HIGH ? "HIGH" : "LOW");
#endif
}
@@ -783,7 +791,7 @@ void GPS::writePinStandby(bool standby)
pinMode(PIN_GPS_STANDBY, OUTPUT);
digitalWrite(PIN_GPS_STANDBY, val);
#ifdef GPS_EXTRAVERBOSE
- LOG_DEBUG("Pin STANDBY %s\n", val == HIGH ? "HIGH" : "LOW");
+ LOG_DEBUG("Pin STANDBY %s", val == HIGH ? "HIGH" : "LOW");
#endif
#endif
}
@@ -817,7 +825,7 @@ void GPS::setPowerPMU(bool on)
}
#ifdef GPS_EXTRAVERBOSE
- LOG_DEBUG("PMU %s\n", on ? "on" : "off");
+ LOG_DEBUG("PMU %s", on ? "on" : "off");
#endif
#endif
}
@@ -834,7 +842,7 @@ void GPS::setPowerUBLOX(bool on, uint32_t sleepMs)
gps->_serial_gps->write(0xFF);
clearBuffer(); // This often returns old data, so drop it
#ifdef GPS_EXTRAVERBOSE
- LOG_DEBUG("UBLOX: wake\n");
+ LOG_DEBUG("UBLOX: wake");
#endif
}
@@ -849,7 +857,7 @@ void GPS::setPowerUBLOX(bool on, uint32_t sleepMs)
}
// Determine hardware version
- if (gnssModel == GNSS_MODEL_UBLOX10) {
+ if (gnssModel != GNSS_MODEL_UBLOX10) {
// Encode the sleep time in millis into the packet
for (int i = 0; i < 4; i++)
gps->_message_PMREQ[0 + i] = sleepMs >> (i * 8);
@@ -869,7 +877,7 @@ void GPS::setPowerUBLOX(bool on, uint32_t sleepMs)
gps->_serial_gps->write(gps->UBXscratch, msglen);
#ifdef GPS_EXTRAVERBOSE
- LOG_DEBUG("UBLOX: sleep for %dmS\n", sleepMs);
+ LOG_DEBUG("UBLOX: sleep for %dmS", sleepMs);
#endif
}
}
@@ -898,7 +906,7 @@ void GPS::down()
uint32_t sleepTime = scheduling.msUntilNextSearch();
uint32_t updateInterval = Default::getConfiguredOrDefaultMs(config.position.gps_update_interval);
- LOG_DEBUG("%us until next search\n", sleepTime / 1000);
+ LOG_DEBUG("%us until next search", sleepTime / 1000);
// If update interval less than 10 seconds, no attempt to sleep
if (updateInterval <= 10 * 1000UL || sleepTime == 0)
@@ -921,7 +929,7 @@ void GPS::down()
// https://www.desmos.com/calculator/6gvjghoumr
// This is not particularly accurate, but probably an impromevement over a single, fixed threshold
uint32_t hardsleepThreshold = (2750 * pow(predictedSearchDuration / 1000, 1.22));
- LOG_DEBUG("gps_update_interval >= %us needed to justify hardsleep\n", hardsleepThreshold / 1000);
+ LOG_DEBUG("gps_update_interval >= %us needed to justify hardsleep", hardsleepThreshold / 1000);
// If update interval too short: softsleep (if supported by hardware)
if (updateInterval < hardsleepThreshold) {
@@ -940,7 +948,7 @@ void GPS::publishUpdate()
shouldPublish = false;
// In debug logs, identify position by @timestamp:stage (stage 2 = publish)
- LOG_DEBUG("publishing pos@%x:2, hasVal=%d, Sats=%d, GPSlock=%d\n", p.timestamp, hasValidLocation, p.sats_in_view,
+ LOG_DEBUG("publishing pos@%x:2, hasVal=%d, Sats=%d, GPSlock=%d", p.timestamp, hasValidLocation, p.sats_in_view,
hasLock());
// Notify any status instances that are observing us
@@ -956,7 +964,7 @@ int32_t GPS::runOnce()
{
if (!GPSInitFinished) {
if (!_serial_gps || config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT) {
- LOG_INFO("GPS set to not-present. Skipping probe.\n");
+ LOG_INFO("GPS set to not-present. Skipping probe.");
return disable();
}
if (!setup())
@@ -968,7 +976,7 @@ int32_t GPS::runOnce()
}
// ONCE we will factory reset the GPS for bug #327
if (!devicestate.did_gps_reset) {
- LOG_WARN("GPS FactoryReset requested\n");
+ LOG_WARN("GPS FactoryReset requested");
if (gps->factoryReset()) { // If we don't succeed try again next time
devicestate.did_gps_reset = true;
nodeDB->saveToDisk(SEGMENT_DEVICESTATE);
@@ -991,7 +999,7 @@ int32_t GPS::runOnce()
GNSS_MODEL_UBLOX10)) {
// reset the GPS on next bootup
if (devicestate.did_gps_reset && scheduling.elapsedSearchMs() > 60 * 1000UL && !hasFlow()) {
- LOG_DEBUG("GPS is not communicating, trying factory reset on next bootup.\n");
+ LOG_DEBUG("GPS is not communicating, trying factory reset on next bootup.");
devicestate.did_gps_reset = false;
nodeDB->saveToDisk(SEGMENT_DEVICESTATE);
return disable(); // Stop the GPS thread as it can do nothing useful until next reboot.
@@ -1001,7 +1009,7 @@ int32_t GPS::runOnce()
// At least one GPS has a bad habit of losing its mind from time to time
if (rebootsSeen > 2) {
rebootsSeen = 0;
- LOG_DEBUG("Would normally factoryReset()\n");
+ LOG_DEBUG("Would normally factoryReset()");
// gps->factoryReset();
}
@@ -1018,23 +1026,23 @@ int32_t GPS::runOnce()
bool gotLoc = lookForLocation();
if (gotLoc && !hasValidLocation) { // declare that we have location ASAP
- LOG_DEBUG("hasValidLocation RISING EDGE\n");
+ LOG_DEBUG("hasValidLocation RISING EDGE");
hasValidLocation = true;
shouldPublish = true;
}
bool tooLong = scheduling.searchedTooLong();
if (tooLong)
- LOG_WARN("Couldn't publish a valid location: didn't get a GPS lock in time.\n");
+ LOG_WARN("Couldn't publish a valid location: didn't get a GPS lock in time.");
// Once we get a location we no longer desperately want an update
- // LOG_DEBUG("gotLoc %d, tooLong %d, gotTime %d\n", gotLoc, tooLong, gotTime);
+ // LOG_DEBUG("gotLoc %d, tooLong %d, gotTime %d", gotLoc, tooLong, gotTime);
if ((gotLoc && gotTime) || tooLong) {
if (tooLong) {
// we didn't get a location during this ack window, therefore declare loss of lock
if (hasValidLocation) {
- LOG_DEBUG("hasValidLocation FALLING EDGE\n");
+ LOG_DEBUG("hasValidLocation FALLING EDGE");
}
p = meshtastic_Position_init_default;
hasValidLocation = false;
@@ -1066,13 +1074,13 @@ void GPS::clearBuffer()
/// Prepare the GPS for the cpu entering deep or light sleep, expect to be gone for at least 100s of msecs
int GPS::prepareDeepSleep(void *unused)
{
- LOG_INFO("GPS deep sleep!\n");
+ LOG_INFO("GPS deep sleep!");
disable();
return 0;
}
-const char *PROBE_MESSAGE = "Trying %s (%s)...\n";
-const char *DETECTED_MESSAGE = "%s detected, using %s Module\n";
+const char *PROBE_MESSAGE = "Trying %s (%s)...";
+const char *DETECTED_MESSAGE = "%s detected, using %s Module";
#define PROBE_SIMPLE(CHIP, TOWRITE, RESPONSE, DRIVER, TIMEOUT, ...) \
LOG_DEBUG(PROBE_MESSAGE, TOWRITE, CHIP); \
@@ -1094,7 +1102,7 @@ GnssModel_t GPS::probe(int serialSpeed)
_serial_gps->begin(serialSpeed);
#else
if (_serial_gps->baudRate() != serialSpeed) {
- LOG_DEBUG("Setting Baud to %i\n", serialSpeed);
+ LOG_DEBUG("Setting Baud to %i", serialSpeed);
_serial_gps->updateBaudRate(serialSpeed);
}
#endif
@@ -1106,6 +1114,11 @@ GnssModel_t GPS::probe(int serialSpeed)
// Close all NMEA sentences, valid for L76K, ATGM336H (and likely other AT6558 devices)
_serial_gps->write("$PCAS03,0,0,0,0,0,0,0,0,0,0,,,0,0*02\r\n");
delay(20);
+ // Close NMEA sequences on Ublox
+ _serial_gps->write("$PUBX,40,GLL,0,0,0,0,0,0*5C\r\n");
+ _serial_gps->write("$PUBX,40,GSV,0,0,0,0,0,0*59\r\n");
+ _serial_gps->write("$PUBX,40,VTG,0,0,0,0,0,0*5E\r\n");
+ delay(20);
// Unicore UFirebirdII Series: UC6580, UM620, UM621, UM670A, UM680A, or UM681A
PROBE_SIMPLE("UC6580", "$PDTINFO", "UC6580", GNSS_MODEL_UC6580, 500);
@@ -1138,35 +1151,10 @@ GnssModel_t GPS::probe(int serialSpeed)
// Check that the returned response class and message ID are correct
GPS_RESPONSE response = getACK(0x06, 0x08, 750);
if (response == GNSS_RESPONSE_NONE) {
- LOG_WARN("Failed to find UBlox & MTK GNSS Module using baudrate %d\n", serialSpeed);
+ LOG_WARN("Failed to find GNSS Module (baudrate %d)", serialSpeed);
return GNSS_MODEL_UNKNOWN;
} else if (response == GNSS_RESPONSE_FRAME_ERRORS) {
- LOG_INFO("UBlox Frame Errors using baudrate %d\n", serialSpeed);
- } else if (response == GNSS_RESPONSE_OK) {
- LOG_INFO("Found a UBlox Module using baudrate %d\n", serialSpeed);
- }
-
- // tips: NMEA Only should not be set here, otherwise initializing Ublox gnss module again after
- // setting will not output command messages in UART1, resulting in unrecognized module information
- if (serialSpeed != 9600) {
- // Set the UART port to 9600
- uint8_t _message_prt[] = {0xB5, 0x62, 0x06, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0xD0, 0x08, 0x00, 0x00,
- 0x80, 0x25, 0x00, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- UBXChecksum(_message_prt, sizeof(_message_prt));
- _serial_gps->write(_message_prt, sizeof(_message_prt));
- delay(500);
- serialSpeed = 9600;
-#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_STM32WL)
- _serial_gps->end();
- _serial_gps->begin(serialSpeed);
-#elif defined(ARCH_RP2040)
- _serial_gps->end();
- _serial_gps->setFIFOSize(256);
- _serial_gps->begin(serialSpeed);
-#else
- _serial_gps->updateBaudRate(serialSpeed);
-#endif
- delay(200);
+ LOG_INFO("UBlox Frame Errors (baudrate %d)", serialSpeed);
}
memset(buffer, 0, sizeof(buffer));
@@ -1183,7 +1171,7 @@ GnssModel_t GPS::probe(int serialSpeed)
uint16_t len = getACK(buffer, sizeof(buffer), 0x0A, 0x04, 1200);
if (len) {
- // LOG_DEBUG("monver reply size = %d\n", len);
+ // LOG_DEBUG("monver reply size = %d", len);
uint16_t position = 0;
for (int i = 0; i < 30; i++) {
info.swVersion[i] = buffer[position];
@@ -1204,12 +1192,12 @@ GnssModel_t GPS::probe(int serialSpeed)
break;
}
- LOG_DEBUG("Module Info : \n");
- LOG_DEBUG("Soft version: %s\n", info.swVersion);
- LOG_DEBUG("Hard version: %s\n", info.hwVersion);
- LOG_DEBUG("Extensions:%d\n", info.extensionNo);
+ LOG_DEBUG("Module Info : ");
+ LOG_DEBUG("Soft version: %s", info.swVersion);
+ LOG_DEBUG("Hard version: %s", info.hwVersion);
+ LOG_DEBUG("Extensions:%d", info.extensionNo);
for (int i = 0; i < info.extensionNo; i++) {
- LOG_DEBUG(" %s\n", info.extension[i]);
+ LOG_DEBUG(" %s", info.extension[i]);
}
memset(buffer, 0, sizeof(buffer));
@@ -1218,38 +1206,37 @@ GnssModel_t GPS::probe(int serialSpeed)
for (int i = 0; i < info.extensionNo; ++i) {
if (!strncmp(info.extension[i], "MOD=", 4)) {
strncpy((char *)buffer, &(info.extension[i][4]), sizeof(buffer));
- // LOG_DEBUG("GetModel:%s\n", (char *)buffer);
- if (strlen((char *)buffer)) {
- LOG_INFO("%s detected, using GNSS_MODEL_UBLOX\n", (char *)buffer);
- } else {
- LOG_INFO("Generic Ublox detected, using GNSS_MODEL_UBLOX\n");
- }
} else if (!strncmp(info.extension[i], "PROTVER", 7)) {
char *ptr = nullptr;
memset(buffer, 0, sizeof(buffer));
strncpy((char *)buffer, &(info.extension[i][8]), sizeof(buffer));
- LOG_DEBUG("Protocol Version:%s\n", (char *)buffer);
+ LOG_DEBUG("Protocol Version:%s", (char *)buffer);
if (strlen((char *)buffer)) {
uBloxProtocolVersion = strtoul((char *)buffer, &ptr, 10);
- LOG_DEBUG("ProtVer=%d\n", uBloxProtocolVersion);
+ LOG_DEBUG("ProtVer=%d", uBloxProtocolVersion);
} else {
uBloxProtocolVersion = 0;
}
}
}
if (strncmp(info.hwVersion, "00040007", 8) == 0) {
+ LOG_INFO(DETECTED_MESSAGE, "U-blox 6", "6");
return GNSS_MODEL_UBLOX6;
} else if (strncmp(info.hwVersion, "00070000", 8) == 0) {
+ LOG_INFO(DETECTED_MESSAGE, "U-blox 7", "7");
return GNSS_MODEL_UBLOX7;
} else if (strncmp(info.hwVersion, "00080000", 8) == 0) {
+ LOG_INFO(DETECTED_MESSAGE, "U-blox 8", "8");
return GNSS_MODEL_UBLOX8;
} else if (strncmp(info.hwVersion, "00190000", 8) == 0) {
+ LOG_INFO(DETECTED_MESSAGE, "U-blox 9", "9");
return GNSS_MODEL_UBLOX9;
} else if (strncmp(info.hwVersion, "000A0000", 8) == 0) {
+ LOG_INFO(DETECTED_MESSAGE, "U-blox 10", "10");
return GNSS_MODEL_UBLOX10;
}
}
-
+ LOG_WARN("Failed to find GNSS Module (baudrate %d)", serialSpeed);
return GNSS_MODEL_UNKNOWN;
}
@@ -1310,7 +1297,7 @@ GPS *GPS::createGps()
// see NMEAGPS.h
gsafixtype.begin(reader, NMEA_MSG_GXGSA, 2);
gsapdop.begin(reader, NMEA_MSG_GXGSA, 15);
- LOG_DEBUG("Using " NMEA_MSG_GXGSA " for 3DFIX and PDOP\n");
+ LOG_DEBUG("Using " NMEA_MSG_GXGSA " for 3DFIX and PDOP");
#endif
// Make sure the GPS is awake before performing any init.
@@ -1331,8 +1318,8 @@ GPS *GPS::createGps()
// ESP32 has a special set of parameters vs other arduino ports
#if defined(ARCH_ESP32)
- LOG_DEBUG("Using GPIO%d for GPS RX\n", new_gps->rx_gpio);
- LOG_DEBUG("Using GPIO%d for GPS TX\n", new_gps->tx_gpio);
+ LOG_DEBUG("Using GPIO%d for GPS RX", new_gps->rx_gpio);
+ LOG_DEBUG("Using GPIO%d for GPS TX", new_gps->tx_gpio);
_serial_gps->begin(GPS_BAUDRATE, SERIAL_8N1, new_gps->rx_gpio, new_gps->tx_gpio);
#elif defined(ARCH_RP2040)
_serial_gps->setFIFOSize(256);
@@ -1390,11 +1377,11 @@ bool GPS::factoryReset()
// delay(1000);
} else if (gnssModel == GNSS_MODEL_MTK) {
// send the CAS10 to perform a factory restart of the device (and other device that support PCAS statements)
- LOG_INFO("GNSS Factory Reset via PCAS10,3\n");
+ LOG_INFO("GNSS Factory Reset via PCAS10,3");
_serial_gps->write("$PCAS10,3*1F\r\n");
delay(100);
} else if (gnssModel == GNSS_MODEL_ATGM336H) {
- LOG_INFO("Factory Reset via CAS-CFG-RST\n");
+ LOG_INFO("Factory Reset via CAS-CFG-RST");
uint8_t msglen = makeCASPacket(0x06, 0x02, sizeof(_message_CAS_CFG_RST_FACTORY), _message_CAS_CFG_RST_FACTORY);
_serial_gps->write(UBXscratch, msglen);
delay(100);
@@ -1455,7 +1442,7 @@ The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of s
t.tm_year = d.year() - 1900;
t.tm_isdst = false;
if (t.tm_mon > -1) {
- LOG_DEBUG("NMEA GPS time %02d-%02d-%02d %02d:%02d:%02d age %d\n", d.year(), d.month(), t.tm_mday, t.tm_hour, t.tm_min,
+ LOG_DEBUG("NMEA GPS time %02d-%02d-%02d %02d:%02d:%02d age %d", d.year(), d.month(), t.tm_mday, t.tm_hour, t.tm_min,
t.tm_sec, ti.age());
perhapsSetRTC(RTCQualityGPS, t);
return true;
@@ -1499,7 +1486,7 @@ bool GPS::lookForLocation()
#ifndef TINYGPS_OPTION_NO_STATISTICS
if (reader.failedChecksum() > lastChecksumFailCount) {
- LOG_WARN("%u new GPS checksum failures, for a total of %u.\n", reader.failedChecksum() - lastChecksumFailCount,
+ LOG_WARN("%u new GPS checksum failures, for a total of %u.", reader.failedChecksum() - lastChecksumFailCount,
reader.failedChecksum());
lastChecksumFailCount = reader.failedChecksum();
}
@@ -1507,7 +1494,7 @@ bool GPS::lookForLocation()
#ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS
fixType = atoi(gsafixtype.value()); // will set to zero if no data
- // LOG_DEBUG("FIX QUAL=%d, TYPE=%d\n", fixQual, fixType);
+ // LOG_DEBUG("FIX QUAL=%d, TYPE=%d", fixQual, fixType);
#endif
// check if GPS has an acceptable lock
@@ -1515,7 +1502,7 @@ bool GPS::lookForLocation()
return false;
#ifdef GPS_EXTRAVERBOSE
- LOG_DEBUG("AGE: LOC=%d FIX=%d DATE=%d TIME=%d\n", reader.location.age(),
+ LOG_DEBUG("AGE: LOC=%d FIX=%d DATE=%d TIME=%d", reader.location.age(),
#ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS
gsafixtype.age(),
#else
@@ -1536,7 +1523,7 @@ bool GPS::lookForLocation()
(gsafixtype.age() < GPS_SOL_EXPIRY_MS) &&
#endif
(reader.time.age() < GPS_SOL_EXPIRY_MS) && (reader.date.age() < GPS_SOL_EXPIRY_MS))) {
- LOG_WARN("SOME data is TOO OLD: LOC %u, TIME %u, DATE %u\n", reader.location.age(), reader.time.age(), reader.date.age());
+ LOG_WARN("SOME data is TOO OLD: LOC %u, TIME %u, DATE %u", reader.location.age(), reader.time.age(), reader.date.age());
return false;
}
@@ -1546,13 +1533,13 @@ bool GPS::lookForLocation()
// Bail out EARLY to avoid overwriting previous good data (like #857)
if (toDegInt(loc.lat) > 900000000) {
#ifdef GPS_EXTRAVERBOSE
- LOG_DEBUG("Bail out EARLY on LAT %i\n", toDegInt(loc.lat));
+ LOG_DEBUG("Bail out EARLY on LAT %i", toDegInt(loc.lat));
#endif
return false;
}
if (toDegInt(loc.lng) > 1800000000) {
#ifdef GPS_EXTRAVERBOSE
- LOG_DEBUG("Bail out EARLY on LNG %i\n", toDegInt(loc.lng));
+ LOG_DEBUG("Bail out EARLY on LNG %i", toDegInt(loc.lng));
#endif
return false;
}
@@ -1563,7 +1550,7 @@ bool GPS::lookForLocation()
#ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS
p.HDOP = reader.hdop.value();
p.PDOP = TinyGPSPlus::parseDecimal(gsapdop.value());
- // LOG_DEBUG("PDOP=%d, HDOP=%d\n", p.PDOP, p.HDOP);
+ // LOG_DEBUG("PDOP=%d, HDOP=%d", p.PDOP, p.HDOP);
#else
// FIXME! naive PDOP emulation (assumes VDOP==HDOP)
// correct formula is PDOP = SQRT(HDOP^2 + VDOP^2)
@@ -1573,7 +1560,7 @@ bool GPS::lookForLocation()
// Discard incomplete or erroneous readings
if (reader.hdop.value() == 0) {
- LOG_WARN("BOGUS hdop.value() REJECTED: %d\n", reader.hdop.value());
+ LOG_WARN("BOGUS hdop.value() REJECTED: %d", reader.hdop.value());
return false;
}
@@ -1610,7 +1597,7 @@ bool GPS::lookForLocation()
p.ground_track =
reader.course.value() * 1e3; // Scale the heading (in degrees * 10^-2) to match the expected degrees * 10^-5
} else {
- LOG_WARN("BOGUS course.value() REJECTED: %d\n", reader.course.value());
+ LOG_WARN("BOGUS course.value() REJECTED: %d", reader.course.value());
}
}
@@ -1644,24 +1631,27 @@ bool GPS::whileActive()
{
unsigned int charsInBuf = 0;
bool isValid = false;
+#ifdef GPS_DEBUG
+ std::string debugmsg = "";
+#endif
if (powerState != GPS_ACTIVE) {
clearBuffer();
return false;
}
#ifdef SERIAL_BUFFER_SIZE
if (_serial_gps->available() >= SERIAL_BUFFER_SIZE - 1) {
- LOG_WARN("GPS Buffer full with %u bytes waiting. Flushing to avoid corruption.\n", _serial_gps->available());
+ LOG_WARN("GPS Buffer full with %u bytes waiting. Flushing to avoid corruption.", _serial_gps->available());
clearBuffer();
}
#endif
// if (_serial_gps->available() > 0)
- // LOG_DEBUG("GPS Bytes Waiting: %u\n", _serial_gps->available());
+ // LOG_DEBUG("GPS Bytes Waiting: %u", _serial_gps->available());
// First consume any chars that have piled up at the receiver
while (_serial_gps->available() > 0) {
int c = _serial_gps->read();
UBXscratch[charsInBuf] = c;
#ifdef GPS_DEBUG
- LOG_DEBUG("%c", c);
+ debugmsg += vformat("%c", (c >= 32 && c <= 126) ? c : '.');
#endif
isValid |= reader.encode(c);
if (charsInBuf > sizeof(UBXscratch) - 10 || c == '\r') {
@@ -1673,6 +1663,9 @@ bool GPS::whileActive()
charsInBuf++;
}
}
+#ifdef GPS_DEBUG
+ LOG_DEBUG(debugmsg.c_str());
+#endif
return isValid;
}
void GPS::enable()
@@ -1700,17 +1693,19 @@ void GPS::toggleGpsMode()
{
if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED) {
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_DISABLED;
- LOG_INFO("User toggled GpsMode. Now DISABLED.\n");
+ LOG_INFO("User toggled GpsMode. Now DISABLED.");
+ playGPSDisableBeep();
#ifdef GNSS_AIROHA
if (powerState == GPS_ACTIVE) {
- LOG_DEBUG("User power Off GPS\n");
+ LOG_DEBUG("User power Off GPS");
digitalWrite(PIN_GPS_EN, LOW);
}
#endif
disable();
} else if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_DISABLED) {
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_ENABLED;
- LOG_INFO("User toggled GpsMode. Now ENABLED\n");
+ LOG_INFO("User toggled GpsMode. Now ENABLED");
+ playGPSEnableBeep();
enable();
}
}
diff --git a/src/gps/GPS.h b/src/gps/GPS.h
index 6222881bc6..8b1982cf74 100644
--- a/src/gps/GPS.h
+++ b/src/gps/GPS.h
@@ -75,7 +75,7 @@ class GPS : private concurrency::OSThread
uint8_t fixType = 0; // fix type from GPGSA
#endif
private:
- const int serialSpeeds[6] = {9600, 4800, 38400, 57600, 115200, 9600};
+ const int serialSpeeds[6] = {9600, 115200, 38400, 4800, 57600, 9600};
uint32_t lastWakeStartMsec = 0, lastSleepStartMsec = 0, lastFixStartMsec = 0;
uint32_t rx_gpio = 0;
uint32_t tx_gpio = 0;
@@ -156,7 +156,7 @@ class GPS : private concurrency::OSThread
static const uint8_t _message_CAS_CFG_NAVX_CONF[];
static const uint8_t _message_CAS_CFG_RATE_1HZ[];
- const char *ACK_SUCCESS_MESSAGE = "Get ack success!\n";
+ const char *ACK_SUCCESS_MESSAGE = "Get ack success!";
meshtastic_Position p = meshtastic_Position_init_default;
diff --git a/src/gps/GPSUpdateScheduling.cpp b/src/gps/GPSUpdateScheduling.cpp
index 949ef60397..9c2626e848 100644
--- a/src/gps/GPSUpdateScheduling.cpp
+++ b/src/gps/GPSUpdateScheduling.cpp
@@ -13,7 +13,7 @@ void GPSUpdateScheduling::informSearching()
void GPSUpdateScheduling::informGotLock()
{
searchEndedMs = millis();
- LOG_DEBUG("Took %us to get lock\n", (searchEndedMs - searchStartedMs) / 1000);
+ LOG_DEBUG("Took %us to get lock", (searchEndedMs - searchStartedMs) / 1000);
updateLockTimePrediction();
}
@@ -108,7 +108,7 @@ void GPSUpdateScheduling::updateLockTimePrediction()
searchCount++; // Only tracked so we can diregard initial lock-times
- LOG_DEBUG("Predicting %us to get next lock\n", predictedMsToGetLock / 1000);
+ LOG_DEBUG("Predicting %us to get next lock", predictedMsToGetLock / 1000);
}
// How long do we expect to spend searching for a lock?
diff --git a/src/gps/RTC.cpp b/src/gps/RTC.cpp
index d9ac56b743..8130d76681 100644
--- a/src/gps/RTC.cpp
+++ b/src/gps/RTC.cpp
@@ -46,7 +46,7 @@ void readFromRTC()
tv.tv_usec = 0;
uint32_t printableEpoch = tv.tv_sec; // Print lib only supports 32 bit but time_t can be 64 bit on some platforms
- LOG_DEBUG("Read RTC time from RV3028 getTime as %02d-%02d-%02d %02d:%02d:%02d (%ld)\n", t.tm_year + 1900, t.tm_mon + 1,
+ LOG_DEBUG("Read RTC time from RV3028 getTime as %02d-%02d-%02d %02d:%02d:%02d (%ld)", t.tm_year + 1900, t.tm_mon + 1,
t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec, printableEpoch);
timeStartMsec = now;
zeroOffsetSecs = tv.tv_sec;
@@ -77,8 +77,8 @@ void readFromRTC()
tv.tv_usec = 0;
uint32_t printableEpoch = tv.tv_sec; // Print lib only supports 32 bit but time_t can be 64 bit on some platforms
- LOG_DEBUG("Read RTC time from PCF8563 getDateTime as %02d-%02d-%02d %02d:%02d:%02d (%ld)\n", t.tm_year + 1900,
- t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec, printableEpoch);
+ LOG_DEBUG("Read RTC time from PCF8563 getDateTime as %02d-%02d-%02d %02d:%02d:%02d (%ld)", t.tm_year + 1900, t.tm_mon + 1,
+ t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec, printableEpoch);
timeStartMsec = now;
zeroOffsetSecs = tv.tv_sec;
if (currentQuality == RTCQualityNone) {
@@ -89,7 +89,7 @@ void readFromRTC()
if (!gettimeofday(&tv, NULL)) {
uint32_t now = millis();
uint32_t printableEpoch = tv.tv_sec; // Print lib only supports 32 bit but time_t can be 64 bit on some platforms
- LOG_DEBUG("Read RTC time as %ld\n", printableEpoch);
+ LOG_DEBUG("Read RTC time as %ld", printableEpoch);
timeStartMsec = now;
zeroOffsetSecs = tv.tv_sec;
}
@@ -112,7 +112,7 @@ bool perhapsSetRTC(RTCQuality q, const struct timeval *tv, bool forceUpdate)
uint32_t printableEpoch = tv->tv_sec; // Print lib only supports 32 bit but time_t can be 64 bit on some platforms
#ifdef BUILD_EPOCH
if (tv->tv_sec < BUILD_EPOCH) {
- LOG_WARN("Ignoring time (%ld) before build epoch (%ld)!\n", printableEpoch, BUILD_EPOCH);
+ LOG_WARN("Ignoring time (%ld) before build epoch (%ld)!", printableEpoch, BUILD_EPOCH);
return false;
}
#endif
@@ -120,21 +120,21 @@ bool perhapsSetRTC(RTCQuality q, const struct timeval *tv, bool forceUpdate)
bool shouldSet;
if (forceUpdate) {
shouldSet = true;
- LOG_DEBUG("Overriding current RTC quality (%s) with incoming time of RTC quality of %s\n", RtcName(currentQuality),
+ LOG_DEBUG("Overriding current RTC quality (%s) with incoming time of RTC quality of %s", RtcName(currentQuality),
RtcName(q));
} else if (q > currentQuality) {
shouldSet = true;
- LOG_DEBUG("Upgrading time to quality %s\n", RtcName(q));
+ LOG_DEBUG("Upgrading time to quality %s", RtcName(q));
} else if (q == RTCQualityGPS) {
shouldSet = true;
- LOG_DEBUG("Reapplying GPS time: %ld secs\n", printableEpoch);
+ LOG_DEBUG("Reapplying GPS time: %ld secs", printableEpoch);
} else if (q == RTCQualityNTP && !Throttle::isWithinTimespanMs(lastSetMsec, (12 * 60 * 60 * 1000UL))) {
// Every 12 hrs we will slam in a new NTP or Phone GPS / NTP time, to correct for local RTC clock drift
shouldSet = true;
- LOG_DEBUG("Reapplying external time to correct clock drift %ld secs\n", printableEpoch);
+ LOG_DEBUG("Reapplying external time to correct clock drift %ld secs", printableEpoch);
} else {
shouldSet = false;
- LOG_DEBUG("Current RTC quality: %s. Ignoring time of RTC quality of %s\n", RtcName(currentQuality), RtcName(q));
+ LOG_DEBUG("Current RTC quality: %s. Ignoring time of RTC quality of %s", RtcName(currentQuality), RtcName(q));
}
if (shouldSet) {
@@ -158,7 +158,7 @@ bool perhapsSetRTC(RTCQuality q, const struct timeval *tv, bool forceUpdate)
#endif
tm *t = gmtime(&tv->tv_sec);
rtc.setTime(t->tm_year + 1900, t->tm_mon + 1, t->tm_wday, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
- LOG_DEBUG("RV3028_RTC setTime %02d-%02d-%02d %02d:%02d:%02d (%ld)\n", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
+ LOG_DEBUG("RV3028_RTC setTime %02d-%02d-%02d %02d:%02d:%02d (%ld)", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
t->tm_hour, t->tm_min, t->tm_sec, printableEpoch);
}
#elif defined(PCF8563_RTC)
@@ -172,8 +172,8 @@ bool perhapsSetRTC(RTCQuality q, const struct timeval *tv, bool forceUpdate)
#endif
tm *t = gmtime(&tv->tv_sec);
rtc.setDateTime(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
- LOG_DEBUG("PCF8563_RTC setDateTime %02d-%02d-%02d %02d:%02d:%02d (%ld)\n", t->tm_year + 1900, t->tm_mon + 1,
- t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, printableEpoch);
+ LOG_DEBUG("PCF8563_RTC setDateTime %02d-%02d-%02d %02d:%02d:%02d (%ld)", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
+ t->tm_hour, t->tm_min, t->tm_sec, printableEpoch);
}
#elif defined(ARCH_ESP32)
settimeofday(tv, NULL);
@@ -228,9 +228,9 @@ bool perhapsSetRTC(RTCQuality q, struct tm &t)
tv.tv_sec = res;
tv.tv_usec = 0; // time.centisecond() * (10 / 1000);
- // LOG_DEBUG("Got time from GPS month=%d, year=%d, unixtime=%ld\n", t.tm_mon, t.tm_year, tv.tv_sec);
+ // LOG_DEBUG("Got time from GPS month=%d, year=%d, unixtime=%ld", t.tm_mon, t.tm_year, tv.tv_sec);
if (t.tm_year < 0 || t.tm_year >= 300) {
- // LOG_DEBUG("Ignoring invalid GPS month=%d, year=%d, unixtime=%ld\n", t.tm_mon, t.tm_year, tv.tv_sec);
+ // LOG_DEBUG("Ignoring invalid GPS month=%d, year=%d, unixtime=%ld", t.tm_mon, t.tm_year, tv.tv_sec);
return false;
} else {
return perhapsSetRTC(q, &tv);
diff --git a/src/gps/ubx.h b/src/gps/ubx.h
index b137d3349b..68cca00a3c 100644
--- a/src/gps/ubx.h
+++ b/src/gps/ubx.h
@@ -1,4 +1,4 @@
-const char *failMessage = "Unable to %s\n";
+const char *failMessage = "Unable to %s";
#define SEND_UBX_PACKET(TYPE, ID, DATA, ERRMSG, TIMEOUT) \
msglen = makeUBXPacket(TYPE, ID, sizeof(DATA), DATA); \
diff --git a/src/graphics/EInkDisplay2.cpp b/src/graphics/EInkDisplay2.cpp
index c4cb10f827..1d3b2f6055 100644
--- a/src/graphics/EInkDisplay2.cpp
+++ b/src/graphics/EInkDisplay2.cpp
@@ -79,13 +79,13 @@ bool EInkDisplay::forceDisplay(uint32_t msecLimit)
}
// Trigger the refresh in GxEPD2
- LOG_DEBUG("Updating E-Paper... ");
+ LOG_DEBUG("Updating E-Paper");
adafruitDisplay->nextPage();
// End the update process
endUpdate();
- LOG_DEBUG("done\n");
+ LOG_DEBUG("done");
return true;
}
@@ -123,7 +123,7 @@ void EInkDisplay::setDetected(uint8_t detected)
// Connect to the display - variant specific
bool EInkDisplay::connect()
{
- LOG_INFO("Doing EInk init\n");
+ LOG_INFO("Doing EInk init");
#ifdef PIN_EINK_EN
// backlight power, HIGH is backlight on, LOW is off
diff --git a/src/graphics/EInkDynamicDisplay.cpp b/src/graphics/EInkDynamicDisplay.cpp
index ca994b2c90..ac5755bc14 100644
--- a/src/graphics/EInkDynamicDisplay.cpp
+++ b/src/graphics/EInkDynamicDisplay.cpp
@@ -119,7 +119,7 @@ void EInkDynamicDisplay::endOrDetach()
awaitRefresh();
else {
// Async begins
- LOG_DEBUG("Async full-refresh begins (dropping frames)\n");
+ LOG_DEBUG("Async full-refresh begins (dropping frames)");
notifyLater(intervalPollAsyncRefresh, DUE_POLL_ASYNCREFRESH, true); // Hand-off to NotifiedWorkerThread
}
}
@@ -133,7 +133,7 @@ void EInkDynamicDisplay::endOrDetach()
if (previousRefresh == FULL || previousRefresh == FAST) { // If refresh wasn't skipped (on unspecified..)
LOG_WARN(
"GxEPD2 version has not been modified to support async refresh; using fallback behavior. Please update lib_deps in "
- "variant's platformio.ini file\n");
+ "variant's platformio.ini file");
EInkDisplay::endUpdate();
}
#endif
@@ -170,7 +170,7 @@ bool EInkDynamicDisplay::determineMode()
checkFastRequested();
if (refresh == UNSPECIFIED)
- LOG_WARN("There was a flaw in the determineMode() logic.\n");
+ LOG_WARN("There was a flaw in the determineMode() logic.");
// -- Decision has been reached --
applyRefreshMode();
@@ -254,7 +254,7 @@ void EInkDynamicDisplay::checkRateLimiting()
if (Throttle::isWithinTimespanMs(previousRunMs, EINK_LIMIT_RATE_RESPONSIVE_SEC * 1000)) {
refresh = SKIPPED;
reason = EXCEEDED_RATELIMIT_FAST;
- LOG_DEBUG("refresh=SKIPPED, reason=EXCEEDED_RATELIMIT_FAST, frameFlags=0x%x\n", frameFlags);
+ LOG_DEBUG("refresh=SKIPPED, reason=EXCEEDED_RATELIMIT_FAST, frameFlags=0x%x", frameFlags);
return;
}
}
@@ -271,7 +271,7 @@ void EInkDynamicDisplay::checkCosmetic()
if (frameFlags & COSMETIC) {
refresh = FULL;
reason = FLAGGED_COSMETIC;
- LOG_DEBUG("refresh=FULL, reason=FLAGGED_COSMETIC, frameFlags=0x%x\n", frameFlags);
+ LOG_DEBUG("refresh=FULL, reason=FLAGGED_COSMETIC, frameFlags=0x%x", frameFlags);
}
}
@@ -286,7 +286,7 @@ void EInkDynamicDisplay::checkDemandingFast()
if (frameFlags & DEMAND_FAST) {
refresh = FAST;
reason = FLAGGED_DEMAND_FAST;
- LOG_DEBUG("refresh=FAST, reason=FLAGGED_DEMAND_FAST, frameFlags=0x%x\n", frameFlags);
+ LOG_DEBUG("refresh=FAST, reason=FLAGGED_DEMAND_FAST, frameFlags=0x%x", frameFlags);
}
}
@@ -306,7 +306,7 @@ void EInkDynamicDisplay::checkFrameMatchesPrevious()
if (frameFlags == BACKGROUND && fastRefreshCount > 0) {
refresh = FULL;
reason = REDRAW_WITH_FULL;
- LOG_DEBUG("refresh=FULL, reason=REDRAW_WITH_FULL, frameFlags=0x%x\n", frameFlags);
+ LOG_DEBUG("refresh=FULL, reason=REDRAW_WITH_FULL, frameFlags=0x%x", frameFlags);
return;
}
#endif
@@ -314,7 +314,7 @@ void EInkDynamicDisplay::checkFrameMatchesPrevious()
// Not redrawn, not COSMETIC, not DEMAND_FAST
refresh = SKIPPED;
reason = FRAME_MATCHED_PREVIOUS;
- LOG_DEBUG("refresh=SKIPPED, reason=FRAME_MATCHED_PREVIOUS, frameFlags=0x%x\n", frameFlags);
+ LOG_DEBUG("refresh=SKIPPED, reason=FRAME_MATCHED_PREVIOUS, frameFlags=0x%x", frameFlags);
}
// Have too many fast-refreshes occured consecutively, since last full refresh?
@@ -328,7 +328,7 @@ void EInkDynamicDisplay::checkConsecutiveFastRefreshes()
if (fastRefreshCount >= EINK_LIMIT_FASTREFRESH) {
refresh = FULL;
reason = EXCEEDED_LIMIT_FASTREFRESH;
- LOG_DEBUG("refresh=FULL, reason=EXCEEDED_LIMIT_FASTREFRESH, frameFlags=0x%x\n", frameFlags);
+ LOG_DEBUG("refresh=FULL, reason=EXCEEDED_LIMIT_FASTREFRESH, frameFlags=0x%x", frameFlags);
}
}
@@ -343,13 +343,13 @@ void EInkDynamicDisplay::checkFastRequested()
// If we want BACKGROUND to use fast. (FULL only when a limit is hit)
refresh = FAST;
reason = BACKGROUND_USES_FAST;
- LOG_DEBUG("refresh=FAST, reason=BACKGROUND_USES_FAST, fastRefreshCount=%lu, frameFlags=0x%x\n", fastRefreshCount,
+ LOG_DEBUG("refresh=FAST, reason=BACKGROUND_USES_FAST, fastRefreshCount=%lu, frameFlags=0x%x", fastRefreshCount,
frameFlags);
#else
// If we do want to use FULL for BACKGROUND updates
refresh = FULL;
reason = FLAGGED_BACKGROUND;
- LOG_DEBUG("refresh=FULL, reason=FLAGGED_BACKGROUND\n");
+ LOG_DEBUG("refresh=FULL, reason=FLAGGED_BACKGROUND");
#endif
}
@@ -357,7 +357,7 @@ void EInkDynamicDisplay::checkFastRequested()
if (frameFlags & RESPONSIVE) {
refresh = FAST;
reason = NO_OBJECTIONS;
- LOG_DEBUG("refresh=FAST, reason=NO_OBJECTIONS, fastRefreshCount=%lu, frameFlags=0x%x\n", fastRefreshCount, frameFlags);
+ LOG_DEBUG("refresh=FAST, reason=NO_OBJECTIONS, fastRefreshCount=%lu, frameFlags=0x%x", fastRefreshCount, frameFlags);
}
}
@@ -438,7 +438,7 @@ void EInkDynamicDisplay::checkExcessiveGhosting()
if (ghostPixelCount > EINK_LIMIT_GHOSTING_PX) {
refresh = FULL;
reason = EXCEEDED_GHOSTINGLIMIT;
- LOG_DEBUG("refresh=FULL, reason=EXCEEDED_GHOSTINGLIMIT, frameFlags=0x%x\n", frameFlags);
+ LOG_DEBUG("refresh=FULL, reason=EXCEEDED_GHOSTINGLIMIT, frameFlags=0x%x", frameFlags);
}
}
@@ -469,7 +469,7 @@ void EInkDynamicDisplay::joinAsyncRefresh()
if (!asyncRefreshRunning)
return;
- LOG_DEBUG("Joining an async refresh in progress\n");
+ LOG_DEBUG("Joining an async refresh in progress");
// Continually poll the BUSY pin
while (adafruitDisplay->epd2.isBusy())
@@ -479,7 +479,7 @@ void EInkDynamicDisplay::joinAsyncRefresh()
adafruitDisplay->endAsyncFull(); // Run the end of nextPage() code
EInkDisplay::endUpdate(); // Run base-class code to finish off update (NOT our derived class override)
asyncRefreshRunning = false; // Unset the flag
- LOG_DEBUG("Refresh complete\n");
+ LOG_DEBUG("Refresh complete");
// Note: this code only works because of a modification to meshtastic/GxEPD2.
// It is only equipped to intercept calls to nextPage()
@@ -503,7 +503,7 @@ void EInkDynamicDisplay::pollAsyncRefresh()
adafruitDisplay->endAsyncFull(); // Run the end of nextPage() code
EInkDisplay::endUpdate(); // Run base-class code to finish off update (NOT our derived class override)
asyncRefreshRunning = false; // Unset the flag
- LOG_DEBUG("Async full-refresh complete\n");
+ LOG_DEBUG("Async full-refresh complete");
// Note: this code only works because of a modification to meshtastic/GxEPD2.
// It is only equipped to intercept calls to nextPage()
diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp
index ad42fa9798..efa3ec78fe 100644
--- a/src/graphics/Screen.cpp
+++ b/src/graphics/Screen.cpp
@@ -144,7 +144,7 @@ static bool haveGlyphs(const char *str)
}
}
- LOG_DEBUG("haveGlyphs=%d\n", have);
+ LOG_DEBUG("haveGlyphs=%d", have);
return have;
}
@@ -186,56 +186,6 @@ static void drawIconScreen(const char *upperMsg, OLEDDisplay *display, OLEDDispl
display->setTextAlignment(TEXT_ALIGN_LEFT); // Restore left align, just to be kind to any other unsuspecting code
}
-static void drawOEMIconScreen(const char *upperMsg, OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
-{
- // draw an xbm image.
- // Please note that everything that should be transitioned
- // needs to be drawn relative to x and y
-
- // draw centered icon left to right and centered above the one line of app text
- display->drawXbm(x + (SCREEN_WIDTH - oemStore.oem_icon_width) / 2,
- y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - oemStore.oem_icon_height) / 2 + 2, oemStore.oem_icon_width,
- oemStore.oem_icon_height, (const uint8_t *)oemStore.oem_icon_bits.bytes);
-
- switch (oemStore.oem_font) {
- case 0:
- display->setFont(FONT_SMALL);
- break;
- case 2:
- display->setFont(FONT_LARGE);
- break;
- default:
- display->setFont(FONT_MEDIUM);
- break;
- }
-
- display->setTextAlignment(TEXT_ALIGN_LEFT);
- const char *title = oemStore.oem_text;
- display->drawString(x + getStringCenteredX(title), y + SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM, title);
- display->setFont(FONT_SMALL);
-
- // Draw region in upper left
- if (upperMsg)
- display->drawString(x + 0, y + 0, upperMsg);
-
- // Draw version and shortname in upper right
- char buf[25];
- snprintf(buf, sizeof(buf), "%s\n%s", xstr(APP_VERSION_SHORT), haveGlyphs(owner.short_name) ? owner.short_name : "");
-
- display->setTextAlignment(TEXT_ALIGN_RIGHT);
- display->drawString(x + SCREEN_WIDTH, y + 0, buf);
- screen->forceDisplay();
-
- display->setTextAlignment(TEXT_ALIGN_LEFT); // Restore left align, just to be kind to any other unsuspecting code
-}
-
-static void drawOEMBootScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
-{
- // Draw region in upper left
- const char *region = myRegion ? myRegion->name : NULL;
- drawOEMIconScreen(region, display, state, x, y);
-}
-
void Screen::drawFrameText(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y, const char *message)
{
uint16_t x_offset = display->width() / 2;
@@ -292,7 +242,7 @@ static void drawWelcomeScreen(OLEDDisplay *display, OLEDDisplayUiState *state, i
// draw overlay in bottom right corner of screen to show when notifications are muted or modifier key is active
static void drawFunctionOverlay(OLEDDisplay *display, OLEDDisplayUiState *state)
{
- // LOG_DEBUG("Drawing function overlay\n");
+ // LOG_DEBUG("Drawing function overlay");
if (functionSymbals.begin() != functionSymbals.end()) {
char buf[64];
display->setFont(FONT_SMALL);
@@ -310,7 +260,7 @@ static void drawDeepSleepScreen(OLEDDisplay *display, OLEDDisplayUiState *state,
EINK_ADD_FRAMEFLAG(display, COSMETIC);
EINK_ADD_FRAMEFLAG(display, BLOCKING);
- LOG_DEBUG("Drawing deep sleep screen\n");
+ LOG_DEBUG("Drawing deep sleep screen");
// Display displayStr on the screen
drawIconScreen("Sleeping", display, state, x, y);
@@ -319,7 +269,7 @@ static void drawDeepSleepScreen(OLEDDisplay *display, OLEDDisplayUiState *state,
/// Used on eink displays when screen updates are paused
static void drawScreensaverOverlay(OLEDDisplay *display, OLEDDisplayUiState *state)
{
- LOG_DEBUG("Drawing screensaver overlay\n");
+ LOG_DEBUG("Drawing screensaver overlay");
EINK_ADD_FRAMEFLAG(display, COSMETIC); // Take the opportunity for a full-refresh
@@ -385,9 +335,9 @@ static void drawModuleFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int
} else {
// otherwise, just display the module frame that's aligned with the current frame
module_frame = state->currentFrame;
- // LOG_DEBUG("Screen is not in transition. Frame: %d\n\n", module_frame);
+ // LOG_DEBUG("Screen is not in transition. Frame: %d", module_frame);
}
- // LOG_DEBUG("Drawing Module Frame %d\n\n", module_frame);
+ // LOG_DEBUG("Drawing Module Frame %d", module_frame);
MeshModule &pi = *moduleFrames.at(module_frame);
pi.drawFrame(display, state, x, y);
}
@@ -497,7 +447,7 @@ void Screen::drawDigitalClockFrame(OLEDDisplay *display, OLEDDisplayUiState *sta
display->drawString(x + 20, y + 2, batteryPercent);
}
- if (nimbleBluetooth->isConnected()) {
+ if (nimbleBluetooth && nimbleBluetooth->isConnected()) {
drawBluetoothConnectedIcon(display, display->getWidth() - 18, y + 2);
}
@@ -729,7 +679,7 @@ void Screen::drawAnalogClockFrame(OLEDDisplay *display, OLEDDisplayUiState *stat
display->drawString(x + 20, y + 2, batteryPercent);
}
- if (nimbleBluetooth->isConnected()) {
+ if (nimbleBluetooth && nimbleBluetooth->isConnected()) {
drawBluetoothConnectedIcon(display, display->getWidth() - 18, y + 2);
}
@@ -962,7 +912,7 @@ static void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state
const meshtastic_MeshPacket &mp = devicestate.rx_text_message;
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(getFrom(&mp));
- // LOG_DEBUG("drawing text message from 0x%x: %s\n", mp.from,
+ // LOG_DEBUG("drawing text message from 0x%x: %s", mp.from,
// mp.decoded.variant.data.decoded.bytes);
// Demo for drawStringMaxWidth:
@@ -1500,7 +1450,7 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
if (!hasNodeHeading) {
// direction to node is unknown so display question mark
// Debug info for gps lock errors
- // LOG_DEBUG("ourNode %d, ourPos %d, theirPos %d\n", !!ourNode, ourNode && hasValidPosition(ourNode),
+ // LOG_DEBUG("ourNode %d, ourPos %d, theirPos %d", !!ourNode, ourNode && hasValidPosition(ourNode),
// hasValidPosition(node));
display->drawString(compassX - FONT_HEIGHT_SMALL / 4, compassY - FONT_HEIGHT_SMALL / 2, "?");
}
@@ -1549,7 +1499,7 @@ Screen::Screen(ScanI2C::DeviceAddress address, meshtastic_Config_DisplayConfig_O
(address.port == ScanI2C::I2CPort::WIRE1) ? HW_I2C::I2C_TWO : HW_I2C::I2C_ONE);
#elif ARCH_PORTDUINO
if (settingsMap[displayPanel] != no_screen) {
- LOG_DEBUG("Making TFTDisplay!\n");
+ LOG_DEBUG("Making TFTDisplay!");
dispdev = new TFTDisplay(address.address, -1, -1, geometry,
(address.port == ScanI2C::I2CPort::WIRE1) ? HW_I2C::I2C_TWO : HW_I2C::I2C_ONE);
} else {
@@ -1596,7 +1546,7 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
if (on != screenOn) {
if (on) {
- LOG_INFO("Turning on screen\n");
+ LOG_INFO("Turning on screen");
powerMon->setState(meshtastic_PowerMon_State_Screen_On);
#ifdef T_WATCH_S3
PMU->enablePowerOutput(XPOWERS_ALDO2);
@@ -1631,7 +1581,7 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
// eInkScreensaver parameter is usually NULL (default argument), default frame used instead
setScreensaverFrames(einkScreensaver);
#endif
- LOG_INFO("Turning off screen\n");
+ LOG_INFO("Turning off screen");
dispdev->displayOff();
#ifdef USE_ST7789
SPI1.end();
@@ -1699,9 +1649,6 @@ void Screen::setup()
// Set the utf8 conversion function
dispdev->setFontTableLookupFunction(customFontTableLookup);
- if (strlen(oemStore.oem_text) > 0)
- logo_timeout *= 2;
-
// Add frames.
EINK_ADD_FRAMEFLAG(dispdev, DEMAND_FAST);
alertFrames[0] = [this](OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) -> void {
@@ -1842,28 +1789,11 @@ int32_t Screen::runOnce()
// serialSinceMsec adjusts for additional serial wait time during nRF52 bootup
static bool showingBootScreen = true;
if (showingBootScreen && (millis() > (logo_timeout + serialSinceMsec))) {
- LOG_INFO("Done with boot screen...\n");
+ LOG_INFO("Done with boot screen...");
stopBootScreen();
showingBootScreen = false;
}
- // If we have an OEM Boot screen, toggle after logo_timeout seconds
- if (strlen(oemStore.oem_text) > 0) {
- static bool showingOEMBootScreen = true;
- if (showingOEMBootScreen && (millis() > ((logo_timeout / 2) + serialSinceMsec))) {
- LOG_INFO("Switch to OEM screen...\n");
- // Change frames.
- static FrameCallback bootOEMFrames[] = {drawOEMBootScreen};
- static const int bootOEMFrameCount = sizeof(bootOEMFrames) / sizeof(bootOEMFrames[0]);
- ui->setFrames(bootOEMFrames, bootOEMFrameCount);
- ui->update();
-#ifndef USE_EINK
- ui->update();
-#endif
- showingOEMBootScreen = false;
- }
- }
-
#ifndef DISABLE_WELCOME_UNSET
if (showingNormalScreen && config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_UNSET) {
setWelcomeFrames();
@@ -1917,7 +1847,7 @@ int32_t Screen::runOnce()
free(cmd.print_text);
break;
default:
- LOG_ERROR("Invalid screen cmd\n");
+ LOG_ERROR("Invalid screen cmd");
}
}
@@ -1955,12 +1885,12 @@ int32_t Screen::runOnce()
EINK_ADD_FRAMEFLAG(dispdev, COSMETIC);
#endif
- LOG_DEBUG("LastScreenTransition exceeded %ums transitioning to next frame\n", (millis() - lastScreenTransition));
+ LOG_DEBUG("LastScreenTransition exceeded %ums transitioning to next frame", (millis() - lastScreenTransition));
handleOnPress();
}
}
- // LOG_DEBUG("want fps %d, fixed=%d\n", targetFramerate,
+ // LOG_DEBUG("want fps %d, fixed=%d", targetFramerate,
// ui->getUiState()->frameState); If we are scrolling we need to be called
// soon, otherwise just 1 fps (to save CPU) We also ask to be called twice
// as fast as we really need so that any rounding errors still result with
@@ -1991,7 +1921,7 @@ void Screen::drawDebugInfoWiFiTrampoline(OLEDDisplay *display, OLEDDisplayUiStat
void Screen::setSSLFrames()
{
if (address_found.address) {
- // LOG_DEBUG("showing SSL frames\n");
+ // LOG_DEBUG("showing SSL frames");
static FrameCallback sslFrames[] = {drawSSLScreen};
ui->setFrames(sslFrames, 1);
ui->update();
@@ -2003,7 +1933,7 @@ void Screen::setSSLFrames()
void Screen::setWelcomeFrames()
{
if (address_found.address) {
- // LOG_DEBUG("showing Welcome frames\n");
+ // LOG_DEBUG("showing Welcome frames");
static FrameCallback frames[] = {drawWelcomeScreen};
setFrameImmediateDraw(frames);
}
@@ -2069,7 +1999,7 @@ void Screen::setFrames(FrameFocus focus)
uint8_t originalPosition = ui->getUiState()->currentFrame;
FramesetInfo fsi; // Location of specific frames, for applying focus parameter
- LOG_DEBUG("showing standard frames\n");
+ LOG_DEBUG("showing standard frames");
showingNormalScreen = true;
#ifdef USE_EINK
@@ -2082,10 +2012,10 @@ void Screen::setFrames(FrameFocus focus)
#endif
moduleFrames = MeshModule::GetMeshModulesWithUIFrames();
- LOG_DEBUG("Showing %d module frames\n", moduleFrames.size());
+ LOG_DEBUG("Showing %d module frames", moduleFrames.size());
#ifdef DEBUG_PORT
int totalFrameCount = MAX_NUM_NODES + NUM_EXTRA_FRAMES + moduleFrames.size();
- LOG_DEBUG("Total frame count: %d\n", totalFrameCount);
+ LOG_DEBUG("Total frame count: %d", totalFrameCount);
#endif
// We don't show the node info of our node (if we have it yet - we should)
@@ -2119,7 +2049,7 @@ void Screen::setFrames(FrameFocus focus)
numframes++;
}
- LOG_DEBUG("Added modules. numframes: %d\n", numframes);
+ LOG_DEBUG("Added modules. numframes: %d", numframes);
// If we have a critical fault, show it first
fsi.positions.fault = numframes;
@@ -2164,7 +2094,7 @@ void Screen::setFrames(FrameFocus focus)
#endif
fsi.frameCount = numframes; // Total framecount is used to apply FOCUS_PRESERVE
- LOG_DEBUG("Finished building frames. numframes: %d\n", numframes);
+ LOG_DEBUG("Finished building frames. numframes: %d", numframes);
ui->setFrames(normalFrames, numframes);
ui->enableAllIndicators();
@@ -2245,13 +2175,13 @@ void Screen::dismissCurrentFrame()
bool dismissed = false;
if (currentFrame == framesetInfo.positions.textMessage && devicestate.has_rx_text_message) {
- LOG_INFO("Dismissing Text Message\n");
+ LOG_INFO("Dismissing Text Message");
devicestate.has_rx_text_message = false;
dismissed = true;
}
else if (currentFrame == framesetInfo.positions.waypoint && devicestate.has_rx_waypoint) {
- LOG_DEBUG("Dismissing Waypoint\n");
+ LOG_DEBUG("Dismissing Waypoint");
devicestate.has_rx_waypoint = false;
dismissed = true;
}
@@ -2263,7 +2193,7 @@ void Screen::dismissCurrentFrame()
void Screen::handleStartFirmwareUpdateScreen()
{
- LOG_DEBUG("showing firmware screen\n");
+ LOG_DEBUG("showing firmware screen");
showingNormalScreen = false;
EINK_ADD_FRAMEFLAG(dispdev, DEMAND_FAST); // E-Ink: Explicitly use fast-refresh for next frame
@@ -2355,7 +2285,7 @@ void Screen::handlePrint(const char *text)
{
// the string passed into us probably has a newline, but that would confuse the logging system
// so strip it
- LOG_DEBUG("Screen: %.*s\n", strlen(text) - 1, text);
+ LOG_DEBUG("Screen: %.*s", strlen(text) - 1, text);
if (!useDisplay || !showingNormalScreen)
return;
@@ -2708,7 +2638,7 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
int Screen::handleStatusUpdate(const meshtastic::Status *arg)
{
- // LOG_DEBUG("Screen got status update %d\n", arg->getStatusType());
+ // LOG_DEBUG("Screen got status update %d", arg->getStatusType());
switch (arg->getStatusType()) {
case STATUS_TYPE_NODE:
if (showingNormalScreen && nodeStatus->getLastNumTotal() != nodeStatus->getNumTotal()) {
diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp
index 0c32a7c32e..3ba847c236 100644
--- a/src/graphics/TFTDisplay.cpp
+++ b/src/graphics/TFTDisplay.cpp
@@ -380,7 +380,7 @@ class LGFX : public lgfx::LGFX_Device
_panel_instance->setBus(&_bus_instance); // set the bus on the panel.
auto cfg = _panel_instance->config(); // Gets a structure for display panel settings.
- LOG_DEBUG("Height: %d, Width: %d \n", settingsMap[displayHeight], settingsMap[displayWidth]);
+ LOG_DEBUG("Height: %d, Width: %d ", settingsMap[displayHeight], settingsMap[displayWidth]);
cfg.pin_cs = settingsMap[displayCS]; // Pin number where CS is connected (-1 = disable)
cfg.pin_rst = settingsMap[displayReset];
cfg.panel_width = settingsMap[displayWidth]; // actual displayable width
@@ -643,7 +643,7 @@ GpioPin *TFTDisplay::backlightEnable = NULL;
TFTDisplay::TFTDisplay(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY geometry, HW_I2C i2cBus)
{
- LOG_DEBUG("TFTDisplay!\n");
+ LOG_DEBUG("TFTDisplay!");
#ifdef TFT_BL
GpioPin *p = new GpioHwPin(TFT_BL);
@@ -712,7 +712,7 @@ void TFTDisplay::sendCommand(uint8_t com)
// handle display on/off directly
switch (com) {
case DISPLAYON: {
- // LOG_DEBUG("Display on\n");
+ // LOG_DEBUG("Display on");
backlightEnable->set(true);
#if ARCH_PORTDUINO
display(true);
@@ -736,7 +736,7 @@ void TFTDisplay::sendCommand(uint8_t com)
break;
}
case DISPLAYOFF: {
- // LOG_DEBUG("Display off\n");
+ // LOG_DEBUG("Display off");
backlightEnable->set(false);
#if ARCH_PORTDUINO
tft->clear();
@@ -772,14 +772,14 @@ void TFTDisplay::setDisplayBrightness(uint8_t _brightness)
// todo
#else
tft->setBrightness(_brightness);
- LOG_DEBUG("Brightness is set to value: %i \n", _brightness);
+ LOG_DEBUG("Brightness is set to value: %i ", _brightness);
#endif
}
void TFTDisplay::flipScreenVertically()
{
#if defined(T_WATCH_S3)
- LOG_DEBUG("Flip TFT vertically\n"); // T-Watch S3 right-handed orientation
+ LOG_DEBUG("Flip TFT vertically"); // T-Watch S3 right-handed orientation
tft->setRotation(0);
#endif
}
@@ -823,7 +823,7 @@ void TFTDisplay::setDetected(uint8_t detected)
bool TFTDisplay::connect()
{
concurrency::LockGuard g(spiLock);
- LOG_INFO("Doing TFT init\n");
+ LOG_INFO("Doing TFT init");
#ifdef RAK14014
tft = new TFT_eSPI;
#else
@@ -831,7 +831,7 @@ bool TFTDisplay::connect()
#endif
backlightEnable->set(true);
- LOG_INFO("Power to TFT Backlight\n");
+ LOG_INFO("Power to TFT Backlight");
#ifdef UNPHONE
unphone.backlight(true); // using unPhone library
diff --git a/src/input/ExpressLRSFiveWay.cpp b/src/input/ExpressLRSFiveWay.cpp
index af4433daea..56413bd55d 100644
--- a/src/input/ExpressLRSFiveWay.cpp
+++ b/src/input/ExpressLRSFiveWay.cpp
@@ -233,7 +233,7 @@ void ExpressLRSFiveWay::sendAdhocPing()
// Contained as one method for easier remapping of buttons by user
void ExpressLRSFiveWay::shutdown()
{
- LOG_INFO("Shutdown from long press\n");
+ LOG_INFO("Shutdown from long press");
powerFSM.trigger(EVENT_PRESS);
screen->startAlert("Shutting down...");
// Don't set alerting = true. We don't want to auto-dismiss this alert.
diff --git a/src/input/InputBroker.h b/src/input/InputBroker.h
index 17c621c8a6..db7524bb08 100644
--- a/src/input/InputBroker.h
+++ b/src/input/InputBroker.h
@@ -18,6 +18,7 @@
#define INPUT_BROKER_MSG_RIGHT 0xb7
#define INPUT_BROKER_MSG_FN_SYMBOL_ON 0xf1
#define INPUT_BROKER_MSG_FN_SYMBOL_OFF 0xf2
+#define INPUT_BROKER_MSG_BLUETOOTH_TOGGLE 0xAA
typedef struct _InputEvent {
const char *source;
diff --git a/src/input/MPR121Keyboard.cpp b/src/input/MPR121Keyboard.cpp
new file mode 100644
index 0000000000..e1b32aa542
--- /dev/null
+++ b/src/input/MPR121Keyboard.cpp
@@ -0,0 +1,430 @@
+// Based on the BBQ10 Keyboard
+
+#include "MPR121Keyboard.h"
+#include "configuration.h"
+#include
+
+#define _MPR121_REG_KEY 0x5a
+
+#define _MPR121_REG_TOUCH_STATUS 0x00
+#define _MPR121_REG_ELECTRODE_FILTERED_DATA
+#define _MPR121_REG_BASELINE_VALUE 0x1E
+
+// Baseline filters
+#define _MPR121_REG_MAX_HALF_DELTA_RISING 0x2B
+#define _MPR121_REG_NOISE_HALF_DELTA_RISING 0x2C
+#define _MPR121_REG_NOISE_COUNT_LIMIT_RISING 0x2D
+#define _MPR121_REG_FILTER_DELAY_COUNT_RISING 0x2E
+#define _MPR121_REG_MAX_HALF_DELTA_FALLING 0x2F
+#define _MPR121_REG_NOISE_HALF_DELTA_FALLING 0x30
+#define _MPR121_REG_NOISE_COUNT_LIMIT_FALLING 0x31
+#define _MPR121_REG_FILTER_DELAY_COUNT_FALLING 0x32
+#define _MPR121_REG_NOISE_HALF_DELTA_TOUCHED 0x33
+#define _MPR121_REG_NOISE_COUNT_LIMIT_TOUCHED 0x34
+#define _MPR121_REG_FILTER_DELAY_COUNT_TOUCHED 0x35
+
+#define _MPR121_REG_TOUCH_THRESHOLD 0x41 // First input, +2 for subsequent
+#define _MPR121_REG_RELEASE_THRESHOLD 0x42 // First input, +2 for subsequent
+#define _MPR121_REG_DEBOUNCE 0x5B
+#define _MPR121_REG_CONFIG1 0x5C
+#define _MPR121_REG_CONFIG2 0x5D
+#define _MPR121_REG_ELECTRODE_CONFIG 0x5E
+#define _MPR121_REG_SOFT_RESET 0x80
+
+#define _KEY_MASK 0x0FFF // Key mask for the first 12 bits
+#define _NUM_KEYS 12
+
+#define ECR_CALIBRATION_TRACK_FROM_ZERO (0 << 6)
+#define ECR_CALIBRATION_LOCK (1 << 6)
+#define ECR_CALIBRATION_TRACK_FROM_PARTIAL_FILTER (2 << 6) // Recommended Typical Mode
+#define ECR_CALIBRATION_TRACK_FROM_FULL_FILTER (3 << 6)
+#define ECR_PROXIMITY_DETECTION_OFF (0 << 0) // Not using proximity detection
+#define ECR_TOUCH_DETECTION_12CH (12 << 0) // Using all 12 channels
+
+#define MPR121_NONE 0x00
+#define MPR121_REBOOT 0x90
+#define MPR121_LEFT 0xb4
+#define MPR121_UP 0xb5
+#define MPR121_DOWN 0xb6
+#define MPR121_RIGHT 0xb7
+#define MPR121_ESC 0x1b
+#define MPR121_BSP 0x08
+#define MPR121_SELECT 0x0d
+
+#define MPR121_FN_ON 0xf1
+#define MPR121_FN_OFF 0xf2
+
+#define LONG_PRESS_THRESHOLD 2000
+#define MULTI_TAP_THRESHOLD 2000
+
+uint8_t TapMod[12] = {1, 2, 1, 13, 7, 7, 7, 7, 7, 9, 7, 9}; // Num chars per key, Modulus for rotating through characters
+
+unsigned char MPR121_TapMap[12][13] = {{MPR121_BSP},
+ {'0', ' '},
+ {MPR121_SELECT},
+ {'1', '.', ',', '?', '!', ':', ';', '-', '_', '\\', '/', '(', ')'},
+ {'2', 'a', 'b', 'c', 'A', 'B', 'C'},
+ {'3', 'd', 'e', 'f', 'D', 'E', 'F'},
+ {'4', 'g', 'h', 'i', 'G', 'H', 'I'},
+ {'5', 'j', 'k', 'l', 'J', 'K', 'L'},
+ {'6', 'm', 'n', 'o', 'M', 'N', 'O'},
+ {'7', 'p', 'q', 'r', 's', 'P', 'Q', 'R', 'S'},
+ {'8', 't', 'u', 'v', 'T', 'U', 'V'},
+ {'9', 'w', 'x', 'y', 'z', 'W', 'X', 'Y', 'Z'}};
+
+unsigned char MPR121_LongPressMap[12] = {MPR121_ESC, ' ', MPR121_NONE, MPR121_NONE, MPR121_UP, MPR121_NONE,
+ MPR121_LEFT, MPR121_NONE, MPR121_RIGHT, MPR121_NONE, MPR121_DOWN, MPR121_NONE};
+
+// Translation map from left to right, top to bottom layout to a more convenient layout to manufacture, matching the
+// https://www.amazon.com.au/Capacitive-Sensitive-Sensitivity-Replacement-Traditional/dp/B0CTJD5KW9/ref=pd_ci_mcx_mh_mcx_views_0_title?th=1
+/*uint8_t MPR121_KeyMap[12] = {
+ 9, 6, 3, 0,
+ 10, 7, 4, 1,
+ 11, 8, 5, 2
+};*/
+// Rotated Layout
+uint8_t MPR121_KeyMap[12] = {2, 5, 8, 11, 1, 4, 7, 10, 0, 3, 6, 9};
+
+MPR121Keyboard::MPR121Keyboard() : m_wire(nullptr), m_addr(0), readCallback(nullptr), writeCallback(nullptr)
+{
+ // LOG_DEBUG("MPR121 @ %02x\n", m_addr);
+ state = Init;
+ last_key = -1;
+ last_tap = 0L;
+ char_idx = 0;
+ queue = "";
+}
+
+void MPR121Keyboard::begin(uint8_t addr, TwoWire *wire)
+{
+ m_addr = addr;
+ m_wire = wire;
+
+ m_wire->begin();
+
+ reset();
+}
+
+void MPR121Keyboard::begin(i2c_com_fptr_t r, i2c_com_fptr_t w, uint8_t addr)
+{
+ m_addr = addr;
+ m_wire = nullptr;
+ writeCallback = w;
+ readCallback = r;
+ reset();
+}
+
+void MPR121Keyboard::reset()
+{
+ LOG_DEBUG("MPR121 Resetting...");
+ // Trigger a MPR121 Soft Reset
+ if (m_wire) {
+ m_wire->beginTransmission(m_addr);
+ m_wire->write(_MPR121_REG_SOFT_RESET);
+ m_wire->endTransmission();
+ }
+ if (writeCallback) {
+ uint8_t data = 0;
+ writeCallback(m_addr, _MPR121_REG_SOFT_RESET, &data, 0);
+ }
+ delay(100);
+ // Reset Electrode Configuration to 0x00, Stop Mode
+ writeRegister(_MPR121_REG_ELECTRODE_CONFIG, 0x00);
+ delay(100);
+
+ LOG_DEBUG("MPR121 Configuring");
+ // Set touch release thresholds
+ for (uint8_t i = 0; i < 12; i++) {
+ // Set touch threshold
+ writeRegister(_MPR121_REG_TOUCH_THRESHOLD + (i * 2), 15);
+ delay(20);
+ // Set release threshold
+ writeRegister(_MPR121_REG_RELEASE_THRESHOLD + (i * 2), 7);
+ delay(20);
+ }
+ // Configure filtering and baseline registers
+ writeRegister(_MPR121_REG_MAX_HALF_DELTA_RISING, 0x01);
+ delay(20);
+ writeRegister(_MPR121_REG_MAX_HALF_DELTA_FALLING, 0x01);
+ delay(20);
+ writeRegister(_MPR121_REG_NOISE_HALF_DELTA_RISING, 0x01);
+ delay(20);
+ writeRegister(_MPR121_REG_NOISE_HALF_DELTA_FALLING, 0x05);
+ delay(20);
+ writeRegister(_MPR121_REG_NOISE_HALF_DELTA_TOUCHED, 0x00);
+ delay(20);
+ writeRegister(_MPR121_REG_NOISE_COUNT_LIMIT_RISING, 0x0e);
+ delay(20);
+ writeRegister(_MPR121_REG_NOISE_COUNT_LIMIT_FALLING, 0x01);
+ delay(20);
+ writeRegister(_MPR121_REG_NOISE_COUNT_LIMIT_TOUCHED, 0x00);
+ delay(20);
+ writeRegister(_MPR121_REG_FILTER_DELAY_COUNT_RISING, 0x00);
+ delay(20);
+ writeRegister(_MPR121_REG_FILTER_DELAY_COUNT_FALLING, 0x00);
+ delay(20);
+ writeRegister(_MPR121_REG_FILTER_DELAY_COUNT_TOUCHED, 0x00);
+ delay(20);
+ // Set Debounce to 0x02
+ writeRegister(_MPR121_REG_DEBOUNCE, 0x00);
+ delay(20);
+ // Set Filter1 itterations and discharge current 6x and 16uA respectively (0x10)
+ writeRegister(_MPR121_REG_CONFIG1, 0x10);
+ delay(20);
+ // Set CDT to 0.5us, Filter2 itterations to 4x, and Sample interval = 0 (0x20)
+ writeRegister(_MPR121_REG_CONFIG2, 0x20);
+ delay(20);
+ // Enter run mode by Seting partial filter calibration tracking, disable proximity detection, enable 12 channels
+ writeRegister(_MPR121_REG_ELECTRODE_CONFIG,
+ ECR_CALIBRATION_TRACK_FROM_PARTIAL_FILTER | ECR_PROXIMITY_DETECTION_OFF | ECR_TOUCH_DETECTION_12CH);
+ delay(100);
+ LOG_DEBUG("MPR121 Running");
+ state = Idle;
+}
+
+void MPR121Keyboard::attachInterrupt(uint8_t pin, void (*func)(void)) const
+{
+ pinMode(pin, INPUT_PULLUP);
+ ::attachInterrupt(digitalPinToInterrupt(pin), func, RISING);
+}
+
+void MPR121Keyboard::detachInterrupt(uint8_t pin) const
+{
+ ::detachInterrupt(pin);
+}
+
+uint8_t MPR121Keyboard::status() const
+{
+ return readRegister16(_MPR121_REG_KEY);
+}
+
+uint8_t MPR121Keyboard::keyCount() const
+{
+ // Read the key register
+ uint16_t keyRegister = readRegister16(_MPR121_REG_KEY);
+ return keyCount(keyRegister);
+}
+
+uint8_t MPR121Keyboard::keyCount(uint16_t value) const
+{
+ // Mask the first 12 bits
+ uint16_t buttonState = value & _KEY_MASK;
+
+ // Count how many bits are set to 1 (i.e., how many buttons are pressed)
+ uint8_t numButtonsPressed = 0;
+ for (uint8_t i = 0; i < 12; ++i) {
+ if (buttonState & (1 << i)) {
+ numButtonsPressed++;
+ }
+ }
+
+ return numButtonsPressed;
+}
+
+bool MPR121Keyboard::hasEvent()
+{
+ return queue.length() > 0;
+}
+
+void MPR121Keyboard::queueEvent(char next)
+{
+ if (next == MPR121_NONE) {
+ return;
+ }
+ queue.concat(next);
+}
+
+char MPR121Keyboard::dequeueEvent()
+{
+ if (queue.length() < 1) {
+ return MPR121_NONE;
+ }
+ char next = queue.charAt(0);
+ queue.remove(0, 1);
+ return next;
+}
+
+void MPR121Keyboard::trigger()
+{
+ // Intended to fire in response to an interrupt from the MPR121 or a longpress callback
+ // Only functional if not in Init state
+ if (state != Init) {
+ // Read the key register
+ uint16_t keyRegister = readRegister16(_MPR121_REG_KEY);
+ uint8_t keysPressed = keyCount(keyRegister);
+ if (keysPressed == 0) {
+ // No buttons pressed
+ if (state == Held)
+ released();
+ state = Idle;
+ return;
+ }
+ if (keysPressed == 1) {
+ // No buttons pressed
+ if (state == Held || state == HeldLong)
+ held(keyRegister);
+ if (state == Idle)
+ pressed(keyRegister);
+ return;
+ }
+ if (keysPressed > 1) {
+ // Multipress
+ state = Busy;
+ return;
+ }
+ } else {
+ reset();
+ }
+}
+
+void MPR121Keyboard::pressed(uint16_t keyRegister)
+{
+ if (state == Init || state == Busy) {
+ return;
+ }
+ if (keyCount(keyRegister) != 1) {
+ LOG_DEBUG("Multipress");
+ return;
+ } else {
+ LOG_DEBUG("Pressed");
+ }
+ uint16_t buttonState = keyRegister & _KEY_MASK;
+ uint8_t next_pin = 0;
+ for (uint8_t i = 0; i < 12; ++i) {
+ if (buttonState & (1 << i)) {
+ next_pin = i;
+ }
+ }
+ uint8_t next_key = MPR121_KeyMap[next_pin];
+ LOG_DEBUG("MPR121 Pin: %i Key: %i", next_pin, next_key);
+ uint32_t now = millis();
+ int32_t tap_interval = now - last_tap;
+ if (tap_interval < 0) {
+ // long running, millis has overflowed.
+ last_tap = 0;
+ state = Busy;
+ return;
+ }
+ if (next_key != last_key || tap_interval > MULTI_TAP_THRESHOLD) {
+ char_idx = 0;
+ } else {
+ char_idx += 1;
+ }
+ last_key = next_key;
+ last_tap = now;
+ state = Held;
+ return;
+}
+
+void MPR121Keyboard::held(uint16_t keyRegister)
+{
+ if (state == Init || state == Busy) {
+ return;
+ }
+ if (keyCount(keyRegister) != 1) {
+ return;
+ }
+ LOG_DEBUG("Held");
+ uint16_t buttonState = keyRegister & _KEY_MASK;
+ uint8_t next_key = 0;
+ for (uint8_t i = 0; i < 12; ++i) {
+ if (buttonState & (1 << i)) {
+ next_key = MPR121_KeyMap[i];
+ }
+ }
+ uint32_t now = millis();
+ int32_t held_interval = now - last_tap;
+ if (held_interval < 0 || next_key != last_key) {
+ // long running, millis has overflowed, or a key has been switched quickly...
+ last_tap = 0;
+ state = Busy;
+ return;
+ }
+ if (held_interval > LONG_PRESS_THRESHOLD) {
+ // Set state to heldlong, send a longpress, and reset the timer...
+ state = HeldLong; // heldlong will allow this function to still fire, but prevent a "release"
+ queueEvent(MPR121_LongPressMap[last_key]);
+ last_tap = now;
+ LOG_DEBUG("Long Press Key: %i Map: %i", last_key, MPR121_LongPressMap[last_key]);
+ }
+ return;
+}
+
+void MPR121Keyboard::released()
+{
+ if (state != Held) {
+ return;
+ }
+ // would clear longpress callback... later.
+ if (last_key < 0 || last_key > _NUM_KEYS) { // reset to idle if last_key out of bounds
+ last_key = -1;
+ state = Idle;
+ return;
+ }
+ LOG_DEBUG("Released");
+ if (char_idx > 0 && TapMod[last_key] > 1) {
+ queueEvent(MPR121_BSP);
+ LOG_DEBUG("Multi Press, Backspace");
+ }
+ queueEvent(MPR121_TapMap[last_key][(char_idx % TapMod[last_key])]);
+ LOG_DEBUG("Key Press: %i Index:%i if %i Map: %i", last_key, char_idx, TapMod[last_key],
+ MPR121_TapMap[last_key][(char_idx % TapMod[last_key])]);
+}
+
+uint8_t MPR121Keyboard::readRegister8(uint8_t reg) const
+{
+ if (m_wire) {
+ m_wire->beginTransmission(m_addr);
+ m_wire->write(reg);
+ m_wire->endTransmission();
+
+ m_wire->requestFrom(m_addr, (uint8_t)1);
+ if (m_wire->available() < 1)
+ return 0;
+
+ return m_wire->read();
+ }
+ if (readCallback) {
+ uint8_t data;
+ readCallback(m_addr, reg, &data, 1);
+ return data;
+ }
+ return 0;
+}
+
+uint16_t MPR121Keyboard::readRegister16(uint8_t reg) const
+{
+ uint8_t data[2] = {0};
+ // uint8_t low = 0, high = 0;
+ if (m_wire) {
+ m_wire->beginTransmission(m_addr);
+ m_wire->write(reg);
+ m_wire->endTransmission();
+
+ m_wire->requestFrom(m_addr, (uint8_t)2);
+ if (m_wire->available() < 2)
+ return 0;
+ data[0] = m_wire->read();
+ data[1] = m_wire->read();
+ }
+ if (readCallback) {
+ readCallback(m_addr, reg, data, 2);
+ }
+ return (data[1] << 8) | data[0];
+}
+
+void MPR121Keyboard::writeRegister(uint8_t reg, uint8_t value)
+{
+ uint8_t data[2];
+ data[0] = reg;
+ data[1] = value;
+
+ if (m_wire) {
+ m_wire->beginTransmission(m_addr);
+ m_wire->write(data, sizeof(uint8_t) * 2);
+ m_wire->endTransmission();
+ }
+ if (writeCallback) {
+ writeCallback(m_addr, data[0], &(data[1]), 1);
+ }
+}
diff --git a/src/input/MPR121Keyboard.h b/src/input/MPR121Keyboard.h
new file mode 100644
index 0000000000..6349750cef
--- /dev/null
+++ b/src/input/MPR121Keyboard.h
@@ -0,0 +1,56 @@
+// Based on the BBQ10 Keyboard
+
+#include "concurrency/NotifiedWorkerThread.h"
+#include "configuration.h"
+#include
+#include
+
+class MPR121Keyboard
+{
+ public:
+ typedef uint8_t (*i2c_com_fptr_t)(uint8_t dev_addr, uint8_t reg_addr, uint8_t *data, uint8_t len);
+
+ enum MPR121States { Init = 0, Idle, Held, HeldLong, Busy };
+
+ MPR121States state;
+
+ int8_t last_key;
+ uint32_t last_tap;
+ uint8_t char_idx;
+
+ String queue;
+
+ MPR121Keyboard();
+
+ void begin(uint8_t addr = MPR121_KB_ADDR, TwoWire *wire = &Wire);
+
+ void begin(i2c_com_fptr_t r, i2c_com_fptr_t w, uint8_t addr = MPR121_KB_ADDR);
+
+ void reset(void);
+
+ void attachInterrupt(uint8_t pin, void (*func)(void)) const;
+ void detachInterrupt(uint8_t pin) const;
+
+ void trigger(void);
+ void pressed(uint16_t value);
+ void held(uint16_t value);
+ void released(void);
+
+ uint8_t status(void) const;
+ uint8_t keyCount(void) const;
+ uint8_t keyCount(uint16_t value) const;
+
+ bool hasEvent(void);
+ char dequeueEvent(void);
+ void queueEvent(char);
+
+ uint8_t readRegister8(uint8_t reg) const;
+ uint16_t readRegister16(uint8_t reg) const;
+ void writeRegister(uint8_t reg, uint8_t value);
+
+ private:
+ TwoWire *m_wire;
+ uint8_t m_addr;
+ i2c_com_fptr_t readCallback;
+ i2c_com_fptr_t writeCallback;
+};
\ No newline at end of file
diff --git a/src/input/RotaryEncoderInterruptBase.cpp b/src/input/RotaryEncoderInterruptBase.cpp
index 0b8e8325d5..785d98ebe0 100644
--- a/src/input/RotaryEncoderInterruptBase.cpp
+++ b/src/input/RotaryEncoderInterruptBase.cpp
@@ -28,7 +28,7 @@ void RotaryEncoderInterruptBase::init(
this->rotaryLevelA = digitalRead(this->_pinA);
this->rotaryLevelB = digitalRead(this->_pinB);
- LOG_INFO("Rotary initialized (%d, %d, %d)\n", this->_pinA, this->_pinB, pinPress);
+ LOG_INFO("Rotary initialized (%d, %d, %d)", this->_pinA, this->_pinB, pinPress);
}
int32_t RotaryEncoderInterruptBase::runOnce()
@@ -38,13 +38,13 @@ int32_t RotaryEncoderInterruptBase::runOnce()
e.source = this->_originName;
if (this->action == ROTARY_ACTION_PRESSED) {
- LOG_DEBUG("Rotary event Press\n");
+ LOG_DEBUG("Rotary event Press");
e.inputEvent = this->_eventPressed;
} else if (this->action == ROTARY_ACTION_CW) {
- LOG_DEBUG("Rotary event CW\n");
+ LOG_DEBUG("Rotary event CW");
e.inputEvent = this->_eventCw;
} else if (this->action == ROTARY_ACTION_CCW) {
- LOG_DEBUG("Rotary event CCW\n");
+ LOG_DEBUG("Rotary event CCW");
e.inputEvent = this->_eventCcw;
}
diff --git a/src/input/ScanAndSelect.cpp b/src/input/ScanAndSelect.cpp
index 65ca7e332b..e1b39edf58 100644
--- a/src/input/ScanAndSelect.cpp
+++ b/src/input/ScanAndSelect.cpp
@@ -47,7 +47,7 @@ bool ScanAndSelectInput::init()
// Connect our class to the canned message module
inputBroker->registerSource(this);
- LOG_INFO("Initialized 'Scan and Select' input for Canned Messages, using pin %d\n", pin);
+ LOG_INFO("Initialized 'Scan and Select' input for Canned Messages, using pin %d", pin);
return true; // Init succeded
}
diff --git a/src/input/SerialKeyboard.cpp b/src/input/SerialKeyboard.cpp
index 4827e89951..8d0730418b 100644
--- a/src/input/SerialKeyboard.cpp
+++ b/src/input/SerialKeyboard.cpp
@@ -52,7 +52,7 @@ int32_t SerialKeyboard::runOnce()
digitalWrite(KB_LOAD, HIGH);
digitalWrite(KB_CLK, LOW);
prevKeys = 0b1111111111111111;
- LOG_DEBUG("Serial Keyboard setup\n");
+ LOG_DEBUG("Serial Keyboard setup");
}
if (INPUTBROKER_SERIAL_TYPE == 1) { // Chatter V1.0 & V2.0 keypads
diff --git a/src/input/TouchScreenBase.cpp b/src/input/TouchScreenBase.cpp
index 2f361ac4c6..03618b3383 100644
--- a/src/input/TouchScreenBase.cpp
+++ b/src/input/TouchScreenBase.cpp
@@ -23,7 +23,7 @@ TouchScreenBase::TouchScreenBase(const char *name, uint16_t width, uint16_t heig
void TouchScreenBase::init(bool hasTouch)
{
if (hasTouch) {
- LOG_INFO("TouchScreen initialized %d %d\n", TOUCH_THRESHOLD_X, TOUCH_THRESHOLD_Y);
+ LOG_INFO("TouchScreen initialized %d %d", TOUCH_THRESHOLD_X, TOUCH_THRESHOLD_Y);
this->setInterval(100);
} else {
disable();
@@ -68,20 +68,20 @@ int32_t TouchScreenBase::runOnce()
if (adx > ady && adx > TOUCH_THRESHOLD_X) {
if (0 > dx) { // swipe right to left
e.touchEvent = static_cast(TOUCH_ACTION_LEFT);
- LOG_DEBUG("action SWIPE: right to left\n");
+ LOG_DEBUG("action SWIPE: right to left");
} else { // swipe left to right
e.touchEvent = static_cast(TOUCH_ACTION_RIGHT);
- LOG_DEBUG("action SWIPE: left to right\n");
+ LOG_DEBUG("action SWIPE: left to right");
}
}
// swipe vertical
else if (ady > adx && ady > TOUCH_THRESHOLD_Y) {
if (0 > dy) { // swipe bottom to top
e.touchEvent = static_cast(TOUCH_ACTION_UP);
- LOG_DEBUG("action SWIPE: bottom to top\n");
+ LOG_DEBUG("action SWIPE: bottom to top");
} else { // swipe top to bottom
e.touchEvent = static_cast(TOUCH_ACTION_DOWN);
- LOG_DEBUG("action SWIPE: top to bottom\n");
+ LOG_DEBUG("action SWIPE: top to bottom");
}
}
// tap
@@ -90,7 +90,7 @@ int32_t TouchScreenBase::runOnce()
if (_tapped) {
_tapped = false;
e.touchEvent = static_cast(TOUCH_ACTION_DOUBLE_TAP);
- LOG_DEBUG("action DOUBLE TAP(%d/%d)\n", x, y);
+ LOG_DEBUG("action DOUBLE TAP(%d/%d)", x, y);
} else {
_tapped = true;
}
@@ -106,7 +106,7 @@ int32_t TouchScreenBase::runOnce()
if (_tapped && (time_t(millis()) - _start) > TIME_LONG_PRESS - 50) {
_tapped = false;
e.touchEvent = static_cast(TOUCH_ACTION_TAP);
- LOG_DEBUG("action TAP(%d/%d)\n", _last_x, _last_y);
+ LOG_DEBUG("action TAP(%d/%d)", _last_x, _last_y);
}
// fire LONG_PRESS event without the need for release
@@ -114,7 +114,7 @@ int32_t TouchScreenBase::runOnce()
// tricky: prevent reoccurring events and another touch event when releasing
_start = millis() + 30000;
e.touchEvent = static_cast(TOUCH_ACTION_LONG_PRESS);
- LOG_DEBUG("action LONG PRESS(%d/%d)\n", _last_x, _last_y);
+ LOG_DEBUG("action LONG PRESS(%d/%d)", _last_x, _last_y);
}
if (e.touchEvent != TOUCH_ACTION_NONE) {
diff --git a/src/input/TrackballInterruptBase.cpp b/src/input/TrackballInterruptBase.cpp
index 71cd130cc2..e35da36229 100644
--- a/src/input/TrackballInterruptBase.cpp
+++ b/src/input/TrackballInterruptBase.cpp
@@ -30,7 +30,7 @@ void TrackballInterruptBase::init(uint8_t pinDown, uint8_t pinUp, uint8_t pinLef
attachInterrupt(this->_pinLeft, onIntLeft, RISING);
attachInterrupt(this->_pinRight, onIntRight, RISING);
- LOG_DEBUG("Trackball GPIO initialized (%d, %d, %d, %d, %d)\n", this->_pinUp, this->_pinDown, this->_pinLeft, this->_pinRight,
+ LOG_DEBUG("Trackball GPIO initialized (%d, %d, %d, %d, %d)", this->_pinUp, this->_pinDown, this->_pinLeft, this->_pinRight,
pinPress);
this->setInterval(100);
@@ -42,19 +42,19 @@ int32_t TrackballInterruptBase::runOnce()
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
if (this->action == TB_ACTION_PRESSED) {
- // LOG_DEBUG("Trackball event Press\n");
+ // LOG_DEBUG("Trackball event Press");
e.inputEvent = this->_eventPressed;
} else if (this->action == TB_ACTION_UP) {
- // LOG_DEBUG("Trackball event UP\n");
+ // LOG_DEBUG("Trackball event UP");
e.inputEvent = this->_eventUp;
} else if (this->action == TB_ACTION_DOWN) {
- // LOG_DEBUG("Trackball event DOWN\n");
+ // LOG_DEBUG("Trackball event DOWN");
e.inputEvent = this->_eventDown;
} else if (this->action == TB_ACTION_LEFT) {
- // LOG_DEBUG("Trackball event LEFT\n");
+ // LOG_DEBUG("Trackball event LEFT");
e.inputEvent = this->_eventLeft;
} else if (this->action == TB_ACTION_RIGHT) {
- // LOG_DEBUG("Trackball event RIGHT\n");
+ // LOG_DEBUG("Trackball event RIGHT");
e.inputEvent = this->_eventRight;
}
diff --git a/src/input/UpDownInterruptBase.cpp b/src/input/UpDownInterruptBase.cpp
index b1f83c56b0..979489c57a 100644
--- a/src/input/UpDownInterruptBase.cpp
+++ b/src/input/UpDownInterruptBase.cpp
@@ -23,7 +23,7 @@ void UpDownInterruptBase::init(uint8_t pinDown, uint8_t pinUp, uint8_t pinPress,
attachInterrupt(this->_pinDown, onIntDown, RISING);
attachInterrupt(this->_pinUp, onIntUp, RISING);
- LOG_DEBUG("Up/down/press GPIO initialized (%d, %d, %d)\n", this->_pinUp, this->_pinDown, pinPress);
+ LOG_DEBUG("Up/down/press GPIO initialized (%d, %d, %d)", this->_pinUp, this->_pinDown, pinPress);
this->setInterval(100);
}
@@ -34,13 +34,13 @@ int32_t UpDownInterruptBase::runOnce()
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
if (this->action == UPDOWN_ACTION_PRESSED) {
- LOG_DEBUG("GPIO event Press\n");
+ LOG_DEBUG("GPIO event Press");
e.inputEvent = this->_eventPressed;
} else if (this->action == UPDOWN_ACTION_UP) {
- LOG_DEBUG("GPIO event Up\n");
+ LOG_DEBUG("GPIO event Up");
e.inputEvent = this->_eventUp;
} else if (this->action == UPDOWN_ACTION_DOWN) {
- LOG_DEBUG("GPIO event Down\n");
+ LOG_DEBUG("GPIO event Down");
e.inputEvent = this->_eventDown;
}
diff --git a/src/input/cardKbI2cImpl.cpp b/src/input/cardKbI2cImpl.cpp
index f1df6b1377..c1f35ba3c3 100644
--- a/src/input/cardKbI2cImpl.cpp
+++ b/src/input/cardKbI2cImpl.cpp
@@ -9,11 +9,11 @@ CardKbI2cImpl::CardKbI2cImpl() : KbI2cBase("cardKB") {}
void CardKbI2cImpl::init()
{
-#if !MESHTASTIC_EXCLUDE_I2C && !defined(ARCH_PORTDUINO)
+#if !MESHTASTIC_EXCLUDE_I2C && !defined(ARCH_PORTDUINO) && !defined(I2C_NO_RESCAN)
if (cardkb_found.address == 0x00) {
- LOG_DEBUG("Rescanning for I2C keyboard\n");
- uint8_t i2caddr_scan[] = {CARDKB_ADDR, TDECK_KB_ADDR, BBQ10_KB_ADDR};
- uint8_t i2caddr_asize = 3;
+ LOG_DEBUG("Rescanning for I2C keyboard");
+ uint8_t i2caddr_scan[] = {CARDKB_ADDR, TDECK_KB_ADDR, BBQ10_KB_ADDR, MPR121_KB_ADDR};
+ uint8_t i2caddr_asize = 4;
auto i2cScanner = std::unique_ptr(new ScanI2CTwoWire());
#if WIRE_INTERFACES_COUNT == 2
@@ -39,12 +39,17 @@ void CardKbI2cImpl::init()
// assign an arbitrary value to distinguish from other models
kb_model = 0x11;
break;
+ case ScanI2C::DeviceType::MPR121KB:
+ // assign an arbitrary value to distinguish from other models
+ kb_model = 0x37;
+ break;
default:
// use this as default since it's also just zero
- LOG_WARN("kb_info.type is unknown(0x%02x), setting kb_model=0x00\n", kb_info.type);
+ LOG_WARN("kb_info.type is unknown(0x%02x), setting kb_model=0x00", kb_info.type);
kb_model = 0x00;
}
}
+ LOG_DEBUG("Keyboard Type: 0x%02x Model: 0x%02x Address: 0x%02x", kb_info.type, kb_model, cardkb_found.address);
if (cardkb_found.address == 0x00) {
disable();
return;
diff --git a/src/input/kbI2cBase.cpp b/src/input/kbI2cBase.cpp
index 4fbca76e59..d0f36c3868 100644
--- a/src/input/kbI2cBase.cpp
+++ b/src/input/kbI2cBase.cpp
@@ -34,21 +34,27 @@ int32_t KbI2cBase::runOnce()
switch (cardkb_found.port) {
case ScanI2C::WIRE1:
#if WIRE_INTERFACES_COUNT == 2
- LOG_DEBUG("Using I2C Bus 1 (the second one)\n");
+ LOG_DEBUG("Using I2C Bus 1 (the second one)");
i2cBus = &Wire1;
if (cardkb_found.address == BBQ10_KB_ADDR) {
Q10keyboard.begin(BBQ10_KB_ADDR, &Wire1);
Q10keyboard.setBacklight(0);
}
+ if (cardkb_found.address == MPR121_KB_ADDR) {
+ MPRkeyboard.begin(MPR121_KB_ADDR, &Wire1);
+ }
break;
#endif
case ScanI2C::WIRE:
- LOG_DEBUG("Using I2C Bus 0 (the first one)\n");
+ LOG_DEBUG("Using I2C Bus 0 (the first one)");
i2cBus = &Wire;
if (cardkb_found.address == BBQ10_KB_ADDR) {
Q10keyboard.begin(BBQ10_KB_ADDR, &Wire);
Q10keyboard.setBacklight(0);
}
+ if (cardkb_found.address == MPR121_KB_ADDR) {
+ MPRkeyboard.begin(MPR121_KB_ADDR, &Wire);
+ }
break;
case ScanI2C::NO_I2C:
default:
@@ -157,6 +163,69 @@ int32_t KbI2cBase::runOnce()
}
break;
}
+ case 0x37: { // MPR121
+ MPRkeyboard.trigger();
+ InputEvent e;
+
+ while (MPRkeyboard.hasEvent()) {
+ char nextEvent = MPRkeyboard.dequeueEvent();
+ e.inputEvent = ANYKEY;
+ e.kbchar = 0x00;
+ e.source = this->_originName;
+ switch (nextEvent) {
+ case 0x00: // MPR121_NONE
+ e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
+ e.kbchar = 0x00;
+ break;
+ case 0x90: // MPR121_REBOOT
+ e.inputEvent = ANYKEY;
+ e.kbchar = INPUT_BROKER_MSG_REBOOT;
+ break;
+ case 0xb4: // MPR121_LEFT
+ e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT;
+ e.kbchar = 0x00;
+ break;
+ case 0xb5: // MPR121_UP
+ e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_UP;
+ e.kbchar = 0x00;
+ break;
+ case 0xb6: // MPR121_DOWN
+ e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_DOWN;
+ e.kbchar = 0x00;
+ break;
+ case 0xb7: // MPR121_RIGHT
+ e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT;
+ e.kbchar = 0x00;
+ break;
+ case 0x1b: // MPR121_ESC
+ e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_CANCEL;
+ e.kbchar = 0x1b;
+ break;
+ case 0x08: // MPR121_BSP
+ e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_BACK;
+ e.kbchar = 0x08;
+ break;
+ case 0x0d: // MPR121_SELECT
+ e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT;
+ e.kbchar = 0x0d;
+ break;
+ default:
+ if (nextEvent > 127) {
+ e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
+ e.kbchar = 0x00;
+ break;
+ }
+ e.inputEvent = ANYKEY;
+ e.kbchar = nextEvent;
+ break;
+ }
+ if (e.inputEvent != meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE) {
+ LOG_DEBUG("MP121 Notifying: %i Char: %i", e.inputEvent, e.kbchar);
+ this->notifyObservers(&e);
+ }
+ }
+ break;
+ }
case 0x02: {
// RAK14004
uint8_t rDataBuf[8] = {0};
@@ -171,7 +240,7 @@ int32_t KbI2cBase::runOnce()
}
}
if (PrintDataBuf != 0) {
- LOG_DEBUG("RAK14004 key 0x%x pressed\n", PrintDataBuf);
+ LOG_DEBUG("RAK14004 key 0x%x pressed", PrintDataBuf);
InputEvent e;
e.inputEvent = MATRIXKEY;
e.source = this->_originName;
@@ -297,6 +366,7 @@ int32_t KbI2cBase::runOnce()
case 0x9e: // fn+g INPUT_BROKER_MSG_GPS_TOGGLE
case 0xaf: // fn+space INPUT_BROKER_MSG_SEND_PING
case 0x8b: // fn+del INPUT_BROKEN_MSG_DISMISS_FRAME
+ case 0xAA: // fn+b INPUT_BROKER_MSG_BLUETOOTH_TOGGLE
// just pass those unmodified
e.inputEvent = ANYKEY;
e.kbchar = c;
@@ -325,7 +395,7 @@ int32_t KbI2cBase::runOnce()
break;
}
default:
- LOG_WARN("Unknown kb_model 0x%02x\n", kb_model);
+ LOG_WARN("Unknown kb_model 0x%02x", kb_model);
}
return 300;
}
\ No newline at end of file
diff --git a/src/input/kbI2cBase.h b/src/input/kbI2cBase.h
index 35b9b09016..dc2414fc05 100644
--- a/src/input/kbI2cBase.h
+++ b/src/input/kbI2cBase.h
@@ -2,6 +2,7 @@
#include "BBQ10Keyboard.h"
#include "InputBroker.h"
+#include "MPR121Keyboard.h"
#include "Wire.h"
#include "concurrency/OSThread.h"
@@ -19,5 +20,6 @@ class KbI2cBase : public Observable, public concurrency::OST
TwoWire *i2cBus = 0;
BBQ10Keyboard Q10keyboard;
+ MPR121Keyboard MPRkeyboard;
bool is_sym = false;
-};
+};
\ No newline at end of file
diff --git a/src/input/kbMatrixBase.cpp b/src/input/kbMatrixBase.cpp
index 823bfb6291..51815b5259 100644
--- a/src/input/kbMatrixBase.cpp
+++ b/src/input/kbMatrixBase.cpp
@@ -70,7 +70,7 @@ int32_t KbMatrixBase::runOnce()
// debounce
if (key != prevkey) {
if (key != 0) {
- LOG_DEBUG("Key 0x%x pressed\n", key);
+ LOG_DEBUG("Key 0x%x pressed", key);
// reset shift now that we have a keypress
InputEvent e;
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
@@ -122,7 +122,7 @@ int32_t KbMatrixBase::runOnce()
}
} else {
- LOG_WARN("Unknown kb_model 0x%02x\n", INPUTBROKER_MATRIX_TYPE);
+ LOG_WARN("Unknown kb_model 0x%02x", INPUTBROKER_MATRIX_TYPE);
return disable();
}
return 50; // Keyscan every 50msec to avoid key bounce
diff --git a/src/main.cpp b/src/main.cpp
index 25059f3c7f..6bf38b5244 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -27,7 +27,6 @@
#include "detect/ScanI2CTwoWire.h"
#include
#endif
-#include "detect/axpDebug.h"
#include "detect/einkScan.h"
#include "graphics/RAKled.h"
#include "graphics/Screen.h"
@@ -238,7 +237,7 @@ void lateInitVariant() {}
*/
void printInfo()
{
- LOG_INFO("S:B:%d,%s\n", HW_VENDOR, optstr(APP_VERSION));
+ LOG_INFO("S:B:%d,%s", HW_VENDOR, optstr(APP_VERSION));
}
#ifndef PIO_UNIT_TESTING
void setup()
@@ -277,7 +276,7 @@ void setup()
serialSinceMsec = millis();
- LOG_INFO("\n\n//\\ E S H T /\\ S T / C\n\n");
+ LOG_INFO("\n\n//\\ E S H T /\\ S T / C\n");
initDeepSleep();
@@ -298,6 +297,11 @@ void setup()
digitalWrite(VEXT_ENABLE, VEXT_ON_VALUE); // turn on the display power
#endif
+#if defined(BIAS_T_ENABLE)
+ pinMode(BIAS_T_ENABLE, OUTPUT);
+ digitalWrite(BIAS_T_ENABLE, BIAS_T_VALUE); // turn on 5V for GPS Antenna
+#endif
+
#if defined(VTFT_CTRL)
pinMode(VTFT_CTRL, OUTPUT);
digitalWrite(VTFT_CTRL, LOW);
@@ -319,7 +323,7 @@ void setup()
#ifdef PERIPHERAL_WARMUP_MS
// Some peripherals may require additional time to stabilize after power is connected
// e.g. I2C on Heltec Vision Master
- LOG_INFO("Waiting for peripherals to stabilize\n");
+ LOG_INFO("Waiting for peripherals to stabilize");
delay(PERIPHERAL_WARMUP_MS);
#endif
@@ -380,10 +384,10 @@ void setup()
Wire.begin(I2C_SDA, I2C_SCL);
#elif defined(ARCH_PORTDUINO)
if (settingsStrings[i2cdev] != "") {
- LOG_INFO("Using %s as I2C device.\n", settingsStrings[i2cdev].c_str());
+ LOG_INFO("Using %s as I2C device.", settingsStrings[i2cdev].c_str());
Wire.begin(settingsStrings[i2cdev].c_str());
} else {
- LOG_INFO("No I2C device configured, skipping.\n");
+ LOG_INFO("No I2C device configured, skipping.");
}
#elif HAS_WIRE
Wire.begin();
@@ -426,7 +430,7 @@ void setup()
// accessories
auto i2cScanner = std::unique_ptr(new ScanI2CTwoWire());
#if HAS_WIRE
- LOG_INFO("Scanning for i2c devices...\n");
+ LOG_INFO("Scanning for i2c devices...");
#endif
#if defined(I2C_SDA1) && defined(ARCH_RP2040)
@@ -451,7 +455,7 @@ void setup()
i2cScanner->scanPort(ScanI2C::I2CPort::WIRE);
#elif defined(ARCH_PORTDUINO)
if (settingsStrings[i2cdev] != "") {
- LOG_INFO("Scanning for i2c devices...\n");
+ LOG_INFO("Scanning for i2c devices...");
i2cScanner->scanPort(ScanI2C::I2CPort::WIRE);
}
#elif HAS_WIRE
@@ -460,9 +464,9 @@ void setup()
auto i2cCount = i2cScanner->countDevices();
if (i2cCount == 0) {
- LOG_INFO("No I2C devices found\n");
+ LOG_INFO("No I2C devices found");
} else {
- LOG_INFO("%i I2C devices found\n", i2cCount);
+ LOG_INFO("%i I2C devices found", i2cCount);
#ifdef SENSOR_GPS_CONFLICT
sensor_detected = true;
#endif
@@ -518,9 +522,13 @@ void setup()
// assign an arbitrary value to distinguish from other models
kb_model = 0x11;
break;
+ case ScanI2C::DeviceType::MPR121KB:
+ // assign an arbitrary value to distinguish from other models
+ kb_model = 0x37;
+ break;
default:
// use this as default since it's also just zero
- LOG_WARN("kb_info.type is unknown(0x%02x), setting kb_model=0x00\n", kb_info.type);
+ LOG_WARN("kb_info.type is unknown(0x%02x), setting kb_model=0x00", kb_info.type);
kb_model = 0x00;
}
}
@@ -538,10 +546,25 @@ void setup()
rgb_found = i2cScanner->find(ScanI2C::DeviceType::NCP5623);
#endif
+#ifdef HAS_TPS65233
+ // TPS65233 is a power management IC for satellite modems, used in the Dreamcatcher
+ // We are switching it off here since we don't use an LNB.
+ if (i2cScanner->exists(ScanI2C::DeviceType::TPS65233)) {
+ Wire.beginTransmission(TPS65233_ADDR);
+ Wire.write(0); // Register 0
+ Wire.write(128); // Turn off the LNB power, keep I2C Control enabled
+ Wire.endTransmission();
+ Wire.beginTransmission(TPS65233_ADDR);
+ Wire.write(1); // Register 1
+ Wire.write(0); // Turn off Tone Generator 22kHz
+ Wire.endTransmission();
+ }
+#endif
+
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
auto acc_info = i2cScanner->firstAccelerometer();
accelerometer_found = acc_info.type != ScanI2C::DeviceType::NONE ? acc_info.address : accelerometer_found;
- LOG_DEBUG("acc_info = %i\n", acc_info.type);
+ LOG_DEBUG("acc_info = %i", acc_info.type);
#endif
#define STRING(S) #S
@@ -552,7 +575,7 @@ void setup()
if (found.type != ScanI2C::DeviceType::NONE) { \
nodeTelemetrySensorsMap[PB_T].first = found.address.address; \
nodeTelemetrySensorsMap[PB_T].second = i2cScanner->fetchI2CBus(found.address); \
- LOG_DEBUG("found i2c sensor %s\n", STRING(PB_T)); \
+ LOG_DEBUG("found i2c sensor %s", STRING(PB_T)); \
} \
}
@@ -580,10 +603,12 @@ void setup()
SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::TSL2591, meshtastic_TelemetrySensorType_TSL25911FN)
SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::OPT3001, meshtastic_TelemetrySensorType_OPT3001)
SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::MLX90632, meshtastic_TelemetrySensorType_MLX90632)
+ SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::MLX90614, meshtastic_TelemetrySensorType_MLX90614)
SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::SHT4X, meshtastic_TelemetrySensorType_SHT4X)
SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::AHT10, meshtastic_TelemetrySensorType_AHT10)
SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::DFROBOT_LARK, meshtastic_TelemetrySensorType_DFROBOT_LARK)
SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::ICM20948, meshtastic_TelemetrySensorType_ICM20948)
+ SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::MAX30102, meshtastic_TelemetrySensorType_MAX30102)
i2cScanner.reset();
#endif
@@ -602,7 +627,7 @@ void setup()
// Hello
printInfo();
#ifdef BUILD_EPOCH
- LOG_INFO("Build timestamp: %ld\n", BUILD_EPOCH);
+ LOG_INFO("Build timestamp: %ld", BUILD_EPOCH);
#endif
#ifdef ARCH_ESP32
@@ -617,6 +642,8 @@ void setup()
rp2040Setup();
#endif
+ initSPI(); // needed here before reading from littleFS
+
// We do this as early as possible because this loads preferences from flash
// but we need to do this after main cpu init (esp32setup), because we need the random seed set
nodeDB = new NodeDB;
@@ -639,7 +666,7 @@ void setup()
if (config.power.is_power_saving == true &&
IS_ONE_OF(config.device.role, meshtastic_Config_DeviceConfig_Role_TRACKER,
meshtastic_Config_DeviceConfig_Role_TAK_TRACKER, meshtastic_Config_DeviceConfig_Role_SENSOR))
- LOG_DEBUG("Tracker/Sensor: Skipping start melody\n");
+ LOG_DEBUG("Tracker/Sensor: Skipping start melody");
else
playStartMelody();
@@ -649,7 +676,7 @@ void setup()
#if defined(USE_SH1107)
screen_model = meshtastic_Config_DisplayConfig_OledType_OLED_SH1107; // set dimension of 128x128
- display_geometry = GEOMETRY_128_128;
+ screen_geometry = GEOMETRY_128_128;
#endif
#if defined(USE_SH1107_128_64)
@@ -680,7 +707,6 @@ void setup()
#endif
// Init our SPI controller (must be before screen and lora)
- initSPI();
#ifdef ARCH_RP2040
#ifdef HW_SPI1_DEVICE
SPI1.setSCK(LORA_SCK);
@@ -700,7 +726,7 @@ void setup()
#else
// ESP32
SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
- LOG_DEBUG("SPI.begin(SCK=%d, MISO=%d, MOSI=%d, NSS=%d)\n", LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
+ LOG_DEBUG("SPI.begin(SCK=%d, MISO=%d, MOSI=%d, NSS=%d)", LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
SPI.setFrequency(4000000);
#endif
@@ -709,9 +735,9 @@ void setup()
// setup TZ prior to time actions.
#if !MESHTASTIC_EXCLUDE_TZ
- LOG_DEBUG("Using compiled/slipstreamed %s\n", slipstreamTZString); // important, removing this clobbers our magic string
+ LOG_DEBUG("Using compiled/slipstreamed %s", slipstreamTZString); // important, removing this clobbers our magic string
if (*config.device.tzdef && config.device.tzdef[0] != 0) {
- LOG_DEBUG("Saved TZ: %s \n", config.device.tzdef);
+ LOG_DEBUG("Saved TZ: %s ", config.device.tzdef);
setenv("TZ", config.device.tzdef, 1);
} else {
if (strncmp((const char *)slipstreamTZString, "tzpl", 4) == 0) {
@@ -722,7 +748,7 @@ void setup()
}
}
tzset();
- LOG_DEBUG("Set Timezone to %s\n", getenv("TZ"));
+ LOG_DEBUG("Set Timezone to %s", getenv("TZ"));
#endif
readFromRTC(); // read the main CPU RTC at first (in case we can't get GPS time)
@@ -739,7 +765,7 @@ void setup()
if (gps) {
gpsStatus->observe(&gps->newStatus);
} else {
- LOG_DEBUG("Running without GPS.\n");
+ LOG_DEBUG("Running without GPS.");
}
}
}
@@ -752,7 +778,7 @@ void setup()
nodeStatus->observe(&nodeDB->newStatus);
#ifdef HAS_I2S
- LOG_DEBUG("Starting audio thread\n");
+ LOG_DEBUG("Starting audio thread");
audioThread = new AudioThread();
#endif
service = new MeshService();
@@ -799,63 +825,63 @@ void setup()
#ifdef ARCH_PORTDUINO
if (settingsMap[use_sx1262]) {
if (!rIf) {
- LOG_DEBUG("Attempting to activate sx1262 radio on SPI port %s\n", settingsStrings[spidev].c_str());
+ LOG_DEBUG("Attempting to activate sx1262 radio on SPI port %s", settingsStrings[spidev].c_str());
LockingArduinoHal *RadioLibHAL =
new LockingArduinoHal(SPI, spiSettings, (settingsMap[ch341Quirk] ? settingsMap[busy] : RADIOLIB_NC));
rIf = new SX1262Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
settingsMap[busy]);
if (!rIf->init()) {
- LOG_ERROR("Failed to find SX1262 radio\n");
+ LOG_ERROR("Failed to find SX1262 radio");
delete rIf;
exit(EXIT_FAILURE);
} else {
- LOG_INFO("SX1262 Radio init succeeded, using SX1262 radio\n");
+ LOG_INFO("SX1262 Radio init succeeded, using SX1262 radio");
}
}
} else if (settingsMap[use_rf95]) {
if (!rIf) {
- LOG_DEBUG("Attempting to activate rf95 radio on SPI port %s\n", settingsStrings[spidev].c_str());
+ LOG_DEBUG("Attempting to activate rf95 radio on SPI port %s", settingsStrings[spidev].c_str());
LockingArduinoHal *RadioLibHAL =
new LockingArduinoHal(SPI, spiSettings, (settingsMap[ch341Quirk] ? settingsMap[busy] : RADIOLIB_NC));
rIf = new RF95Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
settingsMap[busy]);
if (!rIf->init()) {
- LOG_ERROR("Failed to find RF95 radio\n");
+ LOG_ERROR("Failed to find RF95 radio");
delete rIf;
rIf = NULL;
exit(EXIT_FAILURE);
} else {
- LOG_INFO("RF95 Radio init succeeded, using RF95 radio\n");
+ LOG_INFO("RF95 Radio init succeeded, using RF95 radio");
}
}
} else if (settingsMap[use_sx1280]) {
if (!rIf) {
- LOG_DEBUG("Attempting to activate sx1280 radio on SPI port %s\n", settingsStrings[spidev].c_str());
+ LOG_DEBUG("Attempting to activate sx1280 radio on SPI port %s", settingsStrings[spidev].c_str());
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings);
rIf = new SX1280Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
settingsMap[busy]);
if (!rIf->init()) {
- LOG_ERROR("Failed to find SX1280 radio\n");
+ LOG_ERROR("Failed to find SX1280 radio");
delete rIf;
rIf = NULL;
exit(EXIT_FAILURE);
} else {
- LOG_INFO("SX1280 Radio init succeeded, using SX1280 radio\n");
+ LOG_INFO("SX1280 Radio init succeeded, using SX1280 radio");
}
}
} else if (settingsMap[use_sx1268]) {
if (!rIf) {
- LOG_DEBUG("Attempting to activate sx1268 radio on SPI port %s\n", settingsStrings[spidev].c_str());
+ LOG_DEBUG("Attempting to activate sx1268 radio on SPI port %s", settingsStrings[spidev].c_str());
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings);
rIf = new SX1268Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
settingsMap[busy]);
if (!rIf->init()) {
- LOG_ERROR("Failed to find SX1268 radio\n");
+ LOG_ERROR("Failed to find SX1268 radio");
delete rIf;
rIf = NULL;
exit(EXIT_FAILURE);
} else {
- LOG_INFO("SX1268 Radio init succeeded, using SX1268 radio\n");
+ LOG_INFO("SX1268 Radio init succeeded, using SX1268 radio");
}
}
}
@@ -871,11 +897,11 @@ void setup()
if (!rIf) {
rIf = new STM32WLE5JCInterface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY);
if (!rIf->init()) {
- LOG_WARN("Failed to find STM32WL radio\n");
+ LOG_WARN("Failed to find STM32WL radio");
delete rIf;
rIf = NULL;
} else {
- LOG_INFO("STM32WL Radio init succeeded, using STM32WL radio\n");
+ LOG_INFO("STM32WL Radio init succeeded, using STM32WL radio");
radioType = STM32WLx_RADIO;
}
}
@@ -885,11 +911,11 @@ void setup()
if (!rIf) {
rIf = new SimRadio;
if (!rIf->init()) {
- LOG_WARN("Failed to find simulated radio\n");
+ LOG_WARN("Failed to find simulated radio");
delete rIf;
rIf = NULL;
} else {
- LOG_INFO("Using SIMULATED radio!\n");
+ LOG_INFO("Using SIMULATED radio!");
radioType = SIM_RADIO;
}
}
@@ -899,11 +925,11 @@ void setup()
if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) {
rIf = new RF95Interface(RadioLibHAL, LORA_CS, RF95_IRQ, RF95_RESET, RF95_DIO1);
if (!rIf->init()) {
- LOG_WARN("Failed to find RF95 radio\n");
+ LOG_WARN("Failed to find RF95 radio");
delete rIf;
rIf = NULL;
} else {
- LOG_INFO("RF95 Radio init succeeded, using RF95 radio\n");
+ LOG_INFO("RF95 Radio init succeeded, using RF95 radio");
radioType = RF95_RADIO;
}
}
@@ -913,11 +939,11 @@ void setup()
if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) {
rIf = new SX1262Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY);
if (!rIf->init()) {
- LOG_WARN("Failed to find SX1262 radio\n");
+ LOG_WARN("Failed to find SX1262 radio");
delete rIf;
rIf = NULL;
} else {
- LOG_INFO("SX1262 Radio init succeeded, using SX1262 radio\n");
+ LOG_INFO("SX1262 Radio init succeeded, using SX1262 radio");
radioType = SX1262_RADIO;
}
}
@@ -928,14 +954,12 @@ void setup()
// Try using the specified TCXO voltage
rIf = new SX1262Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY);
if (!rIf->init()) {
- LOG_WARN("Failed to find SX1262 radio with TCXO using DIO3 reference voltage at %f V\n", tcxoVoltage);
+ LOG_WARN("Failed to find SX1262 radio with TCXO, Vref %f V", tcxoVoltage);
delete rIf;
rIf = NULL;
tcxoVoltage = 0; // if it fails, set the TCXO voltage to zero for the next attempt
} else {
- LOG_INFO("SX1262 Radio init succeeded, using ");
- LOG_WARN("SX1262 Radio with TCXO");
- LOG_INFO(", reference voltage at %f V\n", tcxoVoltage);
+ LOG_WARN("SX1262 Radio init succeeded, TCXO, Vref %f V", tcxoVoltage);
radioType = SX1262_RADIO;
}
}
@@ -944,14 +968,12 @@ void setup()
// If specified TCXO voltage fails, attempt to use DIO3 as a reference instea
rIf = new SX1262Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY);
if (!rIf->init()) {
- LOG_WARN("Failed to find SX1262 radio with XTAL using DIO3 reference voltage at %f V\n", tcxoVoltage);
+ LOG_WARN("Failed to find SX1262 radio with XTAL, Vref %f V", tcxoVoltage);
delete rIf;
rIf = NULL;
tcxoVoltage = SX126X_DIO3_TCXO_VOLTAGE; // if it fails, set the TCXO voltage back for the next radio search
} else {
- LOG_INFO("SX1262 Radio init succeeded, using ");
- LOG_WARN("SX1262 Radio with XTAL");
- LOG_INFO(", reference voltage at %f V\n", tcxoVoltage);
+ LOG_INFO("SX1262 Radio init succeeded, XTAL, Vref %f V", tcxoVoltage);
radioType = SX1262_RADIO;
}
}
@@ -961,11 +983,11 @@ void setup()
if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) {
rIf = new SX1268Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY);
if (!rIf->init()) {
- LOG_WARN("Failed to find SX1268 radio\n");
+ LOG_WARN("Failed to find SX1268 radio");
delete rIf;
rIf = NULL;
} else {
- LOG_INFO("SX1268 Radio init succeeded, using SX1268 radio\n");
+ LOG_INFO("SX1268 Radio init succeeded, using SX1268 radio");
radioType = SX1268_RADIO;
}
}
@@ -975,11 +997,11 @@ void setup()
if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) {
rIf = new LLCC68Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY);
if (!rIf->init()) {
- LOG_WARN("Failed to find LLCC68 radio\n");
+ LOG_WARN("Failed to find LLCC68 radio");
delete rIf;
rIf = NULL;
} else {
- LOG_INFO("LLCC68 Radio init succeeded, using LLCC68 radio\n");
+ LOG_INFO("LLCC68 Radio init succeeded, using LLCC68 radio");
radioType = LLCC68_RADIO;
}
}
@@ -989,11 +1011,11 @@ void setup()
if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) {
rIf = new LR1110Interface(RadioLibHAL, LR1110_SPI_NSS_PIN, LR1110_IRQ_PIN, LR1110_NRESET_PIN, LR1110_BUSY_PIN);
if (!rIf->init()) {
- LOG_WARN("Failed to find LR1110 radio\n");
+ LOG_WARN("Failed to find LR1110 radio");
delete rIf;
rIf = NULL;
} else {
- LOG_INFO("LR1110 Radio init succeeded, using LR1110 radio\n");
+ LOG_INFO("LR1110 Radio init succeeded, using LR1110 radio");
radioType = LR1110_RADIO;
}
}
@@ -1003,11 +1025,11 @@ void setup()
if (!rIf) {
rIf = new LR1120Interface(RadioLibHAL, LR1120_SPI_NSS_PIN, LR1120_IRQ_PIN, LR1120_NRESET_PIN, LR1120_BUSY_PIN);
if (!rIf->init()) {
- LOG_WARN("Failed to find LR1120 radio\n");
+ LOG_WARN("Failed to find LR1120 radio");
delete rIf;
rIf = NULL;
} else {
- LOG_INFO("LR1120 Radio init succeeded, using LR1120 radio\n");
+ LOG_INFO("LR1120 Radio init succeeded, using LR1120 radio");
radioType = LR1120_RADIO;
}
}
@@ -1017,11 +1039,11 @@ void setup()
if (!rIf) {
rIf = new LR1121Interface(RadioLibHAL, LR1121_SPI_NSS_PIN, LR1121_IRQ_PIN, LR1121_NRESET_PIN, LR1121_BUSY_PIN);
if (!rIf->init()) {
- LOG_WARN("Failed to find LR1121 radio\n");
+ LOG_WARN("Failed to find LR1121 radio");
delete rIf;
rIf = NULL;
} else {
- LOG_INFO("LR1121 Radio init succeeded, using LR1121 radio\n");
+ LOG_INFO("LR1121 Radio init succeeded, using LR1121 radio");
radioType = LR1121_RADIO;
}
}
@@ -1031,11 +1053,11 @@ void setup()
if (!rIf) {
rIf = new SX1280Interface(RadioLibHAL, SX128X_CS, SX128X_DIO1, SX128X_RESET, SX128X_BUSY);
if (!rIf->init()) {
- LOG_WARN("Failed to find SX1280 radio\n");
+ LOG_WARN("Failed to find SX1280 radio");
delete rIf;
rIf = NULL;
} else {
- LOG_INFO("SX1280 Radio init succeeded, using SX1280 radio\n");
+ LOG_INFO("SX1280 Radio init succeeded, using SX1280 radio");
radioType = SX1280_RADIO;
}
}
@@ -1043,11 +1065,11 @@ void setup()
// check if the radio chip matches the selected region
if ((config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_LORA_24) && (!rIf->wideLora())) {
- LOG_WARN("Radio chip does not support 2.4GHz LoRa. Reverting to unset.\n");
+ LOG_WARN("Radio chip does not support 2.4GHz LoRa. Reverting to unset.");
config.lora.region = meshtastic_Config_LoRaConfig_RegionCode_UNSET;
nodeDB->saveToDisk(SEGMENT_CONFIG);
if (!rIf->reconfigure()) {
- LOG_WARN("Reconfigure failed, rebooting\n");
+ LOG_WARN("Reconfigure failed, rebooting");
screen->startAlert("Rebooting...");
rebootAtMsec = millis() + 5000;
}
@@ -1102,9 +1124,9 @@ void setup()
router->addInterface(rIf);
// Log bit rate to debug output
- LOG_DEBUG("LoRA bitrate = %f bytes / sec\n", (float(meshtastic_Constants_DATA_PAYLOAD_LEN) /
- (float(rIf->getPacketTime(meshtastic_Constants_DATA_PAYLOAD_LEN)))) *
- 1000);
+ LOG_DEBUG("LoRA bitrate = %f bytes / sec", (float(meshtastic_Constants_DATA_PAYLOAD_LEN) /
+ (float(rIf->getPacketTime(meshtastic_Constants_DATA_PAYLOAD_LEN)))) *
+ 1000);
}
// This must be _after_ service.init because we need our preferences loaded from flash to have proper timeout values
@@ -1168,4 +1190,4 @@ void loop()
mainDelay.delay(delayMsec);
}
}
-#endif
+#endif
\ No newline at end of file
diff --git a/src/mesh/Channels.cpp b/src/mesh/Channels.cpp
index bb30e501d4..b9fe956789 100644
--- a/src/mesh/Channels.cpp
+++ b/src/mesh/Channels.cpp
@@ -117,13 +117,18 @@ void Channels::initDefaultChannel(ChannelIndex chIndex)
static const uint8_t defaultpsk0[] = USERPREFS_CHANNEL_0_PSK;
memcpy(channelSettings.psk.bytes, defaultpsk0, sizeof(defaultpsk0));
channelSettings.psk.size = sizeof(defaultpsk0);
-
#endif
#ifdef USERPREFS_CHANNEL_0_NAME
strcpy(channelSettings.name, USERPREFS_CHANNEL_0_NAME);
#endif
#ifdef USERPREFS_CHANNEL_0_PRECISION
channelSettings.module_settings.position_precision = USERPREFS_CHANNEL_0_PRECISION;
+#endif
+#ifdef USERPREFS_CHANNEL_0_UPLINK_ENABLED
+ channelSettings.uplink_enabled = USERPREFS_CHANNEL_0_UPLINK_ENABLED;
+#endif
+#ifdef USERPREFS_CHANNEL_0_DOWNLINK_ENABLED
+ channelSettings.downlink_enabled = USERPREFS_CHANNEL_0_DOWNLINK_ENABLED;
#endif
break;
case 1:
@@ -131,13 +136,18 @@ void Channels::initDefaultChannel(ChannelIndex chIndex)
static const uint8_t defaultpsk1[] = USERPREFS_CHANNEL_1_PSK;
memcpy(channelSettings.psk.bytes, defaultpsk1, sizeof(defaultpsk1));
channelSettings.psk.size = sizeof(defaultpsk1);
-
#endif
#ifdef USERPREFS_CHANNEL_1_NAME
strcpy(channelSettings.name, USERPREFS_CHANNEL_1_NAME);
#endif
#ifdef USERPREFS_CHANNEL_1_PRECISION
channelSettings.module_settings.position_precision = USERPREFS_CHANNEL_1_PRECISION;
+#endif
+#ifdef USERPREFS_CHANNEL_1_UPLINK_ENABLED
+ channelSettings.uplink_enabled = USERPREFS_CHANNEL_1_UPLINK_ENABLED;
+#endif
+#ifdef USERPREFS_CHANNEL_1_DOWNLINK_ENABLED
+ channelSettings.downlink_enabled = USERPREFS_CHANNEL_1_DOWNLINK_ENABLED;
#endif
break;
case 2:
@@ -145,13 +155,18 @@ void Channels::initDefaultChannel(ChannelIndex chIndex)
static const uint8_t defaultpsk2[] = USERPREFS_CHANNEL_2_PSK;
memcpy(channelSettings.psk.bytes, defaultpsk2, sizeof(defaultpsk2));
channelSettings.psk.size = sizeof(defaultpsk2);
-
#endif
#ifdef USERPREFS_CHANNEL_2_NAME
strcpy(channelSettings.name, USERPREFS_CHANNEL_2_NAME);
#endif
#ifdef USERPREFS_CHANNEL_2_PRECISION
channelSettings.module_settings.position_precision = USERPREFS_CHANNEL_2_PRECISION;
+#endif
+#ifdef USERPREFS_CHANNEL_2_UPLINK_ENABLED
+ channelSettings.uplink_enabled = USERPREFS_CHANNEL_2_UPLINK_ENABLED;
+#endif
+#ifdef USERPREFS_CHANNEL_2_DOWNLINK_ENABLED
+ channelSettings.downlink_enabled = USERPREFS_CHANNEL_2_DOWNLINK_ENABLED;
#endif
break;
default:
@@ -175,34 +190,19 @@ CryptoKey Channels::getKey(ChannelIndex chIndex)
k.length = channelSettings.psk.size;
if (k.length == 0) {
if (ch.role == meshtastic_Channel_Role_SECONDARY) {
- LOG_DEBUG("Unset PSK for secondary channel %s. using primary key\n", ch.settings.name);
+ LOG_DEBUG("Unset PSK for secondary channel %s. using primary key", ch.settings.name);
k = getKey(primaryIndex);
} else {
- LOG_WARN("User disabled encryption\n");
+ LOG_WARN("User disabled encryption");
}
} else if (k.length == 1) {
// Convert the short single byte variants of psk into variant that can be used more generally
uint8_t pskIndex = k.bytes[0];
- LOG_DEBUG("Expanding short PSK #%d\n", pskIndex);
+ LOG_DEBUG("Expanding short PSK #%d", pskIndex);
if (pskIndex == 0)
k.length = 0; // Turn off encryption
- else if (oemStore.oem_aes_key.size > 1) {
- // Use the OEM key
- LOG_DEBUG("Using OEM Key with %d bytes\n", oemStore.oem_aes_key.size);
- memcpy(k.bytes, oemStore.oem_aes_key.bytes, oemStore.oem_aes_key.size);
- k.length = oemStore.oem_aes_key.size;
- // Bump up the last byte of PSK as needed
- uint8_t *last = k.bytes + oemStore.oem_aes_key.size - 1;
- *last = *last + pskIndex - 1; // index of 1 means no change vs defaultPSK
- if (k.length < 16) {
- LOG_WARN("OEM provided a too short AES128 key - padding\n");
- k.length = 16;
- } else if (k.length < 32 && k.length != 16) {
- LOG_WARN("OEM provided a too short AES256 key - padding\n");
- k.length = 32;
- }
- } else {
+ else {
memcpy(k.bytes, defaultpsk, sizeof(defaultpsk));
k.length = sizeof(defaultpsk);
// Bump up the last byte of PSK as needed
@@ -212,12 +212,12 @@ CryptoKey Channels::getKey(ChannelIndex chIndex)
} else if (k.length < 16) {
// Error! The user specified only the first few bits of an AES128 key. So by convention we just pad the rest of the
// key with zeros
- LOG_WARN("User provided a too short AES128 key - padding\n");
+ LOG_WARN("User provided a too short AES128 key - padding");
k.length = 16;
} else if (k.length < 32 && k.length != 16) {
// Error! The user specified only the first few bits of an AES256 key. So by convention we just pad the rest of the
// key with zeros
- LOG_WARN("User provided a too short AES256 key - padding\n");
+ LOG_WARN("User provided a too short AES256 key - padding");
k.length = 32;
}
}
@@ -267,7 +267,7 @@ void Channels::onConfigChanged()
}
#if !MESHTASTIC_EXCLUDE_MQTT
if (channels.anyMqttEnabled() && mqtt && !mqtt->isEnabled()) {
- LOG_DEBUG("MQTT is enabled on at least one channel, so set MQTT thread to run immediately\n");
+ LOG_DEBUG("MQTT is enabled on at least one channel, so set MQTT thread to run immediately");
mqtt->start();
}
#endif
@@ -280,7 +280,7 @@ meshtastic_Channel &Channels::getByIndex(ChannelIndex chIndex)
meshtastic_Channel *ch = channelFile.channels + chIndex;
return *ch;
} else {
- LOG_ERROR("Invalid channel index %d > %d, malformed packet received?\n", chIndex, channelFile.channels_count);
+ LOG_ERROR("Invalid channel index %d > %d, malformed packet received?", chIndex, channelFile.channels_count);
static meshtastic_Channel *ch = (meshtastic_Channel *)malloc(sizeof(meshtastic_Channel));
memset(ch, 0, sizeof(meshtastic_Channel));
@@ -384,11 +384,11 @@ bool Channels::hasDefaultChannel()
bool Channels::decryptForHash(ChannelIndex chIndex, ChannelHash channelHash)
{
if (chIndex > getNumChannels() || getHash(chIndex) != channelHash) {
- // LOG_DEBUG("Skipping channel %d (hash %x) due to invalid hash/index, want=%x\n", chIndex, getHash(chIndex),
+ // LOG_DEBUG("Skipping channel %d (hash %x) due to invalid hash/index, want=%x", chIndex, getHash(chIndex),
// channelHash);
return false;
} else {
- LOG_DEBUG("Using channel %d (hash 0x%x)\n", chIndex, channelHash);
+ LOG_DEBUG("Using channel %d (hash 0x%x)", chIndex, channelHash);
setCrypto(chIndex);
return true;
}
diff --git a/src/mesh/CryptoEngine.cpp b/src/mesh/CryptoEngine.cpp
index a875eb8b28..282013ea01 100644
--- a/src/mesh/CryptoEngine.cpp
+++ b/src/mesh/CryptoEngine.cpp
@@ -1,8 +1,6 @@
#include "CryptoEngine.h"
-#include "NodeDB.h"
-#include "RadioInterface.h"
+// #include "NodeDB.h"
#include "architecture.h"
-#include "configuration.h"
#if !(MESHTASTIC_EXCLUDE_PKI)
#include "aes-ccm.h"
@@ -20,7 +18,7 @@
*/
void CryptoEngine::generateKeyPair(uint8_t *pubKey, uint8_t *privKey)
{
- LOG_DEBUG("Generating Curve25519 key pair...\n");
+ LOG_DEBUG("Generating Curve25519 key pair...");
Curve25519::dh1(public_key, private_key);
memcpy(pubKey, public_key, sizeof(public_key));
memcpy(privKey, private_key, sizeof(private_key));
@@ -37,14 +35,14 @@ bool CryptoEngine::regeneratePublicKey(uint8_t *pubKey, uint8_t *privKey)
if (!memfll(privKey, 0, sizeof(private_key))) {
Curve25519::eval(pubKey, privKey, 0);
if (Curve25519::isWeakPoint(pubKey)) {
- LOG_ERROR("PKI key generation failed. Specified private key results in a weak\n");
+ LOG_ERROR("PKI key generation failed. Specified private key results in a weak");
memset(pubKey, 0, 32);
return false;
}
memcpy(private_key, privKey, sizeof(private_key));
memcpy(public_key, pubKey, sizeof(public_key));
} else {
- LOG_WARN("X25519 key generation failed due to blank private key\n");
+ LOG_WARN("X25519 key generation failed due to blank private key");
return false;
}
return true;
@@ -62,23 +60,23 @@ void CryptoEngine::clearKeys()
*
* @param bytes is updated in place
*/
-bool CryptoEngine::encryptCurve25519(uint32_t toNode, uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes,
- uint8_t *bytesOut)
+bool CryptoEngine::encryptCurve25519(uint32_t toNode, uint32_t fromNode, meshtastic_UserLite_public_key_t remotePublic,
+ uint64_t packetNum, size_t numBytes, uint8_t *bytes, uint8_t *bytesOut)
{
uint8_t *auth;
long extraNonceTmp = random();
auth = bytesOut + numBytes;
memcpy((uint8_t *)(auth + 8), &extraNonceTmp,
sizeof(uint32_t)); // do not use dereference on potential non aligned pointers : *extraNonce = extraNonceTmp;
- LOG_INFO("Random nonce value: %d\n", extraNonceTmp);
- meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(toNode);
- if (node->num < 1 || node->user.public_key.size == 0) {
- LOG_DEBUG("Node %d or their public_key not found\n", toNode);
+ LOG_INFO("Random nonce value: %d", extraNonceTmp);
+ if (remotePublic.size == 0) {
+ LOG_DEBUG("Node %d or their public_key not found", toNode);
return false;
}
- if (!crypto->setDHKey(toNode)) {
+ if (!crypto->setDHPublicKey(remotePublic.bytes)) {
return false;
}
+ crypto->hash(shared_key, 32);
initNonce(fromNode, packetNum, extraNonceTmp);
// Calculate the shared secret with the destination node and encrypt
@@ -97,27 +95,27 @@ bool CryptoEngine::encryptCurve25519(uint32_t toNode, uint32_t fromNode, uint64_
*
* @param bytes is updated in place
*/
-bool CryptoEngine::decryptCurve25519(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes, uint8_t *bytesOut)
+bool CryptoEngine::decryptCurve25519(uint32_t fromNode, meshtastic_UserLite_public_key_t remotePublic, uint64_t packetNum,
+ size_t numBytes, uint8_t *bytes, uint8_t *bytesOut)
{
uint8_t *auth; // set to last 8 bytes of text?
uint32_t extraNonce; // pointer was not really used
auth = bytes + numBytes - 12;
memcpy(&extraNonce, auth + 8,
sizeof(uint32_t)); // do not use dereference on potential non aligned pointers : (uint32_t *)(auth + 8);
-#ifndef PIO_UNIT_TESTING
- LOG_INFO("Random nonce value: %d\n", extraNonce);
- meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(fromNode);
+ LOG_INFO("Random nonce value: %d", extraNonce);
- if (node == nullptr || node->num < 1 || node->user.public_key.size == 0) {
- LOG_DEBUG("Node or its public key not found in database\n");
+ if (remotePublic.size == 0) {
+ LOG_DEBUG("Node or its public key not found in database");
return false;
}
// Calculate the shared secret with the sending node and decrypt
- if (!crypto->setDHKey(fromNode)) {
+ if (!crypto->setDHPublicKey(remotePublic.bytes)) {
return false;
}
-#endif
+ crypto->hash(shared_key, 32);
+
initNonce(fromNode, packetNum, extraNonce);
printBytes("Attempting decrypt using nonce: ", nonce, 13);
printBytes("Attempting decrypt using shared_key starting with: ", shared_key, 8);
@@ -128,38 +126,6 @@ void CryptoEngine::setDHPrivateKey(uint8_t *_private_key)
{
memcpy(private_key, _private_key, 32);
}
-/**
- * Set the PKI key used for encrypt, decrypt.
- *
- * @param nodeNum the node number of the node who's public key we want to use
- */
-bool CryptoEngine::setDHKey(uint32_t nodeNum)
-{
- meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeNum);
- if (node->num < 1 || node->user.public_key.size == 0) {
- LOG_DEBUG("Node %d or their public_key not found\n", nodeNum);
- return false;
- }
- printBytes("Generating DH with remote pubkey: ", node->user.public_key.bytes, 32);
- printBytes("And local pubkey: ", config.security.public_key.bytes, 32);
- if (!setDHPublicKey(node->user.public_key.bytes))
- return false;
-
- // printBytes("DH Output: ", shared_key, 32);
-
- /**
- * D.J. Bernstein reccomends hashing the shared key. We want to do this because there are
- * at least 128 bits of entropy in the 256-bit output of the DH key exchange, but we don't
- * really know where. If you extract, for instance, the first 128 bits with basic truncation,
- * then you don't know if you got all of your 128 entropy bits, or less, possibly much less.
- *
- * No exploitable bias is really known at that point, but we know enough to be wary.
- * Hashing the DH output is a simple and safe way to gather all the entropy and spread
- * it around as needed.
- */
- crypto->hash(shared_key, 32);
- return true;
-}
/**
* Hash arbitrary data using SHA256.
@@ -208,7 +174,7 @@ bool CryptoEngine::setDHPublicKey(uint8_t *pubKey)
// Calculate the shared secret with the specified node's public key and our private key
// This includes an internal weak key check, which among other things looks for an all 0 public key and shared key.
if (!Curve25519::dh2(shared_key, local_priv)) {
- LOG_WARN("Curve25519DH step 2 failed!\n");
+ LOG_WARN("Curve25519DH step 2 failed!");
return false;
}
return true;
@@ -219,7 +185,7 @@ concurrency::Lock *cryptLock;
void CryptoEngine::setKey(const CryptoKey &k)
{
- LOG_DEBUG("Using AES%d key!\n", k.length * 8);
+ LOG_DEBUG("Using AES%d key!", k.length * 8);
key = k;
}
@@ -235,7 +201,7 @@ void CryptoEngine::encryptPacket(uint32_t fromNode, uint64_t packetId, size_t nu
if (numBytes <= MAX_BLOCKSIZE) {
encryptAESCtr(key, nonce, numBytes, bytes);
} else {
- LOG_ERROR("Packet too large for crypto engine: %d. noop encryption!\n", numBytes);
+ LOG_ERROR("Packet too large for crypto engine: %d. noop encryption!", numBytes);
}
}
}
diff --git a/src/mesh/CryptoEngine.h b/src/mesh/CryptoEngine.h
index 4c2fc19d93..32862d95c4 100644
--- a/src/mesh/CryptoEngine.h
+++ b/src/mesh/CryptoEngine.h
@@ -39,10 +39,10 @@ class CryptoEngine
#endif
void clearKeys();
void setDHPrivateKey(uint8_t *_private_key);
- virtual bool encryptCurve25519(uint32_t toNode, uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes,
- uint8_t *bytesOut);
- virtual bool decryptCurve25519(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes, uint8_t *bytesOut);
- bool setDHKey(uint32_t nodeNum);
+ virtual bool encryptCurve25519(uint32_t toNode, uint32_t fromNode, meshtastic_UserLite_public_key_t remotePublic,
+ uint64_t packetNum, size_t numBytes, uint8_t *bytes, uint8_t *bytesOut);
+ virtual bool decryptCurve25519(uint32_t fromNode, meshtastic_UserLite_public_key_t remotePublic, uint64_t packetNum,
+ size_t numBytes, uint8_t *bytes, uint8_t *bytesOut);
virtual bool setDHPublicKey(uint8_t *publicKey);
virtual void hash(uint8_t *bytes, size_t numBytes);
diff --git a/src/mesh/Default.cpp b/src/mesh/Default.cpp
index 0bedcfc918..653528b607 100644
--- a/src/mesh/Default.cpp
+++ b/src/mesh/Default.cpp
@@ -43,6 +43,15 @@ uint32_t Default::getConfiguredOrDefaultMsScaled(uint32_t configured, uint32_t d
return getConfiguredOrDefaultMs(configured, defaultValue) * congestionScalingCoefficient(numOnlineNodes);
}
+uint32_t Default::getConfiguredOrMinimumValue(uint32_t configured, uint32_t minValue)
+{
+ // If zero, intervals should be coalesced later by getConfiguredOrDefault... methods
+ if (configured == 0)
+ return configured;
+
+ return configured < minValue ? minValue : configured;
+}
+
uint8_t Default::getConfiguredOrDefaultHopLimit(uint8_t configured)
{
#if USERPREFS_EVENT_MODE
diff --git a/src/mesh/Default.h b/src/mesh/Default.h
index 5641b5d25f..2406dafc52 100644
--- a/src/mesh/Default.h
+++ b/src/mesh/Default.h
@@ -6,8 +6,9 @@
#define THIRTY_SECONDS_MS 30 * 1000
#define FIVE_SECONDS_MS 5 * 1000
+#define min_default_telemetry_interval_secs 30 * 60
#define default_gps_update_interval IF_ROUTER(ONE_DAY, 2 * 60)
-#define default_telemetry_broadcast_interval_secs IF_ROUTER(ONE_DAY / 2, 30 * 60)
+#define default_telemetry_broadcast_interval_secs IF_ROUTER(ONE_DAY / 2, 60 * 60)
#define default_broadcast_interval_secs IF_ROUTER(ONE_DAY / 2, 15 * 60)
#define default_wait_bluetooth_secs IF_ROUTER(1, 60)
#define default_sds_secs IF_ROUTER(ONE_DAY, UINT32_MAX) // Default to forever super deep sleep
@@ -35,6 +36,7 @@ class Default
static uint32_t getConfiguredOrDefault(uint32_t configured, uint32_t defaultValue);
static uint32_t getConfiguredOrDefaultMsScaled(uint32_t configured, uint32_t defaultValue, uint32_t numOnlineNodes);
static uint8_t getConfiguredOrDefaultHopLimit(uint8_t configured);
+ static uint32_t getConfiguredOrMinimumValue(uint32_t configured, uint32_t minValue);
private:
static float congestionScalingCoefficient(int numOnlineNodes)
diff --git a/src/mesh/FloodingRouter.cpp b/src/mesh/FloodingRouter.cpp
index 23f6b6f92d..6760d70ebf 100644
--- a/src/mesh/FloodingRouter.cpp
+++ b/src/mesh/FloodingRouter.cpp
@@ -35,17 +35,23 @@ bool FloodingRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
return Router::shouldFilterReceived(p);
}
+bool FloodingRouter::isRebroadcaster()
+{
+ return config.device.role != meshtastic_Config_DeviceConfig_Role_CLIENT_MUTE &&
+ config.device.rebroadcast_mode != meshtastic_Config_DeviceConfig_RebroadcastMode_NONE;
+}
+
void FloodingRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Routing *c)
{
bool isAckorReply = (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) && (p->decoded.request_id != 0);
- if (isAckorReply && !isToUs(p) && p->to != NODENUM_BROADCAST) {
+ if (isAckorReply && !isToUs(p) && !isBroadcast(p->to)) {
// do not flood direct message that is ACKed or replied to
- LOG_DEBUG("Rxd an ACK/reply not for me, cancel rebroadcast.\n");
+ LOG_DEBUG("Rxd an ACK/reply not for me, cancel rebroadcast.");
Router::cancelSending(p->to, p->decoded.request_id); // cancel rebroadcast for this DM
}
if (!isToUs(p) && (p->hop_limit > 0) && !isFromUs(p)) {
if (p->id != 0) {
- if (config.device.role != meshtastic_Config_DeviceConfig_Role_CLIENT_MUTE) {
+ if (isRebroadcaster()) {
meshtastic_MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it
tosend->hop_limit--; // bump down the hop count
@@ -57,15 +63,15 @@ void FloodingRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtas
}
#endif
- LOG_INFO("Rebroadcasting received floodmsg\n");
+ LOG_INFO("Rebroadcasting received floodmsg");
// Note: we are careful to resend using the original senders node id
// We are careful not to call our hooked version of send() - because we don't want to check this again
Router::send(tosend);
} else {
- LOG_DEBUG("Not rebroadcasting. Role = Role_ClientMute\n");
+ LOG_DEBUG("Not rebroadcasting: Role = CLIENT_MUTE or Rebroadcast Mode = NONE");
}
} else {
- LOG_DEBUG("Ignoring 0 id broadcast\n");
+ LOG_DEBUG("Ignoring 0 id broadcast");
}
}
// handle the packet as normal
diff --git a/src/mesh/FloodingRouter.h b/src/mesh/FloodingRouter.h
index a3adfe70c9..0ed2b55823 100644
--- a/src/mesh/FloodingRouter.h
+++ b/src/mesh/FloodingRouter.h
@@ -29,6 +29,8 @@
class FloodingRouter : public Router, protected PacketHistory
{
private:
+ bool isRebroadcaster();
+
public:
/**
* Constructor
diff --git a/src/mesh/LR11x0Interface.cpp b/src/mesh/LR11x0Interface.cpp
index 6641634c4c..d0c1a1fbcd 100644
--- a/src/mesh/LR11x0Interface.cpp
+++ b/src/mesh/LR11x0Interface.cpp
@@ -35,7 +35,7 @@ LR11x0Interface::LR11x0Interface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs
RADIOLIB_PIN_TYPE busy)
: RadioLibInterface(hal, cs, irq, rst, busy, &lora), lora(&module)
{
- LOG_WARN("LR11x0Interface(cs=%d, irq=%d, rst=%d, busy=%d)\n", cs, irq, rst, busy);
+ LOG_WARN("LR11x0Interface(cs=%d, irq=%d, rst=%d, busy=%d)", cs, irq, rst, busy);
}
/// Initialise the Driver transport hardware and software.
@@ -54,10 +54,10 @@ template bool LR11x0Interface::init()
0; // "TCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip." per
// https://github.com/jgromes/RadioLib/blob/690a050ebb46e6097c5d00c371e961c1caa3b52e/src/modules/LR11x0/LR11x0.h#L471C26-L471C104
// (DIO3 is free to be used as an IRQ)
- LOG_DEBUG("LR11X0_DIO3_TCXO_VOLTAGE not defined, not using DIO3 as TCXO reference voltage\n");
+ LOG_DEBUG("LR11X0_DIO3_TCXO_VOLTAGE not defined, not using DIO3 as TCXO reference voltage");
#else
float tcxoVoltage = LR11X0_DIO3_TCXO_VOLTAGE;
- LOG_DEBUG("LR11X0_DIO3_TCXO_VOLTAGE defined, using DIO3 as TCXO reference voltage at %f V\n", LR11X0_DIO3_TCXO_VOLTAGE);
+ LOG_DEBUG("LR11X0_DIO3_TCXO_VOLTAGE defined, using DIO3 as TCXO reference voltage at %f V", LR11X0_DIO3_TCXO_VOLTAGE);
// (DIO3 is not free to be used as an IRQ)
#endif
@@ -67,27 +67,40 @@ template bool LR11x0Interface::init()
power = LR1110_MAX_POWER;
if ((power > LR1120_MAX_POWER) &&
- (config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) // clamp again if wide freq range
+ (config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) { // clamp again if wide freq range
power = LR1120_MAX_POWER;
+ preambleLength = 12; // 12 is the default for operation above 2GHz
+ }
limitPower();
+#ifdef LR11X0_RF_SWITCH_SUBGHZ
+ pinMode(LR11X0_RF_SWITCH_SUBGHZ, OUTPUT);
+ digitalWrite(LR11X0_RF_SWITCH_SUBGHZ, getFreq() < 1e9 ? HIGH : LOW);
+ LOG_DEBUG("Setting RF0 switch to %s", getFreq() < 1e9 ? "SubGHz" : "2.4GHz");
+#endif
+
+#ifdef LR11X0_RF_SWITCH_2_4GHZ
+ pinMode(LR11X0_RF_SWITCH_2_4GHZ, OUTPUT);
+ digitalWrite(LR11X0_RF_SWITCH_2_4GHZ, getFreq() < 1e9 ? LOW : HIGH);
+ LOG_DEBUG("Setting RF1 switch to %s", getFreq() < 1e9 ? "SubGHz" : "2.4GHz");
+#endif
+
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage);
// \todo Display actual typename of the adapter, not just `LR11x0`
- LOG_INFO("LR11x0 init result %d\n", res);
+ LOG_INFO("LR11x0 init result %d", res);
if (res == RADIOLIB_ERR_CHIP_NOT_FOUND)
return false;
LR11x0VersionInfo_t version;
res = lora.getVersionInfo(&version);
if (res == RADIOLIB_ERR_NONE)
- LOG_DEBUG("LR11x0 Device %d, HW %d, FW %d.%d, WiFi %d.%d, GNSS %d.%d\n", version.device, version.hardware,
- version.fwMajor, version.fwMinor, version.fwMajorWiFi, version.fwMinorWiFi, version.fwGNSS,
- version.almanacGNSS);
+ LOG_DEBUG("LR11x0 Device %d, HW %d, FW %d.%d, WiFi %d.%d, GNSS %d.%d", version.device, version.hardware, version.fwMajor,
+ version.fwMinor, version.fwMajorWiFi, version.fwMinorWiFi, version.fwGNSS, version.almanacGNSS);
- LOG_INFO("Frequency set to %f\n", getFreq());
- LOG_INFO("Bandwidth set to %f\n", bw);
- LOG_INFO("Power output set to %d\n", power);
+ LOG_INFO("Frequency set to %f", getFreq());
+ LOG_INFO("Bandwidth set to %f", bw);
+ LOG_INFO("Power output set to %d", power);
if (res == RADIOLIB_ERR_NONE)
res = lora.setCRC(2);
@@ -109,16 +122,16 @@ template bool LR11x0Interface::init()
if (dioAsRfSwitch) {
lora.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
- LOG_DEBUG("Setting DIO RF switch\n", res);
+ LOG_DEBUG("Setting DIO RF switch", res);
}
if (res == RADIOLIB_ERR_NONE) {
if (config.lora.sx126x_rx_boosted_gain) { // the name is unfortunate but historically accurate
res = lora.setRxBoostedGainMode(true);
- LOG_INFO("Set RX gain to boosted mode; result: %d\n", res);
+ LOG_INFO("Set RX gain to boosted mode; result: %d", res);
} else {
res = lora.setRxBoostedGainMode(false);
- LOG_INFO("Set RX gain to power saving mode (boosted mode off); result: %d\n", res);
+ LOG_INFO("Set RX gain to power saving mode (boosted mode off); result: %d", res);
}
}
@@ -188,7 +201,7 @@ template void LR11x0Interface::setStandby()
int err = lora.standby();
if (err != RADIOLIB_ERR_NONE) {
- LOG_DEBUG("LR11x0 standby failed with error %d\n", err);
+ LOG_DEBUG("LR11x0 standby failed with error %d", err);
}
assert(err == RADIOLIB_ERR_NONE);
@@ -205,7 +218,7 @@ template void LR11x0Interface::setStandby()
*/
template void LR11x0Interface::addReceiveMetadata(meshtastic_MeshPacket *mp)
{
- // LOG_DEBUG("PacketStatus %x\n", lora.getPacketStatus());
+ // LOG_DEBUG("PacketStatus %x", lora.getPacketStatus());
mp->rx_snr = lora.getSNR();
mp->rx_rssi = lround(lora.getRSSI());
}
@@ -270,7 +283,7 @@ template bool LR11x0Interface::isActivelyReceiving()
template bool LR11x0Interface::sleep()
{
// \todo Display actual typename of the adapter, not just `LR11x0`
- LOG_DEBUG("LR11x0 entering sleep mode\n");
+ LOG_DEBUG("LR11x0 entering sleep mode");
setStandby(); // Stop any pending operations
// turn off TCXO if it was powered
diff --git a/src/mesh/MeshModule.cpp b/src/mesh/MeshModule.cpp
index c60404c983..a8de540eb3 100644
--- a/src/mesh/MeshModule.cpp
+++ b/src/mesh/MeshModule.cpp
@@ -55,7 +55,7 @@ meshtastic_MeshPacket *MeshModule::allocAckNak(meshtastic_Routing_Error err, Nod
p->decoded.request_id = idFrom;
p->channel = chIndex;
if (err != meshtastic_Routing_Error_NONE)
- LOG_WARN("Alloc an err=%d,to=0x%x,idFrom=0x%x,id=0x%x\n", err, to, idFrom, p->id);
+ LOG_WARN("Alloc an err=%d,to=0x%x,idFrom=0x%x,id=0x%x", err, to, idFrom, p->id);
return p;
}
@@ -74,7 +74,7 @@ meshtastic_MeshPacket *MeshModule::allocErrorResponse(meshtastic_Routing_Error e
void MeshModule::callModules(meshtastic_MeshPacket &mp, RxSource src)
{
- // LOG_DEBUG("In call modules\n");
+ // LOG_DEBUG("In call modules");
bool moduleFound = false;
// We now allow **encrypted** packets to pass through the modules
@@ -86,7 +86,7 @@ void MeshModule::callModules(meshtastic_MeshPacket &mp, RxSource src)
// Was this message directed to us specifically? Will be false if we are sniffing someone elses packets
auto ourNodeNum = nodeDB->getNodeNum();
- bool toUs = mp.to == NODENUM_BROADCAST || isToUs(&mp);
+ bool toUs = isBroadcast(mp.to) || isToUs(&mp);
for (auto i = modules->begin(); i != modules->end(); ++i) {
auto &pi = **i;
@@ -104,7 +104,7 @@ void MeshModule::callModules(meshtastic_MeshPacket &mp, RxSource src)
assert(!pi.myReply); // If it is !null it means we have a bug, because it should have been sent the previous time
if (wantsPacket) {
- LOG_DEBUG("Module '%s' wantsPacket=%d\n", pi.name, wantsPacket);
+ LOG_DEBUG("Module '%s' wantsPacket=%d", pi.name, wantsPacket);
moduleFound = true;
@@ -144,20 +144,20 @@ void MeshModule::callModules(meshtastic_MeshPacket &mp, RxSource src)
if (isDecoded && mp.decoded.want_response && toUs && (!isFromUs(&mp) || isToUs(&mp)) && !currentReply) {
pi.sendResponse(mp);
ignoreRequest = ignoreRequest || pi.ignoreRequest; // If at least one module asks it, we may ignore a request
- LOG_INFO("Asked module '%s' to send a response\n", pi.name);
+ LOG_INFO("Asked module '%s' to send a response", pi.name);
} else {
- LOG_DEBUG("Module '%s' considered\n", pi.name);
+ LOG_DEBUG("Module '%s' considered", pi.name);
}
// If the requester didn't ask for a response we might need to discard unused replies to prevent memory leaks
if (pi.myReply) {
- LOG_DEBUG("Discarding an unneeded response\n");
+ LOG_DEBUG("Discarding an unneeded response");
packetPool.release(pi.myReply);
pi.myReply = NULL;
}
if (handled == ProcessMessage::STOP) {
- LOG_DEBUG("Module '%s' handled and skipped other processing\n", pi.name);
+ LOG_DEBUG("Module '%s' handled and skipped other processing", pi.name);
break;
}
}
@@ -176,7 +176,7 @@ void MeshModule::callModules(meshtastic_MeshPacket &mp, RxSource src)
// no response reply
// No one wanted to reply to this request, tell the requster that happened
- LOG_DEBUG("No one responded, send a nak\n");
+ LOG_DEBUG("No one responded, send a nak");
// SECURITY NOTE! I considered sending back a different error code if we didn't find the psk (i.e. !isDecoded)
// but opted NOT TO. Because it is not a good idea to let remote nodes 'probe' to find out which PSKs were "good" vs
@@ -187,8 +187,7 @@ void MeshModule::callModules(meshtastic_MeshPacket &mp, RxSource src)
}
if (!moduleFound && isDecoded) {
- LOG_DEBUG("No modules interested in portnum=%d, src=%s\n", mp.decoded.portnum,
- (src == RX_SRC_LOCAL) ? "LOCAL" : "REMOTE");
+ LOG_DEBUG("No modules interested in portnum=%d, src=%s", mp.decoded.portnum, (src == RX_SRC_LOCAL) ? "LOCAL" : "REMOTE");
}
}
@@ -211,7 +210,7 @@ void MeshModule::sendResponse(const meshtastic_MeshPacket &req)
currentReply = r;
} else {
// Ignore - this is now expected behavior for routing module (because it ignores some replies)
- // LOG_WARN("Client requested response but this module did not provide\n");
+ // LOG_WARN("Client requested response but this module did not provide");
}
}
@@ -240,7 +239,7 @@ std::vector MeshModule::GetMeshModulesWithUIFrames()
for (auto i = modules->begin(); i != modules->end(); ++i) {
auto &pi = **i;
if (pi.wantUIFrame()) {
- LOG_DEBUG("%s wants a UI Frame\n", pi.name);
+ LOG_DEBUG("%s wants a UI Frame", pi.name);
modulesWithUIFrames.push_back(&pi);
}
}
@@ -255,7 +254,7 @@ void MeshModule::observeUIEvents(Observer *observer)
auto &pi = **i;
Observable *observable = pi.getUIFrameObservable();
if (observable != NULL) {
- LOG_DEBUG("%s wants a UI Frame\n", pi.name);
+ LOG_DEBUG("%s wants a UI Frame", pi.name);
observer->observe(observable);
}
}
@@ -273,7 +272,7 @@ AdminMessageHandleResult MeshModule::handleAdminMessageForAllModules(const mesht
AdminMessageHandleResult h = pi.handleAdminMessageForModule(mp, request, response);
if (h == AdminMessageHandleResult::HANDLED_WITH_RESPONSE) {
// In case we have a response it always has priority.
- LOG_DEBUG("Reply prepared by module '%s' of variant: %d\n", pi.name, response->which_payload_variant);
+ LOG_DEBUG("Reply prepared by module '%s' of variant: %d", pi.name, response->which_payload_variant);
handled = h;
} else if ((handled != AdminMessageHandleResult::HANDLED_WITH_RESPONSE) && (h == AdminMessageHandleResult::HANDLED)) {
// In case the message is handled it should be populated, but will not overwrite
diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp
index 655348bd57..d224c05dca 100644
--- a/src/mesh/MeshService.cpp
+++ b/src/mesh/MeshService.cpp
@@ -80,15 +80,15 @@ int MeshService::handleFromRadio(const meshtastic_MeshPacket *mp)
nodeDB->updateFrom(*mp); // update our DB state based off sniffing every RX packet from the radio
if (mp->which_payload_variant == meshtastic_MeshPacket_decoded_tag &&
mp->decoded.portnum == meshtastic_PortNum_TELEMETRY_APP && mp->decoded.request_id > 0) {
- LOG_DEBUG("Received telemetry response. Skip sending our NodeInfo.\n"); // because this potentially a Repeater which will
- // ignore our request for its NodeInfo
+ LOG_DEBUG("Received telemetry response. Skip sending our NodeInfo."); // because this potentially a Repeater which will
+ // ignore our request for its NodeInfo
} else if (mp->which_payload_variant == meshtastic_MeshPacket_decoded_tag && !nodeDB->getMeshNode(mp->from)->has_user &&
nodeInfoModule) {
- LOG_INFO("Heard new node on channel %d, sending NodeInfo and asking for a response.\n", mp->channel);
+ LOG_INFO("Heard new node on channel %d, sending NodeInfo and asking for a response.", mp->channel);
if (airTime->isTxAllowedChannelUtil(true)) {
nodeInfoModule->sendOurNodeInfo(mp->from, true, mp->channel);
} else {
- LOG_DEBUG("Skip sending NodeInfo due to > 25 percent channel util.\n");
+ LOG_DEBUG("Skip sending NodeInfo due to > 25 percent channel util.");
}
}
@@ -130,7 +130,7 @@ bool MeshService::reloadConfig(int saveWhat)
/// The owner User record just got updated, update our node DB and broadcast the info into the mesh
void MeshService::reloadOwner(bool shouldSave)
{
- // LOG_DEBUG("reloadOwner()\n");
+ // LOG_DEBUG("reloadOwner()");
// update our local data directly
nodeDB->updateUser(nodeDB->getNodeNum(), owner);
assert(nodeInfoModule);
@@ -180,7 +180,7 @@ void MeshService::handleToRadio(meshtastic_MeshPacket &p)
// Switch the port from PortNum_SIMULATOR_APP back to the original PortNum
p.decoded.portnum = decoded->portnum;
} else
- LOG_ERROR("Error decoding protobuf for simulator message!\n");
+ LOG_ERROR("Error decoding protobuf for simulator message!");
}
// Let SimRadio receive as if it did via its LoRa chip
SimRadio::instance->startReceive(&p);
@@ -222,7 +222,7 @@ ErrorCode MeshService::sendQueueStatusToPhone(const meshtastic_QueueStatus &qs,
copied->mesh_packet_id = mesh_packet_id;
if (toPhoneQueueStatusQueue.numFree() == 0) {
- LOG_INFO("tophone queue status queue is full, discarding oldest\n");
+ LOG_INFO("tophone queue status queue is full, discarding oldest");
meshtastic_QueueStatus *d = toPhoneQueueStatusQueue.dequeuePtr(0);
if (d)
releaseQueueStatusToPool(d);
@@ -266,14 +266,14 @@ bool MeshService::trySendPosition(NodeNum dest, bool wantReplies)
if (hasValidPosition(node)) {
#if HAS_GPS && !MESHTASTIC_EXCLUDE_GPS
if (positionModule) {
- LOG_INFO("Sending position ping to 0x%x, wantReplies=%d, channel=%d\n", dest, wantReplies, node->channel);
+ LOG_INFO("Sending position ping to 0x%x, wantReplies=%d, channel=%d", dest, wantReplies, node->channel);
positionModule->sendOurPosition(dest, wantReplies, node->channel);
return true;
}
} else {
#endif
if (nodeInfoModule) {
- LOG_INFO("Sending nodeinfo ping to 0x%x, wantReplies=%d, channel=%d\n", dest, wantReplies, node->channel);
+ LOG_INFO("Sending nodeinfo ping to 0x%x, wantReplies=%d, channel=%d", dest, wantReplies, node->channel);
nodeInfoModule->sendOurNodeInfo(dest, wantReplies, node->channel);
}
}
@@ -298,12 +298,12 @@ void MeshService::sendToPhone(meshtastic_MeshPacket *p)
if (toPhoneQueue.numFree() == 0) {
if (p->decoded.portnum == meshtastic_PortNum_TEXT_MESSAGE_APP ||
p->decoded.portnum == meshtastic_PortNum_RANGE_TEST_APP) {
- LOG_WARN("ToPhone queue is full, discarding oldest\n");
+ LOG_WARN("ToPhone queue is full, discarding oldest");
meshtastic_MeshPacket *d = toPhoneQueue.dequeuePtr(0);
if (d)
releaseToPool(d);
} else {
- LOG_WARN("ToPhone queue is full, dropping packet.\n");
+ LOG_WARN("ToPhone queue is full, dropping packet.");
releaseToPool(p);
fromNum++; // Make sure to notify observers in case they are reconnected so they can get the packets
return;
@@ -316,9 +316,9 @@ void MeshService::sendToPhone(meshtastic_MeshPacket *p)
void MeshService::sendMqttMessageToClientProxy(meshtastic_MqttClientProxyMessage *m)
{
- LOG_DEBUG("Sending mqtt message on topic '%s' to client for proxy\n", m->topic);
+ LOG_DEBUG("Sending mqtt message on topic '%s' to client for proxy", m->topic);
if (toPhoneMqttProxyQueue.numFree() == 0) {
- LOG_WARN("MqttClientProxyMessagePool queue is full, discarding oldest\n");
+ LOG_WARN("MqttClientProxyMessagePool queue is full, discarding oldest");
meshtastic_MqttClientProxyMessage *d = toPhoneMqttProxyQueue.dequeuePtr(0);
if (d)
releaseMqttClientProxyMessageToPool(d);
@@ -330,9 +330,9 @@ void MeshService::sendMqttMessageToClientProxy(meshtastic_MqttClientProxyMessage
void MeshService::sendClientNotification(meshtastic_ClientNotification *n)
{
- LOG_DEBUG("Sending client notification to phone\n");
+ LOG_DEBUG("Sending client notification to phone");
if (toPhoneClientNotificationQueue.numFree() == 0) {
- LOG_WARN("ClientNotification queue is full, discarding oldest\n");
+ LOG_WARN("ClientNotification queue is full, discarding oldest");
meshtastic_ClientNotification *d = toPhoneClientNotificationQueue.dequeuePtr(0);
if (d)
releaseClientNotificationToPool(d);
@@ -381,12 +381,12 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus)
} else {
// The GPS has lost lock
#ifdef GPS_EXTRAVERBOSE
- LOG_DEBUG("onGPSchanged() - lost validLocation\n");
+ LOG_DEBUG("onGPSchanged() - lost validLocation");
#endif
}
// Used fixed position if configured regardless of GPS lock
if (config.position.fixed_position) {
- LOG_WARN("Using fixed position\n");
+ LOG_WARN("Using fixed position");
pos = TypeConversions::ConvertToPosition(node->position);
}
@@ -394,7 +394,7 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus)
pos.time = getValidTime(RTCQualityFromNet);
// In debug logs, identify position by @timestamp:stage (stage 4 = nodeDB)
- LOG_DEBUG("onGPSChanged() pos@%x time=%u lat=%d lon=%d alt=%d\n", pos.timestamp, pos.time, pos.latitude_i, pos.longitude_i,
+ LOG_DEBUG("onGPSChanged() pos@%x time=%u lat=%d lon=%d alt=%d", pos.timestamp, pos.time, pos.latitude_i, pos.longitude_i,
pos.altitude);
// Update our current position in the local DB
diff --git a/src/mesh/MeshTypes.h b/src/mesh/MeshTypes.h
index 27d100fbef..7a3d785dd5 100644
--- a/src/mesh/MeshTypes.h
+++ b/src/mesh/MeshTypes.h
@@ -57,4 +57,6 @@ bool isFromUs(const meshtastic_MeshPacket *p);
bool isToUs(const meshtastic_MeshPacket *p);
/* Some clients might not properly set priority, therefore we fix it here. */
-void fixPriority(meshtastic_MeshPacket *p);
\ No newline at end of file
+void fixPriority(meshtastic_MeshPacket *p);
+
+bool isBroadcast(uint32_t dest);
\ No newline at end of file
diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp
index 97ded5a50f..69cd631c0f 100644
--- a/src/mesh/NodeDB.cpp
+++ b/src/mesh/NodeDB.cpp
@@ -32,9 +32,14 @@
#if HAS_WIFI
#include "mesh/wifi/WiFiAPClient.h"
#endif
+#include "SPILock.h"
#include "modules/StoreForwardModule.h"
#include
+#include
+#include
#include
+#include
+#include
#endif
#ifdef ARCH_PORTDUINO
@@ -55,8 +60,6 @@ meshtastic_MyNodeInfo &myNodeInfo = devicestate.my_node;
meshtastic_LocalConfig config;
meshtastic_LocalModuleConfig moduleConfig;
meshtastic_ChannelFile channelFile;
-meshtastic_OEMStore oemStore;
-static bool hasOemStore = false;
bool meshtastic_DeviceState_callback(pb_istream_t *istream, pb_ostream_t *ostream, const pb_field_iter_t *field)
{
@@ -102,7 +105,7 @@ static uint8_t ourMacAddr[6];
NodeDB::NodeDB()
{
- LOG_INFO("Initializing NodeDB\n");
+ LOG_INFO("Initializing NodeDB");
loadFromDisk();
cleanupMeshDB();
@@ -111,6 +114,43 @@ NodeDB::NodeDB()
uint32_t channelFileCRC = crc32Buffer(&channelFile, sizeof(channelFile));
int saveWhat = 0;
+ bool hasUniqueId = false;
+ // Get device unique id
+#if defined(ARCH_ESP32) && defined(ESP_EFUSE_OPTIONAL_UNIQUE_ID)
+ uint32_t unique_id[4];
+ // ESP32 factory burns a unique id in efuse for S2+ series and evidently C3+ series
+ // This is used for HMACs in the esp-rainmaker AIOT platform and seems to be a good choice for us
+ esp_err_t err = esp_efuse_read_field_blob(ESP_EFUSE_OPTIONAL_UNIQUE_ID, unique_id, sizeof(unique_id) * 8);
+ if (err == ESP_OK) {
+ memcpy(myNodeInfo.device_id.bytes, unique_id, sizeof(unique_id));
+ myNodeInfo.device_id.size = 16;
+ hasUniqueId = true;
+ } else {
+ LOG_WARN("Failed to read unique id from efuse");
+ }
+#elif defined(ARCH_NRF52)
+ // Nordic applies a FIPS compliant Random ID to each chip at the factory
+ // We concatenate the device address to the Random ID to create a unique ID for now
+ // This will likely utilize a crypto module in the future
+ uint64_t device_id_start = ((uint64_t)NRF_FICR->DEVICEID[1] << 32) | NRF_FICR->DEVICEID[0];
+ uint64_t device_id_end = ((uint64_t)NRF_FICR->DEVICEADDR[1] << 32) | NRF_FICR->DEVICEADDR[0];
+ memcpy(myNodeInfo.device_id.bytes, &device_id_start, sizeof(device_id_start));
+ memcpy(myNodeInfo.device_id.bytes + sizeof(device_id_start), &device_id_end, sizeof(device_id_end));
+ myNodeInfo.device_id.size = 16;
+ hasUniqueId = true;
+#else
+ // FIXME - implement for other platforms
+#endif
+ // Uncomment below to print the device id
+ // if (hasUniqueId) {
+ // std::string deviceIdHex;
+ // for (size_t i = 0; i < myNodeInfo.device_id.size; ++i) {
+ // char buf[3];
+ // snprintf(buf, sizeof(buf), "%02X", myNodeInfo.device_id.bytes[i]);
+ // deviceIdHex += buf;
+ // }
+ // LOG_DEBUG("Device ID (HEX): %s", deviceIdHex.c_str());
+ // }
// likewise - we always want the app requirements to come from the running appload
myNodeInfo.min_app_version = 30200; // format is Mmmss (where M is 1+the numeric major number. i.e. 30200 means 2.2.00
@@ -140,7 +180,7 @@ NodeDB::NodeDB()
keygenSuccess = true;
}
} else {
- LOG_INFO("Generating new PKI keys\n");
+ LOG_INFO("Generating new PKI keys");
crypto->generateKeyPair(config.security.public_key.bytes, config.security.private_key.bytes);
keygenSuccess = true;
}
@@ -167,11 +207,27 @@ NodeDB::NodeDB()
preferences.begin("meshtastic", false);
myNodeInfo.reboot_count = preferences.getUInt("rebootCounter", 0);
preferences.end();
- LOG_DEBUG("Number of Device Reboots: %d\n", myNodeInfo.reboot_count);
+ LOG_DEBUG("Number of Device Reboots: %d", myNodeInfo.reboot_count);
#endif
resetRadioConfig(); // If bogus settings got saved, then fix them
- // nodeDB->LOG_DEBUG("region=%d, NODENUM=0x%x, dbsize=%d\n", config.lora.region, myNodeInfo.my_node_num, numMeshNodes);
+ // nodeDB->LOG_DEBUG("region=%d, NODENUM=0x%x, dbsize=%d", config.lora.region, myNodeInfo.my_node_num, numMeshNodes);
+
+ // If we are setup to broadcast on the default channel, ensure that the telemetry intervals are coerced to the minimum value
+ // of 30 minutes or more
+ if (channels.isDefaultChannel(channels.getPrimaryIndex())) {
+ LOG_DEBUG("Coercing telemetry to min of 30 minutes on defaults");
+ moduleConfig.telemetry.device_update_interval = Default::getConfiguredOrMinimumValue(
+ moduleConfig.telemetry.device_update_interval, min_default_telemetry_interval_secs);
+ moduleConfig.telemetry.environment_update_interval = Default::getConfiguredOrMinimumValue(
+ moduleConfig.telemetry.environment_update_interval, min_default_telemetry_interval_secs);
+ moduleConfig.telemetry.air_quality_interval = Default::getConfiguredOrMinimumValue(
+ moduleConfig.telemetry.air_quality_interval, min_default_telemetry_interval_secs);
+ moduleConfig.telemetry.power_update_interval = Default::getConfiguredOrMinimumValue(
+ moduleConfig.telemetry.power_update_interval, min_default_telemetry_interval_secs);
+ moduleConfig.telemetry.health_update_interval = Default::getConfiguredOrMinimumValue(
+ moduleConfig.telemetry.health_update_interval, min_default_telemetry_interval_secs);
+ }
if (devicestateCRC != crc32Buffer(&devicestate, sizeof(devicestate)))
saveWhat |= SEGMENT_DEVICESTATE;
@@ -208,6 +264,11 @@ bool isToUs(const meshtastic_MeshPacket *p)
return p->to == nodeDB->getNodeNum();
}
+bool isBroadcast(uint32_t dest)
+{
+ return dest == NODENUM_BROADCAST || dest == NODENUM_BROADCAST_NO_LORA;
+}
+
bool NodeDB::resetRadioConfig(bool factory_reset)
{
bool didFactoryReset = false;
@@ -219,7 +280,7 @@ bool NodeDB::resetRadioConfig(bool factory_reset)
}
if (channelFile.channels_count != MAX_NUM_CHANNELS) {
- LOG_INFO("Setting default channel and radio preferences!\n");
+ LOG_INFO("Setting default channel and radio preferences!");
channels.initDefaults();
}
@@ -240,12 +301,12 @@ bool NodeDB::resetRadioConfig(bool factory_reset)
bool NodeDB::factoryReset(bool eraseBleBonds)
{
- LOG_INFO("Performing factory reset!\n");
+ LOG_INFO("Performing factory reset!");
// first, remove the "/prefs" (this removes most prefs)
rmDir("/prefs");
#ifdef FSCom
if (FSCom.exists("/static/rangetest.csv") && !FSCom.remove("/static/rangetest.csv")) {
- LOG_ERROR("Could not remove rangetest.csv file\n");
+ LOG_ERROR("Could not remove rangetest.csv file");
}
#endif
// second, install default state (this will deal with the duplicate mac address issue)
@@ -256,14 +317,14 @@ bool NodeDB::factoryReset(bool eraseBleBonds)
// third, write everything to disk
saveToDisk();
if (eraseBleBonds) {
- LOG_INFO("Erasing BLE bonds\n");
+ LOG_INFO("Erasing BLE bonds");
#ifdef ARCH_ESP32
// This will erase what's in NVS including ssl keys, persistent variables and ble pairing
nvs_flash_erase();
#endif
#ifdef ARCH_NRF52
Bluefruit.begin();
- LOG_INFO("Clearing bluetooth bonds!\n");
+ LOG_INFO("Clearing bluetooth bonds!");
bond_print_list(BLE_GAP_ROLE_PERIPH);
bond_print_list(BLE_GAP_ROLE_CENTRAL);
Bluefruit.Periph.clearBonds();
@@ -280,7 +341,7 @@ void NodeDB::installDefaultConfig(bool preserveKey = false)
if (shouldPreserveKey) {
memcpy(private_key_temp, config.security.private_key.bytes, config.security.private_key.size);
}
- LOG_INFO("Installing default LocalConfig\n");
+ LOG_INFO("Installing default LocalConfig");
memset(&config, 0, sizeof(meshtastic_LocalConfig));
config.version = DEVICESTATE_CUR_VER;
config.has_device = true;
@@ -418,7 +479,7 @@ void NodeDB::initConfigIntervals()
void NodeDB::installDefaultModuleConfig()
{
- LOG_INFO("Installing default ModuleConfig\n");
+ LOG_INFO("Installing default ModuleConfig");
memset(&moduleConfig, 0, sizeof(meshtastic_ModuleConfig));
moduleConfig.version = DEVICESTATE_CUR_VER;
@@ -533,6 +594,7 @@ void NodeDB::installRoleDefaults(meshtastic_Config_DeviceConfig_Role role)
moduleConfig.telemetry.device_update_interval = UINT32_MAX;
moduleConfig.telemetry.environment_update_interval = UINT32_MAX;
moduleConfig.telemetry.air_quality_interval = UINT32_MAX;
+ moduleConfig.telemetry.health_update_interval = UINT32_MAX;
}
}
@@ -543,22 +605,26 @@ void NodeDB::initModuleConfigIntervals()
moduleConfig.telemetry.environment_update_interval = 0;
moduleConfig.telemetry.air_quality_interval = 0;
moduleConfig.telemetry.power_update_interval = 0;
+ moduleConfig.telemetry.health_update_interval = 0;
moduleConfig.neighbor_info.update_interval = 0;
moduleConfig.paxcounter.paxcounter_update_interval = 0;
}
void NodeDB::installDefaultChannels()
{
- LOG_INFO("Installing default ChannelFile\n");
+ LOG_INFO("Installing default ChannelFile");
memset(&channelFile, 0, sizeof(meshtastic_ChannelFile));
channelFile.version = DEVICESTATE_CUR_VER;
}
void NodeDB::resetNodes()
{
- clearLocalPosition();
+ if (!config.position.fixed_position)
+ clearLocalPosition();
numMeshNodes = 1;
std::fill(devicestate.node_db_lite.begin() + 1, devicestate.node_db_lite.end(), meshtastic_NodeInfoLite());
+ devicestate.has_rx_text_message = false;
+ devicestate.has_rx_waypoint = false;
saveDeviceStateToDisk();
if (neighborInfoModule && moduleConfig.neighbor_info.enabled)
neighborInfoModule->resetNeighbors();
@@ -576,7 +642,7 @@ void NodeDB::removeNodeByNum(NodeNum nodeNum)
numMeshNodes -= removed;
std::fill(devicestate.node_db_lite.begin() + numMeshNodes, devicestate.node_db_lite.begin() + numMeshNodes + 1,
meshtastic_NodeInfoLite());
- LOG_DEBUG("NodeDB::removeNodeByNum purged %d entries. Saving changes...\n", removed);
+ LOG_DEBUG("NodeDB::removeNodeByNum purged %d entries. Saving changes...", removed);
saveDeviceStateToDisk();
}
@@ -608,12 +674,12 @@ void NodeDB::cleanupMeshDB()
numMeshNodes -= removed;
std::fill(devicestate.node_db_lite.begin() + numMeshNodes, devicestate.node_db_lite.begin() + numMeshNodes + removed,
meshtastic_NodeInfoLite());
- LOG_DEBUG("cleanupMeshDB purged %d entries\n", removed);
+ LOG_DEBUG("cleanupMeshDB purged %d entries", removed);
}
void NodeDB::installDefaultDeviceState()
{
- LOG_INFO("Installing default DeviceState\n");
+ LOG_INFO("Installing default DeviceState");
// memset(&devicestate, 0, sizeof(meshtastic_DeviceState));
numMeshNodes = 0;
@@ -667,11 +733,11 @@ void NodeDB::pickNewNodeNum()
NodeNum candidate = random(NUM_RESERVED, LONG_MAX); // try a new random choice
if (found)
LOG_WARN("NOTE! Our desired nodenum 0x%x is invalid or in use, by MAC ending in 0x%02x%02x vs our 0x%02x%02x, so "
- "trying for 0x%x\n",
+ "trying for 0x%x",
nodeNum, found->user.macaddr[4], found->user.macaddr[5], ourMacAddr[4], ourMacAddr[5], candidate);
nodeNum = candidate;
}
- LOG_DEBUG("Using nodenum 0x%x \n", nodeNum);
+ LOG_DEBUG("Using nodenum 0x%x ", nodeNum);
myNodeInfo.my_node_num = nodeNum;
}
@@ -680,7 +746,6 @@ static const char *prefFileName = "/prefs/db.proto";
static const char *configFileName = "/prefs/config.proto";
static const char *moduleConfigFileName = "/prefs/module.proto";
static const char *channelFileName = "/prefs/channels.proto";
-static const char *oemConfigFile = "/oem/oem.proto";
/** Load a protobuf from a file, return LoadFileResult */
LoadFileResult NodeDB::loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields,
@@ -692,23 +757,23 @@ LoadFileResult NodeDB::loadProto(const char *filename, size_t protoSize, size_t
auto f = FSCom.open(filename, FILE_O_READ);
if (f) {
- LOG_INFO("Loading %s\n", filename);
+ LOG_INFO("Loading %s", filename);
pb_istream_t stream = {&readcb, &f, protoSize};
memset(dest_struct, 0, objSize);
if (!pb_decode(&stream, fields, dest_struct)) {
- LOG_ERROR("Error: can't decode protobuf %s\n", PB_GET_ERROR(&stream));
+ LOG_ERROR("Error: can't decode protobuf %s", PB_GET_ERROR(&stream));
state = LoadFileResult::DECODE_FAILED;
} else {
- LOG_INFO("Loaded %s successfully\n", filename);
+ LOG_INFO("Loaded %s successfully", filename);
state = LoadFileResult::LOAD_SUCCESS;
}
f.close();
} else {
- LOG_ERROR("Could not open / read %s\n", filename);
+ LOG_ERROR("Could not open / read %s", filename);
}
#else
- LOG_ERROR("ERROR: Filesystem not implemented\n");
+ LOG_ERROR("ERROR: Filesystem not implemented");
state = LoadFileResult::NO_FILESYSTEM;
#endif
return state;
@@ -733,11 +798,10 @@ void NodeDB::loadFromDisk()
// installDefaultDeviceState(); // Our in RAM copy might now be corrupt
//} else {
if (devicestate.version < DEVICESTATE_MIN_VER) {
- LOG_WARN("Devicestate %d is old, discarding\n", devicestate.version);
+ LOG_WARN("Devicestate %d is old, discarding", devicestate.version);
installDefaultDeviceState();
} else {
- LOG_INFO("Loaded saved devicestate version %d, with nodecount: %d\n", devicestate.version,
- devicestate.node_db_lite.size());
+ LOG_INFO("Loaded saved devicestate version %d, with nodecount: %d", devicestate.version, devicestate.node_db_lite.size());
meshNodes = &devicestate.node_db_lite;
numMeshNodes = devicestate.node_db_lite.size();
}
@@ -749,10 +813,10 @@ void NodeDB::loadFromDisk()
installDefaultConfig(); // Our in RAM copy might now be corrupt
} else {
if (config.version < DEVICESTATE_MIN_VER) {
- LOG_WARN("config %d is old, discarding\n", config.version);
+ LOG_WARN("config %d is old, discarding", config.version);
installDefaultConfig(true);
} else {
- LOG_INFO("Loaded saved config version %d\n", config.version);
+ LOG_INFO("Loaded saved config version %d", config.version);
}
}
@@ -762,10 +826,10 @@ void NodeDB::loadFromDisk()
installDefaultModuleConfig(); // Our in RAM copy might now be corrupt
} else {
if (moduleConfig.version < DEVICESTATE_MIN_VER) {
- LOG_WARN("moduleConfig %d is old, discarding\n", moduleConfig.version);
+ LOG_WARN("moduleConfig %d is old, discarding", moduleConfig.version);
installDefaultModuleConfig();
} else {
- LOG_INFO("Loaded saved moduleConfig version %d\n", moduleConfig.version);
+ LOG_INFO("Loaded saved moduleConfig version %d", moduleConfig.version);
}
}
@@ -775,22 +839,16 @@ void NodeDB::loadFromDisk()
installDefaultChannels(); // Our in RAM copy might now be corrupt
} else {
if (channelFile.version < DEVICESTATE_MIN_VER) {
- LOG_WARN("channelFile %d is old, discarding\n", channelFile.version);
+ LOG_WARN("channelFile %d is old, discarding", channelFile.version);
installDefaultChannels();
} else {
- LOG_INFO("Loaded saved channelFile version %d\n", channelFile.version);
+ LOG_INFO("Loaded saved channelFile version %d", channelFile.version);
}
}
- state = loadProto(oemConfigFile, meshtastic_OEMStore_size, sizeof(meshtastic_OEMStore), &meshtastic_OEMStore_msg, &oemStore);
- if (state == LoadFileResult::LOAD_SUCCESS) {
- LOG_INFO("Loaded OEMStore\n");
- hasOemStore = true;
- }
-
// 2.4.X - configuration migration to update new default intervals
if (moduleConfig.version < 23) {
- LOG_DEBUG("ModuleConfig version %d is stale, upgrading to new default intervals\n", moduleConfig.version);
+ LOG_DEBUG("ModuleConfig version %d is stale, upgrading to new default intervals", moduleConfig.version);
moduleConfig.version = DEVICESTATE_CUR_VER;
if (moduleConfig.telemetry.device_update_interval == 900)
moduleConfig.telemetry.device_update_interval = 0;
@@ -813,15 +871,18 @@ void NodeDB::loadFromDisk()
bool NodeDB::saveProto(const char *filename, size_t protoSize, const pb_msgdesc_t *fields, const void *dest_struct,
bool fullAtomic)
{
+#ifdef ARCH_ESP32
+ concurrency::LockGuard g(spiLock);
+#endif
bool okay = false;
#ifdef FSCom
auto f = SafeFile(filename, fullAtomic);
- LOG_INFO("Saving %s\n", filename);
+ LOG_INFO("Saving %s", filename);
pb_ostream_t stream = {&writecb, static_cast(&f), protoSize};
if (!pb_encode(&stream, fields, dest_struct)) {
- LOG_ERROR("Error: can't encode protobuf %s\n", PB_GET_ERROR(&stream));
+ LOG_ERROR("Error: can't encode protobuf %s", PB_GET_ERROR(&stream));
} else {
okay = true;
}
@@ -829,10 +890,10 @@ bool NodeDB::saveProto(const char *filename, size_t protoSize, const pb_msgdesc_
bool writeSucceeded = f.close();
if (!okay || !writeSucceeded) {
- LOG_ERROR("Can't write prefs!\n");
+ LOG_ERROR("Can't write prefs!");
}
#else
- LOG_ERROR("ERROR: Filesystem not implemented\n");
+ LOG_ERROR("ERROR: Filesystem not implemented");
#endif
return okay;
}
@@ -894,11 +955,6 @@ bool NodeDB::saveToDiskNoRetry(int saveWhat)
saveProto(moduleConfigFileName, meshtastic_LocalModuleConfig_size, &meshtastic_LocalModuleConfig_msg, &moduleConfig);
}
- // We might need to rewrite the OEM data if we are reformatting the FS
- if ((saveWhat & SEGMENT_OEM) && hasOemStore) {
- success &= saveProto(oemConfigFile, meshtastic_OEMStore_size, &meshtastic_OEMStore_msg, &oemStore);
- }
-
if (saveWhat & SEGMENT_CHANNELS) {
success &= saveChannelsToDisk();
}
@@ -915,12 +971,10 @@ bool NodeDB::saveToDisk(int saveWhat)
bool success = saveToDiskNoRetry(saveWhat);
if (!success) {
- LOG_ERROR("Failed to save to disk, retrying...\n");
+ LOG_ERROR("Failed to save to disk, retrying...");
#ifdef ARCH_NRF52 // @geeksville is not ready yet to say we should do this on other platforms. See bug #4184 discussion
FSCom.format();
- // We need to rewrite the OEM data if we are reformatting the FS
- saveWhat |= SEGMENT_OEM;
#endif
success = saveToDiskNoRetry(saveWhat);
@@ -993,7 +1047,7 @@ void NodeDB::updatePosition(uint32_t nodeId, const meshtastic_Position &p, RxSou
if (src == RX_SRC_LOCAL) {
// Local packet, fully authoritative
- LOG_INFO("updatePosition LOCAL pos@%x time=%u lat=%d lon=%d alt=%d\n", p.timestamp, p.time, p.latitude_i, p.longitude_i,
+ LOG_INFO("updatePosition LOCAL pos@%x time=%u lat=%d lon=%d alt=%d", p.timestamp, p.time, p.latitude_i, p.longitude_i,
p.altitude);
setLocalPosition(p);
@@ -1001,7 +1055,7 @@ void NodeDB::updatePosition(uint32_t nodeId, const meshtastic_Position &p, RxSou
} else if ((p.time > 0) && !p.latitude_i && !p.longitude_i && !p.timestamp && !p.location_source) {
// FIXME SPECIAL TIME SETTING PACKET FROM EUD TO RADIO
// (stop-gap fix for issue #900)
- LOG_DEBUG("updatePosition SPECIAL time setting time=%u\n", p.time);
+ LOG_DEBUG("updatePosition SPECIAL time setting time=%u", p.time);
info->position.time = p.time;
} else {
// Be careful to only update fields that have been set by the REMOTE sender
@@ -1009,7 +1063,7 @@ void NodeDB::updatePosition(uint32_t nodeId, const meshtastic_Position &p, RxSou
// recorded based on the packet rxTime
//
// FIXME perhaps handle RX_SRC_USER separately?
- LOG_INFO("updatePosition REMOTE node=0x%x time=%u lat=%d lon=%d\n", nodeId, p.time, p.latitude_i, p.longitude_i);
+ LOG_INFO("updatePosition REMOTE node=0x%x time=%u lat=%d lon=%d", nodeId, p.time, p.latitude_i, p.longitude_i);
// First, back up fields that we want to protect from overwrite
uint32_t tmp_time = info->position.time;
@@ -1039,9 +1093,9 @@ void NodeDB::updateTelemetry(uint32_t nodeId, const meshtastic_Telemetry &t, RxS
if (src == RX_SRC_LOCAL) {
// Local packet, fully authoritative
- LOG_DEBUG("updateTelemetry LOCAL\n");
+ LOG_DEBUG("updateTelemetry LOCAL");
} else {
- LOG_DEBUG("updateTelemetry REMOTE node=0x%x \n", nodeId);
+ LOG_DEBUG("updateTelemetry REMOTE node=0x%x ", nodeId);
}
info->device_metrics = t.variant.device_metrics;
info->has_device_metrics = true;
@@ -1058,16 +1112,16 @@ bool NodeDB::updateUser(uint32_t nodeId, meshtastic_User &p, uint8_t channelInde
return false;
}
- LOG_DEBUG("old user %s/%s, channel=%d\n", info->user.long_name, info->user.short_name, info->channel);
+ LOG_DEBUG("old user %s/%s, channel=%d", info->user.long_name, info->user.short_name, info->channel);
#if !(MESHTASTIC_EXCLUDE_PKI)
if (p.public_key.size > 0) {
printBytes("Incoming Pubkey: ", p.public_key.bytes, 32);
if (info->user.public_key.size > 0) { // if we have a key for this user already, don't overwrite with a new one
- LOG_INFO("Public Key set for node, not updating!\n");
+ LOG_INFO("Public Key set for node, not updating!");
// we copy the key into the incoming packet, to prevent overwrite
memcpy(p.public_key.bytes, info->user.public_key.bytes, 32);
} else {
- LOG_INFO("Updating Node Pubkey!\n");
+ LOG_INFO("Updating Node Pubkey!");
}
}
#endif
@@ -1082,8 +1136,7 @@ bool NodeDB::updateUser(uint32_t nodeId, meshtastic_User &p, uint8_t channelInde
}
if (nodeId != getNodeNum())
info->channel = channelIndex; // Set channel we need to use to reach this node (but don't set our own channel)
- LOG_DEBUG("updating changed=%d user %s/%s, channel=%d\n", changed, info->user.long_name, info->user.short_name,
- info->channel);
+ LOG_DEBUG("updating changed=%d user %s/%s, channel=%d", changed, info->user.long_name, info->user.short_name, info->channel);
info->has_user = true;
if (changed) {
@@ -1094,7 +1147,7 @@ bool NodeDB::updateUser(uint32_t nodeId, meshtastic_User &p, uint8_t channelInde
// We just changed something about the user, store our DB
Throttle::execute(
&lastNodeDbSave, ONE_MINUTE_MS, []() { nodeDB->saveToDisk(SEGMENT_DEVICESTATE); },
- []() { LOG_DEBUG("Deferring NodeDB saveToDisk for now\n"); }); // since we saved less than a minute ago
+ []() { LOG_DEBUG("Deferring NodeDB saveToDisk for now"); }); // since we saved less than a minute ago
}
return changed;
@@ -1105,7 +1158,7 @@ bool NodeDB::updateUser(uint32_t nodeId, meshtastic_User &p, uint8_t channelInde
void NodeDB::updateFrom(const meshtastic_MeshPacket &mp)
{
if (mp.which_payload_variant == meshtastic_MeshPacket_decoded_tag && mp.from) {
- LOG_DEBUG("Update DB node 0x%x, rx_time=%u\n", mp.from, mp.rx_time);
+ LOG_DEBUG("Update DB node 0x%x, rx_time=%u", mp.from, mp.rx_time);
meshtastic_NodeInfoLite *info = getOrCreateMeshNode(getFrom(&mp));
if (!info) {
@@ -1157,7 +1210,7 @@ meshtastic_NodeInfoLite *NodeDB::getOrCreateMeshNode(NodeNum n)
if ((numMeshNodes >= MAX_NUM_NODES) || (memGet.getFreeHeap() < MINIMUM_SAFE_FREE_HEAP)) {
if (screen)
screen->print("Warn: node database full!\nErasing oldest entry\n");
- LOG_WARN("Node database full with %i nodes and %i bytes free! Erasing oldest entry\n", numMeshNodes,
+ LOG_WARN("Node database full with %i nodes and %i bytes free! Erasing oldest entry", numMeshNodes,
memGet.getFreeHeap());
// look for oldest node and erase it
uint32_t oldest = UINT32_MAX;
@@ -1193,7 +1246,7 @@ meshtastic_NodeInfoLite *NodeDB::getOrCreateMeshNode(NodeNum n)
// everything is missing except the nodenum
memset(lite, 0, sizeof(*lite));
lite->num = n;
- LOG_INFO("Adding node to database with %i nodes and %i bytes free!\n", numMeshNodes, memGet.getFreeHeap());
+ LOG_INFO("Adding node to database with %i nodes and %i bytes free!", numMeshNodes, memGet.getFreeHeap());
}
return lite;
@@ -1204,11 +1257,12 @@ void recordCriticalError(meshtastic_CriticalErrorCode code, uint32_t address, co
{
// Print error to screen and serial port
String lcd = String("Critical error ") + code + "!\n";
- screen->print(lcd.c_str());
+ if (screen)
+ screen->print(lcd.c_str());
if (filename) {
- LOG_ERROR("NOTE! Recording critical error %d at %s:%lu\n", code, filename, address);
+ LOG_ERROR("NOTE! Recording critical error %d at %s:%lu", code, filename, address);
} else {
- LOG_ERROR("NOTE! Recording critical error %d, address=0x%lx\n", code, address);
+ LOG_ERROR("NOTE! Recording critical error %d, address=0x%lx", code, address);
}
// Record error to DB
diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h
index 1be61759a1..eb33a2f6d4 100644
--- a/src/mesh/NodeDB.h
+++ b/src/mesh/NodeDB.h
@@ -21,7 +21,6 @@ DeviceState versions used to be defined in the .proto file but really only this
#define SEGMENT_MODULECONFIG 2
#define SEGMENT_DEVICESTATE 4
#define SEGMENT_CHANNELS 8
-#define SEGMENT_OEM 16
#define DEVICESTATE_CUR_VER 23
#define DEVICESTATE_MIN_VER 22
@@ -31,7 +30,6 @@ extern meshtastic_ChannelFile channelFile;
extern meshtastic_MyNodeInfo &myNodeInfo;
extern meshtastic_LocalConfig config;
extern meshtastic_LocalModuleConfig moduleConfig;
-extern meshtastic_OEMStore oemStore;
extern meshtastic_User &owner;
extern meshtastic_Position localPosition;
@@ -154,12 +152,12 @@ class NodeDB
void setLocalPosition(meshtastic_Position position, bool timeOnly = false)
{
if (timeOnly) {
- LOG_DEBUG("Setting local position time only: time=%u timestamp=%u\n", position.time, position.timestamp);
+ LOG_DEBUG("Setting local position time only: time=%u timestamp=%u", position.time, position.timestamp);
localPosition.time = position.time;
localPosition.timestamp = position.timestamp > 0 ? position.timestamp : position.time;
return;
}
- LOG_DEBUG("Setting local position: lat=%i lon=%i time=%u timestamp=%u\n", position.latitude_i, position.longitude_i,
+ LOG_DEBUG("Setting local position: lat=%i lon=%i time=%u timestamp=%u", position.latitude_i, position.longitude_i,
position.time, position.timestamp);
localPosition = position;
}
diff --git a/src/mesh/PacketHistory.cpp b/src/mesh/PacketHistory.cpp
index ed1c3c59c8..8d49bce43f 100644
--- a/src/mesh/PacketHistory.cpp
+++ b/src/mesh/PacketHistory.cpp
@@ -19,7 +19,7 @@ PacketHistory::PacketHistory()
bool PacketHistory::wasSeenRecently(const meshtastic_MeshPacket *p, bool withUpdate)
{
if (p->id == 0) {
- LOG_DEBUG("Ignoring message with zero id\n");
+ LOG_DEBUG("Ignoring message with zero id");
return false; // Not a floodable message ID, so we don't care
}
@@ -39,7 +39,7 @@ bool PacketHistory::wasSeenRecently(const meshtastic_MeshPacket *p, bool withUpd
}
if (seenRecently) {
- LOG_DEBUG("Found existing packet record for fr=0x%x,to=0x%x,id=0x%x\n", p->from, p->to, p->id);
+ LOG_DEBUG("Found existing packet record for fr=0x%x,to=0x%x,id=0x%x", p->from, p->to, p->id);
}
if (withUpdate) {
@@ -64,7 +64,7 @@ bool PacketHistory::wasSeenRecently(const meshtastic_MeshPacket *p, bool withUpd
*/
void PacketHistory::clearExpiredRecentPackets()
{
- LOG_DEBUG("recentPackets size=%ld\n", recentPackets.size());
+ LOG_DEBUG("recentPackets size=%ld", recentPackets.size());
for (auto it = recentPackets.begin(); it != recentPackets.end();) {
if (!Throttle::isWithinTimespanMs(it->rxTimeMsec, FLOOD_EXPIRE_TIME)) {
@@ -74,5 +74,5 @@ void PacketHistory::clearExpiredRecentPackets()
}
}
- LOG_DEBUG("recentPackets size=%ld (after clearing expired packets)\n", recentPackets.size());
+ LOG_DEBUG("recentPackets size=%ld (after clearing expired packets)", recentPackets.size());
}
\ No newline at end of file
diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp
index ad4a1f33db..98db38c47b 100644
--- a/src/mesh/PhoneAPI.cpp
+++ b/src/mesh/PhoneAPI.cpp
@@ -55,16 +55,16 @@ void PhoneAPI::handleStartConfig()
state = STATE_SEND_MY_INFO;
pauseBluetoothLogging = true;
filesManifest = getFiles("/", 10);
- LOG_DEBUG("Got %d files in manifest\n", filesManifest.size());
+ LOG_DEBUG("Got %d files in manifest", filesManifest.size());
- LOG_INFO("Starting API client config\n");
+ LOG_INFO("Starting API client config");
nodeInfoForPhone.num = 0; // Don't keep returning old nodeinfos
resetReadIndex();
}
void PhoneAPI::close()
{
- LOG_INFO("PhoneAPI::close()\n");
+ LOG_INFO("PhoneAPI::close()");
if (state != STATE_SEND_NOTHING) {
state = STATE_SEND_NOTHING;
@@ -95,7 +95,7 @@ bool PhoneAPI::checkConnectionTimeout()
if (isConnected()) {
bool newContact = checkIsConnected();
if (!newContact) {
- LOG_INFO("Lost phone connection\n");
+ LOG_INFO("Lost phone connection");
close();
return true;
}
@@ -118,41 +118,41 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
return handleToRadioPacket(toRadioScratch.packet);
case meshtastic_ToRadio_want_config_id_tag:
config_nonce = toRadioScratch.want_config_id;
- LOG_INFO("Client wants config, nonce=%u\n", config_nonce);
+ LOG_INFO("Client wants config, nonce=%u", config_nonce);
handleStartConfig();
break;
case meshtastic_ToRadio_disconnect_tag:
- LOG_INFO("Disconnecting from phone\n");
+ LOG_INFO("Disconnecting from phone");
close();
break;
case meshtastic_ToRadio_xmodemPacket_tag:
- LOG_INFO("Got xmodem packet\n");
+ LOG_INFO("Got xmodem packet");
#ifdef FSCom
xModem.handlePacket(toRadioScratch.xmodemPacket);
#endif
break;
#if !MESHTASTIC_EXCLUDE_MQTT
case meshtastic_ToRadio_mqttClientProxyMessage_tag:
- LOG_INFO("Got MqttClientProxy message\n");
+ LOG_INFO("Got MqttClientProxy message");
if (mqtt && moduleConfig.mqtt.proxy_to_client_enabled && moduleConfig.mqtt.enabled &&
(channels.anyMqttEnabled() || moduleConfig.mqtt.map_reporting_enabled)) {
mqtt->onClientProxyReceive(toRadioScratch.mqttClientProxyMessage);
} else {
LOG_WARN("MqttClientProxy received but proxy is not enabled, no channels have up/downlink, or map reporting "
- "not enabled\n");
+ "not enabled");
}
break;
#endif
case meshtastic_ToRadio_heartbeat_tag:
- LOG_DEBUG("Got client heartbeat\n");
+ LOG_DEBUG("Got client heartbeat");
break;
default:
// Ignore nop messages
- // LOG_DEBUG("Error: unexpected ToRadio variant\n");
+ // LOG_DEBUG("Error: unexpected ToRadio variant");
break;
}
} else {
- LOG_ERROR("Error: ignoring malformed toradio\n");
+ LOG_ERROR("Error: ignoring malformed toradio");
}
return false;
@@ -179,7 +179,7 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
size_t PhoneAPI::getFromRadio(uint8_t *buf)
{
if (!available()) {
- // LOG_DEBUG("getFromRadio=not available\n");
+ // LOG_DEBUG("getFromRadio=not available");
return 0;
}
// In case we send a FromRadio packet
@@ -188,11 +188,11 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
// Advance states as needed
switch (state) {
case STATE_SEND_NOTHING:
- LOG_INFO("getFromRadio=STATE_SEND_NOTHING\n");
+ LOG_INFO("getFromRadio=STATE_SEND_NOTHING");
break;
case STATE_SEND_MY_INFO:
- LOG_INFO("getFromRadio=STATE_SEND_MY_INFO\n");
+ LOG_INFO("getFromRadio=STATE_SEND_MY_INFO");
// If the user has specified they don't want our node to share its location, make sure to tell the phone
// app not to send locations on our behalf.
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_my_info_tag;
@@ -203,7 +203,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
break;
case STATE_SEND_OWN_NODEINFO: {
- LOG_INFO("getFromRadio=STATE_SEND_OWN_NODEINFO\n");
+ LOG_INFO("getFromRadio=STATE_SEND_OWN_NODEINFO");
auto us = nodeDB->readNextMeshNode(readIndex);
if (us) {
nodeInfoForPhone = TypeConversions::ConvertToNodeInfo(us);
@@ -219,14 +219,14 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
}
case STATE_SEND_METADATA:
- LOG_INFO("getFromRadio=STATE_SEND_METADATA\n");
+ LOG_INFO("getFromRadio=STATE_SEND_METADATA");
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_metadata_tag;
fromRadioScratch.metadata = getDeviceMetadata();
state = STATE_SEND_CHANNELS;
break;
case STATE_SEND_CHANNELS:
- LOG_INFO("getFromRadio=STATE_SEND_CHANNELS\n");
+ LOG_INFO("getFromRadio=STATE_SEND_CHANNELS");
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_channel_tag;
fromRadioScratch.channel = channels.getByIndex(config_state);
config_state++;
@@ -238,7 +238,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
break;
case STATE_SEND_CONFIG:
- LOG_INFO("getFromRadio=STATE_SEND_CONFIG\n");
+ LOG_INFO("getFromRadio=STATE_SEND_CONFIG");
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_config_tag;
switch (config_state) {
case meshtastic_Config_device_tag:
@@ -278,7 +278,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
fromRadioScratch.config.which_payload_variant = meshtastic_Config_sessionkey_tag;
break;
default:
- LOG_ERROR("Unknown config type %d\n", config_state);
+ LOG_ERROR("Unknown config type %d", config_state);
}
// NOTE: The phone app needs to know the ls_secs value so it can properly expect sleep behavior.
// So even if we internally use 0 to represent 'use default' we still need to send the value we are
@@ -293,7 +293,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
break;
case STATE_SEND_MODULECONFIG:
- LOG_INFO("getFromRadio=STATE_SEND_MODULECONFIG\n");
+ LOG_INFO("getFromRadio=STATE_SEND_MODULECONFIG");
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_moduleConfig_tag;
switch (config_state) {
case meshtastic_ModuleConfig_mqtt_tag:
@@ -349,7 +349,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
fromRadioScratch.moduleConfig.payload_variant.paxcounter = moduleConfig.paxcounter;
break;
default:
- LOG_ERROR("Unknown module config type %d\n", config_state);
+ LOG_ERROR("Unknown module config type %d", config_state);
}
config_state++;
@@ -362,16 +362,16 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
break;
case STATE_SEND_OTHER_NODEINFOS: {
- LOG_INFO("getFromRadio=STATE_SEND_OTHER_NODEINFOS\n");
+ LOG_INFO("getFromRadio=STATE_SEND_OTHER_NODEINFOS");
if (nodeInfoForPhone.num != 0) {
- LOG_INFO("nodeinfo: num=0x%x, lastseen=%u, id=%s, name=%s\n", nodeInfoForPhone.num, nodeInfoForPhone.last_heard,
+ LOG_INFO("nodeinfo: num=0x%x, lastseen=%u, id=%s, name=%s", nodeInfoForPhone.num, nodeInfoForPhone.last_heard,
nodeInfoForPhone.user.id, nodeInfoForPhone.user.long_name);
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_node_info_tag;
fromRadioScratch.node_info = nodeInfoForPhone;
// Stay in current state until done sending nodeinfos
nodeInfoForPhone.num = 0; // We just consumed a nodeinfo, will need a new one next time
} else {
- LOG_INFO("Done sending nodeinfos\n");
+ LOG_INFO("Done sending nodeinfos");
state = STATE_SEND_FILEMANIFEST;
// Go ahead and send that ID right now
return getFromRadio(buf);
@@ -380,7 +380,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
}
case STATE_SEND_FILEMANIFEST: {
- LOG_INFO("getFromRadio=STATE_SEND_FILEMANIFEST\n");
+ LOG_INFO("getFromRadio=STATE_SEND_FILEMANIFEST");
// last element
if (config_state == filesManifest.size()) { // also handles an empty filesManifest
config_state = 0;
@@ -390,7 +390,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
} else {
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_fileInfo_tag;
fromRadioScratch.fileInfo = filesManifest.at(config_state);
- LOG_DEBUG("File: %s (%d) bytes\n", fromRadioScratch.fileInfo.file_name, fromRadioScratch.fileInfo.size_bytes);
+ LOG_DEBUG("File: %s (%d) bytes", fromRadioScratch.fileInfo.file_name, fromRadioScratch.fileInfo.size_bytes);
config_state++;
}
break;
@@ -403,7 +403,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
case STATE_SEND_PACKETS:
pauseBluetoothLogging = false;
// Do we have a message from the mesh or packet from the local device?
- LOG_INFO("getFromRadio=STATE_SEND_PACKETS\n");
+ LOG_INFO("getFromRadio=STATE_SEND_PACKETS");
if (queueStatusPacketForPhone) {
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_queueStatus_tag;
fromRadioScratch.queueStatus = *queueStatusPacketForPhone;
@@ -431,7 +431,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
break;
default:
- LOG_ERROR("getFromRadio unexpected state %d\n", state);
+ LOG_ERROR("getFromRadio unexpected state %d", state);
}
// Do we have a message from the mesh?
@@ -441,17 +441,17 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
// VERY IMPORTANT to not print debug messages while writing to fromRadioScratch - because we use that same buffer
// for logging (when we are encapsulating with protobufs)
- // LOG_DEBUG("encoding toPhone packet to phone variant=%d, %d bytes\n", fromRadioScratch.which_payload_variant, numbytes);
+ // LOG_DEBUG("encoding toPhone packet to phone variant=%d, %d bytes", fromRadioScratch.which_payload_variant, numbytes);
return numbytes;
}
- LOG_DEBUG("no FromRadio packet available\n");
+ LOG_DEBUG("no FromRadio packet available");
return 0;
}
void PhoneAPI::sendConfigComplete()
{
- LOG_INFO("getFromRadio=STATE_SEND_COMPLETE_ID\n");
+ LOG_INFO("getFromRadio=STATE_SEND_COMPLETE_ID");
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_config_complete_id_tag;
fromRadioScratch.config_complete_id = config_nonce;
config_nonce = 0;
@@ -551,11 +551,11 @@ bool PhoneAPI::available()
if (!packetForPhone)
packetForPhone = service->getForPhone();
hasPacket = !!packetForPhone;
- // LOG_DEBUG("available hasPacket=%d\n", hasPacket);
+ // LOG_DEBUG("available hasPacket=%d", hasPacket);
return hasPacket;
}
default:
- LOG_ERROR("PhoneAPI::available unexpected state %d\n", state);
+ LOG_ERROR("PhoneAPI::available unexpected state %d", state);
}
return false;
@@ -597,20 +597,20 @@ bool PhoneAPI::handleToRadioPacket(meshtastic_MeshPacket &p)
printPacket("PACKET FROM PHONE", &p);
if (p.id > 0 && wasSeenRecently(p.id)) {
- LOG_DEBUG("Ignoring packet from phone, already seen recently\n");
+ LOG_DEBUG("Ignoring packet from phone, already seen recently");
return false;
}
if (p.decoded.portnum == meshtastic_PortNum_TRACEROUTE_APP && lastPortNumToRadio[p.decoded.portnum] &&
Throttle::isWithinTimespanMs(lastPortNumToRadio[p.decoded.portnum], THIRTY_SECONDS_MS)) {
- LOG_WARN("Rate limiting portnum %d\n", p.decoded.portnum);
+ LOG_WARN("Rate limiting portnum %d", p.decoded.portnum);
sendNotification(meshtastic_LogRecord_Level_WARNING, p.id, "TraceRoute can only be sent once every 30 seconds");
meshtastic_QueueStatus qs = router->getQueueStatus();
service->sendQueueStatusToPhone(qs, 0, p.id);
return false;
} else if (p.decoded.portnum == meshtastic_PortNum_POSITION_APP && lastPortNumToRadio[p.decoded.portnum] &&
Throttle::isWithinTimespanMs(lastPortNumToRadio[p.decoded.portnum], FIVE_SECONDS_MS)) {
- LOG_WARN("Rate limiting portnum %d\n", p.decoded.portnum);
+ LOG_WARN("Rate limiting portnum %d", p.decoded.portnum);
meshtastic_QueueStatus qs = router->getQueueStatus();
service->sendQueueStatusToPhone(qs, 0, p.id);
// FIXME: Figure out why this continues to happen
@@ -629,10 +629,10 @@ int PhoneAPI::onNotify(uint32_t newValue)
// doesn't call this from idle)
if (state == STATE_SEND_PACKETS) {
- LOG_INFO("Telling client we have new packets %u\n", newValue);
+ LOG_INFO("Telling client we have new packets %u", newValue);
onNowHasData(newValue);
} else {
- LOG_DEBUG("(Client not yet interested in packets)\n");
+ LOG_DEBUG("(Client not yet interested in packets)");
}
return timeout ? -1 : 0; // If we timed out, MeshService should stop iterating through observers as we just removed one
diff --git a/src/mesh/ProtobufModule.h b/src/mesh/ProtobufModule.h
index e4d4e5c098..4ddac9a0d7 100644
--- a/src/mesh/ProtobufModule.h
+++ b/src/mesh/ProtobufModule.h
@@ -47,7 +47,7 @@ template class ProtobufModule : protected SinglePortModule
p->decoded.payload.size =
pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), fields, &payload);
- // LOG_DEBUG("did encode\n");
+ // LOG_DEBUG("did encode");
return p;
}
@@ -82,7 +82,7 @@ template class ProtobufModule : protected SinglePortModule
// it would be better to update even if the message was destined to others.
auto &p = mp.decoded;
- LOG_INFO("Received %s from=0x%0x, id=0x%x, portnum=%d, payloadlen=%d\n", name, mp.from, mp.id, p.portnum, p.payload.size);
+ LOG_INFO("Received %s from=0x%0x, id=0x%x, portnum=%d, payloadlen=%d", name, mp.from, mp.id, p.portnum, p.payload.size);
T scratch;
T *decoded = NULL;
@@ -91,7 +91,7 @@ template class ProtobufModule : protected SinglePortModule
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) {
decoded = &scratch;
} else {
- LOG_ERROR("Error decoding protobuf module!\n");
+ LOG_ERROR("Error decoding protobuf module!");
// if we can't decode it, nobody can process it!
return ProcessMessage::STOP;
}
@@ -112,7 +112,7 @@ template class ProtobufModule : protected SinglePortModule
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) {
decoded = &scratch;
} else {
- LOG_ERROR("Error decoding protobuf module!\n");
+ LOG_ERROR("Error decoding protobuf module!");
// if we can't decode it, nobody can process it!
return;
}
diff --git a/src/mesh/RF95Interface.cpp b/src/mesh/RF95Interface.cpp
index 581fd90342..db56659bd6 100644
--- a/src/mesh/RF95Interface.cpp
+++ b/src/mesh/RF95Interface.cpp
@@ -82,7 +82,7 @@ RF95Interface::RF95Interface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs, RADIO
RADIOLIB_PIN_TYPE busy)
: RadioLibInterface(hal, cs, irq, rst, busy)
{
- LOG_DEBUG("RF95Interface(cs=%d, irq=%d, rst=%d, busy=%d)\n", cs, irq, rst, busy);
+ LOG_DEBUG("RF95Interface(cs=%d, irq=%d, rst=%d, busy=%d)", cs, irq, rst, busy);
}
/** Some boards require GPIO control of tx vs rx paths */
@@ -176,12 +176,12 @@ bool RF95Interface::init()
setTransmitEnable(false);
int res = lora->begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength);
- LOG_INFO("RF95 init result %d\n", res);
- LOG_INFO("Frequency set to %f\n", getFreq());
- LOG_INFO("Bandwidth set to %f\n", bw);
- LOG_INFO("Power output set to %d\n", power);
+ LOG_INFO("RF95 init result %d", res);
+ LOG_INFO("Frequency set to %f", getFreq());
+ LOG_INFO("Bandwidth set to %f", bw);
+ LOG_INFO("Power output set to %d", power);
#if defined(RADIOMASTER_900_BANDIT_NANO) || defined(RADIOMASTER_900_BANDIT)
- LOG_INFO("DAC output set to %d\n", powerDAC);
+ LOG_INFO("DAC output set to %d", powerDAC);
#endif
if (res == RADIOLIB_ERR_NONE)
@@ -220,17 +220,17 @@ bool RF95Interface::reconfigure()
err = lora->setSyncWord(syncWord);
if (err != RADIOLIB_ERR_NONE)
- LOG_ERROR("RF95 setSyncWord %s%d\n", radioLibErr, err);
+ LOG_ERROR("RF95 setSyncWord %s%d", radioLibErr, err);
assert(err == RADIOLIB_ERR_NONE);
err = lora->setCurrentLimit(currentLimit);
if (err != RADIOLIB_ERR_NONE)
- LOG_ERROR("RF95 setCurrentLimit %s%d\n", radioLibErr, err);
+ LOG_ERROR("RF95 setCurrentLimit %s%d", radioLibErr, err);
assert(err == RADIOLIB_ERR_NONE);
err = lora->setPreambleLength(preambleLength);
if (err != RADIOLIB_ERR_NONE)
- LOG_ERROR(" RF95 setPreambleLength %s%d\n", radioLibErr, err);
+ LOG_ERROR(" RF95 setPreambleLength %s%d", radioLibErr, err);
assert(err == RADIOLIB_ERR_NONE);
err = lora->setFrequency(getFreq());
@@ -266,7 +266,7 @@ void RF95Interface::setStandby()
{
int err = lora->standby();
if (err != RADIOLIB_ERR_NONE)
- LOG_ERROR("RF95 standby %s%d\n", radioLibErr, err);
+ LOG_ERROR("RF95 standby %s%d", radioLibErr, err);
assert(err == RADIOLIB_ERR_NONE);
isReceiving = false; // If we were receiving, not any more
@@ -290,7 +290,7 @@ void RF95Interface::startReceive()
setStandby();
int err = lora->startReceive();
if (err != RADIOLIB_ERR_NONE)
- LOG_ERROR("RF95 startReceive %s%d\n", radioLibErr, err);
+ LOG_ERROR("RF95 startReceive %s%d", radioLibErr, err);
assert(err == RADIOLIB_ERR_NONE);
isReceiving = true;
@@ -308,14 +308,14 @@ bool RF95Interface::isChannelActive()
result = lora->scanChannel();
if (result == RADIOLIB_PREAMBLE_DETECTED) {
- // LOG_DEBUG("Channel is busy!\n");
+ // LOG_DEBUG("Channel is busy!");
return true;
}
if (result != RADIOLIB_CHANNEL_FREE)
- LOG_ERROR("RF95 isChannelActive %s%d\n", radioLibErr, result);
+ LOG_ERROR("RF95 isChannelActive %s%d", radioLibErr, result);
assert(result != RADIOLIB_ERR_WRONG_MODEM);
- // LOG_DEBUG("Channel is free!\n");
+ // LOG_DEBUG("Channel is free!");
return false;
}
diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp
index 7501852f29..f51c9bcb95 100644
--- a/src/mesh/RadioInterface.cpp
+++ b/src/mesh/RadioInterface.cpp
@@ -170,11 +170,11 @@ void initRegion()
#ifdef REGULATORY_LORA_REGIONCODE
for (; r->code != meshtastic_Config_LoRaConfig_RegionCode_UNSET && r->code != REGULATORY_LORA_REGIONCODE; r++)
;
- LOG_INFO("Wanted region %d, regulatory override to %s\n", config.lora.region, r->name);
+ LOG_INFO("Wanted region %d, regulatory override to %s", config.lora.region, r->name);
#else
for (; r->code != meshtastic_Config_LoRaConfig_RegionCode_UNSET && r->code != config.lora.region; r++)
;
- LOG_INFO("Wanted region %d, using %s\n", config.lora.region, r->name);
+ LOG_INFO("Wanted region %d, using %s", config.lora.region, r->name);
#endif
myRegion = r;
}
@@ -234,7 +234,7 @@ uint32_t RadioInterface::getRetransmissionMsec(const meshtastic_MeshPacket *p)
size_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), &meshtastic_Data_msg, &p->decoded);
uint32_t packetAirtime = getPacketTime(numbytes + sizeof(PacketHeader));
// Make sure enough time has elapsed for this packet to be sent and an ACK is received.
- // LOG_DEBUG("Waiting for flooding message with airtime %d and slotTime is %d\n", packetAirtime, slotTimeMsec);
+ // LOG_DEBUG("Waiting for flooding message with airtime %d and slotTime is %d", packetAirtime, slotTimeMsec);
float channelUtil = airTime->channelUtilizationPercent();
uint8_t CWsize = map(channelUtil, 0, 100, CWmin, CWmax);
// Assuming we pick max. of CWsize and there will be a client with SNR at half the range
@@ -250,7 +250,7 @@ uint32_t RadioInterface::getTxDelayMsec()
current channel utilization. */
float channelUtil = airTime->channelUtilizationPercent();
uint8_t CWsize = map(channelUtil, 0, 100, CWmin, CWmax);
- // LOG_DEBUG("Current channel utilization is %f so setting CWsize to %d\n", channelUtil, CWsize);
+ // LOG_DEBUG("Current channel utilization is %f so setting CWsize to %d", channelUtil, CWsize);
return random(0, pow(2, CWsize)) * slotTimeMsec;
}
@@ -267,15 +267,15 @@ uint32_t RadioInterface::getTxDelayMsecWeighted(float snr)
// low SNR = small CW size (Short Delay)
uint32_t delay = 0;
uint8_t CWsize = map(snr, SNR_MIN, SNR_MAX, CWmin, CWmax);
- // LOG_DEBUG("rx_snr of %f so setting CWsize to:%d\n", snr, CWsize);
+ // LOG_DEBUG("rx_snr of %f so setting CWsize to:%d", snr, CWsize);
if (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER ||
config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER) {
delay = random(0, 2 * CWsize) * slotTimeMsec;
- LOG_DEBUG("rx_snr found in packet. As a router, setting tx delay:%d\n", delay);
+ LOG_DEBUG("rx_snr found in packet. As a router, setting tx delay:%d", delay);
} else {
// offset the maximum delay for routers: (2 * CWmax * slotTimeMsec)
delay = (2 * CWmax * slotTimeMsec) + random(0, pow(2, CWsize)) * slotTimeMsec;
- LOG_DEBUG("rx_snr found in packet. Setting tx delay:%d\n", delay);
+ LOG_DEBUG("rx_snr found in packet. Setting tx delay:%d", delay);
}
return delay;
@@ -329,7 +329,7 @@ void printPacket(const char *prefix, const meshtastic_MeshPacket *p)
out += DEBUG_PORT.mt_sprintf(" priority=%d", p->priority);
out += ")";
- LOG_DEBUG("%s\n", out.c_str());
+ LOG_DEBUG("%s", out.c_str());
#endif
}
@@ -346,7 +346,7 @@ bool RadioInterface::reconfigure()
bool RadioInterface::init()
{
- LOG_INFO("Starting meshradio init...\n");
+ LOG_INFO("Starting meshradio init...");
configChangedObserver.observe(&service->configChanged);
preflightSleepObserver.observe(&preflightSleep);
@@ -494,8 +494,7 @@ void RadioInterface::applyModemConfig()
}
if ((myRegion->freqEnd - myRegion->freqStart) < bw / 1000) {
- static const char *err_string =
- "Regional frequency range is smaller than bandwidth. Falling back to default preset.\n";
+ static const char *err_string = "Regional frequency range is smaller than bandwidth. Falling back to default preset.";
LOG_ERROR(err_string);
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);
@@ -556,15 +555,15 @@ void RadioInterface::applyModemConfig()
preambleTimeMsec = getPacketTime((uint32_t)0);
maxPacketTimeMsec = getPacketTime(meshtastic_Constants_DATA_PAYLOAD_LEN + sizeof(PacketHeader));
- LOG_INFO("Radio freq=%.3f, config.lora.frequency_offset=%.3f\n", freq, loraConfig.frequency_offset);
- LOG_INFO("Set radio: region=%s, name=%s, config=%u, ch=%d, power=%d\n", myRegion->name, channelName, loraConfig.modem_preset,
+ LOG_INFO("Radio freq=%.3f, config.lora.frequency_offset=%.3f", freq, loraConfig.frequency_offset);
+ LOG_INFO("Set radio: region=%s, name=%s, config=%u, ch=%d, power=%d", myRegion->name, channelName, loraConfig.modem_preset,
channel_num, power);
- LOG_INFO("myRegion->freqStart -> myRegion->freqEnd: %f -> %f (%f MHz)\n", myRegion->freqStart, myRegion->freqEnd,
+ LOG_INFO("myRegion->freqStart -> myRegion->freqEnd: %f -> %f (%f MHz)", myRegion->freqStart, myRegion->freqEnd,
myRegion->freqEnd - myRegion->freqStart);
- LOG_INFO("numChannels: %d x %.3fkHz\n", numChannels, bw);
- LOG_INFO("channel_num: %d\n", channel_num + 1);
- LOG_INFO("frequency: %f\n", getFreq());
- LOG_INFO("Slot time: %u msec\n", slotTimeMsec);
+ LOG_INFO("numChannels: %d x %.3fkHz", numChannels, bw);
+ LOG_INFO("channel_num: %d", channel_num + 1);
+ LOG_INFO("frequency: %f", getFreq());
+ LOG_INFO("Slot time: %u msec", slotTimeMsec);
}
/**
@@ -579,11 +578,11 @@ void RadioInterface::limitPower()
maxPower = myRegion->powerLimit;
if ((power > maxPower) && !devicestate.owner.is_licensed) {
- LOG_INFO("Lowering transmit power because of regulatory limits\n");
+ LOG_INFO("Lowering transmit power because of regulatory limits");
power = maxPower;
}
- LOG_INFO("Set radio: final power level=%d\n", power);
+ LOG_INFO("Set radio: final power level=%d", power);
}
void RadioInterface::deliverToReceiver(meshtastic_MeshPacket *p)
@@ -599,7 +598,7 @@ size_t RadioInterface::beginSending(meshtastic_MeshPacket *p)
{
assert(!sendingPacket);
- // LOG_DEBUG("sending queued packet on mesh (txGood=%d,rxGood=%d,rxBad=%d)\n", rf95.txGood(), rf95.rxGood(), rf95.rxBad());
+ // LOG_DEBUG("sending queued packet on mesh (txGood=%d,rxGood=%d,rxBad=%d)", rf95.txGood(), rf95.rxGood(), rf95.rxBad());
assert(p->which_payload_variant == meshtastic_MeshPacket_encrypted_tag); // It should have already been encoded by now
lastTxStart = millis();
@@ -611,7 +610,7 @@ size_t RadioInterface::beginSending(meshtastic_MeshPacket *p)
radioBuffer.header.next_hop = 0; // *** For future use ***
radioBuffer.header.relay_node = 0; // *** For future use ***
if (p->hop_limit > HOP_MAX) {
- LOG_WARN("hop limit %d is too high, setting to %d\n", p->hop_limit, HOP_RELIABLE);
+ LOG_WARN("hop limit %d is too high, setting to %d", p->hop_limit, HOP_RELIABLE);
p->hop_limit = HOP_RELIABLE;
}
radioBuffer.header.flags =
diff --git a/src/mesh/RadioInterface.h b/src/mesh/RadioInterface.h
index 6df51ce1a9..89a4c70879 100644
--- a/src/mesh/RadioInterface.h
+++ b/src/mesh/RadioInterface.h
@@ -55,7 +55,7 @@ typedef struct {
PacketHeader header;
/** The payload, of maximum length minus the header, aligned just to be sure */
- uint8_t payload[MAX_LORA_PAYLOAD_LEN + 1 - sizeof(PacketHeader)] __attribute__ ((__aligned__));
+ uint8_t payload[MAX_LORA_PAYLOAD_LEN + 1 - sizeof(PacketHeader)] __attribute__((__aligned__));
} RadioBuffer;
@@ -105,7 +105,7 @@ class RadioInterface
/**
* A temporary buffer used for sending/receiving packets, sized to hold the biggest buffer we might need
* */
- RadioBuffer radioBuffer __attribute__ ((__aligned__));
+ RadioBuffer radioBuffer __attribute__((__aligned__));
/**
* Enqueue a received packet for the registered receiver
*/
diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp
index 8188260180..f44d50d363 100644
--- a/src/mesh/RadioLibInterface.cpp
+++ b/src/mesh/RadioLibInterface.cpp
@@ -111,18 +111,18 @@ bool RadioLibInterface::canSendImmediately()
if (busyTx || busyRx) {
if (busyTx) {
- LOG_WARN("Can not send yet, busyTx\n");
+ LOG_WARN("Can not send yet, busyTx");
}
// If we've been trying to send the same packet more than one minute and we haven't gotten a
// TX IRQ from the radio, the radio is probably broken.
if (busyTx && !Throttle::isWithinTimespanMs(lastTxStart, 60000)) {
- LOG_ERROR("Hardware Failure! busyTx for more than 60s\n");
+ LOG_ERROR("Hardware Failure! busyTx for more than 60s");
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_TRANSMIT_FAILED);
// reboot in 5 seconds when this condition occurs.
rebootAtMsec = lastTxStart + 65000;
}
if (busyRx) {
- LOG_WARN("Can not send yet, busyRx\n");
+ LOG_WARN("Can not send yet, busyRx");
}
return false;
} else
@@ -139,12 +139,12 @@ bool RadioLibInterface::receiveDetected(uint16_t irq, ulong syncWordHeaderValidF
} else if (!Throttle::isWithinTimespanMs(activeReceiveStart, 2 * preambleTimeMsec) && !(irq & syncWordHeaderValidFlag)) {
// The HEADER_VALID flag should be set by now if it was really a packet, so ignore PREAMBLE_DETECTED flag
activeReceiveStart = 0;
- LOG_DEBUG("Ignore false preamble detection.\n");
+ LOG_DEBUG("Ignore false preamble detection.");
return false;
} else if (!Throttle::isWithinTimespanMs(activeReceiveStart, maxPacketTimeMsec)) {
// We should have gotten an RX_DONE IRQ by now if it was really a packet, so ignore HEADER_VALID flag
activeReceiveStart = 0;
- LOG_DEBUG("Ignore false header detection.\n");
+ LOG_DEBUG("Ignore false header detection.");
return false;
}
}
@@ -161,13 +161,13 @@ ErrorCode RadioLibInterface::send(meshtastic_MeshPacket *p)
if (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_UNSET) {
if (disabled || !config.lora.tx_enabled) {
- LOG_WARN("send - !config.lora.tx_enabled\n");
+ LOG_WARN("send - !config.lora.tx_enabled");
packetPool.release(p);
return ERRNO_DISABLED;
}
} else {
- LOG_WARN("send - lora tx disabled because RegionCode_Unset\n");
+ LOG_WARN("send - lora tx disabled because RegionCode_Unset");
packetPool.release(p);
return ERRNO_DISABLED;
}
@@ -175,7 +175,7 @@ ErrorCode RadioLibInterface::send(meshtastic_MeshPacket *p)
#else
if (disabled || !config.lora.tx_enabled) {
- LOG_WARN("send - !config.lora.tx_enabled\n");
+ LOG_WARN("send - !config.lora.tx_enabled");
packetPool.release(p);
return ERRNO_DISABLED;
}
@@ -186,7 +186,7 @@ ErrorCode RadioLibInterface::send(meshtastic_MeshPacket *p)
#ifndef LORA_DISABLE_SENDING
printPacket("enqueuing for send", p);
- LOG_DEBUG("txGood=%d,txRelay=%d,rxGood=%d,rxBad=%d\n", txGood, txRelay, rxGood, rxBad);
+ LOG_DEBUG("txGood=%d,txRelay=%d,rxGood=%d,rxBad=%d", txGood, txRelay, rxGood, rxBad);
ErrorCode res = txQueue.enqueue(p) ? ERRNO_OK : ERRNO_UNKNOWN;
if (res != ERRNO_OK) { // we weren't able to queue it, so we must drop it to prevent leaks
@@ -196,7 +196,7 @@ ErrorCode RadioLibInterface::send(meshtastic_MeshPacket *p)
// set (random) transmit delay to let others reconfigure their radio,
// to avoid collisions and implement timing-based flooding
- // LOG_DEBUG("Set random delay before transmitting.\n");
+ // LOG_DEBUG("Set random delay before transmitting.");
setTransmitDelay();
return res;
@@ -221,7 +221,7 @@ bool RadioLibInterface::canSleep()
{
bool res = txQueue.empty();
if (!res) { // only print debug messages if we are vetoing sleep
- LOG_DEBUG("radio wait to sleep, txEmpty=%d\n", res);
+ LOG_DEBUG("radio wait to sleep, txEmpty=%d", res);
}
return res;
}
@@ -234,7 +234,7 @@ bool RadioLibInterface::cancelSending(NodeNum from, PacketId id)
packetPool.release(p); // free the packet we just removed
bool result = (p != NULL);
- LOG_DEBUG("cancelSending id=0x%x, removed=%d\n", id, result);
+ LOG_DEBUG("cancelSending id=0x%x, removed=%d", id, result);
return result;
}
@@ -251,27 +251,27 @@ void RadioLibInterface::onNotify(uint32_t notification)
case ISR_TX:
handleTransmitInterrupt();
startReceive();
- // LOG_DEBUG("tx complete - starting timer\n");
+ // LOG_DEBUG("tx complete - starting timer");
startTransmitTimer();
break;
case ISR_RX:
handleReceiveInterrupt();
startReceive();
- // LOG_DEBUG("rx complete - starting timer\n");
+ // LOG_DEBUG("rx complete - starting timer");
startTransmitTimer();
break;
case TRANSMIT_DELAY_COMPLETED:
- // LOG_DEBUG("delay done\n");
+ // LOG_DEBUG("delay done");
// If we are not currently in receive mode, then restart the random delay (this can happen if the main thread
// has placed the unit into standby) FIXME, how will this work if the chipset is in sleep mode?
if (!txQueue.empty()) {
if (!canSendImmediately()) {
- // LOG_DEBUG("Currently Rx/Tx-ing: set random delay\n");
+ // LOG_DEBUG("Currently Rx/Tx-ing: set random delay");
setTransmitDelay(); // currently Rx/Tx-ing: reset random delay
} else {
if (isChannelActive()) { // check if there is currently a LoRa packet on the channel
- // LOG_DEBUG("Channel is active, try receiving first.\n");
+ // LOG_DEBUG("Channel is active, try receiving first.");
startReceive(); // try receiving this packet, afterwards we'll be trying to transmit again
setTransmitDelay();
} else {
@@ -286,7 +286,7 @@ void RadioLibInterface::onNotify(uint32_t notification)
}
}
} else {
- // LOG_DEBUG("done with txqueue\n");
+ // LOG_DEBUG("done with txqueue");
}
break;
default:
@@ -309,7 +309,7 @@ void RadioLibInterface::setTransmitDelay()
startTransmitTimer(true);
} else {
// If there is a SNR, start a timer scaled based on that SNR.
- LOG_DEBUG("rx_snr found. hop_limit:%d rx_snr:%f\n", p->hop_limit, p->rx_snr);
+ LOG_DEBUG("rx_snr found. hop_limit:%d rx_snr:%f", p->hop_limit, p->rx_snr);
startTransmitTimerSNR(p->rx_snr);
}
}
@@ -319,7 +319,7 @@ void RadioLibInterface::startTransmitTimer(bool withDelay)
// If we have work to do and the timer wasn't already scheduled, schedule it now
if (!txQueue.empty()) {
uint32_t delay = !withDelay ? 1 : getTxDelayMsec();
- // LOG_DEBUG("xmit timer %d\n", delay);
+ // LOG_DEBUG("xmit timer %d", delay);
notifyLater(delay, TRANSMIT_DELAY_COMPLETED, false); // This will implicitly enable
}
}
@@ -329,14 +329,14 @@ void RadioLibInterface::startTransmitTimerSNR(float snr)
// If we have work to do and the timer wasn't already scheduled, schedule it now
if (!txQueue.empty()) {
uint32_t delay = getTxDelayMsecWeighted(snr);
- // LOG_DEBUG("xmit timer %d\n", delay);
+ // LOG_DEBUG("xmit timer %d", delay);
notifyLater(delay, TRANSMIT_DELAY_COMPLETED, false); // This will implicitly enable
}
}
void RadioLibInterface::handleTransmitInterrupt()
{
- // LOG_DEBUG("handling lora TX interrupt\n");
+ // LOG_DEBUG("handling lora TX interrupt");
// This can be null if we forced the device to enter standby mode. In that case
// ignore the transmit interrupt
if (sendingPacket)
@@ -359,7 +359,7 @@ void RadioLibInterface::completeSending()
// We are done sending that packet, release it
packetPool.release(p);
- // LOG_DEBUG("Done with send\n");
+ // LOG_DEBUG("Done with send");
}
}
@@ -370,7 +370,7 @@ void RadioLibInterface::handleReceiveInterrupt()
// when this is called, we should be in receive mode - if we are not, just jump out instead of bombing. Possible Race
// Condition?
if (!isReceiving) {
- LOG_ERROR("handleReceiveInterrupt called when not in receive mode, which shouldn't happen.\n");
+ LOG_ERROR("handleReceiveInterrupt called when not in receive mode, which shouldn't happen.");
return;
}
@@ -383,7 +383,7 @@ void RadioLibInterface::handleReceiveInterrupt()
#ifndef DISABLE_WELCOME_UNSET
if (config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_UNSET) {
- LOG_WARN("recv - lora rx disabled because RegionCode_Unset\n");
+ LOG_WARN("recv - lora rx disabled because RegionCode_Unset");
airTime->logAirtime(RX_ALL_LOG, xmitMsec);
return;
}
@@ -391,7 +391,7 @@ void RadioLibInterface::handleReceiveInterrupt()
int state = iface->readData((uint8_t *)&radioBuffer, length);
if (state != RADIOLIB_ERR_NONE) {
- LOG_ERROR("ignoring received packet due to error=%d\n", state);
+ LOG_ERROR("ignoring received packet due to error=%d", state);
rxBad++;
airTime->logAirtime(RX_ALL_LOG, xmitMsec);
@@ -402,14 +402,14 @@ void RadioLibInterface::handleReceiveInterrupt()
// check for short packets
if (payloadLen < 0) {
- LOG_WARN("ignoring received packet too short\n");
+ LOG_WARN("ignoring received packet too short");
rxBad++;
airTime->logAirtime(RX_ALL_LOG, xmitMsec);
} else {
rxGood++;
// altered packet with "from == 0" can do Remote Node Administration without permission
if (radioBuffer.header.from == 0) {
- LOG_WARN("ignoring received packet without sender\n");
+ LOG_WARN("ignoring received packet without sender");
return;
}
@@ -467,8 +467,11 @@ void RadioLibInterface::setStandby()
void RadioLibInterface::startSend(meshtastic_MeshPacket *txp)
{
printPacket("Starting low level send", txp);
- if (disabled || !config.lora.tx_enabled) {
- LOG_WARN("Drop Tx packet because LoRa Tx disabled\n");
+ if (txp->to == NODENUM_BROADCAST_NO_LORA) {
+ LOG_DEBUG("Drop Tx packet because dest is broadcast no-lora");
+ packetPool.release(txp);
+ } else if (disabled || !config.lora.tx_enabled) {
+ LOG_WARN("Drop Tx packet because LoRa Tx disabled");
packetPool.release(txp);
} else {
configHardwareForSend(); // must be after setStandby
@@ -477,7 +480,7 @@ void RadioLibInterface::startSend(meshtastic_MeshPacket *txp)
int res = iface->startTransmit((uint8_t *)&radioBuffer, numbytes);
if (res != RADIOLIB_ERR_NONE) {
- LOG_ERROR("startTransmit failed, error=%d\n", res);
+ LOG_ERROR("startTransmit failed, error=%d", res);
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_RADIO_SPI_BUG);
// This send failed, but make sure to 'complete' it properly
diff --git a/src/mesh/RadioLibInterface.h b/src/mesh/RadioLibInterface.h
index 673f53a322..353176a5ba 100644
--- a/src/mesh/RadioLibInterface.h
+++ b/src/mesh/RadioLibInterface.h
@@ -197,5 +197,5 @@ class RadioLibInterface : public RadioInterface, protected concurrency::Notified
*/
virtual void setStandby();
- const char *radioLibErr = "RadioLib err=\n";
+ const char *radioLibErr = "RadioLib err=";
};
\ No newline at end of file
diff --git a/src/mesh/RadioLibRF95.cpp b/src/mesh/RadioLibRF95.cpp
index fe9bbdc93f..a34c0605f9 100644
--- a/src/mesh/RadioLibRF95.cpp
+++ b/src/mesh/RadioLibRF95.cpp
@@ -18,8 +18,8 @@ int16_t RadioLibRF95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_
// current limit was removed from module' ctor
// override default value (60 mA)
state = setCurrentLimit(currentLimit);
- LOG_DEBUG("Current limit set to %f\n", currentLimit);
- LOG_DEBUG("Current limit set result %d\n", state);
+ LOG_DEBUG("Current limit set to %f", currentLimit);
+ LOG_DEBUG("Current limit set result %d", state);
// configure settings not accessible by API
// state = config();
@@ -73,7 +73,7 @@ bool RadioLibRF95::isReceiving()
{
// 0x0b == Look for header info valid, signal synchronized or signal detected
uint8_t reg = readReg(RADIOLIB_SX127X_REG_MODEM_STAT);
- // Serial.printf("reg %x\n", reg);
+ // Serial.printf("reg %x", reg);
return (reg & (RH_RF95_MODEM_STATUS_SIGNAL_DETECTED | RH_RF95_MODEM_STATUS_SIGNAL_SYNCHRONIZED |
RH_RF95_MODEM_STATUS_HEADER_INFO_VALID)) != 0;
}
diff --git a/src/mesh/ReliableRouter.cpp b/src/mesh/ReliableRouter.cpp
index fa05e79731..a2e09362dd 100644
--- a/src/mesh/ReliableRouter.cpp
+++ b/src/mesh/ReliableRouter.cpp
@@ -53,14 +53,14 @@ bool ReliableRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
auto key = GlobalPacketId(getFrom(p), p->id);
auto old = findPendingPacket(key);
if (old) {
- LOG_DEBUG("generating implicit ack\n");
+ LOG_DEBUG("generating implicit ack");
// NOTE: we do NOT check p->wantAck here because p is the INCOMING rebroadcast and that packet is not expected to be
// marked as wantAck
sendAckNak(meshtastic_Routing_Error_NONE, getFrom(p), p->id, old->packet->channel);
stopRetransmission(key);
} else {
- LOG_DEBUG("didn't find pending packet\n");
+ LOG_DEBUG("didn't find pending packet");
}
}
@@ -79,7 +79,7 @@ bool ReliableRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
* flooding this ACK back to the original sender already adds redundancy. */
bool isRepeated = p->hop_start == 0 ? (p->hop_limit == HOP_RELIABLE) : (p->hop_start == p->hop_limit);
if (wasSeenRecently(p, false) && isRepeated && !MeshModule::currentReply && !isToUs(p)) {
- LOG_DEBUG("Resending implicit ack for a repeated floodmsg\n");
+ LOG_DEBUG("Resending implicit ack for a repeated floodmsg");
meshtastic_MeshPacket *tosend = packetPool.allocCopy(*p);
tosend->hop_limit--; // bump down the hop count
Router::send(tosend);
@@ -105,12 +105,12 @@ void ReliableRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtas
if (isToUs(p)) { // ignore ack/nak/want_ack packets that are not address to us (we only handle 0 hop reliability)
if (p->want_ack) {
if (MeshModule::currentReply) {
- LOG_DEBUG("Another module replied to this message, no need for 2nd ack\n");
+ LOG_DEBUG("Another module replied to this message, no need for 2nd ack");
} else if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
sendAckNak(meshtastic_Routing_Error_NONE, getFrom(p), p->id, p->channel, p->hop_start, p->hop_limit);
} else if (p->which_payload_variant == meshtastic_MeshPacket_encrypted_tag && p->channel == 0 &&
(nodeDB->getMeshNode(p->from) == nullptr || nodeDB->getMeshNode(p->from)->user.public_key.size == 0)) {
- LOG_INFO("PKI packet from unknown node, send PKI_UNKNOWN_PUBKEY\n");
+ LOG_INFO("PKI packet from unknown node, send PKI_UNKNOWN_PUBKEY");
sendAckNak(meshtastic_Routing_Error_PKI_UNKNOWN_PUBKEY, getFrom(p), p->id, channels.getPrimaryIndex(),
p->hop_start, p->hop_limit);
} else {
@@ -134,7 +134,7 @@ void ReliableRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtas
// We intentionally don't check wasSeenRecently, because it is harmless to delete non existent retransmission records
if (ackId || nakId) {
- LOG_DEBUG("Received a %s for 0x%x, stopping retransmissions\n", ackId ? "ACK" : "NAK", ackId);
+ LOG_DEBUG("Received a %s for 0x%x, stopping retransmissions", ackId ? "ACK" : "NAK", ackId);
if (ackId) {
stopRetransmission(p->to, ackId);
} else {
@@ -227,15 +227,15 @@ int32_t ReliableRouter::doRetransmissions()
// FIXME, handle 51 day rolloever here!!!
if (p.nextTxMsec <= now) {
if (p.numRetransmissions == 0) {
- LOG_DEBUG("Reliable send failed, returning a nak for fr=0x%x,to=0x%x,id=0x%x\n", p.packet->from, p.packet->to,
+ LOG_DEBUG("Reliable send failed, returning a nak for fr=0x%x,to=0x%x,id=0x%x", p.packet->from, p.packet->to,
p.packet->id);
sendAckNak(meshtastic_Routing_Error_MAX_RETRANSMIT, getFrom(p.packet), p.packet->id, p.packet->channel);
// Note: we don't stop retransmission here, instead the Nak packet gets processed in sniffReceived
stopRetransmission(it->first);
stillValid = false; // just deleted it
} else {
- LOG_DEBUG("Sending reliable retransmission fr=0x%x,to=0x%x,id=0x%x, tries left=%d\n", p.packet->from,
- p.packet->to, p.packet->id, p.numRetransmissions);
+ LOG_DEBUG("Sending reliable retransmission fr=0x%x,to=0x%x,id=0x%x, tries left=%d", p.packet->from, p.packet->to,
+ p.packet->id, p.numRetransmissions);
// Note: we call the superclass version because we don't want to have our version of send() add a new
// retransmission record
diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp
index b5732dee9a..84ae7bbb02 100644
--- a/src/mesh/Router.cpp
+++ b/src/mesh/Router.cpp
@@ -48,9 +48,9 @@ Router::Router() : concurrency::OSThread("Router"), fromRadioQueue(MAX_RX_FROMRA
{
// This is called pre main(), don't touch anything here, the following code is not safe
- /* LOG_DEBUG("Size of NodeInfo %d\n", sizeof(NodeInfo));
- LOG_DEBUG("Size of SubPacket %d\n", sizeof(SubPacket));
- LOG_DEBUG("Size of MeshPacket %d\n", sizeof(MeshPacket)); */
+ /* LOG_DEBUG("Size of NodeInfo %d", sizeof(NodeInfo));
+ LOG_DEBUG("Size of SubPacket %d", sizeof(SubPacket));
+ LOG_DEBUG("Size of MeshPacket %d", sizeof(MeshPacket)); */
fromRadioQueue.setReader(this);
@@ -71,7 +71,7 @@ int32_t Router::runOnce()
perhapsHandleReceived(mp);
}
- // LOG_DEBUG("sleeping forever!\n");
+ // LOG_DEBUG("sleeping forever!");
return INT32_MAX; // Wait a long time - until we get woken for the message queue
}
@@ -104,14 +104,14 @@ PacketId generatePacketId()
// pick a random initial sequence number at boot (to prevent repeated reboots always starting at 0)
// Note: we mask the high order bit to ensure that we never pass a 'negative' number to random
rollingPacketId = random(UINT32_MAX & 0x7fffffff);
- LOG_DEBUG("Initial packet id %u\n", rollingPacketId);
+ LOG_DEBUG("Initial packet id %u", rollingPacketId);
}
rollingPacketId++;
rollingPacketId &= ID_COUNTER_MASK; // Mask out the top 22 bits
PacketId id = rollingPacketId | random(UINT32_MAX & 0x7fffffff) << 10; // top 22 bits
- LOG_DEBUG("Partially randomized packet id %u\n", id);
+ LOG_DEBUG("Partially randomized packet id %u", id);
return id;
}
@@ -141,14 +141,14 @@ void Router::sendAckNak(meshtastic_Routing_Error err, NodeNum to, PacketId idFro
void Router::abortSendAndNak(meshtastic_Routing_Error err, meshtastic_MeshPacket *p)
{
- LOG_ERROR("Error=%d, returning NAK and dropping packet.\n", err);
+ LOG_ERROR("Error=%d, returning NAK and dropping packet.", err);
sendAckNak(err, getFrom(p), p->id, p->channel);
packetPool.release(p);
}
void Router::setReceivedMessage()
{
- // LOG_DEBUG("set interval to ASAP\n");
+ // LOG_DEBUG("set interval to ASAP");
setInterval(0); // Run ASAP, so we can figure out our correct sleep time
runASAP = true;
}
@@ -166,7 +166,7 @@ meshtastic_QueueStatus Router::getQueueStatus()
ErrorCode Router::sendLocal(meshtastic_MeshPacket *p, RxSource src)
{
if (p->to == 0) {
- LOG_ERROR("Packet received with to: of 0!\n");
+ LOG_ERROR("Packet received with to: of 0!");
}
// No need to deliver externally if the destination is the local node
if (isToUs(p)) {
@@ -181,7 +181,7 @@ ErrorCode Router::sendLocal(meshtastic_MeshPacket *p, RxSource src)
} else {
// If we are sending a broadcast, we also treat it as if we just received it ourself
// this allows local apps (and PCs) to see broadcasts sourced locally
- if (p->to == NODENUM_BROADCAST) {
+ if (isBroadcast(p->to)) {
handleReceived(p, src);
}
@@ -189,7 +189,7 @@ ErrorCode Router::sendLocal(meshtastic_MeshPacket *p, RxSource src)
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(p->to);
if (node && node->user.public_key.size == 0) {
p->channel = node->channel;
- LOG_DEBUG("localSend to channel %d\n", p->channel);
+ LOG_DEBUG("localSend to channel %d", p->channel);
}
}
@@ -205,7 +205,7 @@ ErrorCode Router::sendLocal(meshtastic_MeshPacket *p, RxSource src)
ErrorCode Router::send(meshtastic_MeshPacket *p)
{
if (isToUs(p)) {
- LOG_ERROR("BUG! send() called with packet destined for local node!\n");
+ LOG_ERROR("BUG! send() called with packet destined for local node!");
packetPool.release(p);
return meshtastic_Routing_Error_BAD_REQUEST;
} // should have already been handled by sendLocal
@@ -216,7 +216,7 @@ ErrorCode Router::send(meshtastic_MeshPacket *p)
if (hourlyTxPercent > myRegion->dutyCycle) {
#ifdef DEBUG_PORT
uint8_t silentMinutes = airTime->getSilentMinutes(hourlyTxPercent, myRegion->dutyCycle);
- LOG_WARN("Duty cycle limit exceeded. Aborting send for now, you can send again in %d minutes.\n", silentMinutes);
+ LOG_WARN("Duty cycle limit exceeded. Aborting send for now, you can send again in %d minutes.", silentMinutes);
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
cn->has_reply_id = true;
cn->reply_id = p->id;
@@ -240,7 +240,7 @@ ErrorCode Router::send(meshtastic_MeshPacket *p)
// assert
// Never set the want_ack flag on broadcast packets sent over the air.
- if (p->to == NODENUM_BROADCAST)
+ if (isBroadcast(p->to))
p->want_ack = false;
// Up until this point we might have been using 0 for the from address (if it started with the phone), but when we send over
@@ -309,7 +309,7 @@ bool perhapsDecode(meshtastic_MeshPacket *p)
if (config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_KNOWN_ONLY &&
(nodeDB->getMeshNode(p->from) == NULL || !nodeDB->getMeshNode(p->from)->has_user)) {
- LOG_DEBUG("Node 0x%x not in nodeDB-> Rebroadcast mode KNOWN_ONLY will ignore packet\n", p->from);
+ LOG_DEBUG("Node 0x%x not in nodeDB-> Rebroadcast mode KNOWN_ONLY will ignore packet", p->from);
return false;
}
@@ -318,7 +318,7 @@ bool perhapsDecode(meshtastic_MeshPacket *p)
size_t rawSize = p->encrypted.size;
if (rawSize > sizeof(bytes)) {
- LOG_ERROR("Packet too large to attempt decryption! (rawSize=%d > 256)\n", rawSize);
+ LOG_ERROR("Packet too large to attempt decryption! (rawSize=%d > 256)", rawSize);
return false;
}
bool decrypted = false;
@@ -328,30 +328,31 @@ bool perhapsDecode(meshtastic_MeshPacket *p)
memcpy(ScratchEncrypted, p->encrypted.bytes, rawSize);
#if !(MESHTASTIC_EXCLUDE_PKI)
// Attempt PKI decryption first
- if (p->channel == 0 && isToUs(p) && p->to > 0 && p->to != NODENUM_BROADCAST && nodeDB->getMeshNode(p->from) != nullptr &&
+ if (p->channel == 0 && isToUs(p) && p->to > 0 && !isBroadcast(p->to) && nodeDB->getMeshNode(p->from) != nullptr &&
nodeDB->getMeshNode(p->from)->user.public_key.size > 0 && nodeDB->getMeshNode(p->to)->user.public_key.size > 0 &&
rawSize > MESHTASTIC_PKC_OVERHEAD) {
- LOG_DEBUG("Attempting PKI decryption\n");
+ LOG_DEBUG("Attempting PKI decryption");
- if (crypto->decryptCurve25519(p->from, p->id, rawSize, ScratchEncrypted, bytes)) {
- LOG_INFO("PKI Decryption worked!\n");
+ if (crypto->decryptCurve25519(p->from, nodeDB->getMeshNode(p->from)->user.public_key, p->id, rawSize, ScratchEncrypted,
+ bytes)) {
+ LOG_INFO("PKI Decryption worked!");
memset(&p->decoded, 0, sizeof(p->decoded));
rawSize -= MESHTASTIC_PKC_OVERHEAD;
if (pb_decode_from_bytes(bytes, rawSize, &meshtastic_Data_msg, &p->decoded) &&
p->decoded.portnum != meshtastic_PortNum_UNKNOWN_APP) {
decrypted = true;
- LOG_INFO("Packet decrypted using PKI!\n");
+ LOG_INFO("Packet decrypted using PKI!");
p->pki_encrypted = true;
memcpy(&p->public_key.bytes, nodeDB->getMeshNode(p->from)->user.public_key.bytes, 32);
p->public_key.size = 32;
// memcpy(bytes, ScratchEncrypted, rawSize); // TODO: Rename the bytes buffers
// chIndex = 8;
} else {
- LOG_ERROR("PKC Decrypted, but pb_decode failed!\n");
+ LOG_ERROR("PKC Decrypted, but pb_decode failed!");
return false;
}
} else {
- LOG_WARN("PKC decrypt attempted but failed!\n");
+ LOG_WARN("PKC decrypt attempted but failed!");
}
}
#endif
@@ -370,9 +371,9 @@ bool perhapsDecode(meshtastic_MeshPacket *p)
// Take those raw bytes and convert them back into a well structured protobuf we can understand
memset(&p->decoded, 0, sizeof(p->decoded));
if (!pb_decode_from_bytes(bytes, rawSize, &meshtastic_Data_msg, &p->decoded)) {
- LOG_ERROR("Invalid protobufs in received mesh packet id=0x%08x (bad psk?)!\n", p->id);
+ LOG_ERROR("Invalid protobufs in received mesh packet id=0x%08x (bad psk?)!", p->id);
} else if (p->decoded.portnum == meshtastic_PortNum_UNKNOWN_APP) {
- LOG_ERROR("Invalid portnum (bad psk?)!\n");
+ LOG_ERROR("Invalid portnum (bad psk?)!");
} else {
decrypted = true;
break;
@@ -399,7 +400,7 @@ bool perhapsDecode(meshtastic_MeshPacket *p)
decompressed_len = unishox2_decompress_simple(compressed_in, p->decoded.payload.size, decompressed_out);
- // LOG_DEBUG("\n\n**\n\nDecompressed length - %d \n", decompressed_len);
+ // LOG_DEBUG("**Decompressed length - %d ", decompressed_len);
memcpy(p->decoded.payload.bytes, decompressed_out, decompressed_len);
@@ -409,15 +410,15 @@ bool perhapsDecode(meshtastic_MeshPacket *p)
printPacket("decoded message", p);
#if ENABLE_JSON_LOGGING
- LOG_TRACE("%s\n", MeshPacketSerializer::JsonSerialize(p, false).c_str());
+ LOG_TRACE("%s", MeshPacketSerializer::JsonSerialize(p, false).c_str());
#elif ARCH_PORTDUINO
if (settingsStrings[traceFilename] != "" || settingsMap[logoutputlevel] == level_trace) {
- LOG_TRACE("%s\n", MeshPacketSerializer::JsonSerialize(p, false).c_str());
+ LOG_TRACE("%s", MeshPacketSerializer::JsonSerialize(p, false).c_str());
}
#endif
return true;
} else {
- LOG_WARN("No suitable channel found for decoding, hash was 0x%x!\n", p->channel);
+ LOG_WARN("No suitable channel found for decoding, hash was 0x%x!", p->channel);
return false;
}
}
@@ -452,20 +453,20 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
int compressed_len;
compressed_len = unishox2_compress_simple(original_payload, p->decoded.payload.size, compressed_out);
- LOG_DEBUG("Original length - %d \n", p->decoded.payload.size);
- LOG_DEBUG("Compressed length - %d \n", compressed_len);
- LOG_DEBUG("Original message - %s \n", p->decoded.payload.bytes);
+ LOG_DEBUG("Original length - %d ", p->decoded.payload.size);
+ LOG_DEBUG("Compressed length - %d ", compressed_len);
+ LOG_DEBUG("Original message - %s ", p->decoded.payload.bytes);
// If the compressed length is greater than or equal to the original size, don't use the compressed form
if (compressed_len >= p->decoded.payload.size) {
- LOG_DEBUG("Not using compressing message.\n");
+ LOG_DEBUG("Not using compressing message.");
// Set the uncompressed payload variant anyway. Shouldn't hurt?
// p->decoded.which_payloadVariant = Data_payload_tag;
// Otherwise we use the compressor
} else {
- LOG_DEBUG("Using compressed message.\n");
+ LOG_DEBUG("Using compressed message.");
// Copy the compressed data into the meshpacket
p->decoded.payload.size = compressed_len;
@@ -492,22 +493,22 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
// Don't use PKC if it's not explicitly requested and a non-primary channel is requested
!(p->pki_encrypted != true && p->channel > 0) &&
// Check for valid keys and single node destination
- config.security.private_key.size == 32 && p->to != NODENUM_BROADCAST && node != nullptr &&
+ config.security.private_key.size == 32 && !isBroadcast(p->to) && node != nullptr &&
// Check for a known public key for the destination
(node->user.public_key.size == 32) &&
// Some portnums either make no sense to send with PKC
p->decoded.portnum != meshtastic_PortNum_TRACEROUTE_APP && p->decoded.portnum != meshtastic_PortNum_NODEINFO_APP &&
p->decoded.portnum != meshtastic_PortNum_ROUTING_APP && p->decoded.portnum != meshtastic_PortNum_POSITION_APP) {
- LOG_DEBUG("Using PKI!\n");
+ LOG_DEBUG("Using PKI!");
if (numbytes + MESHTASTIC_HEADER_LENGTH + MESHTASTIC_PKC_OVERHEAD > MAX_LORA_PAYLOAD_LEN)
return meshtastic_Routing_Error_TOO_LARGE;
if (p->pki_encrypted && !memfll(p->public_key.bytes, 0, 32) &&
memcmp(p->public_key.bytes, node->user.public_key.bytes, 32) != 0) {
- LOG_WARN("Client public key differs from requested: 0x%02x, stored key begins 0x%02x\n", *p->public_key.bytes,
+ LOG_WARN("Client public key differs from requested: 0x%02x, stored key begins 0x%02x", *p->public_key.bytes,
*node->user.public_key.bytes);
return meshtastic_Routing_Error_PKI_FAILED;
}
- crypto->encryptCurve25519(p->to, getFrom(p), p->id, numbytes, bytes, ScratchEncrypted);
+ crypto->encryptCurve25519(p->to, getFrom(p), node->user.public_key, p->id, numbytes, bytes, ScratchEncrypted);
numbytes += MESHTASTIC_PKC_OVERHEAD;
memcpy(p->encrypted.bytes, ScratchEncrypted, numbytes);
p->channel = 0;
@@ -585,7 +586,7 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
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");
+ LOG_DEBUG("Neighbor info module is disabled, ignoring neighbor packet");
cancelSending(p->from, p->id);
skipHandle = true;
}
@@ -598,7 +599,7 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
p->decoded.portnum == meshtastic_PortNum_DETECTION_SENSOR_APP ||
p->decoded.portnum == meshtastic_PortNum_RANGE_TEST_APP ||
p->decoded.portnum == meshtastic_PortNum_REMOTE_HARDWARE_APP)) {
- LOG_DEBUG("Ignoring packet on blacklisted portnum during event\n");
+ LOG_DEBUG("Ignoring packet on blacklisted portnum during event");
cancelSending(p->from, p->id);
skipHandle = true;
}
@@ -612,8 +613,12 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
MeshModule::callModules(*p, src);
#if !MESHTASTIC_EXCLUDE_MQTT
+ // Mark as pki_encrypted if it is not yet decoded and MQTT encryption is also enabled, hash matches and it's a DM not to
+ // us (because we would be able to decrypt it)
+ if (!decoded && moduleConfig.mqtt.encryption_enabled && p->channel == 0x00 && !isBroadcast(p->to) && !isToUs(p))
+ p_encrypted->pki_encrypted = true;
// After potentially altering it, publish received message to MQTT if we're not the original transmitter of the packet
- if (decoded && moduleConfig.mqtt.enabled && !isFromUs(p) && mqtt)
+ if ((decoded || p_encrypted->pki_encrypted) && moduleConfig.mqtt.enabled && !isFromUs(p) && mqtt)
mqtt->onSend(*p_encrypted, *p, p->channel);
#endif
}
@@ -626,29 +631,35 @@ void Router::perhapsHandleReceived(meshtastic_MeshPacket *p)
#if ENABLE_JSON_LOGGING
// Even ignored packets get logged in the trace
p->rx_time = getValidTime(RTCQualityFromNet); // store the arrival timestamp for the phone
- LOG_TRACE("%s\n", MeshPacketSerializer::JsonSerializeEncrypted(p).c_str());
+ LOG_TRACE("%s", MeshPacketSerializer::JsonSerializeEncrypted(p).c_str());
#elif ARCH_PORTDUINO
// Even ignored packets get logged in the trace
if (settingsStrings[traceFilename] != "" || settingsMap[logoutputlevel] == level_trace) {
p->rx_time = getValidTime(RTCQualityFromNet); // store the arrival timestamp for the phone
- LOG_TRACE("%s\n", MeshPacketSerializer::JsonSerializeEncrypted(p).c_str());
+ LOG_TRACE("%s", MeshPacketSerializer::JsonSerializeEncrypted(p).c_str());
}
#endif
// assert(radioConfig.has_preferences);
if (is_in_repeated(config.lora.ignore_incoming, p->from)) {
- LOG_DEBUG("Ignoring incoming message, 0x%x is in our ignore list\n", p->from);
+ LOG_DEBUG("Ignoring msg, 0x%x is in our ignore list", p->from);
+ packetPool.release(p);
+ return;
+ }
+
+ if (p->from == NODENUM_BROADCAST) {
+ LOG_DEBUG("Ignoring msg from broadcast address");
packetPool.release(p);
return;
}
if (config.lora.ignore_mqtt && p->via_mqtt) {
- LOG_DEBUG("Message came in via MQTT from 0x%x\n", p->from);
+ LOG_DEBUG("Msg came in via MQTT from 0x%x", p->from);
packetPool.release(p);
return;
}
if (shouldFilterReceived(p)) {
- LOG_DEBUG("Incoming message was filtered from 0x%x\n", p->from);
+ LOG_DEBUG("Incoming msg was filtered from 0x%x", p->from);
packetPool.release(p);
return;
}
diff --git a/src/mesh/STM32WLE5JCInterface.cpp b/src/mesh/STM32WLE5JCInterface.cpp
index 3c1870d3bb..499db91766 100644
--- a/src/mesh/STM32WLE5JCInterface.cpp
+++ b/src/mesh/STM32WLE5JCInterface.cpp
@@ -27,11 +27,11 @@ bool STM32WLE5JCInterface::init()
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage);
- LOG_INFO("STM32WLx init result %d\n", res);
+ LOG_INFO("STM32WLx init result %d", res);
- LOG_INFO("Frequency set to %f\n", getFreq());
- LOG_INFO("Bandwidth set to %f\n", bw);
- LOG_INFO("Power output set to %d\n", power);
+ LOG_INFO("Frequency set to %f", getFreq());
+ LOG_INFO("Bandwidth set to %f", bw);
+ LOG_INFO("Power output set to %d", power);
if (res == RADIOLIB_ERR_NONE)
startReceive(); // start receiving
diff --git a/src/mesh/SX126xInterface.cpp b/src/mesh/SX126xInterface.cpp
index 924cdfa9f4..c88ed39d93 100644
--- a/src/mesh/SX126xInterface.cpp
+++ b/src/mesh/SX126xInterface.cpp
@@ -20,7 +20,7 @@ SX126xInterface::SX126xInterface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs
RADIOLIB_PIN_TYPE busy)
: RadioLibInterface(hal, cs, irq, rst, busy, &lora), lora(&module)
{
- LOG_DEBUG("SX126xInterface(cs=%d, irq=%d, rst=%d, busy=%d)\n", cs, irq, rst, busy);
+ LOG_DEBUG("SX126xInterface(cs=%d, irq=%d, rst=%d, busy=%d)", cs, irq, rst, busy);
}
/// Initialise the Driver transport hardware and software.
@@ -68,9 +68,9 @@ template bool SX126xInterface::init()
// (DIO3 is not free to be used as an IRQ)
#endif
if (tcxoVoltage == 0)
- LOG_DEBUG("SX126X_DIO3_TCXO_VOLTAGE not defined, not using DIO3 as TCXO reference voltage\n");
+ LOG_DEBUG("SX126X_DIO3_TCXO_VOLTAGE not defined, not using DIO3 as TCXO reference voltage");
else
- LOG_DEBUG("SX126X_DIO3_TCXO_VOLTAGE defined, using DIO3 as TCXO reference voltage at %f V\n", tcxoVoltage);
+ LOG_DEBUG("SX126X_DIO3_TCXO_VOLTAGE defined, using DIO3 as TCXO reference voltage at %f V", tcxoVoltage);
// FIXME: May want to set depending on a definition, currently all SX126x variant files use the DC-DC regulator option
bool useRegulatorLDO = false; // Seems to depend on the connection to pin 9/DCC_SW - if an inductor DCDC?
@@ -84,13 +84,13 @@ template bool SX126xInterface::init()
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage, useRegulatorLDO);
// \todo Display actual typename of the adapter, not just `SX126x`
- LOG_INFO("SX126x init result %d\n", res);
+ LOG_INFO("SX126x init result %d", res);
if (res == RADIOLIB_ERR_CHIP_NOT_FOUND)
return false;
- LOG_INFO("Frequency set to %f\n", getFreq());
- LOG_INFO("Bandwidth set to %f\n", bw);
- LOG_INFO("Power output set to %d\n", power);
+ LOG_INFO("Frequency set to %f", getFreq());
+ LOG_INFO("Bandwidth set to %f", bw);
+ LOG_INFO("Power output set to %d", power);
// Overriding current limit
// (https://github.com/jgromes/RadioLib/blob/690a050ebb46e6097c5d00c371e961c1caa3b52e/src/modules/SX126x/SX126x.cpp#L85) using
@@ -101,8 +101,8 @@ template bool SX126xInterface::init()
// FIXME: Not ideal to increase SX1261 current limit above 60mA as it can only transmit max 15dBm, should probably only do it
// if using SX1262 or SX1268
res = lora.setCurrentLimit(currentLimit);
- LOG_DEBUG("Current limit set to %f\n", currentLimit);
- LOG_DEBUG("Current limit set result %d\n", res);
+ LOG_DEBUG("Current limit set to %f", currentLimit);
+ LOG_DEBUG("Current limit set result %d", res);
if (res == RADIOLIB_ERR_NONE) {
#ifdef SX126X_DIO2_AS_RF_SWITCH
@@ -116,36 +116,36 @@ template bool SX126xInterface::init()
bool dio2AsRfSwitch = false;
#endif
res = lora.setDio2AsRfSwitch(dio2AsRfSwitch);
- LOG_DEBUG("Set DIO2 as %sRF switch, result: %d\n", dio2AsRfSwitch ? "" : "not ", res);
+ LOG_DEBUG("Set DIO2 as %sRF switch, result: %d", dio2AsRfSwitch ? "" : "not ", res);
}
// If a pin isn't defined, we set it to RADIOLIB_NC, it is safe to always do external RF switching with RADIOLIB_NC as it has
// no effect
#if ARCH_PORTDUINO
if (res == RADIOLIB_ERR_NONE) {
- LOG_DEBUG("Using MCU pin %i as RXEN and pin %i as TXEN to control RF switching\n", settingsMap[rxen], settingsMap[txen]);
+ LOG_DEBUG("Using MCU pin %i as RXEN and pin %i as TXEN to control RF switching", settingsMap[rxen], settingsMap[txen]);
lora.setRfSwitchPins(settingsMap[rxen], settingsMap[txen]);
}
#else
#ifndef SX126X_RXEN
#define SX126X_RXEN RADIOLIB_NC
- LOG_DEBUG("SX126X_RXEN not defined, defaulting to RADIOLIB_NC\n");
+ LOG_DEBUG("SX126X_RXEN not defined, defaulting to RADIOLIB_NC");
#endif
#ifndef SX126X_TXEN
#define SX126X_TXEN RADIOLIB_NC
- LOG_DEBUG("SX126X_TXEN not defined, defaulting to RADIOLIB_NC\n");
+ LOG_DEBUG("SX126X_TXEN not defined, defaulting to RADIOLIB_NC");
#endif
if (res == RADIOLIB_ERR_NONE) {
- LOG_DEBUG("Using MCU pin %i as RXEN and pin %i as TXEN to control RF switching\n", SX126X_RXEN, SX126X_TXEN);
+ LOG_DEBUG("Using MCU pin %i as RXEN and pin %i as TXEN to control RF switching", SX126X_RXEN, SX126X_TXEN);
lora.setRfSwitchPins(SX126X_RXEN, SX126X_TXEN);
}
#endif
if (config.lora.sx126x_rx_boosted_gain) {
uint16_t result = lora.setRxBoostedGainMode(true);
- LOG_INFO("Set RX gain to boosted mode; result: %d\n", result);
+ LOG_INFO("Set RX gain to boosted mode; result: %d", result);
} else {
uint16_t result = lora.setRxBoostedGainMode(false);
- LOG_INFO("Set RX gain to power saving mode (boosted mode off); result: %d\n", result);
+ LOG_INFO("Set RX gain to power saving mode (boosted mode off); result: %d", result);
}
#if 0
@@ -203,17 +203,17 @@ template bool SX126xInterface::reconfigure()
err = lora.setSyncWord(syncWord);
if (err != RADIOLIB_ERR_NONE)
- LOG_ERROR("SX126X setSyncWord %s%d\n", radioLibErr, err);
+ LOG_ERROR("SX126X setSyncWord %s%d", radioLibErr, err);
assert(err == RADIOLIB_ERR_NONE);
err = lora.setCurrentLimit(currentLimit);
if (err != RADIOLIB_ERR_NONE)
- LOG_ERROR("SX126X setCurrentLimit %s%d\n", radioLibErr, err);
+ LOG_ERROR("SX126X setCurrentLimit %s%d", radioLibErr, err);
assert(err == RADIOLIB_ERR_NONE);
err = lora.setPreambleLength(preambleLength);
if (err != RADIOLIB_ERR_NONE)
- LOG_ERROR("SX126X setPreambleLength %s%d\n", radioLibErr, err);
+ LOG_ERROR("SX126X setPreambleLength %s%d", radioLibErr, err);
assert(err == RADIOLIB_ERR_NONE);
err = lora.setFrequency(getFreq());
@@ -225,7 +225,7 @@ template bool SX126xInterface::reconfigure()
err = lora.setOutputPower(power);
if (err != RADIOLIB_ERR_NONE)
- LOG_ERROR("SX126X setOutputPower %s%d\n", radioLibErr, err);
+ LOG_ERROR("SX126X setOutputPower %s%d", radioLibErr, err);
assert(err == RADIOLIB_ERR_NONE);
startReceive(); // restart receiving
@@ -245,7 +245,7 @@ template void SX126xInterface::setStandby()
int err = lora.standby();
if (err != RADIOLIB_ERR_NONE)
- LOG_DEBUG("SX126x standby %s%d\n", radioLibErr, err);
+ LOG_DEBUG("SX126x standby %s%d", radioLibErr, err);
assert(err == RADIOLIB_ERR_NONE);
isReceiving = false; // If we were receiving, not any more
@@ -260,7 +260,7 @@ template void SX126xInterface::setStandby()
*/
template void SX126xInterface::addReceiveMetadata(meshtastic_MeshPacket *mp)
{
- // LOG_DEBUG("PacketStatus %x\n", lora.getPacketStatus());
+ // LOG_DEBUG("PacketStatus %x", lora.getPacketStatus());
mp->rx_snr = lora.getSNR();
mp->rx_rssi = lround(lora.getRSSI());
}
@@ -287,7 +287,7 @@ template void SX126xInterface::startReceive()
// Furthermore, we need the PREAMBLE_DETECTED and HEADER_VALID IRQ flag to detect whether we are actively receiving
int err = lora.startReceiveDutyCycleAuto(preambleLength, 8, RADIOLIB_IRQ_RX_DEFAULT_FLAGS | RADIOLIB_IRQ_PREAMBLE_DETECTED);
if (err != RADIOLIB_ERR_NONE)
- LOG_ERROR("SX126X startReceiveDutyCycleAuto %s%d\n", radioLibErr, err);
+ LOG_ERROR("SX126X startReceiveDutyCycleAuto %s%d", radioLibErr, err);
assert(err == RADIOLIB_ERR_NONE);
RadioLibInterface::startReceive();
@@ -308,7 +308,7 @@ template bool SX126xInterface::isChannelActive()
if (result == RADIOLIB_LORA_DETECTED)
return true;
if (result != RADIOLIB_CHANNEL_FREE)
- LOG_ERROR("SX126X scanChannel %s%d\n", radioLibErr, result);
+ LOG_ERROR("SX126X scanChannel %s%d", radioLibErr, result);
assert(result != RADIOLIB_ERR_WRONG_MODEM);
return false;
@@ -326,8 +326,8 @@ template bool SX126xInterface::sleep()
{
// Not keeping config is busted - next time nrf52 board boots lora sending fails tcxo related? - see datasheet
// \todo Display actual typename of the adapter, not just `SX126x`
- LOG_DEBUG("SX126x entering sleep mode\n"); // (FIXME, don't keep config)
- setStandby(); // Stop any pending operations
+ LOG_DEBUG("SX126x entering sleep mode"); // (FIXME, don't keep config)
+ setStandby(); // Stop any pending operations
// turn off TCXO if it was powered
// FIXME - this isn't correct
diff --git a/src/mesh/SX128xInterface.cpp b/src/mesh/SX128xInterface.cpp
index d379f26e6a..9fe86cc6e0 100644
--- a/src/mesh/SX128xInterface.cpp
+++ b/src/mesh/SX128xInterface.cpp
@@ -19,7 +19,7 @@ SX128xInterface::SX128xInterface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs
RADIOLIB_PIN_TYPE busy)
: RadioLibInterface(hal, cs, irq, rst, busy, &lora), lora(&module)
{
- LOG_DEBUG("SX128xInterface(cs=%d, irq=%d, rst=%d, busy=%d)\n", cs, irq, rst, busy);
+ LOG_DEBUG("SX128xInterface(cs=%d, irq=%d, rst=%d, busy=%d)", cs, irq, rst, busy);
}
/// Initialise the Driver transport hardware and software.
@@ -68,10 +68,10 @@ template bool SX128xInterface::init()
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength);
// \todo Display actual typename of the adapter, not just `SX128x`
- LOG_INFO("SX128x init result %d\n", res);
+ LOG_INFO("SX128x init result %d", res);
if ((config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24) && (res == RADIOLIB_ERR_INVALID_FREQUENCY)) {
- LOG_WARN("Radio chip only supports 2.4GHz LoRa. Adjusting Region and rebooting.\n");
+ LOG_WARN("Radio chip only supports 2.4GHz LoRa. Adjusting Region and rebooting.");
config.lora.region = meshtastic_Config_LoRaConfig_RegionCode_LORA_24;
nodeDB->saveToDisk(SEGMENT_CONFIG);
delay(2000);
@@ -80,13 +80,13 @@ template bool SX128xInterface::init()
#elif defined(ARCH_NRF52)
NVIC_SystemReset();
#else
- LOG_ERROR("FIXME implement reboot for this platform. Skipping for now.\n");
+ LOG_ERROR("FIXME implement reboot for this platform. Skipping for now.");
#endif
}
- LOG_INFO("Frequency set to %f\n", getFreq());
- LOG_INFO("Bandwidth set to %f\n", bw);
- LOG_INFO("Power output set to %d\n", power);
+ LOG_INFO("Frequency set to %f", getFreq());
+ LOG_INFO("Bandwidth set to %f", bw);
+ LOG_INFO("Power output set to %d", power);
#if defined(SX128X_TXEN) && (SX128X_TXEN != RADIOLIB_NC) && defined(SX128X_RXEN) && (SX128X_RXEN != RADIOLIB_NC)
if (res == RADIOLIB_ERR_NONE) {
@@ -129,12 +129,12 @@ template bool SX128xInterface::reconfigure()
err = lora.setSyncWord(syncWord);
if (err != RADIOLIB_ERR_NONE)
- LOG_ERROR("SX128X setSyncWord %s%d\n", radioLibErr, err);
+ LOG_ERROR("SX128X setSyncWord %s%d", radioLibErr, err);
assert(err == RADIOLIB_ERR_NONE);
err = lora.setPreambleLength(preambleLength);
if (err != RADIOLIB_ERR_NONE)
- LOG_ERROR("SX128X setPreambleLength %s%d\n", radioLibErr, err);
+ LOG_ERROR("SX128X setPreambleLength %s%d", radioLibErr, err);
assert(err == RADIOLIB_ERR_NONE);
err = lora.setFrequency(getFreq());
@@ -146,7 +146,7 @@ template bool SX128xInterface::reconfigure()
err = lora.setOutputPower(power);
if (err != RADIOLIB_ERR_NONE)
- LOG_ERROR("SX128X setOutputPower %s%d\n", radioLibErr, err);
+ LOG_ERROR("SX128X setOutputPower %s%d", radioLibErr, err);
assert(err == RADIOLIB_ERR_NONE);
startReceive(); // restart receiving
@@ -171,7 +171,7 @@ template void SX128xInterface::setStandby()
int err = lora.standby();
if (err != RADIOLIB_ERR_NONE)
- LOG_ERROR("SX128x standby %s%d\n", radioLibErr, err);
+ LOG_ERROR("SX128x standby %s%d", radioLibErr, err);
assert(err == RADIOLIB_ERR_NONE);
#if ARCH_PORTDUINO
if (settingsMap[rxen] != RADIOLIB_NC) {
@@ -200,7 +200,7 @@ template void SX128xInterface::setStandby()
*/
template void SX128xInterface::addReceiveMetadata(meshtastic_MeshPacket *mp)
{
- // LOG_DEBUG("PacketStatus %x\n", lora.getPacketStatus());
+ // LOG_DEBUG("PacketStatus %x", lora.getPacketStatus());
mp->rx_snr = lora.getSNR();
mp->rx_rssi = lround(lora.getRSSI());
}
@@ -261,7 +261,7 @@ template void SX128xInterface::startReceive()
int err = lora.startReceive(RADIOLIB_SX128X_RX_TIMEOUT_INF, RADIOLIB_IRQ_RX_DEFAULT_FLAGS | RADIOLIB_IRQ_PREAMBLE_DETECTED);
if (err != RADIOLIB_ERR_NONE)
- LOG_ERROR("SX128X startReceive %s%d\n", radioLibErr, err);
+ LOG_ERROR("SX128X startReceive %s%d", radioLibErr, err);
assert(err == RADIOLIB_ERR_NONE);
RadioLibInterface::startReceive();
@@ -282,7 +282,7 @@ template bool SX128xInterface::isChannelActive()
if (result == RADIOLIB_LORA_DETECTED)
return true;
if (result != RADIOLIB_CHANNEL_FREE)
- LOG_ERROR("SX128X scanChannel %s%d\n", radioLibErr, result);
+ LOG_ERROR("SX128X scanChannel %s%d", radioLibErr, result);
assert(result != RADIOLIB_ERR_WRONG_MODEM);
return false;
@@ -298,8 +298,8 @@ template bool SX128xInterface::sleep()
{
// Not keeping config is busted - next time nrf52 board boots lora sending fails tcxo related? - see datasheet
// \todo Display actual typename of the adapter, not just `SX128x`
- LOG_DEBUG("SX128x entering sleep mode\n"); // (FIXME, don't keep config)
- setStandby(); // Stop any pending operations
+ LOG_DEBUG("SX128x entering sleep mode"); // (FIXME, don't keep config)
+ setStandby(); // Stop any pending operations
// turn off TCXO if it was powered
// FIXME - this isn't correct
diff --git a/src/mesh/StreamAPI.cpp b/src/mesh/StreamAPI.cpp
index c3d85ed338..4a42e5197a 100644
--- a/src/mesh/StreamAPI.cpp
+++ b/src/mesh/StreamAPI.cpp
@@ -115,7 +115,7 @@ void StreamAPI::emitRebooted()
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_rebooted_tag;
fromRadioScratch.rebooted = true;
- // LOG_DEBUG("Emitting reboot packet for serial shell\n");
+ // LOG_DEBUG("Emitting reboot packet for serial shell");
emitTxBuffer(pb_encode_to_bytes(txBuf + HEADER_LEN, meshtastic_FromRadio_size, &meshtastic_FromRadio_msg, &fromRadioScratch));
}
diff --git a/src/mesh/api/ServerAPI.cpp b/src/mesh/api/ServerAPI.cpp
index 42217428df..7705858b5e 100644
--- a/src/mesh/api/ServerAPI.cpp
+++ b/src/mesh/api/ServerAPI.cpp
@@ -5,7 +5,7 @@
template
ServerAPI::ServerAPI(T &_client) : StreamAPI(&client), concurrency::OSThread("ServerAPI"), client(_client)
{
- LOG_INFO("Incoming API connection\n");
+ LOG_INFO("Incoming API connection");
}
template ServerAPI::~ServerAPI()
@@ -30,7 +30,7 @@ template int32_t ServerAPI::runOnce()
if (client.connected()) {
return StreamAPI::runOncePart();
} else {
- LOG_INFO("Client dropped connection, suspending API service\n");
+ LOG_INFO("Client dropped connection, suspending API service");
enabled = false; // we no longer need to run
return 0;
}
@@ -63,11 +63,11 @@ template int32_t APIServerPort::runOnce()
// Reconnections are delayed by full wait time
if (waitTime < 400) {
waitTime *= 2;
- LOG_INFO("Previous TCP connection still open, trying again in %dms\n", waitTime);
+ LOG_INFO("Previous TCP connection still open, trying again in %dms", waitTime);
return waitTime;
}
#endif
- LOG_INFO("Force closing previous TCP connection\n");
+ LOG_INFO("Force closing previous TCP connection");
delete openAPI;
}
diff --git a/src/mesh/api/WiFiServerAPI.cpp b/src/mesh/api/WiFiServerAPI.cpp
index ba31f76e5f..89ab2c626b 100644
--- a/src/mesh/api/WiFiServerAPI.cpp
+++ b/src/mesh/api/WiFiServerAPI.cpp
@@ -11,7 +11,7 @@ void initApiServer(int port)
// Start API server on port 4403
if (!apiPort) {
apiPort = new WiFiServerPort(port);
- LOG_INFO("API server listening on TCP port %d\n", port);
+ LOG_INFO("API server listening on TCP port %d", port);
apiPort->init();
}
}
@@ -22,7 +22,7 @@ void deInitApiServer()
WiFiServerAPI::WiFiServerAPI(WiFiClient &_client) : ServerAPI(_client)
{
- LOG_INFO("Incoming wifi connection\n");
+ LOG_INFO("Incoming wifi connection");
}
WiFiServerPort::WiFiServerPort(int port) : APIServerPort(port) {}
diff --git a/src/mesh/api/ethServerAPI.cpp b/src/mesh/api/ethServerAPI.cpp
index 3badcdfdec..a8701848a6 100644
--- a/src/mesh/api/ethServerAPI.cpp
+++ b/src/mesh/api/ethServerAPI.cpp
@@ -12,14 +12,14 @@ void initApiServer(int port)
// Start API server on port 4403
if (!apiPort) {
apiPort = new ethServerPort(port);
- LOG_INFO("API server listening on TCP port %d\n", port);
+ LOG_INFO("API server listening on TCP port %d", port);
apiPort->init();
}
}
ethServerAPI::ethServerAPI(EthernetClient &_client) : ServerAPI(_client)
{
- LOG_INFO("Incoming ethernet connection\n");
+ LOG_INFO("Incoming ethernet connection");
}
ethServerPort::ethServerPort(int port) : APIServerPort(port) {}
diff --git a/src/mesh/eth/ethClient.cpp b/src/mesh/eth/ethClient.cpp
index 1c97f3bed7..67da224c6a 100644
--- a/src/mesh/eth/ethClient.cpp
+++ b/src/mesh/eth/ethClient.cpp
@@ -38,16 +38,16 @@ static int32_t reconnectETH()
Ethernet.maintain();
if (!ethStartupComplete) {
// Start web server
- LOG_INFO("Starting Ethernet network services\n");
+ LOG_INFO("Starting Ethernet network services");
#ifndef DISABLE_NTP
- LOG_INFO("Starting NTP time client\n");
+ LOG_INFO("Starting NTP time client");
timeClient.begin();
timeClient.setUpdateInterval(60 * 60); // Update once an hour
#endif
if (config.network.rsyslog_server[0]) {
- LOG_INFO("Starting Syslog client\n");
+ LOG_INFO("Starting Syslog client");
// Defaults
int serverPort = 514;
const char *serverAddr = config.network.rsyslog_server;
@@ -82,9 +82,9 @@ static int32_t reconnectETH()
#ifndef DISABLE_NTP
if (isEthernetAvailable() && (ntp_renew < millis())) {
- LOG_INFO("Updating NTP time from %s\n", config.network.ntp_server);
+ LOG_INFO("Updating NTP time from %s", config.network.ntp_server);
if (timeClient.update()) {
- LOG_DEBUG("NTP Request Success - Setting RTCQualityNTP if needed\n");
+ LOG_DEBUG("NTP Request Success - Setting RTCQualityNTP if needed");
struct timeval tv;
tv.tv_sec = timeClient.getEpochTime();
@@ -94,7 +94,7 @@ static int32_t reconnectETH()
ntp_renew = millis() + 43200 * 1000; // success, refresh every 12 hours
} else {
- LOG_ERROR("NTP Update failed\n");
+ LOG_ERROR("NTP Update failed");
ntp_renew = millis() + 300 * 1000; // failure, retry every 5 minutes
}
}
@@ -127,45 +127,45 @@ bool initEthernet()
mac[0] &= 0xfe; // Make sure this is not a multicast MAC
if (config.network.address_mode == meshtastic_Config_NetworkConfig_AddressMode_DHCP) {
- LOG_INFO("starting Ethernet DHCP\n");
+ LOG_INFO("starting Ethernet DHCP");
status = Ethernet.begin(mac);
} else if (config.network.address_mode == meshtastic_Config_NetworkConfig_AddressMode_STATIC) {
- LOG_INFO("starting Ethernet Static\n");
+ LOG_INFO("starting Ethernet Static");
Ethernet.begin(mac, config.network.ipv4_config.ip, config.network.ipv4_config.dns, config.network.ipv4_config.gateway,
config.network.ipv4_config.subnet);
status = 1;
} else {
- LOG_INFO("Ethernet Disabled\n");
+ LOG_INFO("Ethernet Disabled");
return false;
}
if (status == 0) {
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
- LOG_ERROR("Ethernet shield was not found.\n");
+ LOG_ERROR("Ethernet shield was not found.");
return false;
} else if (Ethernet.linkStatus() == LinkOFF) {
- LOG_ERROR("Ethernet cable is not connected.\n");
+ LOG_ERROR("Ethernet cable is not connected.");
return false;
} else {
- LOG_ERROR("Unknown Ethernet error.\n");
+ LOG_ERROR("Unknown Ethernet error.");
return false;
}
} else {
- LOG_INFO("Local IP %u.%u.%u.%u\n", Ethernet.localIP()[0], Ethernet.localIP()[1], Ethernet.localIP()[2],
+ LOG_INFO("Local IP %u.%u.%u.%u", Ethernet.localIP()[0], Ethernet.localIP()[1], Ethernet.localIP()[2],
Ethernet.localIP()[3]);
- LOG_INFO("Subnet Mask %u.%u.%u.%u\n", Ethernet.subnetMask()[0], Ethernet.subnetMask()[1], Ethernet.subnetMask()[2],
+ LOG_INFO("Subnet Mask %u.%u.%u.%u", Ethernet.subnetMask()[0], Ethernet.subnetMask()[1], Ethernet.subnetMask()[2],
Ethernet.subnetMask()[3]);
- LOG_INFO("Gateway IP %u.%u.%u.%u\n", Ethernet.gatewayIP()[0], Ethernet.gatewayIP()[1], Ethernet.gatewayIP()[2],
+ LOG_INFO("Gateway IP %u.%u.%u.%u", Ethernet.gatewayIP()[0], Ethernet.gatewayIP()[1], Ethernet.gatewayIP()[2],
Ethernet.gatewayIP()[3]);
- LOG_INFO("DNS Server IP %u.%u.%u.%u\n", Ethernet.dnsServerIP()[0], Ethernet.dnsServerIP()[1],
- Ethernet.dnsServerIP()[2], Ethernet.dnsServerIP()[3]);
+ LOG_INFO("DNS Server IP %u.%u.%u.%u", Ethernet.dnsServerIP()[0], Ethernet.dnsServerIP()[1], Ethernet.dnsServerIP()[2],
+ Ethernet.dnsServerIP()[3]);
}
ethEvent = new Periodic("ethConnect", reconnectETH);
return true;
} else {
- LOG_INFO("Not using Ethernet\n");
+ LOG_INFO("Not using Ethernet");
return false;
}
}
diff --git a/src/mesh/generated/meshtastic/admin.pb.h b/src/mesh/generated/meshtastic/admin.pb.h
index bf81269b40..d802eb3da2 100644
--- a/src/mesh/generated/meshtastic/admin.pb.h
+++ b/src/mesh/generated/meshtastic/admin.pb.h
@@ -9,6 +9,7 @@
#include "meshtastic/connection_status.pb.h"
#include "meshtastic/mesh.pb.h"
#include "meshtastic/module_config.pb.h"
+#include "meshtastic/device_ui.pb.h"
#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
@@ -34,7 +35,9 @@ typedef enum _meshtastic_AdminMessage_ConfigType {
/* TODO: REPLACE */
meshtastic_AdminMessage_ConfigType_SECURITY_CONFIG = 7,
/* */
- meshtastic_AdminMessage_ConfigType_SESSIONKEY_CONFIG = 8
+ meshtastic_AdminMessage_ConfigType_SESSIONKEY_CONFIG = 8,
+ /* device-ui config */
+ meshtastic_AdminMessage_ConfigType_DEVICEUI_CONFIG = 9
} meshtastic_AdminMessage_ConfigType;
/* TODO: REPLACE */
@@ -171,6 +174,12 @@ typedef struct _meshtastic_AdminMessage {
/* Set time only on the node
Convenience method to set the time on the node (as Net quality) without any other position data */
uint32_t set_time_only;
+ /* Tell the node to send the stored ui data. */
+ bool get_ui_config_request;
+ /* Reply stored device ui data. */
+ meshtastic_DeviceUIConfig get_ui_config_response;
+ /* Tell the node to store UI data persistently. */
+ meshtastic_DeviceUIConfig store_ui_config;
/* Begins an edit transaction for config, module config, owner, and channel settings changes
This will delay the standard *implicit* save to the file system and subsequent reboot behavior until committed (commit_edit_settings) */
bool begin_edit_settings;
@@ -206,8 +215,8 @@ extern "C" {
/* Helper constants for enums */
#define _meshtastic_AdminMessage_ConfigType_MIN meshtastic_AdminMessage_ConfigType_DEVICE_CONFIG
-#define _meshtastic_AdminMessage_ConfigType_MAX meshtastic_AdminMessage_ConfigType_SESSIONKEY_CONFIG
-#define _meshtastic_AdminMessage_ConfigType_ARRAYSIZE ((meshtastic_AdminMessage_ConfigType)(meshtastic_AdminMessage_ConfigType_SESSIONKEY_CONFIG+1))
+#define _meshtastic_AdminMessage_ConfigType_MAX meshtastic_AdminMessage_ConfigType_DEVICEUI_CONFIG
+#define _meshtastic_AdminMessage_ConfigType_ARRAYSIZE ((meshtastic_AdminMessage_ConfigType)(meshtastic_AdminMessage_ConfigType_DEVICEUI_CONFIG+1))
#define _meshtastic_AdminMessage_ModuleConfigType_MIN meshtastic_AdminMessage_ModuleConfigType_MQTT_CONFIG
#define _meshtastic_AdminMessage_ModuleConfigType_MAX meshtastic_AdminMessage_ModuleConfigType_PAXCOUNTER_CONFIG
@@ -267,6 +276,9 @@ extern "C" {
#define meshtastic_AdminMessage_set_fixed_position_tag 41
#define meshtastic_AdminMessage_remove_fixed_position_tag 42
#define meshtastic_AdminMessage_set_time_only_tag 43
+#define meshtastic_AdminMessage_get_ui_config_request_tag 44
+#define meshtastic_AdminMessage_get_ui_config_response_tag 45
+#define meshtastic_AdminMessage_store_ui_config_tag 46
#define meshtastic_AdminMessage_begin_edit_settings_tag 64
#define meshtastic_AdminMessage_commit_edit_settings_tag 65
#define meshtastic_AdminMessage_factory_reset_device_tag 94
@@ -314,6 +326,9 @@ X(a, STATIC, ONEOF, UINT32, (payload_variant,remove_favorite_node,remove_
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,set_fixed_position,set_fixed_position), 41) \
X(a, STATIC, ONEOF, BOOL, (payload_variant,remove_fixed_position,remove_fixed_position), 42) \
X(a, STATIC, ONEOF, FIXED32, (payload_variant,set_time_only,set_time_only), 43) \
+X(a, STATIC, ONEOF, BOOL, (payload_variant,get_ui_config_request,get_ui_config_request), 44) \
+X(a, STATIC, ONEOF, MESSAGE, (payload_variant,get_ui_config_response,get_ui_config_response), 45) \
+X(a, STATIC, ONEOF, MESSAGE, (payload_variant,store_ui_config,store_ui_config), 46) \
X(a, STATIC, ONEOF, BOOL, (payload_variant,begin_edit_settings,begin_edit_settings), 64) \
X(a, STATIC, ONEOF, BOOL, (payload_variant,commit_edit_settings,commit_edit_settings), 65) \
X(a, STATIC, ONEOF, INT32, (payload_variant,factory_reset_device,factory_reset_device), 94) \
@@ -339,6 +354,8 @@ X(a, STATIC, SINGULAR, BYTES, session_passkey, 101)
#define meshtastic_AdminMessage_payload_variant_set_config_MSGTYPE meshtastic_Config
#define meshtastic_AdminMessage_payload_variant_set_module_config_MSGTYPE meshtastic_ModuleConfig
#define meshtastic_AdminMessage_payload_variant_set_fixed_position_MSGTYPE meshtastic_Position
+#define meshtastic_AdminMessage_payload_variant_get_ui_config_response_MSGTYPE meshtastic_DeviceUIConfig
+#define meshtastic_AdminMessage_payload_variant_store_ui_config_MSGTYPE meshtastic_DeviceUIConfig
#define meshtastic_HamParameters_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, STRING, call_sign, 1) \
diff --git a/src/mesh/generated/meshtastic/config.pb.h b/src/mesh/generated/meshtastic/config.pb.h
index 988f852ffb..fab23ae34f 100644
--- a/src/mesh/generated/meshtastic/config.pb.h
+++ b/src/mesh/generated/meshtastic/config.pb.h
@@ -4,6 +4,7 @@
#ifndef PB_MESHTASTIC_MESHTASTIC_CONFIG_PB_H_INCLUDED
#define PB_MESHTASTIC_MESHTASTIC_CONFIG_PB_H_INCLUDED
#include
+#include "meshtastic/device_ui.pb.h"
#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
@@ -73,7 +74,12 @@ typedef enum _meshtastic_Config_DeviceConfig_RebroadcastMode {
meshtastic_Config_DeviceConfig_RebroadcastMode_LOCAL_ONLY = 2,
/* Ignores observed messages from foreign meshes like LOCAL_ONLY,
but takes it step further by also ignoring messages from nodenums not in the node's known list (NodeDB) */
- meshtastic_Config_DeviceConfig_RebroadcastMode_KNOWN_ONLY = 3
+ meshtastic_Config_DeviceConfig_RebroadcastMode_KNOWN_ONLY = 3,
+ /* Only permitted for SENSOR, TRACKER and TAK_TRACKER roles, this will inhibit all rebroadcasts, not unlike CLIENT_MUTE role. */
+ meshtastic_Config_DeviceConfig_RebroadcastMode_NONE = 4,
+ /* Ignores packets from non-standard portnums such as: TAK, RangeTest, PaxCounter, etc.
+ Only rebroadcasts packets with standard portnums: NodeInfo, Text, Position, Telemetry, and Routing. */
+ meshtastic_Config_DeviceConfig_RebroadcastMode_CORE_PORTNUMS_ONLY = 5
} meshtastic_Config_DeviceConfig_RebroadcastMode;
/* Bit field of boolean configuration options, indicating which optional
@@ -571,6 +577,7 @@ typedef struct _meshtastic_Config {
meshtastic_Config_BluetoothConfig bluetooth;
meshtastic_Config_SecurityConfig security;
meshtastic_Config_SessionkeyConfig sessionkey;
+ meshtastic_DeviceUIConfig device_ui;
} payload_variant;
} meshtastic_Config;
@@ -585,8 +592,8 @@ extern "C" {
#define _meshtastic_Config_DeviceConfig_Role_ARRAYSIZE ((meshtastic_Config_DeviceConfig_Role)(meshtastic_Config_DeviceConfig_Role_TAK_TRACKER+1))
#define _meshtastic_Config_DeviceConfig_RebroadcastMode_MIN meshtastic_Config_DeviceConfig_RebroadcastMode_ALL
-#define _meshtastic_Config_DeviceConfig_RebroadcastMode_MAX meshtastic_Config_DeviceConfig_RebroadcastMode_KNOWN_ONLY
-#define _meshtastic_Config_DeviceConfig_RebroadcastMode_ARRAYSIZE ((meshtastic_Config_DeviceConfig_RebroadcastMode)(meshtastic_Config_DeviceConfig_RebroadcastMode_KNOWN_ONLY+1))
+#define _meshtastic_Config_DeviceConfig_RebroadcastMode_MAX meshtastic_Config_DeviceConfig_RebroadcastMode_CORE_PORTNUMS_ONLY
+#define _meshtastic_Config_DeviceConfig_RebroadcastMode_ARRAYSIZE ((meshtastic_Config_DeviceConfig_RebroadcastMode)(meshtastic_Config_DeviceConfig_RebroadcastMode_CORE_PORTNUMS_ONLY+1))
#define _meshtastic_Config_PositionConfig_PositionFlags_MIN meshtastic_Config_PositionConfig_PositionFlags_UNSET
#define _meshtastic_Config_PositionConfig_PositionFlags_MAX meshtastic_Config_PositionConfig_PositionFlags_SPEED
@@ -774,6 +781,7 @@ extern "C" {
#define meshtastic_Config_bluetooth_tag 7
#define meshtastic_Config_security_tag 8
#define meshtastic_Config_sessionkey_tag 9
+#define meshtastic_Config_device_ui_tag 10
/* Struct field encoding specification for nanopb */
#define meshtastic_Config_FIELDLIST(X, a) \
@@ -785,7 +793,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,display,payload_variant.disp
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,lora,payload_variant.lora), 6) \
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,bluetooth,payload_variant.bluetooth), 7) \
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,security,payload_variant.security), 8) \
-X(a, STATIC, ONEOF, MESSAGE, (payload_variant,sessionkey,payload_variant.sessionkey), 9)
+X(a, STATIC, ONEOF, MESSAGE, (payload_variant,sessionkey,payload_variant.sessionkey), 9) \
+X(a, STATIC, ONEOF, MESSAGE, (payload_variant,device_ui,payload_variant.device_ui), 10)
#define meshtastic_Config_CALLBACK NULL
#define meshtastic_Config_DEFAULT NULL
#define meshtastic_Config_payload_variant_device_MSGTYPE meshtastic_Config_DeviceConfig
@@ -797,6 +806,7 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,sessionkey,payload_variant.s
#define meshtastic_Config_payload_variant_bluetooth_MSGTYPE meshtastic_Config_BluetoothConfig
#define meshtastic_Config_payload_variant_security_MSGTYPE meshtastic_Config_SecurityConfig
#define meshtastic_Config_payload_variant_sessionkey_MSGTYPE meshtastic_Config_SessionkeyConfig
+#define meshtastic_Config_payload_variant_device_ui_MSGTYPE meshtastic_DeviceUIConfig
#define meshtastic_Config_DeviceConfig_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UENUM, role, 1) \
diff --git a/src/mesh/generated/meshtastic/device_ui.pb.cpp b/src/mesh/generated/meshtastic/device_ui.pb.cpp
new file mode 100644
index 0000000000..6e0cf0cc8b
--- /dev/null
+++ b/src/mesh/generated/meshtastic/device_ui.pb.cpp
@@ -0,0 +1,22 @@
+/* Automatically generated nanopb constant definitions */
+/* Generated by nanopb-0.4.9 */
+
+#include "meshtastic/device_ui.pb.h"
+#if PB_PROTO_HEADER_VERSION != 40
+#error Regenerate this file with the current version of nanopb generator.
+#endif
+
+PB_BIND(meshtastic_DeviceUIConfig, meshtastic_DeviceUIConfig, AUTO)
+
+
+PB_BIND(meshtastic_NodeFilter, meshtastic_NodeFilter, AUTO)
+
+
+PB_BIND(meshtastic_NodeHighlight, meshtastic_NodeHighlight, AUTO)
+
+
+
+
+
+
+
diff --git a/src/mesh/generated/meshtastic/device_ui.pb.h b/src/mesh/generated/meshtastic/device_ui.pb.h
new file mode 100644
index 0000000000..469fe6f11f
--- /dev/null
+++ b/src/mesh/generated/meshtastic/device_ui.pb.h
@@ -0,0 +1,198 @@
+/* Automatically generated nanopb header */
+/* Generated by nanopb-0.4.9 */
+
+#ifndef PB_MESHTASTIC_MESHTASTIC_DEVICE_UI_PB_H_INCLUDED
+#define PB_MESHTASTIC_MESHTASTIC_DEVICE_UI_PB_H_INCLUDED
+#include
+
+#if PB_PROTO_HEADER_VERSION != 40
+#error Regenerate this file with the current version of nanopb generator.
+#endif
+
+/* Enum definitions */
+typedef enum _meshtastic_Theme {
+ /* Dark */
+ meshtastic_Theme_DARK = 0,
+ /* Light */
+ meshtastic_Theme_LIGHT = 1,
+ /* Red */
+ meshtastic_Theme_RED = 2
+} meshtastic_Theme;
+
+/* Localization */
+typedef enum _meshtastic_Language {
+ /* English */
+ meshtastic_Language_ENGLISH = 0,
+ /* French */
+ meshtastic_Language_FRENCH = 1,
+ /* German */
+ meshtastic_Language_GERMAN = 2,
+ /* Italian */
+ meshtastic_Language_ITALIAN = 3,
+ /* Portuguese */
+ meshtastic_Language_PORTUGUESE = 4,
+ /* Spanish */
+ meshtastic_Language_SPANISH = 5,
+ /* Swedish */
+ meshtastic_Language_SWEDISH = 6,
+ /* Finnish */
+ meshtastic_Language_FINNISH = 7,
+ /* Polish */
+ meshtastic_Language_POLISH = 8,
+ /* Turkish */
+ meshtastic_Language_TURKISH = 9
+} meshtastic_Language;
+
+/* Struct definitions */
+typedef struct _meshtastic_NodeFilter {
+ /* Filter unknown nodes */
+ bool unknown_switch;
+ /* Filter offline nodes */
+ bool offline_switch;
+ /* Filter nodes w/o public key */
+ bool public_key_switch;
+ /* Filter based on hops away */
+ int8_t hops_away;
+ /* Filter nodes w/o position */
+ bool position_switch;
+ /* Filter nodes by matching name string */
+ char node_name[16];
+} meshtastic_NodeFilter;
+
+typedef struct _meshtastic_NodeHighlight {
+ /* Hightlight nodes w/ active chat */
+ bool chat_switch;
+ /* Highlight nodes w/ position */
+ bool position_switch;
+ /* Highlight nodes w/ telemetry data */
+ bool telemetry_switch;
+ /* Highlight nodes w/ iaq data */
+ bool iaq_switch;
+ /* Highlight nodes by matching name string */
+ char node_name[16];
+} meshtastic_NodeHighlight;
+
+typedef struct _meshtastic_DeviceUIConfig {
+ /* TFT display brightness 1..255 */
+ uint8_t screen_brightness;
+ /* Screen timeout 0..900 */
+ uint16_t screen_timeout;
+ /* Screen lock enabled */
+ bool screen_lock;
+ /* Color theme */
+ meshtastic_Theme theme;
+ /* Audible message alert enabled */
+ bool alert_enabled;
+ /* Localization */
+ meshtastic_Language language;
+ /* Node list filter */
+ bool has_node_filter;
+ meshtastic_NodeFilter node_filter;
+ /* Node list highlightening */
+ bool has_node_highlight;
+ meshtastic_NodeHighlight node_highlight;
+} meshtastic_DeviceUIConfig;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Helper constants for enums */
+#define _meshtastic_Theme_MIN meshtastic_Theme_DARK
+#define _meshtastic_Theme_MAX meshtastic_Theme_RED
+#define _meshtastic_Theme_ARRAYSIZE ((meshtastic_Theme)(meshtastic_Theme_RED+1))
+
+#define _meshtastic_Language_MIN meshtastic_Language_ENGLISH
+#define _meshtastic_Language_MAX meshtastic_Language_TURKISH
+#define _meshtastic_Language_ARRAYSIZE ((meshtastic_Language)(meshtastic_Language_TURKISH+1))
+
+#define meshtastic_DeviceUIConfig_theme_ENUMTYPE meshtastic_Theme
+#define meshtastic_DeviceUIConfig_language_ENUMTYPE meshtastic_Language
+
+
+
+
+/* Initializer values for message structs */
+#define meshtastic_DeviceUIConfig_init_default {0, 0, 0, _meshtastic_Theme_MIN, 0, _meshtastic_Language_MIN, false, meshtastic_NodeFilter_init_default, false, meshtastic_NodeHighlight_init_default}
+#define meshtastic_NodeFilter_init_default {0, 0, 0, 0, 0, ""}
+#define meshtastic_NodeHighlight_init_default {0, 0, 0, 0, ""}
+#define meshtastic_DeviceUIConfig_init_zero {0, 0, 0, _meshtastic_Theme_MIN, 0, _meshtastic_Language_MIN, false, meshtastic_NodeFilter_init_zero, false, meshtastic_NodeHighlight_init_zero}
+#define meshtastic_NodeFilter_init_zero {0, 0, 0, 0, 0, ""}
+#define meshtastic_NodeHighlight_init_zero {0, 0, 0, 0, ""}
+
+/* Field tags (for use in manual encoding/decoding) */
+#define meshtastic_NodeFilter_unknown_switch_tag 1
+#define meshtastic_NodeFilter_offline_switch_tag 2
+#define meshtastic_NodeFilter_public_key_switch_tag 3
+#define meshtastic_NodeFilter_hops_away_tag 4
+#define meshtastic_NodeFilter_position_switch_tag 5
+#define meshtastic_NodeFilter_node_name_tag 6
+#define meshtastic_NodeHighlight_chat_switch_tag 1
+#define meshtastic_NodeHighlight_position_switch_tag 2
+#define meshtastic_NodeHighlight_telemetry_switch_tag 3
+#define meshtastic_NodeHighlight_iaq_switch_tag 4
+#define meshtastic_NodeHighlight_node_name_tag 5
+#define meshtastic_DeviceUIConfig_screen_brightness_tag 1
+#define meshtastic_DeviceUIConfig_screen_timeout_tag 2
+#define meshtastic_DeviceUIConfig_screen_lock_tag 3
+#define meshtastic_DeviceUIConfig_theme_tag 4
+#define meshtastic_DeviceUIConfig_alert_enabled_tag 5
+#define meshtastic_DeviceUIConfig_language_tag 6
+#define meshtastic_DeviceUIConfig_node_filter_tag 7
+#define meshtastic_DeviceUIConfig_node_highlight_tag 8
+
+/* Struct field encoding specification for nanopb */
+#define meshtastic_DeviceUIConfig_FIELDLIST(X, a) \
+X(a, STATIC, SINGULAR, UINT32, screen_brightness, 1) \
+X(a, STATIC, SINGULAR, UINT32, screen_timeout, 2) \
+X(a, STATIC, SINGULAR, BOOL, screen_lock, 3) \
+X(a, STATIC, SINGULAR, UENUM, theme, 4) \
+X(a, STATIC, SINGULAR, BOOL, alert_enabled, 5) \
+X(a, STATIC, SINGULAR, UENUM, language, 6) \
+X(a, STATIC, OPTIONAL, MESSAGE, node_filter, 7) \
+X(a, STATIC, OPTIONAL, MESSAGE, node_highlight, 8)
+#define meshtastic_DeviceUIConfig_CALLBACK NULL
+#define meshtastic_DeviceUIConfig_DEFAULT NULL
+#define meshtastic_DeviceUIConfig_node_filter_MSGTYPE meshtastic_NodeFilter
+#define meshtastic_DeviceUIConfig_node_highlight_MSGTYPE meshtastic_NodeHighlight
+
+#define meshtastic_NodeFilter_FIELDLIST(X, a) \
+X(a, STATIC, SINGULAR, BOOL, unknown_switch, 1) \
+X(a, STATIC, SINGULAR, BOOL, offline_switch, 2) \
+X(a, STATIC, SINGULAR, BOOL, public_key_switch, 3) \
+X(a, STATIC, SINGULAR, INT32, hops_away, 4) \
+X(a, STATIC, SINGULAR, BOOL, position_switch, 5) \
+X(a, STATIC, SINGULAR, STRING, node_name, 6)
+#define meshtastic_NodeFilter_CALLBACK NULL
+#define meshtastic_NodeFilter_DEFAULT NULL
+
+#define meshtastic_NodeHighlight_FIELDLIST(X, a) \
+X(a, STATIC, SINGULAR, BOOL, chat_switch, 1) \
+X(a, STATIC, SINGULAR, BOOL, position_switch, 2) \
+X(a, STATIC, SINGULAR, BOOL, telemetry_switch, 3) \
+X(a, STATIC, SINGULAR, BOOL, iaq_switch, 4) \
+X(a, STATIC, SINGULAR, STRING, node_name, 5)
+#define meshtastic_NodeHighlight_CALLBACK NULL
+#define meshtastic_NodeHighlight_DEFAULT NULL
+
+extern const pb_msgdesc_t meshtastic_DeviceUIConfig_msg;
+extern const pb_msgdesc_t meshtastic_NodeFilter_msg;
+extern const pb_msgdesc_t meshtastic_NodeHighlight_msg;
+
+/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
+#define meshtastic_DeviceUIConfig_fields &meshtastic_DeviceUIConfig_msg
+#define meshtastic_NodeFilter_fields &meshtastic_NodeFilter_msg
+#define meshtastic_NodeHighlight_fields &meshtastic_NodeHighlight_msg
+
+/* Maximum encoded size of messages (where known) */
+#define MESHTASTIC_MESHTASTIC_DEVICE_UI_PB_H_MAX_SIZE meshtastic_DeviceUIConfig_size
+#define meshtastic_DeviceUIConfig_size 80
+#define meshtastic_NodeFilter_size 36
+#define meshtastic_NodeHighlight_size 25
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif
diff --git a/src/mesh/generated/meshtastic/deviceonly.pb.cpp b/src/mesh/generated/meshtastic/deviceonly.pb.cpp
index 135634762f..92853f00dd 100644
--- a/src/mesh/generated/meshtastic/deviceonly.pb.cpp
+++ b/src/mesh/generated/meshtastic/deviceonly.pb.cpp
@@ -21,9 +21,4 @@ PB_BIND(meshtastic_DeviceState, meshtastic_DeviceState, 2)
PB_BIND(meshtastic_ChannelFile, meshtastic_ChannelFile, 2)
-PB_BIND(meshtastic_OEMStore, meshtastic_OEMStore, 2)
-
-
-
-
diff --git a/src/mesh/generated/meshtastic/deviceonly.pb.h b/src/mesh/generated/meshtastic/deviceonly.pb.h
index 2aa8fda8e4..a90e72244c 100644
--- a/src/mesh/generated/meshtastic/deviceonly.pb.h
+++ b/src/mesh/generated/meshtastic/deviceonly.pb.h
@@ -6,7 +6,6 @@
#include
#include
#include "meshtastic/channel.pb.h"
-#include "meshtastic/localonly.pb.h"
#include "meshtastic/mesh.pb.h"
#include "meshtastic/telemetry.pb.h"
#include "meshtastic/config.pb.h"
@@ -15,17 +14,6 @@
#error Regenerate this file with the current version of nanopb generator.
#endif
-/* Enum definitions */
-/* Font sizes for the device screen */
-typedef enum _meshtastic_ScreenFonts {
- /* TODO: REPLACE */
- meshtastic_ScreenFonts_FONT_SMALL = 0,
- /* TODO: REPLACE */
- meshtastic_ScreenFonts_FONT_MEDIUM = 1,
- /* TODO: REPLACE */
- meshtastic_ScreenFonts_FONT_LARGE = 2
-} meshtastic_ScreenFonts;
-
/* Struct definitions */
/* Position with static location information only for NodeDBLite */
typedef struct _meshtastic_PositionLite {
@@ -154,65 +142,22 @@ typedef struct _meshtastic_ChannelFile {
uint32_t version;
} meshtastic_ChannelFile;
-typedef PB_BYTES_ARRAY_T(2048) meshtastic_OEMStore_oem_icon_bits_t;
-typedef PB_BYTES_ARRAY_T(32) meshtastic_OEMStore_oem_aes_key_t;
-/* This can be used for customizing the firmware distribution. If populated,
- show a secondary bootup screen with custom logo and text for 2.5 seconds. */
-typedef struct _meshtastic_OEMStore {
- /* The Logo width in Px */
- uint32_t oem_icon_width;
- /* The Logo height in Px */
- uint32_t oem_icon_height;
- /* The Logo in XBM bytechar format */
- meshtastic_OEMStore_oem_icon_bits_t oem_icon_bits;
- /* Use this font for the OEM text. */
- meshtastic_ScreenFonts oem_font;
- /* Use this font for the OEM text. */
- char oem_text[40];
- /* The default device encryption key, 16 or 32 byte */
- meshtastic_OEMStore_oem_aes_key_t oem_aes_key;
- /* A Preset LocalConfig to apply during factory reset */
- bool has_oem_local_config;
- meshtastic_LocalConfig oem_local_config;
- /* A Preset LocalModuleConfig to apply during factory reset */
- bool has_oem_local_module_config;
- meshtastic_LocalModuleConfig oem_local_module_config;
-} meshtastic_OEMStore;
-
#ifdef __cplusplus
extern "C" {
#endif
-/* Helper constants for enums */
-#define _meshtastic_ScreenFonts_MIN meshtastic_ScreenFonts_FONT_SMALL
-#define _meshtastic_ScreenFonts_MAX meshtastic_ScreenFonts_FONT_LARGE
-#define _meshtastic_ScreenFonts_ARRAYSIZE ((meshtastic_ScreenFonts)(meshtastic_ScreenFonts_FONT_LARGE+1))
-
-#define meshtastic_PositionLite_location_source_ENUMTYPE meshtastic_Position_LocSource
-
-#define meshtastic_UserLite_hw_model_ENUMTYPE meshtastic_HardwareModel
-#define meshtastic_UserLite_role_ENUMTYPE meshtastic_Config_DeviceConfig_Role
-
-
-
-
-#define meshtastic_OEMStore_oem_font_ENUMTYPE meshtastic_ScreenFonts
-
-
/* Initializer values for message structs */
#define meshtastic_PositionLite_init_default {0, 0, 0, 0, _meshtastic_Position_LocSource_MIN}
#define meshtastic_UserLite_init_default {{0}, "", "", _meshtastic_HardwareModel_MIN, 0, _meshtastic_Config_DeviceConfig_Role_MIN, {0, {0}}}
#define meshtastic_NodeInfoLite_init_default {0, false, meshtastic_UserLite_init_default, false, meshtastic_PositionLite_init_default, 0, 0, false, meshtastic_DeviceMetrics_init_default, 0, 0, false, 0, 0}
#define meshtastic_DeviceState_init_default {false, meshtastic_MyNodeInfo_init_default, false, meshtastic_User_init_default, 0, {meshtastic_MeshPacket_init_default}, false, meshtastic_MeshPacket_init_default, 0, 0, 0, false, meshtastic_MeshPacket_init_default, 0, {meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default}, {0}}
#define meshtastic_ChannelFile_init_default {0, {meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default}, 0}
-#define meshtastic_OEMStore_init_default {0, 0, {0, {0}}, _meshtastic_ScreenFonts_MIN, "", {0, {0}}, false, meshtastic_LocalConfig_init_default, false, meshtastic_LocalModuleConfig_init_default}
#define meshtastic_PositionLite_init_zero {0, 0, 0, 0, _meshtastic_Position_LocSource_MIN}
#define meshtastic_UserLite_init_zero {{0}, "", "", _meshtastic_HardwareModel_MIN, 0, _meshtastic_Config_DeviceConfig_Role_MIN, {0, {0}}}
#define meshtastic_NodeInfoLite_init_zero {0, false, meshtastic_UserLite_init_zero, false, meshtastic_PositionLite_init_zero, 0, 0, false, meshtastic_DeviceMetrics_init_zero, 0, 0, false, 0, 0}
#define meshtastic_DeviceState_init_zero {false, meshtastic_MyNodeInfo_init_zero, false, meshtastic_User_init_zero, 0, {meshtastic_MeshPacket_init_zero}, false, meshtastic_MeshPacket_init_zero, 0, 0, 0, false, meshtastic_MeshPacket_init_zero, 0, {meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero}, {0}}
#define meshtastic_ChannelFile_init_zero {0, {meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero}, 0}
-#define meshtastic_OEMStore_init_zero {0, 0, {0, {0}}, _meshtastic_ScreenFonts_MIN, "", {0, {0}}, false, meshtastic_LocalConfig_init_zero, false, meshtastic_LocalModuleConfig_init_zero}
/* Field tags (for use in manual encoding/decoding) */
#define meshtastic_PositionLite_latitude_i_tag 1
@@ -249,14 +194,6 @@ extern "C" {
#define meshtastic_DeviceState_node_db_lite_tag 14
#define meshtastic_ChannelFile_channels_tag 1
#define meshtastic_ChannelFile_version_tag 2
-#define meshtastic_OEMStore_oem_icon_width_tag 1
-#define meshtastic_OEMStore_oem_icon_height_tag 2
-#define meshtastic_OEMStore_oem_icon_bits_tag 3
-#define meshtastic_OEMStore_oem_font_tag 4
-#define meshtastic_OEMStore_oem_text_tag 5
-#define meshtastic_OEMStore_oem_aes_key_tag 6
-#define meshtastic_OEMStore_oem_local_config_tag 7
-#define meshtastic_OEMStore_oem_local_module_config_tag 8
/* Struct field encoding specification for nanopb */
#define meshtastic_PositionLite_FIELDLIST(X, a) \
@@ -325,26 +262,11 @@ X(a, STATIC, SINGULAR, UINT32, version, 2)
#define meshtastic_ChannelFile_DEFAULT NULL
#define meshtastic_ChannelFile_channels_MSGTYPE meshtastic_Channel
-#define meshtastic_OEMStore_FIELDLIST(X, a) \
-X(a, STATIC, SINGULAR, UINT32, oem_icon_width, 1) \
-X(a, STATIC, SINGULAR, UINT32, oem_icon_height, 2) \
-X(a, STATIC, SINGULAR, BYTES, oem_icon_bits, 3) \
-X(a, STATIC, SINGULAR, UENUM, oem_font, 4) \
-X(a, STATIC, SINGULAR, STRING, oem_text, 5) \
-X(a, STATIC, SINGULAR, BYTES, oem_aes_key, 6) \
-X(a, STATIC, OPTIONAL, MESSAGE, oem_local_config, 7) \
-X(a, STATIC, OPTIONAL, MESSAGE, oem_local_module_config, 8)
-#define meshtastic_OEMStore_CALLBACK NULL
-#define meshtastic_OEMStore_DEFAULT NULL
-#define meshtastic_OEMStore_oem_local_config_MSGTYPE meshtastic_LocalConfig
-#define meshtastic_OEMStore_oem_local_module_config_MSGTYPE meshtastic_LocalModuleConfig
-
extern const pb_msgdesc_t meshtastic_PositionLite_msg;
extern const pb_msgdesc_t meshtastic_UserLite_msg;
extern const pb_msgdesc_t meshtastic_NodeInfoLite_msg;
extern const pb_msgdesc_t meshtastic_DeviceState_msg;
extern const pb_msgdesc_t meshtastic_ChannelFile_msg;
-extern const pb_msgdesc_t meshtastic_OEMStore_msg;
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
#define meshtastic_PositionLite_fields &meshtastic_PositionLite_msg
@@ -352,14 +274,12 @@ extern const pb_msgdesc_t meshtastic_OEMStore_msg;
#define meshtastic_NodeInfoLite_fields &meshtastic_NodeInfoLite_msg
#define meshtastic_DeviceState_fields &meshtastic_DeviceState_msg
#define meshtastic_ChannelFile_fields &meshtastic_ChannelFile_msg
-#define meshtastic_OEMStore_fields &meshtastic_OEMStore_msg
/* Maximum encoded size of messages (where known) */
/* meshtastic_DeviceState_size depends on runtime parameters */
-#define MESHTASTIC_MESHTASTIC_DEVICEONLY_PB_H_MAX_SIZE meshtastic_OEMStore_size
+#define MESHTASTIC_MESHTASTIC_DEVICEONLY_PB_H_MAX_SIZE meshtastic_ChannelFile_size
#define meshtastic_ChannelFile_size 718
#define meshtastic_NodeInfoLite_size 183
-#define meshtastic_OEMStore_size 3578
#define meshtastic_PositionLite_size 28
#define meshtastic_UserLite_size 96
diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h
index fb154e9d55..17254354c1 100644
--- a/src/mesh/generated/meshtastic/mesh.pb.h
+++ b/src/mesh/generated/meshtastic/mesh.pb.h
@@ -10,6 +10,7 @@
#include "meshtastic/portnums.pb.h"
#include "meshtastic/telemetry.pb.h"
#include "meshtastic/xmodem.pb.h"
+#include "meshtastic/device_ui.pb.h"
#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
@@ -764,6 +765,7 @@ typedef struct _meshtastic_NodeInfo {
bool is_favorite;
} meshtastic_NodeInfo;
+typedef PB_BYTES_ARRAY_T(16) meshtastic_MyNodeInfo_device_id_t;
/* Unique local debugging info for this node
Note: we don't include position or the user info, because that will come in the
Sent to the phone in response to WantNodes. */
@@ -777,6 +779,8 @@ typedef struct _meshtastic_MyNodeInfo {
/* The minimum app version that can talk to this device.
Phone/PC apps should compare this to their build number and if too low tell the user they must update their app */
uint32_t min_app_version;
+ /* Unique hardware identifier for this device */
+ meshtastic_MyNodeInfo_device_id_t device_id;
} meshtastic_MyNodeInfo;
/* Debug output from the device.
@@ -940,6 +944,8 @@ typedef struct _meshtastic_FromRadio {
meshtastic_FileInfo fileInfo;
/* Notification message to the client */
meshtastic_ClientNotification clientNotification;
+ /* Persistent data for device-ui */
+ meshtastic_DeviceUIConfig deviceuiConfig;
};
} meshtastic_FromRadio;
@@ -1109,7 +1115,7 @@ extern "C" {
#define meshtastic_MqttClientProxyMessage_init_default {"", 0, {{0, {0}}}, 0}
#define meshtastic_MeshPacket_init_default {0, 0, 0, 0, {meshtastic_Data_init_default}, 0, 0, 0, 0, 0, _meshtastic_MeshPacket_Priority_MIN, 0, _meshtastic_MeshPacket_Delayed_MIN, 0, 0, {0, {0}}, 0}
#define meshtastic_NodeInfo_init_default {0, false, meshtastic_User_init_default, false, meshtastic_Position_init_default, 0, 0, false, meshtastic_DeviceMetrics_init_default, 0, 0, false, 0, 0}
-#define meshtastic_MyNodeInfo_init_default {0, 0, 0}
+#define meshtastic_MyNodeInfo_init_default {0, 0, 0, {0, {0}}}
#define meshtastic_LogRecord_init_default {"", 0, "", _meshtastic_LogRecord_Level_MIN}
#define meshtastic_QueueStatus_init_default {0, 0, 0, 0}
#define meshtastic_FromRadio_init_default {0, 0, {meshtastic_MeshPacket_init_default}}
@@ -1134,7 +1140,7 @@ extern "C" {
#define meshtastic_MqttClientProxyMessage_init_zero {"", 0, {{0, {0}}}, 0}
#define meshtastic_MeshPacket_init_zero {0, 0, 0, 0, {meshtastic_Data_init_zero}, 0, 0, 0, 0, 0, _meshtastic_MeshPacket_Priority_MIN, 0, _meshtastic_MeshPacket_Delayed_MIN, 0, 0, {0, {0}}, 0}
#define meshtastic_NodeInfo_init_zero {0, false, meshtastic_User_init_zero, false, meshtastic_Position_init_zero, 0, 0, false, meshtastic_DeviceMetrics_init_zero, 0, 0, false, 0, 0}
-#define meshtastic_MyNodeInfo_init_zero {0, 0, 0}
+#define meshtastic_MyNodeInfo_init_zero {0, 0, 0, {0, {0}}}
#define meshtastic_LogRecord_init_zero {"", 0, "", _meshtastic_LogRecord_Level_MIN}
#define meshtastic_QueueStatus_init_zero {0, 0, 0, 0}
#define meshtastic_FromRadio_init_zero {0, 0, {meshtastic_MeshPacket_init_zero}}
@@ -1241,6 +1247,7 @@ extern "C" {
#define meshtastic_MyNodeInfo_my_node_num_tag 1
#define meshtastic_MyNodeInfo_reboot_count_tag 8
#define meshtastic_MyNodeInfo_min_app_version_tag 11
+#define meshtastic_MyNodeInfo_device_id_tag 12
#define meshtastic_LogRecord_message_tag 1
#define meshtastic_LogRecord_time_tag 2
#define meshtastic_LogRecord_source_tag 3
@@ -1292,6 +1299,7 @@ extern "C" {
#define meshtastic_FromRadio_mqttClientProxyMessage_tag 14
#define meshtastic_FromRadio_fileInfo_tag 15
#define meshtastic_FromRadio_clientNotification_tag 16
+#define meshtastic_FromRadio_deviceuiConfig_tag 17
#define meshtastic_ToRadio_packet_tag 1
#define meshtastic_ToRadio_want_config_id_tag 3
#define meshtastic_ToRadio_disconnect_tag 4
@@ -1442,7 +1450,8 @@ X(a, STATIC, SINGULAR, BOOL, is_favorite, 10)
#define meshtastic_MyNodeInfo_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, my_node_num, 1) \
X(a, STATIC, SINGULAR, UINT32, reboot_count, 8) \
-X(a, STATIC, SINGULAR, UINT32, min_app_version, 11)
+X(a, STATIC, SINGULAR, UINT32, min_app_version, 11) \
+X(a, STATIC, SINGULAR, BYTES, device_id, 12)
#define meshtastic_MyNodeInfo_CALLBACK NULL
#define meshtastic_MyNodeInfo_DEFAULT NULL
@@ -1478,7 +1487,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,xmodemPacket,xmodemPacket),
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,metadata,metadata), 13) \
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,mqttClientProxyMessage,mqttClientProxyMessage), 14) \
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,fileInfo,fileInfo), 15) \
-X(a, STATIC, ONEOF, MESSAGE, (payload_variant,clientNotification,clientNotification), 16)
+X(a, STATIC, ONEOF, MESSAGE, (payload_variant,clientNotification,clientNotification), 16) \
+X(a, STATIC, ONEOF, MESSAGE, (payload_variant,deviceuiConfig,deviceuiConfig), 17)
#define meshtastic_FromRadio_CALLBACK NULL
#define meshtastic_FromRadio_DEFAULT NULL
#define meshtastic_FromRadio_payload_variant_packet_MSGTYPE meshtastic_MeshPacket
@@ -1494,6 +1504,7 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,clientNotification,clientNot
#define meshtastic_FromRadio_payload_variant_mqttClientProxyMessage_MSGTYPE meshtastic_MqttClientProxyMessage
#define meshtastic_FromRadio_payload_variant_fileInfo_MSGTYPE meshtastic_FileInfo
#define meshtastic_FromRadio_payload_variant_clientNotification_MSGTYPE meshtastic_ClientNotification
+#define meshtastic_FromRadio_payload_variant_deviceuiConfig_MSGTYPE meshtastic_DeviceUIConfig
#define meshtastic_ClientNotification_FIELDLIST(X, a) \
X(a, STATIC, OPTIONAL, UINT32, reply_id, 1) \
@@ -1663,7 +1674,7 @@ extern const pb_msgdesc_t meshtastic_ChunkedPayloadResponse_msg;
#define meshtastic_LogRecord_size 426
#define meshtastic_MeshPacket_size 367
#define meshtastic_MqttClientProxyMessage_size 501
-#define meshtastic_MyNodeInfo_size 18
+#define meshtastic_MyNodeInfo_size 36
#define meshtastic_NeighborInfo_size 258
#define meshtastic_Neighbor_size 22
#define meshtastic_NodeInfo_size 317
diff --git a/src/mesh/generated/meshtastic/rtttl.pb.h b/src/mesh/generated/meshtastic/rtttl.pb.h
index 2b7e35f116..0572265f7a 100644
--- a/src/mesh/generated/meshtastic/rtttl.pb.h
+++ b/src/mesh/generated/meshtastic/rtttl.pb.h
@@ -13,7 +13,7 @@
/* Canned message module configuration. */
typedef struct _meshtastic_RTTTLConfig {
/* Ringtone for PWM Buzzer in RTTTL Format. */
- char ringtone[230];
+ char ringtone[231];
} meshtastic_RTTTLConfig;
@@ -41,7 +41,7 @@ extern const pb_msgdesc_t meshtastic_RTTTLConfig_msg;
/* Maximum encoded size of messages (where known) */
#define MESHTASTIC_MESHTASTIC_RTTTL_PB_H_MAX_SIZE meshtastic_RTTTLConfig_size
-#define meshtastic_RTTTLConfig_size 232
+#define meshtastic_RTTTLConfig_size 233
#ifdef __cplusplus
} /* extern "C" */
diff --git a/src/mesh/generated/meshtastic/telemetry.pb.h b/src/mesh/generated/meshtastic/telemetry.pb.h
index a33988129e..309c01dc7e 100644
--- a/src/mesh/generated/meshtastic/telemetry.pb.h
+++ b/src/mesh/generated/meshtastic/telemetry.pb.h
@@ -74,8 +74,10 @@ typedef enum _meshtastic_TelemetrySensorType {
meshtastic_TelemetrySensorType_CUSTOM_SENSOR = 29,
/* MAX30102 Pulse Oximeter and Heart-Rate Sensor */
meshtastic_TelemetrySensorType_MAX30102 = 30,
- /* MLX90614 non-contact IR temperature sensor. */
- meshtastic_TelemetrySensorType_MLX90614 = 31
+ /* MLX90614 non-contact IR temperature sensor */
+ meshtastic_TelemetrySensorType_MLX90614 = 31,
+ /* SCD40/SCD41 CO2, humidity, temperature sensor */
+ meshtastic_TelemetrySensorType_SCD4X = 32
} meshtastic_TelemetrySensorType;
/* Struct definitions */
@@ -215,6 +217,9 @@ typedef struct _meshtastic_AirQualityMetrics {
/* 10.0um Particle Count */
bool has_particles_100um;
uint32_t particles_100um;
+ /* 10.0um Particle Count */
+ bool has_co2;
+ uint32_t co2;
} meshtastic_AirQualityMetrics;
/* Local device mesh statistics */
@@ -294,8 +299,8 @@ extern "C" {
/* Helper constants for enums */
#define _meshtastic_TelemetrySensorType_MIN meshtastic_TelemetrySensorType_SENSOR_UNSET
-#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_MLX90614
-#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_MLX90614+1))
+#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_SCD4X
+#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_SCD4X+1))
@@ -310,7 +315,7 @@ extern "C" {
#define meshtastic_DeviceMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0}
#define meshtastic_EnvironmentMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0}
#define meshtastic_PowerMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0}
-#define meshtastic_AirQualityMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0}
+#define meshtastic_AirQualityMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0}
#define meshtastic_LocalStats_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
#define meshtastic_HealthMetrics_init_default {false, 0, false, 0, false, 0}
#define meshtastic_Telemetry_init_default {0, 0, {meshtastic_DeviceMetrics_init_default}}
@@ -318,7 +323,7 @@ extern "C" {
#define meshtastic_DeviceMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0}
#define meshtastic_EnvironmentMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0}
#define meshtastic_PowerMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0}
-#define meshtastic_AirQualityMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0}
+#define meshtastic_AirQualityMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0}
#define meshtastic_LocalStats_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
#define meshtastic_HealthMetrics_init_zero {false, 0, false, 0, false, 0}
#define meshtastic_Telemetry_init_zero {0, 0, {meshtastic_DeviceMetrics_init_zero}}
@@ -365,6 +370,7 @@ extern "C" {
#define meshtastic_AirQualityMetrics_particles_25um_tag 10
#define meshtastic_AirQualityMetrics_particles_50um_tag 11
#define meshtastic_AirQualityMetrics_particles_100um_tag 12
+#define meshtastic_AirQualityMetrics_co2_tag 13
#define meshtastic_LocalStats_uptime_seconds_tag 1
#define meshtastic_LocalStats_channel_utilization_tag 2
#define meshtastic_LocalStats_air_util_tx_tag 3
@@ -442,7 +448,8 @@ X(a, STATIC, OPTIONAL, UINT32, particles_05um, 8) \
X(a, STATIC, OPTIONAL, UINT32, particles_10um, 9) \
X(a, STATIC, OPTIONAL, UINT32, particles_25um, 10) \
X(a, STATIC, OPTIONAL, UINT32, particles_50um, 11) \
-X(a, STATIC, OPTIONAL, UINT32, particles_100um, 12)
+X(a, STATIC, OPTIONAL, UINT32, particles_100um, 12) \
+X(a, STATIC, OPTIONAL, UINT32, co2, 13)
#define meshtastic_AirQualityMetrics_CALLBACK NULL
#define meshtastic_AirQualityMetrics_DEFAULT NULL
@@ -512,7 +519,7 @@ extern const pb_msgdesc_t meshtastic_Nau7802Config_msg;
/* Maximum encoded size of messages (where known) */
#define MESHTASTIC_MESHTASTIC_TELEMETRY_PB_H_MAX_SIZE meshtastic_Telemetry_size
-#define meshtastic_AirQualityMetrics_size 72
+#define meshtastic_AirQualityMetrics_size 78
#define meshtastic_DeviceMetrics_size 27
#define meshtastic_EnvironmentMetrics_size 85
#define meshtastic_HealthMetrics_size 11
diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp
index c5ea86429e..8535a335fc 100644
--- a/src/mesh/http/ContentHandler.cpp
+++ b/src/mesh/http/ContentHandler.cpp
@@ -143,7 +143,7 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
void handleAPIv1FromRadio(HTTPRequest *req, HTTPResponse *res)
{
- LOG_DEBUG("webAPI handleAPIv1FromRadio\n");
+ LOG_DEBUG("webAPI handleAPIv1FromRadio");
/*
For documentation, see:
@@ -188,12 +188,12 @@ void handleAPIv1FromRadio(HTTPRequest *req, HTTPResponse *res)
res->write(txBuf, len);
}
- LOG_DEBUG("webAPI handleAPIv1FromRadio, len %d\n", len);
+ LOG_DEBUG("webAPI handleAPIv1FromRadio, len %d", len);
}
void handleAPIv1ToRadio(HTTPRequest *req, HTTPResponse *res)
{
- LOG_DEBUG("webAPI handleAPIv1ToRadio\n");
+ LOG_DEBUG("webAPI handleAPIv1ToRadio");
/*
For documentation, see:
@@ -216,11 +216,11 @@ void handleAPIv1ToRadio(HTTPRequest *req, HTTPResponse *res)
byte buffer[MAX_TO_FROM_RADIO_SIZE];
size_t s = req->readBytes(buffer, MAX_TO_FROM_RADIO_SIZE);
- LOG_DEBUG("Received %d bytes from PUT request\n", s);
+ LOG_DEBUG("Received %d bytes from PUT request", s);
webAPI.handleToRadio(buffer, s);
res->write(buffer, s);
- LOG_DEBUG("webAPI handleAPIv1ToRadio\n");
+ LOG_DEBUG("webAPI handleAPIv1ToRadio");
}
void htmlDeleteDir(const char *dirname)
@@ -243,7 +243,7 @@ void htmlDeleteDir(const char *dirname)
String fileName = String(file.name());
file.flush();
file.close();
- LOG_DEBUG(" %s\n", fileName.c_str());
+ LOG_DEBUG(" %s", fileName.c_str());
FSCom.remove(fileName);
}
file = root.openNextFile();
@@ -341,7 +341,7 @@ void handleFsDeleteStatic(HTTPRequest *req, HTTPResponse *res)
if (params->getQueryParameter("delete", paramValDelete)) {
std::string pathDelete = "/" + paramValDelete;
if (FSCom.remove(pathDelete.c_str())) {
- LOG_INFO("%s\n", pathDelete.c_str());
+ LOG_INFO("%s", pathDelete.c_str());
JSONObject jsonObjOuter;
jsonObjOuter["status"] = new JSONValue("ok");
JSONValue *value = new JSONValue(jsonObjOuter);
@@ -349,7 +349,7 @@ void handleFsDeleteStatic(HTTPRequest *req, HTTPResponse *res)
delete value;
return;
} else {
- LOG_INFO("%s\n", pathDelete.c_str());
+ LOG_INFO("%s", pathDelete.c_str());
JSONObject jsonObjOuter;
jsonObjOuter["status"] = new JSONValue("Error");
JSONValue *value = new JSONValue(jsonObjOuter);
@@ -385,13 +385,13 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res)
if (FSCom.exists(filename.c_str())) {
file = FSCom.open(filename.c_str());
if (!file.available()) {
- LOG_WARN("File not available - %s\n", filename.c_str());
+ LOG_WARN("File not available - %s", filename.c_str());
}
} else if (FSCom.exists(filenameGzip.c_str())) {
file = FSCom.open(filenameGzip.c_str());
res->setHeader("Content-Encoding", "gzip");
if (!file.available()) {
- LOG_WARN("File not available - %s\n", filenameGzip.c_str());
+ LOG_WARN("File not available - %s", filenameGzip.c_str());
}
} else {
has_set_content_type = true;
@@ -399,7 +399,7 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res)
file = FSCom.open(filenameGzip.c_str());
res->setHeader("Content-Type", "text/html");
if (!file.available()) {
- LOG_WARN("File not available - %s\n", filenameGzip.c_str());
+ LOG_WARN("File not available - %s", filenameGzip.c_str());
res->println("Web server is running.
The content you are looking for can't be found. Please see: FAQ.
admin");
@@ -441,7 +441,7 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res)
return;
} else {
- LOG_ERROR("This should not have happened...\n");
+ LOG_ERROR("This should not have happened...");
res->println("ERROR: This should not have happened...");
}
}
@@ -449,7 +449,7 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res)
void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
{
- LOG_DEBUG("Form Upload - Disabling keep-alive\n");
+ LOG_DEBUG("Form Upload - Disabling keep-alive");
res->setHeader("Connection", "close");
// First, we need to check the encoding of the form that we have received.
@@ -457,7 +457,7 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
// Then we select the body parser based on the encoding.
// Actually we do this only for documentary purposes, we know the form is going
// to be multipart/form-data.
- LOG_DEBUG("Form Upload - Creating body parser reference\n");
+ LOG_DEBUG("Form Upload - Creating body parser reference");
HTTPBodyParser *parser;
std::string contentType = req->getHeader("Content-Type");
@@ -473,10 +473,10 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
// Now, we can decide based on the content type:
if (contentType == "multipart/form-data") {
- LOG_DEBUG("Form Upload - multipart/form-data\n");
+ LOG_DEBUG("Form Upload - multipart/form-data");
parser = new HTTPMultipartBodyParser(req);
} else {
- LOG_DEBUG("Unknown POST Content-Type: %s\n", contentType.c_str());
+ LOG_DEBUG("Unknown POST Content-Type: %s", contentType.c_str());
return;
}
@@ -503,19 +503,19 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
std::string filename = parser->getFieldFilename();
std::string mimeType = parser->getFieldMimeType();
// We log all three values, so that you can observe the upload on the serial monitor:
- LOG_DEBUG("handleFormUpload: field name='%s', filename='%s', mimetype='%s'\n", name.c_str(), filename.c_str(),
+ LOG_DEBUG("handleFormUpload: field name='%s', filename='%s', mimetype='%s'", name.c_str(), filename.c_str(),
mimeType.c_str());
// Double check that it is what we expect
if (name != "file") {
- LOG_DEBUG("Skipping unexpected field\n");
+ LOG_DEBUG("Skipping unexpected field");
res->println("
No file found.
");
return;
}
// Double check that it is what we expect
if (filename == "") {
- LOG_DEBUG("Skipping unexpected field\n");
+ LOG_DEBUG("Skipping unexpected field");
res->println("
No file found.
");
return;
}
@@ -536,7 +536,7 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
byte buf[512];
size_t readLength = parser->read(buf, 512);
- // LOG_DEBUG("\n\nreadLength - %i\n", readLength);
+ // LOG_DEBUG("readLength - %i", readLength);
// Abort the transfer if there is less than 50k space left on the filesystem.
if (FSCom.totalBytes() - FSCom.usedBytes() < 51200) {
@@ -553,7 +553,7 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
// if (readLength) {
file.write(buf, readLength);
fileLength += readLength;
- LOG_DEBUG("File Length %i\n", fileLength);
+ LOG_DEBUG("File Length %i", fileLength);
//}
}
// enableLoopWDT();
@@ -676,7 +676,7 @@ void handleReport(HTTPRequest *req, HTTPResponse *res)
*/
void handleHotspot(HTTPRequest *req, HTTPResponse *res)
{
- LOG_INFO("Hotspot Request\n");
+ LOG_INFO("Hotspot Request");
/*
If we don't do a redirect, be sure to return a "Success" message
@@ -690,7 +690,7 @@ void handleHotspot(HTTPRequest *req, HTTPResponse *res)
res->setHeader("Access-Control-Allow-Methods", "GET");
// res->println("");
- res->println("\n");
+ res->println("");
}
void handleDeleteFsContent(HTTPRequest *req, HTTPResponse *res)
@@ -699,14 +699,14 @@ void handleDeleteFsContent(HTTPRequest *req, HTTPResponse *res)
res->setHeader("Access-Control-Allow-Origin", "*");
res->setHeader("Access-Control-Allow-Methods", "GET");
- res->println("
Meshtastic
\n");
+ res->println("
Meshtastic
");
res->println("Deleting Content in /static/*");
- LOG_INFO("Deleting files from /static/* : \n");
+ LOG_INFO("Deleting files from /static/* : ");
htmlDeleteDir("/static");
- res->println("