Comments (2)
Hi @per1234
I appreciate your detailed explanation & tecnical dive in. I changed my code and things work fine now.
from arduinomqttclient.
Hi @ma-bg. This feature is only available when the MQTT_CLIENT_STD_FUNCTION_CALLBACK
macro is defined.
Unfortunately the comment in the source code regarding this is misleading:
ArduinoMqttClient/src/MqttClient.h
Lines 35 to 36 in f257432
The comment implies that you can simply add the #define
directive to the sketch:
MySketch.ino:
#define MQTT_CLIENT_STD_FUNCTION_CALLBACK
#include <ArduinoMqttClient.h>
// ...
But this is not possible. The reason is that this only defines the macro in the "translation unit" of the sketch, but not in the translation unit of MqttClient.cpp
, where the macro must also be defined. If the macro is not defined in that translation unit, you get an undefined reference
error.
There are two approaches to using the feature:
- Define the macro globally via a
-D
flag in the compilation command. - Define the macro in the library header file.
Arduino IDE 2.x does not provide an interface for the user to define arbitrary global macros so the former is only possible for Arduino IDE users by modifying the compilation command pattern in the boards platform. So the latter approach will be the best option for Arduino IDE users:
- Open the
MqttClient.h
file of your local installation of the library in any text editor. - Change line 36 from this:
ArduinoMqttClient/src/MqttClient.h
Line 36 in f257432
To this:#define MQTT_CLIENT_STD_FUNCTION_CALLBACK
- Save the file.
If you would like further assistance with the configuration of the library or the usage of this feature, you are welcome to post over on Arduino Forum:
I'm sure we'll be able to help you out over there.
from arduinomqttclient.
Related Issues (20)
- Return values of `MqttClient::subscribe` not documented HOT 4
- Unit of mqttClient.setKeepAliveInterval is undocumented HOT 1
- docs?
- QoS2 PUBREC causes connection drop
- Stuck on .poll()?
- Can't send retained messages HOT 2
- [Question] TLS PSK Authentication HOT 1
- SSL/TLS with Aduino UNO Wifi REV2 HOT 1
- This MQTT library needs IPv6 support
- can not set setKeepAliveInterval HOT 1
- MQTT not connecting to AWS IOT with MKR NB 15000 HOT 3
- Doesn't connect to ThingsBoard HOT 1
- Giga R1 WiFi works with a small change HOT 3
- Failure to connect to 127.0.0.1 (localhost) using Mosquitto Broker HOT 1
- Slow and then non responsive mqtt.read
- json string is "damaged" on transmitting HOT 2
- How to send MQTT server's username and password HOT 2
- mqttClient.connected() always 0 despite being connected HOT 3
- Add Uno R4 WiFi support to examples HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduinomqttclient.