From e1010a27b3e507f3b7ac5e237f2659bea6464dae Mon Sep 17 00:00:00 2001 From: copercini Date: Tue, 1 Aug 2017 13:34:32 -0300 Subject: [PATCH] Small improvements in update example - 100ms is too low to get server response --- .../AWS_S3_OTA_Update/AWS_S3_OTA_Update.ino | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libraries/Update/examples/AWS_S3_OTA_Update/AWS_S3_OTA_Update.ino b/libraries/Update/examples/AWS_S3_OTA_Update/AWS_S3_OTA_Update.ino index 432f2eebdf6..6da329676a9 100644 --- a/libraries/Update/examples/AWS_S3_OTA_Update/AWS_S3_OTA_Update.ino +++ b/libraries/Update/examples/AWS_S3_OTA_Update/AWS_S3_OTA_Update.ino @@ -31,8 +31,8 @@ bool isValidContentType = false; // Your SSID and PSWD that the chip needs // to connect to -char* SSID = "YOUR-SSID"; -char* PSWD = "YOUR-SSID-PSWD"; +const char* SSID = "YOUR-SSID"; +const char* PSWD = "YOUR-SSID-PSWD"; // S3 Bucket Config String host = "bucket-name.s3.ap-south-1.amazonaws.com"; // Host => bucket-name.s3.region.amazonaws.com @@ -65,7 +65,14 @@ void execOTA() { // "Cache-Control: no-cache\r\n" + // "Connection: close\r\n\r\n"); - delay(100); + unsigned long timeout = millis(); + while (client.available() == 0) { + if (millis() - timeout > 5000) { + Serial.println("Client Timeout !"); + client.stop(); + return; + } + } // Once the response is available, // check stuff