Skip to content

Conversation

@Arduinux
Copy link
Contributor

@Arduinux Arduinux commented Jan 8, 2026

With just a few changes, the client can use both WiFi and Ethernet.

Here are the changes:
diff --git a/src/Transport/ClientSecureSync.h b/src/Transport/ClientSecureSync.h
index b81681e..d4b0e06 100644
--- a/src/Transport/ClientSecureSync.h
+++ b/src/Transport/ClientSecureSync.h
@@ -10,7 +10,7 @@ the LICENSE file.

#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)

-#include <WiFiClientSecure.h> // includes IPAddress
+#include <NetworkClientSecure.h> // includes IPAddress

#include ‘Transport.h’

@@ -26,7 +26,7 @@ class ClientSecureSync : public Transport {
void stop() override;
bool connected() override;
bool disconnected() override;

  • WiFiClientSecure client;
  • NetworkClientSecure client;
    };

} // namespace espMqttClientInternals
diff --git a/src/Transport/ClientSync.h b/src/Transport/ClientSync.h
index ccfbdba..373a092 100644
-- - a/src/Transport/ClientSync.h
+++ b/src/Transport/ClientSync.h
@@ -10,7 +10,7 @@ the LICENSE file.

#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)

-#include <WiFiClient.h> // includes IPAddress
+#include <Network.h> // includes IPAddress

#include ‘Transport.h’

@@ -26,7 +26,7 @@ class ClientSync : public Transport {
void stop() override;
bool connected() override;
bool disconnected() override;

  • WiFiClient client;
  • NetworkClient client;
    };

Feel free to use the code.

Edit:
In addition, I have eliminated this compiler warning: 'void AsyncClient::close(bool)' is deprecated: Use AsyncClient::close() instead [-Wdeprecated-declarations]

Best Regards,
Arduinux

@bertmelis
Copy link
Owner

  • ESP8266 compatibility is worth a discussion but I'd like to keep it for now.
  • I have to fix CI for Platformio to use the pioarduino framework.

@Arduinux
Copy link
Contributor Author

Arduinux commented Jan 9, 2026

Thanks for your efforts!

I can't comment on the crashes with PlatformIO, as I've never worked with it before. As far as I can tell, all the others are due to the missing “Network.h”.

I'll try to find a solution using preprocessor macros.

Best regards,
Arduinux

@bertmelis
Copy link
Owner

Standard platformio is stuck on v2 of the Arduino framework but a community fork has moved to v3. CI doesn't use this fork so it is missing the "network"-versions of the stack.

Can you adjust the workflow:

Here: https://github.com/bertmelis/espMqttClient/blob/main/.github/workflows/build_platformio.yml#L57
and here: https://github.com/bertmelis/espMqttClient/blob/main/.github/workflows/build_platformio.yml#L84

run: pio ci --lib="." --board=lolin32 --project-option="platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip"
run: pio ci --lib="." --board=lolin_c3_mini --project-option="platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip"

I'll try to fix in the weekend should this not work.

@Arduinux
Copy link
Contributor Author

Arduinux commented Jan 9, 2026

"Can you adjust the workflow: ..." Sorry, I haven't worked with PlatformIO yet. But I hope that at least the Arduino IDE can now handle my changes. It works with the ESP32. I don't know about the ESP8266, but I'll install the ‘board’ now and then test my code against the ESP8266.

Edit:
All 5 examples for the ESP8266 were compiled without warnings or errors.

Best regards,
Arduinux

@Arduinux
Copy link
Contributor Author

Arduinux commented Jan 9, 2026

I completely overlooked Lint. OK, I hope I've fixed all the bugs. If there's anything else that needs doing, I'll be happy to do it if I'm able to.

Best regards,
Arduinux

@bertmelis bertmelis merged commit bf5aa22 into bertmelis:main Jan 9, 2026
20 checks passed
@bertmelis
Copy link
Owner

All green! Thank you for the contribution!

@Arduinux
Copy link
Contributor Author

Arduinux commented Jan 9, 2026

It was my pleasure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants