 
 //############################################################################
 //
+//                              OTA Updates
+//
+//############################################################################
+/*
+ * Function called to check for updates from the binary server
+ *   INPUT:  NA
+ *   Return: NA
+ */
+void checkForUpdates() {
+  #ifdef DEBUG
+    Serial.println(F("INFO:  OTA update check beginning..."));
+  #endif
+
+  // Make the server side call and hold onto the HTTP return status
+  t_httpUpdate_return state = ESPhttpUpdate.update(OTA_SERVER_IP, OTA_PORT, "/updater.php");
+
+  // Do something based on the response from the server
+  #ifdef DEBUG
+    switch (state) {
+      case HTTP_UPDATE_FAILED:
+        Serial.println(F("ERROR: OTA update failed."));
+        break;
+      case HTTP_UPDATE_NO_UPDATES:
+        Serial.println(F("INFO:  OTA update not available. Already running latest version."));
+        break;
+      case HTTP_UPDATE_OK:
+        Serial.println(F("INFO:  OTA update succeeded."));
+        break;
+    }
+  #endif
+}
+
+
+//############################################################################
+//
 //                            SETUP and LOOP
 //
 //############################################################################

  // Configure and connect to MQTT broker.
  g_mqttClient.setServer(MQTT_SERVER_IP, MQTT_SERVER_PORT);
  g_mqttClient.setCallback(callback);

  // Configure and initialize OTA listener.
  ArduinoOTA.setHostname(OTA_HOSTNAME);
  ArduinoOTA.setPassword(OTA_PASSWORD);
  ArduinoOTA.setPort(OTA_PORT);
  
  #ifdef DEBUG
    ArduinoOTA.onStart([]() {
      Serial.println(F("INFO:  OTA session started."));
    });
    ArduinoOTA.onEnd([]() {
      Serial.println(F("INFO:  OTA session ended."));
    });
    ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
      Serial.printf("INFO:  OTA rogress is %u%%\r", (progress / (total / 100)));
    });
    ArduinoOTA.onError([](ota_error_t error) {
      Serial.printf("ERROR: [%u] ", error);
      if (error == OTA_AUTH_ERROR) {
        Serial.println("Auth Failed");
      } else if (error == OTA_BEGIN_ERROR) {
        Serial.println("Begin Failed");
      } else if (error == OTA_CONNECT_ERROR) {
        Serial.println("Connect Failed");
      } else if (error == OTA_RECEIVE_ERROR) {
        Serial.println("Receive Failed");
      } else if (error == OTA_END_ERROR) {
        Serial.println("End Failed");
      }
    });
  #endif

  ArduinoOTA.begin();
}

/*

// MQTT: client ID, broker IP, port, username & password
const char*       MQTT_CLIENT_ID    = "<REDACTED>";
const char*       MQTT_SERVER_IP    = "<REDACTED>";
const uint8_t     MQTT_SERVER_PORT  = 1883;
const char*       MQTT_USERNAME     = "<REDACTED>";
const char*       MQTT_PASSWORD     = "<REDACTED>";

// OTA Information
const char*       OTA_SERVER_IP      = "<REDACTED>";
const uint8_t     OTA_PORT           = 80;

// MQTT: topics
// Interior: Living Room Side Lamp
