-
-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added optional onDelivery callback for publishing messages with QoS 1 and 2. #617
Conversation
Tested on real device and ready to use. |
@slaff : Nice extension.
|
@hreintke Thanks for the remarks
The main reason is backwards compatability. If I change the function signature the way you suggest that will break compatibility with already existing code and Sming users may not like it.
I am not sure if I understood you but there has to be a way to figure out whether a message was confirmed as delivered from the other side ( server ). Not every published message has delegates attached. Only the message ids for which the developer explicitly requested onDelivery callback.
Again I am not sure if I get the reason for this?! The onDelivery callback is per message! Not for the whole MqttClient. The use-case for that is that the developer can track the success of some messages. Those that she/he defines as important and requests onDelivery callback. Not all. |
@slaff : Sorry for later reply. I have been busy last days. Overload : Delegates per msg. |
@hreintke Agreed.
Hm... Think about the following use-case.
If I add a callback that is for a general callback for all delivered messages then outside of the MqttClient class the developer has to implement on his own a logic that reads the msgId and then adds a check in the onDeliveredAllMessages callback that compares the msgId that he/she is interested in with the one that is delivered. Which is doable but it would be much better if the class MqttClient already has this built-in. The onDeliveredMessage callback per message has encapsulated all the logic and the developer needs without forcing him to know the details of Mqtt communication. |
@slaff : The delegates within other parts of sming use the same methodology : there are different delegates for different functionality, but all are defined on "class level" and not on "message level" One other Mqtt related question. |
For QoS 1 the server returns PUBACK message as confirmation. For QoS 2 returns PUBREC message as confirmation and then the client has to do something more. For the onDelivery we are interested ONLY in confirmation from the server. And both QoS 1 and 2 are handled in the code. else if (type == MQTT_MSG_PUBACK || type == MQTT_MSG_PUBREC) {
Please, send me some sample code to understand your implementation for the above use-case. |
3d909ae
to
427dbaf
Compare
* upstream/develop: (21 commits) Added crash handler. Fixed/improved debugging information. (SmingHub#826) Enabled the SPIFFS. Fixed the HttpServer_Bootstrap example. (SmingHub#827) Added onDelivery callback for messages with QoS 1 or 2. (SmingHub#617) Backported changes from SmingRTOS. (SmingHub#825) Add FAST GPIO for CS pin and change pin numbering to start from 0 in MCP23S17 Lib (SmingHub#823) Fix issue SmingHub#709. Keep SPI_WR_BYTE_ORDER, SPI_RD_BYTE_ORDER, and SPI_CK_OUT_EDGE when upddating the SPI_USER reg (SmingHub#710) Fix stability and performance of websocket server (SmingHub#824) Fixed the SSL support for MQTT. Fixed Echo_Ssl sample. Feature/websocket client ssl (SmingHub#819) The latest spiffs is loaded as third-party module. (SmingHub#816) More efficient way to analyze errors. (SmingHub#821) Websocket client implementation for Sming (SmingHub#809) Simplified the compilation of custom PWM and Basic_HwPWM sample. (SmingHub#818) Removed test that is randomly braking on MacOS X travis machines. Adds / updates API documentation for: DateTime, Clock, Debug, NtpCient, RTC, SystemClock, some non-Sming (ESP) functions. (SmingHub#812) Fix/remove gdbstub (SmingHub#811) Fixes/freebsd (SmingHub#810) Proper timeout handling for Websockets (SmingHub#806) Added information about the SSL support. Fixed small typos. ... # Conflicts: # Sming/Makefile-project.mk
* upstream_develop: (43 commits) Added crash handler. Fixed/improved debugging information. (SmingHub#826) Enabled the SPIFFS. Fixed the HttpServer_Bootstrap example. (SmingHub#827) Added onDelivery callback for messages with QoS 1 or 2. (SmingHub#617) Backported changes from SmingRTOS. (SmingHub#825) Add FAST GPIO for CS pin and change pin numbering to start from 0 in MCP23S17 Lib (SmingHub#823) Fix issue SmingHub#709. Keep SPI_WR_BYTE_ORDER, SPI_RD_BYTE_ORDER, and SPI_CK_OUT_EDGE when upddating the SPI_USER reg (SmingHub#710) Fix stability and performance of websocket server (SmingHub#824) Fixed the SSL support for MQTT. Fixed Echo_Ssl sample. Feature/websocket client ssl (SmingHub#819) The latest spiffs is loaded as third-party module. (SmingHub#816) More efficient way to analyze errors. (SmingHub#821) Websocket client implementation for Sming (SmingHub#809) Simplified the compilation of custom PWM and Basic_HwPWM sample. (SmingHub#818) Removed test that is randomly braking on MacOS X travis machines. Adds / updates API documentation for: DateTime, Clock, Debug, NtpCient, RTC, SystemClock, some non-Sming (ESP) functions. (SmingHub#812) Fix/remove gdbstub (SmingHub#811) Fixes/freebsd (SmingHub#810) Proper timeout handling for Websockets (SmingHub#806) Added information about the SSL support. Fixed small typos. ... # Conflicts: # Sming/Makefile-project.mk # Sming/SmingCore/Network/HttpServer.cpp
Useful if you want to publish a message, make sure that it was delivered and execute a callback once the message was delivered.