Skip to content
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

potential fix for pin polling error #152

Merged
merged 2 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/Wippersnapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1087,24 +1087,23 @@ void Wippersnapper::connect() {
// Register hardware with Wippersnapper
WS_DEBUG_PRINTLN("Registering hardware with WipperSnapper...")
setStatusLEDColor(LED_IO_REGISTER_HW);

if (!registerBoard()) {
haltError("Unable to register with WipperSnapper.");
}
feedWDT(); // Hardware registered with IO, feed WDT */
WS_DEBUG_PRINTLN("Registered with WipperSnapper.");

WS_DEBUG_PRINTLN("Polling for configuration message...");
WS._mqtt->processPackets(2000);

// did we get and process the registration message?
if (!WS.pinCfgCompleted)
haltError("Did not get configuration message from broker, resetting...");
runNetFSM();
feedWDT();

// Configure hardware
WS.pinCfgCompleted = false;
while (!WS.pinCfgCompleted) {
WS_DEBUG_PRINTLN("Polling for message containing hardware configuration...");
WS._mqtt->processPackets(10); // poll
}
// Publish that we have completed the configuration workflow
feedWDT();
runNetFSM();
publishPinConfigComplete();
WS_DEBUG_PRINTLN("Hardware configured successfully!");

// Run application
statusLEDBlink(WS_LED_STATUS_CONNECTED);
Expand Down Expand Up @@ -1138,7 +1137,6 @@ void Wippersnapper::publishPinConfigComplete() {
WS_DEBUG_PRINTLN("Publishing to pin config complete...");
WS.publish(WS._topic_device_pin_config_complete, _message_buffer,
_message_len, 1);
WS_DEBUG_PRINTLN("Completed registration process, configuration next!");
}

/**************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion src/Wippersnapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#endif

#define WS_VERSION \
"1.0.0-beta.9" ///< WipperSnapper app. version (semver-formatted)
"1.0.0-beta.10" ///< WipperSnapper app. version (semver-formatted)

// Reserved Adafruit IO MQTT topics
#define TOPIC_IO_THROTTLE "/throttle" ///< Adafruit IO Throttle MQTT Topic
Expand Down