diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index fdd0de7..c1bfe9b 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -51,6 +51,17 @@ jobs: - name: arduino:samd libraries: | - name: WiFiNINA + - fqbn: arduino:mbed_portenta:envie_m7 + platforms: | + - name: arduino:mbed_portenta + libraries: "" + - fqbn: arduino:mbed_nicla:nicla_vision + platforms: | + - name: arduino:mbed_nicla + libraries: "" + - fqbn: arduino:mbed_giga:giga + platforms: | + - name: arduino:mbed_giga - fqbn: esp8266:esp8266:huzzah platforms: | - name: esp8266:esp8266 diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 986bda6..94938f3 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -31,7 +31,7 @@ jobs: - name: Download JSON schema for labels configuration file id: download-schema - uses: carlosperate/download-file-action@v1 + uses: carlosperate/download-file-action@v2 with: file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json location: ${{ runner.temp }}/label-configuration-schema @@ -65,7 +65,7 @@ jobs: steps: - name: Download - uses: carlosperate/download-file-action@v1 + uses: carlosperate/download-file-action@v2 with: file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }} @@ -114,7 +114,7 @@ jobs: path: ${{ env.CONFIGURATIONS_FOLDER }} - name: Remove unneeded artifact - uses: geekyeggo/delete-artifact@v1 + uses: geekyeggo/delete-artifact@v2 with: name: ${{ env.CONFIGURATIONS_ARTIFACT }} diff --git a/examples/WiFiAdvancedCallback/WiFiAdvancedCallback.ino b/examples/WiFiAdvancedCallback/WiFiAdvancedCallback.ino index c4bec66..5cf2b58 100644 --- a/examples/WiFiAdvancedCallback/WiFiAdvancedCallback.ino +++ b/examples/WiFiAdvancedCallback/WiFiAdvancedCallback.ino @@ -22,7 +22,7 @@ #include #elif defined(ARDUINO_ARCH_ESP8266) #include -#elif defined(ARDUINO_ARCH_ESP32) +#elif defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_GIGA) #include #endif diff --git a/examples/WiFiEcho/WiFiEcho.ino b/examples/WiFiEcho/WiFiEcho.ino index 53ad4e3..e5e47ee 100644 --- a/examples/WiFiEcho/WiFiEcho.ino +++ b/examples/WiFiEcho/WiFiEcho.ino @@ -18,7 +18,7 @@ #include #elif defined(ARDUINO_ARCH_ESP8266) #include -#elif defined(ARDUINO_ARCH_ESP32) +#elif defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_GIGA) #include #endif diff --git a/examples/WiFiEchoCallback/WiFiEchoCallback.ino b/examples/WiFiEchoCallback/WiFiEchoCallback.ino index ef17c54..7f1afa9 100644 --- a/examples/WiFiEchoCallback/WiFiEchoCallback.ino +++ b/examples/WiFiEchoCallback/WiFiEchoCallback.ino @@ -19,7 +19,7 @@ #include #elif defined(ARDUINO_ARCH_ESP8266) #include -#elif defined(ARDUINO_ARCH_ESP32) +#elif defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_GIGA) #include #endif diff --git a/examples/WiFiSimpleReceive/WiFiSimpleReceive.ino b/examples/WiFiSimpleReceive/WiFiSimpleReceive.ino index 753989b..6af92a3 100644 --- a/examples/WiFiSimpleReceive/WiFiSimpleReceive.ino +++ b/examples/WiFiSimpleReceive/WiFiSimpleReceive.ino @@ -17,7 +17,7 @@ #include #elif defined(ARDUINO_ARCH_ESP8266) #include -#elif defined(ARDUINO_ARCH_ESP32) +#elif defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_GIGA) #include #endif diff --git a/examples/WiFiSimpleReceiveCallback/WiFiSimpleReceiveCallback.ino b/examples/WiFiSimpleReceiveCallback/WiFiSimpleReceiveCallback.ino index 4dc4b96..5f6c47a 100644 --- a/examples/WiFiSimpleReceiveCallback/WiFiSimpleReceiveCallback.ino +++ b/examples/WiFiSimpleReceiveCallback/WiFiSimpleReceiveCallback.ino @@ -18,7 +18,7 @@ #include #elif defined(ARDUINO_ARCH_ESP8266) #include -#elif defined(ARDUINO_ARCH_ESP32) +#elif defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_GIGA) #include #endif diff --git a/examples/WiFiSimpleSender/WiFiSimpleSender.ino b/examples/WiFiSimpleSender/WiFiSimpleSender.ino index b7f94bd..236a6e8 100644 --- a/examples/WiFiSimpleSender/WiFiSimpleSender.ino +++ b/examples/WiFiSimpleSender/WiFiSimpleSender.ino @@ -17,7 +17,7 @@ #include #elif defined(ARDUINO_ARCH_ESP8266) #include -#elif defined(ARDUINO_ARCH_ESP32) +#elif defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_GIGA) #include #endif diff --git a/library.properties b/library.properties index 79e24de..47629db 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ArduinoMqttClient -version=0.1.6 +version=0.1.7 author=Arduino maintainer=Arduino sentence=[BETA] Allows you to send and receive MQTT messages using Arduino. diff --git a/src/MqttClient.cpp b/src/MqttClient.cpp index 146e38f..221b230 100644 --- a/src/MqttClient.cpp +++ b/src/MqttClient.cpp @@ -105,7 +105,11 @@ MqttClient::~MqttClient() } } +#ifdef MQTT_CLIENT_STD_FUNCTION_CALLBACK +void MqttClient::onMessage(MessageCallback callback) +#else void MqttClient::onMessage(void(*callback)(int)) +#endif { _onMessage = callback; } @@ -562,7 +566,11 @@ void MqttClient::poll() _rxState = MQTT_CLIENT_RX_STATE_READ_PUBLISH_PAYLOAD; if (_onMessage) { +#ifdef MQTT_CLIENT_STD_FUNCTION_CALLBACK + _onMessage(this,_rxLength); +#else _onMessage(_rxLength); +#endif if (_rxLength == 0) { _rxState = MQTT_CLIENT_RX_STATE_READ_TYPE; @@ -585,7 +593,11 @@ void MqttClient::poll() _rxState = MQTT_CLIENT_RX_STATE_READ_PUBLISH_PAYLOAD; if (_onMessage) { +#ifdef MQTT_CLIENT_STD_FUNCTION_CALLBACK + _onMessage(this,_rxLength); +#else _onMessage(_rxLength); +#endif } if (_rxLength == 0) { diff --git a/src/MqttClient.h b/src/MqttClient.h index 007c4ba..522f023 100644 --- a/src/MqttClient.h +++ b/src/MqttClient.h @@ -32,17 +32,26 @@ #define MQTT_BAD_USER_NAME_OR_PASSWORD 4 #define MQTT_NOT_AUTHORIZED 5 +// Make this definition in your application code to use std::functions for onMessage callbacks instead of C-pointers: +// #define MQTT_CLIENT_STD_FUNCTION_CALLBACK + +#ifdef MQTT_CLIENT_STD_FUNCTION_CALLBACK +#include +#endif + class MqttClient : public Client { public: MqttClient(Client* client); MqttClient(Client& client); virtual ~MqttClient(); - +#ifdef MQTT_CLIENT_STD_FUNCTION_CALLBACK + typedef std::function MessageCallback; + void onMessage(MessageCallback callback); +#else inline void setClient(Client& client) { _client = &client; } - - void onMessage(void(*)(int)); +#endif int parseMessage(); String messageTopic() const; @@ -134,7 +143,11 @@ class MqttClient : public Client { private: Client* _client; +#ifdef MQTT_CLIENT_STD_FUNCTION_CALLBACK + MessageCallback _onMessage; +#else void (*_onMessage)(int); +#endif String _id; String _username; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy