-
Fototrend
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
Wolfram #19320 üzenetére
Nincs ez elbonyolítva.
Hirtelenjében ezt hoztam össze.
Ha erre gondoltál használd, ha nem, majd valakinek valamire hátha jó lesz.#define __cplusplus 201103L
#include <WiFi.h>
#include <WiFiClient.h>
#include <string>
#include <iostream>
#include <fstream> // ofstream
#include <stdio.h>
using namespace std;
#define remoteServerPort 80
//const char* ssid = "*********";
//const char* password = "*********";
uint8_t ServerIPlocal[] {192,168,0,30} ;
uint8_t gatewayIPlocal[] {192,168,0,1} ;
uint8_t subnetIPlocal[] {255,255,255,0} ;
WiFiServer remoteServer (remoteServerPort );
WiFiClient remoteServerClient ;
void setup() {
delay(1000);
Serial.begin(115200) ;
delay(1000);
WiFi.begin(ssid, password );
delay(2000);
WiFi.config(ServerIPlocal, gatewayIPlocal, subnetIPlocal) ;
WiFi.setAutoReconnect(true);
delay(2000);
printf("\nConnecting to %s \n",ssid);
uint8_t i = 0;
while (WiFi.status() != WL_CONNECTED && i++ < 20){
printf(".");
delay(500);
}
if(i == 21){
printf("\nCould not connect to \n",ssid);
while(1) delay(500);
} ;
string strMyURL = "http://"+
to_string(WiFi.localIP()[0])+"."+
to_string(WiFi.localIP()[1])+"."+
to_string(WiFi.localIP()[2])+"."+
to_string(WiFi.localIP()[3])+":"+
to_string(remoteServerPort)
;
printf("My URL: %s \n",strMyURL.c_str() );
uint8_t ip[]{192,168,0,33};
String valasz = httpGet((IPAddress)ip) ;
Serial.println(); Serial.println(); Serial.println(); Serial.println();
Serial.println("ez a valasz:");
Serial.println(valasz);
} // end setup
void loop() {
} ; // end loop
String httpGet(IPAddress ip){
const char GET_HTTP[] PROGMEM = R"=====(
GET / HTTP/1.1
)=====";
uint16_t idozites ;
String reply ;
WiFiClient remoteServerClient ;
if (!remoteServerClient.connect(ip,80)){
return "no connect";
Serial.println ("connect hiba");
} ;
// Serial.println ("connected");
remoteServerClient.println(GET_HTTP);
idozites = 0 ;
reply = "" ;
while (
remoteServerClient.available() ||
(idozites++ < 500)
) // rxBuffer->available()
{
if (remoteServerClient.available()){
char c=remoteServerClient.read();
idozites = 0 ;
reply += c ;
// printf("%c",c);
}
else{
delay(1);
}; // if (remoteServerClient.available())
} ; // end while (remoteServerClient.available())
// printf("\n");
remoteServerClient.stop(); // _rxBuffer = NULL; _connected = false;
// Serial.println();Serial.println();Serial.println();Serial.println();
// Serial.println("Ez a string");
// Serial.println(reply);
return reply ;
};
Új hozzászólás Aktív témák
- Napelem
- Nintendo Switch 2
- Okos Otthon / Smart Home
- Telekom otthoni szolgáltatások (TV, internet, telefon)
- Futás, futópályák
- Ventilátorok - Ház, CPU (borda, radiátor), VGA
- Hieronymus: A németországi vasúthálózat
- Forr az AI-láz, az Apple tőzsdei rekordját is túlszárnyalta az NVIDIA
- PROHARDVER! feedback: bugok, problémák, ötletek
- Milyen videókártyát?
- További aktív témák...
- Aful Explorer
- Lian Li ITX Gamer PC - AMD R5 5600, RX 6700 XT, 16GB, 1TB, Win11 Pro - ELADÓ!
- Újszerű Lenovo Thinkpad L14 G5 (Gen5) AMD Ryzen 5 7535U 16GB RAM 512GB SSD Win11Pro Gari: 25.09
- BESZÁMÍTÁS! MSI B450 R5 5500 16GB DDR4 512GB SSD RTX 2060 Super 8GB Rampage SHIVA TT 500W
- BESZÁMÍTÁS! GIGABYTE B660M i7 13700 32GB DDR4 512GB SSD RX 6800 16GB Thermaltake Core X5 GB 850W
- Xiaomi Redmi 10 128GB, Kártyafüggetlen, 1 Év Garanciával
- 35" ASUS ROG Swift PG35VQ curved GAMER monitor
- BESZÁMÍTÁS! Gigabyte A620M R5 7500F 32GB DDR5 500GB SSD RX 6700XT 12GB Cooler Master CMP 520L 750W
- Honor Magic7 Lite 8/512GB, Kártyafüggetlen
- AKCIÓ! ASRock B85M Pro4 B85 chipset alaplap garanciával hibátlan működéssel
Állásajánlatok
Cég: CAMERA-PRO Hungary Kft
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest