Comments (8)
Actually this would also fix a serious bug as creating a String from the payload using String(payload)
allocates another buffer with the exact copy.
from arduino-mqtt.
Is not very user friendly, but can be better!
You can add the sign if MQTTMessage in the readme or as comment in the examples?
from arduino-mqtt.
What is not very user friendly? The current implementation or this proposed change?
Sorry, I read your answer now various times but still don't get it... 😄
This would be a breaking change and result in releasing a v2.
from arduino-mqtt.
Sorry for the language ;)
I'm saying that a lot's of arduino users may not be friendly with data structures and usually in the libraries are avoided, but if you don't want to hack the MQTTClient.h code I agree that use the MQTTMessage in the callback is the best way.
I suggest that in the readme we should add the structure description, like:
typedef struct {
char * topic;
char * payload;
unsigned int length;
boolean retained;
} MQTTMessage;
or in the examples as a comment.
from arduino-mqtt.
Thanks for the clarifications.
I'm not yet fully convinced by my own idea, so I have to sleep on it again some time. ;)
I'll keep you updated.
from arduino-mqtt.
Note to myself: To support multiple clients at the same time the signature could even be updated to something like this:
void messageReceived(MQTTMessage msg, MQTTClient* client) {
Serial.print("incoming: ");
Serial.print(msg.topic());
Serial.print(" - ");
Serial.print(msg.payload());
Serial.println();
}
from arduino-mqtt.
Regarding #38 (comment), in general it would be nice to avoid pointers in the call back, as from my understanding most Arduino users aren't exposed to them.
from arduino-mqtt.
Has been simplified in #59.
from arduino-mqtt.
Related Issues (20)
- Unreliable behaviour with reconnections HOT 3
- MQTT HOT 1
- Websockets support HOT 3
- MQTT SSL connection issue with QoS1 and QoS2 messages HOT 1
- DCU: cannot connect to local MQTT broker HOT 1
- This library uses some posix functions that are not provided for Uno R4 HOT 3
- Subscribe query HOT 1
- Release version `v2.5.1` different of master version HOT 1
- 0
- Error connect MQTT SSL/TLS with module CBU use platform libretiny
- RP2040 seems to work fine HOT 2
- payload length / reconnect HOT 1
- Random error in MQTTClient::loop() function HOT 2
- Cosmetics only in MQTTClient.h / MQTTClient(...)
- Wrong version in README.md?
- ESP32 PSRAM for MQTT buffer?
- if available bytes on the network is available, close connection. HOT 1
- MQTT5 HOT 1
- subscribe fails HARD
- Connection is lost when second device is connected 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 arduino-mqtt.