Kód: Vybrat vše
Odesli(CisloZarizeni, TypEventu, TextEventu);
Kód: Vybrat vše
Odesli(CisloZarizeni, TypEventu, TextEventu);
Kód: Vybrat vše
void loop() {
    if (millis() - cas >= 6000 || cas == 0) {
    cas = millis();
    if(client.connect(serverName, 80)){
        client.print("GET http://xxxx/eee/reset");
        client.print(ID_MODULU);
        client.print(".php");
        client.println(" HTTP/1.0"); 
        client.println("Host: xxxx.eu");
        client.println("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
        client.println("Connection: close");
        client.println();
        delay(1000);
        while (client.connected()) {
      String line = client.readStringUntil('\n');
     //   Serial.println(line); //ak chceme vypísať HTTP header
        if (line == "\r") {
          break;
        }
      }
      String line = client.readStringUntil('\n');
      Serial.println("Nacitany payload response:");
      Serial.println(line); //odpoveď webservera - naše dáta
      
      if(line == '1'){//&& PosledniStav == 0
                    digitalWrite(4, HIGH);
                    PosledniStav = 1;
                    OdesliZapnuto();
                    Serial.print("Posledni stav = ");
                    Serial.println(PosledniStav);
                }
      if(line == '0'){ // && PosledniStav == 1
                    digitalWrite(4, LOW);
                    PosledniStav = 0;
                    OdesliVypnuto();
                    Serial.print("Posledni stav = ");
                    Serial.println(PosledniStav);
                } 
    else {
      Serial.println("Pripojenie na webserver sa nepodarilo");
    }
    }
        client.stop();
    }
}Kód: Vybrat vše
   if(line == '1'){//&& PosledniStav == 0
                    digitalWrite(4, HIGH);
                    PosledniStav = 1;
                    OdesliZapnuto();
                    Serial.print("Posledni stav = ");
                    Serial.println(PosledniStav);
                }
      if(line == '0'){ // && PosledniStav == 1
                    digitalWrite(4, LOW);
                    PosledniStav = 0;
                    OdesliVypnuto();
                    Serial.print("Posledni stav = ");
                    Serial.println(PosledniStav);
                } Kód: Vybrat vše
17:26:20.485 -> ip-192.168.1.120
17:26:20.485 -> Subnet mask-255.255.255.0
17:26:20.530 -> Gateway-192.168.1.1
17:26:20.569 -> DNS-8.8.4.4
17:26:20.569 -> Cislo modulu-2
17:26:23.353 -> Nacitany payload response:
17:26:23.353 -> 0
17:26:23.353 -> Pripojenie na webserver sa nepodarilo
17:26:54.215 -> Nacitany payload response:
17:26:54.215 -> 0
17:26:54.215 -> Pripojenie na webserver sa nepodarilo
17:27:25.544 -> Nacitany payload response:
17:27:25.544 -> 0
Kód: Vybrat vše
void loop() {
    if (millis() - cas >= 6000 || cas == 0) {
		cas = millis();
		if(client.connect(serverName, 80)){
			client.print("GET http://xxxx/eee/reset");
			client.print(ID_MODULU);
			client.print(".php");
			client.println(" HTTP/1.0"); 
			client.println("Host: xxxx.eu");
			client.println("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
			client.println("Connection: close");
			client.println();
			delay(1000);
			while (client.connected()) {
				String line = client.readStringUntil('\n');
				//   Serial.println(line); //ak chceme vypísať HTTP header
					if (line == "\r") {
					break;
					}
			}
		String line = client.readStringUntil('\n');
		Serial.println("Nacitany payload response:");
		Serial.println(line); //odpoveď webservera - naše dáta
      
			if(line == '1'){//&& PosledniStav == 0
				digitalWrite(4, HIGH);
                PosledniStav = 1;
                OdesliZapnuto();
                Serial.print("Posledni stav = ");
                Serial.println(PosledniStav);
            }
			if(line == '0'){ // && PosledniStav == 1
                digitalWrite(4, LOW);
                PosledniStav = 0;
                OdesliVypnuto();
                Serial.print("Posledni stav = ");
                Serial.println(PosledniStav);
            }
		}
		else {
			Serial.println("Pripojenie na webserver sa nepodarilo");
		}
    client.stop();
    }
}
Kód: Vybrat vše
        while(client.available()){
            buffer[inBuffer] = client.read();    
            inBuffer++;Kód: Vybrat vše
while (client.connected()) {
      String line = client.readStringUntil('\n');
     //   Serial.println(line); //ak chceme vypísať HTTP header
        if (line == "\r") {
          break;
A s tou mou změnou (přesunul jsem závorku) to vypisuje co ?
Kód: Vybrat vše
// ty porovnáváš String, ten je dle mne zakončený nějakým znakem, tudíž to nemůže fungovat
// line je String a porovnáváš s char
if(line == '1')
//nemám to jak vyzkoušet, musel by jsi testnout co vrátí na serial "line.charAt(n)" n = 0 nebo 1 
// to vrací char z nějaké pozice z toho Stringu
// záleží na které pozici ta "0" nebo "1" je (mezery, ukončovací a jiné neviditelné znaky)
// pak bude fungovat, jen doplnit správné číslo do závorky
if(line.charAt(0) == '1')

Uživatelé prohlížející si toto fórum: Žádní registrovaní uživatelé a 1 host