Níže uvedený kód mi má pouze sestavit pole charu pro následné odeslaní přes Ethernet Shield.
Neřešte prosím HTML kód.
Chyba se momentalně projevuje tak že do konzole se patricny text vypisuje jen omezenou dou cca 20s a potom celý program zatuhne a musím stisknout RESET na ARDUINO chipu.
Do výsledného projektu a současně k testům používám Arduino Nano https://dratek.cz/arduino/936-ethernet- ... -nano.html
Kód: Vybrat vše
void loop() {
//CteniKlavesnice();
//CteniKlavesniceI2C();
// CteniDHT();
// CteniHladiny();
// BlikaniBUILDIN_LED();
// OvladaniRelatek();
//CteniCasuDS1302();
// ZapisOLED_SSD1306();
//ZapisLiquidDisplay();
CteniEthernetShield();
// char* b = IntToString(random());
// VypisDebugText(b);
// free(b);
delay(2000);
}
void CteniEthernetShield() {
String nactiOdpoved;
EthernetClient klient = server.available();
OdeslemeStandartniOdpoved(klient, 15);
}
void OdeslemeStandartniOdpoved(EthernetClient klient, int refresh) {
char buff[250];
buff[0] = 0;
strcat(buff, "HTTP/1.1 200 OK\n"); //klient.println("HTTP/1.1 200 OK");
strcat(buff, "Content-Type: text/html;charset=utf-8\n"); // klient.println("Content-Type: text/html;charset=utf-8");
strcat(buff, "Connection: close\n"); // klient.println("Connection: close");
if (refresh > 0) {
strcat(buff, "Refresh: ");
char d[12]; // klient.println("Refresh: 5");
itoa(refresh, d, 10);
strcat(buff, d);
strcat(buff, "<!DOCTYPE HTML>\n<html>\n"); // klient.println("<!DOCTYPE HTML>");
strcat(buff, "cas od spusteni: ");
itoa(millis() / 1000, d, 10); // klient.print(millis() / 1000);
strcat(buff, d);
strcat(buff, "\n</html>");
}
VypisDebugText(buff);
VypisDebugInfo("Delka textu %d", strlen(buff));
}
Teď celý program běžel cca 89s.
Spuštěno v "09:42:48.219 -> Server je na IP adrese: 192.168.0.220"
Ukončeno v "09:44:16.320"
Díky za každou radu