Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNS not resolve the URL name after AP reconnection #49

Closed
Rocketct opened this issue Mar 7, 2019 · 0 comments · Fixed by arduino/nina-fw#13
Closed

DNS not resolve the URL name after AP reconnection #49

Rocketct opened this issue Mar 7, 2019 · 0 comments · Fixed by arduino/nina-fw#13
Assignees

Comments

@Rocketct
Copy link
Contributor

Rocketct commented Mar 7, 2019

Using the WiFiClient connenction API, affter a reboot of the access point the NINA module is not able to resolve the server url, defined in the sketch, the test case is:

  • Connect the board to the AP;
  • Call the WiFiclient connection API;
  • After the connection disable the AP and wait for module disconnection;
  • Enable again the AP, connect the board and call again the WiFiClient Connection.

In this last case some time the board stay connected to the access point but following the API chain called by the WiFiClient connection, the board is not able to resolve the host and get the IP address.
seems that in the f/w of the NINAthis line https://github.com/arduino/nina-fw/blob/master/arduino/libraries/WiFi/src/WiFi.cpp#L63 return NULL, i have used an arduino uno wifi rev 2 and the sketch used for the issue is:

#include <SPI.h>
#include <WiFiNINA.h>
#include <OneWire.h> //Using latest from Paul Stoffregen
//#include <Time.h>
//#include <TimeLib.h>
#include "arduino_secrets.h"


char ssid[] = SECRET_SSID;
char pass[] = SECRET_PASS;
int status = WL_IDLE_STATUS;

WiFiClient client;
IPAddress ip(192, 168, 0, 33);
//char server[] = "www.google.com"; 
IPAddress server(216,58,205,132);
void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ;
  }

  connectWiFi();
}

void loop() {

  if (client.available()) {
    char c = client.read();
    Serial.println("client available");
  }

  if (WiFi.status() != WL_CONNECTED) {
    Serial.println("tring to reconnect");
    Serial.println(WiFi.status());
    client.stop();
    WiFi.disconnect();
      connectWiFi();
  }
  delay(1000);

  if (client.connected()) {
    Serial.println("Connect ok");
    String celsius_string = "50";
    //Insert temp record into database
    client.println("POST /insert.php?Value=" + celsius_string + " HTTP/1.1");
    client.println("Host: www.***.***");
    //client.println("User-Agent: Arduino/1.0");
    client.println("Connection: close");
    //client.println("Content-Type: application/x-www-form-urlencoded; charset=UTF-8");
    //client.println("Content-Length: ");
    client.println();
    //Serial.println(WiFi.status());

  } else {
    Serial.println("not connected");
  }

  delay(5000);
}


void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

void connectWiFi() {
  status = WiFi.status();
  //WiFi.config(ip);
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    status = WiFi.begin(ssid, pass);
    delay(5000);
  }
  Serial.println("Connected to wifi");
  printWifiStatus();
  if (client.connect(server, 80)) {
    Serial.println("Connected");
  } else {
    client.stop();
    WiFi.disconnect();
    Serial.println("Not connected");
  }
}

@sandeepmistry sandeepmistry self-assigned this Mar 8, 2019
@Rocketct Rocketct changed the title DNS not resove the URL name after AP reconnection DNS not resolve the URL name after AP reconnection Mar 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants