/*------------------------------------------------------------------------------------------------------------*/ void cgi_reset( void * pStruct ) { struct HTTP_REQUEST * http_request; http_request = (struct HTTP_REQUEST *) pStruct; cgi_PrintHttpheaderStart(); if ( http_request->argc == 0 ) { printf_P( PSTR( "<form action=\"reset.cgi\" method=\"get\" accept-charset=\"ISO-8859-1\">" "<p><input type=\"submit\" name=\"reset\" value=\"reset\"></p></form>" )); cgi_PrintHttpheaderEnd(); } else if( PharseCheckName_P( http_request, PSTR("reset") ) ) { if ( !strcmp_P( http_request->argvalue[ PharseGetValue_P( http_request, PSTR("reset") ) ] , PSTR("reset") ) ) { printf_P( PSTR("Reset")); cgi_PrintHttpheaderEnd(); STDOUT_Flush(); CloseTCPSocket( http_request->HTTP_SOCKET ); softreset(); while(1); } } }
/*------------------------------------------------------------------------------------------------------------*/ void cgi_aio( void * pStruct ) { struct HTTP_REQUEST * http_request; http_request = (struct HTTP_REQUEST *) pStruct; char i; char gpio[10]; int temp; /* printf_P( PSTR( "<HTML>" "<HEAD>" "<TITLE>ADC</TITLE>" "</HEAD>" "<BODY>"*/ cgi_PrintHttpheaderStart(); printf_P( PSTR( "<form action=\"dio.cgi\">" "<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\">" ) ); for( i = 0 ; i < MAX_ADC ; i++ ) { temp = ADC_mVolt( ADC_GetValue( i ) + 1 , 5000 ); printf_P( PSTR( "<tr>" "<td align=\"right\">ADC %d =</td>" "<td align=\"right\"> %d.%03dV</td>" "</tr>\r"), i, temp / 1000, temp % 1000 ); } printf_P( PSTR( "</table>" "</form>")); cgi_PrintHttpheaderEnd(); /* "</BODY>" "</HTML>\r\n" "\r\n")); */ }
/*------------------------------------------------------------------------------------------------------------*/ void cgi_eemem( void * pStruct ) { struct HTTP_REQUEST * http_request; http_request = (struct HTTP_REQUEST *) pStruct; cgi_PrintHttpheaderStart(); printf_P( PSTR( "<pre>")); PrintConfig (); printf_P( PSTR( "</pre>" )); cgi_PrintHttpheaderEnd(); }
void cgi_ntp( void * pStruct ) { struct HTTP_REQUEST * http_request; http_request = (struct HTTP_REQUEST *) pStruct; char NTPSERVER[32]; char UTCZONE[4]; cgi_PrintHttpheaderStart(); // Wenn keine Variablen übergeben wurden, dann Config ausgeben, // wenn Variablen übergeben wurden Config ändern if ( http_request->argc == 0 ) { readConfig_P( NTP_P, NTPSERVER ); printf_P( PSTR( "<form action=\"ntp.cgi\">\r" "<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\">" "<tr>" "<td align=\"right\">SNTP aktivieren</td>" "<td><input type=\"checkbox\" name=\"NTP\" value=\"on\" " )); if ( !strcmp_P( NTPSERVER, PSTR("on") ) ) printf_P( PSTR("checked")); printf_P( PSTR( "></td>" "</tr>") ); if( checkConfigName_P( NTP_P ) != -1 ) readConfig_P ( NTPSERVER_P, NTPSERVER ); else strcpy_P ( NTPSERVER, PSTR("time.fu-berlin.de")); if( checkConfigName_P( UTCZONE_P ) != -1 ) readConfig_P ( UTCZONE_P, UTCZONE ); else strcpy_P ( UTCZONE, PSTR("0")); printf_P( PSTR( "<tr>" "<td align=\"right\">SNTP-Server</td>" "<td><input name=\"NTPSERVER\" type=\"text\" size=\"25\" value=\"%s\" maxlength=\"25\"></td>" "</tr>" "<tr>" "<td align=\"right\">Zeitzone</td>" "<td><input name=\"UTCZONE\" type=\"text\" size=\"3\" value=\"%s\" maxlength=\"3\"></td>" "</tr>" "<tr>" "<td></td><td><input type=\"submit\" value=\" Einstellung Übernehmen \"></td>" "</tr>" "</table>" "</form>" ) , NTPSERVER, UTCZONE ); } else { if ( PharseCheckName_P( http_request, NTP_P ) ) changeConfig_P( NTP_P, http_request->argvalue[ PharseGetValue_P ( http_request, NTP_P ) ] ); else changeConfig_P( NTP_P, "off" ); if ( PharseCheckName_P( http_request, NTPSERVER_P ) ) changeConfig_P( NTPSERVER_P, http_request->argvalue[ PharseGetValue_P ( http_request, NTPSERVER_P ) ] ); if ( PharseCheckName_P( http_request, UTCZONE_P ) ) changeConfig_P( UTCZONE_P, http_request->argvalue[ PharseGetValue_P ( http_request, UTCZONE_P ) ] ); printf_P( PSTR("Einstellungen uebernommen!\r\n")); } cgi_PrintHttpheaderEnd(); }
void cgi_cron( void * pStruct ) { int i; char string[32]; int HH, MM; struct HTTP_REQUEST * http_request; http_request = (struct HTTP_REQUEST *) pStruct; cgi_PrintHttpheaderStart(); if ( http_request->argc == 0 ) { printf_P( PSTR( "<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\">" )); for( i = 0 ; i < MAX_CRON ; i++ ) { if ( CRON_getentry( string, i) == 1 ) { printf_P( PSTR( "<tr>" "<td align=\"left\">%s</td>" "<td align=\"left\">" "<a href=\"cron.cgi?del=%d\" style=\"text-decoration:none\" title=\"Del\"><input type=\"button\" value=\"del\" class=\"actionBtn\"></a>" "</td>" "</tr>"), string, i ); } } printf_P( PSTR( "<tr>" "<td align=\"left\">" "<a href=\"cron.cgi?addnew\" style=\"text-decoration:none\" title=\"Add\"><input type=\"button\" value=\"add new cron\" class=\"actionBtn\"></a>" "</td>" "</tr>" "</table>\r") ); } else { if ( PharseCheckName_P( http_request, PSTR("addnew") ) ) { printf_P( PSTR( "<form action=\"cron.cgi\">" "<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\">" "<tr>" "<td align=\"right\">Stunde</td><td><input name=\"HH\" type=\"text\" size=\"3\" value=\"0\"maxlength=\"3\"></td>" "</tr>" "<tr>" "<td align=\"right\">Minute</td>" "<td><input name=\"MM\" type=\"text\" size=\"3\" value=\"0\" maxlength=\"3\"></td>" "</tr>" "<tr>" "<td align=\"right\">Command</td>" "<td><input name=\"CMD\" type=\"text\" size=\"30\" maxlength=\"30\"></td>" "</tr>" "<tr>" "<td></td><td><input type=\"submit\" value=\" Eintrag sichern \"></td>" "</tr>" "</table>" "</form>\r" ) ); } else if ( PharseCheckName_P( http_request, PSTR("CMD") ) ) { HH = atoi( http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("HH") ) ] ); MM = atoi( http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("MM") ) ] ); sprintf_P( string, PSTR("%d %d \"%s\""), HH, MM, http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("CMD") ) ] ); CRON_addentry( string ); CRON_reloadcrontable(); printf_P( PSTR("Einstellungen uebernommen!\r\n")); } else if ( PharseCheckName_P( http_request, PSTR("del") ) ) { CRON_delentry( atoi( http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("del") ) ] ) ); CRON_reloadcrontable(); } } cgi_PrintHttpheaderEnd(); }
/*------------------------------------------------------------------------------------------------------------*/ void cgi_onewire( void * pStruct ) { struct HTTP_REQUEST * http_request; http_request = (struct HTTP_REQUEST *) pStruct; char id[8], diff; char i,VZ; int Temp; /* printf_P( PSTR( "<HTML>" "<HEAD>" "<TITLE>1-Wire</TITLE>" "</HEAD>" "<BODY>" */ cgi_PrintHttpheaderStart(); printf_P( PSTR( "<pre>" "Folgende Geraete wurden gefunden:\r\n")); // 1-Wire Gereäte suchen for( diff = SEARCH_FIRST; diff != LAST_DEVICE; ) { cli(); diff = ONEWIRE_searchrom( diff, id ); sei(); if( diff == PRESENCE_ERR ) { printf_P( PSTR("No Sensor found\r\n" )); break; } if( diff == DATA_ERR ) { printf_P( PSTR( "Bus Error\r\n" )); break; } // Device-ID ausgeben + familystring printf_P( PSTR( "ID: " ) ); for( i = 0; i < 7; i++ ) { printf_P( PSTR("%02X:"), id[i] ); } printf_P( PSTR("%02X ("), id[ i ] ); printf_P( ONEWIRE_getfamilycode2string ( id[0] ) ); // Auf tempsensor testen if ( DS16xxx_readtemp( id ) != 0x8000 ) { Temp = DS16xxx_readtemp( id ); if ( Temp < 0 ) VZ = '-'; else VZ = '+'; printf_P( PSTR(" %c%d.%01d C"), VZ, abs(Temp / 256) , abs((Temp << 8 ) / 6250 )); // 0.1øC } printf_P( PSTR(")\r\n")); } cgi_PrintHttpheaderEnd(); /*printf_P( PSTR( "</pre>" "</BODY>" "</HTML>" "\r\n\r\n")); */ }
/*------------------------------------------------------------------------------------------------------------*/ void cgi_network( void * pStruct ) { struct HTTP_REQUEST * http_request; http_request = (struct HTTP_REQUEST *) pStruct; unsigned char IP[32]; /* printf_P( PSTR( "<HTML>\r\n" "<HEAD>\r\n" "<TITLE>network</TITLE>\r\n" "</HEAD>\r\n" " <BODY>\r\n")); */ cgi_PrintHttpheaderStart(); if ( http_request->argc == 0 ) { printf_P( PSTR( "<pre>\r\n") ); #ifdef TELNETSERVER TELNET_runcmdextern_P( PSTR("ifconfig") ); TELNET_runcmdextern_P( PSTR("stats") ); #endif printf_P( PSTR( "</pre>\r\n") ); } else if( PharseCheckName_P( http_request, PSTR("config") ) ) { printf_P( PSTR( "<form action=\"network.cgi\">\r" " <table border=\"0\" cellpadding=\"5\" cellspacing=\"0\">" )); #ifdef DHCP readConfig_P( PSTR("DHCP"), IP ); printf_P( PSTR( " <tr>\r" " <td align=\"right\">DHCP aktivieren</td>" " <td><input type=\"checkbox\" name=\"DHCP\" value=\"on\" " )); if ( !strcmp_P( IP, PSTR("on") ) ) printf_P( PSTR("checked")); printf_P( PSTR( "></td>\r" " </tr>\r") ); #endif if ( readConfig_P ( PSTR("IP"), IP ) != 1 ) iptostr ( myIP, IP ); printf_P( PSTR( " <tr>\r" " <td align=\"right\">IP-Adresse</td>" " <td><input name=\"IP\" type=\"text\" size=\"15\" value=\"%s\" maxlength=\"15\"></td>" " </tr>\r") , IP ); if ( readConfig_P ( PSTR("MASK"), IP ) != 1 ) iptostr ( Netmask, IP ); printf_P( PSTR( " <tr>\r" " <td align=\"right\">Netzwerkmaske</td>" " <td><input name=\"MASK\" type=\"text\" size=\"15\" value=\"%s\" maxlength=\"15\"></td>" " </tr>\r") , IP ); if ( readConfig_P ( PSTR("GATE"), IP ) != 1 ) iptostr ( Gateway, IP ); printf_P( PSTR( " <tr>\r" " <td align=\"right\">Gateway</td>" " <td><input name=\"GATE\" type=\"text\" size=\"15\" value=\"%s\" maxlength=\"15\"></td>" " </tr>\r") , IP ); #ifdef DNS if ( readConfig_P ( PSTR("DNS"), IP ) != 1 ) iptostr ( DNSserver, IP ); printf_P( PSTR( " <tr>\r" " <td align=\"right\">DNS-Server</td>" " <td><input name=\"DNS\" type=\"text\" size=\"15\" value=\"%s\" maxlength=\"15\"></td>" " </tr>\r" ), IP ); #endif readConfig_P( PSTR("ETH_FLDX"), IP ); printf_P( PSTR( " <tr>\r" " <td align=\"right\">Fullduplex aktivieren</td>" " <td><input type=\"checkbox\" name=\"ETH_FLDX\" value=\"on\" " )); if ( !strcmp_P( IP, PSTR("on") ) ) printf_P( PSTR("checked")); printf_P( PSTR( "></td>\r" " </tr>\r") ); if ( readConfig_P ( PSTR("MAC"), IP ) != 1 ) mactostr( mymac, IP ); printf_P( PSTR( " <tr>\r" " <td align=\"right\">Hardware-MAC</td>" " <td><input name=\"MAC\" type=\"text\" size=\"17\" value=\"%s\" maxlength=\"17\"></td>" " </tr>\r" " <tr>\r" " <td></td><td><input type=\"submit\" value=\" Einstellung Übernehmen \"></td>" " </tr>\r" " </table>\r" "</form>") , IP ); } else { #ifdef DHCP if ( PharseCheckName_P( http_request, PSTR("DHCP") ) ) changeConfig_P( PSTR("DHCP"), http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("DHCP") ) ] ); else changeConfig_P( PSTR("DHCP"), "off" ); #endif if ( PharseCheckName_P( http_request, PSTR("IP") ) ) changeConfig_P( PSTR("IP"), http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("IP") ) ] ); if ( PharseCheckName_P( http_request, PSTR("MASK") ) ) changeConfig_P( PSTR("MASK"), http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("MASK") ) ] ); if ( PharseCheckName_P( http_request, PSTR("GATE") ) ) changeConfig_P( PSTR("GATE"), http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("GATE") ) ] ); #ifdef DNS if ( PharseCheckName_P( http_request, PSTR("DNS") ) ) changeConfig_P( PSTR("DNS"), http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("DNS") ) ] ); #endif if ( PharseCheckName_P( http_request, PSTR("MAC") ) ) changeConfig_P( PSTR("MAC"), http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("MAC") ) ] ); if ( PharseCheckName_P( http_request, PSTR("ETH_FLDX") ) ) changeConfig_P( PSTR("ETH_FLDX"), http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("ETH_FLDX") ) ] ); else changeConfig_P( PSTR("ETH_FLDX"), "off" ); printf_P( PSTR("Einstellungen uebernommen!\r\n")); } cgi_PrintHttpheaderEnd(); /* printf_P( PSTR( " </BODY>\r\n" "</HTML>\r\n" "\r\n"), IP); */ }