Système de gestion de DOME vidéo

Programmation:
(j'ai exclu les déclaration de variable et de librairie, ça évitera les copier coller bête et méchant :stuck_out_tongue: )

Partie 1: Le gestionnaire Régi !

Page web:

Partie commune: (pris et adapté d'un programme web exemple)

//(partie à modifier si rajout ou suppression de pages)
#define NUM_PAGES 5

// page erreur 404
PROGMEM prog_char content_404[] = "HTTP/1.1 404 Not Found\n Erreure \nContent-Type: text/html\n\n<html><head><title>STS Gestion des rondes - Error </title></head><body><h1>Une erreure est survenue veuillez nous en excusez...</h1></body>";
PGM_P page_404[] PROGMEM = { content_404 }; 


// HTML Header for pages
PROGMEM prog_char content_main_header[] = "HTTP/1.0 200 OK\nServer: arduino\nCache-Control: no-store, no-cache, must-revalidate\nPragma: no-cache\nConnection: close\nContent-Type: text/html \n";

PROGMEM prog_char content_main_top[] = "<html><head><title>STS Reglage des presets et des ronde </title><style type=text/css>...

PROGMEM prog_char content_main_top2[] = "Suite du CSS";
PROGMEM prog_char content_main_top3[] = "Suite du CSS";
PROGMEM prog_char content_main_top4[] = "</style></head><body><h11>S</h11><h22>T</h22><h33>S</h33>
<center>


<div class=debut><h1>Menu de gestion des rondes</h1></div>
 "; // Titre de la page web

PROGMEM prog_char content_main_menu[] = "<div class=gros>
<div id=tabs><center>"
"<li><a href=/page1 onclick=\"window.open('/page1','wclose','width=730,height=950,toolbar=no,status=no,left=-10,top=0')\"><span>Gestion module</span></a></li>"
"<li><a href=page2 onclick=\"window.open('page2','wclose','width=730,height=950,toolbar=no,status=no,left=-10,top=0')\"><span>Composition rondes</span></a></li>"
"<li><a href=page3 onclick=\"window.open('page3','wclose','width=730,height=950,toolbar=no,status=no,left=-10,top=0')\"><span>Definition preset</span></a></li>"
"<li><a href=page4 onclick=\"window.open('page4','wclose','width=730,height=950,toolbar=no,status=no,left=-10,top=0')\"><span>Planification rondes</span></a></li>"
"<li><a href=/ onclick=\"window.open('page5','wclose','width=730,height=950,toolbar=no,status=no,left=-10,top=0')\"><span>Notice d'utilisation</span></a></li>"
"</center></div>";// mon menu avec ouverture d'une fenêtre redimensionnée appart sur clique pour ceux que sa intéresse voila:
//<a href=/ onclick=\"window.open('page5','wclose','width=730,height=950,toolbar=no,status=no,left=-10,top=0')\">Notice d'utilisation</a>"

PROGMEM prog_char content_main_footer[] = "</div></body></html>";// fin de page 

PGM_P contents_main[] PROGMEM = { 
   content_main_header, content_main_top, content_main_top2, content_main_top3, content_main_top4, content_main_menu, content_main_footer }; // table de composition de la page web

#define CONT_HEADER 0
#define CONT_TOP 1
#define CONT_TOP2 2
#define CONT_TOP3 3
#define CONT_TOP4 4
#define CONT_MENU 5
#define CONT_FOOTER 6

(partie à modifier si rajout ou suppression de pages)
// table des titre de pages
PGM_P contents_titles[] PROGMEM = { 
  content_title1, content_title2, content_title3, content_title4, content_title5};
// tables des URL
PGM_P http_uris[] PROGMEM = { 
  http_uri1, http_uri2, http_uri3, http_uri4, http_uri5 }; 
// table des contenu de page
PGM_P contents_pages[] PROGMEM = { 
  content_page1, content_page2, content_page3, content_page4, content_page5};

struct HTTP_DEF 
{ int pages;
  char vars[STRING_VARS_SIZE]; // structure page web
};

//dans l'init:
EthernetServer server(80);
server.begin();

//dans le loop
EthernetClient client = server.available();
if (client) 
{ HTTP_DEF http_def = readHTTPRequest(client);
  if (http_def.pages > 0) 
  { sendPage(client,http_def); } 
  else 
  { http_def.pages=retien_pages;
    sendPage(client,http_def);
  }
  delay(25);
  client.stop(); 
}


struct HTTP_DEF readHTTPRequest(EthernetClient client) {
//... partie lecture pour récupérer les informations non détaillée, similaire à l’exemple, partie traitement détaillé page par page.
}


//impression de la page en plusieurs parties
void sendPage(EthernetClient client,struct HTTP_DEF http_def) {

  contentPrinter(client,(char*)pgm_read_word(&(contents_main[CONT_TOP])));//titre
  contentPrinter(client,(char*)pgm_read_word(&(contents_main[CONT_TOP2])));//CSS
  contentPrinter(client,(char*)pgm_read_word(&(contents_main[CONT_TOP3])));//CSS
  contentPrinter(client,(char*)pgm_read_word(&(contents_main[CONT_TOP4])));//CSS
  contentPrinter(client,(char*)pgm_read_word(&(contents_main[CONT_MENU])));//Menu

  contentPrinter(client,(char*)pgm_read_word(&(contents_titles[http_def.pages-1])));//corps de la page demandée
  sendContent(client,http_def.pages-1);

//affichage des Arduinos Dôme présent 1 à 9 max (sure toute les pages)
  client.print("
<center>Dome present : |");
  if(arduino_present[1]!=0){client.print(" 1 |");}
  if(arduino_present[2]!=0){client.print(" 2 |");}
  if(arduino_present[3]!=0){client.print(" 3 |");}
  if(arduino_present[4]!=0){client.print(" 4 |");}
  if(arduino_present[5]!=0){client.print(" 5 |");}
  if(arduino_present[6]!=0){client.print(" 6 |");}
  if(arduino_present[7]!=0){client.print(" 7 |");}
  if(arduino_present[8]!=0){client.print(" 8 |");}
  if(arduino_present[9]!=0){client.print(" 9 |");}

//ID du dôme séléctionné
  client.print("
Dome selectionnee : ");
  client.print(ID_dome);
 
//heure du système
  client.print("
");
  client.print(heure);
  client.print(":");
  client.print(minute);

//lien web + @ + n°tel 
  client.print("

");
  client.print("<FONT size=2><a href=\"http://www.xxxxxxxx/\" target=_blank>Notre site web</a>
");
  client.print("
Contacte: 04.xx.xx.xx.xx - email: xxx@xxxxx.net
SECURITE TECHNOLOGIE SERVICES</FONT></center>"); 
  
// bas de page
  contentPrinter(client,(char*)pgm_read_word(&(contents_main[CONT_FOOTER])));
}

//partie non modifié envoie de la page web
void contentPrinter(EthernetClient client, char *realword) {
  int total = 0;
  int start = 0;
  char buffer[STRING_BUFFER_SIZE];
  int realLen = strlen_P(realword);
  memset(buffer,0,STRING_BUFFER_SIZE);

  while (total <= realLen) {
    strncpy_P(buffer, realword+start, STRING_BUFFER_SIZE-1);
    client.print(buffer);

    total = start + STRING_BUFFER_SIZE-1;
    start = start + STRING_BUFFER_SIZE-1;
  }
}
void sendContent(EthernetClient client, int pageId) 
{
  contentPrinter(client,(char*)pgm_read_word(&(contents_pages[pageId])));
}