update web pages

pull/7/head
Thorsten von Eicken 10 years ago
parent 47eb82c4d7
commit c55485cf61
  1. 5
      html/console.tpl
  2. 6
      html/help.tpl
  3. 17
      html/index.tpl
  4. 3
      html/led.tpl
  5. 45
      html/style.css
  6. 5
      html/wifi/wifi.tpl
  7. 34
      user/cgi.c
  8. 3
      user/cgi.h
  9. 3
      user/cgiwifi.c
  10. 31
      user/console.c
  11. 2
      user/user_main.c

@ -3,8 +3,9 @@
</head> </head>
<body> <body>
<div id="main"> <div id="main">
<h1>ESP Link - Debug Console</h1> <div id="topnav">%topnav%</div>
<pre> <h1><span class="esp">esp</span> link - Debug Console</h1>
<pre class="console">
%console% %console%
</pre> </pre>
</div> </div>

@ -4,10 +4,8 @@
</head> </head>
<body> <body>
<div id="main"> <div id="main">
<p><a href="/index.tpl">Home</a> | <a href="/wifi/wifi.tpl">Wifi</a> | <div id="topnav">%topnav%</div>
Serial | <a href="/led.tpl">LED</a></p> <h1><span class="esp">esp</span> link - Help</h1>
<h1>ESP Link Help</h1>
The ESP Link functions in two wifi modes: Station+AccessPoint (STA+AP) and Station (STA). The ESP Link functions in two wifi modes: Station+AccessPoint (STA+AP) and Station (STA).
In the STA+AP mode it presents a network called esp8266 that you can connect to using the In the STA+AP mode it presents a network called esp8266 that you can connect to using the

@ -4,24 +4,11 @@
</head> </head>
<body> <body>
<div id="main"> <div id="main">
<p><a href="/index.tpl">Home</a> | <a href="/wifi/wifi.tpl">Wifi</a> | <div id="topnav">%topnav%</div>
Serial | <a href="/led.tpl">LED</a> | <a href="/help.tpl">Help</a> | <h1><span class="esp">esp</span> link</h1>
<a href="/console.tpl">Console</a>
</p>
<h1>ESP Link</h1>
<p> <p>
The ESP Link connects the ESP's serial port to Wifi and it can The ESP Link connects the ESP's serial port to Wifi and it can
program microcontrollers over the serial port, in particular Arduinos, AVRs, and program microcontrollers over the serial port, in particular Arduinos, AVRs, and
NXP's LPC800-series ARM processors.</p> NXP's LPC800-series ARM processors.</p>
<h1>Status</h1>
<ul>
<li>This page has been loaded <b>%counter%</b> times</li>
<li>Manage <a href="/wifi">wifi</a></li>
<li>Control the <a href="led.tpl">LED</a></li>
</ul>
</p>
</div> </div>
</body></html> </body></html>

@ -3,7 +3,8 @@
</head> </head>
<body> <body>
<div id="main"> <div id="main">
<h1>ESP Link - LED test</h1> <div id="topnav">%topnav%</div>
<h1><span class="esp">esp</span> link - LED test</h1>
<p> <p>
If there's a LED connected to GPIO2, it's now %ledstate%. You can change that using the buttons below. If there's a LED connected to GPIO2, it's now %ledstate%. You can change that using the buttons below.
</p> </p>

@ -7,15 +7,54 @@ body {
#main { #main {
background-color: #FFFFCC; background-color: #FFFFCC;
-moz-border-radius: 5px; -moz-border-radius: 10px;
-webkit-border-radius: 5px; -webkit-border-radius: 10px;
border-radius: 5px; border-radius: 10px;
border: 2px solid #000000; border: 2px solid #000000;
width: 800px; width: 800px;
margin: 0 auto; margin: 0 auto;
padding: 20px padding: 20px
} }
h1 {
margin-top: 0;
font-size: 2.4em;
}
h1 .esp {
font-size: 3em;
}
#topnav {
background-color: #CC9966;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
border: 0px solid #000000;
padding: 10px;
margin-left: auto;
margin-right: auto;
color: #ffff99;
}
#topnav a {
color: #ffff99;
font-weight: bold;
font-stretch: expanded;
}
pre.console {
background-color: #663300;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
border: 0px solid #000000;
color: #66ff66;
padding: 5px;
}
pre.console a {
color: #66ff66;
}
.lock-icon { .lock-icon {
background-image: url("/wifi/icons.png"); background-image: url("/wifi/icons.png");
background-color: transparent; background-color: transparent;

@ -74,9 +74,8 @@ window.onload=function(e) {
</head> </head>
<body> <body>
<div id="main"> <div id="main">
<p><a href="/index.tpl">Home</a> | Wifi | Serial | <a href="/led.tpl">LED</a></p> <div id="topnav">%topnav%</div>
<h1><span class="esp">esp</span> link - Wifi Configuration</h1>
<h1>ESP Link - Wifi Configuration</h1>
<p> <p>
Current WiFi mode: %WiFiMode%<br> Current WiFi mode: %WiFiMode%<br>
Current network: %currSsid% Status: %currStatus% Phy:%currPhy% Current network: %currSsid% Status: %currStatus% Phy:%currPhy%

@ -6,9 +6,9 @@ flash as a binary. Also handles the hit counter on the main page.
/* /*
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42): * "THE BEER-WARE LICENSE" (Revision 42):
* Jeroen Domburg <jeroen@spritesmods.com> wrote this file. As long as you retain * Jeroen Domburg <jeroen@spritesmods.com> wrote this file. As long as you retain
* this notice you can do whatever you want with this stuff. If we meet some day, * this notice you can do whatever you want with this stuff. If we meet some day,
* and you think this stuff is worth it, you can buy me a beer in return. * and you think this stuff is worth it, you can buy me a beer in return.
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
*/ */
@ -25,7 +25,7 @@ static char currLedState=0;
int ICACHE_FLASH_ATTR cgiLed(HttpdConnData *connData) { int ICACHE_FLASH_ATTR cgiLed(HttpdConnData *connData) {
int len; int len;
char buff[1024]; char buff[1024];
if (connData->conn==NULL) { if (connData->conn==NULL) {
//Connection aborted. Clean up. //Connection aborted. Clean up.
return HTTPD_CGI_DONE; return HTTPD_CGI_DONE;
@ -55,6 +55,8 @@ int ICACHE_FLASH_ATTR tplLed(HttpdConnData *connData, char *token, void **arg) {
} else { } else {
os_strcpy(buff, "off"); os_strcpy(buff, "off");
} }
} else if (os_strcmp(token, "topnav")==0) {
printNav(buff);
} }
httpdSend(connData, buff, -1); httpdSend(connData, buff, -1);
return HTTPD_CGI_DONE; return HTTPD_CGI_DONE;
@ -64,13 +66,33 @@ static long hitCounter=0;
//Template code for the counter on the index page. //Template code for the counter on the index page.
int ICACHE_FLASH_ATTR tplCounter(HttpdConnData *connData, char *token, void **arg) { int ICACHE_FLASH_ATTR tplCounter(HttpdConnData *connData, char *token, void **arg) {
char buff[128]; char buff[256];
if (token==NULL) return HTTPD_CGI_DONE; if (token==NULL) return HTTPD_CGI_DONE;
if (os_strcmp(token, "counter")==0) { if (os_strcmp(token, "topnav")==0) {
printNav(buff);
} else if (os_strcmp(token, "counter")==0) {
hitCounter++; hitCounter++;
os_sprintf(buff, "%ld", hitCounter); os_sprintf(buff, "%ld", hitCounter);
} }
httpdSend(connData, buff, -1); httpdSend(connData, buff, -1);
return HTTPD_CGI_DONE; return HTTPD_CGI_DONE;
} }
static char *navLinks[][2] = {
{ "Home", "/index.tpl" }, { "Wifi", "/wifi/wifi.tpl" }, { "Serial", "/index.tpl" },
{ "Esp log", "/console.tpl" }, { "Help", "/help.tpl" },
{ 0, 0 },
};
// Print the navigation links into the buffer and return the length of what got added
int ICACHE_FLASH_ATTR printNav(char *buff) {
int len = 0;
for (uint8_t i=0; navLinks[i][0] != NULL; i++) {
if (i > 0) buff[len++] = '|';
//os_printf("nav %d: %s -> %s\n", i, navLinks[i][0], navLinks[i][1]);
len += os_sprintf(buff+len, " <a href=\"%s\">%s</a> ", navLinks[i][1], navLinks[i][0]);
}
//os_printf("nav: %s\n", buff);
return len;
}

@ -6,5 +6,6 @@
int cgiLed(HttpdConnData *connData); int cgiLed(HttpdConnData *connData);
int tplLed(HttpdConnData *connData, char *token, void **arg); int tplLed(HttpdConnData *connData, char *token, void **arg);
int tplCounter(HttpdConnData *connData, char *token, void **arg); int tplCounter(HttpdConnData *connData, char *token, void **arg);
int printNav(char *buff);
#endif #endif

@ -14,6 +14,7 @@ Cgi/template routines for the /wifi url.
#include <esp8266.h> #include <esp8266.h>
#include "cgiwifi.h" #include "cgiwifi.h"
#include "cgi.h"
#include "status.h" #include "status.h"
//Enable this to disallow any changes in AP settings //Enable this to disallow any changes in AP settings
@ -397,6 +398,8 @@ int ICACHE_FLASH_ATTR tplWlan(HttpdConnData *connData, char *token, void **arg)
os_strcpy(buff, "Click <a href=\"setmode.cgi?mode=1\">here</a> to go to STA mode."); os_strcpy(buff, "Click <a href=\"setmode.cgi?mode=1\">here</a> to go to STA mode.");
break; break;
} }
} else if (os_strcmp(token, "topnav")==0) {
printNav(buff);
} }
httpdSend(connData, buff, -1); httpdSend(connData, buff, -1);
return HTTPD_CGI_DONE; return HTTPD_CGI_DONE;

@ -1,5 +1,6 @@
#include <esp8266.h> #include <esp8266.h>
#include "uart.h" #include "uart.h"
#include "cgi.h"
#include "console.h" #include "console.h"
// Web console for the esp8266 to replace outputting to uart1. // Web console for the esp8266 to replace outputting to uart1.
@ -13,12 +14,13 @@ static int console_wr, console_rd;
static void ICACHE_FLASH_ATTR static void ICACHE_FLASH_ATTR
console_write(char c) { console_write(char c) {
int wr = (console_wr+1)%BUF_MAX; int wr = (console_wr+1)%BUF_MAX;
if (wr != console_rd) { if (wr == console_rd)
console_buf[console_wr] = c; console_rd = (console_rd+1) % BUF_MAX; // full, eat first char
console_wr = wr; console_buf[console_wr] = c;
} console_wr = wr;
} }
#if 0
static char ICACHE_FLASH_ATTR static char ICACHE_FLASH_ATTR
console_read(void) { console_read(void) {
char c = 0; char c = 0;
@ -28,10 +30,11 @@ console_read(void) {
} }
return c; return c;
} }
#endif
static void ICACHE_FLASH_ATTR static void ICACHE_FLASH_ATTR
console_write_char(char c) { console_write_char(char c) {
//uart0_write_char(c); uart0_write_char(c);
if (c == '\n') console_write('\r'); if (c == '\n') console_write('\r');
console_write(c); console_write(c);
} }
@ -40,18 +43,18 @@ console_write_char(char c) {
int ICACHE_FLASH_ATTR int ICACHE_FLASH_ATTR
tplConsole(HttpdConnData *connData, char *token, void **arg) { tplConsole(HttpdConnData *connData, char *token, void **arg) {
if (token==NULL) return HTTPD_CGI_DONE; if (token==NULL) return HTTPD_CGI_DONE;
char buff[256];
if (os_strcmp(token, "console") == 0) { if (os_strcmp(token, "console") == 0) {
char buf[128]; if (console_wr > console_rd) {
int n = 0; httpdSend(connData, console_buf+console_rd, console_wr-console_rd);
while (console_rd != console_wr) { } else if (console_rd != console_wr) {
buf[n++] = console_read(); httpdSend(connData, console_buf+console_rd, BUF_MAX-console_rd);
if (n == 128) { httpdSend(connData, console_buf, console_wr);
httpdSend(connData, buf, n);
n = 0;
}
} }
if (n > 0) httpdSend(connData, buf, n); } else if (os_strcmp(token, "topnav")==0) {
printNav(buff);
httpdSend(connData, buff, -1);
} else { } else {
httpdSend(connData, "Unknown\n", -1); httpdSend(connData, "Unknown\n", -1);
} }

@ -64,8 +64,8 @@ HttpdBuiltInUrl builtInUrls[]={
{"/flash/next", cgiGetFirmwareNext, NULL}, {"/flash/next", cgiGetFirmwareNext, NULL},
{"/flash/upload", cgiUploadFirmware, NULL}, {"/flash/upload", cgiUploadFirmware, NULL},
{"/flash/reboot", cgiRebootFirmware, NULL}, {"/flash/reboot", cgiRebootFirmware, NULL},
{"/led.tpl", cgiEspFsTemplate, tplLed},
{"/index.tpl", cgiEspFsTemplate, tplCounter}, {"/index.tpl", cgiEspFsTemplate, tplCounter},
{"/help.tpl", cgiEspFsTemplate, tplCounter},
{"/led.cgi", cgiLed, NULL}, {"/led.cgi", cgiLed, NULL},
{"/console.tpl", cgiEspFsTemplate, tplConsole}, {"/console.tpl", cgiEspFsTemplate, tplConsole},

Loading…
Cancel
Save