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
I have being try to set get request to my nodejs Server. On the upload first time the connection with the server is extablished, later if reboted the server fails to connect
#include <EthernetENC.h>
#include "esp_system.h"
#include <Update.h>
#include <EthernetENC.h>
#include <SPI.h>
#include <EthernetClient.h>
uint8_t mac[6] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip = {192,168,131,183};
IPAddress bc = {255,255,255,255};
IPAddress subnet = {255,0,0,0};
uint8_t myDns[] = {192,168,131,1};
char buf[100];
char serverAddress[] = "60.254.18.10"; // Server IP address
int serverPort = 5000; // Server port
char temp[]="5000";
char path[] = "/?AUTH=adwdscsdc342423423rw@$@";
char host[] = "192.168.131.100:5000";
void setup(){
Serial.begin(115200);
Serial.println("Hello Esp32");
Ethernet.init(2);
Ethernet.begin(mac, ip, myDns, myDns, subnet);
int checkLink = Ethernet.linkStatus();
int checkHwd = Ethernet.hardwareStatus();
//Cabel & Hardware Check
while (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("ENC: not found");
delay(1000);
}
while (Ethernet.linkStatus() != LinkON){
Serial.println("ENC: cable not found");
delay(1000);
}
Serial.println(Ethernet.localIP());
GET(serverAddress,serverPort,"/checkOtaM/KVAR-1");
}
int count =0;
void loop(){
Ethernet.maintain();
delay(1000);
if(count==5){
ESP.restart();
}else{
count = count +1;
}
}
void GET(const char* host, int port, const char* path){
Serial.println("Check Status : Init");
EthernetClient ethClient2;
if (!ethClient2.connected()) { // Check if ethClient2 is not connected
//ethClient2.flush();
ethClient2.stop(); // Disconnect any previous connection
}
if (ethClient2.connect(host, port)) {
Serial.println("Connected to server");
// Send HTTP request
ethClient2.print("GET ");
ethClient2.print(path);
ethClient2.println(" HTTP/1.1");
ethClient2.print("Host: ");
ethClient2.println(host);
ethClient2.println("Connection: close");
ethClient2.println();
size_t totalBytesReceived = 0;
bool bodyStarted = false; // Flag to indicate if HTTP response body has started
String Body;
while (ethClient2.connected() || ethClient2.available()) {
if (ethClient2.available()) {
char c = ethClient2.read();
if (bodyStarted) {
// file.write(c);
Body = Body + c ;
totalBytesReceived++;
} else if (c == '\r' || c == '\n') {
// Check for end of headers
if (ethClient2.available() && ethClient2.peek() == '\r') {
// Skip '\r\n\r\n' which indicates the end of headers
ethClient2.read();
ethClient2.read();
bodyStarted = true;
}
}
} else {
delay(1);
}
}
Serial.println(" Check OTA Body: " + Body);
ethClient2.stop();
}
}
I have being try to set get request to my nodejs Server. On the upload first time the connection with the server is extablished, later if reboted the server fails to connect
Output
"rst:0x1 (POWERON_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
10:58:53.586 -> configsip: 0, SPIWP:0xee
10:58:53.586 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
10:58:53.586 -> mode:DIO, clock div:1
10:58:53.586 -> load:0x3fff0030,len:1184
10:58:53.586 -> load:0x40078000,len:13220
10:58:53.586 -> ho 0 tail 12 room 4
10:58:53.586 -> load:0x40080400,len:3028
10:58:53.586 -> entry 0x400805e4
10:58:53.727 -> Hello Esp32
10:58:53.773 -> 192.168.131.183
10:58:53.773 -> Check Status : Init
10:58:54.333 -> Connected to server
10:58:54.472 -> Check OTA Body: Master True
10:59:00.486 -> ets Jun 8 2016 00:22:57
10:59:00.486 ->
10:59:00.486 -> rst:0xc (SW_CPU_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
10:59:00.486 -> configsip: 0, SPIWP:0xee
10:59:00.486 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
10:59:00.486 -> mode:DIO, clock div:1
10:59:00.486 -> load:0x3fff0030,len:1184
10:59:00.486 -> load:0x40078000,len:13220
10:59:00.486 -> ho 0 tail 12 room 4
10:59:00.486 -> load:0x40080400,len:3028
10:59:00.486 -> entry 0x400805e4
10:59:00.672 -> Hello Esp32
10:59:00.719 -> 192.168.131.183
10:59:00.719 -> Check Status : Init
10:59:11.716 -> ets Jun 8 2016 00:22:57
10:59:11.716 ->
10:59:11.716 -> rst:0xc (SW_CPU_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
10:59:11.762 -> configsip: 0, SPIWP:0xee
10:59:11.762 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
10:59:11.762 -> mode:DIO, clock div:1
10:59:11.762 -> load:0x3fff0030,len:1184
10:59:11.762 -> load:0x40078000,len:13220
10:59:11.762 -> ho 0 tail 12 room 4
10:59:11.762 -> load:0x40080400,len:3028
10:59:11.762 -> entry 0x400805e4
10:59:11.902 -> Hello Esp32
10:59:11.948 -> ENC: cable not found
10:59:12.974 -> 192.168.131.183
10:59:12.974 -> Check Status : Init
10:59:24.011 -> ets Jun 8 2016 00:22:57
10:59:24.011 ->
10:59:24.011 -> rst:0xc (SW_CPU_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
10:59:24.011 -> configsip: 0, SPIWP:0xee
10:59:24.011 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
10:59:24.011 -> mode:DIO, clock div:1
10:59:24.011 -> load:0x3fff0030,len:1184
10:59:24.011 -> load:0x40078000,len:13220
10:59:24.011 -> ho 0 tail 12 room 4
10:59:24.011 -> load:0x40080400,len:3028
10:59:24.011 -> entry 0x400805e4
10:59:24.149 -> Hello Esp32
10:59:24.196 -> ENC: cable not found
10:59:25.209 -> 192.168.131.183
10:59:25.209 -> Check Status : Init
10:59:36.238 -> ets Jun 8 2016 00:22:57
10:59:36.238 ->
10:59:36.238 -> rst:0xc (SW_CPU_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
10:59:36.238 -> configsip: 0, SPIWP:0xee
10:59:36.238 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
10:59:36.238 -> mode:DIO, clock div:1
10:59:36.238 -> load:0x3fff0030,len:1184
10:59:36.238 -> load:0x40078000,len:13220
10:59:36.238 -> ho 0 tail 12 room 4
10:59:36.238 -> load:0x40080400,len:3028
10:59:36.238 -> entry 0x400805e4
10:59:36.424 -> Hello Esp32
10:59:36.469 -> ENC: cable not found
10:59:37.449 -> 192.168.131.183
10:59:37.449 -> Check Status : Init
10:59:48.486 -> ets Jun 8 2016 00:22:57
10:59:48.486 ->
10:59:48.486 -> rst:0xc (SW_CPU_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
10:59:48.486 -> configsip: 0, SPIWP:0xee
10:59:48.486 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
10:59:48.486 -> mode:DIO, clock div:1
10:59:48.486 -> load:0x3fff0030,len:1184
10:59:48.486 -> load:0x40078000,len:13220
10:59:48.486 -> ho 0 tail 12 room 4
10:59:48.486 -> load:0x40080400,len:3028
10:59:48.486 -> entry 0x400805e4
10:59:48.672 -> Hello Esp32
10:59:48.719 -> ENC: cable not found
10:59:49.687 -> 192.168.131.183
10:59:49.687 -> Check Status : Init
11:00:00.726 -> ets Jun 8 2016 00:22:57
11:00:00.726 ->
11:00:00.726 -> rst:0xc (SW_CPU_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
11:00:00.726 -> configsip: 0, SPIWP:0xee
11:00:00.726 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
11:00:00.726 -> mode:DIO, clock div:1
11:00:00.726 -> load:0x3fff0030,len:1184
11:00:00.726 -> load:0x40078000,len:13220
11:00:00.726 -> ho 0 tail 12 room 4
11:00:00.726 -> load:0x40080400,len:3028
11:00:00.726 -> entry 0x400805e4
11:00:00.912 -> Hello Esp32
11:00:00.960 -> ENC: cable not found
11:00:01.941 -> 192.168.131.183
11:00:01.941 -> Check Status : Init
"
The text was updated successfully, but these errors were encountered: