Merge branch 'master' into tft-gui-work

This commit is contained in:
Manuel 2024-10-20 16:02:29 +02:00 committed by GitHub
commit 171eea045f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 131 additions and 35 deletions

View File

@ -20,6 +20,7 @@ Lora:
# CS: 0 # CS: 0
# IRQ: 10 # IRQ: 10
# Busy: 11 # Busy: 11
# DIO2_AS_RF_SWITCH: true
# spidev: spidev0.1 # spidev: spidev0.1
# Module: RF95 # Adafruit RFM9x # Module: RF95 # Adafruit RFM9x
@ -177,4 +178,4 @@ Webserver:
General: General:
MaxNodes: 200 MaxNodes: 200
MaxMessageQueue: 100 MaxMessageQueue: 100

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
cp "release/meshtasticd_linux_$(uname -m)" /usr/sbin/meshtasticd cp "release/meshtasticd_linux_$(uname -m)" /usr/sbin/meshtasticd
mkdir /etc/meshtasticd mkdir -p /etc/meshtasticd
if [[ -f "/etc/meshtasticd/config.yaml" ]]; then if [[ -f "/etc/meshtasticd/config.yaml" ]]; then
cp bin/config-dist.yaml /etc/meshtasticd/config-upgrade.yaml cp bin/config-dist.yaml /etc/meshtasticd/config-upgrade.yaml
else else

@ -1 +1 @@
Subproject commit e22381a3c6bbdd428f127ed8c0aa0a37789c3907 Subproject commit 0fed5c7709d2cec043a0f6daefa86ff11de0b946

View File

@ -55,6 +55,18 @@ void playBeep()
playTones(melody, sizeof(melody) / sizeof(ToneDuration)); playTones(melody, sizeof(melody) / sizeof(ToneDuration));
} }
void playGPSEnableBeep()
{
ToneDuration melody[] = {{NOTE_C3, DURATION_1_8}, {NOTE_FS3, DURATION_1_4}, {NOTE_CS4, DURATION_1_4}};
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
}
void playGPSDisableBeep()
{
ToneDuration melody[] = {{NOTE_CS4, DURATION_1_8}, {NOTE_FS3, DURATION_1_4}, {NOTE_C3, DURATION_1_4}};
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
}
void playStartMelody() void playStartMelody()
{ {
ToneDuration melody[] = {{NOTE_FS3, DURATION_1_8}, {NOTE_AS3, DURATION_1_8}, {NOTE_CS4, DURATION_1_4}}; ToneDuration melody[] = {{NOTE_FS3, DURATION_1_8}, {NOTE_AS3, DURATION_1_8}, {NOTE_CS4, DURATION_1_4}};

View File

@ -3,3 +3,5 @@
void playBeep(); void playBeep();
void playStartMelody(); void playStartMelody();
void playShutdownMelody(); void playShutdownMelody();
void playGPSEnableBeep();
void playGPSDisableBeep();

View File

@ -7,6 +7,7 @@
#include "PowerMon.h" #include "PowerMon.h"
#include "RTC.h" #include "RTC.h"
#include "Throttle.h" #include "Throttle.h"
#include "buzz.h"
#include "meshUtils.h" #include "meshUtils.h"
#include "main.h" // pmu_found #include "main.h" // pmu_found
@ -267,6 +268,9 @@ GPS_RESPONSE GPS::getACK(uint8_t class_id, uint8_t msg_id, uint32_t waitMillis)
uint32_t startTime = millis(); uint32_t startTime = millis();
const char frame_errors[] = "More than 100 frame errors"; const char frame_errors[] = "More than 100 frame errors";
int sCounter = 0; int sCounter = 0;
#ifdef GPS_DEBUG
std::string debugmsg = "";
#endif
for (int j = 2; j < 6; j++) { for (int j = 2; j < 6; j++) {
buf[8] += buf[j]; buf[8] += buf[j];
@ -292,20 +296,24 @@ GPS_RESPONSE GPS::getACK(uint8_t class_id, uint8_t msg_id, uint32_t waitMillis)
if (b == frame_errors[sCounter]) { if (b == frame_errors[sCounter]) {
sCounter++; sCounter++;
if (sCounter == 26) { if (sCounter == 26) {
#ifdef GPS_DEBUG
LOG_DEBUG(debugmsg.c_str());
#endif
return GNSS_RESPONSE_FRAME_ERRORS; return GNSS_RESPONSE_FRAME_ERRORS;
} }
} else { } else {
sCounter = 0; sCounter = 0;
} }
#ifdef GPS_DEBUG #ifdef GPS_DEBUG
LOG_DEBUG("%02X", b); debugmsg += vformat("%02X", b);
#endif #endif
if (b == buf[ack]) { if (b == buf[ack]) {
ack++; ack++;
} else { } else {
if (ack == 3 && b == 0x00) { // UBX-ACK-NAK message if (ack == 3 && b == 0x00) { // UBX-ACK-NAK message
#ifdef GPS_DEBUG #ifdef GPS_DEBUG
LOG_DEBUG(""); LOG_DEBUG(debugmsg.c_str());
#endif #endif
LOG_WARN("Got NAK for class %02X message %02X", class_id, msg_id); LOG_WARN("Got NAK for class %02X message %02X", class_id, msg_id);
return GNSS_RESPONSE_NAK; // NAK received return GNSS_RESPONSE_NAK; // NAK received
@ -315,7 +323,7 @@ GPS_RESPONSE GPS::getACK(uint8_t class_id, uint8_t msg_id, uint32_t waitMillis)
} }
} }
#ifdef GPS_DEBUG #ifdef GPS_DEBUG
LOG_DEBUG(""); LOG_DEBUG(debugmsg.c_str());
LOG_WARN("No response for class %02X message %02X", class_id, msg_id); LOG_WARN("No response for class %02X message %02X", class_id, msg_id);
#endif #endif
return GNSS_RESPONSE_NONE; // No response received within timeout return GNSS_RESPONSE_NONE; // No response received within timeout
@ -1624,6 +1632,9 @@ bool GPS::whileActive()
{ {
unsigned int charsInBuf = 0; unsigned int charsInBuf = 0;
bool isValid = false; bool isValid = false;
#ifdef GPS_DEBUG
std::string debugmsg = "";
#endif
if (powerState != GPS_ACTIVE) { if (powerState != GPS_ACTIVE) {
clearBuffer(); clearBuffer();
return false; return false;
@ -1641,7 +1652,7 @@ bool GPS::whileActive()
int c = _serial_gps->read(); int c = _serial_gps->read();
UBXscratch[charsInBuf] = c; UBXscratch[charsInBuf] = c;
#ifdef GPS_DEBUG #ifdef GPS_DEBUG
LOG_DEBUG("%c", c); debugmsg += vformat("%c", (c >= 32 && c <= 126) ? c : '.');
#endif #endif
isValid |= reader.encode(c); isValid |= reader.encode(c);
if (charsInBuf > sizeof(UBXscratch) - 10 || c == '\r') { if (charsInBuf > sizeof(UBXscratch) - 10 || c == '\r') {
@ -1653,6 +1664,9 @@ bool GPS::whileActive()
charsInBuf++; charsInBuf++;
} }
} }
#ifdef GPS_DEBUG
LOG_DEBUG(debugmsg.c_str());
#endif
return isValid; return isValid;
} }
void GPS::enable() void GPS::enable()
@ -1681,6 +1695,7 @@ void GPS::toggleGpsMode()
if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED) { if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED) {
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_DISABLED; config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_DISABLED;
LOG_INFO("User toggled GpsMode. Now DISABLED."); LOG_INFO("User toggled GpsMode. Now DISABLED.");
playGPSDisableBeep();
#ifdef GNSS_AIROHA #ifdef GNSS_AIROHA
if (powerState == GPS_ACTIVE) { if (powerState == GPS_ACTIVE) {
LOG_DEBUG("User power Off GPS"); LOG_DEBUG("User power Off GPS");
@ -1691,6 +1706,7 @@ void GPS::toggleGpsMode()
} else if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_DISABLED) { } else if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_DISABLED) {
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_ENABLED; config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_ENABLED;
LOG_INFO("User toggled GpsMode. Now ENABLED"); LOG_INFO("User toggled GpsMode. Now ENABLED");
playGPSEnableBeep();
enable(); enable();
} }
} }

View File

@ -75,7 +75,7 @@ class GPS : private concurrency::OSThread
uint8_t fixType = 0; // fix type from GPGSA uint8_t fixType = 0; // fix type from GPGSA
#endif #endif
private: private:
const int serialSpeeds[6] = {9600, 4800, 38400, 57600, 115200, 9600}; const int serialSpeeds[6] = {9600, 115200, 38400, 4800, 57600, 9600};
uint32_t lastWakeStartMsec = 0, lastSleepStartMsec = 0, lastFixStartMsec = 0; uint32_t lastWakeStartMsec = 0, lastSleepStartMsec = 0, lastFixStartMsec = 0;
uint32_t rx_gpio = 0; uint32_t rx_gpio = 0;
uint32_t tx_gpio = 0; uint32_t tx_gpio = 0;

View File

@ -43,6 +43,15 @@ uint32_t Default::getConfiguredOrDefaultMsScaled(uint32_t configured, uint32_t d
return getConfiguredOrDefaultMs(configured, defaultValue) * congestionScalingCoefficient(numOnlineNodes); return getConfiguredOrDefaultMs(configured, defaultValue) * congestionScalingCoefficient(numOnlineNodes);
} }
uint32_t Default::getConfiguredOrMinimumValue(uint32_t configured, uint32_t minValue)
{
// If zero, intervals should be coalesced later by getConfiguredOrDefault... methods
if (configured == 0)
return configured;
return configured < minValue ? minValue : configured;
}
uint8_t Default::getConfiguredOrDefaultHopLimit(uint8_t configured) uint8_t Default::getConfiguredOrDefaultHopLimit(uint8_t configured)
{ {
#if USERPREFS_EVENT_MODE #if USERPREFS_EVENT_MODE

View File

@ -6,8 +6,9 @@
#define THIRTY_SECONDS_MS 30 * 1000 #define THIRTY_SECONDS_MS 30 * 1000
#define FIVE_SECONDS_MS 5 * 1000 #define FIVE_SECONDS_MS 5 * 1000
#define min_default_telemetry_interval_secs 30 * 60
#define default_gps_update_interval IF_ROUTER(ONE_DAY, 2 * 60) #define default_gps_update_interval IF_ROUTER(ONE_DAY, 2 * 60)
#define default_telemetry_broadcast_interval_secs IF_ROUTER(ONE_DAY / 2, 30 * 60) #define default_telemetry_broadcast_interval_secs IF_ROUTER(ONE_DAY / 2, 60 * 60)
#define default_broadcast_interval_secs IF_ROUTER(ONE_DAY / 2, 15 * 60) #define default_broadcast_interval_secs IF_ROUTER(ONE_DAY / 2, 15 * 60)
#define default_wait_bluetooth_secs IF_ROUTER(1, 60) #define default_wait_bluetooth_secs IF_ROUTER(1, 60)
#define default_sds_secs IF_ROUTER(ONE_DAY, UINT32_MAX) // Default to forever super deep sleep #define default_sds_secs IF_ROUTER(ONE_DAY, UINT32_MAX) // Default to forever super deep sleep
@ -35,6 +36,7 @@ class Default
static uint32_t getConfiguredOrDefault(uint32_t configured, uint32_t defaultValue); static uint32_t getConfiguredOrDefault(uint32_t configured, uint32_t defaultValue);
static uint32_t getConfiguredOrDefaultMsScaled(uint32_t configured, uint32_t defaultValue, uint32_t numOnlineNodes); static uint32_t getConfiguredOrDefaultMsScaled(uint32_t configured, uint32_t defaultValue, uint32_t numOnlineNodes);
static uint8_t getConfiguredOrDefaultHopLimit(uint8_t configured); static uint8_t getConfiguredOrDefaultHopLimit(uint8_t configured);
static uint32_t getConfiguredOrMinimumValue(uint32_t configured, uint32_t minValue);
private: private:
static float congestionScalingCoefficient(int numOnlineNodes) static float congestionScalingCoefficient(int numOnlineNodes)

View File

@ -44,7 +44,7 @@ bool FloodingRouter::isRebroadcaster()
void FloodingRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Routing *c) void FloodingRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Routing *c)
{ {
bool isAckorReply = (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) && (p->decoded.request_id != 0); bool isAckorReply = (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) && (p->decoded.request_id != 0);
if (isAckorReply && !isToUs(p) && p->to != NODENUM_BROADCAST) { if (isAckorReply && !isToUs(p) && !isBroadcast(p->to)) {
// do not flood direct message that is ACKed or replied to // do not flood direct message that is ACKed or replied to
LOG_DEBUG("Rxd an ACK/reply not for me, cancel rebroadcast."); LOG_DEBUG("Rxd an ACK/reply not for me, cancel rebroadcast.");
Router::cancelSending(p->to, p->decoded.request_id); // cancel rebroadcast for this DM Router::cancelSending(p->to, p->decoded.request_id); // cancel rebroadcast for this DM

View File

@ -86,7 +86,7 @@ void MeshModule::callModules(meshtastic_MeshPacket &mp, RxSource src)
// Was this message directed to us specifically? Will be false if we are sniffing someone elses packets // Was this message directed to us specifically? Will be false if we are sniffing someone elses packets
auto ourNodeNum = nodeDB->getNodeNum(); auto ourNodeNum = nodeDB->getNodeNum();
bool toUs = mp.to == NODENUM_BROADCAST || isToUs(&mp); bool toUs = isBroadcast(mp.to) || isToUs(&mp);
for (auto i = modules->begin(); i != modules->end(); ++i) { for (auto i = modules->begin(); i != modules->end(); ++i) {
auto &pi = **i; auto &pi = **i;

View File

@ -57,4 +57,6 @@ bool isFromUs(const meshtastic_MeshPacket *p);
bool isToUs(const meshtastic_MeshPacket *p); bool isToUs(const meshtastic_MeshPacket *p);
/* Some clients might not properly set priority, therefore we fix it here. */ /* Some clients might not properly set priority, therefore we fix it here. */
void fixPriority(meshtastic_MeshPacket *p); void fixPriority(meshtastic_MeshPacket *p);
bool isBroadcast(uint32_t dest);

View File

@ -172,6 +172,22 @@ NodeDB::NodeDB()
resetRadioConfig(); // If bogus settings got saved, then fix them resetRadioConfig(); // If bogus settings got saved, then fix them
// nodeDB->LOG_DEBUG("region=%d, NODENUM=0x%x, dbsize=%d", config.lora.region, myNodeInfo.my_node_num, numMeshNodes); // nodeDB->LOG_DEBUG("region=%d, NODENUM=0x%x, dbsize=%d", config.lora.region, myNodeInfo.my_node_num, numMeshNodes);
// If we are setup to broadcast on the default channel, ensure that the telemetry intervals are coerced to the minimum value
// of 30 minutes or more
if (channels.isDefaultChannel(channels.getPrimaryIndex())) {
LOG_DEBUG("Coercing telemetry to min of 30 minutes on defaults");
moduleConfig.telemetry.device_update_interval = Default::getConfiguredOrMinimumValue(
moduleConfig.telemetry.device_update_interval, min_default_telemetry_interval_secs);
moduleConfig.telemetry.environment_update_interval = Default::getConfiguredOrMinimumValue(
moduleConfig.telemetry.environment_update_interval, min_default_telemetry_interval_secs);
moduleConfig.telemetry.air_quality_interval = Default::getConfiguredOrMinimumValue(
moduleConfig.telemetry.air_quality_interval, min_default_telemetry_interval_secs);
moduleConfig.telemetry.power_update_interval = Default::getConfiguredOrMinimumValue(
moduleConfig.telemetry.power_update_interval, min_default_telemetry_interval_secs);
moduleConfig.telemetry.health_update_interval = Default::getConfiguredOrMinimumValue(
moduleConfig.telemetry.health_update_interval, min_default_telemetry_interval_secs);
}
if (devicestateCRC != crc32Buffer(&devicestate, sizeof(devicestate))) if (devicestateCRC != crc32Buffer(&devicestate, sizeof(devicestate)))
saveWhat |= SEGMENT_DEVICESTATE; saveWhat |= SEGMENT_DEVICESTATE;
if (configCRC != crc32Buffer(&config, sizeof(config))) if (configCRC != crc32Buffer(&config, sizeof(config)))
@ -207,6 +223,11 @@ bool isToUs(const meshtastic_MeshPacket *p)
return p->to == nodeDB->getNodeNum(); return p->to == nodeDB->getNodeNum();
} }
bool isBroadcast(uint32_t dest)
{
return dest == NODENUM_BROADCAST || dest == NODENUM_BROADCAST_NO_LORA;
}
bool NodeDB::resetRadioConfig(bool factory_reset) bool NodeDB::resetRadioConfig(bool factory_reset)
{ {
bool didFactoryReset = false; bool didFactoryReset = false;

View File

@ -467,7 +467,10 @@ void RadioLibInterface::setStandby()
void RadioLibInterface::startSend(meshtastic_MeshPacket *txp) void RadioLibInterface::startSend(meshtastic_MeshPacket *txp)
{ {
printPacket("Starting low level send", txp); printPacket("Starting low level send", txp);
if (disabled || !config.lora.tx_enabled) { if (txp->to == NODENUM_BROADCAST_NO_LORA) {
LOG_DEBUG("Drop Tx packet because dest is broadcast no-lora");
packetPool.release(txp);
} else if (disabled || !config.lora.tx_enabled) {
LOG_WARN("Drop Tx packet because LoRa Tx disabled"); LOG_WARN("Drop Tx packet because LoRa Tx disabled");
packetPool.release(txp); packetPool.release(txp);
} else { } else {

View File

@ -181,7 +181,7 @@ ErrorCode Router::sendLocal(meshtastic_MeshPacket *p, RxSource src)
} else { } else {
// If we are sending a broadcast, we also treat it as if we just received it ourself // If we are sending a broadcast, we also treat it as if we just received it ourself
// this allows local apps (and PCs) to see broadcasts sourced locally // this allows local apps (and PCs) to see broadcasts sourced locally
if (p->to == NODENUM_BROADCAST) { if (isBroadcast(p->to)) {
handleReceived(p, src); handleReceived(p, src);
} }
@ -240,7 +240,7 @@ ErrorCode Router::send(meshtastic_MeshPacket *p)
// assert // assert
// Never set the want_ack flag on broadcast packets sent over the air. // Never set the want_ack flag on broadcast packets sent over the air.
if (p->to == NODENUM_BROADCAST) if (isBroadcast(p->to))
p->want_ack = false; p->want_ack = false;
// Up until this point we might have been using 0 for the from address (if it started with the phone), but when we send over // Up until this point we might have been using 0 for the from address (if it started with the phone), but when we send over
@ -328,7 +328,7 @@ bool perhapsDecode(meshtastic_MeshPacket *p)
memcpy(ScratchEncrypted, p->encrypted.bytes, rawSize); memcpy(ScratchEncrypted, p->encrypted.bytes, rawSize);
#if !(MESHTASTIC_EXCLUDE_PKI) #if !(MESHTASTIC_EXCLUDE_PKI)
// Attempt PKI decryption first // Attempt PKI decryption first
if (p->channel == 0 && isToUs(p) && p->to > 0 && p->to != NODENUM_BROADCAST && nodeDB->getMeshNode(p->from) != nullptr && if (p->channel == 0 && isToUs(p) && p->to > 0 && !isBroadcast(p->to) && nodeDB->getMeshNode(p->from) != nullptr &&
nodeDB->getMeshNode(p->from)->user.public_key.size > 0 && nodeDB->getMeshNode(p->to)->user.public_key.size > 0 && nodeDB->getMeshNode(p->from)->user.public_key.size > 0 && nodeDB->getMeshNode(p->to)->user.public_key.size > 0 &&
rawSize > MESHTASTIC_PKC_OVERHEAD) { rawSize > MESHTASTIC_PKC_OVERHEAD) {
LOG_DEBUG("Attempting PKI decryption"); LOG_DEBUG("Attempting PKI decryption");
@ -493,7 +493,7 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
// Don't use PKC if it's not explicitly requested and a non-primary channel is requested // Don't use PKC if it's not explicitly requested and a non-primary channel is requested
!(p->pki_encrypted != true && p->channel > 0) && !(p->pki_encrypted != true && p->channel > 0) &&
// Check for valid keys and single node destination // Check for valid keys and single node destination
config.security.private_key.size == 32 && p->to != NODENUM_BROADCAST && node != nullptr && config.security.private_key.size == 32 && !isBroadcast(p->to) && node != nullptr &&
// Check for a known public key for the destination // Check for a known public key for the destination
(node->user.public_key.size == 32) && (node->user.public_key.size == 32) &&
// Some portnums either make no sense to send with PKC // Some portnums either make no sense to send with PKC
@ -615,7 +615,7 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
#if !MESHTASTIC_EXCLUDE_MQTT #if !MESHTASTIC_EXCLUDE_MQTT
// Mark as pki_encrypted if it is not yet decoded and MQTT encryption is also enabled, hash matches and it's a DM not to // Mark as pki_encrypted if it is not yet decoded and MQTT encryption is also enabled, hash matches and it's a DM not to
// us (because we would be able to decrypt it) // us (because we would be able to decrypt it)
if (!decoded && moduleConfig.mqtt.encryption_enabled && p->channel == 0x00 && p->to != NODENUM_BROADCAST && !isToUs(p)) if (!decoded && moduleConfig.mqtt.encryption_enabled && p->channel == 0x00 && !isBroadcast(p->to) && !isToUs(p))
p_encrypted->pki_encrypted = true; p_encrypted->pki_encrypted = true;
// After potentially altering it, publish received message to MQTT if we're not the original transmitter of the packet // After potentially altering it, publish received message to MQTT if we're not the original transmitter of the packet
if ((decoded || p_encrypted->pki_encrypted) && moduleConfig.mqtt.enabled && !isFromUs(p) && mqtt) if ((decoded || p_encrypted->pki_encrypted) && moduleConfig.mqtt.enabled && !isFromUs(p) && mqtt)

View File

@ -778,6 +778,8 @@ typedef struct _meshtastic_MyNodeInfo {
/* The minimum app version that can talk to this device. /* The minimum app version that can talk to this device.
Phone/PC apps should compare this to their build number and if too low tell the user they must update their app */ Phone/PC apps should compare this to their build number and if too low tell the user they must update their app */
uint32_t min_app_version; uint32_t min_app_version;
/* Unique hardware identifier for this device */
uint64_t device_id;
} meshtastic_MyNodeInfo; } meshtastic_MyNodeInfo;
/* Debug output from the device. /* Debug output from the device.
@ -1112,7 +1114,7 @@ extern "C" {
#define meshtastic_MqttClientProxyMessage_init_default {"", 0, {{0, {0}}}, 0} #define meshtastic_MqttClientProxyMessage_init_default {"", 0, {{0, {0}}}, 0}
#define meshtastic_MeshPacket_init_default {0, 0, 0, 0, {meshtastic_Data_init_default}, 0, 0, 0, 0, 0, _meshtastic_MeshPacket_Priority_MIN, 0, _meshtastic_MeshPacket_Delayed_MIN, 0, 0, {0, {0}}, 0} #define meshtastic_MeshPacket_init_default {0, 0, 0, 0, {meshtastic_Data_init_default}, 0, 0, 0, 0, 0, _meshtastic_MeshPacket_Priority_MIN, 0, _meshtastic_MeshPacket_Delayed_MIN, 0, 0, {0, {0}}, 0}
#define meshtastic_NodeInfo_init_default {0, false, meshtastic_User_init_default, false, meshtastic_Position_init_default, 0, 0, false, meshtastic_DeviceMetrics_init_default, 0, 0, false, 0, 0} #define meshtastic_NodeInfo_init_default {0, false, meshtastic_User_init_default, false, meshtastic_Position_init_default, 0, 0, false, meshtastic_DeviceMetrics_init_default, 0, 0, false, 0, 0}
#define meshtastic_MyNodeInfo_init_default {0, 0, 0} #define meshtastic_MyNodeInfo_init_default {0, 0, 0, 0}
#define meshtastic_LogRecord_init_default {"", 0, "", _meshtastic_LogRecord_Level_MIN} #define meshtastic_LogRecord_init_default {"", 0, "", _meshtastic_LogRecord_Level_MIN}
#define meshtastic_QueueStatus_init_default {0, 0, 0, 0} #define meshtastic_QueueStatus_init_default {0, 0, 0, 0}
#define meshtastic_FromRadio_init_default {0, 0, {meshtastic_MeshPacket_init_default}} #define meshtastic_FromRadio_init_default {0, 0, {meshtastic_MeshPacket_init_default}}
@ -1137,7 +1139,7 @@ extern "C" {
#define meshtastic_MqttClientProxyMessage_init_zero {"", 0, {{0, {0}}}, 0} #define meshtastic_MqttClientProxyMessage_init_zero {"", 0, {{0, {0}}}, 0}
#define meshtastic_MeshPacket_init_zero {0, 0, 0, 0, {meshtastic_Data_init_zero}, 0, 0, 0, 0, 0, _meshtastic_MeshPacket_Priority_MIN, 0, _meshtastic_MeshPacket_Delayed_MIN, 0, 0, {0, {0}}, 0} #define meshtastic_MeshPacket_init_zero {0, 0, 0, 0, {meshtastic_Data_init_zero}, 0, 0, 0, 0, 0, _meshtastic_MeshPacket_Priority_MIN, 0, _meshtastic_MeshPacket_Delayed_MIN, 0, 0, {0, {0}}, 0}
#define meshtastic_NodeInfo_init_zero {0, false, meshtastic_User_init_zero, false, meshtastic_Position_init_zero, 0, 0, false, meshtastic_DeviceMetrics_init_zero, 0, 0, false, 0, 0} #define meshtastic_NodeInfo_init_zero {0, false, meshtastic_User_init_zero, false, meshtastic_Position_init_zero, 0, 0, false, meshtastic_DeviceMetrics_init_zero, 0, 0, false, 0, 0}
#define meshtastic_MyNodeInfo_init_zero {0, 0, 0} #define meshtastic_MyNodeInfo_init_zero {0, 0, 0, 0}
#define meshtastic_LogRecord_init_zero {"", 0, "", _meshtastic_LogRecord_Level_MIN} #define meshtastic_LogRecord_init_zero {"", 0, "", _meshtastic_LogRecord_Level_MIN}
#define meshtastic_QueueStatus_init_zero {0, 0, 0, 0} #define meshtastic_QueueStatus_init_zero {0, 0, 0, 0}
#define meshtastic_FromRadio_init_zero {0, 0, {meshtastic_MeshPacket_init_zero}} #define meshtastic_FromRadio_init_zero {0, 0, {meshtastic_MeshPacket_init_zero}}
@ -1244,6 +1246,7 @@ extern "C" {
#define meshtastic_MyNodeInfo_my_node_num_tag 1 #define meshtastic_MyNodeInfo_my_node_num_tag 1
#define meshtastic_MyNodeInfo_reboot_count_tag 8 #define meshtastic_MyNodeInfo_reboot_count_tag 8
#define meshtastic_MyNodeInfo_min_app_version_tag 11 #define meshtastic_MyNodeInfo_min_app_version_tag 11
#define meshtastic_MyNodeInfo_device_id_tag 12
#define meshtastic_LogRecord_message_tag 1 #define meshtastic_LogRecord_message_tag 1
#define meshtastic_LogRecord_time_tag 2 #define meshtastic_LogRecord_time_tag 2
#define meshtastic_LogRecord_source_tag 3 #define meshtastic_LogRecord_source_tag 3
@ -1446,7 +1449,8 @@ X(a, STATIC, SINGULAR, BOOL, is_favorite, 10)
#define meshtastic_MyNodeInfo_FIELDLIST(X, a) \ #define meshtastic_MyNodeInfo_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, my_node_num, 1) \ X(a, STATIC, SINGULAR, UINT32, my_node_num, 1) \
X(a, STATIC, SINGULAR, UINT32, reboot_count, 8) \ X(a, STATIC, SINGULAR, UINT32, reboot_count, 8) \
X(a, STATIC, SINGULAR, UINT32, min_app_version, 11) X(a, STATIC, SINGULAR, UINT32, min_app_version, 11) \
X(a, STATIC, SINGULAR, UINT64, device_id, 12)
#define meshtastic_MyNodeInfo_CALLBACK NULL #define meshtastic_MyNodeInfo_CALLBACK NULL
#define meshtastic_MyNodeInfo_DEFAULT NULL #define meshtastic_MyNodeInfo_DEFAULT NULL
@ -1669,7 +1673,7 @@ extern const pb_msgdesc_t meshtastic_ChunkedPayloadResponse_msg;
#define meshtastic_LogRecord_size 426 #define meshtastic_LogRecord_size 426
#define meshtastic_MeshPacket_size 367 #define meshtastic_MeshPacket_size 367
#define meshtastic_MqttClientProxyMessage_size 501 #define meshtastic_MqttClientProxyMessage_size 501
#define meshtastic_MyNodeInfo_size 18 #define meshtastic_MyNodeInfo_size 29
#define meshtastic_NeighborInfo_size 258 #define meshtastic_NeighborInfo_size 258
#define meshtastic_Neighbor_size 22 #define meshtastic_Neighbor_size 22
#define meshtastic_NodeInfo_size 317 #define meshtastic_NodeInfo_size 317

View File

@ -122,7 +122,7 @@ Will be used for broadcast.
int32_t NeighborInfoModule::runOnce() int32_t NeighborInfoModule::runOnce()
{ {
if (airTime->isTxAllowedChannelUtil(true) && airTime->isTxAllowedAirUtil()) { if (airTime->isTxAllowedChannelUtil(true) && airTime->isTxAllowedAirUtil()) {
sendNeighborInfo(NODENUM_BROADCAST, false); sendNeighborInfo(NODENUM_BROADCAST_NO_LORA, false);
} }
return Default::getConfiguredOrDefaultMs(moduleConfig.neighbor_info.update_interval, default_neighbor_info_broadcast_secs); return Default::getConfiguredOrDefaultMs(moduleConfig.neighbor_info.update_interval, default_neighbor_info_broadcast_secs);
} }

View File

@ -16,7 +16,7 @@ bool NodeInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
bool hasChanged = nodeDB->updateUser(getFrom(&mp), p, mp.channel); 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 // Show new nodes on LCD screen
if (wasBroadcast) { if (wasBroadcast) {

View File

@ -13,8 +13,7 @@ bool RoutingModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mesh
printPacket("Routing sniffing", &mp); printPacket("Routing sniffing", &mp);
router->sniffReceived(&mp, r); router->sniffReceived(&mp, r);
bool maybePKI = bool maybePKI = mp.which_payload_variant == meshtastic_MeshPacket_encrypted_tag && mp.channel == 0 && !isBroadcast(mp.to);
mp.which_payload_variant == meshtastic_MeshPacket_encrypted_tag && mp.channel == 0 && mp.to != NODENUM_BROADCAST;
// Beginning of logic whether to drop the packet based on Rebroadcast mode // Beginning of logic whether to drop the packet based on Rebroadcast mode
if (mp.which_payload_variant == meshtastic_MeshPacket_encrypted_tag && if (mp.which_payload_variant == meshtastic_MeshPacket_encrypted_tag &&
(config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_LOCAL_ONLY || (config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_LOCAL_ONLY ||
@ -28,7 +27,7 @@ bool RoutingModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mesh
// FIXME - move this to a non promsicious PhoneAPI module? // 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 // 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); printPacket("Delivering rx packet", &mp);
service->handleFromRadio(&mp); service->handleFromRadio(&mp);
} }

View File

@ -706,18 +706,43 @@ bool MQTT::isValidJsonEnvelope(JSONObject &json)
bool MQTT::isPrivateIpAddress(const char address[]) bool MQTT::isPrivateIpAddress(const char address[])
{ {
// Min. length like 10.0.0.0, max like 192.168.255.255 // Min. length like 10.0.0.0 (8), max like 192.168.255.255:65535 (21)
size_t length = strlen(address); size_t length = strlen(address);
if (length < 8 || length > 15) { if (length < 8 || length > 21) {
return false; return false;
} }
// Ensure the address contains only digits and dots. // 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. // Even if it's not a valid IP address, we will know it's not a domain.
bool hasColon = false;
int numDots = 0;
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
if (!isdigit(address[i]) && address[i] != '.') { if (!isdigit(address[i]) && address[i] != '.' && address[i] != ':') {
return false; 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. // Check the easy ones first.

View File

@ -54,7 +54,7 @@
#define SX126X_DIO1 LORA_DIO1 #define SX126X_DIO1 LORA_DIO1
#define SX126X_BUSY LORA_BUSY #define SX126X_BUSY LORA_BUSY
#define SX126X_RESET LORA_RESET #define SX126X_RESET LORA_RESET
#define SX126X_DIO2_AS_RF_SWITCH // Antenna switch CTRL #define SX126X_DIO2_AS_RF_SWITCH // Antenna switch CTRL
#define SX126X_POWER_EN LORA_DIO4 // Antenna switch !CTRL via GPIO17 #define SX126X_RXEN LORA_DIO4 // Antenna switch !CTRL via GPIO17
// #define SX126X_DIO3_TCXO_VOLTAGE 1.8 // #define SX126X_DIO3_TCXO_VOLTAGE 1.8
#endif #endif

View File

@ -1,4 +1,4 @@
[VERSION] [VERSION]
major = 2 major = 2
minor = 5 minor = 5
build = 7 build = 8