- AMD Ryzen 9 / 7 / 5 / 3 5***(X) "Zen 3" (AM4)
- Hobby elektronika
- Bluetooth hangszórók
- Radeon RX 9060 XT: Ezt aztán jól meghúzták
- OLED monitor topik
- Azonnali notebookos kérdések órája
- Azonnali alaplapos kérdések órája
- Teljesen az AI-ra fókuszál az új AMD Instinct sorozat
- Milyen billentyűzetet vegyek?
- AMD K6-III, és minden ami RETRO - Oldschool tuning
-
PROHARDVER!
Arduino hardverrel és szoftverrel foglakozó téma. Minden mikrovezérlő ami arduinoval programozható, és minden arduino program, board, és hardverrel kapcsolatos kérdések helye.
Új hozzászólás Aktív témák
-
Janos250
őstag
válasz
polgcsabi #17540 üzenetére
Ez meg egy minta WEB szerverre, eggyel magasabb szinten:
#include <iostream>
#include <string>
#include <WiFi.h>
#include <SPI.h>
using namespace std;
const char* ssid = "*********";
const char* password = "*********";
IPAddress ip(192, 168, 0, 30);
IPAddress dns(192, 168, 0, 1);
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 0, 0);
IPAddress primaryDNS(8, 8, 8, 8); //optional
IPAddress secondaryDNS(8, 8, 4, 4); //optional
WiFiServer myServer(80);
const char httpHeader[] PROGMEM = R"=====(
HTTP/1.1 200 OK
Content-type:text/html
Connection: close
)=====";
char htmlHeader[] PROGMEM = R"=====(
<!DOCTYPE html>
<html lang = hu >
<head>
<meta charset="UTF-8">
<title>minta WEB szerver</title>
</head>
)=====";
char body[] PROGMEM = R"=====(
<body>
Ez a kiirando
</body></html>
)=====";
void setup(void) {
Serial.begin(115200);
delay(2000);
WiFi.begin(ssid, password);
if(!WiFi.config(ip, gateway, subnet, dns, secondaryDNS)) {
Serial.println("STA Failed to configure");
}
Serial.print("Connecting to ");
Serial.println(ssid);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Print local IP address and start web server
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());// this will display the Ip address of the Pi which should be entered into your browser
myServer.begin();
Serial.println("setup lefutott");
} ; // end setup
void loop(void) {
string header = "";
uint16_t karakterszam = 0 ;
unsigned long previousTime = 0;
const long timeoutTime = 1000; //in milliseconds (example: 2000ms = 2s)
IPAddress tavoliIP ; // = uint8_t tavoliIP[4]
//https://randomnerdtutorials.com/esp32-web-server-arduino-ide/
WiFiClient client = myServer.available(); // Listen for incoming clients
if (client) {
tavoliIP = client.remoteIP() ;
printf("tavoli IP: %3d.%3d.%3d.%3d\n",tavoliIP[0],
tavoliIP[1],tavoliIP[2],tavoliIP[3]);
previousTime = millis();
// Serial.println();
// printf("\nNew Client\n");
String currentLine = "";
while (!client.available()){
if ( (millis()- previousTime) > 100 ) {
tavoliIP = client.remoteIP() ;
Serial.println(tavoliIP) ;
client.flush() ;
client.stop() ;
printf ("megszakitva\n");
return;
} ; // if ( (millis()- previousTime) > 100 )
} ; // while (!client.available())
while (client.connected() &&
( (millis() - previousTime) <= timeoutTime) ) {
if (client.available()) {
karakterszam++ ;
char c = client.read();
Serial.write(c);
header += c;
if (c == '\n') {
if (currentLine.length() == 0) {
break;
// printf ("ures sor\n");
}
else {
currentLine = "";
// printf ("uj sor\n");
}
} else
if (c != '\r') {
currentLine += c;
} ; // if (c != '\r')
} ; // if (client.available())
} ; // while (client.connected()
if (karakterszam == 0){
client.flush() ;
client.stop() ;
return;
} ; // if (karakterszam == 0)
// Serial.println(header.c_str());
client.println(httpHeader);
client.println(htmlHeader);
client.println(body);
client.flush();
client.stop(); // Close the connection
while (client.available()){
delay(1) ;
}; // while (client.connected())
} ; // if (client)
delay(50);
} ; // end loopAzért WEB, mert figyeli, hogy mikor jön közvetlenül egymás után két sorváltás, mert a http szerint az jelzi az üzenet végét.
Természetesen bármilyen beérkező szöveget figyelhetsz, és bármit válaszolhatsz rá, nem kell a headereket küldeni, ha nem WEB lap, amit elküldesz.Ezt használtam fel:
https://randomnerdtutorials.com/esp32-web-server-arduino-ide/
Új hozzászólás Aktív témák
- Apple Watch ultra 2 49mm Natur Titanium, Új, 1 év Apple garanciával
- Gamer PC - R5 5600, RTX 3060 és 16gb RAM + GARANCIA
- HP Zbook 14 laptop (14FHD/I7-G5/8GB/128SSD/MagyarVilágítós)
- Jó áron ÁRON ELADÓ! Üzleti HP Elitebook 1040 G9 Laptop! / i5-1245U 16GB 256GB
- Szuper áron DELL XPS 13 7390 /i7-10510U/16 GB Ram/512 GB SSD/IPS/
- ÁRGARANCIA!Épített KomPhone Ryzen 7 7800X3D 32/64GB RAM RX 9070 16GB GAMER PC termékbeszámítással
- Telefon felvásárlás!! Apple Watch SE/Apple Watch SE 2 (2022)
- Bomba ár! Dell Latitude 7320 - i5-11GEN I 8GB I 512SSD I HDMI I 13,3" FHD I Cam I W11 I Garancia!
- LG UltraGear Gaming Monitorok: FRISS SZÁLLÍTMÁNY -30%
- 10% -tól elvihető. Országosan a legjobb BANKMENTES részletfizetés! Lenovo Legion Pro 7
Állásajánlatok
Cég: CAMERA-PRO Hungary Kft
Város: Budapest
Cég: Liszt Ferenc Zeneművészeti Egyetem
Város: Budapest