");
+ res->println("");
+ res->println("Be patient!");
- res->println("
Back to admin\n");
+ res->println("
Back to admin");
}
void handleRestart(HTTPRequest *req, HTTPResponse *res)
@@ -773,10 +782,10 @@ void handleRestart(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("Restarting");
- LOG_DEBUG("Restarted on HTTP(s) Request\n");
+ LOG_DEBUG("Restarted on HTTP(s) Request");
webServerThread->requestRestart = (millis() / 1000) + 5;
}
diff --git a/src/mesh/http/WebServer.cpp b/src/mesh/http/WebServer.cpp
index fc8535257..d9856e157 100644
--- a/src/mesh/http/WebServer.cpp
+++ b/src/mesh/http/WebServer.cpp
@@ -69,19 +69,19 @@ static void taskCreateCert(void *parameter)
#if 0
// Delete the saved certs (used in debugging)
- LOG_DEBUG("Deleting any saved SSL keys ...\n");
+ LOG_DEBUG("Delete any saved SSL keys");
// prefs.clear();
prefs.remove("PK");
prefs.remove("cert");
#endif
- LOG_INFO("Checking if we have a previously saved SSL Certificate.\n");
+ LOG_INFO("Checking if we have a saved SSL Certificate");
size_t pkLen = prefs.getBytesLength("PK");
size_t certLen = prefs.getBytesLength("cert");
if (pkLen && certLen) {
- LOG_INFO("Existing SSL Certificate found!\n");
+ LOG_INFO("Existing SSL Certificate found!");
uint8_t *pkBuffer = new uint8_t[pkLen];
prefs.getBytes("PK", pkBuffer, pkLen);
@@ -91,11 +91,11 @@ static void taskCreateCert(void *parameter)
cert = new SSLCert(certBuffer, certLen, pkBuffer, pkLen);
- LOG_DEBUG("Retrieved Private Key: %d Bytes\n", cert->getPKLength());
- LOG_DEBUG("Retrieved Certificate: %d Bytes\n", cert->getCertLength());
+ LOG_DEBUG("Retrieved Private Key: %d Bytes", cert->getPKLength());
+ LOG_DEBUG("Retrieved Certificate: %d Bytes", cert->getCertLength());
} else {
- LOG_INFO("Creating the certificate. This may take a while. Please wait...\n");
+ LOG_INFO("Creating the certificate. This may take a while. Please wait");
yield();
cert = new SSLCert();
yield();
@@ -104,13 +104,13 @@ static void taskCreateCert(void *parameter)
yield();
if (createCertResult != 0) {
- LOG_ERROR("Creating the certificate failed\n");
+ LOG_ERROR("Creating the certificate failed");
} else {
- LOG_INFO("Creating the certificate was successful\n");
+ LOG_INFO("Creating the certificate was successful");
- LOG_DEBUG("Created Private Key: %d Bytes\n", cert->getPKLength());
+ LOG_DEBUG("Created Private Key: %d Bytes", cert->getPKLength());
- LOG_DEBUG("Created Certificate: %d Bytes\n", cert->getCertLength());
+ LOG_DEBUG("Created Certificate: %d Bytes", cert->getCertLength());
prefs.putBytes("PK", (uint8_t *)cert->getPKData(), cert->getPKLength());
prefs.putBytes("cert", (uint8_t *)cert->getCertData(), cert->getCertLength());
@@ -139,7 +139,7 @@ void createSSLCert()
16, /* Priority of the task. */
NULL); /* Task handle. */
- LOG_DEBUG("Waiting for SSL Cert to be generated.\n");
+ LOG_DEBUG("Waiting for SSL Cert to be generated");
while (!isCertReady) {
if ((millis() / 500) % 2) {
if (runLoop) {
@@ -158,13 +158,13 @@ void createSSLCert()
runLoop = true;
}
}
- LOG_INFO("SSL Cert Ready!\n");
+ LOG_INFO("SSL Cert Ready!");
}
}
WebServerThread *webServerThread;
-WebServerThread::WebServerThread() : concurrency::OSThread("WebServerThread")
+WebServerThread::WebServerThread() : concurrency::OSThread("WebServer")
{
if (!config.network.wifi_enabled) {
disable();
@@ -189,7 +189,7 @@ int32_t WebServerThread::runOnce()
void initWebServer()
{
- LOG_DEBUG("Initializing Web Server ...\n");
+ LOG_DEBUG("Init Web Server");
// We can now use the new certificate to setup our server as usual.
secureServer = new HTTPSServer(cert);
@@ -198,16 +198,16 @@ void initWebServer()
registerHandlers(insecureServer, secureServer);
if (secureServer) {
- LOG_INFO("Starting Secure Web Server...\n");
+ LOG_INFO("Start Secure Web Server");
secureServer->start();
}
- LOG_INFO("Starting Insecure Web Server...\n");
+ LOG_INFO("Start Insecure Web Server");
insecureServer->start();
if (insecureServer->isRunning()) {
- LOG_INFO("Web Servers Ready! :-) \n");
+ LOG_INFO("Web Servers Ready! :-) ");
isWebServerReady = true;
} else {
- LOG_ERROR("Web Servers Failed! ;-( \n");
+ LOG_ERROR("Web Servers Failed! ;-( ");
}
}
-#endif
\ No newline at end of file
+#endif
diff --git a/src/mesh/mesh-pb-constants.cpp b/src/mesh/mesh-pb-constants.cpp
index 5b5d669cc..deb93d0a6 100644
--- a/src/mesh/mesh-pb-constants.cpp
+++ b/src/mesh/mesh-pb-constants.cpp
@@ -3,7 +3,6 @@
#include "FSCommon.h"
#include "mesh-pb-constants.h"
#include
-#include
#include
#include
@@ -13,9 +12,7 @@ size_t pb_encode_to_bytes(uint8_t *destbuf, size_t destbufsize, const pb_msgdesc
{
pb_ostream_t stream = pb_ostream_from_buffer(destbuf, destbufsize);
if (!pb_encode(&stream, fields, src_struct)) {
- LOG_ERROR("Panic: can't encode protobuf reason='%s'\n", PB_GET_ERROR(&stream));
- assert(
- 0); // If this assert fails it probably means you made a field too large for the max limits specified in mesh.options
+ LOG_ERROR("Panic: can't encode protobuf reason='%s'", PB_GET_ERROR(&stream));
return 0;
} else {
return stream.bytes_written;
@@ -27,7 +24,7 @@ bool pb_decode_from_bytes(const uint8_t *srcbuf, size_t srcbufsize, const pb_msg
{
pb_istream_t stream = pb_istream_from_buffer(srcbuf, srcbufsize);
if (!pb_decode(&stream, fields, dest_struct)) {
- LOG_ERROR("Can't decode protobuf reason='%s', pb_msgdesc %p\n", PB_GET_ERROR(&stream), fields);
+ LOG_ERROR("Can't decode protobuf reason='%s', pb_msgdesc %p", PB_GET_ERROR(&stream), fields);
return false;
} else {
return true;
@@ -59,7 +56,7 @@ bool readcb(pb_istream_t *stream, uint8_t *buf, size_t count)
bool writecb(pb_ostream_t *stream, const uint8_t *buf, size_t count)
{
auto file = (Print *)stream->state;
- // LOG_DEBUG("writing %d bytes to protobuf file\n", count);
+ // LOG_DEBUG("writing %d bytes to protobuf file", count);
return file->write(buf, count) == count;
}
#endif
@@ -71,4 +68,4 @@ bool is_in_helper(uint32_t n, const uint32_t *array, pb_size_t count)
return true;
return false;
-}
\ No newline at end of file
+}
diff --git a/src/mesh/mesh-pb-constants.h b/src/mesh/mesh-pb-constants.h
index f91c48560..039b36d8d 100644
--- a/src/mesh/mesh-pb-constants.h
+++ b/src/mesh/mesh-pb-constants.h
@@ -23,6 +23,8 @@
#define MAX_NUM_NODES 100
#endif
+#define MAX_NUM_NODES_FS 100
+
/// Max number of channels allowed
#define MAX_NUM_CHANNELS (member_size(meshtastic_ChannelFile, channels) / member_size(meshtastic_ChannelFile, channels[0]))
diff --git a/src/mesh/raspihttp/PiWebServer.cpp b/src/mesh/raspihttp/PiWebServer.cpp
index d7e596759..846d70723 100644
--- a/src/mesh/raspihttp/PiWebServer.cpp
+++ b/src/mesh/raspihttp/PiWebServer.cpp
@@ -178,14 +178,14 @@ int callback_static_file(const struct _u_request *request, struct _u_response *r
content_type = u_map_get_case(&configWeb.mime_types, get_filename_ext(file_requested));
if (content_type == NULL) {
content_type = u_map_get(&configWeb.mime_types, "*");
- LOG_DEBUG("Static File Server - Unknown mime type for extension %s \n", get_filename_ext(file_requested));
+ LOG_DEBUG("Static File Server - Unknown mime type for extension %s ", get_filename_ext(file_requested));
}
u_map_put(response->map_header, "Content-Type", content_type);
u_map_copy_into(response->map_header, &configWeb.map_header);
if (ulfius_set_stream_response(response, 200, callback_static_file_stream, callback_static_file_stream_free,
length, STATIC_FILE_CHUNK, f) != U_OK) {
- LOG_DEBUG("callback_static_file - Error ulfius_set_stream_response\n ");
+ LOG_DEBUG("callback_static_file - Error ulfius_set_stream_response");
}
}
} else {
@@ -210,7 +210,7 @@ int callback_static_file(const struct _u_request *request, struct _u_response *r
free(real_path); // realpath uses malloc
return U_CALLBACK_CONTINUE;
} else {
- LOG_DEBUG("Static File Server - Error, user_data is NULL or inconsistent\n");
+ LOG_DEBUG("Static File Server - Error, user_data is NULL or inconsistent");
return U_CALLBACK_ERROR;
}
}
@@ -223,7 +223,7 @@ static void handleWebResponse() {}
*/
int handleAPIv1ToRadio(const struct _u_request *req, struct _u_response *res, void *user_data)
{
- LOG_DEBUG("handleAPIv1ToRadio web -> radio \n");
+ LOG_DEBUG("handleAPIv1ToRadio web -> radio ");
ulfius_add_header_to_response(res, "Content-Type", "application/x-protobuf");
ulfius_add_header_to_response(res, "Access-Control-Allow-Headers", "Content-Type");
@@ -232,9 +232,9 @@ int handleAPIv1ToRadio(const struct _u_request *req, struct _u_response *res, vo
ulfius_add_header_to_response(res, "X-Protobuf-Schema",
"https://raw.githubusercontent.com/meshtastic/protobufs/master/meshtastic/mesh.proto");
- if (req->http_verb == "OPTIONS") {
+ if (strcmp(req->http_verb, "OPTIONS") == 0) {
ulfius_set_response_properties(res, U_OPT_STATUS, 204);
- return U_CALLBACK_CONTINUE;
+ return U_CALLBACK_COMPLETE;
}
byte buffer[MAX_TO_FROM_RADIO_SIZE];
@@ -246,9 +246,9 @@ int handleAPIv1ToRadio(const struct _u_request *req, struct _u_response *res, vo
portduinoVFS->mountpoint(configWeb.rootPath);
- LOG_DEBUG("Received %d bytes from PUT request\n", s);
+ LOG_DEBUG("Received %d bytes from PUT request", s);
webAPI.handleToRadio(buffer, s);
- LOG_DEBUG("end web->radio \n");
+ LOG_DEBUG("end web->radio ");
return U_CALLBACK_COMPLETE;
}
@@ -259,7 +259,7 @@ int handleAPIv1ToRadio(const struct _u_request *req, struct _u_response *res, vo
int handleAPIv1FromRadio(const struct _u_request *req, struct _u_response *res, void *user_data)
{
- // LOG_DEBUG("handleAPIv1FromRadio radio -> web\n");
+ // LOG_DEBUG("handleAPIv1FromRadio radio -> web");
std::string valueAll;
// Status code is 200 OK by default.
@@ -269,6 +269,11 @@ int handleAPIv1FromRadio(const struct _u_request *req, struct _u_response *res,
ulfius_add_header_to_response(res, "X-Protobuf-Schema",
"https://raw.githubusercontent.com/meshtastic/protobufs/master/meshtastic/mesh.proto");
+ if (strcmp(req->http_verb, "OPTIONS") == 0) {
+ ulfius_set_response_properties(res, U_OPT_STATUS, 204);
+ return U_CALLBACK_COMPLETE;
+ }
+
uint8_t txBuf[MAX_STREAM_BUF_SIZE];
uint32_t len = 1;
@@ -278,21 +283,21 @@ int handleAPIv1FromRadio(const struct _u_request *req, struct _u_response *res,
ulfius_set_response_properties(res, U_OPT_STATUS, 200, U_OPT_BINARY_BODY, txBuf, len);
const char *tmpa = (const char *)txBuf;
ulfius_set_string_body_response(res, 200, tmpa);
- // LOG_DEBUG("\n----webAPI response all:----\n");
+ // LOG_DEBUG("\n----webAPI response all:----");
// LOG_DEBUG(tmpa);
- // LOG_DEBUG("\n");
+ // LOG_DEBUG("");
}
// Otherwise, just return one protobuf
} else {
len = webAPI.getFromRadio(txBuf);
const char *tmpa = (const char *)txBuf;
ulfius_set_binary_body_response(res, 200, tmpa, len);
- // LOG_DEBUG("\n----webAPI response:\n");
+ // LOG_DEBUG("\n----webAPI response:");
// LOG_DEBUG(tmpa);
- // LOG_DEBUG("\n");
+ // LOG_DEBUG("");
}
- // LOG_DEBUG("end radio->web\n", len);
+ // LOG_DEBUG("end radio->web", len);
return U_CALLBACK_COMPLETE;
}
@@ -346,7 +351,7 @@ char *read_file_into_string(const char *filename)
{
FILE *file = fopen(filename, "rb");
if (file == NULL) {
- LOG_ERROR("Error reading File : %s \n", filename);
+ LOG_ERROR("Error reading File : %s ", filename);
return NULL;
}
@@ -358,7 +363,7 @@ char *read_file_into_string(const char *filename)
// reserve mem for file + 1 byte
char *buffer = (char *)malloc(filesize + 1);
if (buffer == NULL) {
- LOG_ERROR("Malloc of mem failed for file : %s \n", filename);
+ LOG_ERROR("Malloc of mem failed for file : %s ", filename);
fclose(file);
return NULL;
}
@@ -366,7 +371,7 @@ char *read_file_into_string(const char *filename)
// read content
size_t readSize = fread(buffer, 1, filesize, file);
if (readSize != filesize) {
- LOG_ERROR("Error reading file into buffer\n");
+ LOG_ERROR("Error reading file into buffer");
free(buffer);
fclose(file);
return NULL;
@@ -383,13 +388,13 @@ int PiWebServerThread::CheckSSLandLoad()
// read certificate
cert_pem = read_file_into_string("certificate.pem");
if (cert_pem == NULL) {
- LOG_ERROR("ERROR SSL Certificate File can't be loaded or is missing\n");
+ LOG_ERROR("ERROR SSL Certificate File can't be loaded or is missing");
return 1;
}
// read private key
key_pem = read_file_into_string("private_key.pem");
if (key_pem == NULL) {
- LOG_ERROR("ERROR file private_key can't be loaded or is missing\n");
+ LOG_ERROR("ERROR file private_key can't be loaded or is missing");
return 2;
}
@@ -403,19 +408,19 @@ int PiWebServerThread::CreateSSLCertificate()
X509 *x509 = NULL;
if (generate_rsa_key(&pkey) != 0) {
- LOG_ERROR("Error generating RSA-Key.\n");
+ LOG_ERROR("Error generating RSA-Key");
return 1;
}
if (generate_self_signed_x509(pkey, &x509) != 0) {
- LOG_ERROR("Error generating of X509-Certificat.\n");
+ LOG_ERROR("Error generating X509-Cert");
return 2;
}
// Ope file to write private key file
FILE *pkey_file = fopen("private_key.pem", "wb");
if (!pkey_file) {
- LOG_ERROR("Error opening private key file.\n");
+ LOG_ERROR("Error opening private key file");
return 3;
}
// write private key file
@@ -425,7 +430,7 @@ int PiWebServerThread::CreateSSLCertificate()
// open Certificate file
FILE *x509_file = fopen("certificate.pem", "wb");
if (!x509_file) {
- LOG_ERROR("Error opening certificate.\n");
+ LOG_ERROR("Error opening cert");
return 4;
}
// write cirtificate
@@ -434,7 +439,7 @@ int PiWebServerThread::CreateSSLCertificate()
EVP_PKEY_free(pkey);
X509_free(x509);
- LOG_INFO("Create SSL Certifictate -certificate.pem- succesfull \n");
+ LOG_INFO("Create SSL Cert -certificate.pem- succesfull ");
return 0;
}
@@ -447,24 +452,24 @@ PiWebServerThread::PiWebServerThread()
if (CheckSSLandLoad() != 0) {
CreateSSLCertificate();
if (CheckSSLandLoad() != 0) {
- LOG_ERROR("Major Error Gen & Read SSL Certificate\n");
+ LOG_ERROR("Major Error Gen & Read SSL Certificate");
}
}
if (settingsMap[webserverport] != 0) {
webservport = settingsMap[webserverport];
- LOG_INFO("Using webserver port from yaml config. %i \n", webservport);
+ LOG_INFO("Use webserver port from yaml config %i ", webservport);
} else {
- LOG_INFO("Webserver port in yaml config set to 0, so defaulting to port 443.\n");
+ LOG_INFO("Webserver port in yaml config set to 0, defaulting to port 443");
webservport = 443;
}
// Web Content Service Instance
if (ulfius_init_instance(&instanceWeb, webservport, NULL, DEFAULT_REALM) != U_OK) {
- LOG_ERROR("Webserver couldn't be started, abort execution\n");
+ LOG_ERROR("Webserver couldn't be started, abort execution");
} else {
- LOG_INFO("Webserver started ....\n");
+ LOG_INFO("Webserver started");
u_map_init(&configWeb.mime_types);
u_map_put(&configWeb.mime_types, "*", "application/octet-stream");
u_map_put(&configWeb.mime_types, ".html", "text/html");
@@ -493,7 +498,9 @@ PiWebServerThread::PiWebServerThread()
// Maximum body size sent by the client is 1 Kb
instanceWeb.max_post_body_size = 1024;
ulfius_add_endpoint_by_val(&instanceWeb, "GET", PREFIX, "/api/v1/fromradio/*", 1, &handleAPIv1FromRadio, NULL);
+ ulfius_add_endpoint_by_val(&instanceWeb, "OPTIONS", PREFIX, "/api/v1/fromradio/*", 1, &handleAPIv1FromRadio, NULL);
ulfius_add_endpoint_by_val(&instanceWeb, "PUT", PREFIX, "/api/v1/toradio/*", 1, &handleAPIv1ToRadio, configWeb.rootPath);
+ ulfius_add_endpoint_by_val(&instanceWeb, "OPTIONS", PREFIX, "/api/v1/toradio/*", 1, &handleAPIv1ToRadio, NULL);
// Add callback function to all endpoints for the Web Server
ulfius_add_endpoint_by_val(&instanceWeb, "GET", NULL, "/*", 2, &callback_static_file, &configWeb);
@@ -505,10 +512,10 @@ PiWebServerThread::PiWebServerThread()
retssl = ulfius_start_secure_framework(&instanceWeb, key_pem, cert_pem);
if (retssl == U_OK) {
- LOG_INFO("Web Server framework started on port: %i \n", webservport);
- LOG_INFO("Web Server root %s\n", (char *)webrootpath.c_str());
+ LOG_INFO("Web Server framework started on port: %i ", webservport);
+ LOG_INFO("Web Server root %s", (char *)webrootpath.c_str());
} else {
- LOG_ERROR("Error starting Web Server framework, error number: %d\n", retssl);
+ LOG_ERROR("Error starting Web Server framework, error number: %d", retssl);
}
}
}
@@ -527,4 +534,4 @@ PiWebServerThread::~PiWebServerThread()
}
#endif
-#endif
\ No newline at end of file
+#endif
diff --git a/src/mesh/wifi/WiFiAPClient.cpp b/src/mesh/wifi/WiFiAPClient.cpp
index c835878d3..779576d64 100644
--- a/src/mesh/wifi/WiFiAPClient.cpp
+++ b/src/mesh/wifi/WiFiAPClient.cpp
@@ -20,6 +20,8 @@
#include
#include
static void WiFiEvent(WiFiEvent_t event);
+#elif defined(ARCH_RP2040)
+#include
#endif
#ifndef DISABLE_NTP
@@ -57,30 +59,36 @@ static void onNetworkConnected()
{
if (!APStartupComplete) {
// Start web server
- LOG_INFO("Starting WiFi network services\n");
+ LOG_INFO("Start WiFi network services");
-#ifdef ARCH_ESP32
// start mdns
- if (!MDNS.begin("Meshtastic")) {
- LOG_ERROR("Error setting up MDNS responder!\n");
+ if (
+#ifdef ARCH_RP2040
+ !moduleConfig.mqtt.enabled && // MDNS is not supported when MQTT is enabled on ARCH_RP2040
+#endif
+ !MDNS.begin("Meshtastic")) {
+ LOG_ERROR("Error setting up MDNS responder!");
} else {
- LOG_INFO("mDNS responder started\n");
- LOG_INFO("mDNS Host: Meshtastic.local\n");
+ LOG_INFO("mDNS Host: Meshtastic.local");
+#ifdef ARCH_ESP32
MDNS.addService("http", "tcp", 80);
MDNS.addService("https", "tcp", 443);
- }
-#else // ESP32 handles this in WiFiEvent
- LOG_INFO("Obtained IP address: %s\n", WiFi.localIP().toString().c_str());
+#elif defined(ARCH_RP2040)
+ // ARCH_RP2040 does not support HTTPS, create a "meshtastic" service
+ MDNS.addService("meshtastic", "tcp", 4403);
+ // ESP32 handles this in WiFiEvent
+ LOG_INFO("Obtained IP address: %s", WiFi.localIP().toString().c_str());
#endif
+ }
#ifndef DISABLE_NTP
- LOG_INFO("Starting NTP time client\n");
+ LOG_INFO("Start 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("Start Syslog client");
// Defaults
int serverPort = 514;
const char *serverAddr = config.network.rsyslog_server;
@@ -129,10 +137,10 @@ static int32_t reconnectWiFi()
// Make sure we clear old connection credentials
#ifdef ARCH_ESP32
WiFi.disconnect(false, true);
-#else
+#elif defined(ARCH_RP2040)
WiFi.disconnect(false);
#endif
- LOG_INFO("Reconnecting to WiFi access point %s\n", wifiName);
+ LOG_INFO("Reconnecting to WiFi access point %s", wifiName);
delay(5000);
@@ -144,9 +152,9 @@ static int32_t reconnectWiFi()
#ifndef DISABLE_NTP
if (WiFi.isConnected() && (!Throttle::isWithinTimespanMs(lastrun_ntp, 43200000) || (lastrun_ntp == 0))) { // every 12 hours
- LOG_DEBUG("Updating NTP time from %s\n", config.network.ntp_server);
+ LOG_DEBUG("Update 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();
@@ -155,7 +163,7 @@ static int32_t reconnectWiFi()
perhapsSetRTC(RTCQualityNTP, &tv);
lastrun_ntp = millis();
} else {
- LOG_DEBUG("NTP Update failed\n");
+ LOG_DEBUG("NTP Update failed");
}
}
#endif
@@ -188,16 +196,16 @@ bool isWifiAvailable()
// Disable WiFi
void deinitWifi()
{
- LOG_INFO("WiFi deinit\n");
+ LOG_INFO("WiFi deinit");
if (isWifiAvailable()) {
#ifdef ARCH_ESP32
WiFi.disconnect(true, false);
-#else
+#elif defined(ARCH_RP2040)
WiFi.disconnect(true);
#endif
WiFi.mode(WIFI_OFF);
- LOG_INFO("WiFi Turned Off\n");
+ LOG_INFO("WiFi Turned Off");
// WiFi.printDiag(Serial);
}
}
@@ -229,15 +237,15 @@ bool initWifi()
if (config.network.address_mode == meshtastic_Config_NetworkConfig_AddressMode_STATIC &&
config.network.ipv4_config.ip != 0) {
-#ifndef ARCH_RP2040
+#ifdef ARCH_ESP32
WiFi.config(config.network.ipv4_config.ip, config.network.ipv4_config.gateway, config.network.ipv4_config.subnet,
config.network.ipv4_config.dns);
-#else
+#elif defined(ARCH_RP2040)
WiFi.config(config.network.ipv4_config.ip, config.network.ipv4_config.dns, config.network.ipv4_config.gateway,
config.network.ipv4_config.subnet);
#endif
}
-#ifndef ARCH_RP2040
+#ifdef ARCH_ESP32
WiFi.onEvent(WiFiEvent);
WiFi.setAutoReconnect(true);
WiFi.setSleep(false);
@@ -247,7 +255,7 @@ bool initWifi()
WiFi.onEvent(
[](WiFiEvent_t event, WiFiEventInfo_t info) {
- LOG_WARN("WiFi lost connection. Reason: %d\n", info.wifi_sta_disconnected.reason);
+ LOG_WARN("WiFi lost connection. Reason: %d", info.wifi_sta_disconnected.reason);
/*
If we are disconnected from the AP for some reason,
@@ -260,12 +268,12 @@ bool initWifi()
},
WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED);
#endif
- LOG_DEBUG("JOINING WIFI soon: ssid=%s\n", wifiName);
+ LOG_DEBUG("JOINING WIFI soon: ssid=%s", wifiName);
wifiReconnect = new Periodic("WifiConnect", reconnectWiFi);
}
return true;
} else {
- LOG_INFO("Not using WIFI\n");
+ LOG_INFO("Not using WIFI");
return false;
}
}
@@ -278,23 +286,23 @@ static void WiFiEvent(WiFiEvent_t event)
switch (event) {
case ARDUINO_EVENT_WIFI_READY:
- LOG_INFO("WiFi interface ready\n");
+ LOG_INFO("WiFi interface ready");
break;
case ARDUINO_EVENT_WIFI_SCAN_DONE:
- LOG_INFO("Completed scan for access points\n");
+ LOG_INFO("Completed scan for access points");
break;
case ARDUINO_EVENT_WIFI_STA_START:
- LOG_INFO("WiFi station started\n");
+ LOG_INFO("WiFi station started");
break;
case ARDUINO_EVENT_WIFI_STA_STOP:
- LOG_INFO("WiFi station stopped\n");
+ LOG_INFO("WiFi station stopped");
syslog.disable();
break;
case ARDUINO_EVENT_WIFI_STA_CONNECTED:
- LOG_INFO("Connected to access point\n");
+ LOG_INFO("Connected to access point");
break;
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
- LOG_INFO("Disconnected from WiFi access point\n");
+ LOG_INFO("Disconnected from WiFi access point");
if (!isReconnecting) {
WiFi.disconnect(false, true);
syslog.disable();
@@ -303,22 +311,22 @@ static void WiFiEvent(WiFiEvent_t event)
}
break;
case ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE:
- LOG_INFO("Authentication mode of access point has changed\n");
+ LOG_INFO("Authentication mode of access point has changed");
break;
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
- LOG_INFO("Obtained IP address: %s\n", WiFi.localIP().toString().c_str());
+ LOG_INFO("Obtained IP address: %s", WiFi.localIP().toString().c_str());
onNetworkConnected();
break;
case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
- LOG_INFO("Obtained Local IP6 address: %s\n", WiFi.linkLocalIPv6().toString().c_str());
- LOG_INFO("Obtained GlobalIP6 address: %s\n", WiFi.globalIPv6().toString().c_str());
+ LOG_INFO("Obtained Local IP6 address: %s", WiFi.linkLocalIPv6().toString().c_str());
+ LOG_INFO("Obtained GlobalIP6 address: %s", WiFi.globalIPv6().toString().c_str());
#else
- LOG_INFO("Obtained IP6 address: %s\n", WiFi.localIPv6().toString().c_str());
+ LOG_INFO("Obtained IP6 address: %s", WiFi.localIPv6().toString().c_str());
#endif
break;
case ARDUINO_EVENT_WIFI_STA_LOST_IP:
- LOG_INFO("Lost IP address and IP address is reset to 0\n");
+ LOG_INFO("Lost IP address and IP address is reset to 0");
if (!isReconnecting) {
WiFi.disconnect(false, true);
syslog.disable();
@@ -327,94 +335,94 @@ static void WiFiEvent(WiFiEvent_t event)
}
break;
case ARDUINO_EVENT_WPS_ER_SUCCESS:
- LOG_INFO("WiFi Protected Setup (WPS): succeeded in enrollee mode\n");
+ LOG_INFO("WiFi Protected Setup (WPS): succeeded in enrollee mode");
break;
case ARDUINO_EVENT_WPS_ER_FAILED:
- LOG_INFO("WiFi Protected Setup (WPS): failed in enrollee mode\n");
+ LOG_INFO("WiFi Protected Setup (WPS): failed in enrollee mode");
break;
case ARDUINO_EVENT_WPS_ER_TIMEOUT:
- LOG_INFO("WiFi Protected Setup (WPS): timeout in enrollee mode\n");
+ LOG_INFO("WiFi Protected Setup (WPS): timeout in enrollee mode");
break;
case ARDUINO_EVENT_WPS_ER_PIN:
- LOG_INFO("WiFi Protected Setup (WPS): pin code in enrollee mode\n");
+ LOG_INFO("WiFi Protected Setup (WPS): pin code in enrollee mode");
break;
case ARDUINO_EVENT_WPS_ER_PBC_OVERLAP:
- LOG_INFO("WiFi Protected Setup (WPS): push button overlap in enrollee mode\n");
+ LOG_INFO("WiFi Protected Setup (WPS): push button overlap in enrollee mode");
break;
case ARDUINO_EVENT_WIFI_AP_START:
- LOG_INFO("WiFi access point started\n");
+ LOG_INFO("WiFi access point started");
break;
case ARDUINO_EVENT_WIFI_AP_STOP:
- LOG_INFO("WiFi access point stopped\n");
+ LOG_INFO("WiFi access point stopped");
break;
case ARDUINO_EVENT_WIFI_AP_STACONNECTED:
- LOG_INFO("Client connected\n");
+ LOG_INFO("Client connected");
break;
case ARDUINO_EVENT_WIFI_AP_STADISCONNECTED:
- LOG_INFO("Client disconnected\n");
+ LOG_INFO("Client disconnected");
break;
case ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED:
- LOG_INFO("Assigned IP address to client\n");
+ LOG_INFO("Assigned IP address to client");
break;
case ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED:
- LOG_INFO("Received probe request\n");
+ LOG_INFO("Received probe request");
break;
case ARDUINO_EVENT_WIFI_AP_GOT_IP6:
- LOG_INFO("IPv6 is preferred\n");
+ LOG_INFO("IPv6 is preferred");
break;
case ARDUINO_EVENT_WIFI_FTM_REPORT:
- LOG_INFO("Fast Transition Management report\n");
+ LOG_INFO("Fast Transition Management report");
break;
case ARDUINO_EVENT_ETH_START:
- LOG_INFO("Ethernet started\n");
+ LOG_INFO("Ethernet started");
break;
case ARDUINO_EVENT_ETH_STOP:
- LOG_INFO("Ethernet stopped\n");
+ LOG_INFO("Ethernet stopped");
break;
case ARDUINO_EVENT_ETH_CONNECTED:
- LOG_INFO("Ethernet connected\n");
+ LOG_INFO("Ethernet connected");
break;
case ARDUINO_EVENT_ETH_DISCONNECTED:
- LOG_INFO("Ethernet disconnected\n");
+ LOG_INFO("Ethernet disconnected");
break;
case ARDUINO_EVENT_ETH_GOT_IP:
- LOG_INFO("Obtained IP address (ARDUINO_EVENT_ETH_GOT_IP)\n");
+ LOG_INFO("Obtained IP address (ARDUINO_EVENT_ETH_GOT_IP)");
break;
case ARDUINO_EVENT_ETH_GOT_IP6:
- LOG_INFO("Obtained IP6 address (ARDUINO_EVENT_ETH_GOT_IP6)\n");
+ LOG_INFO("Obtained IP6 address (ARDUINO_EVENT_ETH_GOT_IP6)");
break;
case ARDUINO_EVENT_SC_SCAN_DONE:
- LOG_INFO("SmartConfig: Scan done\n");
+ LOG_INFO("SmartConfig: Scan done");
break;
case ARDUINO_EVENT_SC_FOUND_CHANNEL:
- LOG_INFO("SmartConfig: Found channel\n");
+ LOG_INFO("SmartConfig: Found channel");
break;
case ARDUINO_EVENT_SC_GOT_SSID_PSWD:
- LOG_INFO("SmartConfig: Got SSID and password\n");
+ LOG_INFO("SmartConfig: Got SSID and password");
break;
case ARDUINO_EVENT_SC_SEND_ACK_DONE:
- LOG_INFO("SmartConfig: Send ACK done\n");
+ LOG_INFO("SmartConfig: Send ACK done");
break;
case ARDUINO_EVENT_PROV_INIT:
- LOG_INFO("Provisioning: Init\n");
+ LOG_INFO("Provision Init");
break;
case ARDUINO_EVENT_PROV_DEINIT:
- LOG_INFO("Provisioning: Stopped\n");
+ LOG_INFO("Provision Stopped");
break;
case ARDUINO_EVENT_PROV_START:
- LOG_INFO("Provisioning: Started\n");
+ LOG_INFO("Provision Started");
break;
case ARDUINO_EVENT_PROV_END:
- LOG_INFO("Provisioning: End\n");
+ LOG_INFO("Provision End");
break;
case ARDUINO_EVENT_PROV_CRED_RECV:
- LOG_INFO("Provisioning: Credentials received\n");
+ LOG_INFO("Provision Credentials received");
break;
case ARDUINO_EVENT_PROV_CRED_FAIL:
- LOG_INFO("Provisioning: Credentials failed\n");
+ LOG_INFO("Provision Credentials failed");
break;
case ARDUINO_EVENT_PROV_CRED_SUCCESS:
- LOG_INFO("Provisioning: Credentials success\n");
+ LOG_INFO("Provision Credentials success");
break;
default:
break;
diff --git a/src/meshUtils.cpp b/src/meshUtils.cpp
index e98a6f1ce..ea2ba641b 100644
--- a/src/meshUtils.cpp
+++ b/src/meshUtils.cpp
@@ -61,15 +61,13 @@ char *strnstr(const char *s, const char *find, size_t slen)
void printBytes(const char *label, const uint8_t *p, size_t numbytes)
{
int labelSize = strlen(label);
- if (labelSize < 100 && numbytes < 64) {
- char *messageBuffer = new char[labelSize + (numbytes * 3) + 2];
- strncpy(messageBuffer, label, labelSize);
- for (size_t i = 0; i < numbytes; i++)
- snprintf(messageBuffer + labelSize + i * 3, 4, " %02x", p[i]);
- strcpy(messageBuffer + labelSize + numbytes * 3, "\n");
- LOG_DEBUG(messageBuffer);
- delete[] messageBuffer;
- }
+ char *messageBuffer = new char[labelSize + (numbytes * 3) + 2];
+ strncpy(messageBuffer, label, labelSize);
+ for (size_t i = 0; i < numbytes; i++)
+ snprintf(messageBuffer + labelSize + i * 3, 4, " %02x", p[i]);
+ strcpy(messageBuffer + labelSize + numbytes * 3, "\n");
+ LOG_DEBUG(messageBuffer);
+ delete[] messageBuffer;
}
bool memfll(const uint8_t *mem, uint8_t find, size_t numbytes)
@@ -94,4 +92,18 @@ bool isOneOf(int item, int count, ...)
}
va_end(args);
return found;
+}
+
+const std::string vformat(const char *const zcFormat, ...)
+{
+ va_list vaArgs;
+ va_start(vaArgs, zcFormat);
+ va_list vaArgsCopy;
+ va_copy(vaArgsCopy, vaArgs);
+ const int iLen = std::vsnprintf(NULL, 0, zcFormat, vaArgsCopy);
+ va_end(vaArgsCopy);
+ std::vector zc(iLen + 1);
+ std::vsnprintf(zc.data(), zc.size(), zcFormat, vaArgs);
+ va_end(vaArgs);
+ return std::string(zc.data(), iLen);
}
\ No newline at end of file
diff --git a/src/meshUtils.h b/src/meshUtils.h
index aff3976f4..47d42b41b 100644
--- a/src/meshUtils.h
+++ b/src/meshUtils.h
@@ -24,4 +24,6 @@ bool memfll(const uint8_t *mem, uint8_t find, size_t numbytes);
bool isOneOf(int item, int count, ...);
+const std::string vformat(const char *const zcFormat, ...);
+
#define IS_ONE_OF(item, ...) isOneOf(item, sizeof((int[]){__VA_ARGS__}) / sizeof(int), __VA_ARGS__)
diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp
index 79fc67515..c81b6ede4 100644
--- a/src/modules/AdminModule.cpp
+++ b/src/modules/AdminModule.cpp
@@ -74,15 +74,15 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
// Could tighten this up further by tracking the last public_key we went an AdminMessage request to
// and only allowing responses from that remote.
if (messageIsResponse(r)) {
- LOG_DEBUG("Allowing admin response message\n");
+ LOG_DEBUG("Allow admin response message");
} else if (mp.from == 0) {
if (config.security.is_managed) {
- LOG_INFO("Ignoring local admin payload because is_managed.\n");
+ LOG_INFO("Ignore local admin payload because is_managed");
return handled;
}
} else if (strcasecmp(ch->settings.name, Channels::adminChannel) == 0) {
if (!config.security.admin_channel_enabled) {
- LOG_INFO("Ignoring admin channel, as legacy admin is disabled.\n");
+ LOG_INFO("Ignore admin channel, legacy admin is disabled");
myReply = allocErrorResponse(meshtastic_Routing_Error_NOT_AUTHORIZED, &mp);
return handled;
}
@@ -93,25 +93,25 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
memcmp(mp.public_key.bytes, config.security.admin_key[1].bytes, 32) == 0) ||
(config.security.admin_key[2].size == 32 &&
memcmp(mp.public_key.bytes, config.security.admin_key[2].bytes, 32) == 0)) {
- LOG_INFO("PKC admin payload with authorized sender key.\n");
+ LOG_INFO("PKC admin payload with authorized sender key");
} else {
myReply = allocErrorResponse(meshtastic_Routing_Error_ADMIN_PUBLIC_KEY_UNAUTHORIZED, &mp);
- LOG_INFO("Received PKC admin payload, but the sender public key does not match the admin authorized key!\n");
+ LOG_INFO("Received PKC admin payload, but the sender public key does not match the admin authorized key!");
return handled;
}
} else {
- LOG_INFO("Ignoring unauthorized admin payload %i\n", r->which_payload_variant);
+ LOG_INFO("Ignore unauthorized admin payload %i", r->which_payload_variant);
myReply = allocErrorResponse(meshtastic_Routing_Error_NOT_AUTHORIZED, &mp);
return handled;
}
- LOG_INFO("Handling admin payload %i\n", r->which_payload_variant);
+ LOG_INFO("Handle admin payload %i", r->which_payload_variant);
// all of the get and set messages, including those for other modules, flow through here first.
// any message that changes state, we want to check the passkey for
if (mp.from != 0 && !messageIsRequest(r) && !messageIsResponse(r)) {
if (!checkPassKey(r)) {
- LOG_WARN("Admin message without session_key!\n");
+ LOG_WARN("Admin message without session_key!");
myReply = allocErrorResponse(meshtastic_Routing_Error_ADMIN_BAD_SESSION_KEY, &mp);
return handled;
}
@@ -122,23 +122,23 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
* Getters
*/
case meshtastic_AdminMessage_get_owner_request_tag:
- LOG_INFO("Client is getting owner\n");
+ LOG_INFO("Client got owner");
handleGetOwner(mp);
break;
case meshtastic_AdminMessage_get_config_request_tag:
- LOG_INFO("Client is getting config\n");
+ LOG_INFO("Client got config");
handleGetConfig(mp, r->get_config_request);
break;
case meshtastic_AdminMessage_get_module_config_request_tag:
- LOG_INFO("Client is getting module config\n");
+ LOG_INFO("Client got module config");
handleGetModuleConfig(mp, r->get_module_config_request);
break;
case meshtastic_AdminMessage_get_channel_request_tag: {
uint32_t i = r->get_channel_request - 1;
- LOG_INFO("Client is getting channel %u\n", i);
+ LOG_INFO("Client got channel %u", i);
if (i >= MAX_NUM_CHANNELS)
myReply = allocErrorResponse(meshtastic_Routing_Error_BAD_REQUEST, &mp);
else
@@ -150,29 +150,29 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
* Setters
*/
case meshtastic_AdminMessage_set_owner_tag:
- LOG_INFO("Client is setting owner\n");
+ LOG_INFO("Client set owner");
handleSetOwner(r->set_owner);
break;
case meshtastic_AdminMessage_set_config_tag:
- LOG_INFO("Client is setting the config\n");
+ LOG_INFO("Client set config");
handleSetConfig(r->set_config);
break;
case meshtastic_AdminMessage_set_module_config_tag:
- LOG_INFO("Client is setting the module config\n");
+ LOG_INFO("Client set module config");
handleSetModuleConfig(r->set_module_config);
break;
case meshtastic_AdminMessage_set_channel_tag:
- LOG_INFO("Client is setting channel %d\n", r->set_channel.index);
+ LOG_INFO("Client set channel %d", r->set_channel.index);
if (r->set_channel.index < 0 || r->set_channel.index >= (int)MAX_NUM_CHANNELS)
myReply = allocErrorResponse(meshtastic_Routing_Error_BAD_REQUEST, &mp);
else
handleSetChannel(r->set_channel);
break;
case meshtastic_AdminMessage_set_ham_mode_tag:
- LOG_INFO("Client is setting ham mode\n");
+ LOG_INFO("Client set ham mode");
handleSetHamMode(r->set_ham_mode);
break;
@@ -187,15 +187,15 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
int32_t s = r->reboot_ota_seconds;
#if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_BLUETOOTH
if (BleOta::getOtaAppVersion().isEmpty()) {
- LOG_INFO("No OTA firmware available, scheduling regular reboot in %d seconds\n", s);
+ LOG_INFO("No OTA firmware available, scheduling regular reboot in %d seconds", s);
screen->startAlert("Rebooting...");
} else {
screen->startFirmwareUpdateScreen();
BleOta::switchToOtaApp();
- LOG_INFO("Rebooting to OTA in %d seconds\n", s);
+ LOG_INFO("Reboot to OTA in %d seconds", s);
}
#else
- LOG_INFO("Not on ESP32, scheduling regular reboot in %d seconds\n", s);
+ LOG_INFO("Not on ESP32, scheduling regular reboot in %d seconds", s);
screen->startAlert("Rebooting...");
#endif
rebootAtMsec = (s < 0) ? 0 : (millis() + s * 1000);
@@ -203,56 +203,56 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
}
case meshtastic_AdminMessage_shutdown_seconds_tag: {
int32_t s = r->shutdown_seconds;
- LOG_INFO("Shutdown in %d seconds\n", s);
+ LOG_INFO("Shutdown in %d seconds", s);
shutdownAtMsec = (s < 0) ? 0 : (millis() + s * 1000);
break;
}
case meshtastic_AdminMessage_get_device_metadata_request_tag: {
- LOG_INFO("Client is getting device metadata\n");
+ LOG_INFO("Client got device metadata");
handleGetDeviceMetadata(mp);
break;
}
case meshtastic_AdminMessage_factory_reset_config_tag: {
disableBluetooth();
- LOG_INFO("Initiating factory config reset\n");
+ LOG_INFO("Initiate factory config reset");
nodeDB->factoryReset();
- LOG_INFO("Factory config reset finished, rebooting soon.\n");
+ LOG_INFO("Factory config reset finished, rebooting soon");
reboot(DEFAULT_REBOOT_SECONDS);
break;
}
case meshtastic_AdminMessage_factory_reset_device_tag: {
disableBluetooth();
- LOG_INFO("Initiating full factory reset\n");
+ LOG_INFO("Initiate full factory reset");
nodeDB->factoryReset(true);
reboot(DEFAULT_REBOOT_SECONDS);
break;
}
case meshtastic_AdminMessage_nodedb_reset_tag: {
disableBluetooth();
- LOG_INFO("Initiating node-db reset\n");
+ LOG_INFO("Initiate node-db reset");
nodeDB->resetNodes();
reboot(DEFAULT_REBOOT_SECONDS);
break;
}
case meshtastic_AdminMessage_begin_edit_settings_tag: {
- LOG_INFO("Beginning transaction for editing settings\n");
+ LOG_INFO("Begin transaction for editing settings");
hasOpenEditTransaction = true;
break;
}
case meshtastic_AdminMessage_commit_edit_settings_tag: {
disableBluetooth();
- LOG_INFO("Committing transaction for edited settings\n");
+ LOG_INFO("Commit transaction for edited settings");
hasOpenEditTransaction = false;
saveChanges(SEGMENT_CONFIG | SEGMENT_MODULECONFIG | SEGMENT_DEVICESTATE | SEGMENT_CHANNELS);
break;
}
case meshtastic_AdminMessage_get_device_connection_status_request_tag: {
- LOG_INFO("Client is getting device connection status\n");
+ LOG_INFO("Client got device connection status");
handleGetDeviceConnectionStatus(mp);
break;
}
case meshtastic_AdminMessage_get_module_config_response_tag: {
- LOG_INFO("Client is receiving a get_module_config response.\n");
+ LOG_INFO("Client received a get_module_config response");
if (fromOthers && r->get_module_config_response.which_payload_variant ==
meshtastic_AdminMessage_ModuleConfigType_REMOTEHARDWARE_CONFIG) {
handleGetModuleConfigResponse(mp, r);
@@ -260,13 +260,13 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
break;
}
case meshtastic_AdminMessage_remove_by_nodenum_tag: {
- LOG_INFO("Client is receiving a remove_nodenum command.\n");
+ LOG_INFO("Client received remove_nodenum command");
nodeDB->removeNodeByNum(r->remove_by_nodenum);
this->notifyObservers(r); // Observed by screen
break;
}
case meshtastic_AdminMessage_set_favorite_node_tag: {
- LOG_INFO("Client is receiving a set_favorite_node command.\n");
+ LOG_INFO("Client received set_favorite_node command");
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(r->set_favorite_node);
if (node != NULL) {
node->is_favorite = true;
@@ -275,7 +275,7 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
break;
}
case meshtastic_AdminMessage_remove_favorite_node_tag: {
- LOG_INFO("Client is receiving a remove_favorite_node command.\n");
+ LOG_INFO("Client received remove_favorite_node command");
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(r->remove_favorite_node);
if (node != NULL) {
node->is_favorite = false;
@@ -283,8 +283,30 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
}
break;
}
+ case meshtastic_AdminMessage_set_ignored_node_tag: {
+ LOG_INFO("Client received set_ignored_node command");
+ meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(r->set_ignored_node);
+ if (node != NULL) {
+ node->is_ignored = true;
+ node->has_device_metrics = false;
+ node->has_position = false;
+ node->user.public_key.size = 0;
+ node->user.public_key.bytes[0] = 0;
+ saveChanges(SEGMENT_DEVICESTATE, false);
+ }
+ break;
+ }
+ case meshtastic_AdminMessage_remove_ignored_node_tag: {
+ LOG_INFO("Client received remove_ignored_node command");
+ meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(r->remove_ignored_node);
+ if (node != NULL) {
+ node->is_ignored = false;
+ saveChanges(SEGMENT_DEVICESTATE, false);
+ }
+ break;
+ }
case meshtastic_AdminMessage_set_fixed_position_tag: {
- LOG_INFO("Client is receiving a set_fixed_position command.\n");
+ LOG_INFO("Client received set_fixed_position command");
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeDB->getNodeNum());
node->has_position = true;
node->position = TypeConversions::ConvertToPositionLite(r->set_fixed_position);
@@ -300,14 +322,14 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
break;
}
case meshtastic_AdminMessage_remove_fixed_position_tag: {
- LOG_INFO("Client is receiving a remove_fixed_position command.\n");
+ LOG_INFO("Client received remove_fixed_position command");
nodeDB->clearLocalPosition();
config.position.fixed_position = false;
saveChanges(SEGMENT_DEVICESTATE | SEGMENT_CONFIG, false);
break;
}
case meshtastic_AdminMessage_set_time_only_tag: {
- LOG_INFO("Client is receiving a set_time_only command.\n");
+ LOG_INFO("Client received set_time_only command");
struct timeval tv;
tv.tv_sec = r->set_time_only;
tv.tv_usec = 0;
@@ -316,26 +338,26 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
break;
}
case meshtastic_AdminMessage_enter_dfu_mode_request_tag: {
- LOG_INFO("Client is requesting to enter DFU mode.\n");
+ LOG_INFO("Client requesting to enter DFU mode");
#if defined(ARCH_NRF52) || defined(ARCH_RP2040)
enterDfuMode();
#endif
break;
}
case meshtastic_AdminMessage_delete_file_request_tag: {
- LOG_DEBUG("Client is requesting to delete file: %s\n", r->delete_file_request);
+ LOG_DEBUG("Client requesting to delete file: %s", r->delete_file_request);
#ifdef FSCom
if (FSCom.remove(r->delete_file_request)) {
- LOG_DEBUG("Successfully deleted file\n");
+ LOG_DEBUG("Successfully deleted file");
} else {
- LOG_DEBUG("Failed to delete file\n");
+ LOG_DEBUG("Failed to delete file");
}
#endif
break;
}
#ifdef ARCH_PORTDUINO
case meshtastic_AdminMessage_exit_simulator_tag:
- LOG_INFO("Exiting simulator\n");
+ LOG_INFO("Exiting simulator");
_exit(0);
break;
#endif
@@ -348,10 +370,10 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
setPassKey(&res);
myReply = allocDataProtobuf(res);
} else if (mp.decoded.want_response) {
- LOG_DEBUG("We did not responded to a request that wanted a respond. req.variant=%d\n", r->which_payload_variant);
+ LOG_DEBUG("Did not responded to a request that wanted a respond. req.variant=%d", r->which_payload_variant);
} else if (handleResult != AdminMessageHandleResult::HANDLED) {
// Probably a message sent by us or sent to our local node. FIXME, we should avoid scanning these messages
- LOG_INFO("Ignoring nonrelevant admin %d\n", r->which_payload_variant);
+ LOG_INFO("Ignore irrelevant admin %d", r->which_payload_variant);
}
break;
}
@@ -369,7 +391,7 @@ void AdminModule::handleGetModuleConfigResponse(const meshtastic_MeshPacket &mp,
// Skip if it's disabled or no pins are exposed
if (!r->get_module_config_response.payload_variant.remote_hardware.enabled ||
r->get_module_config_response.payload_variant.remote_hardware.available_pins_count == 0) {
- LOG_DEBUG("Remote hardware module disabled or no available_pins. Skipping...\n");
+ LOG_DEBUG("Remote hardware module disabled or no available_pins. Skip");
return;
}
for (uint8_t i = 0; i < devicestate.node_remote_hardware_pins_count; i++) {
@@ -427,7 +449,7 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
switch (c.which_payload_variant) {
case meshtastic_Config_device_tag:
- LOG_INFO("Setting config: Device\n");
+ LOG_INFO("Set config: Device");
config.has_device = true;
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
if (config.device.double_tap_as_button_press == false && c.payload_variant.device.double_tap_as_button_press == true &&
@@ -463,7 +485,7 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
if (existingRole != c.payload_variant.device.role)
nodeDB->installRoleDefaults(c.payload_variant.device.role);
if (config.device.node_info_broadcast_secs < min_node_info_broadcast_secs) {
- LOG_DEBUG("Tried to set node_info_broadcast_secs too low, setting to %d\n", min_node_info_broadcast_secs);
+ LOG_DEBUG("Tried to set node_info_broadcast_secs too low, setting to %d", min_node_info_broadcast_secs);
config.device.node_info_broadcast_secs = min_node_info_broadcast_secs;
}
// Router Client is deprecated; Set it to client
@@ -484,14 +506,14 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
#endif
break;
case meshtastic_Config_position_tag:
- LOG_INFO("Setting config: Position\n");
+ LOG_INFO("Set config: Position");
config.has_position = true;
config.position = c.payload_variant.position;
// Save nodedb as well in case we got a fixed position packet
saveChanges(SEGMENT_DEVICESTATE, false);
break;
case meshtastic_Config_power_tag:
- LOG_INFO("Setting config: Power\n");
+ LOG_INFO("Set config: Power");
config.has_power = true;
// Really just the adc override is the only thing that can change without a reboot
if (config.power.device_battery_ina_address == c.payload_variant.power.device_battery_ina_address &&
@@ -504,14 +526,19 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
requiresReboot = false;
}
config.power = c.payload_variant.power;
+ if (c.payload_variant.power.on_battery_shutdown_after_secs > 0 &&
+ c.payload_variant.power.on_battery_shutdown_after_secs < 30) {
+ LOG_WARN("Tried to set on_battery_shutdown_after_secs too low, set to min 30 seconds");
+ config.power.on_battery_shutdown_after_secs = 30;
+ }
break;
case meshtastic_Config_network_tag:
- LOG_INFO("Setting config: WiFi\n");
+ LOG_INFO("Set config: WiFi");
config.has_network = true;
config.network = c.payload_variant.network;
break;
case meshtastic_Config_display_tag:
- LOG_INFO("Setting config: Display\n");
+ LOG_INFO("Set config: Display");
config.has_display = true;
if (config.display.screen_on_secs == c.payload_variant.display.screen_on_secs &&
config.display.flip_screen == c.payload_variant.display.flip_screen &&
@@ -529,7 +556,7 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
config.display = c.payload_variant.display;
break;
case meshtastic_Config_lora_tag:
- LOG_INFO("Setting config: LoRa\n");
+ LOG_INFO("Set config: LoRa");
config.has_lora = true;
// If no lora radio parameters change, don't need to reboot
if (config.lora.use_preset == c.payload_variant.lora.use_preset && config.lora.region == c.payload_variant.lora.region &&
@@ -568,12 +595,12 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
}
break;
case meshtastic_Config_bluetooth_tag:
- LOG_INFO("Setting config: Bluetooth\n");
+ LOG_INFO("Set config: Bluetooth");
config.has_bluetooth = true;
config.bluetooth = c.payload_variant.bluetooth;
break;
case meshtastic_Config_security_tag:
- LOG_INFO("Setting config: Security\n");
+ LOG_INFO("Set config: Security");
config.security = c.payload_variant.security;
#if !(MESHTASTIC_EXCLUDE_PKI_KEYGEN) && !(MESHTASTIC_EXCLUDE_PKI)
// We check for a potentially valid private key, and a blank public key, and regen the public key if needed.
@@ -608,71 +635,71 @@ void AdminModule::handleSetModuleConfig(const meshtastic_ModuleConfig &c)
disableBluetooth();
switch (c.which_payload_variant) {
case meshtastic_ModuleConfig_mqtt_tag:
- LOG_INFO("Setting module config: MQTT\n");
+ LOG_INFO("Set module config: MQTT");
moduleConfig.has_mqtt = true;
moduleConfig.mqtt = c.payload_variant.mqtt;
break;
case meshtastic_ModuleConfig_serial_tag:
- LOG_INFO("Setting module config: Serial\n");
+ LOG_INFO("Set module config: Serial");
moduleConfig.has_serial = true;
moduleConfig.serial = c.payload_variant.serial;
break;
case meshtastic_ModuleConfig_external_notification_tag:
- LOG_INFO("Setting module config: External Notification\n");
+ LOG_INFO("Set module config: External Notification");
moduleConfig.has_external_notification = true;
moduleConfig.external_notification = c.payload_variant.external_notification;
break;
case meshtastic_ModuleConfig_store_forward_tag:
- LOG_INFO("Setting module config: Store & Forward\n");
+ LOG_INFO("Set module config: Store & Forward");
moduleConfig.has_store_forward = true;
moduleConfig.store_forward = c.payload_variant.store_forward;
break;
case meshtastic_ModuleConfig_range_test_tag:
- LOG_INFO("Setting module config: Range Test\n");
+ LOG_INFO("Set module config: Range Test");
moduleConfig.has_range_test = true;
moduleConfig.range_test = c.payload_variant.range_test;
break;
case meshtastic_ModuleConfig_telemetry_tag:
- LOG_INFO("Setting module config: Telemetry\n");
+ LOG_INFO("Set module config: Telemetry");
moduleConfig.has_telemetry = true;
moduleConfig.telemetry = c.payload_variant.telemetry;
break;
case meshtastic_ModuleConfig_canned_message_tag:
- LOG_INFO("Setting module config: Canned Message\n");
+ LOG_INFO("Set module config: Canned Message");
moduleConfig.has_canned_message = true;
moduleConfig.canned_message = c.payload_variant.canned_message;
break;
case meshtastic_ModuleConfig_audio_tag:
- LOG_INFO("Setting module config: Audio\n");
+ LOG_INFO("Set module config: Audio");
moduleConfig.has_audio = true;
moduleConfig.audio = c.payload_variant.audio;
break;
case meshtastic_ModuleConfig_remote_hardware_tag:
- LOG_INFO("Setting module config: Remote Hardware\n");
+ LOG_INFO("Set module config: Remote Hardware");
moduleConfig.has_remote_hardware = true;
moduleConfig.remote_hardware = c.payload_variant.remote_hardware;
break;
case meshtastic_ModuleConfig_neighbor_info_tag:
- LOG_INFO("Setting module config: Neighbor Info\n");
+ LOG_INFO("Set module config: Neighbor Info");
moduleConfig.has_neighbor_info = true;
if (moduleConfig.neighbor_info.update_interval < min_neighbor_info_broadcast_secs) {
- LOG_DEBUG("Tried to set update_interval too low, setting to %d\n", default_neighbor_info_broadcast_secs);
+ LOG_DEBUG("Tried to set update_interval too low, setting to %d", default_neighbor_info_broadcast_secs);
moduleConfig.neighbor_info.update_interval = default_neighbor_info_broadcast_secs;
}
moduleConfig.neighbor_info = c.payload_variant.neighbor_info;
break;
case meshtastic_ModuleConfig_detection_sensor_tag:
- LOG_INFO("Setting module config: Detection Sensor\n");
+ LOG_INFO("Set module config: Detection Sensor");
moduleConfig.has_detection_sensor = true;
moduleConfig.detection_sensor = c.payload_variant.detection_sensor;
break;
case meshtastic_ModuleConfig_ambient_lighting_tag:
- LOG_INFO("Setting module config: Ambient Lighting\n");
+ LOG_INFO("Set module config: Ambient Lighting");
moduleConfig.has_ambient_lighting = true;
moduleConfig.ambient_lighting = c.payload_variant.ambient_lighting;
break;
case meshtastic_ModuleConfig_paxcounter_tag:
- LOG_INFO("Setting module config: Paxcounter\n");
+ LOG_INFO("Set module config: Paxcounter");
moduleConfig.has_paxcounter = true;
moduleConfig.paxcounter = c.payload_variant.paxcounter;
break;
@@ -711,49 +738,49 @@ void AdminModule::handleGetConfig(const meshtastic_MeshPacket &req, const uint32
if (req.decoded.want_response) {
switch (configType) {
case meshtastic_AdminMessage_ConfigType_DEVICE_CONFIG:
- LOG_INFO("Getting config: Device\n");
+ LOG_INFO("Get config: Device");
res.get_config_response.which_payload_variant = meshtastic_Config_device_tag;
res.get_config_response.payload_variant.device = config.device;
break;
case meshtastic_AdminMessage_ConfigType_POSITION_CONFIG:
- LOG_INFO("Getting config: Position\n");
+ LOG_INFO("Get config: Position");
res.get_config_response.which_payload_variant = meshtastic_Config_position_tag;
res.get_config_response.payload_variant.position = config.position;
break;
case meshtastic_AdminMessage_ConfigType_POWER_CONFIG:
- LOG_INFO("Getting config: Power\n");
+ LOG_INFO("Get config: Power");
res.get_config_response.which_payload_variant = meshtastic_Config_power_tag;
res.get_config_response.payload_variant.power = config.power;
break;
case meshtastic_AdminMessage_ConfigType_NETWORK_CONFIG:
- LOG_INFO("Getting config: Network\n");
+ LOG_INFO("Get config: Network");
res.get_config_response.which_payload_variant = meshtastic_Config_network_tag;
res.get_config_response.payload_variant.network = config.network;
writeSecret(res.get_config_response.payload_variant.network.wifi_psk,
sizeof(res.get_config_response.payload_variant.network.wifi_psk), config.network.wifi_psk);
break;
case meshtastic_AdminMessage_ConfigType_DISPLAY_CONFIG:
- LOG_INFO("Getting config: Display\n");
+ LOG_INFO("Get config: Display");
res.get_config_response.which_payload_variant = meshtastic_Config_display_tag;
res.get_config_response.payload_variant.display = config.display;
break;
case meshtastic_AdminMessage_ConfigType_LORA_CONFIG:
- LOG_INFO("Getting config: LoRa\n");
+ LOG_INFO("Get config: LoRa");
res.get_config_response.which_payload_variant = meshtastic_Config_lora_tag;
res.get_config_response.payload_variant.lora = config.lora;
break;
case meshtastic_AdminMessage_ConfigType_BLUETOOTH_CONFIG:
- LOG_INFO("Getting config: Bluetooth\n");
+ LOG_INFO("Get config: Bluetooth");
res.get_config_response.which_payload_variant = meshtastic_Config_bluetooth_tag;
res.get_config_response.payload_variant.bluetooth = config.bluetooth;
break;
case meshtastic_AdminMessage_ConfigType_SECURITY_CONFIG:
- LOG_INFO("Getting config: Security\n");
+ LOG_INFO("Get config: Security");
res.get_config_response.which_payload_variant = meshtastic_Config_security_tag;
res.get_config_response.payload_variant.security = config.security;
break;
case meshtastic_AdminMessage_ConfigType_SESSIONKEY_CONFIG:
- LOG_INFO("Getting config: Sessionkey\n");
+ LOG_INFO("Get config: Sessionkey");
res.get_config_response.which_payload_variant = meshtastic_Config_sessionkey_tag;
break;
}
@@ -777,67 +804,67 @@ void AdminModule::handleGetModuleConfig(const meshtastic_MeshPacket &req, const
if (req.decoded.want_response) {
switch (configType) {
case meshtastic_AdminMessage_ModuleConfigType_MQTT_CONFIG:
- LOG_INFO("Getting module config: MQTT\n");
+ LOG_INFO("Get module config: MQTT");
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_mqtt_tag;
res.get_module_config_response.payload_variant.mqtt = moduleConfig.mqtt;
break;
case meshtastic_AdminMessage_ModuleConfigType_SERIAL_CONFIG:
- LOG_INFO("Getting module config: Serial\n");
+ LOG_INFO("Get module config: Serial");
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_serial_tag;
res.get_module_config_response.payload_variant.serial = moduleConfig.serial;
break;
case meshtastic_AdminMessage_ModuleConfigType_EXTNOTIF_CONFIG:
- LOG_INFO("Getting module config: External Notification\n");
+ LOG_INFO("Get module config: External Notification");
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_external_notification_tag;
res.get_module_config_response.payload_variant.external_notification = moduleConfig.external_notification;
break;
case meshtastic_AdminMessage_ModuleConfigType_STOREFORWARD_CONFIG:
- LOG_INFO("Getting module config: Store & Forward\n");
+ LOG_INFO("Get module config: Store & Forward");
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_store_forward_tag;
res.get_module_config_response.payload_variant.store_forward = moduleConfig.store_forward;
break;
case meshtastic_AdminMessage_ModuleConfigType_RANGETEST_CONFIG:
- LOG_INFO("Getting module config: Range Test\n");
+ LOG_INFO("Get module config: Range Test");
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_range_test_tag;
res.get_module_config_response.payload_variant.range_test = moduleConfig.range_test;
break;
case meshtastic_AdminMessage_ModuleConfigType_TELEMETRY_CONFIG:
- LOG_INFO("Getting module config: Telemetry\n");
+ LOG_INFO("Get module config: Telemetry");
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_telemetry_tag;
res.get_module_config_response.payload_variant.telemetry = moduleConfig.telemetry;
break;
case meshtastic_AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG:
- LOG_INFO("Getting module config: Canned Message\n");
+ LOG_INFO("Get module config: Canned Message");
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_canned_message_tag;
res.get_module_config_response.payload_variant.canned_message = moduleConfig.canned_message;
break;
case meshtastic_AdminMessage_ModuleConfigType_AUDIO_CONFIG:
- LOG_INFO("Getting module config: Audio\n");
+ LOG_INFO("Get module config: Audio");
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_audio_tag;
res.get_module_config_response.payload_variant.audio = moduleConfig.audio;
break;
case meshtastic_AdminMessage_ModuleConfigType_REMOTEHARDWARE_CONFIG:
- LOG_INFO("Getting module config: Remote Hardware\n");
+ LOG_INFO("Get module config: Remote Hardware");
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_remote_hardware_tag;
res.get_module_config_response.payload_variant.remote_hardware = moduleConfig.remote_hardware;
break;
case meshtastic_AdminMessage_ModuleConfigType_NEIGHBORINFO_CONFIG:
- LOG_INFO("Getting module config: Neighbor Info\n");
+ LOG_INFO("Get module config: Neighbor Info");
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_neighbor_info_tag;
res.get_module_config_response.payload_variant.neighbor_info = moduleConfig.neighbor_info;
break;
case meshtastic_AdminMessage_ModuleConfigType_DETECTIONSENSOR_CONFIG:
- LOG_INFO("Getting module config: Detection Sensor\n");
+ LOG_INFO("Get module config: Detection Sensor");
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_detection_sensor_tag;
res.get_module_config_response.payload_variant.detection_sensor = moduleConfig.detection_sensor;
break;
case meshtastic_AdminMessage_ModuleConfigType_AMBIENTLIGHTING_CONFIG:
- LOG_INFO("Getting module config: Ambient Lighting\n");
+ LOG_INFO("Get module config: Ambient Lighting");
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_ambient_lighting_tag;
res.get_module_config_response.payload_variant.ambient_lighting = moduleConfig.ambient_lighting;
break;
case meshtastic_AdminMessage_ModuleConfigType_PAXCOUNTER_CONFIG:
- LOG_INFO("Getting module config: Paxcounter\n");
+ LOG_INFO("Get module config: Paxcounter");
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_paxcounter_tag;
res.get_module_config_response.payload_variant.paxcounter = moduleConfig.paxcounter;
break;
@@ -900,7 +927,7 @@ void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &r
#ifdef ARCH_PORTDUINO
conn.wifi.status.is_connected = true;
#else
- conn.wifi.status.is_connected = WiFi.status() != WL_CONNECTED;
+ conn.wifi.status.is_connected = WiFi.status() == WL_CONNECTED;
#endif
strncpy(conn.wifi.ssid, config.network.wifi_ssid, 33);
if (conn.wifi.status.is_connected) {
@@ -932,10 +959,14 @@ void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &r
conn.has_bluetooth = true;
conn.bluetooth.pin = config.bluetooth.fixed_pin;
#ifdef ARCH_ESP32
- conn.bluetooth.is_connected = nimbleBluetooth->isConnected();
- conn.bluetooth.rssi = nimbleBluetooth->getRssi();
+ if (config.bluetooth.enabled && nimbleBluetooth) {
+ conn.bluetooth.is_connected = nimbleBluetooth->isConnected();
+ conn.bluetooth.rssi = nimbleBluetooth->getRssi();
+ }
#elif defined(ARCH_NRF52)
- conn.bluetooth.is_connected = nrf52Bluetooth->isConnected();
+ if (config.bluetooth.enabled && nrf52Bluetooth) {
+ conn.bluetooth.is_connected = nrf52Bluetooth->isConnected();
+ }
#endif
#endif
conn.has_serial = true; // No serial-less devices
@@ -966,7 +997,7 @@ void AdminModule::handleGetChannel(const meshtastic_MeshPacket &req, uint32_t ch
void AdminModule::reboot(int32_t seconds)
{
- LOG_INFO("Rebooting in %d seconds\n", seconds);
+ LOG_INFO("Reboot in %d seconds", seconds);
screen->startAlert("Rebooting...");
rebootAtMsec = (seconds < 0) ? 0 : (millis() + seconds * 1000);
}
@@ -974,10 +1005,10 @@ void AdminModule::reboot(int32_t seconds)
void AdminModule::saveChanges(int saveWhat, bool shouldReboot)
{
if (!hasOpenEditTransaction) {
- LOG_INFO("Saving changes to disk\n");
+ LOG_INFO("Save changes to disk");
service->reloadConfig(saveWhat); // Calls saveToDisk among other things
} else {
- LOG_INFO("Delaying save of changes to disk until the open transaction is committed\n");
+ LOG_INFO("Delay save of changes to disk until the open transaction is committed");
}
if (shouldReboot && !hasOpenEditTransaction) {
reboot(DEFAULT_REBOOT_SECONDS);
@@ -1026,7 +1057,7 @@ void AdminModule::setPassKey(meshtastic_AdminMessage *res)
}
memcpy(res->session_passkey.bytes, session_passkey, 8);
res->session_passkey.size = 8;
- printBytes("Setting admin key to ", res->session_passkey.bytes, 8);
+ printBytes("Set admin key to ", res->session_passkey.bytes, 8);
// if halfway to session_expire, regenerate session_passkey, reset the timeout
// set the key in the packet
}
@@ -1092,4 +1123,4 @@ void disableBluetooth()
nrf52Bluetooth->shutdown();
#endif
#endif
-}
\ No newline at end of file
+}
diff --git a/src/modules/AdminModule.h b/src/modules/AdminModule.h
index e54b89af1..b99e86707 100644
--- a/src/modules/AdminModule.h
+++ b/src/modules/AdminModule.h
@@ -1,3 +1,5 @@
+#include
+
#pragma once
#include "ProtobufModule.h"
#if HAS_WIFI
diff --git a/src/modules/AtakPluginModule.cpp b/src/modules/AtakPluginModule.cpp
index 72d069619..d242e5501 100644
--- a/src/modules/AtakPluginModule.cpp
+++ b/src/modules/AtakPluginModule.cpp
@@ -11,7 +11,7 @@
AtakPluginModule *atakPluginModule;
AtakPluginModule::AtakPluginModule()
- : ProtobufModule("atak", meshtastic_PortNum_ATAK_PLUGIN, &meshtastic_TAKPacket_msg), concurrency::OSThread("AtakPluginModule")
+ : ProtobufModule("atak", meshtastic_PortNum_ATAK_PLUGIN, &meshtastic_TAKPacket_msg), concurrency::OSThread("AtakPlugin")
{
ourPortNum = meshtastic_PortNum_ATAK_PLUGIN;
}
@@ -65,7 +65,7 @@ void AtakPluginModule::alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtast
{
// From Phone (EUD)
if (mp.from == 0) {
- LOG_DEBUG("Received uncompressed TAK payload from phone: %d bytes\n", mp.decoded.payload.size);
+ LOG_DEBUG("Received uncompressed TAK payload from phone: %d bytes", mp.decoded.payload.size);
// Compress for LoRA transport
auto compressed = cloneTAKPacketData(t);
compressed.is_compressed = true;
@@ -73,28 +73,28 @@ void AtakPluginModule::alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtast
auto length = unishox2_compress_lines(t->contact.callsign, strlen(t->contact.callsign), compressed.contact.callsign,
sizeof(compressed.contact.callsign) - 1, USX_PSET_DFLT, NULL);
if (length < 0) {
- LOG_WARN("Compression overflowed contact.callsign. Reverting to uncompressed packet\n");
+ LOG_WARN("Compress overflow contact.callsign. Revert to uncompressed packet");
return;
}
- LOG_DEBUG("Compressed callsign: %d bytes\n", length);
+ LOG_DEBUG("Compressed callsign: %d bytes", length);
length = unishox2_compress_lines(t->contact.device_callsign, strlen(t->contact.device_callsign),
compressed.contact.device_callsign, sizeof(compressed.contact.device_callsign) - 1,
USX_PSET_DFLT, NULL);
if (length < 0) {
- LOG_WARN("Compression overflowed contact.device_callsign. Reverting to uncompressed packet\n");
+ LOG_WARN("Compress overflow contact.device_callsign. Revert to uncompressed packet");
return;
}
- LOG_DEBUG("Compressed device_callsign: %d bytes\n", length);
+ LOG_DEBUG("Compressed device_callsign: %d bytes", length);
}
if (t->which_payload_variant == meshtastic_TAKPacket_chat_tag) {
auto length = unishox2_compress_lines(t->payload_variant.chat.message, strlen(t->payload_variant.chat.message),
compressed.payload_variant.chat.message,
sizeof(compressed.payload_variant.chat.message) - 1, USX_PSET_DFLT, NULL);
if (length < 0) {
- LOG_WARN("Compression overflowed chat.message. Reverting to uncompressed packet\n");
+ LOG_WARN("Compress overflow chat.message. Revert to uncompressed packet");
return;
}
- LOG_DEBUG("Compressed chat message: %d bytes\n", length);
+ LOG_DEBUG("Compressed chat message: %d bytes", length);
if (t->payload_variant.chat.has_to) {
compressed.payload_variant.chat.has_to = true;
@@ -102,10 +102,10 @@ void AtakPluginModule::alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtast
compressed.payload_variant.chat.to,
sizeof(compressed.payload_variant.chat.to) - 1, USX_PSET_DFLT, NULL);
if (length < 0) {
- LOG_WARN("Compression overflowed chat.to. Reverting to uncompressed packet\n");
+ LOG_WARN("Compress overflow chat.to. Revert to uncompressed packet");
return;
}
- LOG_DEBUG("Compressed chat to: %d bytes\n", length);
+ LOG_DEBUG("Compressed chat to: %d bytes", length);
}
if (t->payload_variant.chat.has_to_callsign) {
@@ -114,19 +114,19 @@ void AtakPluginModule::alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtast
compressed.payload_variant.chat.to_callsign,
sizeof(compressed.payload_variant.chat.to_callsign) - 1, USX_PSET_DFLT, NULL);
if (length < 0) {
- LOG_WARN("Compression overflowed chat.to_callsign. Reverting to uncompressed packet\n");
+ LOG_WARN("Compress overflow chat.to_callsign. Revert to uncompressed packet");
return;
}
- LOG_DEBUG("Compressed chat to_callsign: %d bytes\n", length);
+ LOG_DEBUG("Compressed chat to_callsign: %d bytes", length);
}
}
mp.decoded.payload.size = pb_encode_to_bytes(mp.decoded.payload.bytes, sizeof(mp.decoded.payload.bytes),
meshtastic_TAKPacket_fields, &compressed);
- LOG_DEBUG("Final payload: %d bytes\n", mp.decoded.payload.size);
+ LOG_DEBUG("Final payload: %d bytes", mp.decoded.payload.size);
} else {
if (!t->is_compressed) {
// Not compressed. Something is wrong
- LOG_WARN("Received uncompressed TAKPacket over radio! Skipping\n");
+ LOG_WARN("Received uncompressed TAKPacket over radio! Skip");
return;
}
@@ -139,29 +139,29 @@ void AtakPluginModule::alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtast
unishox2_decompress_lines(t->contact.callsign, strlen(t->contact.callsign), uncompressed.contact.callsign,
sizeof(uncompressed.contact.callsign) - 1, USX_PSET_DFLT, NULL);
if (length < 0) {
- LOG_WARN("Decompression overflowed contact.callsign. Bailing out\n");
+ LOG_WARN("Decompress overflow contact.callsign. Bailing out");
return;
}
- LOG_DEBUG("Decompressed callsign: %d bytes\n", length);
+ LOG_DEBUG("Decompressed callsign: %d bytes", length);
length = unishox2_decompress_lines(t->contact.device_callsign, strlen(t->contact.device_callsign),
uncompressed.contact.device_callsign,
sizeof(uncompressed.contact.device_callsign) - 1, USX_PSET_DFLT, NULL);
if (length < 0) {
- LOG_WARN("Decompression overflowed contact.device_callsign. Bailing out\n");
+ LOG_WARN("Decompress overflow contact.device_callsign. Bailing out");
return;
}
- LOG_DEBUG("Decompressed device_callsign: %d bytes\n", length);
+ LOG_DEBUG("Decompressed device_callsign: %d bytes", length);
}
if (uncompressed.which_payload_variant == meshtastic_TAKPacket_chat_tag) {
auto length = unishox2_decompress_lines(t->payload_variant.chat.message, strlen(t->payload_variant.chat.message),
uncompressed.payload_variant.chat.message,
sizeof(uncompressed.payload_variant.chat.message) - 1, USX_PSET_DFLT, NULL);
if (length < 0) {
- LOG_WARN("Decompression overflowed chat.message. Bailing out\n");
+ LOG_WARN("Decompress overflow chat.message. Bailing out");
return;
}
- LOG_DEBUG("Decompressed chat message: %d bytes\n", length);
+ LOG_DEBUG("Decompressed chat message: %d bytes", length);
if (t->payload_variant.chat.has_to) {
uncompressed.payload_variant.chat.has_to = true;
@@ -169,10 +169,10 @@ void AtakPluginModule::alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtast
uncompressed.payload_variant.chat.to,
sizeof(uncompressed.payload_variant.chat.to) - 1, USX_PSET_DFLT, NULL);
if (length < 0) {
- LOG_WARN("Decompression overflowed chat.to. Bailing out\n");
+ LOG_WARN("Decompress overflow chat.to. Bailing out");
return;
}
- LOG_DEBUG("Decompressed chat to: %d bytes\n", length);
+ LOG_DEBUG("Decompressed chat to: %d bytes", length);
}
if (t->payload_variant.chat.has_to_callsign) {
@@ -182,10 +182,10 @@ void AtakPluginModule::alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtast
uncompressed.payload_variant.chat.to_callsign,
sizeof(uncompressed.payload_variant.chat.to_callsign) - 1, USX_PSET_DFLT, NULL);
if (length < 0) {
- LOG_WARN("Decompression overflowed chat.to_callsign. Bailing out\n");
+ LOG_WARN("Decompress overflow chat.to_callsign. Bailing out");
return;
}
- LOG_DEBUG("Decompressed chat to_callsign: %d bytes\n", length);
+ LOG_DEBUG("Decompressed chat to_callsign: %d bytes", length);
}
}
decompressedCopy->decoded.payload.size =
diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp
index ed0dce25f..a96fcc080 100644
--- a/src/modules/CannedMessageModule.cpp
+++ b/src/modules/CannedMessageModule.cpp
@@ -42,20 +42,20 @@ meshtastic_CannedMessageModuleConfig cannedMessageModuleConfig;
CannedMessageModule *cannedMessageModule;
CannedMessageModule::CannedMessageModule()
- : SinglePortModule("canned", meshtastic_PortNum_TEXT_MESSAGE_APP), concurrency::OSThread("CannedMessageModule")
+ : SinglePortModule("canned", meshtastic_PortNum_TEXT_MESSAGE_APP), concurrency::OSThread("CannedMessage")
{
if (moduleConfig.canned_message.enabled || CANNED_MESSAGE_MODULE_ENABLE) {
this->loadProtoForModule();
if ((this->splitConfiguredMessages() <= 0) && (cardkb_found.address == 0x00) && !INPUTBROKER_MATRIX_TYPE &&
!CANNED_MESSAGE_MODULE_ENABLE) {
- LOG_INFO("CannedMessageModule: No messages are configured. Module is disabled\n");
+ LOG_INFO("CannedMessageModule: No messages are configured. Module is disabled");
this->runState = CANNED_MESSAGE_RUN_STATE_DISABLED;
disable();
} else {
- LOG_INFO("CannedMessageModule is enabled\n");
+ LOG_INFO("CannedMessageModule is enabled");
// T-Watch interface currently has no way to select destination type, so default to 'node'
-#if defined(T_WATCH_S3) || defined(RAK14014)
+#if defined(USE_VIRTUAL_KEYBOARD)
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NODE;
#endif
@@ -81,7 +81,7 @@ int CannedMessageModule::splitConfiguredMessages()
String canned_messages = cannedMessageModuleConfig.messages;
-#if defined(T_WATCH_S3) || defined(RAK14014)
+#if defined(USE_VIRTUAL_KEYBOARD)
String separator = canned_messages.length() ? "|" : "";
canned_messages = "[---- Free Text ----]" + separator + canned_messages;
@@ -112,7 +112,7 @@ int CannedMessageModule::splitConfiguredMessages()
}
if (strlen(this->messages[messageIndex - 1]) > 0) {
// We have a last message.
- LOG_DEBUG("CannedMessage %d is: '%s'\n", messageIndex - 1, this->messages[messageIndex - 1]);
+ LOG_DEBUG("CannedMessage %d is: '%s'", messageIndex - 1, this->messages[messageIndex - 1]);
this->messagesCount = messageIndex;
} else {
this->messagesCount = messageIndex - 1;
@@ -150,7 +150,7 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
}
if (event->inputEvent == static_cast(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT)) {
-#if defined(T_WATCH_S3) || defined(RAK14014)
+#if defined(USE_VIRTUAL_KEYBOARD)
if (this->currentMessageIndex == 0) {
this->runState = CANNED_MESSAGE_RUN_STATE_FREETEXT;
@@ -177,7 +177,7 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
e.action = UIFrameEvent::Action::REGENERATE_FRAMESET; // We want to change the list of frames shown on-screen
this->currentMessageIndex = -1;
-#if !defined(T_WATCH_S3) && !defined(RAK14014)
+#if !defined(T_WATCH_S3) && !defined(RAK14014) && !defined(USE_VIRTUAL_KEYBOARD)
this->freetext = ""; // clear freetext
this->cursor = 0;
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE;
@@ -190,7 +190,7 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
(event->inputEvent == static_cast(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT)) ||
(event->inputEvent == static_cast(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT))) {
-#if defined(T_WATCH_S3) || defined(RAK14014)
+#if defined(USE_VIRTUAL_KEYBOARD)
if (event->inputEvent == static_cast(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT)) {
this->payload = INPUT_BROKER_MSG_LEFT;
} else if (event->inputEvent == static_cast(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT)) {
@@ -227,20 +227,20 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
case INPUT_BROKER_MSG_BRIGHTNESS_UP: // make screen brighter
if (screen)
screen->increaseBrightness();
- LOG_DEBUG("increasing Screen Brightness\n");
+ LOG_DEBUG("Increase Screen Brightness");
break;
case INPUT_BROKER_MSG_BRIGHTNESS_DOWN: // make screen dimmer
if (screen)
screen->decreaseBrightness();
- LOG_DEBUG("Decreasing Screen Brightness\n");
+ LOG_DEBUG("Decrease Screen Brightness");
break;
- case INPUT_BROKER_MSG_FN_SYMBOL_ON: // draw modifier (function) symbal
+ case INPUT_BROKER_MSG_FN_SYMBOL_ON: // draw modifier (function) symbol
if (screen)
- screen->setFunctionSymbal("Fn");
+ screen->setFunctionSymbol("Fn");
break;
- case INPUT_BROKER_MSG_FN_SYMBOL_OFF: // remove modifier (function) symbal
+ case INPUT_BROKER_MSG_FN_SYMBOL_OFF: // remove modifier (function) symbol
if (screen)
- screen->removeFunctionSymbal("Fn");
+ screen->removeFunctionSymbol("Fn");
break;
// mute (switch off/toggle) external notifications on fn+m
case INPUT_BROKER_MSG_MUTE_TOGGLE:
@@ -249,13 +249,13 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
externalNotificationModule->setMute(false);
showTemporaryMessage("Notifications \nEnabled");
if (screen)
- screen->removeFunctionSymbal("M"); // remove the mute symbol from the bottom right corner
+ screen->removeFunctionSymbol("M"); // remove the mute symbol from the bottom right corner
} else {
externalNotificationModule->stopNow(); // this will turn off all GPIO and sounds and idle the loop
externalNotificationModule->setMute(true);
showTemporaryMessage("Notifications \nDisabled");
if (screen)
- screen->setFunctionSymbal("M"); // add the mute symbol to the bottom right corner
+ screen->setFunctionSymbol("M"); // add the mute symbol to the bottom right corner
}
}
break;
@@ -301,18 +301,18 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
return 0;
default:
// pass the pressed key
- // LOG_DEBUG("Canned message ANYKEY (%x)\n", event->kbchar);
+ // LOG_DEBUG("Canned message ANYKEY (%x)", event->kbchar);
this->payload = event->kbchar;
this->lastTouchMillis = millis();
validEvent = true;
break;
}
if (screen && (event->kbchar != INPUT_BROKER_MSG_FN_SYMBOL_ON)) {
- screen->removeFunctionSymbal("Fn"); // remove modifier (function) symbal
+ screen->removeFunctionSymbol("Fn"); // remove modifier (function) symbol
}
}
-#if defined(T_WATCH_S3) || defined(RAK14014)
+#if defined(USE_VIRTUAL_KEYBOARD)
if (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) {
String keyTapped = keyForCoordinates(event->touchX, event->touchY);
@@ -325,7 +325,9 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
this->shift = !this->shift;
} else if (keyTapped == "⌫") {
+#ifndef RAK14014
this->highlight = keyTapped[0];
+#endif
this->payload = 0x08;
@@ -341,7 +343,9 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
validEvent = true;
} else if (keyTapped == " ") {
+#ifndef RAK14014
this->highlight = keyTapped[0];
+#endif
this->payload = keyTapped[0];
@@ -361,7 +365,9 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
this->shift = false;
} else if (keyTapped != "") {
+#ifndef RAK14014
this->highlight = keyTapped[0];
+#endif
this->payload = this->shift ? keyTapped[0] : std::tolower(keyTapped[0]);
@@ -414,7 +420,7 @@ void CannedMessageModule::sendText(NodeNum dest, ChannelIndex channel, const cha
// or raising a UIFrameEvent before another module has the chance
this->waitingForAck = true;
- LOG_INFO("Sending message id=%d, dest=%x, msg=%.*s\n", p->id, p->to, p->decoded.payload.size, p->decoded.payload.bytes);
+ LOG_INFO("Send message id=%d, dest=%x, msg=%.*s", p->id, p->to, p->decoded.payload.size, p->decoded.payload.bytes);
service->sendToMesh(
p, RX_SRC_LOCAL,
@@ -428,7 +434,7 @@ int32_t CannedMessageModule::runOnce()
temporaryMessage = "";
return INT32_MAX;
}
- // LOG_DEBUG("Check status\n");
+ // LOG_DEBUG("Check status");
UIFrameEvent e;
if ((this->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) ||
(this->runState == CANNED_MESSAGE_RUN_STATE_ACK_NACK_RECEIVED) || (this->runState == CANNED_MESSAGE_RUN_STATE_MESSAGE)) {
@@ -440,7 +446,7 @@ int32_t CannedMessageModule::runOnce()
this->freetext = ""; // clear freetext
this->cursor = 0;
-#if !defined(T_WATCH_S3) && !defined(RAK14014)
+#if !defined(T_WATCH_S3) && !defined(RAK14014) && !defined(SENSECAP_INDICATOR)
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE;
#endif
@@ -453,7 +459,7 @@ int32_t CannedMessageModule::runOnce()
this->freetext = ""; // clear freetext
this->cursor = 0;
-#if !defined(T_WATCH_S3) && !defined(RAK14014)
+#if !defined(T_WATCH_S3) && !defined(RAK14014) && !defined(USE_VIRTUAL_KEYBOARD)
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE;
#endif
@@ -473,7 +479,7 @@ int32_t CannedMessageModule::runOnce()
powerFSM.trigger(EVENT_PRESS);
return INT32_MAX;
} else {
-#if defined(T_WATCH_S3) || defined(RAK14014)
+#if defined(USE_VIRTUAL_KEYBOARD)
sendText(this->dest, indexChannels[this->channel], this->messages[this->currentMessageIndex], true);
#else
sendText(NODENUM_BROADCAST, channels.getPrimaryIndex(), this->messages[this->currentMessageIndex], true);
@@ -481,7 +487,7 @@ int32_t CannedMessageModule::runOnce()
}
this->runState = CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE;
} else {
- // LOG_DEBUG("Reset message is empty.\n");
+ // LOG_DEBUG("Reset message is empty");
this->runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
}
}
@@ -490,7 +496,7 @@ int32_t CannedMessageModule::runOnce()
this->freetext = ""; // clear freetext
this->cursor = 0;
-#if !defined(T_WATCH_S3) && !defined(RAK14014)
+#if !defined(T_WATCH_S3) && !defined(RAK14014) && !defined(USE_VIRTUAL_KEYBOARD)
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE;
#endif
@@ -498,7 +504,7 @@ int32_t CannedMessageModule::runOnce()
return 2000;
} else if ((this->runState != CANNED_MESSAGE_RUN_STATE_FREETEXT) && (this->currentMessageIndex == -1)) {
this->currentMessageIndex = 0;
- LOG_DEBUG("First touch (%d):%s\n", this->currentMessageIndex, this->getCurrentMessage());
+ LOG_DEBUG("First touch (%d):%s", this->currentMessageIndex, this->getCurrentMessage());
e.action = UIFrameEvent::Action::REGENERATE_FRAMESET; // We want to change the list of frames shown on-screen
this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE;
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_UP) {
@@ -507,12 +513,12 @@ int32_t CannedMessageModule::runOnce()
this->freetext = ""; // clear freetext
this->cursor = 0;
-#if !defined(T_WATCH_S3) && !defined(RAK14014)
+#if !defined(T_WATCH_S3) && !defined(RAK14014) && !defined(USE_VIRTUAL_KEYBOARD)
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE;
#endif
this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE;
- LOG_DEBUG("MOVE UP (%d):%s\n", this->currentMessageIndex, this->getCurrentMessage());
+ LOG_DEBUG("MOVE UP (%d):%s", this->currentMessageIndex, this->getCurrentMessage());
}
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_DOWN) {
if (this->messagesCount > 0) {
@@ -520,12 +526,12 @@ int32_t CannedMessageModule::runOnce()
this->freetext = ""; // clear freetext
this->cursor = 0;
-#if !defined(T_WATCH_S3) && !defined(RAK14014)
+#if !defined(T_WATCH_S3) && !defined(RAK14014) && !defined(USE_VIRTUAL_KEYBOARD)
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE;
#endif
this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE;
- LOG_DEBUG("MOVE DOWN (%d):%s\n", this->currentMessageIndex, this->getCurrentMessage());
+ LOG_DEBUG("MOVE DOWN (%d):%s", this->currentMessageIndex, this->getCurrentMessage());
}
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT || this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE) {
switch (this->payload) {
@@ -666,7 +672,7 @@ int32_t CannedMessageModule::runOnce()
break;
}
if (screen)
- screen->removeFunctionSymbal("Fn");
+ screen->removeFunctionSymbol("Fn");
}
this->lastTouchMillis = millis();
@@ -763,7 +769,7 @@ void CannedMessageModule::showTemporaryMessage(const String &message)
setIntervalFromNow(2000);
}
-#if defined(T_WATCH_S3) || defined(RAK14014)
+#if defined(USE_VIRTUAL_KEYBOARD)
String CannedMessageModule::keyForCoordinates(uint x, uint y)
{
@@ -830,6 +836,11 @@ void CannedMessageModule::drawKeyboard(OLEDDisplay *display, OLEDDisplayUiState
Letter updatedLetter = {letter.character, letter.width, xOffset, yOffset, cellWidth, cellHeight};
+#ifdef RAK14014 // Optimize the touch range of the virtual keyboard in the bottom row
+ if (outerIndex == outerSize - 1) {
+ updatedLetter.rectHeight = 240 - yOffset;
+ }
+#endif
this->keyboard[this->charSet][outerIndex][innerIndex] = updatedLetter;
float characterOffset = ((cellWidth / 2) - (letter.width / 2));
@@ -977,7 +988,7 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
if (temporaryMessage.length() != 0) {
requestFocus(); // Tell Screen::setFrames to move to our module's frame
- LOG_DEBUG("Drawing temporary message: %s", temporaryMessage.c_str());
+ LOG_DEBUG("Draw temporary message: %s", temporaryMessage.c_str());
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->setFont(FONT_MEDIUM);
display->drawString(display->getWidth() / 2 + x, 0 + y + 12, temporaryMessage);
@@ -1044,7 +1055,7 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
display->drawString(10 + x, 0 + y + FONT_HEIGHT_SMALL, "Canned Message\nModule disabled.");
} else if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) {
requestFocus(); // Tell Screen::setFrames to move to our module's frame
-#if defined(T_WATCH_S3) || defined(RAK14014)
+#if defined(USE_VIRTUAL_KEYBOARD)
drawKeyboard(display, state, 0, 0);
#else
@@ -1206,13 +1217,13 @@ AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(const
switch (request->which_payload_variant) {
case meshtastic_AdminMessage_get_canned_message_module_messages_request_tag:
- LOG_DEBUG("Client is getting radio canned messages\n");
+ LOG_DEBUG("Client getting radio canned messages");
this->handleGetCannedMessageModuleMessages(mp, response);
result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE;
break;
case meshtastic_AdminMessage_set_canned_message_module_messages_tag:
- LOG_DEBUG("Client is setting radio canned messages\n");
+ LOG_DEBUG("Client getting radio canned messages");
this->handleSetCannedMessageModuleMessages(request->set_canned_message_module_messages);
result = AdminMessageHandleResult::HANDLED;
break;
@@ -1227,7 +1238,7 @@ AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(const
void CannedMessageModule::handleGetCannedMessageModuleMessages(const meshtastic_MeshPacket &req,
meshtastic_AdminMessage *response)
{
- LOG_DEBUG("*** handleGetCannedMessageModuleMessages\n");
+ LOG_DEBUG("*** handleGetCannedMessageModuleMessages");
if (req.decoded.want_response) {
response->which_payload_variant = meshtastic_AdminMessage_get_canned_message_module_messages_response_tag;
strncpy(response->get_canned_message_module_messages_response, cannedMessageModuleConfig.messages,
@@ -1242,7 +1253,7 @@ void CannedMessageModule::handleSetCannedMessageModuleMessages(const char *from_
if (*from_msg) {
changed |= strcmp(cannedMessageModuleConfig.messages, from_msg);
strncpy(cannedMessageModuleConfig.messages, from_msg, sizeof(cannedMessageModuleConfig.messages));
- LOG_DEBUG("*** from_msg.text:%s\n", from_msg);
+ LOG_DEBUG("*** from_msg.text:%s", from_msg);
}
if (changed) {
@@ -1256,4 +1267,4 @@ String CannedMessageModule::drawWithCursor(String text, int cursor)
return result;
}
-#endif
\ No newline at end of file
+#endif
diff --git a/src/modules/CannedMessageModule.h b/src/modules/CannedMessageModule.h
index e9dc2bda0..fd9ffc9b6 100644
--- a/src/modules/CannedMessageModule.h
+++ b/src/modules/CannedMessageModule.h
@@ -68,6 +68,10 @@ class CannedMessageModule : public SinglePortModule, public Observable 0) {
pinMode(moduleConfig.detection_sensor.monitor_pin, moduleConfig.detection_sensor.use_pullup ? INPUT_PULLUP : INPUT);
} else {
- LOG_WARN("Detection Sensor Module: Set to enabled but no monitor pin is set. Disabling module...\n");
+ LOG_WARN("Detection Sensor Module: Set to enabled but no monitor pin is set. Disable module");
return disable();
}
- LOG_INFO("Detection Sensor Module: Initializing\n");
+ LOG_INFO("Detection Sensor Module: init");
return DELAYED_INTERVAL;
}
- // LOG_DEBUG("Detection Sensor Module: Current pin state: %i\n", digitalRead(moduleConfig.detection_sensor.monitor_pin));
+ // LOG_DEBUG("Detection Sensor Module: Current pin state: %i", digitalRead(moduleConfig.detection_sensor.monitor_pin));
if (!Throttle::isWithinTimespanMs(lastSentToMesh,
Default::getConfiguredOrDefaultMs(moduleConfig.detection_sensor.minimum_broadcast_secs))) {
@@ -118,7 +118,7 @@ int32_t DetectionSensorModule::runOnce()
void DetectionSensorModule::sendDetectionMessage()
{
- LOG_DEBUG("Detected event observed. Sending message\n");
+ LOG_DEBUG("Detected event observed. Send message");
char *message = new char[40];
sprintf(message, "%s detected", moduleConfig.detection_sensor.name);
meshtastic_MeshPacket *p = allocDataPacket();
@@ -130,9 +130,12 @@ void DetectionSensorModule::sendDetectionMessage()
p->decoded.payload.bytes[p->decoded.payload.size + 1] = '\0'; // Bell character
p->decoded.payload.size++;
}
- LOG_INFO("Sending message id=%d, dest=%x, msg=%.*s\n", p->id, p->to, p->decoded.payload.size, p->decoded.payload.bytes);
lastSentToMesh = millis();
- service->sendToMesh(p);
+ if (!channels.isDefaultChannel(0)) {
+ LOG_INFO("Send message id=%d, dest=%x, msg=%.*s", p->id, p->to, p->decoded.payload.size, p->decoded.payload.bytes);
+ service->sendToMesh(p);
+ } else
+ LOG_ERROR("Message not allow on Public channel");
delete[] message;
}
@@ -140,20 +143,22 @@ void DetectionSensorModule::sendCurrentStateMessage(bool state)
{
char *message = new char[40];
sprintf(message, "%s state: %i", moduleConfig.detection_sensor.name, state);
-
meshtastic_MeshPacket *p = allocDataPacket();
p->want_ack = false;
p->decoded.payload.size = strlen(message);
memcpy(p->decoded.payload.bytes, message, p->decoded.payload.size);
- LOG_INFO("Sending message id=%d, dest=%x, msg=%.*s\n", p->id, p->to, p->decoded.payload.size, p->decoded.payload.bytes);
lastSentToMesh = millis();
- service->sendToMesh(p);
+ if (!channels.isDefaultChannel(0)) {
+ LOG_INFO("Send message id=%d, dest=%x, msg=%.*s", p->id, p->to, p->decoded.payload.size, p->decoded.payload.bytes);
+ service->sendToMesh(p);
+ } else
+ LOG_ERROR("Message not allow on Public channel");
delete[] message;
}
bool DetectionSensorModule::hasDetectionEvent()
{
bool currentState = digitalRead(moduleConfig.detection_sensor.monitor_pin);
- // LOG_DEBUG("Detection Sensor Module: Current state: %i\n", currentState);
+ // LOG_DEBUG("Detection Sensor Module: Current state: %i", currentState);
return (moduleConfig.detection_sensor.detection_trigger_type & 1) ? currentState : !currentState;
-}
\ No newline at end of file
+}
diff --git a/src/modules/DetectionSensorModule.h b/src/modules/DetectionSensorModule.h
index b960c8744..3ba10d329 100644
--- a/src/modules/DetectionSensorModule.h
+++ b/src/modules/DetectionSensorModule.h
@@ -4,8 +4,7 @@
class DetectionSensorModule : public SinglePortModule, private concurrency::OSThread
{
public:
- DetectionSensorModule()
- : SinglePortModule("detection", meshtastic_PortNum_DETECTION_SENSOR_APP), OSThread("DetectionSensorModule")
+ DetectionSensorModule() : SinglePortModule("detection", meshtastic_PortNum_DETECTION_SENSOR_APP), OSThread("DetectionSensor")
{
}
diff --git a/src/modules/DropzoneModule.cpp b/src/modules/DropzoneModule.cpp
index b1ca2af81..6c42af98b 100644
--- a/src/modules/DropzoneModule.cpp
+++ b/src/modules/DropzoneModule.cpp
@@ -34,13 +34,13 @@ ProcessMessage DropzoneModule::handleReceived(const meshtastic_MeshPacket &mp)
auto incomingMessage = reinterpret_cast(p.payload.bytes);
sprintf(matchCompare, "%s conditions", owner.short_name);
if (strncasecmp(incomingMessage, matchCompare, strlen(matchCompare)) == 0) {
- LOG_DEBUG("Received dropzone conditions request\n");
+ LOG_DEBUG("Received dropzone conditions request");
startSendConditions = millis();
}
sprintf(matchCompare, "%s conditions", owner.long_name);
if (strncasecmp(incomingMessage, matchCompare, strlen(matchCompare)) == 0) {
- LOG_DEBUG("Received dropzone conditions request\n");
+ LOG_DEBUG("Received dropzone conditions request");
startSendConditions = millis();
}
return ProcessMessage::CONTINUE;
@@ -82,10 +82,10 @@ meshtastic_MeshPacket *DropzoneModule::sendConditions()
sprintf(replyStr, "%s @ %02d:%02d:%02dz\nWind %.2f kts @ %d°\nBaro %.2f inHg %.2f°C", dropzoneStatus, hour, min, sec,
windSpeed, windDirection, baro, temp);
} else {
- LOG_ERROR("No sensor found\n");
+ LOG_ERROR("No sensor found");
sprintf(replyStr, "%s @ %02d:%02d:%02d\nNo sensor found", dropzoneStatus, hour, min, sec);
}
- LOG_DEBUG("Conditions reply: %s\n", replyStr);
+ LOG_DEBUG("Conditions reply: %s", replyStr);
reply->decoded.payload.size = strlen(replyStr); // You must specify how many bytes are in the reply
memcpy(reply->decoded.payload.bytes, replyStr, reply->decoded.payload.size);
diff --git a/src/modules/DropzoneModule.h b/src/modules/DropzoneModule.h
index 28f54ee0f..9e79ab447 100644
--- a/src/modules/DropzoneModule.h
+++ b/src/modules/DropzoneModule.h
@@ -15,7 +15,7 @@ class DropzoneModule : public SinglePortModule, private concurrency::OSThread
/** Constructor
* name is for debugging output
*/
- DropzoneModule() : SinglePortModule("dropzone", meshtastic_PortNum_TEXT_MESSAGE_APP), concurrency::OSThread("DropzoneModule")
+ DropzoneModule() : SinglePortModule("dropzone", meshtastic_PortNum_TEXT_MESSAGE_APP), concurrency::OSThread("Dropzone")
{
// Set up the analog pin for reading the dropzone status
pinMode(PIN_A1, INPUT);
diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp
index 2306119b1..bbb3f90e0 100644
--- a/src/modules/ExternalNotificationModule.cpp
+++ b/src/modules/ExternalNotificationModule.cpp
@@ -93,11 +93,11 @@ int32_t ExternalNotificationModule::runOnce()
nagCycleCutoff = UINT32_MAX;
LOG_INFO("Turning off external notification: ");
for (int i = 0; i < 3; i++) {
- setExternalOff(i);
+ setExternalState(i, false);
externalTurnedOn[i] = 0;
LOG_INFO("%d ", i);
}
- LOG_INFO("\n");
+ LOG_INFO("");
#ifdef HAS_I2S
// GPIO0 is used as mclk for I2S audio and set to OUTPUT by the sound library
// T-Deck uses GPIO0 as trackball button, so restore the mode
@@ -114,17 +114,19 @@ int32_t ExternalNotificationModule::runOnce()
if (externalTurnedOn[0] + (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms
: EXT_NOTIFICATION_MODULE_OUTPUT_MS) <
millis()) {
- getExternal(0) ? setExternalOff(0) : setExternalOn(0);
+ setExternalState(0, !getExternal(0));
}
if (externalTurnedOn[1] + (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms
: EXT_NOTIFICATION_MODULE_OUTPUT_MS) <
millis()) {
- getExternal(1) ? setExternalOff(1) : setExternalOn(1);
+ setExternalState(1, !getExternal(1));
}
if (externalTurnedOn[2] + (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms
: EXT_NOTIFICATION_MODULE_OUTPUT_MS) <
millis()) {
- getExternal(2) ? setExternalOff(2) : setExternalOn(2);
+ LOG_DEBUG("EXTERNAL 2 %d compared to %d", externalTurnedOn[2] + moduleConfig.external_notification.output_ms,
+ millis());
+ setExternalState(2, !getExternal(2));
}
#if defined(HAS_NCP5623) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE)
red = (colorState & 4) ? brightnessValues[brightnessIndex] : 0; // Red enabled on colorState = 4,5,6,7
@@ -184,7 +186,7 @@ int32_t ExternalNotificationModule::runOnce()
}
#endif
// now let the PWM buzzer play
- if (moduleConfig.external_notification.use_pwm) {
+ if (moduleConfig.external_notification.use_pwm && config.device.buzzer_gpio) {
if (rtttl::isPlaying()) {
rtttl::play();
} else if (isNagging && (nagCycleCutoff >= millis())) {
@@ -203,86 +205,42 @@ bool ExternalNotificationModule::wantPacket(const meshtastic_MeshPacket *p)
}
/**
- * Sets the external notification on for the specified index.
+ * Sets the external notification for the specified index.
*
- * @param index The index of the external notification to turn on.
+ * @param index The index of the external notification to change state.
+ * @param on Whether we are turning things on (true) or off (false).
*/
-void ExternalNotificationModule::setExternalOn(uint8_t index)
+void ExternalNotificationModule::setExternalState(uint8_t index, bool on)
{
- externalCurrentState[index] = 1;
+ externalCurrentState[index] = on;
externalTurnedOn[index] = millis();
switch (index) {
case 1:
#ifdef UNPHONE
- unphone.vibe(true); // the unPhone's vibration motor is on a i2c GPIO expander
+ unphone.vibe(on); // the unPhone's vibration motor is on a i2c GPIO expander
#endif
if (moduleConfig.external_notification.output_vibra)
- digitalWrite(moduleConfig.external_notification.output_vibra, true);
+ digitalWrite(moduleConfig.external_notification.output_vibra, on);
break;
case 2:
if (moduleConfig.external_notification.output_buzzer)
- digitalWrite(moduleConfig.external_notification.output_buzzer, true);
+ digitalWrite(moduleConfig.external_notification.output_buzzer, on);
break;
default:
if (output > 0)
- digitalWrite(output, (moduleConfig.external_notification.active ? true : false));
- break;
- }
-
-#ifdef HAS_NCP5623
- if (rgb_found.type == ScanI2C::NCP5623) {
- rgb.setColor(red, green, blue);
- }
-#endif
-#ifdef RGBLED_CA
- analogWrite(RGBLED_RED, 255 - red); // CA type needs reverse logic
- analogWrite(RGBLED_GREEN, 255 - green);
- analogWrite(RGBLED_BLUE, 255 - blue);
-#elif defined(RGBLED_RED)
- analogWrite(RGBLED_RED, red);
- analogWrite(RGBLED_GREEN, green);
- analogWrite(RGBLED_BLUE, blue);
-#endif
-#ifdef HAS_NEOPIXEL
- pixels.fill(pixels.Color(red, green, blue), 0, NEOPIXEL_COUNT);
- pixels.show();
-#endif
-#ifdef UNPHONE
- unphone.rgb(red, green, blue);
-#endif
-#ifdef T_WATCH_S3
- drv.go();
-#endif
-}
-
-void ExternalNotificationModule::setExternalOff(uint8_t index)
-{
- externalCurrentState[index] = 0;
- externalTurnedOn[index] = millis();
-
- switch (index) {
- case 1:
-#ifdef UNPHONE
- unphone.vibe(false); // the unPhone's vibration motor is on a i2c GPIO expander
-#endif
- if (moduleConfig.external_notification.output_vibra)
- digitalWrite(moduleConfig.external_notification.output_vibra, false);
- break;
- case 2:
- if (moduleConfig.external_notification.output_buzzer)
- digitalWrite(moduleConfig.external_notification.output_buzzer, false);
- break;
- default:
- if (output > 0)
- digitalWrite(output, (moduleConfig.external_notification.active ? false : true));
+ digitalWrite(output, (moduleConfig.external_notification.active ? on : !on));
break;
}
#if defined(HAS_NCP5623) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE)
- red = 0;
- green = 0;
- blue = 0;
+ if (!on) {
+ red = 0;
+ green = 0;
+ blue = 0;
+ }
+#endif
+
#ifdef HAS_NCP5623
if (rgb_found.type == ScanI2C::NCP5623) {
rgb.setColor(red, green, blue);
@@ -304,10 +262,12 @@ void ExternalNotificationModule::setExternalOff(uint8_t index)
#ifdef UNPHONE
unphone.rgb(red, green, blue);
#endif
-#endif
-
#ifdef T_WATCH_S3
- drv.stop();
+ if (on) {
+ drv.go();
+ } else {
+ drv.stop();
+ }
#endif
}
@@ -333,7 +293,7 @@ void ExternalNotificationModule::stopNow()
ExternalNotificationModule::ExternalNotificationModule()
: SinglePortModule("ExternalNotificationModule", meshtastic_PortNum_TEXT_MESSAGE_APP),
- concurrency::OSThread("ExternalNotificationModule")
+ concurrency::OSThread("ExternalNotification")
{
/*
Uncomment the preferences below if you want to use the module
@@ -369,34 +329,34 @@ ExternalNotificationModule::ExternalNotificationModule()
sizeof(rtttlConfig.ringtone));
}
- LOG_INFO("Initializing External Notification Module\n");
+ LOG_INFO("Init External Notification Module");
output = moduleConfig.external_notification.output ? moduleConfig.external_notification.output
: EXT_NOTIFICATION_MODULE_OUTPUT;
// Set the direction of a pin
if (output > 0) {
- LOG_INFO("Using Pin %i in digital mode\n", output);
+ LOG_INFO("Use Pin %i in digital mode", output);
pinMode(output, OUTPUT);
}
- setExternalOff(0);
+ setExternalState(0, false);
externalTurnedOn[0] = 0;
if (moduleConfig.external_notification.output_vibra) {
- LOG_INFO("Using Pin %i for vibra motor\n", moduleConfig.external_notification.output_vibra);
+ LOG_INFO("Use Pin %i for vibra motor", moduleConfig.external_notification.output_vibra);
pinMode(moduleConfig.external_notification.output_vibra, OUTPUT);
- setExternalOff(1);
+ setExternalState(1, false);
externalTurnedOn[1] = 0;
}
if (moduleConfig.external_notification.output_buzzer) {
if (!moduleConfig.external_notification.use_pwm) {
- LOG_INFO("Using Pin %i for buzzer\n", moduleConfig.external_notification.output_buzzer);
+ LOG_INFO("Use Pin %i for buzzer", moduleConfig.external_notification.output_buzzer);
pinMode(moduleConfig.external_notification.output_buzzer, OUTPUT);
- setExternalOff(2);
+ setExternalState(2, false);
externalTurnedOn[2] = 0;
} else {
config.device.buzzer_gpio = config.device.buzzer_gpio ? config.device.buzzer_gpio : PIN_BUZZER;
// in PWM Mode we force the buzzer pin if it is set
- LOG_INFO("Using Pin %i in PWM mode\n", config.device.buzzer_gpio);
+ LOG_INFO("Use Pin %i in PWM mode", config.device.buzzer_gpio);
}
}
#ifdef HAS_NCP5623
@@ -421,7 +381,7 @@ ExternalNotificationModule::ExternalNotificationModule()
pixels.setBrightness(moduleConfig.ambient_lighting.current);
#endif
} else {
- LOG_INFO("External Notification Module Disabled\n");
+ LOG_INFO("External Notification Module Disabled");
disable();
}
}
@@ -447,9 +407,9 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
if (moduleConfig.external_notification.alert_bell) {
if (containsBell) {
- LOG_INFO("externalNotificationModule - Notification Bell\n");
+ LOG_INFO("externalNotificationModule - Notification Bell");
isNagging = true;
- setExternalOn(0);
+ setExternalState(0, true);
if (moduleConfig.external_notification.nag_timeout) {
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
} else {
@@ -460,9 +420,9 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
if (moduleConfig.external_notification.alert_bell_vibra) {
if (containsBell) {
- LOG_INFO("externalNotificationModule - Notification Bell (Vibra)\n");
+ LOG_INFO("externalNotificationModule - Notification Bell (Vibra)");
isNagging = true;
- setExternalOn(1);
+ setExternalState(1, true);
if (moduleConfig.external_notification.nag_timeout) {
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
} else {
@@ -473,10 +433,10 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
if (moduleConfig.external_notification.alert_bell_buzzer) {
if (containsBell) {
- LOG_INFO("externalNotificationModule - Notification Bell (Buzzer)\n");
+ LOG_INFO("externalNotificationModule - Notification Bell (Buzzer)");
isNagging = true;
if (!moduleConfig.external_notification.use_pwm) {
- setExternalOn(2);
+ setExternalState(2, true);
} else {
#ifdef HAS_I2S
audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone));
@@ -493,9 +453,9 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
}
if (moduleConfig.external_notification.alert_message) {
- LOG_INFO("externalNotificationModule - Notification Module\n");
+ LOG_INFO("externalNotificationModule - Notification Module");
isNagging = true;
- setExternalOn(0);
+ setExternalState(0, true);
if (moduleConfig.external_notification.nag_timeout) {
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
} else {
@@ -504,9 +464,9 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
}
if (moduleConfig.external_notification.alert_message_vibra) {
- LOG_INFO("externalNotificationModule - Notification Module (Vibra)\n");
+ LOG_INFO("externalNotificationModule - Notification Module (Vibra)");
isNagging = true;
- setExternalOn(1);
+ setExternalState(1, true);
if (moduleConfig.external_notification.nag_timeout) {
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
} else {
@@ -515,10 +475,10 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
}
if (moduleConfig.external_notification.alert_message_buzzer) {
- LOG_INFO("externalNotificationModule - Notification Module (Buzzer)\n");
+ LOG_INFO("externalNotificationModule - Notification Module (Buzzer)");
isNagging = true;
if (!moduleConfig.external_notification.use_pwm && !moduleConfig.external_notification.use_i2s_as_buzzer) {
- setExternalOn(2);
+ setExternalState(2, true);
} else {
#ifdef HAS_I2S
if (moduleConfig.external_notification.use_i2s_as_buzzer) {
@@ -537,7 +497,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
setIntervalFromNow(0); // run once so we know if we should do something
}
} else {
- LOG_INFO("External Notification Module Disabled or muted\n");
+ LOG_INFO("External Notification Module Disabled or muted");
}
return ProcessMessage::CONTINUE; // Let others look at this message also if they want
@@ -560,13 +520,13 @@ AdminMessageHandleResult ExternalNotificationModule::handleAdminMessageForModule
switch (request->which_payload_variant) {
case meshtastic_AdminMessage_get_ringtone_request_tag:
- LOG_INFO("Client is getting ringtone\n");
+ LOG_INFO("Client getting ringtone");
this->handleGetRingtone(mp, response);
result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE;
break;
case meshtastic_AdminMessage_set_ringtone_message_tag:
- LOG_INFO("Client is setting ringtone\n");
+ LOG_INFO("Client setting ringtone");
this->handleSetRingtone(request->set_canned_message_module_messages);
result = AdminMessageHandleResult::HANDLED;
break;
@@ -580,7 +540,7 @@ AdminMessageHandleResult ExternalNotificationModule::handleAdminMessageForModule
void ExternalNotificationModule::handleGetRingtone(const meshtastic_MeshPacket &req, meshtastic_AdminMessage *response)
{
- LOG_INFO("*** handleGetRingtone\n");
+ LOG_INFO("*** handleGetRingtone");
if (req.decoded.want_response) {
response->which_payload_variant = meshtastic_AdminMessage_get_ringtone_response_tag;
strncpy(response->get_ringtone_response, rtttlConfig.ringtone, sizeof(response->get_ringtone_response));
@@ -594,7 +554,7 @@ void ExternalNotificationModule::handleSetRingtone(const char *from_msg)
if (*from_msg) {
changed |= strcmp(rtttlConfig.ringtone, from_msg);
strncpy(rtttlConfig.ringtone, from_msg, sizeof(rtttlConfig.ringtone));
- LOG_INFO("*** from_msg.text:%s\n", from_msg);
+ LOG_INFO("*** from_msg.text:%s", from_msg);
}
if (changed) {
diff --git a/src/modules/ExternalNotificationModule.h b/src/modules/ExternalNotificationModule.h
index a5dff3651..841ca6de9 100644
--- a/src/modules/ExternalNotificationModule.h
+++ b/src/modules/ExternalNotificationModule.h
@@ -32,10 +32,9 @@ class ExternalNotificationModule : public SinglePortModule, private concurrency:
public:
ExternalNotificationModule();
- uint32_t nagCycleCutoff = UINT32_MAX;
+ uint32_t nagCycleCutoff = 1;
- void setExternalOn(uint8_t index = 0);
- void setExternalOff(uint8_t index = 0);
+ void setExternalState(uint8_t index = 0, bool on = false);
bool getExternal(uint8_t index = 0);
void setMute(bool mute) { isMuted = mute; }
diff --git a/src/modules/NeighborInfoModule.cpp b/src/modules/NeighborInfoModule.cpp
index e4c9b44bd..fb658421d 100644
--- a/src/modules/NeighborInfoModule.cpp
+++ b/src/modules/NeighborInfoModule.cpp
@@ -14,11 +14,11 @@ NOTE: For debugging only
*/
void NeighborInfoModule::printNeighborInfo(const char *header, const meshtastic_NeighborInfo *np)
{
- LOG_DEBUG("%s NEIGHBORINFO PACKET from Node 0x%x to Node 0x%x (last sent by 0x%x)\n", header, np->node_id,
- nodeDB->getNodeNum(), np->last_sent_by_id);
- LOG_DEBUG("Packet contains %d neighbors\n", np->neighbors_count);
+ LOG_DEBUG("%s NEIGHBORINFO PACKET from Node 0x%x to Node 0x%x (last sent by 0x%x)", header, np->node_id, nodeDB->getNodeNum(),
+ np->last_sent_by_id);
+ LOG_DEBUG("Packet contains %d neighbors", np->neighbors_count);
for (int i = 0; i < np->neighbors_count; i++) {
- LOG_DEBUG("Neighbor %d: node_id=0x%x, snr=%.2f\n", i, np->neighbors[i].node_id, np->neighbors[i].snr);
+ LOG_DEBUG("Neighbor %d: node_id=0x%x, snr=%.2f", i, np->neighbors[i].node_id, np->neighbors[i].snr);
}
}
@@ -28,16 +28,16 @@ NOTE: for debugging only
*/
void NeighborInfoModule::printNodeDBNeighbors()
{
- LOG_DEBUG("Our NodeDB contains %d neighbors\n", neighbors.size());
+ LOG_DEBUG("Our NodeDB contains %d neighbors", neighbors.size());
for (size_t i = 0; i < neighbors.size(); i++) {
- LOG_DEBUG("Node %d: node_id=0x%x, snr=%.2f\n", i, neighbors[i].node_id, neighbors[i].snr);
+ LOG_DEBUG("Node %d: node_id=0x%x, snr=%.2f", i, neighbors[i].node_id, neighbors[i].snr);
}
}
/* Send our initial owner announcement 35 seconds after we start (to give network time to setup) */
NeighborInfoModule::NeighborInfoModule()
: ProtobufModule("neighborinfo", meshtastic_PortNum_NEIGHBORINFO_APP, &meshtastic_NeighborInfo_msg),
- concurrency::OSThread("NeighborInfoModule")
+ concurrency::OSThread("NeighborInfo")
{
ourPortNum = meshtastic_PortNum_NEIGHBORINFO_APP;
nodeStatusObserver.observe(&nodeStatus->onNewStatus);
@@ -47,7 +47,7 @@ NeighborInfoModule::NeighborInfoModule()
setIntervalFromNow(Default::getConfiguredOrDefaultMs(moduleConfig.neighbor_info.update_interval,
default_telemetry_broadcast_interval_secs));
} else {
- LOG_DEBUG("NeighborInfoModule is disabled\n");
+ LOG_DEBUG("NeighborInfoModule is disabled");
disable();
}
}
@@ -91,7 +91,7 @@ void NeighborInfoModule::cleanUpNeighbors()
// We will remove a neighbor if we haven't heard from them in twice the broadcast interval
// cannot use isWithinTimespanMs() as it->last_rx_time is seconds since 1970
if ((now - it->last_rx_time > it->node_broadcast_interval_secs * 2) && (it->node_id != my_node_id)) {
- LOG_DEBUG("Removing neighbor with node ID 0x%x\n", it->node_id);
+ LOG_DEBUG("Remove neighbor with node ID 0x%x", it->node_id);
it = std::vector::reverse_iterator(
neighbors.erase(std::next(it).base())); // Erase the element and update the iterator
} else {
@@ -121,14 +121,17 @@ Will be used for broadcast.
*/
int32_t NeighborInfoModule::runOnce()
{
- if (airTime->isTxAllowedChannelUtil(true) && airTime->isTxAllowedAirUtil()) {
+ if (moduleConfig.neighbor_info.transmit_over_lora && !channels.isDefaultChannel(channels.getPrimaryIndex()) &&
+ airTime->isTxAllowedChannelUtil(true) && airTime->isTxAllowedAirUtil()) {
sendNeighborInfo(NODENUM_BROADCAST, false);
+ } else {
+ sendNeighborInfo(NODENUM_BROADCAST_NO_LORA, false);
}
return Default::getConfiguredOrDefaultMs(moduleConfig.neighbor_info.update_interval, default_neighbor_info_broadcast_secs);
}
/*
-Collect a recieved neighbor info packet from another node
+Collect a received neighbor info packet from another node
Pass it to an upper client; do not persist this data on the mesh
*/
bool NeighborInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_NeighborInfo *np)
@@ -205,7 +208,7 @@ meshtastic_Neighbor *NeighborInfoModule::getOrCreateNeighbor(NodeNum originalSen
neighbors.push_back(new_nbr);
} else {
// If we have too many neighbors, replace the oldest one
- LOG_WARN("Neighbor DB is full, replacing oldest neighbor\n");
+ LOG_WARN("Neighbor DB is full, replace oldest neighbor");
neighbors.erase(neighbors.begin());
neighbors.push_back(new_nbr);
}
diff --git a/src/modules/NodeInfoModule.cpp b/src/modules/NodeInfoModule.cpp
index 61ec375cc..b55d47d5b 100644
--- a/src/modules/NodeInfoModule.cpp
+++ b/src/modules/NodeInfoModule.cpp
@@ -16,7 +16,7 @@ bool NodeInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
bool hasChanged = nodeDB->updateUser(getFrom(&mp), p, mp.channel);
- bool wasBroadcast = mp.to == NODENUM_BROADCAST;
+ bool wasBroadcast = isBroadcast(mp.to);
// Show new nodes on LCD screen
if (wasBroadcast) {
@@ -29,7 +29,7 @@ bool NodeInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
if (hasChanged && !wasBroadcast && !isToUs(&mp))
service->sendToPhone(packetPool.allocCopy(mp));
- // LOG_DEBUG("did handleReceived\n");
+ // LOG_DEBUG("did handleReceived");
return false; // Let others look at this message also if they want
}
@@ -50,7 +50,7 @@ void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies, uint8_t cha
else
p->priority = meshtastic_MeshPacket_Priority_BACKGROUND;
if (channel > 0) {
- LOG_DEBUG("sending ourNodeInfo to channel %d\n", channel);
+ LOG_DEBUG("Send ourNodeInfo to channel %d", channel);
p->channel = channel;
}
@@ -65,30 +65,36 @@ meshtastic_MeshPacket *NodeInfoModule::allocReply()
{
if (!airTime->isTxAllowedChannelUtil(false)) {
ignoreRequest = true; // Mark it as ignored for MeshModule
- LOG_DEBUG("Skip sending NodeInfo due to > 40 percent channel util.\n");
+ LOG_DEBUG("Skip send NodeInfo > 40%% ch. util");
return NULL;
}
// If we sent our NodeInfo less than 5 min. ago, don't send it again as it may be still underway.
if (!shorterTimeout && lastSentToMesh && Throttle::isWithinTimespanMs(lastSentToMesh, 5 * 60 * 1000)) {
- LOG_DEBUG("Skip sending NodeInfo since we just sent it less than 5 minutes ago.\n");
+ LOG_DEBUG("Skip send NodeInfo since we sent it <5min ago");
ignoreRequest = true; // Mark it as ignored for MeshModule
return NULL;
} else if (shorterTimeout && lastSentToMesh && Throttle::isWithinTimespanMs(lastSentToMesh, 60 * 1000)) {
- LOG_DEBUG("Skip sending actively requested NodeInfo since we just sent it less than 60 seconds ago.\n");
+ LOG_DEBUG("Skip send NodeInfo since we sent it <60s ago");
ignoreRequest = true; // Mark it as ignored for MeshModule
return NULL;
} else {
ignoreRequest = false; // Don't ignore requests anymore
meshtastic_User &u = owner;
- LOG_INFO("sending owner %s/%s/%s\n", u.id, u.long_name, u.short_name);
+ // Strip the public key if the user is licensed
+ if (u.is_licensed && u.public_key.size > 0) {
+ u.public_key.bytes[0] = 0;
+ u.public_key.size = 0;
+ }
+
+ LOG_INFO("Send owner %s/%s/%s", u.id, u.long_name, u.short_name);
lastSentToMesh = millis();
return allocDataProtobuf(u);
}
}
NodeInfoModule::NodeInfoModule()
- : ProtobufModule("nodeinfo", meshtastic_PortNum_NODEINFO_APP, &meshtastic_User_msg), concurrency::OSThread("NodeInfoModule")
+ : ProtobufModule("nodeinfo", meshtastic_PortNum_NODEINFO_APP, &meshtastic_User_msg), concurrency::OSThread("NodeInfo")
{
isPromiscuous = true; // We always want to update our nodedb, even if we are sniffing on others
setIntervalFromNow(30 *
@@ -102,8 +108,8 @@ int32_t NodeInfoModule::runOnce()
currentGeneration = radioGeneration;
if (airTime->isTxAllowedAirUtil() && config.device.role != meshtastic_Config_DeviceConfig_Role_CLIENT_HIDDEN) {
- LOG_INFO("Sending our nodeinfo to mesh (wantReplies=%d)\n", requestReplies);
+ LOG_INFO("Send our nodeinfo to mesh (wantReplies=%d)", requestReplies);
sendOurNodeInfo(NODENUM_BROADCAST, requestReplies); // Send our info (don't request replies)
}
return Default::getConfiguredOrDefaultMs(config.device.node_info_broadcast_secs, default_node_info_broadcast_secs);
-}
\ No newline at end of file
+}
diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp
index 6ad30f927..6285d7aa5 100644
--- a/src/modules/PositionModule.cpp
+++ b/src/modules/PositionModule.cpp
@@ -16,16 +16,12 @@
#include "meshtastic/atak.pb.h"
#include "sleep.h"
#include "target_specific.h"
-
-extern "C" {
#include
-}
PositionModule *positionModule;
PositionModule::PositionModule()
- : ProtobufModule("position", meshtastic_PortNum_POSITION_APP, &meshtastic_Position_msg),
- concurrency::OSThread("PositionModule")
+ : ProtobufModule("position", meshtastic_PortNum_POSITION_APP, &meshtastic_Position_msg), concurrency::OSThread("Position")
{
precision = 0; // safe starting value
isPromiscuous = true; // We always want to update our nodedb, even if we are sniffing on others
@@ -39,7 +35,7 @@ PositionModule::PositionModule()
if ((config.device.role == meshtastic_Config_DeviceConfig_Role_TRACKER ||
config.device.role == meshtastic_Config_DeviceConfig_Role_TAK_TRACKER) &&
config.power.is_power_saving) {
- LOG_DEBUG("Clearing position on startup for sleepy tracker (ー。ー) zzz\n");
+ LOG_DEBUG("Clear position on startup for sleepy tracker (ー。ー) zzz");
nodeDB->clearLocalPosition();
}
}
@@ -57,7 +53,7 @@ bool PositionModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
if (isFromUs(&mp)) {
isLocal = true;
if (config.position.fixed_position) {
- LOG_DEBUG("Ignore incoming position update from myself except for time, because position.fixed_position is true\n");
+ LOG_DEBUG("Ignore incoming position update from myself except for time, because position.fixed_position is true");
#ifdef T_WATCH_S3
// Since we return early if position.fixed_position is true, set the T-Watch's RTC to the time received from the
@@ -70,14 +66,14 @@ bool PositionModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
nodeDB->setLocalPosition(p, true);
return false;
} else {
- LOG_DEBUG("Incoming update from MYSELF\n");
+ LOG_DEBUG("Incoming update from MYSELF");
nodeDB->setLocalPosition(p);
}
}
// Log packet size and data fields
LOG_DEBUG("POSITION node=%08x l=%d lat=%d lon=%d msl=%d hae=%d geo=%d pdop=%d hdop=%d vdop=%d siv=%d fxq=%d fxt=%d pts=%d "
- "time=%d\n",
+ "time=%d",
getFrom(&mp), mp.decoded.payload.size, p.latitude_i, p.longitude_i, p.altitude, p.altitude_hae,
p.altitude_geoidal_separation, p.PDOP, p.HDOP, p.VDOP, p.sats_in_view, p.fix_quality, p.fix_type, p.timestamp,
p.time);
@@ -111,7 +107,7 @@ void PositionModule::alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtastic
{
// Phone position packets need to be truncated to the channel precision
if (isFromUs(&mp) && (precision < 32 && precision > 0)) {
- LOG_DEBUG("Truncating phone position to channel precision %i\n", precision);
+ LOG_DEBUG("Truncate phone position to channel precision %i", precision);
p->latitude_i = p->latitude_i & (UINT32_MAX << (32 - precision));
p->longitude_i = p->longitude_i & (UINT32_MAX << (32 - precision));
@@ -127,11 +123,11 @@ void PositionModule::alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtastic
void PositionModule::trySetRtc(meshtastic_Position p, bool isLocal, bool forceUpdate)
{
if (hasQualityTimesource() && !isLocal) {
- LOG_DEBUG("Ignoring time from mesh because we have a GPS, RTC, or Phone/NTP time source in the past day\n");
+ LOG_DEBUG("Ignore time from mesh because we have a GPS, RTC, or Phone/NTP time source in the past day");
return;
}
if (!isLocal && p.location_source < meshtastic_Position_LocSource_LOC_INTERNAL) {
- LOG_DEBUG("Ignoring time from mesh because it has a unknown or manual source\n");
+ LOG_DEBUG("Ignore time from mesh because it has a unknown or manual source");
return;
}
struct timeval tv;
@@ -150,15 +146,24 @@ bool PositionModule::hasQualityTimesource()
#if MESHTASTIC_EXCLUDE_GPS
bool hasGpsOrRtc = (rtc_found.address != ScanI2C::ADDRESS_NONE.address);
#else
- bool hasGpsOrRtc = (gps && gps->isConnected()) || (rtc_found.address != ScanI2C::ADDRESS_NONE.address);
+ bool hasGpsOrRtc = hasGPS() || (rtc_found.address != ScanI2C::ADDRESS_NONE.address);
#endif
return hasGpsOrRtc || setFromPhoneOrNtpToday;
}
+bool PositionModule::hasGPS()
+{
+#if MESHTASTIC_EXCLUDE_GPS
+ return false;
+#else
+ return gps && gps->isConnected();
+#endif
+}
+
meshtastic_MeshPacket *PositionModule::allocReply()
{
if (precision == 0) {
- LOG_DEBUG("Skipping location send because precision is set to 0!\n");
+ LOG_DEBUG("Skip location send because precision is set to 0!");
return nullptr;
}
@@ -178,12 +183,12 @@ meshtastic_MeshPacket *PositionModule::allocReply()
localPosition.seq_number++;
if (localPosition.latitude_i == 0 && localPosition.longitude_i == 0) {
- LOG_WARN("Skipping position send because lat/lon are zero!\n");
+ LOG_WARN("Skip position send because lat/lon are zero!");
return nullptr;
}
// lat/lon are unconditionally included - IF AVAILABLE!
- LOG_DEBUG("Sending location with precision %i\n", precision);
+ LOG_DEBUG("Send location with precision %i", precision);
if (precision < 32 && precision > 0) {
p.latitude_i = localPosition.latitude_i & (UINT32_MAX << (32 - precision));
p.longitude_i = localPosition.longitude_i & (UINT32_MAX << (32 - precision));
@@ -198,10 +203,21 @@ meshtastic_MeshPacket *PositionModule::allocReply()
p.precision_bits = precision;
p.has_latitude_i = true;
p.has_longitude_i = true;
- p.time = getValidTime(RTCQualityNTP) > 0 ? getValidTime(RTCQualityNTP) : localPosition.time;
+ // Always use NTP / GPS time if available
+ if (getValidTime(RTCQualityNTP) > 0) {
+ p.time = getValidTime(RTCQualityNTP);
+ } else if (rtc_found.address != ScanI2C::ADDRESS_NONE.address) {
+ LOG_INFO("Use RTC time for position");
+ p.time = getValidTime(RTCQualityDevice);
+ } else if (getRTCQuality() < RTCQualityNTP) {
+ LOG_INFO("Strip low RTCQuality (%d) time from position", getRTCQuality());
+ p.time = 0;
+ }
if (config.position.fixed_position) {
p.location_source = meshtastic_Position_LocSource_LOC_MANUAL;
+ } else {
+ p.location_source = localPosition.location_source;
}
if (pos_flags & meshtastic_Config_PositionConfig_PositionFlags_ALTITUDE) {
@@ -246,18 +262,7 @@ meshtastic_MeshPacket *PositionModule::allocReply()
p.has_ground_speed = true;
}
- // Strip out any time information before sending packets to other nodes - to keep the wire size small (and because other
- // nodes shouldn't trust it anyways) Note: we allow a device with a local GPS or NTP to include the time, so that devices
- // without can get time.
- if (getRTCQuality() < RTCQualityNTP) {
- LOG_INFO("Stripping time %u from position send\n", p.time);
- p.time = 0;
- } else {
- p.time = getValidTime(RTCQualityNTP);
- LOG_INFO("Providing time to mesh %u\n", p.time);
- }
-
- LOG_INFO("Position reply: time=%i lat=%i lon=%i\n", p.time, p.latitude_i, p.longitude_i);
+ LOG_INFO("Position reply: time=%i lat=%i lon=%i", p.time, p.latitude_i, p.longitude_i);
// TAK Tracker devices should send their position in a TAK packet over the ATAK port
if (config.device.role == meshtastic_Config_DeviceConfig_Role_TAK_TRACKER)
@@ -268,7 +273,7 @@ meshtastic_MeshPacket *PositionModule::allocReply()
meshtastic_MeshPacket *PositionModule::allocAtakPli()
{
- LOG_INFO("Sending TAK PLI packet\n");
+ LOG_INFO("Send TAK PLI packet");
meshtastic_MeshPacket *mp = allocDataPacket();
mp->decoded.portnum = meshtastic_PortNum_ATAK_PLUGIN;
@@ -293,8 +298,8 @@ meshtastic_MeshPacket *PositionModule::allocAtakPli()
auto length = unishox2_compress_lines(owner.long_name, strlen(owner.long_name), takPacket.contact.device_callsign,
sizeof(takPacket.contact.device_callsign) - 1, USX_PSET_DFLT, NULL);
- LOG_DEBUG("Uncompressed device_callsign '%s' - %d bytes\n", owner.long_name, strlen(owner.long_name));
- LOG_DEBUG("Compressed device_callsign '%s' - %d bytes\n", takPacket.contact.device_callsign, length);
+ LOG_DEBUG("Uncompressed device_callsign '%s' - %d bytes", owner.long_name, strlen(owner.long_name));
+ LOG_DEBUG("Compressed device_callsign '%s' - %d bytes", takPacket.contact.device_callsign, length);
length = unishox2_compress_lines(owner.long_name, strlen(owner.long_name), takPacket.contact.callsign,
sizeof(takPacket.contact.callsign) - 1, USX_PSET_DFLT, NULL);
mp->decoded.payload.size =
@@ -308,7 +313,7 @@ void PositionModule::sendOurPosition()
currentGeneration = radioGeneration;
// If we changed channels, ask everyone else for their latest info
- LOG_INFO("Sending pos@%x:6 to mesh (wantReplies=%d)\n", localPosition.timestamp, requestReplies);
+ LOG_INFO("Send pos@%x:6 to mesh (wantReplies=%d)", localPosition.timestamp, requestReplies);
sendOurPosition(NODENUM_BROADCAST, requestReplies);
}
@@ -330,7 +335,7 @@ void PositionModule::sendOurPosition(NodeNum dest, bool wantReplies, uint8_t cha
meshtastic_MeshPacket *p = allocReply();
if (p == nullptr) {
- LOG_DEBUG("allocReply returned a nullptr\n");
+ LOG_DEBUG("allocReply returned a nullptr");
return;
}
@@ -351,7 +356,7 @@ void PositionModule::sendOurPosition(NodeNum dest, bool wantReplies, uint8_t cha
if (IS_ONE_OF(config.device.role, meshtastic_Config_DeviceConfig_Role_TRACKER,
meshtastic_Config_DeviceConfig_Role_TAK_TRACKER) &&
config.power.is_power_saving) {
- LOG_DEBUG("Starting next execution in 5 seconds and then going to sleep.\n");
+ LOG_DEBUG("Start next execution in 5s, then sleep");
sleepOnNextExecution = true;
setIntervalFromNow(5000);
}
@@ -364,8 +369,8 @@ int32_t PositionModule::runOnce()
if (sleepOnNextExecution == true) {
sleepOnNextExecution = false;
uint32_t nightyNightMs = Default::getConfiguredOrDefaultMs(config.position.position_broadcast_secs);
- LOG_DEBUG("Sleeping for %ims, then awaking to send position again.\n", nightyNightMs);
- doDeepSleep(nightyNightMs, false);
+ LOG_DEBUG("Sleep for %ims, then awaking to send position again", nightyNightMs);
+ doDeepSleep(nightyNightMs, false, false);
}
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeDB->getNodeNum());
@@ -384,7 +389,7 @@ int32_t PositionModule::runOnce()
}
if (lastGpsSend == 0 || msSinceLastSend >= intervalMs) {
- if (hasValidPosition(node)) {
+ if (nodeDB->hasValidPosition(node)) {
lastGpsSend = now;
lastGpsLatitude = node->position.latitude_i;
@@ -398,7 +403,7 @@ int32_t PositionModule::runOnce()
} else if (config.position.position_broadcast_smart_enabled) {
const meshtastic_NodeInfoLite *node2 = service->refreshLocalMeshNode(); // should guarantee there is now a position
- if (hasValidPosition(node2)) {
+ if (nodeDB->hasValidPosition(node2)) {
// The minimum time (in seconds) that would pass before we are able to send a new position packet.
auto smartPosition = getDistanceTraveledSinceLastSend(node->position);
@@ -407,10 +412,10 @@ int32_t PositionModule::runOnce()
if (smartPosition.hasTraveledOverThreshold &&
Throttle::execute(
&lastGpsSend, minimumTimeThreshold, []() { positionModule->sendOurPosition(); },
- []() { LOG_DEBUG("Skipping send smart broadcast due to time throttling\n"); })) {
+ []() { LOG_DEBUG("Skip send smart broadcast due to time throttling"); })) {
LOG_DEBUG("Sent smart pos@%x:6 to mesh (distanceTraveled=%fm, minDistanceThreshold=%im, timeElapsed=%ims, "
- "minTimeInterval=%ims)\n",
+ "minTimeInterval=%ims)",
localPosition.timestamp, smartPosition.distanceTraveled, smartPosition.distanceThreshold,
msSinceLastSend, minimumTimeThreshold);
@@ -449,23 +454,6 @@ struct SmartPosition PositionModule::getDistanceTraveledSinceLastSend(meshtastic
float distanceTraveledSinceLastSend = GeoCoord::latLongToMeter(
lastGpsLatitude * 1e-7, lastGpsLongitude * 1e-7, currentPosition.latitude_i * 1e-7, currentPosition.longitude_i * 1e-7);
-#ifdef GPS_EXTRAVERBOSE
- LOG_DEBUG("--------LAST POSITION------------------------------------\n");
- LOG_DEBUG("lastGpsLatitude=%i, lastGpsLatitude=%i\n", lastGpsLatitude, lastGpsLongitude);
-
- LOG_DEBUG("--------CURRENT POSITION---------------------------------\n");
- LOG_DEBUG("currentPosition.latitude_i=%i, currentPosition.longitude_i=%i\n", lastGpsLatitude, lastGpsLongitude);
-
- LOG_DEBUG("--------SMART POSITION-----------------------------------\n");
- LOG_DEBUG("hasTraveledOverThreshold=%i, distanceTraveled=%f, distanceThreshold=%f\n",
- abs(distanceTraveledSinceLastSend) >= distanceTravelThreshold, abs(distanceTraveledSinceLastSend),
- distanceTravelThreshold);
-
- if (abs(distanceTraveledSinceLastSend) >= distanceTravelThreshold) {
- LOG_DEBUG("\n\n\nSMART SEEEEEEEEENDING\n\n\n");
- }
-#endif
-
return SmartPosition{.distanceTraveled = abs(distanceTraveledSinceLastSend),
.distanceThreshold = distanceTravelThreshold,
.hasTraveledOverThreshold = abs(distanceTraveledSinceLastSend) >= distanceTravelThreshold};
@@ -476,15 +464,15 @@ void PositionModule::handleNewPosition()
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeDB->getNodeNum());
const meshtastic_NodeInfoLite *node2 = service->refreshLocalMeshNode(); // should guarantee there is now a position
// We limit our GPS broadcasts to a max rate
- if (hasValidPosition(node2)) {
+ if (nodeDB->hasValidPosition(node2)) {
auto smartPosition = getDistanceTraveledSinceLastSend(node->position);
uint32_t msSinceLastSend = millis() - lastGpsSend;
if (smartPosition.hasTraveledOverThreshold &&
Throttle::execute(
&lastGpsSend, minimumTimeThreshold, []() { positionModule->sendOurPosition(); },
- []() { LOG_DEBUG("Skipping send smart broadcast due to time throttling\n"); })) {
+ []() { LOG_DEBUG("Skip send smart broadcast due to time throttling"); })) {
LOG_DEBUG("Sent smart pos@%x:6 to mesh (distanceTraveled=%fm, minDistanceThreshold=%im, timeElapsed=%ims, "
- "minTimeInterval=%ims)\n",
+ "minTimeInterval=%ims)",
localPosition.timestamp, smartPosition.distanceTraveled, smartPosition.distanceThreshold, msSinceLastSend,
minimumTimeThreshold);
diff --git a/src/modules/PositionModule.h b/src/modules/PositionModule.h
index 41b86b795..1e4aa5d29 100644
--- a/src/modules/PositionModule.h
+++ b/src/modules/PositionModule.h
@@ -61,6 +61,7 @@ class PositionModule : public ProtobufModule, private concu
uint32_t precision;
void sendLostAndFoundText();
bool hasQualityTimesource();
+ bool hasGPS();
const uint32_t minimumTimeThreshold =
Default::getConfiguredOrDefaultMs(config.position.broadcast_smart_minimum_interval_secs, 30);
diff --git a/src/modules/PowerStressModule.cpp b/src/modules/PowerStressModule.cpp
index 48159ba54..d487fe6fc 100644
--- a/src/modules/PowerStressModule.cpp
+++ b/src/modules/PowerStressModule.cpp
@@ -15,7 +15,7 @@ extern void printInfo();
PowerStressModule::PowerStressModule()
: ProtobufModule("powerstress", meshtastic_PortNum_POWERSTRESS_APP, &meshtastic_PowerStressMessage_msg),
- concurrency::OSThread("PowerStressModule")
+ concurrency::OSThread("PowerStress")
{
}
@@ -24,12 +24,12 @@ bool PowerStressModule::handleReceivedProtobuf(const meshtastic_MeshPacket &req,
// We only respond to messages if powermon debugging is already on
if (config.power.powermon_enables) {
auto p = *pptr;
- LOG_INFO("Received PowerStress cmd=%d\n", p.cmd);
+ LOG_INFO("Received PowerStress cmd=%d", p.cmd);
// Some commands we can handle immediately, anything else gets deferred to be handled by our thread
switch (p.cmd) {
case meshtastic_PowerStressMessage_Opcode_UNSET:
- LOG_ERROR("PowerStress operation unset\n");
+ LOG_ERROR("PowerStress operation unset");
break;
case meshtastic_PowerStressMessage_Opcode_PRINT_INFO:
@@ -42,7 +42,7 @@ bool PowerStressModule::handleReceivedProtobuf(const meshtastic_MeshPacket &req,
default:
if (currentMessage.cmd != meshtastic_PowerStressMessage_Opcode_UNSET)
- LOG_ERROR("PowerStress operation %d already in progress! Can't start new command\n", currentMessage.cmd);
+ LOG_ERROR("PowerStress operation %d already in progress! Can't start new command", currentMessage.cmd);
else
currentMessage = p; // copy for use by thread (the message provided to us will be getting freed)
break;
@@ -67,13 +67,13 @@ int32_t PowerStressModule::runOnce()
p.cmd = meshtastic_PowerStressMessage_Opcode_UNSET;
p.num_seconds = 0;
isRunningCommand = false;
- LOG_INFO("S:PS:%u\n", p.cmd);
+ LOG_INFO("S:PS:%u", p.cmd);
} else {
if (p.cmd != meshtastic_PowerStressMessage_Opcode_UNSET) {
sleep_msec = (int32_t)(p.num_seconds * 1000);
isRunningCommand = !!sleep_msec; // if the command wants us to sleep, make sure to mark that we have something running
LOG_INFO(
- "S:PS:%u\n",
+ "S:PS:%u",
p.cmd); // Emit a structured log saying we are starting a powerstress state (to make it easier to parse later)
switch (p.cmd) {
@@ -111,7 +111,7 @@ int32_t PowerStressModule::runOnce()
setBluetoothEnable(true);
break;
case meshtastic_PowerStressMessage_Opcode_CPU_DEEPSLEEP:
- doDeepSleep(sleep_msec, true);
+ doDeepSleep(sleep_msec, true, true);
break;
case meshtastic_PowerStressMessage_Opcode_CPU_FULLON: {
uint32_t start_msec = millis();
@@ -124,7 +124,7 @@ int32_t PowerStressModule::runOnce()
// FIXME - implement
break;
default:
- LOG_ERROR("PowerStress operation %d not yet implemented!\n", p.cmd);
+ LOG_ERROR("PowerStress operation %d not yet implemented!", p.cmd);
sleep_msec = 0; // Don't do whatever sleep was requested...
break;
}
diff --git a/src/modules/RangeTestModule.cpp b/src/modules/RangeTestModule.cpp
index e78b4e68d..bf842ce55 100644
--- a/src/modules/RangeTestModule.cpp
+++ b/src/modules/RangeTestModule.cpp
@@ -24,7 +24,7 @@
RangeTestModule *rangeTestModule;
RangeTestModuleRadio *rangeTestModuleRadio;
-RangeTestModule::RangeTestModule() : concurrency::OSThread("RangeTestModule") {}
+RangeTestModule::RangeTestModule() : concurrency::OSThread("RangeTest") {}
uint32_t packetSequence = 0;
@@ -54,11 +54,11 @@ int32_t RangeTestModule::runOnce()
firstTime = 0;
if (moduleConfig.range_test.sender) {
- LOG_INFO("Initializing Range Test Module -- Sender\n");
+ LOG_INFO("Init Range Test Module -- Sender");
started = millis(); // make a note of when we started
return (5000); // Sending first message 5 seconds after initialization.
} else {
- LOG_INFO("Initializing Range Test Module -- Receiver\n");
+ LOG_INFO("Init Range Test Module -- Receiver");
return disable();
// This thread does not need to run as a receiver
}
@@ -66,13 +66,13 @@ int32_t RangeTestModule::runOnce()
if (moduleConfig.range_test.sender) {
// If sender
- LOG_INFO("Range Test Module - Sending heartbeat every %d ms\n", (senderHeartbeat));
+ LOG_INFO("Range Test Module - Sending heartbeat every %d ms", (senderHeartbeat));
- LOG_INFO("gpsStatus->getLatitude() %d\n", gpsStatus->getLatitude());
- LOG_INFO("gpsStatus->getLongitude() %d\n", gpsStatus->getLongitude());
- LOG_INFO("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock());
- LOG_INFO("gpsStatus->getDOP() %d\n", gpsStatus->getDOP());
- LOG_INFO("fixed_position() %d\n", config.position.fixed_position);
+ LOG_INFO("gpsStatus->getLatitude() %d", gpsStatus->getLatitude());
+ LOG_INFO("gpsStatus->getLongitude() %d", gpsStatus->getLongitude());
+ LOG_INFO("gpsStatus->getHasLock() %d", gpsStatus->getHasLock());
+ LOG_INFO("gpsStatus->getDOP() %d", gpsStatus->getDOP());
+ LOG_INFO("fixed_position() %d", config.position.fixed_position);
// Only send packets if the channel is less than 25% utilized.
if (airTime->isTxAllowedChannelUtil(true)) {
@@ -81,7 +81,7 @@ int32_t RangeTestModule::runOnce()
// If we have been running for more than 8 hours, turn module back off
if (!Throttle::isWithinTimespanMs(started, 28800000)) {
- LOG_INFO("Range Test Module - Disabling after 8 hours\n");
+ LOG_INFO("Range Test Module - Disable after 8 hours");
return disable();
} else {
return (senderHeartbeat);
@@ -92,7 +92,7 @@ int32_t RangeTestModule::runOnce()
}
}
} else {
- LOG_INFO("Range Test Module - Disabled\n");
+ LOG_INFO("Range Test Module - Disabled");
}
#endif
@@ -135,7 +135,7 @@ ProcessMessage RangeTestModuleRadio::handleReceived(const meshtastic_MeshPacket
/*
auto &p = mp.decoded;
- LOG_DEBUG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n",
+ LOG_DEBUG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s",
LOG_INFO.getNodeNum(), mp.from, mp.to, mp.id, p.payload.size, p.payload.bytes);
*/
@@ -148,31 +148,31 @@ ProcessMessage RangeTestModuleRadio::handleReceived(const meshtastic_MeshPacket
/*
NodeInfoLite *n = nodeDB->getMeshNode(getFrom(&mp));
- LOG_DEBUG("-----------------------------------------\n");
- LOG_DEBUG("p.payload.bytes \"%s\"\n", p.payload.bytes);
- LOG_DEBUG("p.payload.size %d\n", p.payload.size);
- LOG_DEBUG("---- Received Packet:\n");
- LOG_DEBUG("mp.from %d\n", mp.from);
- LOG_DEBUG("mp.rx_snr %f\n", mp.rx_snr);
- LOG_DEBUG("mp.hop_limit %d\n", mp.hop_limit);
- // LOG_DEBUG("mp.decoded.position.latitude_i %d\n", mp.decoded.position.latitude_i); // Deprecated
- // LOG_DEBUG("mp.decoded.position.longitude_i %d\n", mp.decoded.position.longitude_i); // Deprecated
- LOG_DEBUG("---- Node Information of Received Packet (mp.from):\n");
- LOG_DEBUG("n->user.long_name %s\n", n->user.long_name);
- LOG_DEBUG("n->user.short_name %s\n", n->user.short_name);
- LOG_DEBUG("n->has_position %d\n", n->has_position);
- LOG_DEBUG("n->position.latitude_i %d\n", n->position.latitude_i);
- LOG_DEBUG("n->position.longitude_i %d\n", n->position.longitude_i);
- LOG_DEBUG("---- Current device location information:\n");
- LOG_DEBUG("gpsStatus->getLatitude() %d\n", gpsStatus->getLatitude());
- LOG_DEBUG("gpsStatus->getLongitude() %d\n", gpsStatus->getLongitude());
- LOG_DEBUG("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock());
- LOG_DEBUG("gpsStatus->getDOP() %d\n", gpsStatus->getDOP());
- LOG_DEBUG("-----------------------------------------\n");
+ LOG_DEBUG("-----------------------------------------");
+ LOG_DEBUG("p.payload.bytes \"%s\"", p.payload.bytes);
+ LOG_DEBUG("p.payload.size %d", p.payload.size);
+ LOG_DEBUG("---- Received Packet:");
+ LOG_DEBUG("mp.from %d", mp.from);
+ LOG_DEBUG("mp.rx_snr %f", mp.rx_snr);
+ LOG_DEBUG("mp.hop_limit %d", mp.hop_limit);
+ // LOG_DEBUG("mp.decoded.position.latitude_i %d", mp.decoded.position.latitude_i); // Deprecated
+ // LOG_DEBUG("mp.decoded.position.longitude_i %d", mp.decoded.position.longitude_i); // Deprecated
+ LOG_DEBUG("---- Node Information of Received Packet (mp.from):");
+ LOG_DEBUG("n->user.long_name %s", n->user.long_name);
+ LOG_DEBUG("n->user.short_name %s", n->user.short_name);
+ LOG_DEBUG("n->has_position %d", n->has_position);
+ LOG_DEBUG("n->position.latitude_i %d", n->position.latitude_i);
+ LOG_DEBUG("n->position.longitude_i %d", n->position.longitude_i);
+ LOG_DEBUG("---- Current device location information:");
+ LOG_DEBUG("gpsStatus->getLatitude() %d", gpsStatus->getLatitude());
+ LOG_DEBUG("gpsStatus->getLongitude() %d", gpsStatus->getLongitude());
+ LOG_DEBUG("gpsStatus->getHasLock() %d", gpsStatus->getHasLock());
+ LOG_DEBUG("gpsStatus->getDOP() %d", gpsStatus->getDOP());
+ LOG_DEBUG("-----------------------------------------");
*/
}
} else {
- LOG_INFO("Range Test Module Disabled\n");
+ LOG_INFO("Range Test Module Disabled");
}
#endif
@@ -187,35 +187,35 @@ bool RangeTestModuleRadio::appendFile(const meshtastic_MeshPacket &mp)
meshtastic_NodeInfoLite *n = nodeDB->getMeshNode(getFrom(&mp));
/*
- LOG_DEBUG("-----------------------------------------\n");
- LOG_DEBUG("p.payload.bytes \"%s\"\n", p.payload.bytes);
- LOG_DEBUG("p.payload.size %d\n", p.payload.size);
- LOG_DEBUG("---- Received Packet:\n");
- LOG_DEBUG("mp.from %d\n", mp.from);
- LOG_DEBUG("mp.rx_snr %f\n", mp.rx_snr);
- LOG_DEBUG("mp.hop_limit %d\n", mp.hop_limit);
- // LOG_DEBUG("mp.decoded.position.latitude_i %d\n", mp.decoded.position.latitude_i); // Deprecated
- // LOG_DEBUG("mp.decoded.position.longitude_i %d\n", mp.decoded.position.longitude_i); // Deprecated
- LOG_DEBUG("---- Node Information of Received Packet (mp.from):\n");
- LOG_DEBUG("n->user.long_name %s\n", n->user.long_name);
- LOG_DEBUG("n->user.short_name %s\n", n->user.short_name);
- LOG_DEBUG("n->has_position %d\n", n->has_position);
- LOG_DEBUG("n->position.latitude_i %d\n", n->position.latitude_i);
- LOG_DEBUG("n->position.longitude_i %d\n", n->position.longitude_i);
- LOG_DEBUG("---- Current device location information:\n");
- LOG_DEBUG("gpsStatus->getLatitude() %d\n", gpsStatus->getLatitude());
- LOG_DEBUG("gpsStatus->getLongitude() %d\n", gpsStatus->getLongitude());
- LOG_DEBUG("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock());
- LOG_DEBUG("gpsStatus->getDOP() %d\n", gpsStatus->getDOP());
- LOG_DEBUG("-----------------------------------------\n");
+ LOG_DEBUG("-----------------------------------------");
+ LOG_DEBUG("p.payload.bytes \"%s\"", p.payload.bytes);
+ LOG_DEBUG("p.payload.size %d", p.payload.size);
+ LOG_DEBUG("---- Received Packet:");
+ LOG_DEBUG("mp.from %d", mp.from);
+ LOG_DEBUG("mp.rx_snr %f", mp.rx_snr);
+ LOG_DEBUG("mp.hop_limit %d", mp.hop_limit);
+ // LOG_DEBUG("mp.decoded.position.latitude_i %d", mp.decoded.position.latitude_i); // Deprecated
+ // LOG_DEBUG("mp.decoded.position.longitude_i %d", mp.decoded.position.longitude_i); // Deprecated
+ LOG_DEBUG("---- Node Information of Received Packet (mp.from):");
+ LOG_DEBUG("n->user.long_name %s", n->user.long_name);
+ LOG_DEBUG("n->user.short_name %s", n->user.short_name);
+ LOG_DEBUG("n->has_position %d", n->has_position);
+ LOG_DEBUG("n->position.latitude_i %d", n->position.latitude_i);
+ LOG_DEBUG("n->position.longitude_i %d", n->position.longitude_i);
+ LOG_DEBUG("---- Current device location information:");
+ LOG_DEBUG("gpsStatus->getLatitude() %d", gpsStatus->getLatitude());
+ LOG_DEBUG("gpsStatus->getLongitude() %d", gpsStatus->getLongitude());
+ LOG_DEBUG("gpsStatus->getHasLock() %d", gpsStatus->getHasLock());
+ LOG_DEBUG("gpsStatus->getDOP() %d", gpsStatus->getDOP());
+ LOG_DEBUG("-----------------------------------------");
*/
if (!FSBegin()) {
- LOG_DEBUG("An Error has occurred while mounting the filesystem\n");
+ LOG_DEBUG("An Error has occurred while mounting the filesystem");
return 0;
}
if (FSCom.totalBytes() - FSCom.usedBytes() < 51200) {
- LOG_DEBUG("Filesystem doesn't have enough free space. Aborting write.\n");
+ LOG_DEBUG("Filesystem doesn't have enough free space. Aborting write");
return 0;
}
@@ -227,16 +227,16 @@ bool RangeTestModuleRadio::appendFile(const meshtastic_MeshPacket &mp)
File fileToWrite = FSCom.open("/static/rangetest.csv", FILE_WRITE);
if (!fileToWrite) {
- LOG_ERROR("There was an error opening the file for writing\n");
+ LOG_ERROR("There was an error opening the file for writing");
return 0;
}
// Print the CSV header
if (fileToWrite.println(
"time,from,sender name,sender lat,sender long,rx lat,rx long,rx elevation,rx snr,distance,hop limit,payload")) {
- LOG_INFO("File was written\n");
+ LOG_INFO("File was written");
} else {
- LOG_ERROR("File write failed\n");
+ LOG_ERROR("File write failed");
}
fileToWrite.flush();
fileToWrite.close();
@@ -246,7 +246,7 @@ bool RangeTestModuleRadio::appendFile(const meshtastic_MeshPacket &mp)
File fileToAppend = FSCom.open("/static/rangetest.csv", FILE_APPEND);
if (!fileToAppend) {
- LOG_ERROR("There was an error opening the file for appending\n");
+ LOG_ERROR("There was an error opening the file for appending");
return 0;
}
@@ -292,4 +292,4 @@ bool RangeTestModuleRadio::appendFile(const meshtastic_MeshPacket &mp)
#endif
return 1;
-}
\ No newline at end of file
+}
diff --git a/src/modules/RemoteHardwareModule.cpp b/src/modules/RemoteHardwareModule.cpp
index 43612e450..9bc8512b6 100644
--- a/src/modules/RemoteHardwareModule.cpp
+++ b/src/modules/RemoteHardwareModule.cpp
@@ -64,7 +64,7 @@ static uint64_t digitalReads(uint64_t mask, uint64_t maskAvailable)
RemoteHardwareModule::RemoteHardwareModule()
: ProtobufModule("remotehardware", meshtastic_PortNum_REMOTE_HARDWARE_APP, &meshtastic_HardwareMessage_msg),
- concurrency::OSThread("RemoteHardwareModule")
+ concurrency::OSThread("RemoteHardware")
{
// restrict to the gpio channel for rx
boundChannel = Channels::gpioChannel;
@@ -79,7 +79,7 @@ bool RemoteHardwareModule::handleReceivedProtobuf(const meshtastic_MeshPacket &r
{
if (moduleConfig.remote_hardware.enabled) {
auto p = *pptr;
- LOG_INFO("Received RemoteHardware type=%d\n", p.type);
+ LOG_INFO("Received RemoteHardware type=%d", p.type);
switch (p.type) {
case meshtastic_HardwareMessage_Type_WRITE_GPIOS: {
@@ -122,7 +122,7 @@ bool RemoteHardwareModule::handleReceivedProtobuf(const meshtastic_MeshPacket &r
~watchGpios; // generate a 'previous' value which is guaranteed to not match (to force an initial publish)
enabled = true; // Let our thread run at least once
setInterval(2000); // Set a new interval so we'll run soon
- LOG_INFO("Now watching GPIOs 0x%llx\n", watchGpios);
+ LOG_INFO("Now watching GPIOs 0x%llx", watchGpios);
break;
}
@@ -131,7 +131,7 @@ bool RemoteHardwareModule::handleReceivedProtobuf(const meshtastic_MeshPacket &r
break; // Ignore - we might see our own replies
default:
- LOG_ERROR("Hardware operation %d not yet implemented! FIXME\n", p.type);
+ LOG_ERROR("Hardware operation %d not yet implemented! FIXME", p.type);
break;
}
}
@@ -149,7 +149,7 @@ int32_t RemoteHardwareModule::runOnce()
if (curVal != previousWatch) {
previousWatch = curVal;
- LOG_INFO("Broadcasting GPIOS 0x%llx changed!\n", curVal);
+ LOG_INFO("Broadcast GPIOS 0x%llx changed!", curVal);
// Something changed! Tell the world with a broadcast message
meshtastic_HardwareMessage r = meshtastic_HardwareMessage_init_default;
diff --git a/src/modules/ReplyModule.cpp b/src/modules/ReplyModule.cpp
index 439f6b7f7..c4f63c6b1 100644
--- a/src/modules/ReplyModule.cpp
+++ b/src/modules/ReplyModule.cpp
@@ -12,10 +12,10 @@ meshtastic_MeshPacket *ReplyModule::allocReply()
auto req = *currentRequest;
auto &p = req.decoded;
// The incoming message is in p.payload
- LOG_INFO("Received message from=0x%0x, id=%d, msg=%.*s\n", req.from, req.id, p.payload.size, p.payload.bytes);
+ LOG_INFO("Received message from=0x%0x, id=%d, msg=%.*s", req.from, req.id, p.payload.size, p.payload.bytes);
#endif
- screen->print("Sending reply\n");
+ screen->print("Send reply\n");
const char *replyStr = "Message Received";
auto reply = allocDataPacket(); // Allocate a packet for sending
diff --git a/src/modules/RoutingModule.cpp b/src/modules/RoutingModule.cpp
index 3b7be1ab7..a501e319b 100644
--- a/src/modules/RoutingModule.cpp
+++ b/src/modules/RoutingModule.cpp
@@ -10,11 +10,7 @@ RoutingModule *routingModule;
bool RoutingModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Routing *r)
{
- printPacket("Routing sniffing", &mp);
- router->sniffReceived(&mp, r);
-
- bool maybePKI =
- mp.which_payload_variant == meshtastic_MeshPacket_encrypted_tag && mp.channel == 0 && mp.to != NODENUM_BROADCAST;
+ bool maybePKI = mp.which_payload_variant == meshtastic_MeshPacket_encrypted_tag && mp.channel == 0 && !isBroadcast(mp.to);
// Beginning of logic whether to drop the packet based on Rebroadcast mode
if (mp.which_payload_variant == meshtastic_MeshPacket_encrypted_tag &&
(config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_LOCAL_ONLY ||
@@ -26,9 +22,12 @@ bool RoutingModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mesh
return false;
}
+ printPacket("Routing sniffing", &mp);
+ router->sniffReceived(&mp, r);
+
// FIXME - move this to a non promsicious PhoneAPI module?
// Note: we are careful not to send back packets that started with the phone back to the phone
- if ((mp.to == NODENUM_BROADCAST || isToUs(&mp)) && (mp.from != 0)) {
+ if ((isBroadcast(mp.to) || isToUs(&mp)) && (mp.from != 0)) {
printPacket("Delivering rx packet", &mp);
service->handleFromRadio(&mp);
}
@@ -50,10 +49,9 @@ meshtastic_MeshPacket *RoutingModule::allocReply()
return NULL;
}
-void RoutingModule::sendAckNak(meshtastic_Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex, uint8_t hopStart,
- uint8_t hopLimit)
+void RoutingModule::sendAckNak(meshtastic_Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex, uint8_t hopLimit)
{
- auto p = allocAckNak(err, to, idFrom, chIndex, hopStart, hopLimit);
+ auto p = allocAckNak(err, to, idFrom, chIndex, hopLimit);
router->sendLocal(p); // we sometimes send directly to the local node
}
@@ -79,7 +77,7 @@ RoutingModule::RoutingModule() : ProtobufModule("routing", meshtastic_PortNum_RO
{
isPromiscuous = true;
- // moved the ReboradcastMode logic into handleReceivedProtobuf
+ // moved the RebroadcastMode logic into handleReceivedProtobuf
// LocalOnly requires either the from or to to be a known node
// knownOnly specifically requires the from to be a known node.
encryptedOk = true;
diff --git a/src/modules/RoutingModule.h b/src/modules/RoutingModule.h
index f085b307b..7c34c5bc9 100644
--- a/src/modules/RoutingModule.h
+++ b/src/modules/RoutingModule.h
@@ -13,8 +13,7 @@ class RoutingModule : public ProtobufModule
*/
RoutingModule();
- void sendAckNak(meshtastic_Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex, uint8_t hopStart = 0,
- uint8_t hopLimit = 0);
+ void sendAckNak(meshtastic_Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex, uint8_t hopLimit = 0);
// Given the hopStart and hopLimit upon reception of a request, return the hop limit to use for the response
uint8_t getHopLimitForResponse(uint8_t hopStart, uint8_t hopLimit);
@@ -36,4 +35,4 @@ class RoutingModule : public ProtobufModule
virtual bool wantPacket(const meshtastic_MeshPacket *p) override { return true; }
};
-extern RoutingModule *routingModule;
+extern RoutingModule *routingModule;
\ No newline at end of file
diff --git a/src/modules/SerialModule.cpp b/src/modules/SerialModule.cpp
index d40b59345..bf53b1748 100644
--- a/src/modules/SerialModule.cpp
+++ b/src/modules/SerialModule.cpp
@@ -61,13 +61,13 @@ SerialModule *serialModule;
SerialModuleRadio *serialModuleRadio;
#if defined(TTGO_T_ECHO) || defined(CANARYONE)
-SerialModule::SerialModule() : StreamAPI(&Serial), concurrency::OSThread("SerialModule") {}
+SerialModule::SerialModule() : StreamAPI(&Serial), concurrency::OSThread("Serial") {}
static Print *serialPrint = &Serial;
#elif defined(CONFIG_IDF_TARGET_ESP32C6)
-SerialModule::SerialModule() : StreamAPI(&Serial1), concurrency::OSThread("SerialModule") {}
+SerialModule::SerialModule() : StreamAPI(&Serial1), concurrency::OSThread("Serial") {}
static Print *serialPrint = &Serial1;
#else
-SerialModule::SerialModule() : StreamAPI(&Serial2), concurrency::OSThread("SerialModule") {}
+SerialModule::SerialModule() : StreamAPI(&Serial2), concurrency::OSThread("Serial") {}
static Print *serialPrint = &Serial2;
#endif
@@ -125,7 +125,7 @@ int32_t SerialModule::runOnce()
if (moduleConfig.serial.override_console_serial_port || (moduleConfig.serial.rxd && moduleConfig.serial.txd)) {
if (firstTime) {
// Interface with the serial peripheral from in here.
- LOG_INFO("Initializing serial peripheral interface\n");
+ LOG_INFO("Init serial peripheral interface");
uint32_t baud = getBaudRate();
@@ -204,9 +204,11 @@ int32_t SerialModule::runOnce()
lastNmeaTime = millis();
uint32_t readIndex = 0;
const meshtastic_NodeInfoLite *tempNodeInfo = nodeDB->readNextMeshNode(readIndex);
- while (tempNodeInfo != NULL && tempNodeInfo->has_user && hasValidPosition(tempNodeInfo)) {
- printWPL(outbuf, sizeof(outbuf), tempNodeInfo->position, tempNodeInfo->user.long_name, true);
- serialPrint->printf("%s", outbuf);
+ while (tempNodeInfo != NULL) {
+ if (tempNodeInfo->has_user && nodeDB->hasValidPosition(tempNodeInfo)) {
+ printWPL(outbuf, sizeof(outbuf), tempNodeInfo->position, tempNodeInfo->user.long_name, true);
+ serialPrint->printf("%s", outbuf);
+ }
tempNodeInfo = nodeDB->readNextMeshNode(readIndex);
}
}
@@ -252,7 +254,12 @@ void SerialModule::sendTelemetry(meshtastic_Telemetry m)
pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), &meshtastic_Telemetry_msg, &m);
p->to = NODENUM_BROADCAST;
p->decoded.want_response = false;
- p->priority = meshtastic_MeshPacket_Priority_RELIABLE;
+ if (config.device.role == meshtastic_Config_DeviceConfig_Role_SENSOR) {
+ p->want_ack = true;
+ p->priority = meshtastic_MeshPacket_Priority_HIGH;
+ } else {
+ p->priority = meshtastic_MeshPacket_Priority_RELIABLE;
+ }
service->sendToMesh(p, RX_SRC_LOCAL, true);
}
@@ -307,10 +314,10 @@ ProcessMessage SerialModuleRadio::handleReceived(const meshtastic_MeshPacket &mp
}
auto &p = mp.decoded;
- // LOG_DEBUG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n",
+ // LOG_DEBUG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s",
// nodeDB->getNodeNum(), mp.from, mp.to, mp.id, p.payload.size, p.payload.bytes);
- if (!isFromUs(&mp)) {
+ if (isFromUs(&mp)) {
/*
* If moduleConfig.serial.echo is true, then echo the packets that are sent out
@@ -322,7 +329,7 @@ ProcessMessage SerialModuleRadio::handleReceived(const meshtastic_MeshPacket &mp
// TODO: need to find out why.
if (lastRxID != mp.id) {
lastRxID = mp.id;
- // LOG_DEBUG("* * Message came this device\n");
+ // LOG_DEBUG("* * Message came this device");
// serialPrint->println("* * Message came this device");
serialPrint->printf("%s", p.payload.bytes);
}
@@ -424,8 +431,10 @@ void SerialModule::processWXSerial()
static char windGust[5] = "xx.x"; // Assuming windGust is 4 characters long + null terminator
static char batVoltage[5] = "0.0V";
static char capVoltage[5] = "0.0V";
+ static char temperature[5] = "00.0";
static float batVoltageF = 0;
static float capVoltageF = 0;
+ static float temperatureF = 0;
bool gotwind = false;
while (Serial2.available()) {
@@ -465,7 +474,7 @@ void SerialModule::processWXSerial()
if (windDirPos != NULL) {
// Extract data after "=" for WindDir
strcpy(windDir, windDirPos + 15); // Add 15 to skip "WindDir = "
- double radians = toRadians(strtof(windDir, nullptr));
+ double radians = GeoCoord::toRadians(strtof(windDir, nullptr));
dir_sum_sin += sin(radians);
dir_sum_cos += cos(radians);
dirCount++;
@@ -499,6 +508,13 @@ void SerialModule::processWXSerial()
strcpy(capVoltage, capVoltagePos + 17); // 18 for ws 80, 17 for ws85
capVoltageF = strtof(capVoltage, nullptr);
}
+ // GXTS04Temp = 24.4
+ } else if (strstr(line, "GXTS04Temp") != NULL) { // we have a temperature line
+ char *tempPos = strstr(line, "GXTS04Temp = ");
+ if (tempPos != NULL) {
+ strcpy(temperature, tempPos + 15); // 15 spaces for ws85
+ temperatureF = strtof(temperature, nullptr);
+ }
}
// Update lineStart for the next line
@@ -514,18 +530,18 @@ void SerialModule::processWXSerial()
}
if (gotwind) {
- LOG_INFO("WS85 : %i %.1fg%.1f %.1fv %.1fv\n", atoi(windDir), strtof(windVel, nullptr), strtof(windGust, nullptr),
- batVoltageF, capVoltageF);
+ LOG_INFO("WS85 : %i %.1fg%.1f %.1fv %.1fv %.1fC", atoi(windDir), strtof(windVel, nullptr), strtof(windGust, nullptr),
+ batVoltageF, capVoltageF, temperatureF);
}
if (gotwind && !Throttle::isWithinTimespanMs(lastAveraged, averageIntervalMillis)) {
- // calulate averages and send to the mesh
+ // calculate averages and send to the mesh
float velAvg = 1.0 * velSum / velCount;
double avgSin = dir_sum_sin / dirCount;
double avgCos = dir_sum_cos / dirCount;
double avgRadians = atan2(avgSin, avgCos);
- float dirAvg = toDegrees(avgRadians);
+ float dirAvg = GeoCoord::toDegrees(avgRadians);
if (dirAvg < 0) {
dirAvg += 360.0;
@@ -535,17 +551,32 @@ void SerialModule::processWXSerial()
// make a telemetry packet with the data
meshtastic_Telemetry m = meshtastic_Telemetry_init_zero;
m.which_variant = meshtastic_Telemetry_environment_metrics_tag;
+
m.variant.environment_metrics.wind_speed = velAvg;
+ m.variant.environment_metrics.has_wind_speed = true;
+
m.variant.environment_metrics.wind_direction = dirAvg;
- m.variant.environment_metrics.wind_gust = gust;
- m.variant.environment_metrics.wind_lull = lull;
+ m.variant.environment_metrics.has_wind_direction = true;
+
+ m.variant.environment_metrics.temperature = temperatureF;
+ m.variant.environment_metrics.has_temperature = true;
+
m.variant.environment_metrics.voltage =
capVoltageF > batVoltageF ? capVoltageF : batVoltageF; // send the larger of the two voltage values.
+ m.variant.environment_metrics.has_voltage = true;
- LOG_INFO("WS85 Transmit speed=%fm/s, direction=%d , lull=%f, gust=%f, voltage=%f\n",
+ m.variant.environment_metrics.wind_gust = gust;
+ m.variant.environment_metrics.has_wind_gust = true;
+
+ if (lull == -1)
+ lull = 0;
+ m.variant.environment_metrics.wind_lull = lull;
+ m.variant.environment_metrics.has_wind_lull = true;
+
+ LOG_INFO("WS85 Transmit speed=%fm/s, direction=%d , lull=%f, gust=%f, voltage=%f temperature=%f",
m.variant.environment_metrics.wind_speed, m.variant.environment_metrics.wind_direction,
m.variant.environment_metrics.wind_lull, m.variant.environment_metrics.wind_gust,
- m.variant.environment_metrics.voltage);
+ m.variant.environment_metrics.voltage, m.variant.environment_metrics.temperature);
sendTelemetry(m);
diff --git a/src/modules/StoreForwardModule.cpp b/src/modules/StoreForwardModule.cpp
index e0092839f..4cf06f5d2 100644
--- a/src/modules/StoreForwardModule.cpp
+++ b/src/modules/StoreForwardModule.cpp
@@ -46,7 +46,7 @@ int32_t StoreForwardModule::runOnce()
} else if (this->heartbeat && (!Throttle::isWithinTimespanMs(lastHeartbeat, heartbeatInterval * 1000)) &&
airTime->isTxAllowedChannelUtil(true)) {
lastHeartbeat = millis();
- LOG_INFO("Sending heartbeat\n");
+ LOG_INFO("Send heartbeat");
meshtastic_StoreAndForward sf = meshtastic_StoreAndForward_init_zero;
sf.rr = meshtastic_StoreAndForward_RequestResponse_ROUTER_HEARTBEAT;
sf.which_variant = meshtastic_StoreAndForward_heartbeat_tag;
@@ -70,7 +70,7 @@ void StoreForwardModule::populatePSRAM()
https://learn.upesy.com/en/programmation/psram.html#psram-tab
*/
- LOG_DEBUG("Before PSRAM init: heap %d/%d PSRAM %d/%d\n", memGet.getFreeHeap(), memGet.getHeapSize(), memGet.getFreePsram(),
+ LOG_DEBUG("Before PSRAM init: heap %d/%d PSRAM %d/%d", memGet.getFreeHeap(), memGet.getHeapSize(), memGet.getFreePsram(),
memGet.getPsramSize());
/* Use a maximum of 2/3 the available PSRAM unless otherwise specified.
@@ -86,9 +86,9 @@ void StoreForwardModule::populatePSRAM()
#endif
- LOG_DEBUG("After PSRAM init: heap %d/%d PSRAM %d/%d\n", memGet.getFreeHeap(), memGet.getHeapSize(), memGet.getFreePsram(),
+ LOG_DEBUG("After PSRAM init: heap %d/%d PSRAM %d/%d", memGet.getFreeHeap(), memGet.getHeapSize(), memGet.getFreePsram(),
memGet.getPsramSize());
- LOG_DEBUG("numberOfPackets for packetHistory - %u\n", numberOfPackets);
+ LOG_DEBUG("numberOfPackets for packetHistory - %u", numberOfPackets);
}
/**
@@ -105,11 +105,11 @@ void StoreForwardModule::historySend(uint32_t secAgo, uint32_t to)
queueSize = this->historyReturnMax;
if (queueSize) {
- LOG_INFO("S&F - Sending %u message(s)\n", queueSize);
+ LOG_INFO("S&F - Send %u message(s)", queueSize);
this->busy = true; // runOnce() will pickup the next steps once busy = true.
this->busyTo = to;
} else {
- LOG_INFO("S&F - No history\n");
+ LOG_INFO("S&F - No history");
}
meshtastic_StoreAndForward sf = meshtastic_StoreAndForward_init_zero;
sf.rr = meshtastic_StoreAndForward_RequestResponse_ROUTER_HISTORY;
@@ -187,7 +187,7 @@ void StoreForwardModule::historyAdd(const meshtastic_MeshPacket &mp)
const auto &p = mp.decoded;
if (this->packetHistoryTotalCount == this->records) {
- LOG_WARN("S&F - PSRAM Full. Starting overwrite.\n");
+ LOG_WARN("S&F - PSRAM Full. Starting overwrite");
this->packetHistoryTotalCount = 0;
for (auto &i : lastRequest) {
i.second = 0; // Clear the last request index for each client device
@@ -215,7 +215,7 @@ bool StoreForwardModule::sendPayload(NodeNum dest, uint32_t last_time)
{
meshtastic_MeshPacket *p = preparePayload(dest, last_time);
if (p) {
- LOG_INFO("Sending S&F Payload\n");
+ LOG_INFO("Send S&F Payload");
service->sendToMesh(p);
this->requestCount++;
return true;
@@ -335,7 +335,7 @@ void StoreForwardModule::sendErrorTextMessage(NodeNum dest, bool want_response)
} else {
str = "S&F not permitted on the public channel.";
}
- LOG_WARN("%s\n", str);
+ LOG_WARN("%s", str);
memcpy(pr->decoded.payload.bytes, str, strlen(str));
pr->decoded.payload.size = strlen(str);
if (want_response) {
@@ -365,7 +365,7 @@ void StoreForwardModule::statsSend(uint32_t to)
sf.variant.stats.return_max = this->historyReturnMax;
sf.variant.stats.return_window = this->historyReturnWindow;
- LOG_DEBUG("Sending S&F Stats\n");
+ LOG_DEBUG("Send S&F Stats");
storeForwardModule->sendMessage(to, sf);
}
@@ -383,7 +383,7 @@ ProcessMessage StoreForwardModule::handleReceived(const meshtastic_MeshPacket &m
if ((mp.decoded.portnum == meshtastic_PortNum_TEXT_MESSAGE_APP) && is_server) {
auto &p = mp.decoded;
if (isToUs(&mp) && (p.payload.bytes[0] == 'S') && (p.payload.bytes[1] == 'F') && (p.payload.bytes[2] == 0x00)) {
- LOG_DEBUG("Legacy Request to send\n");
+ LOG_DEBUG("Legacy Request to send");
// Send the last 60 minutes of messages.
if (this->busy || channels.isDefaultChannel(mp.channel)) {
@@ -393,7 +393,7 @@ ProcessMessage StoreForwardModule::handleReceived(const meshtastic_MeshPacket &m
}
} else {
storeForwardModule->historyAdd(mp);
- LOG_INFO("S&F stored. Message history contains %u records now.\n", this->packetHistoryTotalCount);
+ LOG_INFO("S&F stored. Message history contains %u records now", this->packetHistoryTotalCount);
}
} else if (!isFromUs(&mp) && mp.decoded.portnum == meshtastic_PortNum_STORE_FORWARD_APP) {
auto &p = mp.decoded;
@@ -403,7 +403,7 @@ ProcessMessage StoreForwardModule::handleReceived(const meshtastic_MeshPacket &m
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, &meshtastic_StoreAndForward_msg, &scratch)) {
decoded = &scratch;
} else {
- LOG_ERROR("Error decoding protobuf module!\n");
+ LOG_ERROR("Error decoding proto module!");
// if we can't decode it, nobody can process it!
return ProcessMessage::STOP;
}
@@ -439,7 +439,7 @@ bool StoreForwardModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp,
if (is_server) {
// stop sending stuff, the client wants to abort or has another error
if ((this->busy) && (this->busyTo == getFrom(&mp))) {
- LOG_ERROR("Client in ERROR or ABORT requested\n");
+ LOG_ERROR("Client in ERROR or ABORT requested");
this->requestCount = 0;
this->busy = false;
}
@@ -449,7 +449,7 @@ bool StoreForwardModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp,
case meshtastic_StoreAndForward_RequestResponse_CLIENT_HISTORY:
if (is_server) {
requests_history++;
- LOG_INFO("Client Request to send HISTORY\n");
+ LOG_INFO("Client Request to send HISTORY");
// Send the last 60 minutes of messages.
if (this->busy || channels.isDefaultChannel(mp.channel)) {
sendErrorTextMessage(getFrom(&mp), mp.decoded.want_response);
@@ -479,10 +479,10 @@ bool StoreForwardModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp,
case meshtastic_StoreAndForward_RequestResponse_CLIENT_STATS:
if (is_server) {
- LOG_INFO("Client Request to send STATS\n");
+ LOG_INFO("Client Request to send STATS");
if (this->busy) {
storeForwardModule->sendMessage(getFrom(&mp), meshtastic_StoreAndForward_RequestResponse_ROUTER_BUSY);
- LOG_INFO("S&F - Busy. Try again shortly.\n");
+ LOG_INFO("S&F - Busy. Try again shortly");
} else {
storeForwardModule->statsSend(getFrom(&mp));
}
@@ -492,7 +492,7 @@ bool StoreForwardModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp,
case meshtastic_StoreAndForward_RequestResponse_ROUTER_ERROR:
case meshtastic_StoreAndForward_RequestResponse_ROUTER_BUSY:
if (is_client) {
- LOG_DEBUG("StoreAndForward_RequestResponse_ROUTER_BUSY\n");
+ LOG_DEBUG("StoreAndForward_RequestResponse_ROUTER_BUSY");
// retry in messages_saved * packetTimeMax ms
retry_delay = millis() + getNumAvailablePackets(this->busyTo, this->last_time) * packetTimeMax *
(meshtastic_StoreAndForward_RequestResponse_ROUTER_ERROR ? 2 : 1);
@@ -508,7 +508,7 @@ bool StoreForwardModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp,
heartbeatInterval = p->variant.heartbeat.period;
}
lastHeartbeat = millis();
- LOG_INFO("StoreAndForward Heartbeat received\n");
+ LOG_INFO("StoreAndForward Heartbeat received");
}
break;
@@ -521,7 +521,7 @@ bool StoreForwardModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp,
case meshtastic_StoreAndForward_RequestResponse_ROUTER_STATS:
if (is_client) {
- LOG_DEBUG("Router Response STATS\n");
+ LOG_DEBUG("Router Response STATS");
// These fields only have informational purpose on a client. Fill them to consume later.
if (p->which_variant == meshtastic_StoreAndForward_stats_tag) {
this->records = p->variant.stats.messages_max;
@@ -539,7 +539,7 @@ bool StoreForwardModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp,
// These fields only have informational purpose on a client. Fill them to consume later.
if (p->which_variant == meshtastic_StoreAndForward_history_tag) {
this->historyReturnWindow = p->variant.history.window / 60000;
- LOG_INFO("Router Response HISTORY - Sending %d messages from last %d minutes\n",
+ LOG_INFO("Router Response HISTORY - Sending %d messages from last %d minutes",
p->variant.history.history_messages, this->historyReturnWindow);
}
}
@@ -552,7 +552,7 @@ bool StoreForwardModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp,
}
StoreForwardModule::StoreForwardModule()
- : concurrency::OSThread("StoreForwardModule"),
+ : concurrency::OSThread("StoreForward"),
ProtobufModule("StoreForward", meshtastic_PortNum_STORE_FORWARD_APP, &meshtastic_StoreAndForward_msg)
{
@@ -573,7 +573,7 @@ StoreForwardModule::StoreForwardModule()
// Router
if ((config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER || moduleConfig.store_forward.is_server)) {
- LOG_INFO("Initializing Store & Forward Module in Server mode\n");
+ LOG_INFO("Init Store & Forward Module in Server mode");
if (memGet.getPsramSize() > 0) {
if (memGet.getFreePsram() >= 1024 * 1024) {
@@ -601,20 +601,20 @@ StoreForwardModule::StoreForwardModule()
this->populatePSRAM();
is_server = true;
} else {
- LOG_INFO(".\n");
- LOG_INFO("S&F: not enough PSRAM free, disabling.\n");
+ LOG_INFO(".");
+ LOG_INFO("S&F: not enough PSRAM free, Disable");
}
} else {
- LOG_INFO("S&F: device doesn't have PSRAM, disabling.\n");
+ LOG_INFO("S&F: device doesn't have PSRAM, Disable");
}
// Client
} else {
is_client = true;
- LOG_INFO("Initializing Store & Forward Module in Client mode\n");
+ LOG_INFO("Init Store & Forward Module in Client mode");
}
} else {
disable();
}
#endif
-}
\ No newline at end of file
+}
diff --git a/src/modules/Telemetry/AirQualityTelemetry.cpp b/src/modules/Telemetry/AirQualityTelemetry.cpp
index 0b6be1b7e..362d60252 100644
--- a/src/modules/Telemetry/AirQualityTelemetry.cpp
+++ b/src/modules/Telemetry/AirQualityTelemetry.cpp
@@ -33,9 +33,10 @@ int32_t AirQualityTelemetryModule::runOnce()
firstTime = false;
if (moduleConfig.telemetry.air_quality_enabled) {
- LOG_INFO("Air quality Telemetry: Initializing\n");
+ LOG_INFO("Air quality Telemetry: init");
if (!aqi.begin_I2C()) {
- LOG_WARN("Could not establish i2c connection to AQI sensor. Rescanning...\n");
+#ifndef I2C_NO_RESCAN
+ LOG_WARN("Could not establish i2c connection to AQI sensor. Rescan");
// rescan for late arriving sensors. AQI Module starts about 10 seconds into the boot so this is plenty.
uint8_t i2caddr_scan[] = {PMSA0031_ADDR};
uint8_t i2caddr_asize = 1;
@@ -51,6 +52,7 @@ int32_t AirQualityTelemetryModule::runOnce()
i2cScanner->fetchI2CBus(found.address);
return 1000;
}
+#endif
return disable();
}
return 1000;
@@ -84,11 +86,11 @@ bool AirQualityTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPack
#ifdef DEBUG_PORT
const char *sender = getSenderShortName(mp);
- LOG_INFO("(Received from %s): pm10_standard=%i, pm25_standard=%i, pm100_standard=%i\n", sender,
+ LOG_INFO("(Received from %s): pm10_standard=%i, pm25_standard=%i, pm100_standard=%i", sender,
t->variant.air_quality_metrics.pm10_standard, t->variant.air_quality_metrics.pm25_standard,
t->variant.air_quality_metrics.pm100_standard);
- LOG_INFO(" | PM1.0(Environmental)=%i, PM2.5(Environmental)=%i, PM10.0(Environmental)=%i\n",
+ LOG_INFO(" | PM1.0(Environmental)=%i, PM2.5(Environmental)=%i, PM10.0(Environmental)=%i",
t->variant.air_quality_metrics.pm10_environmental, t->variant.air_quality_metrics.pm25_environmental,
t->variant.air_quality_metrics.pm100_environmental);
#endif
@@ -105,7 +107,7 @@ bool AirQualityTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPack
bool AirQualityTelemetryModule::getAirQualityTelemetry(meshtastic_Telemetry *m)
{
if (!aqi.read(&data)) {
- LOG_WARN("Skipping send measurements. Could not read AQIn\n");
+ LOG_WARN("Skip send measurements. Could not read AQIn");
return false;
}
@@ -119,11 +121,10 @@ bool AirQualityTelemetryModule::getAirQualityTelemetry(meshtastic_Telemetry *m)
m->variant.air_quality_metrics.pm25_environmental = data.pm25_env;
m->variant.air_quality_metrics.pm100_environmental = data.pm100_env;
- LOG_INFO("(Sending): PM1.0(Standard)=%i, PM2.5(Standard)=%i, PM10.0(Standard)=%i\n",
- m->variant.air_quality_metrics.pm10_standard, m->variant.air_quality_metrics.pm25_standard,
- m->variant.air_quality_metrics.pm100_standard);
+ LOG_INFO("Send: PM1.0(Standard)=%i, PM2.5(Standard)=%i, PM10.0(Standard)=%i", m->variant.air_quality_metrics.pm10_standard,
+ m->variant.air_quality_metrics.pm25_standard, m->variant.air_quality_metrics.pm100_standard);
- LOG_INFO(" | PM1.0(Environmental)=%i, PM2.5(Environmental)=%i, PM10.0(Environmental)=%i\n",
+ LOG_INFO(" | PM1.0(Environmental)=%i, PM2.5(Environmental)=%i, PM10.0(Environmental)=%i",
m->variant.air_quality_metrics.pm10_environmental, m->variant.air_quality_metrics.pm25_environmental,
m->variant.air_quality_metrics.pm100_environmental);
@@ -141,14 +142,14 @@ meshtastic_MeshPacket *AirQualityTelemetryModule::allocReply()
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, &meshtastic_Telemetry_msg, &scratch)) {
decoded = &scratch;
} else {
- LOG_ERROR("Error decoding AirQualityTelemetry module!\n");
+ LOG_ERROR("Error decoding AirQualityTelemetry module!");
return NULL;
}
// Check for a request for air quality metrics
if (decoded->which_variant == meshtastic_Telemetry_air_quality_metrics_tag) {
meshtastic_Telemetry m = meshtastic_Telemetry_init_zero;
if (getAirQualityTelemetry(&m)) {
- LOG_INFO("Air quality telemetry replying to request\n");
+ LOG_INFO("Air quality telemetry reply to request");
return allocDataProtobuf(m);
} else {
return NULL;
@@ -176,10 +177,10 @@ bool AirQualityTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
lastMeasurementPacket = packetPool.allocCopy(*p);
if (phoneOnly) {
- LOG_INFO("Sending packet to phone\n");
+ LOG_INFO("Send packet to phone");
service->sendToPhone(p);
} else {
- LOG_INFO("Sending packet to mesh\n");
+ LOG_INFO("Send packet to mesh");
service->sendToMesh(p, RX_SRC_LOCAL, true);
}
return true;
diff --git a/src/modules/Telemetry/AirQualityTelemetry.h b/src/modules/Telemetry/AirQualityTelemetry.h
index fb8edd07e..3b983bd56 100644
--- a/src/modules/Telemetry/AirQualityTelemetry.h
+++ b/src/modules/Telemetry/AirQualityTelemetry.h
@@ -16,7 +16,7 @@ class AirQualityTelemetryModule : private concurrency::OSThread, public Protobuf
public:
AirQualityTelemetryModule()
- : concurrency::OSThread("AirQualityTelemetryModule"),
+ : concurrency::OSThread("AirQualityTelemetry"),
ProtobufModule("AirQualityTelemetry", meshtastic_PortNum_TELEMETRY_APP, &meshtastic_Telemetry_msg)
{
lastMeasurementPacket = nullptr;
diff --git a/src/modules/Telemetry/DeviceTelemetry.cpp b/src/modules/Telemetry/DeviceTelemetry.cpp
index eb3f67e96..4989b88e2 100644
--- a/src/modules/Telemetry/DeviceTelemetry.cpp
+++ b/src/modules/Telemetry/DeviceTelemetry.cpp
@@ -51,7 +51,7 @@ bool DeviceTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &
#ifdef DEBUG_PORT
const char *sender = getSenderShortName(mp);
- LOG_INFO("(Received from %s): air_util_tx=%f, channel_utilization=%f, battery_level=%i, voltage=%f\n", sender,
+ LOG_INFO("(Received from %s): air_util_tx=%f, channel_utilization=%f, battery_level=%i, voltage=%f", sender,
t->variant.device_metrics.air_util_tx, t->variant.device_metrics.channel_utilization,
t->variant.device_metrics.battery_level, t->variant.device_metrics.voltage);
#endif
@@ -71,15 +71,16 @@ meshtastic_MeshPacket *DeviceTelemetryModule::allocReply()
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, &meshtastic_Telemetry_msg, &scratch)) {
decoded = &scratch;
} else {
- LOG_ERROR("Error decoding DeviceTelemetry module!\n");
+ LOG_ERROR("Error decoding DeviceTelemetry module!");
return NULL;
}
// Check for a request for device metrics
if (decoded->which_variant == meshtastic_Telemetry_device_metrics_tag) {
- LOG_INFO("Device telemetry replying to request\n");
-
- meshtastic_Telemetry telemetry = getDeviceTelemetry();
- return allocDataProtobuf(telemetry);
+ LOG_INFO("Device telemetry reply to request");
+ return allocDataProtobuf(getDeviceTelemetry());
+ } else if (decoded->which_variant == meshtastic_Telemetry_local_stats_tag) {
+ LOG_INFO("Device telemetry reply w/ LocalStats to request");
+ return allocDataProtobuf(getLocalStatsTelemetry());
}
}
return NULL;
@@ -112,7 +113,7 @@ meshtastic_Telemetry DeviceTelemetryModule::getDeviceTelemetry()
return t;
}
-void DeviceTelemetryModule::sendLocalStatsToPhone()
+meshtastic_Telemetry DeviceTelemetryModule::getLocalStatsTelemetry()
{
meshtastic_Telemetry telemetry = meshtastic_Telemetry_init_zero;
telemetry.which_variant = meshtastic_Telemetry_local_stats_tag;
@@ -134,16 +135,20 @@ void DeviceTelemetryModule::sendLocalStatsToPhone()
telemetry.variant.local_stats.num_tx_relay_canceled = router->txRelayCanceled;
}
- LOG_INFO(
- "(Sending local stats): uptime=%i, channel_utilization=%f, air_util_tx=%f, num_online_nodes=%i, num_total_nodes=%i\n",
- telemetry.variant.local_stats.uptime_seconds, telemetry.variant.local_stats.channel_utilization,
- telemetry.variant.local_stats.air_util_tx, telemetry.variant.local_stats.num_online_nodes,
- telemetry.variant.local_stats.num_total_nodes);
+ LOG_INFO("Sending local stats: uptime=%i, channel_utilization=%f, air_util_tx=%f, num_online_nodes=%i, num_total_nodes=%i",
+ telemetry.variant.local_stats.uptime_seconds, telemetry.variant.local_stats.channel_utilization,
+ telemetry.variant.local_stats.air_util_tx, telemetry.variant.local_stats.num_online_nodes,
+ telemetry.variant.local_stats.num_total_nodes);
- LOG_INFO("num_packets_tx=%i, num_packets_rx=%i, num_packets_rx_bad=%i\n", telemetry.variant.local_stats.num_packets_tx,
+ LOG_INFO("num_packets_tx=%i, num_packets_rx=%i, num_packets_rx_bad=%i", telemetry.variant.local_stats.num_packets_tx,
telemetry.variant.local_stats.num_packets_rx, telemetry.variant.local_stats.num_packets_rx_bad);
- meshtastic_MeshPacket *p = allocDataProtobuf(telemetry);
+ return telemetry;
+}
+
+void DeviceTelemetryModule::sendLocalStatsToPhone()
+{
+ meshtastic_MeshPacket *p = allocDataProtobuf(getLocalStatsTelemetry());
p->to = NODENUM_BROADCAST;
p->decoded.want_response = false;
p->priority = meshtastic_MeshPacket_Priority_BACKGROUND;
@@ -154,7 +159,7 @@ void DeviceTelemetryModule::sendLocalStatsToPhone()
bool DeviceTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
{
meshtastic_Telemetry telemetry = getDeviceTelemetry();
- LOG_INFO("(Sending): air_util_tx=%f, channel_utilization=%f, battery_level=%i, voltage=%f, uptime=%i\n",
+ LOG_INFO("Send: air_util_tx=%f, channel_utilization=%f, battery_level=%i, voltage=%f, uptime=%i",
telemetry.variant.device_metrics.air_util_tx, telemetry.variant.device_metrics.channel_utilization,
telemetry.variant.device_metrics.battery_level, telemetry.variant.device_metrics.voltage,
telemetry.variant.device_metrics.uptime_seconds);
@@ -166,10 +171,10 @@ bool DeviceTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
nodeDB->updateTelemetry(nodeDB->getNodeNum(), telemetry, RX_SRC_LOCAL);
if (phoneOnly) {
- LOG_INFO("Sending packet to phone\n");
+ LOG_INFO("Send packet to phone");
service->sendToPhone(p);
} else {
- LOG_INFO("Sending packet to mesh\n");
+ LOG_INFO("Send packet to mesh");
service->sendToMesh(p, RX_SRC_LOCAL, true);
}
return true;
diff --git a/src/modules/Telemetry/DeviceTelemetry.h b/src/modules/Telemetry/DeviceTelemetry.h
index 6d7f69891..19b7d5b01 100644
--- a/src/modules/Telemetry/DeviceTelemetry.h
+++ b/src/modules/Telemetry/DeviceTelemetry.h
@@ -12,7 +12,7 @@ class DeviceTelemetryModule : private concurrency::OSThread, public ProtobufModu
public:
DeviceTelemetryModule()
- : concurrency::OSThread("DeviceTelemetryModule"),
+ : concurrency::OSThread("DeviceTelemetry"),
ProtobufModule("DeviceTelemetry", meshtastic_PortNum_TELEMETRY_APP, &meshtastic_Telemetry_msg)
{
uptimeWrapCount = 0;
@@ -42,6 +42,8 @@ class DeviceTelemetryModule : private concurrency::OSThread, public ProtobufModu
private:
meshtastic_Telemetry getDeviceTelemetry();
+ meshtastic_Telemetry getLocalStatsTelemetry();
+
void sendLocalStatsToPhone();
uint32_t sendToPhoneIntervalMs = SECONDS_IN_MINUTE * 1000; // Send to phone every minute
uint32_t sendStatsToPhoneIntervalMs = 15 * SECONDS_IN_MINUTE * 1000; // Send stats to phone every 15 minutes
diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp
index 1ccdedeb7..92d964f7d 100644
--- a/src/modules/Telemetry/EnvironmentTelemetry.cpp
+++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp
@@ -25,6 +25,7 @@
#include "Sensor/BMP085Sensor.h"
#include "Sensor/BMP280Sensor.h"
#include "Sensor/BMP3XXSensor.h"
+#include "Sensor/CGRadSensSensor.h"
#include "Sensor/DFRobotLarkSensor.h"
#include "Sensor/LPS22HBSensor.h"
#include "Sensor/MCP9808Sensor.h"
@@ -60,6 +61,7 @@ BMP3XXSensor bmp3xxSensor;
#ifdef T1000X_SENSOR_EN
T1000xSensor t1000xSensor;
#endif
+CGRadSensSensor cgRadSens;
#define FAILED_STATE_SENSOR_READ_MULTIPLIER 10
#define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true
@@ -73,8 +75,8 @@ int32_t EnvironmentTelemetryModule::runOnce()
sleepOnNextExecution = false;
uint32_t nightyNightMs = Default::getConfiguredOrDefaultMs(moduleConfig.telemetry.environment_update_interval,
default_telemetry_broadcast_interval_secs);
- LOG_DEBUG("Sleeping for %ims, then awaking to send metrics again.\n", nightyNightMs);
- doDeepSleep(nightyNightMs, true);
+ LOG_DEBUG("Sleep for %ims, then awake to send metrics again", nightyNightMs);
+ doDeepSleep(nightyNightMs, true, false);
}
uint32_t result = UINT32_MAX;
@@ -97,7 +99,7 @@ int32_t EnvironmentTelemetryModule::runOnce()
firstTime = 0;
if (moduleConfig.telemetry.environment_measurement_enabled) {
- LOG_INFO("Environment Telemetry: Initializing\n");
+ LOG_INFO("Environment Telemetry: init");
// it's possible to have this module enabled, only for displaying values on the screen.
// therefore, we should only enable the sensor loop if measurement is also enabled
#ifdef T1000X_SENSOR_EN
@@ -147,6 +149,8 @@ int32_t EnvironmentTelemetryModule::runOnce()
result = nau7802Sensor.runOnce();
if (max17048Sensor.hasSensor())
result = max17048Sensor.runOnce();
+ if (cgRadSens.hasSensor())
+ result = cgRadSens.runOnce();
#endif
}
return result;
@@ -210,16 +214,19 @@ void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSt
// Display "Env. From: ..." on its own
display->drawString(x, y, "Env. From: " + String(lastSender) + "(" + String(agoSecs) + "s)");
- String last_temp = String(lastMeasurement.variant.environment_metrics.temperature, 0) + "°C";
- if (moduleConfig.telemetry.environment_display_fahrenheit) {
- last_temp =
- String(UnitConversions::CelsiusToFahrenheit(lastMeasurement.variant.environment_metrics.temperature), 0) + "°F";
- }
+ if (lastMeasurement.variant.environment_metrics.has_temperature ||
+ lastMeasurement.variant.environment_metrics.has_relative_humidity) {
+ String last_temp = String(lastMeasurement.variant.environment_metrics.temperature, 0) + "°C";
+ if (moduleConfig.telemetry.environment_display_fahrenheit) {
+ last_temp =
+ String(UnitConversions::CelsiusToFahrenheit(lastMeasurement.variant.environment_metrics.temperature), 0) + "°F";
+ }
- // Continue with the remaining details
- display->drawString(x, y += _fontHeight(FONT_SMALL),
- "Temp/Hum: " + last_temp + " / " +
- String(lastMeasurement.variant.environment_metrics.relative_humidity, 0) + "%");
+ // Continue with the remaining details
+ display->drawString(x, y += _fontHeight(FONT_SMALL),
+ "Temp/Hum: " + last_temp + " / " +
+ String(lastMeasurement.variant.environment_metrics.relative_humidity, 0) + "%");
+ }
if (lastMeasurement.variant.environment_metrics.barometric_pressure != 0) {
display->drawString(x, y += _fontHeight(FONT_SMALL),
@@ -243,6 +250,10 @@ void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSt
if (lastMeasurement.variant.environment_metrics.weight != 0)
display->drawString(x, y += _fontHeight(FONT_SMALL),
"Weight: " + String(lastMeasurement.variant.environment_metrics.weight, 0) + "kg");
+
+ if (lastMeasurement.variant.environment_metrics.radiation != 0)
+ display->drawString(x, y += _fontHeight(FONT_SMALL),
+ "Rad: " + String(lastMeasurement.variant.environment_metrics.radiation, 2) + "µR/h");
}
bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t)
@@ -252,17 +263,19 @@ bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPac
const char *sender = getSenderShortName(mp);
LOG_INFO("(Received from %s): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, "
- "temperature=%f\n",
+ "temperature=%f",
sender, t->variant.environment_metrics.barometric_pressure, t->variant.environment_metrics.current,
t->variant.environment_metrics.gas_resistance, t->variant.environment_metrics.relative_humidity,
t->variant.environment_metrics.temperature);
- LOG_INFO("(Received from %s): voltage=%f, IAQ=%d, distance=%f, lux=%f\n", sender, t->variant.environment_metrics.voltage,
+ LOG_INFO("(Received from %s): voltage=%f, IAQ=%d, distance=%f, lux=%f", sender, t->variant.environment_metrics.voltage,
t->variant.environment_metrics.iaq, t->variant.environment_metrics.distance, t->variant.environment_metrics.lux);
- LOG_INFO("(Received from %s): wind speed=%fm/s, direction=%d degrees, weight=%fkg\n", sender,
+ LOG_INFO("(Received from %s): wind speed=%fm/s, direction=%d degrees, weight=%fkg", sender,
t->variant.environment_metrics.wind_speed, t->variant.environment_metrics.wind_direction,
t->variant.environment_metrics.weight);
+ LOG_INFO("(Received from %s): radiation=%fµR/h", sender, t->variant.environment_metrics.radiation);
+
#endif
// release previous packet before occupying a new spot
if (lastMeasurementPacket != nullptr)
@@ -373,21 +386,27 @@ bool EnvironmentTelemetryModule::getEnvironmentTelemetry(meshtastic_Telemetry *m
} else if (bmp280Sensor.hasSensor()) {
// prefer bmp280 temp if both sensors are present, fetch only humidity
meshtastic_Telemetry m_ahtx = meshtastic_Telemetry_init_zero;
- LOG_INFO("AHTX0+BMP280 module detected: using temp from BMP280 and humy from AHTX0\n");
+ LOG_INFO("AHTX0+BMP280 module detected: using temp from BMP280 and humy from AHTX0");
aht10Sensor.getMetrics(&m_ahtx);
m->variant.environment_metrics.relative_humidity = m_ahtx.variant.environment_metrics.relative_humidity;
+ m->variant.environment_metrics.has_relative_humidity = m_ahtx.variant.environment_metrics.has_relative_humidity;
} else {
// prefer bmp3xx temp if both sensors are present, fetch only humidity
meshtastic_Telemetry m_ahtx = meshtastic_Telemetry_init_zero;
- LOG_INFO("AHTX0+BMP3XX module detected: using temp from BMP3XX and humy from AHTX0\n");
+ LOG_INFO("AHTX0+BMP3XX module detected: using temp from BMP3XX and humy from AHTX0");
aht10Sensor.getMetrics(&m_ahtx);
m->variant.environment_metrics.relative_humidity = m_ahtx.variant.environment_metrics.relative_humidity;
+ m->variant.environment_metrics.has_relative_humidity = m_ahtx.variant.environment_metrics.has_relative_humidity;
}
}
if (max17048Sensor.hasSensor()) {
valid = valid && max17048Sensor.getMetrics(m);
hasSensor = true;
}
+ if (cgRadSens.hasSensor()) {
+ valid = valid && cgRadSens.getMetrics(m);
+ hasSensor = true;
+ }
#endif
return valid && hasSensor;
@@ -404,14 +423,14 @@ meshtastic_MeshPacket *EnvironmentTelemetryModule::allocReply()
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, &meshtastic_Telemetry_msg, &scratch)) {
decoded = &scratch;
} else {
- LOG_ERROR("Error decoding EnvironmentTelemetry module!\n");
+ LOG_ERROR("Error decoding EnvironmentTelemetry module!");
return NULL;
}
// Check for a request for environment metrics
if (decoded->which_variant == meshtastic_Telemetry_environment_metrics_tag) {
meshtastic_Telemetry m = meshtastic_Telemetry_init_zero;
if (getEnvironmentTelemetry(&m)) {
- LOG_INFO("Environment telemetry replying to request\n");
+ LOG_INFO("Environment telemetry reply to request");
return allocDataProtobuf(m);
} else {
return NULL;
@@ -431,16 +450,18 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
#else
if (getEnvironmentTelemetry(&m)) {
#endif
- LOG_INFO("(Sending): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, temperature=%f\n",
+ LOG_INFO("Send: barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, temperature=%f",
m.variant.environment_metrics.barometric_pressure, m.variant.environment_metrics.current,
m.variant.environment_metrics.gas_resistance, m.variant.environment_metrics.relative_humidity,
m.variant.environment_metrics.temperature);
- LOG_INFO("(Sending): voltage=%f, IAQ=%d, distance=%f, lux=%f\n", m.variant.environment_metrics.voltage,
+ LOG_INFO("Send: voltage=%f, IAQ=%d, distance=%f, lux=%f", m.variant.environment_metrics.voltage,
m.variant.environment_metrics.iaq, m.variant.environment_metrics.distance, m.variant.environment_metrics.lux);
- LOG_INFO("(Sending): wind speed=%fm/s, direction=%d degrees, weight=%fkg\n", m.variant.environment_metrics.wind_speed,
+ LOG_INFO("Send: wind speed=%fm/s, direction=%d degrees, weight=%fkg", m.variant.environment_metrics.wind_speed,
m.variant.environment_metrics.wind_direction, m.variant.environment_metrics.weight);
+ LOG_INFO("Send: radiation=%fµR/h", m.variant.environment_metrics.radiation);
+
sensor_read_error_count = 0;
meshtastic_MeshPacket *p = allocDataProtobuf(m);
@@ -456,14 +477,14 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
lastMeasurementPacket = packetPool.allocCopy(*p);
if (phoneOnly) {
- LOG_INFO("Sending packet to phone\n");
+ LOG_INFO("Send packet to phone");
service->sendToPhone(p);
} else {
- LOG_INFO("Sending packet to mesh\n");
+ LOG_INFO("Send packet to mesh");
service->sendToMesh(p, RX_SRC_LOCAL, true);
if (config.device.role == meshtastic_Config_DeviceConfig_Role_SENSOR && config.power.is_power_saving) {
- LOG_DEBUG("Starting next execution in 5 seconds and then going to sleep.\n");
+ LOG_DEBUG("Start next execution in 5s, then sleep");
sleepOnNextExecution = true;
setIntervalFromNow(5000);
}
@@ -583,7 +604,12 @@ AdminMessageHandleResult EnvironmentTelemetryModule::handleAdminMessageForModule
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
+ if (cgRadSens.hasSensor()) {
+ result = cgRadSens.handleAdminMessage(mp, request, response);
+ if (result != AdminMessageHandleResult::NOT_HANDLED)
+ return result;
+ }
return result;
}
-#endif
\ No newline at end of file
+#endif
diff --git a/src/modules/Telemetry/EnvironmentTelemetry.h b/src/modules/Telemetry/EnvironmentTelemetry.h
index e680d8bbd..6e0f850ef 100644
--- a/src/modules/Telemetry/EnvironmentTelemetry.h
+++ b/src/modules/Telemetry/EnvironmentTelemetry.h
@@ -17,7 +17,7 @@ class EnvironmentTelemetryModule : private concurrency::OSThread, public Protobu
public:
EnvironmentTelemetryModule()
- : concurrency::OSThread("EnvironmentTelemetryModule"),
+ : concurrency::OSThread("EnvironmentTelemetry"),
ProtobufModule("EnvironmentTelemetry", meshtastic_PortNum_TELEMETRY_APP, &meshtastic_Telemetry_msg)
{
lastMeasurementPacket = nullptr;
diff --git a/src/modules/Telemetry/HealthTelemetry.cpp b/src/modules/Telemetry/HealthTelemetry.cpp
index bcf9d9d57..22534e9f5 100644
--- a/src/modules/Telemetry/HealthTelemetry.cpp
+++ b/src/modules/Telemetry/HealthTelemetry.cpp
@@ -39,8 +39,8 @@ int32_t HealthTelemetryModule::runOnce()
sleepOnNextExecution = false;
uint32_t nightyNightMs = Default::getConfiguredOrDefaultMs(moduleConfig.telemetry.health_update_interval,
default_telemetry_broadcast_interval_secs);
- LOG_DEBUG("Sleeping for %ims, then awaking to send metrics again.\n", nightyNightMs);
- doDeepSleep(nightyNightMs, true);
+ LOG_DEBUG("Sleep for %ims, then awake to send metrics again", nightyNightMs);
+ doDeepSleep(nightyNightMs, true, false);
}
uint32_t result = UINT32_MAX;
@@ -55,7 +55,7 @@ int32_t HealthTelemetryModule::runOnce()
firstTime = false;
if (moduleConfig.telemetry.health_measurement_enabled) {
- LOG_INFO("Health Telemetry: Initializing\n");
+ LOG_INFO("Health Telemetry: init");
// Initialize sensors
if (mlx90614Sensor.hasSensor())
result = mlx90614Sensor.runOnce();
@@ -143,7 +143,7 @@ bool HealthTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &
#ifdef DEBUG_PORT
const char *sender = getSenderShortName(mp);
- LOG_INFO("(Received from %s): temperature=%f, heart_bpm=%d, spO2=%d,\n", sender, t->variant.health_metrics.temperature,
+ LOG_INFO("(Received from %s): temperature=%f, heart_bpm=%d, spO2=%d,", sender, t->variant.health_metrics.temperature,
t->variant.health_metrics.heart_bpm, t->variant.health_metrics.spO2);
#endif
@@ -188,14 +188,14 @@ meshtastic_MeshPacket *HealthTelemetryModule::allocReply()
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, &meshtastic_Telemetry_msg, &scratch)) {
decoded = &scratch;
} else {
- LOG_ERROR("Error decoding HealthTelemetry module!\n");
+ LOG_ERROR("Error decoding HealthTelemetry module!");
return NULL;
}
// Check for a request for health metrics
if (decoded->which_variant == meshtastic_Telemetry_health_metrics_tag) {
meshtastic_Telemetry m = meshtastic_Telemetry_init_zero;
if (getHealthTelemetry(&m)) {
- LOG_INFO("Health telemetry replying to request\n");
+ LOG_INFO("Health telemetry reply to request");
return allocDataProtobuf(m);
} else {
return NULL;
@@ -211,7 +211,7 @@ bool HealthTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
m.which_variant = meshtastic_Telemetry_health_metrics_tag;
m.time = getTime();
if (getHealthTelemetry(&m)) {
- LOG_INFO("(Sending): temperature=%f, heart_bpm=%d, spO2=%d\n", m.variant.health_metrics.temperature,
+ LOG_INFO("Send: temperature=%f, heart_bpm=%d, spO2=%d", m.variant.health_metrics.temperature,
m.variant.health_metrics.heart_bpm, m.variant.health_metrics.spO2);
sensor_read_error_count = 0;
@@ -229,14 +229,14 @@ bool HealthTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
lastMeasurementPacket = packetPool.allocCopy(*p);
if (phoneOnly) {
- LOG_INFO("Sending packet to phone\n");
+ LOG_INFO("Send packet to phone");
service->sendToPhone(p);
} else {
- LOG_INFO("Sending packet to mesh\n");
+ LOG_INFO("Send packet to mesh");
service->sendToMesh(p, RX_SRC_LOCAL, true);
if (config.device.role == meshtastic_Config_DeviceConfig_Role_SENSOR && config.power.is_power_saving) {
- LOG_DEBUG("Starting next execution in 5 seconds and then going to sleep.\n");
+ LOG_DEBUG("Start next execution in 5s, then sleep");
sleepOnNextExecution = true;
setIntervalFromNow(5000);
}
diff --git a/src/modules/Telemetry/HealthTelemetry.h b/src/modules/Telemetry/HealthTelemetry.h
index 4ad0da838..fe84f2d27 100644
--- a/src/modules/Telemetry/HealthTelemetry.h
+++ b/src/modules/Telemetry/HealthTelemetry.h
@@ -16,7 +16,7 @@ class HealthTelemetryModule : private concurrency::OSThread, public ProtobufModu
public:
HealthTelemetryModule()
- : concurrency::OSThread("HealthTelemetryModule"),
+ : concurrency::OSThread("HealthTelemetry"),
ProtobufModule("HealthTelemetry", meshtastic_PortNum_TELEMETRY_APP, &meshtastic_Telemetry_msg)
{
lastMeasurementPacket = nullptr;
diff --git a/src/modules/Telemetry/PowerTelemetry.cpp b/src/modules/Telemetry/PowerTelemetry.cpp
index be3048998..367643849 100644
--- a/src/modules/Telemetry/PowerTelemetry.cpp
+++ b/src/modules/Telemetry/PowerTelemetry.cpp
@@ -27,8 +27,8 @@ int32_t PowerTelemetryModule::runOnce()
sleepOnNextExecution = false;
uint32_t nightyNightMs = Default::getConfiguredOrDefaultMs(moduleConfig.telemetry.power_update_interval,
default_telemetry_broadcast_interval_secs);
- LOG_DEBUG("Sleeping for %ims, then awaking to send metrics again.\n", nightyNightMs);
- doDeepSleep(nightyNightMs, true);
+ LOG_DEBUG("Sleep for %ims, then awake to send metrics again", nightyNightMs);
+ doDeepSleep(nightyNightMs, true, false);
}
uint32_t result = UINT32_MAX;
@@ -51,7 +51,7 @@ int32_t PowerTelemetryModule::runOnce()
firstTime = 0;
#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO)
if (moduleConfig.telemetry.power_measurement_enabled) {
- LOG_INFO("Power Telemetry: Initializing\n");
+ LOG_INFO("Power Telemetry: init");
// it's possible to have this module enabled, only for displaying values on the screen.
// therefore, we should only enable the sensor loop if measurement is also enabled
if (ina219Sensor.hasSensor() && !ina219Sensor.isInitialized())
@@ -145,7 +145,7 @@ bool PowerTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &m
const char *sender = getSenderShortName(mp);
LOG_INFO("(Received from %s): ch1_voltage=%.1f, ch1_current=%.1f, ch2_voltage=%.1f, ch2_current=%.1f, "
- "ch3_voltage=%.1f, ch3_current=%.1f\n",
+ "ch3_voltage=%.1f, ch3_current=%.1f",
sender, t->variant.power_metrics.ch1_voltage, t->variant.power_metrics.ch1_current,
t->variant.power_metrics.ch2_voltage, t->variant.power_metrics.ch2_current, t->variant.power_metrics.ch3_voltage,
t->variant.power_metrics.ch3_current);
@@ -192,14 +192,14 @@ meshtastic_MeshPacket *PowerTelemetryModule::allocReply()
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, &meshtastic_Telemetry_msg, &scratch)) {
decoded = &scratch;
} else {
- LOG_ERROR("Error decoding PowerTelemetry module!\n");
+ LOG_ERROR("Error decoding PowerTelemetry module!");
return NULL;
}
// Check for a request for power metrics
if (decoded->which_variant == meshtastic_Telemetry_power_metrics_tag) {
meshtastic_Telemetry m = meshtastic_Telemetry_init_zero;
if (getPowerTelemetry(&m)) {
- LOG_INFO("Power telemetry replying to request\n");
+ LOG_INFO("Power telemetry reply to request");
return allocDataProtobuf(m);
} else {
return NULL;
@@ -216,8 +216,8 @@ bool PowerTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
m.which_variant = meshtastic_Telemetry_power_metrics_tag;
m.time = getTime();
if (getPowerTelemetry(&m)) {
- LOG_INFO("(Sending): ch1_voltage=%f, ch1_current=%f, ch2_voltage=%f, ch2_current=%f, "
- "ch3_voltage=%f, ch3_current=%f\n",
+ LOG_INFO("Send: ch1_voltage=%f, ch1_current=%f, ch2_voltage=%f, ch2_current=%f, "
+ "ch3_voltage=%f, ch3_current=%f",
m.variant.power_metrics.ch1_voltage, m.variant.power_metrics.ch1_current, m.variant.power_metrics.ch2_voltage,
m.variant.power_metrics.ch2_current, m.variant.power_metrics.ch3_voltage, m.variant.power_metrics.ch3_current);
@@ -236,14 +236,14 @@ bool PowerTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
lastMeasurementPacket = packetPool.allocCopy(*p);
if (phoneOnly) {
- LOG_INFO("Sending packet to phone\n");
+ LOG_INFO("Send packet to phone");
service->sendToPhone(p);
} else {
- LOG_INFO("Sending packet to mesh\n");
+ LOG_INFO("Send packet to mesh");
service->sendToMesh(p, RX_SRC_LOCAL, true);
if (config.device.role == meshtastic_Config_DeviceConfig_Role_SENSOR && config.power.is_power_saving) {
- LOG_DEBUG("Starting next execution in 5s then going to sleep.\n");
+ LOG_DEBUG("Start next execution in 5s then sleep");
sleepOnNextExecution = true;
setIntervalFromNow(5000);
}
diff --git a/src/modules/Telemetry/PowerTelemetry.h b/src/modules/Telemetry/PowerTelemetry.h
index f8248304e..b9ec6edc1 100644
--- a/src/modules/Telemetry/PowerTelemetry.h
+++ b/src/modules/Telemetry/PowerTelemetry.h
@@ -17,7 +17,7 @@ class PowerTelemetryModule : private concurrency::OSThread, public ProtobufModul
public:
PowerTelemetryModule()
- : concurrency::OSThread("PowerTelemetryModule"),
+ : concurrency::OSThread("PowerTelemetry"),
ProtobufModule("PowerTelemetry", meshtastic_PortNum_TELEMETRY_APP, &meshtastic_Telemetry_msg)
{
lastMeasurementPacket = nullptr;
diff --git a/src/modules/Telemetry/Sensor/AHT10.cpp b/src/modules/Telemetry/Sensor/AHT10.cpp
index f9e8ba18a..4d8c80200 100644
--- a/src/modules/Telemetry/Sensor/AHT10.cpp
+++ b/src/modules/Telemetry/Sensor/AHT10.cpp
@@ -13,7 +13,7 @@ AHT10Sensor::AHT10Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_AHT1
int32_t AHT10Sensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
@@ -27,7 +27,7 @@ void AHT10Sensor::setup() {}
bool AHT10Sensor::getMetrics(meshtastic_Telemetry *measurement)
{
- LOG_DEBUG("AHT10Sensor::getMetrics\n");
+ LOG_DEBUG("AHT10 getMetrics");
sensors_event_t humidity, temp;
aht10.getEvent(&humidity, &temp);
diff --git a/src/modules/Telemetry/Sensor/BME280Sensor.cpp b/src/modules/Telemetry/Sensor/BME280Sensor.cpp
index 55bc16744..65dab5105 100644
--- a/src/modules/Telemetry/Sensor/BME280Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/BME280Sensor.cpp
@@ -12,7 +12,7 @@ BME280Sensor::BME280Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BM
int32_t BME280Sensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
@@ -35,7 +35,7 @@ bool BME280Sensor::getMetrics(meshtastic_Telemetry *measurement)
measurement->variant.environment_metrics.has_relative_humidity = true;
measurement->variant.environment_metrics.has_barometric_pressure = true;
- LOG_DEBUG("BME280Sensor::getMetrics\n");
+ LOG_DEBUG("BME280 getMetrics");
bme280.takeForcedMeasurement();
measurement->variant.environment_metrics.temperature = bme280.readTemperature();
measurement->variant.environment_metrics.relative_humidity = bme280.readHumidity();
diff --git a/src/modules/Telemetry/Sensor/BME680Sensor.cpp b/src/modules/Telemetry/Sensor/BME680Sensor.cpp
index 328ec827d..18515d0a8 100644
--- a/src/modules/Telemetry/Sensor/BME680Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/BME680Sensor.cpp
@@ -37,13 +37,13 @@ int32_t BME680Sensor::runOnce()
checkStatus("updateSubscription");
status = 0;
}
- LOG_INFO("Init sensor: %s with the BSEC Library version %d.%d.%d.%d \n", sensorName, bme680.version.major,
+ LOG_INFO("Init sensor: %s with the BSEC Library version %d.%d.%d.%d ", sensorName, bme680.version.major,
bme680.version.minor, bme680.version.major_bugfix, bme680.version.minor_bugfix);
} else {
status = 0;
}
if (status == 0)
- LOG_DEBUG("BME680Sensor::runOnce: bme680.status %d\n", bme680.status);
+ LOG_DEBUG("BME680Sensor::runOnce: bme680.status %d", bme680.status);
return initI2CSensor();
}
@@ -80,12 +80,12 @@ void BME680Sensor::loadState()
file.read((uint8_t *)&bsecState, BSEC_MAX_STATE_BLOB_SIZE);
file.close();
bme680.setState(bsecState);
- LOG_INFO("%s state read from %s.\n", sensorName, bsecConfigFileName);
+ LOG_INFO("%s state read from %s", sensorName, bsecConfigFileName);
} else {
- LOG_INFO("No %s state found (File: %s).\n", sensorName, bsecConfigFileName);
+ LOG_INFO("No %s state found (File: %s)", sensorName, bsecConfigFileName);
}
#else
- LOG_ERROR("ERROR: Filesystem not implemented\n");
+ LOG_ERROR("ERROR: Filesystem not implemented");
#endif
}
@@ -97,16 +97,16 @@ void BME680Sensor::updateState()
/* First state update when IAQ accuracy is >= 3 */
accuracy = bme680.getData(BSEC_OUTPUT_IAQ).accuracy;
if (accuracy >= 2) {
- LOG_DEBUG("%s state update IAQ accuracy %u >= 2\n", sensorName, accuracy);
+ LOG_DEBUG("%s state update IAQ accuracy %u >= 2", sensorName, accuracy);
update = true;
stateUpdateCounter++;
} else {
- LOG_DEBUG("%s not updated, IAQ accuracy is %u < 2\n", sensorName, accuracy);
+ LOG_DEBUG("%s not updated, IAQ accuracy is %u < 2", sensorName, accuracy);
}
} else {
/* Update every STATE_SAVE_PERIOD minutes */
if ((stateUpdateCounter * STATE_SAVE_PERIOD) < millis()) {
- LOG_DEBUG("%s state update every %d minutes\n", sensorName, STATE_SAVE_PERIOD / 60000);
+ LOG_DEBUG("%s state update every %d minutes", sensorName, STATE_SAVE_PERIOD / 60000);
update = true;
stateUpdateCounter++;
}
@@ -115,34 +115,34 @@ void BME680Sensor::updateState()
if (update) {
bme680.getState(bsecState);
if (FSCom.exists(bsecConfigFileName) && !FSCom.remove(bsecConfigFileName)) {
- LOG_WARN("Can't remove old state file\n");
+ LOG_WARN("Can't remove old state file");
}
auto file = FSCom.open(bsecConfigFileName, FILE_O_WRITE);
if (file) {
- LOG_INFO("%s state write to %s.\n", sensorName, bsecConfigFileName);
+ LOG_INFO("%s state write to %s", sensorName, bsecConfigFileName);
file.write((uint8_t *)&bsecState, BSEC_MAX_STATE_BLOB_SIZE);
file.flush();
file.close();
} else {
- LOG_INFO("Can't write %s state (File: %s).\n", sensorName, bsecConfigFileName);
+ LOG_INFO("Can't write %s state (File: %s)", sensorName, bsecConfigFileName);
}
}
#else
- LOG_ERROR("ERROR: Filesystem not implemented\n");
+ LOG_ERROR("ERROR: Filesystem not implemented");
#endif
}
void BME680Sensor::checkStatus(String functionName)
{
if (bme680.status < BSEC_OK)
- LOG_ERROR("%s BSEC2 code: %s\n", functionName.c_str(), String(bme680.status).c_str());
+ LOG_ERROR("%s BSEC2 code: %s", functionName.c_str(), String(bme680.status).c_str());
else if (bme680.status > BSEC_OK)
- LOG_WARN("%s BSEC2 code: %s\n", functionName.c_str(), String(bme680.status).c_str());
+ LOG_WARN("%s BSEC2 code: %s", functionName.c_str(), String(bme680.status).c_str());
if (bme680.sensor.status < BME68X_OK)
- LOG_ERROR("%s BME68X code: %s\n", functionName.c_str(), String(bme680.sensor.status).c_str());
+ LOG_ERROR("%s BME68X code: %s", functionName.c_str(), String(bme680.sensor.status).c_str());
else if (bme680.sensor.status > BME68X_OK)
- LOG_WARN("%s BME68X code: %s\n", functionName.c_str(), String(bme680.sensor.status).c_str());
+ LOG_WARN("%s BME68X code: %s", functionName.c_str(), String(bme680.sensor.status).c_str());
}
-#endif
\ No newline at end of file
+#endif
diff --git a/src/modules/Telemetry/Sensor/BMP085Sensor.cpp b/src/modules/Telemetry/Sensor/BMP085Sensor.cpp
index 15951126f..7f59f14f0 100644
--- a/src/modules/Telemetry/Sensor/BMP085Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/BMP085Sensor.cpp
@@ -12,7 +12,7 @@ BMP085Sensor::BMP085Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BM
int32_t BMP085Sensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
@@ -29,7 +29,7 @@ bool BMP085Sensor::getMetrics(meshtastic_Telemetry *measurement)
measurement->variant.environment_metrics.has_temperature = true;
measurement->variant.environment_metrics.has_barometric_pressure = true;
- LOG_DEBUG("BMP085Sensor::getMetrics\n");
+ LOG_DEBUG("BMP085 getMetrics");
measurement->variant.environment_metrics.temperature = bmp085.readTemperature();
measurement->variant.environment_metrics.barometric_pressure = bmp085.readPressure() / 100.0F;
diff --git a/src/modules/Telemetry/Sensor/BMP280Sensor.cpp b/src/modules/Telemetry/Sensor/BMP280Sensor.cpp
index 6b0743d75..56a8bc080 100644
--- a/src/modules/Telemetry/Sensor/BMP280Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/BMP280Sensor.cpp
@@ -12,7 +12,7 @@ BMP280Sensor::BMP280Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BM
int32_t BMP280Sensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
@@ -34,7 +34,7 @@ bool BMP280Sensor::getMetrics(meshtastic_Telemetry *measurement)
measurement->variant.environment_metrics.has_temperature = true;
measurement->variant.environment_metrics.has_barometric_pressure = true;
- LOG_DEBUG("BMP280Sensor::getMetrics\n");
+ LOG_DEBUG("BMP280 getMetrics");
bmp280.takeForcedMeasurement();
measurement->variant.environment_metrics.temperature = bmp280.readTemperature();
measurement->variant.environment_metrics.barometric_pressure = bmp280.readPressure() / 100.0F;
diff --git a/src/modules/Telemetry/Sensor/BMP3XXSensor.cpp b/src/modules/Telemetry/Sensor/BMP3XXSensor.cpp
index 399610613..69feaf3d9 100644
--- a/src/modules/Telemetry/Sensor/BMP3XXSensor.cpp
+++ b/src/modules/Telemetry/Sensor/BMP3XXSensor.cpp
@@ -10,7 +10,7 @@ void BMP3XXSensor::setup() {}
int32_t BMP3XXSensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
@@ -50,11 +50,11 @@ bool BMP3XXSensor::getMetrics(meshtastic_Telemetry *measurement)
measurement->variant.environment_metrics.barometric_pressure = static_cast(bmp3xx->pressure) / 100.0F;
measurement->variant.environment_metrics.relative_humidity = 0.0f;
- LOG_DEBUG("BMP3XXSensor::getMetrics id: %i temp: %.1f press %.1f\n", measurement->which_variant,
+ LOG_DEBUG("BMP3XX getMetrics id: %i temp: %.1f press %.1f", measurement->which_variant,
measurement->variant.environment_metrics.temperature,
measurement->variant.environment_metrics.barometric_pressure);
} else {
- LOG_DEBUG("BMP3XXSensor::getMetrics id: %i\n", measurement->which_variant);
+ LOG_DEBUG("BMP3XX getMetrics id: %i", measurement->which_variant);
}
return true;
}
diff --git a/src/modules/Telemetry/Sensor/CGRadSensSensor.cpp b/src/modules/Telemetry/Sensor/CGRadSensSensor.cpp
new file mode 100644
index 000000000..5e69cc22f
--- /dev/null
+++ b/src/modules/Telemetry/Sensor/CGRadSensSensor.cpp
@@ -0,0 +1,75 @@
+/*
+ * Support for the ClimateGuard RadSens Dosimeter
+ * A fun and educational sensor for Meshtastic; not for safety critical applications.
+ */
+#include "configuration.h"
+
+#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
+
+#include "../mesh/generated/meshtastic/telemetry.pb.h"
+#include "CGRadSensSensor.h"
+#include "TelemetrySensor.h"
+#include
+#include
+
+CGRadSensSensor::CGRadSensSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_RADSENS, "RadSens") {}
+
+int32_t CGRadSensSensor::runOnce()
+{
+ // Initialize the sensor following the same pattern as RCWL9620Sensor
+ LOG_INFO("Init sensor: %s", sensorName);
+ if (!hasSensor()) {
+ return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
+ }
+
+ status = true;
+ begin(nodeTelemetrySensorsMap[sensorType].second, nodeTelemetrySensorsMap[sensorType].first);
+
+ return initI2CSensor();
+}
+
+void CGRadSensSensor::setup() {}
+
+void CGRadSensSensor::begin(TwoWire *wire, uint8_t addr)
+{
+ // Store the Wire and address to the sensor following the same pattern as RCWL9620Sensor
+ _wire = wire;
+ _addr = addr;
+ _wire->begin();
+}
+
+float CGRadSensSensor::getStaticRadiation()
+{
+ // Read a register, following the same pattern as the RCWL9620Sensor
+ uint32_t data;
+ _wire->beginTransmission(_addr); // Transfer data to addr.
+ _wire->write(0x06); // Radiation intensity (static period T = 500 sec)
+ if (_wire->endTransmission() == 0) {
+ if (_wire->requestFrom(_addr, (uint8_t)3)) {
+ ; // Request 3 bytes
+ data = _wire->read();
+ data <<= 8;
+ data |= _wire->read();
+ data <<= 8;
+ data |= _wire->read();
+
+ // As per the data sheet for the RadSens
+ // Register 0x06 contains the reading in 0.1 * μR / h
+ float microRadPerHr = float(data) / 10.0;
+ return microRadPerHr;
+ }
+ }
+ return -1.0;
+}
+
+bool CGRadSensSensor::getMetrics(meshtastic_Telemetry *measurement)
+{
+ // Store the meansurement in the the appropriate fields of the protobuf
+ measurement->variant.environment_metrics.has_radiation = true;
+
+ LOG_DEBUG("CGRADSENS getMetrics");
+ measurement->variant.environment_metrics.radiation = getStaticRadiation();
+
+ return true;
+}
+#endif
\ No newline at end of file
diff --git a/src/modules/Telemetry/Sensor/CGRadSensSensor.h b/src/modules/Telemetry/Sensor/CGRadSensSensor.h
new file mode 100644
index 000000000..3b15a19a2
--- /dev/null
+++ b/src/modules/Telemetry/Sensor/CGRadSensSensor.h
@@ -0,0 +1,30 @@
+/*
+ * Support for the ClimateGuard RadSens Dosimeter
+ * A fun and educational sensor for Meshtastic; not for safety critical applications.
+ */
+#include "configuration.h"
+
+#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
+
+#include "../mesh/generated/meshtastic/telemetry.pb.h"
+#include "TelemetrySensor.h"
+#include
+
+class CGRadSensSensor : public TelemetrySensor
+{
+ private:
+ uint8_t _addr = 0x66;
+ TwoWire *_wire = &Wire;
+
+ protected:
+ virtual void setup() override;
+ void begin(TwoWire *wire = &Wire, uint8_t addr = 0x66);
+ float getStaticRadiation();
+
+ public:
+ CGRadSensSensor();
+ virtual int32_t runOnce() override;
+ virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
+};
+
+#endif
\ No newline at end of file
diff --git a/src/modules/Telemetry/Sensor/DFRobotLarkSensor.cpp b/src/modules/Telemetry/Sensor/DFRobotLarkSensor.cpp
index 4b01eb444..1d143b03b 100644
--- a/src/modules/Telemetry/Sensor/DFRobotLarkSensor.cpp
+++ b/src/modules/Telemetry/Sensor/DFRobotLarkSensor.cpp
@@ -13,7 +13,7 @@ DFRobotLarkSensor::DFRobotLarkSensor() : TelemetrySensor(meshtastic_TelemetrySen
int32_t DFRobotLarkSensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
@@ -22,10 +22,10 @@ int32_t DFRobotLarkSensor::runOnce()
if (lark.begin() == 0) // DFRobotLarkSensor init
{
- LOG_DEBUG("DFRobotLarkSensor Init Succeed\n");
+ LOG_DEBUG("DFRobotLarkSensor Init Succeed");
status = true;
} else {
- LOG_ERROR("DFRobotLarkSensor Init Failed\n");
+ LOG_ERROR("DFRobotLarkSensor Init Failed");
status = false;
}
return initI2CSensor();
@@ -47,11 +47,11 @@ bool DFRobotLarkSensor::getMetrics(meshtastic_Telemetry *measurement)
measurement->variant.environment_metrics.wind_direction = GeoCoord::bearingToDegrees(lark.getValue("Dir").c_str());
measurement->variant.environment_metrics.barometric_pressure = lark.getValue("Pressure").toFloat();
- LOG_INFO("Temperature: %f\n", measurement->variant.environment_metrics.temperature);
- LOG_INFO("Humidity: %f\n", measurement->variant.environment_metrics.relative_humidity);
- LOG_INFO("Wind Speed: %f\n", measurement->variant.environment_metrics.wind_speed);
- LOG_INFO("Wind Direction: %d\n", measurement->variant.environment_metrics.wind_direction);
- LOG_INFO("Barometric Pressure: %f\n", measurement->variant.environment_metrics.barometric_pressure);
+ LOG_INFO("Temperature: %f", measurement->variant.environment_metrics.temperature);
+ LOG_INFO("Humidity: %f", measurement->variant.environment_metrics.relative_humidity);
+ LOG_INFO("Wind Speed: %f", measurement->variant.environment_metrics.wind_speed);
+ LOG_INFO("Wind Direction: %d", measurement->variant.environment_metrics.wind_direction);
+ LOG_INFO("Barometric Pressure: %f", measurement->variant.environment_metrics.barometric_pressure);
return true;
}
diff --git a/src/modules/Telemetry/Sensor/INA219Sensor.cpp b/src/modules/Telemetry/Sensor/INA219Sensor.cpp
index f70d3705e..de69163b4 100644
--- a/src/modules/Telemetry/Sensor/INA219Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/INA219Sensor.cpp
@@ -15,7 +15,7 @@ INA219Sensor::INA219Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_IN
int32_t INA219Sensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
diff --git a/src/modules/Telemetry/Sensor/INA260Sensor.cpp b/src/modules/Telemetry/Sensor/INA260Sensor.cpp
index 751608c82..24182b336 100644
--- a/src/modules/Telemetry/Sensor/INA260Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/INA260Sensor.cpp
@@ -11,7 +11,7 @@ INA260Sensor::INA260Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_IN
int32_t INA260Sensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
diff --git a/src/modules/Telemetry/Sensor/INA3221Sensor.cpp b/src/modules/Telemetry/Sensor/INA3221Sensor.cpp
index 549346d72..ed09856e2 100644
--- a/src/modules/Telemetry/Sensor/INA3221Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/INA3221Sensor.cpp
@@ -11,7 +11,7 @@ INA3221Sensor::INA3221Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_
int32_t INA3221Sensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
diff --git a/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp b/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp
index 111d86d1a..170fafd39 100644
--- a/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp
+++ b/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp
@@ -12,7 +12,7 @@ LPS22HBSensor::LPS22HBSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_
int32_t LPS22HBSensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
diff --git a/src/modules/Telemetry/Sensor/MAX17048Sensor.cpp b/src/modules/Telemetry/Sensor/MAX17048Sensor.cpp
index 96dd5ae80..3aacf9cd7 100644
--- a/src/modules/Telemetry/Sensor/MAX17048Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/MAX17048Sensor.cpp
@@ -19,7 +19,7 @@ MAX17048Singleton *MAX17048Singleton::pinstance{nullptr};
bool MAX17048Singleton::runOnce(TwoWire *theWire)
{
initialized = begin(theWire);
- LOG_DEBUG("%s::runOnce %s\n", sensorStr, initialized ? "began ok" : "begin failed");
+ LOG_DEBUG("%s::runOnce %s", sensorStr, initialized ? "began ok" : "begin failed");
return initialized;
}
@@ -27,7 +27,7 @@ bool MAX17048Singleton::isBatteryCharging()
{
float volts = cellVoltage();
if (isnan(volts)) {
- LOG_DEBUG("%s::isBatteryCharging is not connected\n", sensorStr);
+ LOG_DEBUG("%s::isBatteryCharging not connected", sensorStr);
return 0;
}
@@ -53,7 +53,7 @@ bool MAX17048Singleton::isBatteryCharging()
chargeState = MAX17048ChargeState::IDLE;
}
- LOG_DEBUG("%s::isBatteryCharging %s volts: %.3f soc: %.3f rate: %.3f\n", sensorStr, chargeLabels[chargeState], volts,
+ LOG_DEBUG("%s::isBatteryCharging %s volts: %.3f soc: %.3f rate: %.3f", sensorStr, chargeLabels[chargeState], volts,
sample.cellPercent, sample.chargeRate);
return chargeState == MAX17048ChargeState::IMPORT;
}
@@ -62,17 +62,17 @@ uint16_t MAX17048Singleton::getBusVoltageMv()
{
float volts = cellVoltage();
if (isnan(volts)) {
- LOG_DEBUG("%s::getBusVoltageMv is not connected\n", sensorStr);
+ LOG_DEBUG("%s::getBusVoltageMv is not connected", sensorStr);
return 0;
}
- LOG_DEBUG("%s::getBusVoltageMv %.3fmV\n", sensorStr, volts);
+ LOG_DEBUG("%s::getBusVoltageMv %.3fmV", sensorStr, volts);
return (uint16_t)(volts * 1000.0f);
}
uint8_t MAX17048Singleton::getBusBatteryPercent()
{
float soc = cellPercent();
- LOG_DEBUG("%s::getBusBatteryPercent %.1f%%\n", sensorStr, soc);
+ LOG_DEBUG("%s::getBusBatteryPercent %.1f%%", sensorStr, soc);
return clamp(static_cast(round(soc)), static_cast(0), static_cast(100));
}
@@ -82,7 +82,7 @@ uint16_t MAX17048Singleton::getTimeToGoSecs()
float soc = cellPercent(); // state of charge in percent 0 to 100
soc = clamp(soc, 0.0f, 100.0f); // clamp soc between 0 and 100%
float ttg = ((100.0f - soc) / rate) * 3600.0f; // calculate seconds to charge/discharge
- LOG_DEBUG("%s::getTimeToGoSecs %.0f seconds\n", sensorStr, ttg);
+ LOG_DEBUG("%s::getTimeToGoSecs %.0f seconds", sensorStr, ttg);
return (uint16_t)ttg;
}
@@ -90,7 +90,7 @@ bool MAX17048Singleton::isBatteryConnected()
{
float volts = cellVoltage();
if (isnan(volts)) {
- LOG_DEBUG("%s::isBatteryConnected is not connected\n", sensorStr);
+ LOG_DEBUG("%s::isBatteryConnected is not connected", sensorStr);
return false;
}
@@ -103,12 +103,12 @@ bool MAX17048Singleton::isExternallyPowered()
float volts = cellVoltage();
if (isnan(volts)) {
// if the battery is not connected then there must be external power
- LOG_DEBUG("%s::isExternallyPowered battery is\n", sensorStr);
+ LOG_DEBUG("%s::isExternallyPowered battery is", sensorStr);
return true;
}
// if the bus voltage is over MAX17048_BUS_POWER_VOLTS, then the external power
// is assumed to be connected
- LOG_DEBUG("%s::isExternallyPowered %s connected\n", sensorStr, volts >= MAX17048_BUS_POWER_VOLTS ? "is" : "is not");
+ LOG_DEBUG("%s::isExternallyPowered %s connected", sensorStr, volts >= MAX17048_BUS_POWER_VOLTS ? "is" : "is not");
return volts >= MAX17048_BUS_POWER_VOLTS;
}
@@ -119,11 +119,11 @@ MAX17048Sensor::MAX17048Sensor() : TelemetrySensor(meshtastic_TelemetrySensorTyp
int32_t MAX17048Sensor::runOnce()
{
if (isInitialized()) {
- LOG_INFO("Init sensor: %s is already initialised\n", sensorName);
+ LOG_INFO("Init sensor: %s is already initialised", sensorName);
return true;
}
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
@@ -140,11 +140,11 @@ void MAX17048Sensor::setup() {}
bool MAX17048Sensor::getMetrics(meshtastic_Telemetry *measurement)
{
- LOG_DEBUG("MAX17048Sensor::getMetrics id: %i\n", measurement->which_variant);
+ LOG_DEBUG("MAX17048 getMetrics id: %i", measurement->which_variant);
float volts = max17048->cellVoltage();
if (isnan(volts)) {
- LOG_DEBUG("MAX17048Sensor::getMetrics battery is not connected\n");
+ LOG_DEBUG("MAX17048 getMetrics battery is not connected");
return false;
}
@@ -153,7 +153,7 @@ bool MAX17048Sensor::getMetrics(meshtastic_Telemetry *measurement)
soc = clamp(soc, 0.0f, 100.0f); // clamp soc between 0 and 100%
float ttg = (100.0f - soc) / rate; // calculate hours to charge/discharge
- LOG_DEBUG("MAX17048Sensor::getMetrics volts: %.3fV soc: %.1f%% ttg: %.1f hours\n", volts, soc, ttg);
+ LOG_DEBUG("MAX17048 getMetrics volts: %.3fV soc: %.1f%% ttg: %.1f hours", volts, soc, ttg);
if ((int)measurement->which_variant == meshtastic_Telemetry_power_metrics_tag) {
measurement->variant.power_metrics.has_ch1_voltage = true;
measurement->variant.power_metrics.ch1_voltage = volts;
diff --git a/src/modules/Telemetry/Sensor/MAX30102Sensor.cpp b/src/modules/Telemetry/Sensor/MAX30102Sensor.cpp
index b3b20e5f2..88128a6db 100644
--- a/src/modules/Telemetry/Sensor/MAX30102Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/MAX30102Sensor.cpp
@@ -11,7 +11,7 @@ MAX30102Sensor::MAX30102Sensor() : TelemetrySensor(meshtastic_TelemetrySensorTyp
int32_t MAX30102Sensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
@@ -28,10 +28,10 @@ int32_t MAX30102Sensor::runOnce()
max30102.enableDIETEMPRDY(); // Enable the temperature ready interrupt
max30102.setup(brightness, sampleAverage, leds, sampleRate, pulseWidth, adcRange);
- LOG_DEBUG("MAX30102 Init Succeed\n");
+ LOG_DEBUG("MAX30102 Init Succeed");
status = true;
} else {
- LOG_ERROR("MAX30102 Init Failed\n");
+ LOG_ERROR("MAX30102 Init Failed");
status = false;
}
return initI2CSensor();
diff --git a/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp b/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp
index c1cda7227..58ce29cd2 100644
--- a/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp
@@ -11,7 +11,7 @@ MCP9808Sensor::MCP9808Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_
int32_t MCP9808Sensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
@@ -28,7 +28,7 @@ bool MCP9808Sensor::getMetrics(meshtastic_Telemetry *measurement)
{
measurement->variant.environment_metrics.has_temperature = true;
- LOG_DEBUG("MCP9808Sensor::getMetrics\n");
+ LOG_DEBUG("MCP9808 getMetrics");
measurement->variant.environment_metrics.temperature = mcp9808.readTempC();
return true;
}
diff --git a/src/modules/Telemetry/Sensor/MLX90614Sensor.cpp b/src/modules/Telemetry/Sensor/MLX90614Sensor.cpp
index 92c22bf21..d9908fce3 100644
--- a/src/modules/Telemetry/Sensor/MLX90614Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/MLX90614Sensor.cpp
@@ -9,7 +9,7 @@ MLX90614Sensor::MLX90614Sensor() : TelemetrySensor(meshtastic_TelemetrySensorTyp
int32_t MLX90614Sensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
@@ -19,12 +19,12 @@ int32_t MLX90614Sensor::runOnce()
LOG_DEBUG("MLX90614 emissivity: %f", mlx.readEmissivity());
if (fabs(MLX90614_EMISSIVITY - mlx.readEmissivity()) > 0.001) {
mlx.writeEmissivity(MLX90614_EMISSIVITY);
- LOG_INFO("MLX90614 emissivity updated. In case of weird data, power cycle.");
+ LOG_INFO("MLX90614 emissivity updated. In case of weird data, power cycle");
}
- LOG_DEBUG("MLX90614 Init Succeed\n");
+ LOG_DEBUG("MLX90614 Init Succeed");
status = true;
} else {
- LOG_ERROR("MLX90614 Init Failed\n");
+ LOG_ERROR("MLX90614 Init Failed");
status = false;
}
return initI2CSensor();
diff --git a/src/modules/Telemetry/Sensor/MLX90632Sensor.cpp b/src/modules/Telemetry/Sensor/MLX90632Sensor.cpp
index 0568a4652..b7bd6ae61 100644
--- a/src/modules/Telemetry/Sensor/MLX90632Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/MLX90632Sensor.cpp
@@ -10,7 +10,7 @@ MLX90632Sensor::MLX90632Sensor() : TelemetrySensor(meshtastic_TelemetrySensorTyp
int32_t MLX90632Sensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
@@ -19,10 +19,10 @@ int32_t MLX90632Sensor::runOnce()
if (mlx.begin(nodeTelemetrySensorsMap[sensorType].first, *nodeTelemetrySensorsMap[sensorType].second, returnError) ==
true) // MLX90632 init
{
- LOG_DEBUG("MLX90632 Init Succeed\n");
+ LOG_DEBUG("MLX90632 Init Succeed");
status = true;
} else {
- LOG_ERROR("MLX90632 Init Failed\n");
+ LOG_ERROR("MLX90632 Init Failed");
status = false;
}
return initI2CSensor();
diff --git a/src/modules/Telemetry/Sensor/NAU7802Sensor.cpp b/src/modules/Telemetry/Sensor/NAU7802Sensor.cpp
index 59f310a24..65f616686 100644
--- a/src/modules/Telemetry/Sensor/NAU7802Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/NAU7802Sensor.cpp
@@ -17,17 +17,17 @@ NAU7802Sensor::NAU7802Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_
int32_t NAU7802Sensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
status = nau7802.begin(*nodeTelemetrySensorsMap[sensorType].second);
nau7802.setSampleRate(NAU7802_SPS_320);
if (!loadCalibrationData()) {
- LOG_ERROR("Failed to load calibration data\n");
+ LOG_ERROR("Failed to load calibration data");
}
nau7802.calibrateAFE();
- LOG_INFO("Offset: %d, Calibration factor: %.2f\n", nau7802.getZeroOffset(), nau7802.getCalibrationFactor());
+ LOG_INFO("Offset: %d, Calibration factor: %.2f", nau7802.getZeroOffset(), nau7802.getCalibrationFactor());
return initI2CSensor();
}
@@ -35,7 +35,7 @@ void NAU7802Sensor::setup() {}
bool NAU7802Sensor::getMetrics(meshtastic_Telemetry *measurement)
{
- LOG_DEBUG("NAU7802Sensor::getMetrics\n");
+ LOG_DEBUG("NAU7802 getMetrics");
nau7802.powerUp();
// Wait for the sensor to become ready for one second max
uint32_t start = millis();
@@ -48,7 +48,7 @@ bool NAU7802Sensor::getMetrics(meshtastic_Telemetry *measurement)
}
measurement->variant.environment_metrics.has_weight = true;
// Check if we have correct calibration values after powerup
- LOG_DEBUG("Offset: %d, Calibration factor: %.2f\n", nau7802.getZeroOffset(), nau7802.getCalibrationFactor());
+ LOG_DEBUG("Offset: %d, Calibration factor: %.2f", nau7802.getZeroOffset(), nau7802.getCalibrationFactor());
measurement->variant.environment_metrics.weight = nau7802.getWeight() / 1000; // sample is in kg
nau7802.powerDown();
return true;
@@ -58,9 +58,9 @@ void NAU7802Sensor::calibrate(float weight)
{
nau7802.calculateCalibrationFactor(weight * 1000, 64); // internal sample is in grams
if (!saveCalibrationData()) {
- LOG_WARN("Failed to save calibration data\n");
+ LOG_WARN("Failed to save calibration data");
}
- LOG_INFO("Offset: %d, Calibration factor: %.2f\n", nau7802.getZeroOffset(), nau7802.getCalibrationFactor());
+ LOG_INFO("Offset: %d, Calibration factor: %.2f", nau7802.getZeroOffset(), nau7802.getCalibrationFactor());
}
AdminMessageHandleResult NAU7802Sensor::handleAdminMessage(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *request,
@@ -72,10 +72,10 @@ AdminMessageHandleResult NAU7802Sensor::handleAdminMessage(const meshtastic_Mesh
case meshtastic_AdminMessage_set_scale_tag:
if (request->set_scale == 0) {
this->tare();
- LOG_DEBUG("Client requested to tare scale\n");
+ LOG_DEBUG("Client requested to tare scale");
} else {
this->calibrate(request->set_scale);
- LOG_DEBUG("Client requested to calibrate to %d kg\n", request->set_scale);
+ LOG_DEBUG("Client requested to calibrate to %d kg", request->set_scale);
}
result = AdminMessageHandleResult::HANDLED;
break;
@@ -91,9 +91,9 @@ void NAU7802Sensor::tare()
{
nau7802.calculateZeroOffset(64);
if (!saveCalibrationData()) {
- LOG_WARN("Failed to save calibration data\n");
+ LOG_WARN("Failed to save calibration data");
}
- LOG_INFO("Offset: %d, Calibration factor: %.2f\n", nau7802.getZeroOffset(), nau7802.getCalibrationFactor());
+ LOG_INFO("Offset: %d, Calibration factor: %.2f", nau7802.getZeroOffset(), nau7802.getCalibrationFactor());
}
bool NAU7802Sensor::saveCalibrationData()
@@ -103,11 +103,11 @@ bool NAU7802Sensor::saveCalibrationData()
nau7802config.calibrationFactor = nau7802.getCalibrationFactor();
bool okay = false;
- LOG_INFO("%s state write to %s.\n", sensorName, nau7802ConfigFileName);
+ LOG_INFO("%s state write to %s", sensorName, nau7802ConfigFileName);
pb_ostream_t stream = {&writecb, static_cast(&file), meshtastic_Nau7802Config_size};
if (!pb_encode(&stream, &meshtastic_Nau7802Config_msg, &nau7802config)) {
- 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;
}
@@ -121,10 +121,10 @@ bool NAU7802Sensor::loadCalibrationData()
auto file = FSCom.open(nau7802ConfigFileName, FILE_O_READ);
bool okay = false;
if (file) {
- LOG_INFO("%s state read from %s.\n", sensorName, nau7802ConfigFileName);
+ LOG_INFO("%s state read from %s", sensorName, nau7802ConfigFileName);
pb_istream_t stream = {&readcb, &file, meshtastic_Nau7802Config_size};
if (!pb_decode(&stream, &meshtastic_Nau7802Config_msg, &nau7802config)) {
- 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));
} else {
nau7802.setZeroOffset(nau7802config.zeroOffset);
nau7802.setCalibrationFactor(nau7802config.calibrationFactor);
@@ -132,9 +132,9 @@ bool NAU7802Sensor::loadCalibrationData()
}
file.close();
} else {
- LOG_INFO("No %s state found (File: %s).\n", sensorName, nau7802ConfigFileName);
+ LOG_INFO("No %s state found (File: %s)", sensorName, nau7802ConfigFileName);
}
return okay;
}
-#endif
\ No newline at end of file
+#endif
diff --git a/src/modules/Telemetry/Sensor/OPT3001Sensor.cpp b/src/modules/Telemetry/Sensor/OPT3001Sensor.cpp
index 3e4376d55..75c6cd41a 100644
--- a/src/modules/Telemetry/Sensor/OPT3001Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/OPT3001Sensor.cpp
@@ -11,7 +11,7 @@ OPT3001Sensor::OPT3001Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_
int32_t OPT3001Sensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
@@ -42,7 +42,7 @@ bool OPT3001Sensor::getMetrics(meshtastic_Telemetry *measurement)
OPT3001 result = opt3001.readResult();
measurement->variant.environment_metrics.lux = result.lux;
- LOG_INFO("Lux: %f\n", measurement->variant.environment_metrics.lux);
+ LOG_INFO("Lux: %f", measurement->variant.environment_metrics.lux);
return true;
}
diff --git a/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp b/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp
index b9a29ab7d..e352dda8d 100644
--- a/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp
@@ -10,7 +10,7 @@ RCWL9620Sensor::RCWL9620Sensor() : TelemetrySensor(meshtastic_TelemetrySensorTyp
int32_t RCWL9620Sensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
@@ -24,7 +24,7 @@ void RCWL9620Sensor::setup() {}
bool RCWL9620Sensor::getMetrics(meshtastic_Telemetry *measurement)
{
measurement->variant.environment_metrics.has_distance = true;
- LOG_DEBUG("RCWL9620Sensor::getMetrics\n");
+ LOG_DEBUG("RCWL9620 getMetrics");
measurement->variant.environment_metrics.distance = getDistance();
return true;
}
diff --git a/src/modules/Telemetry/Sensor/SHT31Sensor.cpp b/src/modules/Telemetry/Sensor/SHT31Sensor.cpp
index c372f7986..b96b94fa8 100644
--- a/src/modules/Telemetry/Sensor/SHT31Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/SHT31Sensor.cpp
@@ -11,7 +11,7 @@ SHT31Sensor::SHT31Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHT3
int32_t SHT31Sensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
diff --git a/src/modules/Telemetry/Sensor/SHT4XSensor.cpp b/src/modules/Telemetry/Sensor/SHT4XSensor.cpp
index 94367cba4..0fa6021dc 100644
--- a/src/modules/Telemetry/Sensor/SHT4XSensor.cpp
+++ b/src/modules/Telemetry/Sensor/SHT4XSensor.cpp
@@ -11,7 +11,7 @@ SHT4XSensor::SHT4XSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHT4
int32_t SHT4XSensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
@@ -22,7 +22,7 @@ int32_t SHT4XSensor::runOnce()
serialNumber = sht4x.readSerial();
if (serialNumber != 0) {
- LOG_DEBUG("serialNumber : %x\n", serialNumber);
+ LOG_DEBUG("serialNumber : %x", serialNumber);
status = 1;
} else {
LOG_DEBUG("Error trying to execute readSerial(): ");
diff --git a/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp b/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp
index 64ebfb472..3a7cc48d2 100644
--- a/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp
@@ -11,7 +11,7 @@ SHTC3Sensor::SHTC3Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHTC
int32_t SHTC3Sensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
diff --git a/src/modules/Telemetry/Sensor/T1000xSensor.cpp b/src/modules/Telemetry/Sensor/T1000xSensor.cpp
index 4772aeb9e..068969e8e 100644
--- a/src/modules/Telemetry/Sensor/T1000xSensor.cpp
+++ b/src/modules/Telemetry/Sensor/T1000xSensor.cpp
@@ -40,7 +40,7 @@ T1000xSensor::T1000xSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SE
int32_t T1000xSensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
diff --git a/src/modules/Telemetry/Sensor/TSL2591Sensor.cpp b/src/modules/Telemetry/Sensor/TSL2591Sensor.cpp
index 9002874b3..add475d5b 100644
--- a/src/modules/Telemetry/Sensor/TSL2591Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/TSL2591Sensor.cpp
@@ -12,7 +12,7 @@ TSL2591Sensor::TSL2591Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_
int32_t TSL2591Sensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
@@ -36,7 +36,7 @@ bool TSL2591Sensor::getMetrics(meshtastic_Telemetry *measurement)
full = lum & 0xFFFF;
measurement->variant.environment_metrics.lux = tsl.calculateLux(full, ir);
- LOG_INFO("Lux: %f\n", measurement->variant.environment_metrics.lux);
+ LOG_INFO("Lux: %f", measurement->variant.environment_metrics.lux);
return true;
}
diff --git a/src/modules/Telemetry/Sensor/TelemetrySensor.h b/src/modules/Telemetry/Sensor/TelemetrySensor.h
index da376ad31..08cc1125d 100644
--- a/src/modules/Telemetry/Sensor/TelemetrySensor.h
+++ b/src/modules/Telemetry/Sensor/TelemetrySensor.h
@@ -31,10 +31,10 @@ class TelemetrySensor
int32_t initI2CSensor()
{
if (!status) {
- LOG_WARN("Could not connect to detected %s sensor.\n Removing from nodeTelemetrySensorsMap.\n", sensorName);
+ LOG_WARN("Can't connect to detected %s sensor. Remove from nodeTelemetrySensorsMap", sensorName);
nodeTelemetrySensorsMap[sensorType].first = 0;
} else {
- LOG_INFO("Opened %s sensor on i2c bus\n", sensorName);
+ LOG_INFO("Opened %s sensor on i2c bus", sensorName);
setup();
}
initialized = true;
diff --git a/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp b/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp
index c176ed21b..496b49aeb 100644
--- a/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp
+++ b/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp
@@ -13,7 +13,7 @@ VEML7700Sensor::VEML7700Sensor() : TelemetrySensor(meshtastic_TelemetrySensorTyp
int32_t VEML7700Sensor::runOnce()
{
- LOG_INFO("Init sensor: %s\n", sensorName);
+ LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
@@ -60,7 +60,7 @@ bool VEML7700Sensor::getMetrics(meshtastic_Telemetry *measurement)
measurement->variant.environment_metrics.lux = veml7700.readLux(VEML_LUX_AUTO);
white = veml7700.readWhite(true);
measurement->variant.environment_metrics.white_lux = computeLux(white, white > 100);
- LOG_INFO("white lux %f, als lux %f\n", measurement->variant.environment_metrics.white_lux,
+ LOG_INFO("white lux %f, als lux %f", measurement->variant.environment_metrics.white_lux,
measurement->variant.environment_metrics.lux);
return true;
diff --git a/src/modules/Telemetry/UnitConversions.cpp b/src/modules/Telemetry/UnitConversions.cpp
index 9f40de40f..fff1ee3d2 100644
--- a/src/modules/Telemetry/UnitConversions.cpp
+++ b/src/modules/Telemetry/UnitConversions.cpp
@@ -1,8 +1,8 @@
#include "UnitConversions.h"
-float UnitConversions::CelsiusToFahrenheit(float celcius)
+float UnitConversions::CelsiusToFahrenheit(float celsius)
{
- return (celcius * 9) / 5 + 32;
+ return (celsius * 9) / 5 + 32;
}
float UnitConversions::MetersPerSecondToKnots(float metersPerSecond)
diff --git a/src/modules/Telemetry/UnitConversions.h b/src/modules/Telemetry/UnitConversions.h
index 60f9b664a..638476315 100644
--- a/src/modules/Telemetry/UnitConversions.h
+++ b/src/modules/Telemetry/UnitConversions.h
@@ -3,7 +3,7 @@
class UnitConversions
{
public:
- static float CelsiusToFahrenheit(float celcius);
+ static float CelsiusToFahrenheit(float celsius);
static float MetersPerSecondToKnots(float metersPerSecond);
static float MetersPerSecondToMilesPerHour(float metersPerSecond);
static float HectoPascalToInchesOfMercury(float hectoPascal);
diff --git a/src/modules/TextMessageModule.cpp b/src/modules/TextMessageModule.cpp
index 2933718af..f1d01ad16 100644
--- a/src/modules/TextMessageModule.cpp
+++ b/src/modules/TextMessageModule.cpp
@@ -10,7 +10,7 @@ ProcessMessage TextMessageModule::handleReceived(const meshtastic_MeshPacket &mp
{
#ifdef DEBUG_PORT
auto &p = mp.decoded;
- LOG_INFO("Received text msg from=0x%0x, id=0x%x, msg=%.*s\n", mp.from, mp.id, p.payload.size, p.payload.bytes);
+ LOG_INFO("Received text msg from=0x%0x, id=0x%x, msg=%.*s", mp.from, mp.id, p.payload.size, p.payload.bytes);
#endif
// We only store/display messages destined for us.
// Keep a copy of the most recent text message.
diff --git a/src/modules/TraceRouteModule.cpp b/src/modules/TraceRouteModule.cpp
index 955098c28..79b14de0a 100644
--- a/src/modules/TraceRouteModule.cpp
+++ b/src/modules/TraceRouteModule.cpp
@@ -1,5 +1,6 @@
#include "TraceRouteModule.h"
#include "MeshService.h"
+#include "meshUtils.h"
TraceRouteModule *traceRouteModule;
@@ -101,45 +102,47 @@ void TraceRouteModule::appendMyIDandSNR(meshtastic_RouteDiscovery *updated, floa
route[*route_count] = myNodeInfo.my_node_num;
*route_count += 1;
} else {
- LOG_WARN("Route exceeded maximum hop limit!\n"); // Are you bridging networks?
+ LOG_WARN("Route exceeded maximum hop limit!"); // Are you bridging networks?
}
}
void TraceRouteModule::printRoute(meshtastic_RouteDiscovery *r, uint32_t origin, uint32_t dest, bool isTowardsDestination)
{
#ifdef DEBUG_PORT
- LOG_INFO("Route traced:\n");
- LOG_INFO("0x%x --> ", origin);
+ std::string route = "Route traced:";
+ route += vformat("0x%x --> ", origin);
for (uint8_t i = 0; i < r->route_count; i++) {
if (i < r->snr_towards_count && r->snr_towards[i] != INT8_MIN)
- LOG_INFO("0x%x (%.2fdB) --> ", r->route[i], (float)r->snr_towards[i] / 4);
+ route += vformat("0x%x (%.2fdB) --> ", r->route[i], (float)r->snr_towards[i] / 4);
else
- LOG_INFO("0x%x (?dB) --> ", r->route[i]);
+ route += vformat("0x%x (?dB) --> ", r->route[i]);
}
// If we are the destination, or it has already reached the destination, print it
if (dest == nodeDB->getNodeNum() || !isTowardsDestination) {
if (r->snr_towards_count > 0 && r->snr_towards[r->snr_towards_count - 1] != INT8_MIN)
- LOG_INFO("0x%x (%.2fdB)\n", dest, (float)r->snr_towards[r->snr_towards_count - 1] / 4);
+ route += vformat("0x%x (%.2fdB)", dest, (float)r->snr_towards[r->snr_towards_count - 1] / 4);
+
else
- LOG_INFO("0x%x (?dB)\n", dest);
+ route += vformat("0x%x (?dB)", dest);
} else
- LOG_INFO("...\n");
+ route += "...";
// If there's a route back (or we are the destination as then the route is complete), print it
if (r->route_back_count > 0 || origin == nodeDB->getNodeNum()) {
if (r->snr_towards_count > 0 && origin == nodeDB->getNodeNum())
- LOG_INFO("(%.2fdB) 0x%x <-- ", (float)r->snr_back[r->snr_back_count - 1] / 4, origin);
+ route += vformat("(%.2fdB) 0x%x <-- ", (float)r->snr_back[r->snr_back_count - 1] / 4, origin);
else
- LOG_INFO("...");
+ route += "...";
for (int8_t i = r->route_back_count - 1; i >= 0; i--) {
if (i < r->snr_back_count && r->snr_back[i] != INT8_MIN)
- LOG_INFO("(%.2fdB) 0x%x <-- ", (float)r->snr_back[i] / 4, r->route_back[i]);
+ route += vformat("(%.2fdB) 0x%x <-- ", (float)r->snr_back[i] / 4, r->route_back[i]);
else
- LOG_INFO("(?dB) 0x%x <-- ", r->route_back[i]);
+ route += vformat("(?dB) 0x%x <-- ", r->route_back[i]);
}
- LOG_INFO("0x%x\n", dest);
+ route += vformat("0x%x", dest);
}
+ LOG_INFO(route.c_str());
#endif
}
diff --git a/src/modules/WaypointModule.cpp b/src/modules/WaypointModule.cpp
index a4611e780..b8b738309 100644
--- a/src/modules/WaypointModule.cpp
+++ b/src/modules/WaypointModule.cpp
@@ -14,7 +14,7 @@ ProcessMessage WaypointModule::handleReceived(const meshtastic_MeshPacket &mp)
{
#ifdef DEBUG_PORT
auto &p = mp.decoded;
- LOG_INFO("Received waypoint msg from=0x%0x, id=0x%x, msg=%.*s\n", mp.from, mp.id, p.payload.size, p.payload.bytes);
+ LOG_INFO("Received waypoint msg from=0x%0x, id=0x%x, msg=%.*s", mp.from, mp.id, p.payload.size, p.payload.bytes);
#endif
// We only store/display messages destined for us.
// Keep a copy of the most recent text message.
@@ -68,7 +68,7 @@ bool WaypointModule::shouldDraw()
}
// If decoding failed
- LOG_ERROR("Failed to decode waypoint\n");
+ LOG_ERROR("Failed to decode waypoint");
devicestate.has_rx_waypoint = false;
return false;
#else
@@ -126,7 +126,7 @@ void WaypointModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state,
}
// If our node has a position:
- if (ourNode && (hasValidPosition(ourNode) || screen->hasHeading())) {
+ if (ourNode && (nodeDB->hasValidPosition(ourNode) || screen->hasHeading())) {
const meshtastic_PositionLite &op = ourNode->position;
float myHeading;
if (screen->hasHeading())
diff --git a/src/modules/esp32/AudioModule.cpp b/src/modules/esp32/AudioModule.cpp
index 89e4b4e25..77cc94359 100644
--- a/src/modules/esp32/AudioModule.cpp
+++ b/src/modules/esp32/AudioModule.cpp
@@ -46,7 +46,7 @@ void run_codec2(void *parameter)
// 4 bytes of header in each frame hex c0 de c2 plus the bitrate
memcpy(audioModule->tx_encode_frame, &audioModule->tx_header, sizeof(audioModule->tx_header));
- LOG_INFO("Starting codec2 task\n");
+ LOG_INFO("Start codec2 task");
while (true) {
uint32_t tcount = ulTaskNotifyTake(pdFALSE, pdMS_TO_TICKS(10000));
@@ -61,7 +61,7 @@ void run_codec2(void *parameter)
audioModule->tx_encode_frame_index += audioModule->encode_codec_size;
if (audioModule->tx_encode_frame_index == (audioModule->encode_frame_size + sizeof(audioModule->tx_header))) {
- LOG_INFO("Sending %d codec2 bytes\n", audioModule->encode_frame_size);
+ LOG_INFO("Send %d codec2 bytes", audioModule->encode_frame_size);
audioModule->sendPayload();
audioModule->tx_encode_frame_index = sizeof(audioModule->tx_header);
}
@@ -91,7 +91,7 @@ void run_codec2(void *parameter)
}
}
-AudioModule::AudioModule() : SinglePortModule("AudioModule", meshtastic_PortNum_AUDIO_APP), concurrency::OSThread("AudioModule")
+AudioModule::AudioModule() : SinglePortModule("Audio", meshtastic_PortNum_AUDIO_APP), concurrency::OSThread("Audio")
{
// moduleConfig.audio.codec2_enabled = true;
// moduleConfig.audio.i2s_ws = 13;
@@ -101,8 +101,7 @@ AudioModule::AudioModule() : SinglePortModule("AudioModule", meshtastic_PortNum_
// moduleConfig.audio.ptt_pin = 39;
if ((moduleConfig.audio.codec2_enabled) && (myRegion->audioPermitted)) {
- LOG_INFO("Setting up codec2 in mode %u",
- (moduleConfig.audio.bitrate ? moduleConfig.audio.bitrate : AUDIO_MODULE_MODE) - 1);
+ LOG_INFO("Set up codec2 in mode %u", (moduleConfig.audio.bitrate ? moduleConfig.audio.bitrate : AUDIO_MODULE_MODE) - 1);
codec2 = codec2_create((moduleConfig.audio.bitrate ? moduleConfig.audio.bitrate : AUDIO_MODULE_MODE) - 1);
memcpy(tx_header.magic, c2_magic, sizeof(c2_magic));
tx_header.mode = (moduleConfig.audio.bitrate ? moduleConfig.audio.bitrate : AUDIO_MODULE_MODE) - 1;
@@ -111,7 +110,7 @@ AudioModule::AudioModule() : SinglePortModule("AudioModule", meshtastic_PortNum_
encode_frame_num = (meshtastic_Constants_DATA_PAYLOAD_LEN - sizeof(tx_header)) / encode_codec_size;
encode_frame_size = encode_frame_num * encode_codec_size; // max 233 bytes + 4 header bytes
adc_buffer_size = codec2_samples_per_frame(codec2);
- LOG_INFO("using %d frames of %d bytes for a total payload length of %d bytes\n", encode_frame_num, encode_codec_size,
+ LOG_INFO("Use %d frames of %d bytes for a total payload length of %d bytes", encode_frame_num, encode_codec_size,
encode_frame_size);
xTaskCreate(&run_codec2, "codec2_task", 30000, NULL, 5, &codec2HandlerTask);
} else {
@@ -148,7 +147,7 @@ int32_t AudioModule::runOnce()
esp_err_t res;
if (firstTime) {
// Set up I2S Processor configuration. This will produce 16bit samples at 8 kHz instead of 12 from the ADC
- LOG_INFO("Initializing I2S SD: %d DIN: %d WS: %d SCK: %d\n", moduleConfig.audio.i2s_sd, moduleConfig.audio.i2s_din,
+ LOG_INFO("Init I2S SD: %d DIN: %d WS: %d SCK: %d", moduleConfig.audio.i2s_sd, moduleConfig.audio.i2s_din,
moduleConfig.audio.i2s_ws, moduleConfig.audio.i2s_sck);
i2s_config_t i2s_config = {.mode = (i2s_mode_t)(I2S_MODE_MASTER | (moduleConfig.audio.i2s_sd ? I2S_MODE_RX : 0) |
(moduleConfig.audio.i2s_din ? I2S_MODE_TX : 0)),
@@ -164,7 +163,7 @@ int32_t AudioModule::runOnce()
.fixed_mclk = 0};
res = i2s_driver_install(I2S_PORT, &i2s_config, 0, NULL);
if (res != ESP_OK) {
- LOG_ERROR("Failed to install I2S driver: %d\n", res);
+ LOG_ERROR("Failed to install I2S driver: %d", res);
}
const i2s_pin_config_t pin_config = {
@@ -174,18 +173,18 @@ int32_t AudioModule::runOnce()
.data_in_num = moduleConfig.audio.i2s_sd ? moduleConfig.audio.i2s_sd : I2S_PIN_NO_CHANGE};
res = i2s_set_pin(I2S_PORT, &pin_config);
if (res != ESP_OK) {
- LOG_ERROR("Failed to set I2S pin config: %d\n", res);
+ LOG_ERROR("Failed to set I2S pin config: %d", res);
}
res = i2s_start(I2S_PORT);
if (res != ESP_OK) {
- LOG_ERROR("Failed to start I2S: %d\n", res);
+ LOG_ERROR("Failed to start I2S: %d", res);
}
radio_state = RadioState::rx;
// Configure PTT input
- LOG_INFO("Initializing PTT on Pin %u\n", moduleConfig.audio.ptt_pin ? moduleConfig.audio.ptt_pin : PTT_PIN);
+ LOG_INFO("Init PTT on Pin %u", moduleConfig.audio.ptt_pin ? moduleConfig.audio.ptt_pin : PTT_PIN);
pinMode(moduleConfig.audio.ptt_pin ? moduleConfig.audio.ptt_pin : PTT_PIN, INPUT);
firstTime = false;
@@ -194,17 +193,17 @@ int32_t AudioModule::runOnce()
// Check if PTT is pressed. TODO hook that into Onebutton/Interrupt drive.
if (digitalRead(moduleConfig.audio.ptt_pin ? moduleConfig.audio.ptt_pin : PTT_PIN) == HIGH) {
if (radio_state == RadioState::rx) {
- LOG_INFO("PTT pressed, switching to TX\n");
+ LOG_INFO("PTT pressed, switching to TX");
radio_state = RadioState::tx;
e.action = UIFrameEvent::Action::REGENERATE_FRAMESET; // We want to change the list of frames shown on-screen
this->notifyObservers(&e);
}
} else {
if (radio_state == RadioState::tx) {
- LOG_INFO("PTT released, switching to RX\n");
+ LOG_INFO("PTT released, switching to RX");
if (tx_encode_frame_index > sizeof(tx_header)) {
// Send the incomplete frame
- LOG_INFO("Sending %d codec2 bytes (incomplete)\n", tx_encode_frame_index);
+ LOG_INFO("Send %d codec2 bytes (incomplete)", tx_encode_frame_index);
sendPayload();
}
tx_encode_frame_index = sizeof(tx_header);
diff --git a/src/modules/esp32/PaxcounterModule.cpp b/src/modules/esp32/PaxcounterModule.cpp
index 71810df07..b27586771 100644
--- a/src/modules/esp32/PaxcounterModule.cpp
+++ b/src/modules/esp32/PaxcounterModule.cpp
@@ -15,14 +15,14 @@ PaxcounterModule *paxcounterModule;
void PaxcounterModule::handlePaxCounterReportRequest()
{
// The libpax library already updated our data structure, just before invoking this callback.
- LOG_INFO("PaxcounterModule: libpax reported new data: wifi=%d; ble=%d; uptime=%lu\n",
+ LOG_INFO("PaxcounterModule: libpax reported new data: wifi=%d; ble=%d; uptime=%lu",
paxcounterModule->count_from_libpax.wifi_count, paxcounterModule->count_from_libpax.ble_count, millis() / 1000);
paxcounterModule->reportedDataSent = false;
paxcounterModule->setIntervalFromNow(0);
}
PaxcounterModule::PaxcounterModule()
- : concurrency::OSThread("PaxcounterModule"),
+ : concurrency::OSThread("Paxcounter"),
ProtobufModule("paxcounter", meshtastic_PortNum_PAXCOUNTER_APP, &meshtastic_Paxcount_msg)
{
}
@@ -39,7 +39,7 @@ bool PaxcounterModule::sendInfo(NodeNum dest)
if (paxcounterModule->reportedDataSent)
return false;
- LOG_INFO("PaxcounterModule: sending pax info wifi=%d; ble=%d; uptime=%lu\n", count_from_libpax.wifi_count,
+ LOG_INFO("PaxcounterModule: send pax info wifi=%d; ble=%d; uptime=%lu", count_from_libpax.wifi_count,
count_from_libpax.ble_count, millis() / 1000);
meshtastic_Paxcount pl = meshtastic_Paxcount_init_default;
@@ -78,7 +78,7 @@ int32_t PaxcounterModule::runOnce()
if (isActive()) {
if (firstTime) {
firstTime = false;
- LOG_DEBUG("Paxcounter starting up with interval of %d seconds\n",
+ LOG_DEBUG("Paxcounter starting up with interval of %d seconds",
Default::getConfiguredOrDefault(moduleConfig.paxcounter.paxcounter_update_interval,
default_telemetry_broadcast_interval_secs));
struct libpax_config_t configuration;
@@ -95,7 +95,9 @@ int32_t PaxcounterModule::runOnce()
// internal processing initialization
libpax_counter_init(handlePaxCounterReportRequest, &count_from_libpax,
- moduleConfig.paxcounter.paxcounter_update_interval, 0);
+ Default::getConfiguredOrDefault(moduleConfig.paxcounter.paxcounter_update_interval,
+ default_telemetry_broadcast_interval_secs),
+ 0);
libpax_counter_start();
} else {
sendInfo(NODENUM_BROADCAST);
diff --git a/src/motion/AccelerometerThread.h b/src/motion/AccelerometerThread.h
index f9cbb49a1..95f09910f 100755
--- a/src/motion/AccelerometerThread.h
+++ b/src/motion/AccelerometerThread.h
@@ -7,14 +7,21 @@
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C
#include "../concurrency/OSThread.h"
+#ifdef HAS_BMA423
#include "BMA423Sensor.h"
+#endif
#include "BMX160Sensor.h"
#include "ICM20948Sensor.h"
#include "LIS3DHSensor.h"
#include "LSM6DS3Sensor.h"
#include "MPU6050Sensor.h"
#include "MotionSensor.h"
+#ifdef HAS_QMA6100P
+#include "QMA6100PSensor.h"
+#endif
+#ifdef HAS_STK8XXX
#include "STK8XXXSensor.h"
+#endif
extern ScanI2C::DeviceAddress accelerometer_found;
@@ -25,7 +32,7 @@ class AccelerometerThread : public concurrency::OSThread
bool isInitialised = false;
public:
- explicit AccelerometerThread(ScanI2C::FoundDevice foundDevice) : OSThread("AccelerometerThread")
+ explicit AccelerometerThread(ScanI2C::FoundDevice foundDevice) : OSThread("Accelerometer")
{
device = foundDevice;
init();
@@ -62,23 +69,25 @@ class AccelerometerThread : public concurrency::OSThread
return;
if (device.address.port == ScanI2C::I2CPort::NO_I2C || device.address.address == 0 || device.type == ScanI2C::NONE) {
- LOG_DEBUG("AccelerometerThread disabling due to no sensors found\n");
+ LOG_DEBUG("AccelerometerThread Disable due to no sensors found");
disable();
return;
}
#ifndef RAK_4631
if (!config.display.wake_on_tap_or_motion && !config.device.double_tap_as_button_press) {
- LOG_DEBUG("AccelerometerThread disabling due to no interested configurations\n");
+ LOG_DEBUG("AccelerometerThread Disable due to no interested configurations");
disable();
return;
}
#endif
switch (device.type) {
+#ifdef HAS_BMA423
case ScanI2C::DeviceType::BMA423:
sensor = new BMA423Sensor(device);
break;
+#endif
case ScanI2C::DeviceType::MPU6050:
sensor = new MPU6050Sensor(device);
break;
@@ -91,12 +100,19 @@ class AccelerometerThread : public concurrency::OSThread
case ScanI2C::DeviceType::LSM6DS3:
sensor = new LSM6DS3Sensor(device);
break;
+#ifdef HAS_STK8XXX
case ScanI2C::DeviceType::STK8BAXX:
sensor = new STK8XXXSensor(device);
break;
+#endif
case ScanI2C::DeviceType::ICM20948:
sensor = new ICM20948Sensor(device);
break;
+#ifdef HAS_QMA6100P
+ case ScanI2C::DeviceType::QMA6100P:
+ sensor = new QMA6100PSensor(device);
+ break;
+#endif
default:
disable();
return;
@@ -106,11 +122,11 @@ class AccelerometerThread : public concurrency::OSThread
if (!isInitialised) {
clean();
}
- LOG_DEBUG("AccelerometerThread::init %s\n", isInitialised ? "ok" : "failed");
+ LOG_DEBUG("AccelerometerThread::init %s", isInitialised ? "ok" : "failed");
}
// Copy constructor (not implemented / included to avoid cppcheck warnings)
- AccelerometerThread(const AccelerometerThread &other) : OSThread::OSThread("AccelerometerThread") { this->copy(other); }
+ AccelerometerThread(const AccelerometerThread &other) : OSThread::OSThread("Accelerometer") { this->copy(other); }
// Destructor (included to avoid cppcheck warnings)
virtual ~AccelerometerThread() { clean(); }
diff --git a/src/motion/BMA423Sensor.cpp b/src/motion/BMA423Sensor.cpp
index ec07b7c40..d7058bab0 100755
--- a/src/motion/BMA423Sensor.cpp
+++ b/src/motion/BMA423Sensor.cpp
@@ -1,6 +1,6 @@
#include "BMA423Sensor.h"
-#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C
+#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C && defined(HAS_BMA423)
using namespace MotionSensorI2C;
@@ -41,10 +41,10 @@ bool BMA423Sensor::init()
// It corresponds to isDoubleClick interrupt
sensor.enableWakeupIRQ();
- LOG_DEBUG("BMA423Sensor::init ok\n");
+ LOG_DEBUG("BMA423 init ok");
return true;
}
- LOG_DEBUG("BMA423Sensor::init failed\n");
+ LOG_DEBUG("BMA423 init failed");
return false;
}
diff --git a/src/motion/BMA423Sensor.h b/src/motion/BMA423Sensor.h
index 0bc0ddf8c..455315aa9 100755
--- a/src/motion/BMA423Sensor.h
+++ b/src/motion/BMA423Sensor.h
@@ -4,7 +4,7 @@
#include "MotionSensor.h"
-#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C
+#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C && defined(HAS_BMA423)
#include
#include
diff --git a/src/motion/BMX160Sensor.cpp b/src/motion/BMX160Sensor.cpp
index 3f68a4a25..6562a651c 100755
--- a/src/motion/BMX160Sensor.cpp
+++ b/src/motion/BMX160Sensor.cpp
@@ -16,10 +16,10 @@ bool BMX160Sensor::init()
if (sensor.begin()) {
// set output data rate
sensor.ODR_Config(BMX160_ACCEL_ODR_100HZ, BMX160_GYRO_ODR_100HZ);
- LOG_DEBUG("BMX160Sensor::init ok\n");
+ LOG_DEBUG("BMX160 init ok");
return true;
}
- LOG_DEBUG("BMX160Sensor::init failed\n");
+ LOG_DEBUG("BMX160 init failed");
return false;
}
diff --git a/src/motion/ICM20948Sensor.cpp b/src/motion/ICM20948Sensor.cpp
index d16968e06..338a4fc5f 100755
--- a/src/motion/ICM20948Sensor.cpp
+++ b/src/motion/ICM20948Sensor.cpp
@@ -44,14 +44,14 @@ int32_t ICM20948Sensor::runOnce()
// Wake on motion using polling - this is not as efficient as using hardware interrupt pin (see above)
auto status = sensor->setBank(0);
if (sensor->status != ICM_20948_Stat_Ok) {
- LOG_DEBUG("ICM20948Sensor::isWakeOnMotion failed to set bank - %s\n", sensor->statusString());
+ LOG_DEBUG("ICM20948 isWakeOnMotion failed to set bank - %s", sensor->statusString());
return MOTION_SENSOR_CHECK_INTERVAL_MS;
}
ICM_20948_INT_STATUS_t int_stat;
status = sensor->read(AGB0_REG_INT_STATUS, (uint8_t *)&int_stat, sizeof(ICM_20948_INT_STATUS_t));
if (status != ICM_20948_Stat_Ok) {
- LOG_DEBUG("ICM20948Sensor::isWakeOnMotion failed to read interrupts - %s\n", sensor->statusString());
+ LOG_DEBUG("ICM20948 isWakeOnMotion failed to read interrupts - %s", sensor->statusString());
return MOTION_SENSOR_CHECK_INTERVAL_MS;
}
@@ -99,25 +99,25 @@ bool ICM20948Singleton::init(ScanI2C::FoundDevice device)
ICM_20948_Status_e status = begin(Wire, device.address.address == ICM20948_ADDR ? 1 : 0);
#endif
if (status != ICM_20948_Stat_Ok) {
- LOG_DEBUG("ICM20948Sensor::init begin - %s\n", statusString());
+ LOG_DEBUG("ICM20948 init begin - %s", statusString());
return false;
}
// SW reset to make sure the device starts in a known state
if (swReset() != ICM_20948_Stat_Ok) {
- LOG_DEBUG("ICM20948Sensor::init reset - %s\n", statusString());
+ LOG_DEBUG("ICM20948 init reset - %s", statusString());
return false;
}
delay(200);
// Now wake the sensor up
if (sleep(false) != ICM_20948_Stat_Ok) {
- LOG_DEBUG("ICM20948Sensor::init wake - %s\n", statusString());
+ LOG_DEBUG("ICM20948 init wake - %s", statusString());
return false;
}
if (lowPower(false) != ICM_20948_Stat_Ok) {
- LOG_DEBUG("ICM20948Sensor::init high power - %s\n", statusString());
+ LOG_DEBUG("ICM20948 init high power - %s", statusString());
return false;
}
@@ -125,19 +125,19 @@ bool ICM20948Singleton::init(ScanI2C::FoundDevice device)
// Active low
cfgIntActiveLow(true);
- LOG_DEBUG("ICM20948Sensor::init set cfgIntActiveLow - %s\n", statusString());
+ LOG_DEBUG("ICM20948 init set cfgIntActiveLow - %s", statusString());
// Push-pull
cfgIntOpenDrain(false);
- LOG_DEBUG("ICM20948Sensor::init set cfgIntOpenDrain - %s\n", statusString());
+ LOG_DEBUG("ICM20948 init set cfgIntOpenDrain - %s", statusString());
// If enabled, *ANY* read will clear the INT_STATUS register.
cfgIntAnyReadToClear(true);
- LOG_DEBUG("ICM20948Sensor::init set cfgIntAnyReadToClear - %s\n", statusString());
+ LOG_DEBUG("ICM20948 init set cfgIntAnyReadToClear - %s", statusString());
// Latch the interrupt until cleared
cfgIntLatch(true);
- LOG_DEBUG("ICM20948Sensor::init set cfgIntLatch - %s\n", statusString());
+ LOG_DEBUG("ICM20948 init set cfgIntLatch - %s", statusString());
// Set up an interrupt pin with an internal pullup for active low
pinMode(ICM_20948_INT_PIN, INPUT_PULLUP);
@@ -168,13 +168,13 @@ bool ICM20948Singleton::setWakeOnMotion()
// Enable WoM Logic mode 1 = Compare the current sample with the previous sample
status = WOMLogic(true, 1);
- LOG_DEBUG("ICM20948Sensor::init set WOMLogic - %s\n", statusString());
+ LOG_DEBUG("ICM20948 init set WOMLogic - %s", statusString());
if (status != ICM_20948_Stat_Ok)
return false;
// Enable interrupts on WakeOnMotion
status = intEnableWOM(true);
- LOG_DEBUG("ICM20948Sensor::init set intEnableWOM - %s\n", statusString());
+ LOG_DEBUG("ICM20948 init set intEnableWOM - %s", statusString());
return status == ICM_20948_Stat_Ok;
// Clear any current interrupts
diff --git a/src/motion/LIS3DHSensor.cpp b/src/motion/LIS3DHSensor.cpp
index e2df60b1c..f3f5a62d1 100755
--- a/src/motion/LIS3DHSensor.cpp
+++ b/src/motion/LIS3DHSensor.cpp
@@ -1,4 +1,5 @@
#include "LIS3DHSensor.h"
+#include "NodeDB.h"
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C
@@ -10,10 +11,10 @@ bool LIS3DHSensor::init()
sensor.setRange(LIS3DH_RANGE_2_G);
// Adjust threshold, higher numbers are less sensitive
sensor.setClick(config.device.double_tap_as_button_press ? 2 : 1, MOTION_SENSOR_CHECK_INTERVAL_MS);
- LOG_DEBUG("LIS3DHSensor::init ok\n");
+ LOG_DEBUG("LIS3DH init ok");
return true;
}
- LOG_DEBUG("LIS3DHSensor::init failed\n");
+ LOG_DEBUG("LIS3DH init failed");
return false;
}
diff --git a/src/motion/LSM6DS3Sensor.cpp b/src/motion/LSM6DS3Sensor.cpp
index 64ef9a23b..2dcb4d663 100755
--- a/src/motion/LSM6DS3Sensor.cpp
+++ b/src/motion/LSM6DS3Sensor.cpp
@@ -1,4 +1,5 @@
#include "LSM6DS3Sensor.h"
+#include "NodeDB.h"
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C
@@ -11,13 +12,13 @@ bool LSM6DS3Sensor::init()
// Default threshold of 2G, less sensitive options are 4, 8 or 16G
sensor.setAccelRange(LSM6DS_ACCEL_RANGE_2_G);
- // Duration is number of occurances needed to trigger, higher threshold is less sensitive
+ // Duration is number of occurrences needed to trigger, higher threshold is less sensitive
sensor.enableWakeup(config.display.wake_on_tap_or_motion, 1, LSM6DS3_WAKE_THRESH);
- LOG_DEBUG("LSM6DS3Sensor::init ok\n");
+ LOG_DEBUG("LSM6DS3 init ok");
return true;
}
- LOG_DEBUG("LSM6DS3Sensor::init failed\n");
+ LOG_DEBUG("LSM6DS3 init failed");
return false;
}
diff --git a/src/motion/MPU6050Sensor.cpp b/src/motion/MPU6050Sensor.cpp
index 77aaca46d..c3f2d0b7c 100755
--- a/src/motion/MPU6050Sensor.cpp
+++ b/src/motion/MPU6050Sensor.cpp
@@ -13,10 +13,10 @@ bool MPU6050Sensor::init()
sensor.setMotionDetectionDuration(20);
sensor.setInterruptPinLatch(true); // Keep it latched. Will turn off when reinitialized.
sensor.setInterruptPinPolarity(true);
- LOG_DEBUG("MPU6050Sensor::init ok\n");
+ LOG_DEBUG("MPU6050 init ok");
return true;
}
- LOG_DEBUG("MPU6050Sensor::init failed\n");
+ LOG_DEBUG("MPU6050 init failed");
return false;
}
diff --git a/src/motion/MotionSensor.cpp b/src/motion/MotionSensor.cpp
index f1c0ba85e..242e3709f 100755
--- a/src/motion/MotionSensor.cpp
+++ b/src/motion/MotionSensor.cpp
@@ -10,8 +10,8 @@ MotionSensor::MotionSensor(ScanI2C::FoundDevice foundDevice)
device.address.address = foundDevice.address.address;
device.address.port = foundDevice.address.port;
device.type = foundDevice.type;
- LOG_DEBUG("MotionSensor::MotionSensor port: %s address: 0x%x type: %d\n",
- devicePort() == ScanI2C::I2CPort::WIRE1 ? "Wire1" : "Wire", (uint8_t)deviceAddress(), deviceType());
+ LOG_DEBUG("Motion MotionSensor port: %s address: 0x%x type: %d", devicePort() == ScanI2C::I2CPort::WIRE1 ? "Wire1" : "Wire",
+ (uint8_t)deviceAddress(), deviceType());
}
ScanI2C::DeviceType MotionSensor::deviceType()
@@ -57,14 +57,14 @@ void MotionSensor::drawFrameCalibration(OLEDDisplay *display, OLEDDisplayUiState
void MotionSensor::wakeScreen()
{
if (powerFSM.getState() == &stateDARK) {
- LOG_DEBUG("MotionSensor::wakeScreen detected\n");
+ LOG_DEBUG("Motion wakeScreen detected");
powerFSM.trigger(EVENT_INPUT);
}
}
void MotionSensor::buttonPress()
{
- LOG_DEBUG("MotionSensor::buttonPress detected\n");
+ LOG_DEBUG("Motion buttonPress detected");
powerFSM.trigger(EVENT_PRESS);
}
diff --git a/src/motion/MotionSensor.h b/src/motion/MotionSensor.h
index 4da23cc70..78eec54ce 100755
--- a/src/motion/MotionSensor.h
+++ b/src/motion/MotionSensor.h
@@ -14,6 +14,7 @@
#include "../graphics/Screen.h"
#include "../graphics/ScreenFonts.h"
#include "../power.h"
+#include "Wire.h"
// Base class for motion processing
class MotionSensor
diff --git a/src/motion/QMA6100PSensor.cpp b/src/motion/QMA6100PSensor.cpp
new file mode 100644
index 000000000..4c5bc14d2
--- /dev/null
+++ b/src/motion/QMA6100PSensor.cpp
@@ -0,0 +1,183 @@
+#include "QMA6100PSensor.h"
+
+#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C && defined(HAS_QMA6100P)
+
+// Flag when an interrupt has been detected
+volatile static bool QMA6100P_IRQ = false;
+
+// Interrupt service routine
+void QMA6100PSetInterrupt()
+{
+ QMA6100P_IRQ = true;
+}
+
+QMA6100PSensor::QMA6100PSensor(ScanI2C::FoundDevice foundDevice) : MotionSensor::MotionSensor(foundDevice) {}
+
+bool QMA6100PSensor::init()
+{
+ // Initialise the sensor
+ sensor = QMA6100PSingleton::GetInstance();
+ if (!sensor->init(device))
+ return false;
+
+ // Enable simple Wake on Motion
+ return sensor->setWakeOnMotion();
+}
+
+#ifdef QMA_6100P_INT_PIN
+
+int32_t QMA6100PSensor::runOnce()
+{
+ // Wake on motion using hardware interrupts - this is the most efficient way to check for motion
+ if (QMA6100P_IRQ) {
+ QMA6100P_IRQ = false;
+ wakeScreen();
+ }
+ return MOTION_SENSOR_CHECK_INTERVAL_MS;
+}
+
+#else
+
+int32_t QMA6100PSensor::runOnce()
+{
+ // Wake on motion using polling - this is not as efficient as using hardware interrupt pin (see above)
+
+ uint8_t tempVal;
+ if (!sensor->readRegisterRegion(SFE_QMA6100P_INT_ST0, &tempVal, 1)) {
+ LOG_DEBUG("QMA6100PS isWakeOnMotion failed to read interrupts");
+ return MOTION_SENSOR_CHECK_INTERVAL_MS;
+ }
+
+ if ((tempVal & 7) != 0) {
+ // Wake up!
+ wakeScreen();
+ }
+ return MOTION_SENSOR_CHECK_INTERVAL_MS;
+}
+
+#endif
+
+// ----------------------------------------------------------------------
+// QMA6100PSingleton
+// ----------------------------------------------------------------------
+
+// Get a singleton wrapper for an Sparkfun QMA_6100P_I2C
+QMA6100PSingleton *QMA6100PSingleton::GetInstance()
+{
+ if (pinstance == nullptr) {
+ pinstance = new QMA6100PSingleton();
+ }
+ return pinstance;
+}
+
+QMA6100PSingleton::QMA6100PSingleton() {}
+
+QMA6100PSingleton::~QMA6100PSingleton() {}
+
+QMA6100PSingleton *QMA6100PSingleton::pinstance{nullptr};
+
+// Initialise the QMA6100P Sensor
+bool QMA6100PSingleton::init(ScanI2C::FoundDevice device)
+{
+
+// startup
+#ifdef Wire1
+ bool status = begin(device.address.address, device.address.port == ScanI2C::I2CPort::WIRE1 ? &Wire1 : &Wire);
+#else
+ // check chip id
+ bool status = begin(device.address.address, &Wire);
+#endif
+ if (status != true) {
+ LOG_WARN("QMA6100P init begin failed\n");
+ return false;
+ }
+ delay(20);
+ // SW reset to make sure the device starts in a known state
+ if (softwareReset() != true) {
+ LOG_WARN("QMA6100P init reset failed\n");
+ return false;
+ }
+ delay(20);
+ // Set range
+ if (!setRange(QMA_6100P_MPU_ACCEL_SCALE)) {
+ LOG_WARN("QMA6100P init range failed");
+ return false;
+ }
+ // set active mode
+ if (!enableAccel()) {
+ LOG_WARN("ERROR QMA6100P active mode set failed");
+ }
+ // set calibrateoffsets
+ if (!calibrateOffsets()) {
+ LOG_WARN("ERROR QMA6100P calibration failed");
+ }
+#ifdef QMA_6100P_INT_PIN
+
+ // Active low & Open Drain
+ uint8_t tempVal;
+ if (!readRegisterRegion(SFE_QMA6100P_INTPINT_CONF, &tempVal, 1)) {
+ LOG_WARN("QMA6100P init failed to read interrupt pin config");
+ return false;
+ }
+
+ tempVal |= 0b00000010; // Active low & Open Drain
+
+ if (!writeRegisterByte(SFE_QMA6100P_INTPINT_CONF, tempVal)) {
+ LOG_WARN("QMA6100P init failed to write interrupt pin config");
+ return false;
+ }
+
+ // Latch until cleared, all reads clear the latch
+ if (!readRegisterRegion(SFE_QMA6100P_INT_CFG, &tempVal, 1)) {
+ LOG_WARN("QMA6100P init failed to read interrupt config");
+ return false;
+ }
+
+ tempVal |= 0b10000001; // Latch until cleared, INT_RD_CLR1
+
+ if (!writeRegisterByte(SFE_QMA6100P_INT_CFG, tempVal)) {
+ LOG_WARN("QMA6100P init failed to write interrupt config");
+ return false;
+ }
+ // Set up an interrupt pin with an internal pullup for active low
+ pinMode(QMA_6100P_INT_PIN, INPUT_PULLUP);
+
+ // Set up an interrupt service routine
+ attachInterrupt(QMA_6100P_INT_PIN, QMA6100PSetInterrupt, FALLING);
+
+#endif
+ return true;
+}
+
+bool QMA6100PSingleton::setWakeOnMotion()
+{
+ // Enable 'Any Motion' interrupt
+ if (!writeRegisterByte(SFE_QMA6100P_INT_EN2, 0b00000111)) {
+ LOG_WARN("QMA6100P :setWakeOnMotion failed to write interrupt enable");
+ return false;
+ }
+
+ // Set 'Significant Motion' interrupt map to INT1
+ uint8_t tempVal;
+
+ if (!readRegisterRegion(SFE_QMA6100P_INT_MAP1, &tempVal, 1)) {
+ LOG_WARN("QMA6100P setWakeOnMotion failed to read interrupt map");
+ return false;
+ }
+
+ sfe_qma6100p_int_map1_bitfield_t int_map1;
+ int_map1.all = tempVal;
+ int_map1.bits.int1_any_mot = 1; // any motion interrupt to INT1
+ tempVal = int_map1.all;
+
+ if (!writeRegisterByte(SFE_QMA6100P_INT_MAP1, tempVal)) {
+ LOG_WARN("QMA6100P setWakeOnMotion failed to write interrupt map");
+ return false;
+ }
+
+ // Clear any current interrupts
+ QMA6100P_IRQ = false;
+ return true;
+}
+
+#endif
\ No newline at end of file
diff --git a/src/motion/QMA6100PSensor.h b/src/motion/QMA6100PSensor.h
new file mode 100644
index 000000000..7ba00149c
--- /dev/null
+++ b/src/motion/QMA6100PSensor.h
@@ -0,0 +1,63 @@
+#pragma once
+#ifndef _QMA_6100P_SENSOR_H_
+#define _QMA_6100P_SENSOR_H_
+
+#include "MotionSensor.h"
+
+#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C && defined(HAS_QMA6100P)
+
+#include
+
+// Set the default accelerometer scale - gpm2, gpm4, gpm8, gpm16
+#ifndef QMA_6100P_MPU_ACCEL_SCALE
+#define QMA_6100P_MPU_ACCEL_SCALE SFE_QMA6100P_RANGE32G
+#endif
+
+// The I2C address of the Accelerometer (if found) from main.cpp
+extern ScanI2C::DeviceAddress accelerometer_found;
+
+// Singleton wrapper for the Sparkfun QMA_6100P_I2C class
+class QMA6100PSingleton : public QMA6100P
+{
+ private:
+ static QMA6100PSingleton *pinstance;
+
+ protected:
+ QMA6100PSingleton();
+ ~QMA6100PSingleton();
+
+ public:
+ // Create a singleton instance (not thread safe)
+ static QMA6100PSingleton *GetInstance();
+
+ // Singletons should not be cloneable.
+ QMA6100PSingleton(QMA6100PSingleton &other) = delete;
+
+ // Singletons should not be assignable.
+ void operator=(const QMA6100PSingleton &) = delete;
+
+ // Initialise the motion sensor singleton for normal operation
+ bool init(ScanI2C::FoundDevice device);
+
+ // Enable Wake on Motion interrupts (sensor must be initialised first)
+ bool setWakeOnMotion();
+};
+
+class QMA6100PSensor : public MotionSensor
+{
+ private:
+ QMA6100PSingleton *sensor = nullptr;
+
+ public:
+ explicit QMA6100PSensor(ScanI2C::FoundDevice foundDevice);
+
+ // Initialise the motion sensor
+ virtual bool init() override;
+
+ // Called each time our sensor gets a chance to run
+ virtual int32_t runOnce() override;
+};
+
+#endif
+
+#endif
\ No newline at end of file
diff --git a/src/motion/STK8XXXSensor.cpp b/src/motion/STK8XXXSensor.cpp
index d4d69ef99..377ee3c37 100755
--- a/src/motion/STK8XXXSensor.cpp
+++ b/src/motion/STK8XXXSensor.cpp
@@ -1,6 +1,6 @@
#include "STK8XXXSensor.h"
-#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C
+#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C && defined(HAS_STK8XXX)
STK8XXXSensor::STK8XXXSensor(ScanI2C::FoundDevice foundDevice) : MotionSensor::MotionSensor(foundDevice) {}
@@ -17,10 +17,10 @@ bool STK8XXXSensor::init()
attachInterrupt(
digitalPinToInterrupt(STK8XXX_INT), [] { STK_IRQ = true; }, RISING);
- LOG_DEBUG("STK8XXXSensor::init ok\n");
+ LOG_DEBUG("STK8XXX init ok");
return true;
}
- LOG_DEBUG("STK8XXXSensor::init failed\n");
+ LOG_DEBUG("STK8XXX init failed");
return false;
}
diff --git a/src/motion/STK8XXXSensor.h b/src/motion/STK8XXXSensor.h
index 190b916b4..cff98d87d 100755
--- a/src/motion/STK8XXXSensor.h
+++ b/src/motion/STK8XXXSensor.h
@@ -4,7 +4,7 @@
#include "MotionSensor.h"
-#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C
+#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C && defined(HAS_STK8XXX)
#ifdef STK8XXX_INT
diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp
index dd00a336f..967db04d6 100644
--- a/src/mqtt/MQTT.cpp
+++ b/src/mqtt/MQTT.cpp
@@ -35,6 +35,8 @@ Allocator &mqttPool = staticMqttPool;
// FIXME - this size calculation is super sloppy, but it will go away once we dynamically alloc meshpackets
static uint8_t bytes[meshtastic_MqttClientProxyMessage_size + 30]; // 12 for channel name and 16 for nodeid
+static bool isMqttServerAddressPrivate = false;
+
void MQTT::mqttCallback(char *topic, byte *payload, unsigned int length)
{
mqtt->onReceive(topic, payload, length);
@@ -72,7 +74,7 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length)
// this is a valid envelope
if (json["type"]->AsString().compare("sendtext") == 0 && json["payload"]->IsString()) {
std::string jsonPayloadStr = json["payload"]->AsString();
- LOG_INFO("JSON payload %s, length %u\n", jsonPayloadStr.c_str(), jsonPayloadStr.length());
+ LOG_INFO("JSON payload %s, length %u", jsonPayloadStr.c_str(), jsonPayloadStr.length());
// construct protobuf data packet using TEXT_MESSAGE, send it to the mesh
meshtastic_MeshPacket *p = router->allocForSending();
@@ -89,7 +91,7 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length)
p->decoded.payload.size = jsonPayloadStr.length();
service->sendToMesh(p, RX_SRC_LOCAL);
} else {
- LOG_WARN("Received MQTT json payload too long, dropping\n");
+ LOG_WARN("Received MQTT json payload too long, drop");
}
} else if (json["type"]->AsString().compare("sendposition") == 0 && json["payload"]->IsObject()) {
// invent the "sendposition" type for a valid envelope
@@ -120,29 +122,29 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length)
&meshtastic_Position_msg, &pos); // make the Data protobuf from position
service->sendToMesh(p, RX_SRC_LOCAL);
} else {
- LOG_DEBUG("JSON Ignoring downlink message with unsupported type.\n");
+ LOG_DEBUG("JSON ignore downlink message with unsupported type");
}
} else {
- LOG_ERROR("JSON Received payload on MQTT but not a valid envelope.\n");
+ LOG_ERROR("JSON received payload on MQTT but not a valid envelope");
}
} else {
- LOG_WARN("JSON downlink received on channel not called 'mqtt' or without downlink enabled.\n");
+ LOG_WARN("JSON downlink received on channel not called 'mqtt' or without downlink enabled");
}
} else {
// no json, this is an invalid payload
- LOG_ERROR("JSON Received payload on MQTT but not a valid JSON\n");
+ LOG_ERROR("JSON received payload on MQTT but not a valid JSON");
}
delete json_value;
} else {
if (length == 0) {
- LOG_WARN("Empty MQTT payload received, topic %s!\n", topic);
+ LOG_WARN("Empty MQTT payload received, topic %s!", topic);
return;
} else if (!pb_decode_from_bytes(payload, length, &meshtastic_ServiceEnvelope_msg, &e)) {
- LOG_ERROR("Invalid MQTT service envelope, topic %s, len %u!\n", topic, length);
+ LOG_ERROR("Invalid MQTT service envelope, topic %s, len %u!", topic, length);
return;
} else {
if (e.channel_id == NULL || e.gateway_id == NULL) {
- LOG_ERROR("Invalid MQTT service envelope, topic %s, len %u!\n", topic, length);
+ LOG_ERROR("Invalid MQTT service envelope, topic %s, len %u!", topic, length);
return;
}
meshtastic_Channel ch = channels.getByName(e.channel_id);
@@ -153,29 +155,38 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length)
if (e.packet && isFromUs(e.packet))
routingModule->sendAckNak(meshtastic_Routing_Error_NONE, getFrom(e.packet), e.packet->id, ch.index);
else
- LOG_INFO("Ignoring downlink message we originally sent.\n");
+ LOG_INFO("Ignore downlink message we originally sent");
} else {
// Find channel by channel_id and check downlink_enabled
if ((strcmp(e.channel_id, "PKI") == 0 && e.packet) ||
(strcmp(e.channel_id, channels.getGlobalId(ch.index)) == 0 && e.packet && ch.settings.downlink_enabled)) {
- LOG_INFO("Received MQTT topic %s, len=%u\n", topic, length);
+ LOG_INFO("Received MQTT topic %s, len=%u", topic, length);
meshtastic_MeshPacket *p = packetPool.allocCopy(*e.packet);
p->via_mqtt = true; // Mark that the packet was received via MQTT
if (isFromUs(p)) {
- LOG_INFO("Ignoring downlink message we originally sent.\n");
+ LOG_INFO("Ignore downlink message we originally sent");
packetPool.release(p);
+ free(e.channel_id);
+ free(e.gateway_id);
+ free(e.packet);
return;
}
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
if (moduleConfig.mqtt.encryption_enabled) {
- LOG_INFO("Ignoring decoded message on MQTT, encryption is enabled.\n");
+ LOG_INFO("Ignore decoded message on MQTT, encryption is enabled");
packetPool.release(p);
+ free(e.channel_id);
+ free(e.gateway_id);
+ free(e.packet);
return;
}
if (p->decoded.portnum == meshtastic_PortNum_ADMIN_APP) {
- LOG_INFO("Ignoring decoded admin packet.\n");
+ LOG_INFO("Ignore decoded admin packet");
packetPool.release(p);
+ free(e.channel_id);
+ free(e.gateway_id);
+ free(e.packet);
return;
}
p->channel = ch.index;
@@ -216,7 +227,7 @@ MQTT::MQTT() : concurrency::OSThread("mqtt"), mqttQueue(MAX_MQTT_QUEUE)
#endif
{
if (moduleConfig.mqtt.enabled) {
- LOG_DEBUG("Initializing MQTT\n");
+ LOG_DEBUG("Init MQTT");
assert(!mqtt);
mqtt = this;
@@ -238,13 +249,18 @@ MQTT::MQTT() : concurrency::OSThread("mqtt"), mqttQueue(MAX_MQTT_QUEUE)
moduleConfig.mqtt.map_report_settings.publish_interval_secs, default_map_publish_interval_secs);
}
+ isMqttServerAddressPrivate = isPrivateIpAddress(moduleConfig.mqtt.address);
+ if (isMqttServerAddressPrivate) {
+ LOG_INFO("MQTT server on a private IP");
+ }
+
#if HAS_NETWORKING
if (!moduleConfig.mqtt.proxy_to_client_enabled)
pubSub.setCallback(mqttCallback);
#endif
if (moduleConfig.mqtt.proxy_to_client_enabled) {
- LOG_INFO("MQTT configured to use client proxy...\n");
+ LOG_INFO("MQTT configured to use client proxy");
enabled = true;
runASAP = true;
reconnectCount = 0;
@@ -308,7 +324,7 @@ void MQTT::reconnect()
{
if (wantsLink()) {
if (moduleConfig.mqtt.proxy_to_client_enabled) {
- LOG_INFO("MQTT connecting via client proxy instead...\n");
+ LOG_INFO("MQTT connect via client proxy instead");
enabled = true;
runASAP = true;
reconnectCount = 0;
@@ -329,7 +345,7 @@ void MQTT::reconnect()
mqttPassword = moduleConfig.mqtt.password;
}
#if HAS_WIFI && !defined(ARCH_PORTDUINO)
-#if !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(RPI_PICO)
+#if !defined(CONFIG_IDF_TARGET_ESP32C6)
if (moduleConfig.mqtt.tls_enabled) {
// change default for encrypted to 8883
try {
@@ -337,12 +353,12 @@ void MQTT::reconnect()
wifiSecureClient.setInsecure();
pubSub.setClient(wifiSecureClient);
- LOG_INFO("Using TLS-encrypted session\n");
+ LOG_INFO("Use TLS-encrypted session");
} catch (const std::exception &e) {
- LOG_ERROR("MQTT ERROR: %s\n", e.what());
+ LOG_ERROR("MQTT ERROR: %s", e.what());
}
} else {
- LOG_INFO("Using non-TLS-encrypted session\n");
+ LOG_INFO("Use non-TLS-encrypted session");
pubSub.setClient(mqttClient);
}
#else
@@ -363,12 +379,12 @@ void MQTT::reconnect()
pubSub.setServer(serverAddr, serverPort);
pubSub.setBufferSize(512);
- LOG_INFO("Attempting to connect directly to MQTT server %s, port: %d, username: %s, password: %s\n", serverAddr,
- serverPort, mqttUsername, mqttPassword);
+ LOG_INFO("Connect directly to MQTT server %s, port: %d, username: %s, password: %s", serverAddr, serverPort, mqttUsername,
+ mqttPassword);
bool connected = pubSub.connect(owner.id, mqttUsername, mqttPassword);
if (connected) {
- LOG_INFO("MQTT connected\n");
+ LOG_INFO("MQTT connected");
enabled = true; // Start running background process again
runASAP = true;
reconnectCount = 0;
@@ -378,7 +394,7 @@ void MQTT::reconnect()
} else {
#if HAS_WIFI && !defined(ARCH_PORTDUINO)
reconnectCount++;
- LOG_ERROR("Failed to contact MQTT server directly (%d/%d)...\n", reconnectCount, reconnectMax);
+ LOG_ERROR("Failed to contact MQTT server directly (%d/%d)", reconnectCount, reconnectMax);
if (reconnectCount >= reconnectMax) {
needReconnect = true;
wifiReconnect->setIntervalFromNow(0);
@@ -400,13 +416,13 @@ void MQTT::sendSubscriptions()
if (ch.settings.downlink_enabled) {
hasDownlink = true;
std::string topic = cryptTopic + channels.getGlobalId(i) + "/+";
- LOG_INFO("Subscribing to %s\n", topic.c_str());
+ LOG_INFO("Subscribe to %s", topic.c_str());
pubSub.subscribe(topic.c_str(), 1); // FIXME, is QOS 1 right?
#if !defined(ARCH_NRF52) || \
defined(NRF52_USE_JSON) // JSON is not supported on nRF52, see issue #2804 ### Fixed by using ArduinoJSON ###
if (moduleConfig.mqtt.json_enabled == true) {
std::string topicDecoded = jsonTopic + channels.getGlobalId(i) + "/+";
- LOG_INFO("Subscribing to %s\n", topicDecoded.c_str());
+ LOG_INFO("Subscribe to %s", topicDecoded.c_str());
pubSub.subscribe(topicDecoded.c_str(), 1); // FIXME, is QOS 1 right?
}
#endif // ARCH_NRF52 NRF52_USE_JSON
@@ -415,7 +431,7 @@ void MQTT::sendSubscriptions()
#if !MESHTASTIC_EXCLUDE_PKI
if (hasDownlink) {
std::string topic = cryptTopic + "PKI/+";
- LOG_INFO("Subscribing to %s\n", topic.c_str());
+ LOG_INFO("Subscribe to %s", topic.c_str());
pubSub.subscribe(topic.c_str(), 1);
}
#endif
@@ -471,7 +487,7 @@ int32_t MQTT::runOnce()
} else {
// we are connected to server, check often for new requests on the TCP port
if (!wantConnection) {
- LOG_INFO("MQTT link not needed, dropping\n");
+ LOG_INFO("MQTT link not needed, drop");
pubSub.disconnect();
}
@@ -489,7 +505,7 @@ void MQTT::publishNodeInfo()
void MQTT::publishQueuedMessages()
{
if (!mqttQueue.isEmpty()) {
- LOG_DEBUG("Publishing enqueued MQTT message\n");
+ LOG_DEBUG("Publish enqueued MQTT message");
meshtastic_ServiceEnvelope *env = mqttQueue.dequeuePtr(0);
size_t numBytes = pb_encode_to_bytes(bytes, sizeof(bytes), &meshtastic_ServiceEnvelope_msg, env);
std::string topic;
@@ -498,7 +514,7 @@ void MQTT::publishQueuedMessages()
} else {
topic = cryptTopic + env->channel_id + "/" + owner.id;
}
- LOG_INFO("publish %s, %u bytes from queue\n", topic.c_str(), numBytes);
+ LOG_INFO("publish %s, %u bytes from queue", topic.c_str(), numBytes);
publish(topic.c_str(), bytes, numBytes, false);
@@ -514,8 +530,7 @@ void MQTT::publishQueuedMessages()
} else {
topicJson = jsonTopic + env->channel_id + "/" + owner.id;
}
- LOG_INFO("JSON publish message to %s, %u bytes: %s\n", topicJson.c_str(), jsonString.length(),
- jsonString.c_str());
+ LOG_INFO("JSON publish message to %s, %u bytes: %s", topicJson.c_str(), jsonString.length(), jsonString.c_str());
publish(topicJson.c_str(), jsonString.c_str(), false);
}
}
@@ -539,19 +554,21 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp_encrypted, const meshtastic_Me
// mp_decoded will not be decoded when it's PKI encrypted and not directed to us
if (mp_decoded.which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
+ // For uplinking other's packets, check if it's not OK to MQTT or if it's an older packet without the bitfield
+ bool dontUplink = !mp_decoded.decoded.has_bitfield ||
+ (mp_decoded.decoded.has_bitfield && !(mp_decoded.decoded.bitfield & BITFIELD_OK_TO_MQTT_MASK));
// check for the lowest bit of the data bitfield set false, and the use of one of the default keys.
- if (!isFromUs(&mp_decoded) && strcmp(moduleConfig.mqtt.address, "127.0.0.1") != 0 && mp_decoded.decoded.has_bitfield &&
- !(mp_decoded.decoded.bitfield & BITFIELD_OK_TO_MQTT_MASK) &&
+ if (!isFromUs(&mp_decoded) && !isMqttServerAddressPrivate && dontUplink &&
(ch.settings.psk.size < 2 || (ch.settings.psk.size == 16 && memcmp(ch.settings.psk.bytes, defaultpsk, 16)) ||
(ch.settings.psk.size == 32 && memcmp(ch.settings.psk.bytes, eventpsk, 32)))) {
- LOG_INFO("MQTT onSend - Not forwarding packet due to DontMqttMeBro flag\n");
+ LOG_INFO("MQTT onSend - Not forwarding packet due to DontMqttMeBro flag");
return;
}
if (strcmp(moduleConfig.mqtt.address, default_mqtt_address) == 0 &&
(mp_decoded.decoded.portnum == meshtastic_PortNum_RANGE_TEST_APP ||
mp_decoded.decoded.portnum == meshtastic_PortNum_DETECTION_SENSOR_APP)) {
- LOG_DEBUG("MQTT onSend - Ignoring range test or detection sensor message on public mqtt\n");
+ LOG_DEBUG("MQTT onSend - Ignoring range test or detection sensor message on public mqtt");
return;
}
}
@@ -565,22 +582,23 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp_encrypted, const meshtastic_Me
env->channel_id = (char *)channelId;
env->gateway_id = owner.id;
- LOG_DEBUG("MQTT onSend - Publishing ");
+ LOG_DEBUG("MQTT onSend - Publish ");
if (moduleConfig.mqtt.encryption_enabled) {
env->packet = (meshtastic_MeshPacket *)&mp_encrypted;
- LOG_DEBUG("encrypted message\n");
+ LOG_DEBUG("encrypted message");
} else if (mp_decoded.which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
env->packet = (meshtastic_MeshPacket *)&mp_decoded;
- LOG_DEBUG("portnum %i message\n", env->packet->decoded.portnum);
+ LOG_DEBUG("portnum %i message", env->packet->decoded.portnum);
} else {
- LOG_DEBUG("nothing, pkt not decrypted\n");
+ LOG_DEBUG("nothing, pkt not decrypted");
+ mqttPool.release(env);
return; // Don't upload a still-encrypted PKI packet if not encryption_enabled
}
if (moduleConfig.mqtt.proxy_to_client_enabled || this->isConnectedDirectly()) {
size_t numBytes = pb_encode_to_bytes(bytes, sizeof(bytes), &meshtastic_ServiceEnvelope_msg, env);
std::string topic = cryptTopic + channelId + "/" + owner.id;
- LOG_DEBUG("MQTT Publish %s, %u bytes\n", topic.c_str(), numBytes);
+ LOG_DEBUG("MQTT Publish %s, %u bytes", topic.c_str(), numBytes);
publish(topic.c_str(), bytes, numBytes, false);
@@ -591,16 +609,16 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp_encrypted, const meshtastic_Me
auto jsonString = MeshPacketSerializer::JsonSerialize((meshtastic_MeshPacket *)&mp_decoded);
if (jsonString.length() != 0) {
std::string topicJson = jsonTopic + channelId + "/" + owner.id;
- LOG_INFO("JSON publish message to %s, %u bytes: %s\n", topicJson.c_str(), jsonString.length(),
+ LOG_INFO("JSON publish message to %s, %u bytes: %s", topicJson.c_str(), jsonString.length(),
jsonString.c_str());
publish(topicJson.c_str(), jsonString.c_str(), false);
}
}
#endif // ARCH_NRF52 NRF52_USE_JSON
} else {
- LOG_INFO("MQTT not connected, queueing packet\n");
+ LOG_INFO("MQTT not connected, queue packet");
if (mqttQueue.numFree() == 0) {
- LOG_WARN("NOTE: MQTT queue is full, discarding oldest\n");
+ LOG_WARN("MQTT queue is full, discard oldest");
meshtastic_ServiceEnvelope *d = mqttQueue.dequeuePtr(0);
if (d)
mqttPool.release(d);
@@ -624,9 +642,9 @@ void MQTT::perhapsReportToMap()
if (map_position_precision == 0 || (localPosition.latitude_i == 0 && localPosition.longitude_i == 0)) {
last_report_to_map = millis();
if (map_position_precision == 0)
- LOG_WARN("MQTT Map reporting is enabled, but precision is 0\n");
+ LOG_WARN("MQTT Map report enabled, but precision is 0");
if (localPosition.latitude_i == 0 && localPosition.longitude_i == 0)
- LOG_WARN("MQTT Map reporting is enabled, but no position available.\n");
+ LOG_WARN("MQTT Map report enabled, but no position available");
return;
}
@@ -675,7 +693,7 @@ void MQTT::perhapsReportToMap()
size_t numBytes = pb_encode_to_bytes(bytes, sizeof(bytes), &meshtastic_ServiceEnvelope_msg, se);
- LOG_INFO("MQTT Publish map report to %s\n", mapTopic.c_str());
+ LOG_INFO("MQTT Publish map report to %s", mapTopic.c_str());
publish(mapTopic.c_str(), bytes, numBytes, false);
// Release the allocated memory for ServiceEnvelope and MeshPacket
@@ -696,4 +714,70 @@ bool MQTT::isValidJsonEnvelope(JSONObject &json)
(json["from"]->AsNumber() == nodeDB->getNodeNum()) && // only accept message if the "from" is us
(json.find("type") != json.end()) && json["type"]->IsString() && // should specify a type
(json.find("payload") != json.end()); // should have a payload
-}
\ No newline at end of file
+}
+
+bool MQTT::isPrivateIpAddress(const char address[])
+{
+ // Min. length like 10.0.0.0 (8), max like 192.168.255.255:65535 (21)
+ size_t length = strlen(address);
+ if (length < 8 || length > 21) {
+ return false;
+ }
+
+ // Ensure the address contains only digits and dots and maybe a colon.
+ // Some limited validation is done.
+ // Even if it's not a valid IP address, we will know it's not a domain.
+ bool hasColon = false;
+ int numDots = 0;
+ for (size_t i = 0; i < length; i++) {
+ if (!isdigit(address[i]) && address[i] != '.' && address[i] != ':') {
+ return false;
+ }
+
+ // Dots can't be the first character, immediately follow another dot,
+ // occur more than 3 times, or occur after a colon.
+ if (address[i] == '.') {
+ if (++numDots > 3 || i == 0 || address[i - 1] == '.' || hasColon) {
+ return false;
+ }
+ }
+ // There can only be a single colon, and it can only occur after 3 dots
+ else if (address[i] == ':') {
+ if (hasColon || numDots < 3) {
+ return false;
+ }
+
+ hasColon = true;
+ }
+ }
+
+ // Final validation for IPv4 address and port format.
+ // Note that the values of octets haven't been tested, only the address format.
+ if (numDots != 3) {
+ return false;
+ }
+
+ // Check the easy ones first.
+ if (strcmp(address, "127.0.0.1") == 0 || strncmp(address, "10.", 3) == 0 || strncmp(address, "192.168", 7) == 0 ||
+ strncmp(address, "169.254", 7) == 0) {
+ return true;
+ }
+
+ // See if it's definitely not a 172 address.
+ if (strncmp(address, "172", 3) != 0) {
+ return false;
+ }
+
+ // We know it's a 172 address, now see if the second octet is 2 digits.
+ if (address[6] != '.') {
+ return false;
+ }
+
+ // Copy the second octet into a secondary buffer we can null-terminate and parse.
+ char octet2[3];
+ strncpy(octet2, address + 4, 2);
+ octet2[2] = 0;
+
+ int octet2Num = atoi(octet2);
+ return octet2Num >= 16 && octet2Num <= 31;
+}
diff --git a/src/mqtt/MQTT.h b/src/mqtt/MQTT.h
index 83adc8fd2..7e0378238 100644
--- a/src/mqtt/MQTT.h
+++ b/src/mqtt/MQTT.h
@@ -35,7 +35,7 @@ class MQTT : private concurrency::OSThread
#if HAS_WIFI
WiFiClient mqttClient;
#if !defined(ARCH_PORTDUINO)
-#if defined(ESP_ARDUINO_VERSION_MAJOR) && ESP_ARDUINO_VERSION_MAJOR < 3
+#if (defined(ESP_ARDUINO_VERSION_MAJOR) && ESP_ARDUINO_VERSION_MAJOR < 3) || defined(RPI_PICO)
WiFiClientSecure wifiSecureClient;
#endif
#endif
@@ -120,10 +120,14 @@ class MQTT : private concurrency::OSThread
// returns true if this is a valid JSON envelope which we accept on downlink
bool isValidJsonEnvelope(JSONObject &json);
+ /// Determines if the given address is a private IPv4 address, i.e. not routable on the public internet.
+ /// These are the ranges: 127.0.0.1, 10.0.0.0-10.255.255.255, 172.16.0.0-172.31.255.255, 192.168.0.0-192.168.255.255.
+ bool isPrivateIpAddress(const char address[]);
+
/// Return 0 if sleep is okay, veto sleep if we are connected to pubsub server
// int preflightSleepCb(void *unused = NULL) { return pubSub.connected() ? 1 : 0; }
};
void mqttInit();
-extern MQTT *mqtt;
\ No newline at end of file
+extern MQTT *mqtt;
diff --git a/src/nimble/NimbleBluetooth.cpp b/src/nimble/NimbleBluetooth.cpp
index eedfe1a71..2662ef0bc 100644
--- a/src/nimble/NimbleBluetooth.cpp
+++ b/src/nimble/NimbleBluetooth.cpp
@@ -26,7 +26,7 @@ class BluetoothPhoneAPI : public PhoneAPI
{
PhoneAPI::onNowHasData(fromRadioNum);
- LOG_INFO("BLE notify fromNum\n");
+ LOG_INFO("BLE notify fromNum");
uint8_t val[4];
put_le32(val, fromRadioNum);
@@ -51,15 +51,15 @@ class NimbleBluetoothToRadioCallback : public NimBLECharacteristicCallbacks
{
virtual void onWrite(NimBLECharacteristic *pCharacteristic)
{
- LOG_INFO("To Radio onwrite\n");
+ LOG_INFO("To Radio onwrite");
auto val = pCharacteristic->getValue();
if (memcmp(lastToRadio, val.data(), val.length()) != 0) {
- LOG_DEBUG("New ToRadio packet\n");
+ LOG_DEBUG("New ToRadio packet");
memcpy(lastToRadio, val.data(), val.length());
bluetoothPhoneAPI->handleToRadio(val.data(), val.length());
} else {
- LOG_DEBUG("Dropping duplicate ToRadio packet we just saw\n");
+ LOG_DEBUG("Drop dup ToRadio packet we just saw");
}
}
};
@@ -84,11 +84,11 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
uint32_t passkey = config.bluetooth.fixed_pin;
if (config.bluetooth.mode == meshtastic_Config_BluetoothConfig_PairingMode_RANDOM_PIN) {
- LOG_INFO("Using random passkey\n");
+ LOG_INFO("Use random passkey");
// This is the passkey to be entered on peer - we pick a number >100,000 to ensure 6 digits
passkey = random(100000, 999999);
}
- LOG_INFO("*** Enter passkey %d on the peer side ***\n", passkey);
+ LOG_INFO("*** Enter passkey %d on the peer side ***", passkey);
powerFSM.trigger(EVENT_BLUETOOTH_PAIR);
#if HAS_SCREEN
@@ -125,7 +125,7 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
virtual void onAuthenticationComplete(ble_gap_conn_desc *desc)
{
- LOG_INFO("BLE authentication complete\n");
+ LOG_INFO("BLE authentication complete");
if (passkeyShowing) {
passkeyShowing = false;
@@ -135,7 +135,7 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
virtual void onDisconnect(NimBLEServer *pServer, ble_gap_conn_desc *desc)
{
- LOG_INFO("BLE disconnect\n");
+ LOG_INFO("BLE disconnect");
if (bluetoothPhoneAPI) {
bluetoothPhoneAPI->close();
@@ -151,7 +151,7 @@ void NimbleBluetooth::shutdown()
// No measurable power saving for ESP32 during light-sleep(?)
#ifndef ARCH_ESP32
// Shutdown bluetooth for minimum power draw
- LOG_INFO("Disable bluetooth\n");
+ LOG_INFO("Disable bluetooth");
NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising();
pAdvertising->reset();
pAdvertising->stop();
@@ -162,7 +162,7 @@ void NimbleBluetooth::shutdown()
void NimbleBluetooth::deinit()
{
#ifdef ARCH_ESP32
- LOG_INFO("Disable bluetooth until reboot\n");
+ LOG_INFO("Disable bluetooth until reboot");
NimBLEDevice::deinit();
#endif
}
@@ -193,7 +193,7 @@ void NimbleBluetooth::setup()
// Uncomment for testing
// NimbleBluetooth::clearBonds();
- LOG_INFO("Initialise the NimBLE bluetooth module\n");
+ LOG_INFO("Init the NimBLE bluetooth module");
NimBLEDevice::init(getDeviceName());
NimBLEDevice::setPower(ESP_PWR_LVL_P9);
@@ -279,7 +279,7 @@ void updateBatteryLevel(uint8_t level)
void NimbleBluetooth::clearBonds()
{
- LOG_INFO("Clearing bluetooth bonds!\n");
+ LOG_INFO("Clearing bluetooth bonds!");
NimBLEDevice::deleteAllBonds();
}
diff --git a/src/platform/esp32/ESP32CryptoEngine.cpp b/src/platform/esp32/ESP32CryptoEngine.cpp
index 230139036..b554a3de4 100644
--- a/src/platform/esp32/ESP32CryptoEngine.cpp
+++ b/src/platform/esp32/ESP32CryptoEngine.cpp
@@ -32,7 +32,7 @@ class ESP32CryptoEngine : public CryptoEngine
sizeof(scratch) - numBytes); // Fill rest of buffer with zero (in case cypher looks at it)
mbedtls_aes_crypt_ctr(&aes, numBytes, &nc_off, _nonce, stream_block, scratch, 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/platform/esp32/SimpleAllocator.cpp b/src/platform/esp32/SimpleAllocator.cpp
index 04ce35eb3..d482a3f1c 100644
--- a/src/platform/esp32/SimpleAllocator.cpp
+++ b/src/platform/esp32/SimpleAllocator.cpp
@@ -12,7 +12,7 @@ void *SimpleAllocator::alloc(size_t size)
assert(nextFree + size <= sizeof(bytes));
void *res = &bytes[nextFree];
nextFree += size;
- LOG_DEBUG("Total simple allocs %u\n", nextFree);
+ LOG_DEBUG("Total simple allocs %u", nextFree);
return res;
}
diff --git a/src/platform/esp32/architecture.h b/src/platform/esp32/architecture.h
index 01f416629..1a274aa28 100644
--- a/src/platform/esp32/architecture.h
+++ b/src/platform/esp32/architecture.h
@@ -104,6 +104,8 @@
#define HW_VENDOR meshtastic_HardwareModel_NANO_G1
#elif defined(M5STACK)
#define HW_VENDOR meshtastic_HardwareModel_M5STACK
+#elif defined(M5STACK_CORES3)
+#define HW_VENDOR meshtastic_HardwareModel_M5STACK_CORES3
#elif defined(STATION_G1)
#define HW_VENDOR meshtastic_HardwareModel_STATION_G1
#elif defined(DR_DEV)
@@ -168,8 +170,6 @@
#define HW_VENDOR meshtastic_HardwareModel_HELTEC_VISION_MASTER_E213
#elif defined(HELTEC_VISION_MASTER_E290)
#define HW_VENDOR meshtastic_HardwareModel_HELTEC_VISION_MASTER_E290
-#elif defined(HELTEC_MESH_NODE_T114)
-#define HW_VENDOR meshtastic_HardwareModel_HELTEC_MESH_NODE_T114
#elif defined(SENSECAP_INDICATOR)
#define HW_VENDOR meshtastic_HardwareModel_SENSECAP_INDICATOR
#elif defined(SEEED_XIAO_S3)
diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp
index f16accab6..679222af5 100644
--- a/src/platform/esp32/main-esp32.cpp
+++ b/src/platform/esp32/main-esp32.cpp
@@ -51,7 +51,11 @@ void updateBatteryLevel(uint8_t level) {}
void getMacAddr(uint8_t *dmac)
{
+#if defined(CONFIG_IDF_TARGET_ESP32C6) && defined(CONFIG_SOC_IEEE802154_SUPPORTED)
+ assert(esp_base_mac_addr_get(dmac) == ESP_OK);
+#else
assert(esp_efuse_mac_get_default(dmac) == ESP_OK);
+#endif
}
#ifdef HAS_32768HZ
@@ -76,17 +80,17 @@ void enableSlowCLK()
uint32_t cal_32k = CALIBRATE_ONE(RTC_CAL_32K_XTAL);
if (cal_32k == 0) {
- LOG_DEBUG("32K XTAL OSC has not started up\n");
+ LOG_DEBUG("32K XTAL OSC has not started up");
} else {
rtc_clk_slow_freq_set(RTC_SLOW_FREQ_32K_XTAL);
- LOG_DEBUG("Switching RTC Source to 32.768Khz succeeded, using 32K XTAL\n");
+ LOG_DEBUG("Switch RTC Source to 32.768Khz succeeded, using 32K XTAL");
CALIBRATE_ONE(RTC_CAL_RTC_MUX);
CALIBRATE_ONE(RTC_CAL_32K_XTAL);
}
CALIBRATE_ONE(RTC_CAL_RTC_MUX);
CALIBRATE_ONE(RTC_CAL_32K_XTAL);
if (rtc_clk_slow_freq_get() != RTC_SLOW_FREQ_32K_XTAL) {
- LOG_WARN("Failed to switch 32K XTAL RTC source to 32.768Khz !!! \n");
+ LOG_WARN("Failed to switch 32K XTAL RTC source to 32.768Khz !!! ");
return;
}
}
@@ -97,22 +101,22 @@ void esp32Setup()
/* We explicitly don't want to do call randomSeed,
// as that triggers the esp32 core to use a less secure pseudorandom function.
uint32_t seed = esp_random();
- LOG_DEBUG("Setting random seed %u\n", seed);
+ LOG_DEBUG("Set random seed %u", seed);
randomSeed(seed);
*/
- LOG_DEBUG("Total heap: %d\n", ESP.getHeapSize());
- LOG_DEBUG("Free heap: %d\n", ESP.getFreeHeap());
- LOG_DEBUG("Total PSRAM: %d\n", ESP.getPsramSize());
- LOG_DEBUG("Free PSRAM: %d\n", ESP.getFreePsram());
+ LOG_DEBUG("Total heap: %d", ESP.getHeapSize());
+ LOG_DEBUG("Free heap: %d", ESP.getFreeHeap());
+ LOG_DEBUG("Total PSRAM: %d", ESP.getPsramSize());
+ LOG_DEBUG("Free PSRAM: %d", ESP.getFreePsram());
nvs_stats_t nvs_stats;
auto res = nvs_get_stats(NULL, &nvs_stats);
assert(res == ESP_OK);
- LOG_DEBUG("NVS: UsedEntries %d, FreeEntries %d, AllEntries %d, NameSpaces %d\n", nvs_stats.used_entries,
- nvs_stats.free_entries, nvs_stats.total_entries, nvs_stats.namespace_count);
+ LOG_DEBUG("NVS: UsedEntries %d, FreeEntries %d, AllEntries %d, NameSpaces %d", nvs_stats.used_entries, nvs_stats.free_entries,
+ nvs_stats.total_entries, nvs_stats.namespace_count);
- LOG_DEBUG("Setup Preferences in Flash Storage\n");
+ LOG_DEBUG("Setup Preferences in Flash Storage");
// Create object to store our persistent data
Preferences preferences;
@@ -129,16 +133,16 @@ void esp32Setup()
if (hwven != HW_VENDOR)
preferences.putUInt("hwVendor", HW_VENDOR);
preferences.end();
- LOG_DEBUG("Number of Device Reboots: %d\n", rebootCounter);
+ LOG_DEBUG("Number of Device Reboots: %d", rebootCounter);
#if !MESHTASTIC_EXCLUDE_BLUETOOTH
String BLEOTA = BleOta::getOtaAppVersion();
if (BLEOTA.isEmpty()) {
- LOG_INFO("No OTA firmware available\n");
+ LOG_INFO("No OTA firmware available");
} else {
- LOG_INFO("OTA firmware version %s\n", BLEOTA.c_str());
+ LOG_INFO("OTA firmware version %s", BLEOTA.c_str());
}
#else
- LOG_INFO("No OTA firmware available\n");
+ LOG_INFO("No OTA firmware available");
#endif
// enableModemSleep();
@@ -166,26 +170,6 @@ void esp32Setup()
#endif
}
-#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);
-#endif
-
/// loop code specific to ESP32 targets
void esp32Loop()
{
@@ -263,4 +247,4 @@ void cpuDeepSleep(uint32_t msecToWake)
esp_sleep_enable_timer_wakeup(msecToWake * 1000ULL); // call expects usecs
esp_deep_sleep_start(); // TBD mA sleep current (battery)
-}
\ No newline at end of file
+}
diff --git a/src/platform/extra_variants/heltec_wireless_tracker/variant.cpp b/src/platform/extra_variants/heltec_wireless_tracker/variant.cpp
index 0a19a9c3b..12960e2d9 100644
--- a/src/platform/extra_variants/heltec_wireless_tracker/variant.cpp
+++ b/src/platform/extra_variants/heltec_wireless_tracker/variant.cpp
@@ -9,7 +9,7 @@
// Heltec tracker specific init
void lateInitVariant()
{
- // LOG_DEBUG("Heltec tracker initVariant\n");
+ // LOG_DEBUG("Heltec tracker initVariant");
#ifndef MESHTASTIC_EXCLUDE_GPS
GpioVirtPin *virtGpsEnable = gps ? gps->enablePin : new GpioVirtPin();
diff --git a/src/platform/nrf52/NRF52Bluetooth.cpp b/src/platform/nrf52/NRF52Bluetooth.cpp
index 63d9331ad..31bbc7fa9 100644
--- a/src/platform/nrf52/NRF52Bluetooth.cpp
+++ b/src/platform/nrf52/NRF52Bluetooth.cpp
@@ -39,7 +39,7 @@ class BluetoothPhoneAPI : public PhoneAPI
{
PhoneAPI::onNowHasData(fromRadioNum);
- LOG_INFO("BLE notify fromNum\n");
+ LOG_INFO("BLE notify fromNum");
fromNum.notify32(fromRadioNum);
}
@@ -60,7 +60,7 @@ void onConnect(uint16_t conn_handle)
connectionHandle = conn_handle;
char central_name[32] = {0};
connection->getPeerName(central_name, sizeof(central_name));
- LOG_INFO("BLE Connected to %s\n", central_name);
+ LOG_INFO("BLE Connected to %s", central_name);
}
/**
* Callback invoked when a connection is dropped
@@ -69,7 +69,7 @@ void onConnect(uint16_t conn_handle)
*/
void onDisconnect(uint16_t conn_handle, uint8_t reason)
{
- LOG_INFO("BLE Disconnected, reason = 0x%x\n", reason);
+ LOG_INFO("BLE Disconnected, reason = 0x%x", reason);
if (bluetoothPhoneAPI) {
bluetoothPhoneAPI->close();
}
@@ -77,7 +77,7 @@ void onDisconnect(uint16_t conn_handle, uint8_t reason)
void onCccd(uint16_t conn_hdl, BLECharacteristic *chr, uint16_t cccd_value)
{
// Display the raw request packet
- LOG_INFO("CCCD Updated: %u\n", cccd_value);
+ LOG_INFO("CCCD Updated: %u", cccd_value);
// Check the characteristic this CCCD update is associated with in case
// this handler is used for multiple CCCD records.
@@ -87,9 +87,9 @@ void onCccd(uint16_t conn_hdl, BLECharacteristic *chr, uint16_t cccd_value)
if (chr->uuid == fromNum.uuid || chr->uuid == logRadio.uuid) {
auto result = cccd_value == 2 ? chr->indicateEnabled(conn_hdl) : chr->notifyEnabled(conn_hdl);
if (result) {
- LOG_INFO("Notify/Indicate enabled\n");
+ LOG_INFO("Notify/Indicate enabled");
} else {
- LOG_INFO("Notify/Indicate disabled\n");
+ LOG_INFO("Notify/Indicate disabled");
}
}
}
@@ -137,7 +137,7 @@ void onFromRadioAuthorize(uint16_t conn_hdl, BLECharacteristic *chr, ble_gatts_e
// or make empty if the queue is empty
fromRadio.write(fromRadioBytes, numBytes);
} else {
- // LOG_INFO("Ignoring successor read\n");
+ // LOG_INFO("Ignore successor read");
}
authorizeRead(conn_hdl);
}
@@ -146,13 +146,13 @@ static uint8_t lastToRadio[MAX_TO_FROM_RADIO_SIZE];
void onToRadioWrite(uint16_t conn_hdl, BLECharacteristic *chr, uint8_t *data, uint16_t len)
{
- LOG_INFO("toRadioWriteCb data %p, len %u\n", data, len);
+ LOG_INFO("toRadioWriteCb data %p, len %u", data, len);
if (memcmp(lastToRadio, data, len) != 0) {
- LOG_DEBUG("New ToRadio packet\n");
+ LOG_DEBUG("New ToRadio packet");
memcpy(lastToRadio, data, len);
bluetoothPhoneAPI->handleToRadio(data, len);
} else {
- LOG_DEBUG("Dropping duplicate ToRadio packet we just saw\n");
+ LOG_DEBUG("Drop dup ToRadio packet we just saw");
}
}
@@ -207,11 +207,11 @@ static uint32_t configuredPasskey;
void NRF52Bluetooth::shutdown()
{
// Shutdown bluetooth for minimum power draw
- LOG_INFO("Disable NRF52 bluetooth\n");
+ LOG_INFO("Disable NRF52 bluetooth");
uint8_t connection_num = Bluefruit.connected();
if (connection_num) {
for (uint8_t i = 0; i < connection_num; i++) {
- LOG_INFO("NRF52 bluetooth disconnecting handle %d\n", i);
+ LOG_INFO("NRF52 bluetooth disconnecting handle %d", i);
Bluefruit.disconnect(i);
}
delay(100); // wait for ondisconnect;
@@ -225,7 +225,7 @@ void NRF52Bluetooth::startDisabled()
// Shutdown bluetooth for minimum power draw
Bluefruit.Advertising.stop();
Bluefruit.setTxPower(-40); // Minimum power
- LOG_INFO("Disabling NRF52 Bluetooth. (Workaround: tx power min, advertising stopped)\n");
+ LOG_INFO("Disable NRF52 Bluetooth. (Workaround: tx power min, advertise stopped)");
}
bool NRF52Bluetooth::isConnected()
{
@@ -238,7 +238,7 @@ int NRF52Bluetooth::getRssi()
void NRF52Bluetooth::setup()
{
// Initialise the Bluefruit module
- LOG_INFO("Initialize the Bluefruit nRF52 module\n");
+ LOG_INFO("Init the Bluefruit nRF52 module");
Bluefruit.autoConnLed(false);
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
Bluefruit.begin();
@@ -251,7 +251,7 @@ void NRF52Bluetooth::setup()
? config.bluetooth.fixed_pin
: random(100000, 999999);
auto pinString = std::to_string(configuredPasskey);
- LOG_INFO("Bluetooth pin set to '%i'\n", configuredPasskey);
+ LOG_INFO("Bluetooth pin set to '%i'", configuredPasskey);
Bluefruit.Security.setPIN(pinString.c_str());
Bluefruit.Security.setIOCaps(true, false, false);
Bluefruit.Security.setPairPasskeyCallback(NRF52Bluetooth::onPairingPasskey);
@@ -275,22 +275,22 @@ void NRF52Bluetooth::setup()
bledfusecure.begin(); // Install the DFU helper
#endif
// Configure and Start the Device Information Service
- LOG_INFO("Configuring the Device Information Service\n");
+ LOG_INFO("Init the Device Information Service");
bledis.setModel(optstr(HW_VERSION));
bledis.setFirmwareRev(optstr(APP_VERSION));
bledis.begin();
// Start the BLE Battery Service and set it to 100%
- LOG_INFO("Configuring the Battery Service\n");
+ LOG_INFO("Init the Battery Service");
blebas.begin();
blebas.write(0); // Unknown battery level for now
// Setup the Heart Rate Monitor service using
// BLEService and BLECharacteristic classes
- LOG_INFO("Configuring the Mesh bluetooth service\n");
+ LOG_INFO("Init the Mesh bluetooth service");
setupMeshService();
// Setup the advertising packet(s)
- LOG_INFO("Setting up the advertising payload(s)\n");
+ LOG_INFO("Set up the advertising payload(s)");
startAdv();
- LOG_INFO("Advertising\n");
+ LOG_INFO("Advertise");
}
void NRF52Bluetooth::resumeAdvertising()
{
@@ -306,7 +306,7 @@ void updateBatteryLevel(uint8_t level)
}
void NRF52Bluetooth::clearBonds()
{
- LOG_INFO("Clearing bluetooth bonds!\n");
+ LOG_INFO("Clear bluetooth bonds!");
bond_print_list(BLE_GAP_ROLE_PERIPH);
bond_print_list(BLE_GAP_ROLE_CENTRAL);
Bluefruit.Periph.clearBonds();
@@ -314,11 +314,11 @@ void NRF52Bluetooth::clearBonds()
}
void NRF52Bluetooth::onConnectionSecured(uint16_t conn_handle)
{
- LOG_INFO("BLE connection secured\n");
+ LOG_INFO("BLE connection secured");
}
bool NRF52Bluetooth::onPairingPasskey(uint16_t conn_handle, uint8_t const passkey[6], bool match_request)
{
- LOG_INFO("BLE pairing process started with passkey %.3s %.3s\n", passkey, passkey + 3);
+ LOG_INFO("BLE pair process started with passkey %.3s %.3s", passkey, passkey + 3);
powerFSM.trigger(EVENT_BLUETOOTH_PAIR);
#if !defined(MESHTASTIC_EXCLUDE_SCREEN)
screen->startAlert([](OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) -> void {
@@ -354,15 +354,15 @@ bool NRF52Bluetooth::onPairingPasskey(uint16_t conn_handle, uint8_t const passke
break;
}
}
- LOG_INFO("BLE passkey pairing: match_request=%i\n", match_request);
+ LOG_INFO("BLE passkey pair: match_request=%i", match_request);
return true;
}
void NRF52Bluetooth::onPairingCompleted(uint16_t conn_handle, uint8_t auth_status)
{
if (auth_status == BLE_GAP_SEC_STATUS_SUCCESS)
- LOG_INFO("BLE pairing success\n");
+ LOG_INFO("BLE pair success");
else
- LOG_INFO("BLE pairing failed\n");
+ LOG_INFO("BLE pair failed");
screen->endAlert();
}
diff --git a/src/platform/nrf52/architecture.h b/src/platform/nrf52/architecture.h
index b2b7b5a20..ce99244ba 100644
--- a/src/platform/nrf52/architecture.h
+++ b/src/platform/nrf52/architecture.h
@@ -47,6 +47,8 @@
#define HW_VENDOR meshtastic_HardwareModel_PPR
#elif defined(RAK2560)
#define HW_VENDOR meshtastic_HardwareModel_RAK2560
+#elif defined(WISMESH_TAP)
+#define HW_VENDOR meshtastic_HardwareModel_WISMESH_TAP
#elif defined(RAK4630)
#define HW_VENDOR meshtastic_HardwareModel_RAK4631
#elif defined(TTGO_T_ECHO)
diff --git a/src/platform/nrf52/main-nrf52.cpp b/src/platform/nrf52/main-nrf52.cpp
index f9329d875..7ca047654 100644
--- a/src/platform/nrf52/main-nrf52.cpp
+++ b/src/platform/nrf52/main-nrf52.cpp
@@ -35,7 +35,7 @@ bool loopCanSleep()
// handle standard gcc assert failures
void __attribute__((noreturn)) __assert_func(const char *file, int line, const char *func, const char *failedexpr)
{
- LOG_ERROR("assert failed %s: %d, %s, test=%s\n", file, line, func, failedexpr);
+ LOG_ERROR("assert failed %s: %d, %s, test=%s", file, line, func, failedexpr);
// debugger_break(); FIXME doesn't work, possibly not for segger
// Reboot cpu
NVIC_SystemReset();
@@ -74,7 +74,7 @@ void setBluetoothEnable(bool enable)
// For debugging use: don't use bluetooth
if (!useSoftDevice) {
if (enable)
- LOG_INFO("DISABLING NRF52 BLUETOOTH WHILE DEBUGGING\n");
+ LOG_INFO("Disable NRF52 BLUETOOTH WHILE DEBUGGING");
return;
}
@@ -97,7 +97,7 @@ void setBluetoothEnable(bool enable)
// If not yet set-up
if (!nrf52Bluetooth) {
- LOG_DEBUG("Initializing NRF52 Bluetooth\n");
+ LOG_DEBUG("Init NRF52 Bluetooth");
nrf52Bluetooth = new NRF52Bluetooth();
nrf52Bluetooth->setup();
@@ -141,7 +141,7 @@ void checkSDEvents()
break;
default:
- LOG_DEBUG("Unexpected SDevt %d\n", evt);
+ LOG_DEBUG("Unexpected SDevt %d", evt);
break;
}
}
@@ -188,7 +188,7 @@ void nrf52Setup()
uint32_t why = NRF_POWER->RESETREAS;
// per
// https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fpower.html
- LOG_DEBUG("Reset reason: 0x%x\n", why);
+ LOG_DEBUG("Reset reason: 0x%x", why);
#ifdef USE_SEMIHOSTING
nrf52InitSemiHosting();
@@ -202,7 +202,7 @@ void nrf52Setup()
#ifdef BQ25703A_ADDR
auto *bq = new BQ25713();
if (!bq->setup())
- LOG_ERROR("ERROR! Charge controller init failed\n");
+ LOG_ERROR("ERROR! Charge controller init failed");
#endif
// Init random seed
@@ -212,7 +212,7 @@ void nrf52Setup()
} seed;
nRFCrypto.begin();
nRFCrypto.Random.generate(seed.seed8, sizeof(seed.seed8));
- LOG_DEBUG("Setting random seed %u\n", seed.seed32);
+ LOG_DEBUG("Set random seed %u", seed.seed32);
randomSeed(seed.seed32);
nRFCrypto.end();
}
@@ -280,7 +280,7 @@ void cpuDeepSleep(uint32_t msecToWake)
// https://devzone.nordicsemi.com/f/nordic-q-a/48919/ram-retention-settings-with-softdevice-enabled
auto ok = sd_power_system_off();
if (ok != NRF_SUCCESS) {
- LOG_ERROR("FIXME: Ignoring soft device (EasyDMA pending?) and forcing system-off!\n");
+ LOG_ERROR("FIXME: Ignoring soft device (EasyDMA pending?) and forcing system-off!");
NRF_POWER->SYSTEMOFF = 1;
}
}
@@ -309,4 +309,4 @@ void enterDfuMode()
#else
enterUf2Dfu();
#endif
-}
\ No newline at end of file
+}
diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp
index 92bf7c86e..5d8ac0e60 100644
--- a/src/platform/portduino/PortduinoGlue.cpp
+++ b/src/platform/portduino/PortduinoGlue.cpp
@@ -11,6 +11,7 @@
#include "PortduinoGlue.h"
#include "linux/gpio/LinuxGPIOPin.h"
#include "yaml-cpp/yaml.h"
+#include
#include
#include