You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having looked at many posts and spending several days on this, I still have an issue.
I have a RP2040 Connect which I want to query a web server from time to time (this could be , say, 50 times a day). It will use a GET query to connect via WiFi to the server then diagnose the data returned by the server. This all works, however, for the purpose of testing I've cut my code down to just send the GET query and read the reply and ignore what's returned. I've run this in a loop with no added delays so I can emulate the long term traffic from the RP2040 Connect to my web server in a couple of days.
But it's stopping after a couple of hours with a "No Socket available" sent to the Serial output (note, I've seen in other posts that people have asked where this comes from - it's not something coded by me so must be coded in the WiFiNina library).
In order to analyse what's happening I decided to add a graph to the logged data on my web server. I count the number of connections to the server over a 300 second window and this is the results:
As can be seen, the speed drops off then dies for a while and starts up again. I'm guessing (though haven't witnessed) the board is crashing and rebooting.
I decided to update the WiFiNina firmware. I was using 1.4.5 as is the latest available on the IDE I'm using, but followed a simple idea to force the latest version (1.4.8) by copying the necessary file in place of the 1.4.5 version. However, the result was much worse:
Having looked at many posts and spending several days on this, I still have an issue.
I have a RP2040 Connect which I want to query a web server from time to time (this could be , say, 50 times a day). It will use a GET query to connect via WiFi to the server then diagnose the data returned by the server. This all works, however, for the purpose of testing I've cut my code down to just send the GET query and read the reply and ignore what's returned. I've run this in a loop with no added delays so I can emulate the long term traffic from the RP2040 Connect to my web server in a couple of days.
But it's stopping after a couple of hours with a "No Socket available" sent to the Serial output (note, I've seen in other posts that people have asked where this comes from - it's not something coded by me so must be coded in the WiFiNina library).
In order to analyse what's happening I decided to add a graph to the logged data on my web server. I count the number of connections to the server over a 300 second window and this is the results:
As can be seen, the speed drops off then dies for a while and starts up again. I'm guessing (though haven't witnessed) the board is crashing and rebooting.
I decided to update the WiFiNina firmware. I was using 1.4.5 as is the latest available on the IDE I'm using, but followed a simple idea to force the latest version (1.4.8) by copying the necessary file in place of the 1.4.5 version. However, the result was much worse:
My testing code:
#include <SPI.h>
#include <WiFiNINA.h>
#include <String.h>
#define RLA 9
char ssid[] = "NETY"; // your network SSID (name)
char pass[] = "abcdefghi"; // your network password
String SerialNo = "123";
char* hostname = "AP_1";
char servername[] = "192.168.0.100";
String URLBase = "/go.php";
IPAddress dns1(8, 8, 8, 8);
IPAddress dns2(8, 8, 4, 4);
String MyIP;
int count = 0;
int status = WL_IDLE_STATUS;
String ret;
int ind1;
int ind2;
WiFiClient client;
/////////////////////////////////////////////////////////////
void setup() {
Serial.begin(9600);
Serial.println("Booting...");
ConnectToWifi();
}
/////////////////////////////////////////////////////////////
void loop() {
Serial.println();
String MyURL = URLBase + "serial=" + SerialNo + "&code=boot&lan=" + MyIP + "&debug=1&info=COUNT:" + count;
ReadWebPage(MyURL);
//delay(10);
}
/////////////////////////////////////////////////////////////
void TestWiFiConnection() {
int StatusWiFi = WiFi.status();
if (StatusWiFi == WL_CONNECTION_LOST || StatusWiFi == WL_DISCONNECTED || StatusWiFi == WL_SCAN_COMPLETED) {
Serial.println("WiFi connection not up!!");
ConnectToWifi();
}
}
/////////////////////////////////////////////////////////////
void ConnectToWifi() {
WiFi.disconnect();
WiFi.setHostname(hostname);
status = WiFi.status();
if (ScanSSIDs()) {
while ( status != WL_CONNECTED) {
Serial.print("Not connected, will try to connect to: "); Serial.println(ssid);
status = WiFi.begin(ssid, pass);
delay(500);
if (status == WL_CONNECTED) {
Serial.print("Connected to: "); Serial.println(ssid);
WiFi.setDNS(dns1, dns2);
printWifiData();
printCurrentNet();
MyIP = IPAddress2String(WiFi.localIP());
Serial.println("Connected to WiFi (" + String(MyIP) + ")");
String MyURL = URLBase + "serial=" + SerialNo + "&code=boot&lan=" + MyIP + "&info=WiFi_CONNECTED-COUNT=" + count;
Serial.println(MyURL);
ReadWebPage(MyURL);
} else {
delay(100);
}
}
}
count = 0;
}
/////////////////////////////////////////////////////////////
void ReadWebPage(String ToGet) {
count++;
Serial.print("COUNT: "); Serial.println(count);
Serial.print("URL: "); Serial.println(ToGet);
Serial.println("\nStarting connection...");
if (client.connectSSL(servername, 443)) {
Serial.print("Connected to: ");
Serial.println(servername);
client.print("GET ");
client.print(ToGet);
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(servername);
client.println("Connection: close");
client.println();
client.println();
ret = "";
char c;
while (client.connected()) {
while (client.available()) {
c = client.read();
ret += c;
}
}
} else {
Serial.print("Countn't connect to: ");
Serial.println(servername);
}
Serial.println(ret);
}
/////////////////////////////////////////////////////////////
char ScanSSIDs() {
char score=0;
Serial.print("Scanning SSID's, looking for: "); Serial.println(ssid);
int numSsid = WiFi.scanNetworks();
if (numSsid == -1) {
Serial.println("No SSID's can be seen...");
return (0);
}
for (int thisNet = 0; thisNet<numSsid; thisNet++) {
if (strcmp(WiFi.SSID(thisNet),ssid)==0) {
score=1;
Serial.print("SSID found: "); Serial.println(ssid);
return (score);
}
}
Serial.print("SSID NOT found: "); Serial.println(ssid);
return (score);
}
/////////////////////////////////////////////////////////////
void printWifiData() {
IPAddress ip=WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
byte mac[6];
WiFi.macAddress(mac);
Serial.print("MAC address: ");
printMacAddress(mac);
}
/////////////////////////////////////////////////////////////
void printCurrentNet() {
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
byte bssid[6];
WiFi.BSSID(bssid);
Serial.print("BSSID: ");
printMacAddress(bssid);
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.println(rssi);
byte encryption = WiFi.encryptionType();
Serial.print("Encryption Type:");
Serial.println(encryption, HEX);
Serial.println();
}
/////////////////////////////////////////////////////////////
void printMacAddress(byte mac[]) {
for (int i=5; i>=0; i--) {
if (mac[i]<16) {
Serial.print("0");
}
Serial.print(mac[i],HEX);
if (i > 0) {
Serial.print(":");
}
}
Serial.println();
}
/////////////////////////////////////////////////////////////
String IPAddress2String(const IPAddress& ipAddress) {
return String(ipAddress[0]) + String(".") +
String(ipAddress[1]) + String(".") +
String(ipAddress[2]) + String(".") +
String(ipAddress[3]);
}
The text was updated successfully, but these errors were encountered: