I understand but it is not done
can you test this code ?
WiFi connection :
// WiFi.begin(ssid, pass);
// SPI.begin();
// while (WiFi.status() != WL_CONNECTED)
// {
// delay(500);
// Serial.print(".");
// }
// Serial.println();
//
// Serial.print("Connected, IP address: ");
// Serial.println(WiFi.localIP());
Ethernet Connection :
eth.setDefault(); // use ethernet for default route
if (!eth.begin(mac)) {
Serial.println("ethernet hardware not found ... sleeping");
while (1) {
delay(1000);
}
} else {
Serial.print("connecting ethernet");
while (!eth.connected()) {
Serial.print(".");
delay(1000);
}
}
Main Code :
#include <WiFiClientSecure.h>
#include <ArduinoJson.h>
#include <FS.h>
#include "ESP8266httpUpdate.h"
#include <ENC28J60lwIP.h>
//#include <W5500lwIP.h>
#define CSPIN 15
//Wiznet5500lwIP eth(CSPIN);
ENC28J60lwIP eth(CSPIN);
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(23, 28, 179, 206);
class TLSClass {
public:
boolean TLS_Call(String command_get);
String AnsTLS = "";
String PrivateKey = "";
};
boolean TLSClass::TLS_Call(String command_get) {
boolean TLS = false;
// WiFi.mode(WIFI_OFF);
static bool wait = true;
Serial.print("connecting to ");
Serial.print("assess.mmaviot.com");
Serial.print(':');
Serial.println("443");
//WiFiClient client;
WiFiClientSecure client;
client.setTimeout(5000);
client.setInsecure();
if (client.connect("assess.mmaviot.com", 443)) {
Serial.println("connected to host");
client.print( String("GET ") + command_get + " HTTP/1.1\r\n" + "Host: " + "assess.mmaviot.com" + "\r\n" + "Connection: close" + "\r\n\r\n");
Serial.println("request sent");
Serial.flush();
char status[20] = {0};
client.readBytesUntil('\r', status, sizeof(status));
if (strcmp(status, "HTTP/1.1 200 OK") == 0)
{
Serial.println("Connection Success");
TLS = true;
while (client.connected()) {
char endOfHeaders[] = "\r\n\r\n";
if (client.find(endOfHeaders)) {
Serial.println(status);
String Data_Server = client.readString();
AnsTLS = Data_Server;
Serial.println(Data_Server);
}
}
}
else {
Serial.println("** Connection Failed **");
Serial.println(status);
}
Serial.println("receiving from remote server");
// not testing 'client.connected()' since we do not need to send data here
Serial.println("Print Data Available");
while (client.available()) {
char ch = static_cast<char>(client.read());
Serial.print(ch);
}
Serial.println("closing connection");
client.stop();
client.flush();
}
else
{
TLS = false;
Serial.println("***********************");
Serial.println("** Connection Failed **");
Serial.println("***********************");
delay(3000);
}
return TLS;
}
Result =>>
Over Radio : (it ok , & give 200 OK )
........
Connected, IP address: 192.168.1.107
-----------------------------------------
connecting to assess.mmaviot.com:443
connected to host
request sent
Connection Success
HTTP/1.1 200 OK
"a1d4f093527e7e7287984a38c2ee7514cb2f3f69d7cd972af65a92f7fd7bc98111e9165bd900804a06f0d7af47c9890db375a266013e8ce59f398f71c62b8e6345e752bc4bc1a5b44d57e5996c4fb49a224aa51a2a4043dee24b277be5c8a5190498ef05a9c3e35a049a9def399ab9bad83a42abb4320169132db015e1919acd547823d5e98e368d1b60ff6524ff93d4df55b32a757d7f36a8f5562f179cfb71ca1a3882593fe20a75c04dae513817d60437a81b5430682455718898f2b903d53af1c2103ab0b914320fcb090276886e"
receiving from remote server
Print Data Available
closing connection
Skeleton Data
Skelete : True !!!
Overt Ethernet Cable :
connecting ethernet...
ethernet IP address: 192.168.1.105
192.168.1.1
255.255.255.0
-----------------------------------------
connecting to assess.mmaviot.com:443
***********************
** Connection Failed **
***********************
Skelete : False
-----------------------------------------
connecting to assess.mmaviot.com:443
***********************
** Connection Failed **
***********************
Skelete : False
-----------------------------------------
connecting to assess.mmaviot.com:443
***********************
** Connection Failed **
***********************
Skelete : False
-----------------------------------------
connecting to assess.mmaviot.com:443
***********************
** Connection Failed **
***********************
Skelete : False
-----------------------------------------
connecting to assess.mmaviot.com:443
***********************
** Connection Failed **
***********************
I just change the connection type
over radio all ok , over ethernet connection faild (WiFiClientSecure)