-
Notifications
You must be signed in to change notification settings - Fork 307
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
Proposal to optionally run HomieNode::loop() also in disconnected state #490
Conversation
- $broadcast is handled and globalInputHandler is called - still many TODOs, e.g. support for other callbacks or splitted MQTT message (make use of payload buffer)
+ minor improvements
+ added comments to BootNormal.cpp to explain handling of incoming MQTT message
Dev broadcast
…into local-develop
* 📝 Add Gitter badge * 📝 Add link to the Gitter in the ISSUE_TEMPLATE * 🐛 Fix loopFunction being called too early before MQTT connection is established - closes homieiot#260 (homieiot#290) * 👕 Fix lint * ✨ Add destructor to HomieNode, that will abort() (homieiot#286) * Added destructor to HomieNode, that will abort() * 🎨 Log wifi client IP address upon connection. (homieiot#280) This removes the need to hunt the device IP when debugging connectivity issues. * 📝 Mention troubleshooting page in issue template * 👕 Fix cpplint failure, causing travis CI to be red (homieiot#291) E.g. https://travis-ci.org/marvinroger/homie-esp8266/jobs/199213998 Ran the following command successfully: cpplint --repository=. --recursive \ --filter=-whitespace/line_length,-legal/copyright,-runtime/printf,-build/include,-build/namespace,-runtime/int \ ./src * 🔥 Remove MQTT ack logging * 🐎 Make tiny optimizations * 🎨 Add a comma to the wifi connected log * 🎨 Reorganize next boot mode feature * 🐎 Check length on input fields (homieiot#292) * Fixing loopFunction being called too early before MQTT connection is established * Started cleanup of strcpy/sprintf to include length check. * Fixed warning under Interface.cpp * 👕 Fix lint * 🎨 Print firmware name and version at boot * 🐛 Fix DeviceId incomplete MAC address (homieiot#296) snprintf works with n-1 characters expected behaviour: DeviceId is 12 characters behaviour: only 11 characters are returned (resulting in a "incomplete" mac address) * :bug Fix millis() overflow in uptime - fix homieiot#299 (homieiot#302) Corrected type declaration for correct overflow handling of millis function in uptime calculation
* 📝 Add Gitter badge * 📝 Add link to the Gitter in the ISSUE_TEMPLATE * 🐛 Fix loopFunction being called too early before MQTT connection is established - closes homieiot#260 (homieiot#290) * 👕 Fix lint * ✨ Add destructor to HomieNode, that will abort() (homieiot#286) * Added destructor to HomieNode, that will abort() * 🎨 Log wifi client IP address upon connection. (homieiot#280) This removes the need to hunt the device IP when debugging connectivity issues. * 📝 Mention troubleshooting page in issue template * 👕 Fix cpplint failure, causing travis CI to be red (homieiot#291) E.g. https://travis-ci.org/marvinroger/homie-esp8266/jobs/199213998 Ran the following command successfully: cpplint --repository=. --recursive \ --filter=-whitespace/line_length,-legal/copyright,-runtime/printf,-build/include,-build/namespace,-runtime/int \ ./src * 🔥 Remove MQTT ack logging * 🐎 Make tiny optimizations * 🎨 Add a comma to the wifi connected log * 🎨 Reorganize next boot mode feature * 🐎 Check length on input fields (homieiot#292) * Fixing loopFunction being called too early before MQTT connection is established * Started cleanup of strcpy/sprintf to include length check. * Fixed warning under Interface.cpp * 👕 Fix lint * 🎨 Print firmware name and version at boot * 🐛 Fix DeviceId incomplete MAC address (homieiot#296) snprintf works with n-1 characters expected behaviour: DeviceId is 12 characters behaviour: only 11 characters are returned (resulting in a "incomplete" mac address) * :bug Fix millis() overflow in uptime - fix homieiot#299 (homieiot#302) Corrected type declaration for correct overflow handling of millis function in uptime calculation
@@ -97,6 +97,9 @@ void BootNormal::loop() { | |||
ESP.restart(); | |||
} | |||
|
|||
for (HomieNode* iNode : HomieNode::nodes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this moved? It may break functionality that assumes that loopFunction is executed before the individual node loop methods (for example). Or, in fact, all of the connection logic that is immediately below this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the loop is before the loop.
Prior the change, the loop-function was called as last. Now it is called first, so the order has not changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Maybe it's not so bad, but the end of the loop and the start are only the same if there's nothing else in the Arduino loop function.
I'm strongly opposed to this implementation. It could break existing HomieNodes that assume that the loop methods are only executed when MQTT is connected. Furthermore, if a particular HomieNode expects the runLoopDisconnected to be set to function correctly, then there is no way to enforce that and users may forget to set the flag, creating unexpected behaviour. I suggest to have two "loop" methods per HomieNode: one that only runs when connected (as currently) and one that runs even when disconnected. Then it is up to the implementation of each HomieNode to determine when the loop functionality should run. I'm also worried about unintended consequences of moving where the node loop methods are executed within the homie loop method. |
runLoopDisconnected is initialized to false, so the default behaviour has not changed. Furthermore, runLoopDisconnected is a field of HomieNode, so each HomieNode can set the flag itself. It even couldoverride the setter, so no one else can change this. |
OK. I take back my comments about runLoopDisconnected. I was a bit hasty; I thought it was a property of Homie rather than of the Node. I don't think you need a setter since the property is protected and it should only be set during the Node constructor. I still think it would be better with two loop methods for the Node, one which runs always and one which runs when connected. |
Compermise ? Pass is connected into the loop ? |
@nzbuu you're rigth with the setter. There is no need for it, if you can set the flag in constructor. I will add an optional parameter to |
Oh, and I don't see the benefit of passing a connected parameter to loop(), because it is easy to "ask" homie for it's current state. |
More for convenience But if this loop is running at max speed then asking for the status every look could slow down the loop speed ??? Idk |
Would be cool to have loops which are running without connection to build more robust controllers which are working without connections too. Any progress on this issue? |
…cted state (homieiot#490)" This reverts commit 9968042.
For this breaks all my existing HomieNodes. Previously I could assume that MQTT is ready when the HomieNode::loop() method is called. This is not the case any more and results in MQTT problems. My HomieNodes read sensor values in the loop method() and send them via MQTT. MQTT sending does not work any more as MQTT ready is not reached and SendPromise::send() refuses to send data if MQTT ready is not reached. |
…cted state (homieiot#490)" This reverts commit 9968042.
…cted state (homieiot#490)" This reverts commit 9968042.
See #354, #487