This repository was archived by the owner on Jan 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -13,12 +13,13 @@ const char* password = "************";
13
13
14
14
void setup (){
15
15
Serial.begin (115200 );
16
- WiFi.mode (WIFI_STA);
17
16
WiFi.begin (ssid, password);
18
17
if (WiFi.waitForConnectResult () != WL_CONNECTED) {
19
18
Serial.printf (" WiFi Failed!\n " );
20
19
return ;
21
20
}
21
+ Serial.printf (" WiFi Connected!\n " );
22
+ Serial.println (WiFi.localIP ());
22
23
#ifdef ESP8266
23
24
ArduinoOTA.begin ();
24
25
#endif
@@ -29,14 +30,15 @@ void setup(){
29
30
return ;
30
31
}
31
32
client.setTimeout (2 );
32
- if (client.printf (" GET / HTTP/1.1\r\n Host: www.google.com\r\n\r\n " ) > 0 ){
33
- while (! client.available ())
33
+ if (client.printf (" GET / HTTP/1.1\r\n Host: www.google.com\r\n Connection: close \r\ n\r\n" ) > 0 ){
34
+ while (client.connected () && client. available () == 0 ){
34
35
delay (1 );
35
- while (client.connected ()){
36
- while (client.connected () && client.available () == 0 ) delay (1 );
37
- while (client.connected () && client.available ()){
38
- Serial.write (client.read ());
39
- }
36
+ }
37
+ while (client.available ()){
38
+ Serial.write (client.read ());
39
+ }
40
+ if (client.connected ()){
41
+ client.stop ();
40
42
}
41
43
} else {
42
44
client.stop ();
Original file line number Diff line number Diff line change @@ -257,7 +257,9 @@ int SyncClient::read(uint8_t *data, size_t len){
257
257
_rx_buffer = _rx_buffer->next ;
258
258
size_t toRead = b->available ();
259
259
readSoFar += b->read ((char *)(data+readSoFar), toRead);
260
- _client->ack (b->size () - 1 );
260
+ if (connected ()){
261
+ _client->ack (b->size () - 1 );
262
+ }
261
263
delete b;
262
264
}
263
265
if (_rx_buffer != NULL && readSoFar < len){
You can’t perform that action at this time.
0 commit comments