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. 26
      user/cgi.c
  8. 1
      user/cgi.h
  9. 3
      user/cgiwifi.c
  10. 27
      user/console.c
  11. 2
      user/user_main.c

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

@ -4,10 +4,8 @@
</head>
<body>
<div id="main">
<p><a href="/index.tpl">Home</a> | <a href="/wifi/wifi.tpl">Wifi</a> |
Serial | <a href="/led.tpl">LED</a></p>
<h1>ESP Link Help</h1>
<div id="topnav">%topnav%</div>
<h1><span class="esp">esp</span> link - Help</h1>
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

@ -4,24 +4,11 @@
</head>
<body>
<div id="main">
<p><a href="/index.tpl">Home</a> | <a href="/wifi/wifi.tpl">Wifi</a> |
Serial | <a href="/led.tpl">LED</a> | <a href="/help.tpl">Help</a> |
<a href="/console.tpl">Console</a>
</p>
<h1>ESP Link</h1>
<div id="topnav">%topnav%</div>
<h1><span class="esp">esp</span> link</h1>
<p>
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
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>
</body></html>

@ -3,7 +3,8 @@
</head>
<body>
<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>
If there's a LED connected to GPIO2, it's now %ledstate%. You can change that using the buttons below.
</p>

@ -7,15 +7,54 @@ body {
#main {
background-color: #FFFFCC;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
border: 2px solid #000000;
width: 800px;
margin: 0 auto;
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 {
background-image: url("/wifi/icons.png");
background-color: transparent;

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

@ -55,6 +55,8 @@ int ICACHE_FLASH_ATTR tplLed(HttpdConnData *connData, char *token, void **arg) {
} else {
os_strcpy(buff, "off");
}
} else if (os_strcmp(token, "topnav")==0) {
printNav(buff);
}
httpdSend(connData, buff, -1);
return HTTPD_CGI_DONE;
@ -64,13 +66,33 @@ static long hitCounter=0;
//Template code for the counter on the index page.
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 (os_strcmp(token, "counter")==0) {
if (os_strcmp(token, "topnav")==0) {
printNav(buff);
} else if (os_strcmp(token, "counter")==0) {
hitCounter++;
os_sprintf(buff, "%ld", hitCounter);
}
httpdSend(connData, buff, -1);
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 tplLed(HttpdConnData *connData, char *token, void **arg);
int tplCounter(HttpdConnData *connData, char *token, void **arg);
int printNav(char *buff);
#endif

@ -14,6 +14,7 @@ Cgi/template routines for the /wifi url.
#include <esp8266.h>
#include "cgiwifi.h"
#include "cgi.h"
#include "status.h"
//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.");
break;
}
} else if (os_strcmp(token, "topnav")==0) {
printNav(buff);
}
httpdSend(connData, buff, -1);
return HTTPD_CGI_DONE;

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

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

Loading…
Cancel
Save