// ******************************************************************************
//
//
//  Version/Date    Comment
//   2026.05.28     - First release
// ******************************************************************************

#ifndef __TASK_WEB_SERVER_H__
#define __TASK_WEB_SERVER_H__


#define SYSTEM_FIRMWARE_NAME   "FirmwareName"
#define SYSTEM_CURRENT_YEAR    "2026"


const static char HTML_HEADER[] =
{ "HTTP/1.1 200 OK\r\n"
  "Connection: close\r\n"
  "Content-Type: text/html; charset=UTF-8\r\n"
   "\r\n"
   "<!DOCTYPE HTML>"
   "<html lang=\"en\">"
     "<head>"
       "<meta name=\"version\" content=\"%02X.%02X\" />"
       "<title>WEBSERVER Example %s%s</title>"
     "</head>"
     "<body style=\"font-family:arial,helvetica;\">"
       "<h2 style=\"background:#2b6246;color:#fff;width:400px;"
            "text-align:center;font-size:60px\">"
         "WEBSERVER"
       "</h2>"
};

const static char HTML_MENU[] =
  {"<p><a href='/'>HOME</a> - <a href='/d'>DEBUG</a></p>"};


const static char HTML_DEVICE_INFO[] =
  {"<table>"
#ifdef FREERTOS_PLUS_TCP
  "<tr><td>Software</td><td>:</td><td>" SYSTEM_FIRMWARE_NAME " (FreeRTOS kernel: %s, FreeRTOS_TCP: %s = %s)</td></tr>"
#endif
#ifdef FREERTOS_PLUS_LWIP
  #ifdef FREERTOS_PLUS_OPCUA
    "<tr><td>Software</td><td>:</td><td>" SYSTEM_FIRMWARE_NAME " (FreeRTOS kernel: %s, LwIp: %s, Open62541: %s - %s)</td></tr>"
  #else
    "<tr><td>Software</td><td>:</td><td>" SYSTEM_FIRMWARE_NAME " (FreeRTOS kernel: %s, LwIp: %s - %s)</td></tr>"
  #endif
#endif
  "<tr><td>Device</td><td>:</td><td>%s%s</td></tr>"
  "</table>"};

const static char HTML_PORT_INFO[] =
  {"<tr><td>LISTENING port</td><td>:</td><td>%d</td><td>(%s)</td><td>service</td><td>:</td><td>%s</td></tr>"};


const static char HTML_FOOTER[] =
{
       "<p style=\"font-size:14px;\">&copy; 2026-" SYSTEM_CURRENT_YEAR ", WebServer</p>"
     "</body>"
   "</html>"
};

const static char HTML_WRITE[] =
{
  "<h3>Databus tester</h3>"
  "<font color=\"red\">Only submit if the device is not running!</font>"
  "<form>"
    "Address/Data bus(hex): <input type=\"input\" name=\"b\" value=\"00\" maxlength=\"2\"/></br>"
    "<input type=\"checkbox\" name=\"w\" value=\"1\"/>Write</br>"
    "<input type=\"checkbox\" name=\"a\" value=\"1\"/>Address strobe</br>"
    "<input type=\"checkbox\" name=\"d\" value=\"1\"/>Data strobe</br>"
    "<input type=\"submit\" value=\"apply\"/>"
  "</form>"
};

const static char HTML_REDIRECT[] =
{ "HTTP/1.1 200 OK\r\n"
  "Connection: close\r\n"
  "Content-Type: text/html; charset=UTF-8\r\n"
   "\r\n"
   "<html>"
     "<head>"
       "<meta http-equiv=\"refresh\" content=\"%d; url=%s\" />"
     "</head>"
     "<body>"
       "Wait a moment while redirecting to %s page.<br/>"
};



extern void TaskWebServer_StartWebServerTasks( size_t uxTaskStackSize, UBaseType_t uxTaskPriority );

#endif // __TASK_WEB_SERVER_H__
