mirror of
https://github.com/me-no-dev/AsyncTCP.git
synced 2025-08-01 03:34:42 +02:00
update example
This commit is contained in:
@@ -2,14 +2,14 @@
|
|||||||
#include <AsyncTCP.h>
|
#include <AsyncTCP.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
|
|
||||||
// #define HOST "homeassistant.local"
|
// Run a server at the root of the project with:
|
||||||
// #define PORT 8123
|
// > python3 -m http.server 3333
|
||||||
|
// Now you can open a browser and test it works by visiting http://192.168.125.122:3333/ or http://192.168.125.122:3333/README.md
|
||||||
// #define HOST "www.google.com"
|
|
||||||
// #define PORT 80
|
|
||||||
|
|
||||||
#define HOST "192.168.125.122"
|
#define HOST "192.168.125.122"
|
||||||
#define PORT 4000
|
#define PORT 3333
|
||||||
|
|
||||||
|
// WiFi SSID to connect to
|
||||||
|
#define WIFI_SSID "IoT"
|
||||||
|
|
||||||
// 16 slots on esp32 (CONFIG_LWIP_MAX_ACTIVE_TCP)
|
// 16 slots on esp32 (CONFIG_LWIP_MAX_ACTIVE_TCP)
|
||||||
#define MAX_CLIENTS CONFIG_LWIP_MAX_ACTIVE_TCP
|
#define MAX_CLIENTS CONFIG_LWIP_MAX_ACTIVE_TCP
|
||||||
@@ -48,7 +48,7 @@ void makeRequest() {
|
|||||||
// Serial.printf("** data received by client: %" PRIu16 ": len=%u\n", client->localPort(), len);
|
// Serial.printf("** data received by client: %" PRIu16 ": len=%u\n", client->localPort(), len);
|
||||||
});
|
});
|
||||||
|
|
||||||
client->write("GET / HTTP/1.1\r\nHost: " HOST "\r\nUser-Agent: ESP\r\nConnection: close\r\n\r\n");
|
client->write("GET /README.md HTTP/1.1\r\nHost: " HOST "\r\nUser-Agent: ESP\r\nConnection: close\r\n\r\n");
|
||||||
});
|
});
|
||||||
|
|
||||||
if (client->connect(HOST, PORT)) {
|
if (client->connect(HOST, PORT)) {
|
||||||
@@ -63,7 +63,7 @@ void setup() {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
WiFi.begin("IoT");
|
WiFi.begin(WIFI_SSID);
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
delay(500);
|
delay(500);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
|
Reference in New Issue
Block a user