Skip to content

Commit

Permalink
potential fix for pin polling error
Browse files Browse the repository at this point in the history
  • Loading branch information
brentru committed Sep 17, 2021
1 parent 1058ab2 commit 2968999
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
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

0 comments on commit 2968999

Please sign in to comment.