From 1f7f0e56477f1ccac0aa55a72dec0b8695ec1f35 Mon Sep 17 00:00:00 2001 From: Paul Mandel Date: Wed, 11 Apr 2018 17:57:59 -0700 Subject: [PATCH] Update pubSubTest.ino Prior to this change, certain network settings would yield `aws_iot: failed! mbedtls_net_connect returned -0x52` most of the time (though would occasionally work). -0x52 indicates a DNS problem. I honestly have no idea why that would be related to trying to execute `WiFi.begin(...)` more than once. However, this change resolves the error for me. --- .../examples/pubSubTest/pubSubTest.ino | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/arduino-esp32/AWS_IOT/examples/pubSubTest/pubSubTest.ino b/arduino-esp32/AWS_IOT/examples/pubSubTest/pubSubTest.ino index 6611a7f..21ebf81 100644 --- a/arduino-esp32/AWS_IOT/examples/pubSubTest/pubSubTest.ino +++ b/arduino-esp32/AWS_IOT/examples/pubSubTest/pubSubTest.ino @@ -28,18 +28,19 @@ void setup() { Serial.begin(115200); delay(2000); - while (status != WL_CONNECTED) + Serial.print("Attempting to connect to SSID: "); + Serial.println(WIFI_SSID); + + // Connect to WPA/WPA2 network. Change this line if using open or WEP network: + WiFi.begin(WIFI_SSID, WIFI_PASSWORD); + + while(WiFi.status() != WL_CONNECTED) { - Serial.print("Attempting to connect to SSID: "); - Serial.println(WIFI_SSID); - // Connect to WPA/WPA2 network. Change this line if using open or WEP network: - status = WiFi.begin(WIFI_SSID, WIFI_PASSWORD); - - // wait 5 seconds for connection: - delay(5000); + Serial.print("."); + delay(500); } - Serial.println("Connected to wifi"); + Serial.println("connected."); if(hornbill.connect(HOST_ADDRESS,CLIENT_ID)== 0) { @@ -90,4 +91,4 @@ void loop() { } vTaskDelay(1000 / portTICK_RATE_MS); tick++; -} \ No newline at end of file +}