sprintf(test, "
P_Inst : %ld", papp);
plen=es.ES_fill_tcp_data(buf,plen,test);
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("</font></h3>") );
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
<img src='http://chart.apis.google.com/chart?chs=300x150&cht=gom&chco=00FF00,FFFF00,FF0000&chls=3|10,1,1&chd=t:") );
sprintf(test, "%ld&chds=0,8000&chl=%ld'>" ,papp,papp);
plen=es.ES_fill_tcp_data(buf,plen,test);
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
<a href='t.htm?cmd=1000'>Histo Conso</a>") );
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
<a href='t.htm?cmd=0'>Histo Puissance</a>") );
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
<a href='t.htm?cmd=1'>Valeurs Brut</a>") );
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("</html>") );
return(plen);
}
/////////////////////////////////////////////////////////
// affichage page Valeurs courantes Compteur
// !! Longueur max de trame Ethernet 600 Octets
/////////////////////////////////////////////////////////
uint16_t print_webpage4(uint8_t *buf)
{
uint16_t plen;
plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"));
sprintf(test, "<html><head><title>Tele %ldW</title></head>", papp);
plen=es.ES_fill_tcp_data(buf,plen,test);
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR(" <h2><font color=\"blue\">"));
sprintf(test, "
%d:%d:%d %d/%d/%d", hour(),minute(),second(),day(),month(),year());
plen=es.ES_fill_tcp_data(buf,plen,test);
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
ADCO = "));
plen=es.ES_fill_tcp_data(buf,plen,adco);
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
OPTARIF = "));
plen=es.ES_fill_tcp_data(buf,plen,optarif);
sprintf(test, "
ISOUSC = %ld", isousc);
plen=es.ES_fill_tcp_data(buf,plen,test);
sprintf(test, "
HCHC = %ld", hchc);
plen=es.ES_fill_tcp_data(buf,plen,test);
sprintf(test, "
HCHP = %ld", hchp);
plen=es.ES_fill_tcp_data(buf,plen,test);
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
PTEC = "));
plen=es.ES_fill_tcp_data(buf,plen,ptec);
sprintf(test, "
IINST = %ld", iinst);
plen=es.ES_fill_tcp_data(buf,plen,test);
sprintf(test, "
IMAX = %ld", imax);
plen=es.ES_fill_tcp_data(buf,plen,test);
sprintf(test, "
PAPP = %ld", papp);
plen=es.ES_fill_tcp_data(buf,plen,test);
sprintf(test, "
HHPHC = %c", hhphc);
plen=es.ES_fill_tcp_data(buf,plen,test);
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
MODETAT = "));
plen=es.ES_fill_tcp_data(buf,plen,motdetat);
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
</font></h2></html> ") );
return(plen);
}
/////////////////////////////////////////////////////////
// affichage page Historique
// !! Longueur max de trame Ethernet 600 Octets
/////////////////////////////////////////////////////////
uint16_t print_webpage2(uint8_t *buf,int cmd,char Pile_num)
{ // Attention 550 char Max
unsigned int base = DIM_ENTETE * Pile_num;
unsigned int Deb_pile = Read_int(base);
int Taille_pile = Read_int(base + 2);
long Time_wrap = Read_long(base+4);
int Interval = Read_int(base+8);
unsigned int Ptr = Read_int(base+ 10);
unsigned long Time_evt;
static int len = 10;
int pos_fin;
int pos_deb;
unsigned char value;
uint16_t plen;
int position;
plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"));
sprintf(test, "<html><head><title>Teleinfo Historique</title></head>");
plen=es.ES_fill_tcp_data(buf,plen,test);
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR(" <h2><font color=\"blue\">"));
if(Pile_num == 1) position =cmd;
if(Pile_num == 0) position =cmd-1000;
if (cmd ==0) position=0;
pos_fin = position +len;
pos_deb = position;
Time_evt = Time_wrap ;
sprintf(test, " %d/%d/%d
",day(Time_evt),month(Time_evt),year(Time_evt));
plen=es.ES_fill_tcp_data(buf,plen,test);
while (( position < pos_fin)&& (position <= Taille_pile))
{
if (position > Ptr) Time_evt = Time_wrap + ((position-Taille_pile-1)*Interval);
else Time_evt = Time_wrap +(position*Interval);
value = EEPROM.read(Deb_pile+position);
if(value < 255)
{
sprintf(test, "
%d:%d:%d", hour(Time_evt),minute(Time_evt),second(Time_evt));
plen=es.ES_fill_tcp_data(buf,plen,test);
if(Pile_num == 1)sprintf(test, " %5d W", (value*40));
if(Pile_num == 0)sprintf(test, " %5d Kw/h",value);
plen=es.ES_fill_tcp_data(buf,plen,test);
}
position++;
}
if(position - pos_deb ==len)
{
if(Pile_num == 0) position = position + 1000;
sprintf(test, "
<a href='t.html?cmd=%d'>></a>", position);
plen=es.ES_fill_tcp_data(buf,plen,test);
}
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
</font></h2></html> ") );
return(plen);
}
/////////////////////////////////////////////////////////
// affichage page Dump EEPROM
// !! Longueur max de trame Ethernet 600 Octets
/////////////////////////////////////////////////////////
uint16_t print_webpage3(uint8_t *buf,int cmd,char Pile_num)
{ // Attention 550 char Max
uint16_t plen;
int position;
plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<html><head><title>Teleinfo Dump</title></head> <h2><font color=\"blue\">"));
position=cmd-2000;
while ( position < cmd-2000+50)
{
sprintf(test, " %x;", EEPROM.read(position));
plen=es.ES_fill_tcp_data(buf,plen,test);
position++;
}
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
</font></h2></html> ") );
return(plen);
}
/////////////////////////////////////////////////////////////////////////
// Analyse des paramétre de la ligne de Commande
////////////////////////////////////////////////////////////////////////
int analyse_cmd(char *str)
{
int r=0;
int i=0;
if (find_key_val(str,"cmd"))
{ // is a ASCII number, return it
while (strbuf[i] < 0x3a && strbuf[i] > 0x2f)
{
r=(r*10)+(strbuf[i]-0x30);
i++;
}
}
else return (-1);
return r;
}