mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-19 11:43:27 +00:00
More accurately determine if MQTT uses the default server (#5663)
Some checks are pending
CI / setup (check) (push) Waiting to run
CI / setup (esp32) (push) Waiting to run
CI / setup (esp32c3) (push) Waiting to run
CI / setup (esp32c6) (push) Waiting to run
CI / setup (esp32s3) (push) Waiting to run
CI / setup (nrf52840) (push) Waiting to run
CI / setup (rp2040) (push) Waiting to run
CI / setup (stm32) (push) Waiting to run
CI / check (push) Blocked by required conditions
CI / build-esp32 (push) Blocked by required conditions
CI / build-esp32-s3 (push) Blocked by required conditions
CI / build-esp32-c3 (push) Blocked by required conditions
CI / build-esp32-c6 (push) Blocked by required conditions
CI / build-nrf52 (push) Blocked by required conditions
CI / build-rpi2040 (push) Blocked by required conditions
CI / build-stm32 (push) Blocked by required conditions
CI / package-raspbian (push) Waiting to run
CI / package-raspbian-armv7l (push) Waiting to run
CI / package-native (push) Waiting to run
CI / build-docker (push) Waiting to run
CI / after-checks (push) Blocked by required conditions
CI / gather-artifacts (esp32) (push) Blocked by required conditions
CI / gather-artifacts (esp32c3) (push) Blocked by required conditions
CI / gather-artifacts (esp32c6) (push) Blocked by required conditions
CI / gather-artifacts (esp32s3) (push) Blocked by required conditions
CI / gather-artifacts (nrf52840) (push) Blocked by required conditions
CI / gather-artifacts (rp2040) (push) Blocked by required conditions
CI / gather-artifacts (stm32) (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
CI / release-firmware (esp32) (push) Blocked by required conditions
CI / release-firmware (esp32c3) (push) Blocked by required conditions
CI / release-firmware (esp32c6) (push) Blocked by required conditions
CI / release-firmware (esp32s3) (push) Blocked by required conditions
CI / release-firmware (nrf52840) (push) Blocked by required conditions
CI / release-firmware (rp2040) (push) Blocked by required conditions
CI / release-firmware (stm32) (push) Blocked by required conditions
Flawfinder Scan / Flawfinder (push) Waiting to run
Some checks are pending
CI / setup (check) (push) Waiting to run
CI / setup (esp32) (push) Waiting to run
CI / setup (esp32c3) (push) Waiting to run
CI / setup (esp32c6) (push) Waiting to run
CI / setup (esp32s3) (push) Waiting to run
CI / setup (nrf52840) (push) Waiting to run
CI / setup (rp2040) (push) Waiting to run
CI / setup (stm32) (push) Waiting to run
CI / check (push) Blocked by required conditions
CI / build-esp32 (push) Blocked by required conditions
CI / build-esp32-s3 (push) Blocked by required conditions
CI / build-esp32-c3 (push) Blocked by required conditions
CI / build-esp32-c6 (push) Blocked by required conditions
CI / build-nrf52 (push) Blocked by required conditions
CI / build-rpi2040 (push) Blocked by required conditions
CI / build-stm32 (push) Blocked by required conditions
CI / package-raspbian (push) Waiting to run
CI / package-raspbian-armv7l (push) Waiting to run
CI / package-native (push) Waiting to run
CI / build-docker (push) Waiting to run
CI / after-checks (push) Blocked by required conditions
CI / gather-artifacts (esp32) (push) Blocked by required conditions
CI / gather-artifacts (esp32c3) (push) Blocked by required conditions
CI / gather-artifacts (esp32c6) (push) Blocked by required conditions
CI / gather-artifacts (esp32s3) (push) Blocked by required conditions
CI / gather-artifacts (nrf52840) (push) Blocked by required conditions
CI / gather-artifacts (rp2040) (push) Blocked by required conditions
CI / gather-artifacts (stm32) (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
CI / release-firmware (esp32) (push) Blocked by required conditions
CI / release-firmware (esp32c3) (push) Blocked by required conditions
CI / release-firmware (esp32c6) (push) Blocked by required conditions
CI / release-firmware (esp32s3) (push) Blocked by required conditions
CI / release-firmware (nrf52840) (push) Blocked by required conditions
CI / release-firmware (rp2040) (push) Blocked by required conditions
CI / release-firmware (stm32) (push) Blocked by required conditions
Flawfinder Scan / Flawfinder (push) Waiting to run
* More accurately determine if MQTT uses the default server * Channels::anyMqttEnabled() uses same logic * Remove previous static bool
This commit is contained in:
parent
fbdd6e7223
commit
a7d9e8107a
@ -318,7 +318,7 @@ bool Channels::anyMqttEnabled()
|
|||||||
{
|
{
|
||||||
#if USERPREFS_EVENT_MODE
|
#if USERPREFS_EVENT_MODE
|
||||||
// Don't publish messages on the public MQTT broker if we are in event mode
|
// Don't publish messages on the public MQTT broker if we are in event mode
|
||||||
if (strcmp(moduleConfig.mqtt.address, default_mqtt_address) == 0) {
|
if (mqtt && mqtt.isUsingDefaultServer()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -324,9 +324,10 @@ MQTT::MQTT() : concurrency::OSThread("mqtt"), mqttQueue(MAX_MQTT_QUEUE)
|
|||||||
moduleConfig.mqtt.map_report_settings.publish_interval_secs, default_map_publish_interval_secs);
|
moduleConfig.mqtt.map_report_settings.publish_interval_secs, default_map_publish_interval_secs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String host = parseHostAndPort(moduleConfig.mqtt.address).first;
|
||||||
|
isConfiguredForDefaultServer = host.length() == 0 || host == default_mqtt_address;
|
||||||
IPAddress ip;
|
IPAddress ip;
|
||||||
isMqttServerAddressPrivate =
|
isMqttServerAddressPrivate = ip.fromString(host.c_str()) && isPrivateIpAddress(ip);
|
||||||
ip.fromString(parseHostAndPort(moduleConfig.mqtt.address).first.c_str()) && isPrivateIpAddress(ip);
|
|
||||||
|
|
||||||
#if HAS_NETWORKING
|
#if HAS_NETWORKING
|
||||||
if (!moduleConfig.mqtt.proxy_to_client_enabled)
|
if (!moduleConfig.mqtt.proxy_to_client_enabled)
|
||||||
@ -633,8 +634,7 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp_encrypted, const meshtastic_Me
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(moduleConfig.mqtt.address, default_mqtt_address) == 0 &&
|
if (isConfiguredForDefaultServer && (mp_decoded.decoded.portnum == meshtastic_PortNum_RANGE_TEST_APP ||
|
||||||
(mp_decoded.decoded.portnum == meshtastic_PortNum_RANGE_TEST_APP ||
|
|
||||||
mp_decoded.decoded.portnum == meshtastic_PortNum_DETECTION_SENSOR_APP)) {
|
mp_decoded.decoded.portnum == meshtastic_PortNum_DETECTION_SENSOR_APP)) {
|
||||||
LOG_DEBUG("MQTT onSend - Ignoring range test or detection sensor message on public mqtt");
|
LOG_DEBUG("MQTT onSend - Ignoring range test or detection sensor message on public mqtt");
|
||||||
return;
|
return;
|
||||||
|
@ -79,6 +79,8 @@ class MQTT : private concurrency::OSThread
|
|||||||
|
|
||||||
void start() { setIntervalFromNow(0); };
|
void start() { setIntervalFromNow(0); };
|
||||||
|
|
||||||
|
bool isUsingDefaultServer() { return isConfiguredForDefaultServer; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
struct QueueEntry {
|
struct QueueEntry {
|
||||||
std::string topic;
|
std::string topic;
|
||||||
@ -87,6 +89,7 @@ class MQTT : private concurrency::OSThread
|
|||||||
PointerQueue<QueueEntry> mqttQueue;
|
PointerQueue<QueueEntry> mqttQueue;
|
||||||
|
|
||||||
int reconnectCount = 0;
|
int reconnectCount = 0;
|
||||||
|
bool isConfiguredForDefaultServer = true;
|
||||||
|
|
||||||
virtual int32_t runOnce() override;
|
virtual int32_t runOnce() override;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user