From 2968999f4fe0c5a348290a4ccba705a2da760585 Mon Sep 17 00:00:00 2001 From: brentru Date: Fri, 17 Sep 2021 12:15:17 -0400 Subject: [PATCH] potential fix for pin polling error --- src/Wippersnapper.cpp | 20 +++++++++----------- src/Wippersnapper.h | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Wippersnapper.cpp b/src/Wippersnapper.cpp index e424a0266..d7fd93292 100644 --- a/src/Wippersnapper.cpp +++ b/src/Wippersnapper.cpp @@ -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); @@ -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!"); } /**************************************************************************/ diff --git a/src/Wippersnapper.h b/src/Wippersnapper.h index 81019c990..31af45586 100644 --- a/src/Wippersnapper.h +++ b/src/Wippersnapper.h @@ -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