SDK 1.5.1; makefile and html tweaks

pull/95/head
Thorsten von Eicken 8 years ago
parent 5dbebcd841
commit fa96de2fc0
  1. 24
      Makefile
  2. 94
      esp-link/cgiwifi.c
  3. 2
      html/home.html
  4. 17
      html/mqtt.html
  5. 68
      html/services.html
  6. 4
      html/style.css

@ -25,15 +25,15 @@
# The SOFTAP configuration can be hard-coded here, the minimum parameters to set are AP_SSID && AP_PASS
# The AP SSID has to be at least 8 characters long, same for AP PASSWORD
# The AP AUTH MODE can be set to:
# 0 = AUTH_OPEN,
# 1 = AUTH_WEP,
# 2 = AUTH_WPA_PSK,
# 3 = AUTH_WPA2_PSK,
# 4 = AUTH_WPA_WPA2_PSK
# 0 = AUTH_OPEN,
# 1 = AUTH_WEP,
# 2 = AUTH_WPA_PSK,
# 3 = AUTH_WPA2_PSK,
# 4 = AUTH_WPA_WPA2_PSK
# SSID hidden default 0, ( 0 | 1 )
# Max connections default 4, ( 1 ~ 4 )
# Beacon interval default 100, ( 100 ~ 60000ms )
#
# AP_SSID ?=esp_link_test
# AP_PASS ?=esp_link_test
# AP_AUTH_MODE ?=4
@ -41,10 +41,8 @@
# AP_MAX_CONN ?=4
# AP_BEACON_INTERVAL ?=100
# If CHANGE_TO_STA is set to "yes" the esp-link module will switch to station mode
# once successfully connected to an access point. Else it will stay in STA+AP mode.
CHANGE_TO_STA ?= yes
# hostname or IP address for wifi flashing
@ -58,7 +56,7 @@ XTENSA_TOOLS_ROOT ?= $(abspath ../esp-open-sdk/xtensa-lx106-elf/bin)/
# Base directory of the ESP8266 SDK package, absolute
# Typically you'll download from Espressif's BBS, http://bbs.espressif.com/viewforum.php?f=5
SDK_BASE ?= $(abspath ../esp_iot_sdk_v1.5.0)
SDK_BASE ?= $(abspath ../esp_iot_sdk_v1.5.1)
# Esptool.py path and port, only used for 1-time serial flashing
# Typically you'll use https://github.com/themadinventor/esptool
@ -387,15 +385,17 @@ flash: all
0x00000 "$(SDK_BASE)/bin/boot_v1.4(b1).bin" 0x01000 $(FW_BASE)/user1.bin \
$(ET_BLANK) $(SDK_BASE)/bin/blank.bin
ifeq ($(OS),Windows_NT)
tools/$(HTML_COMPRESSOR):
$(Q) mkdir -p tools
ifeq ($(OS),Windows_NT)
cd tools; wget --no-check-certificate https://github.com/yui/yuicompressor/releases/download/v2.4.8/$(YUI_COMPRESSOR) -O $(YUI_COMPRESSOR)
cd tools; wget --no-check-certificate https://htmlcompressor.googlecode.com/files/$(HTML_COMPRESSOR) -O $(HTML_COMPRESSOR)
else
else
tools/$(HTML_COMPRESSOR):
$(Q) mkdir -p tools
cd tools; wget https://github.com/yui/yuicompressor/releases/download/v2.4.8/$(YUI_COMPRESSOR)
cd tools; wget https://htmlcompressor.googlecode.com/files/$(HTML_COMPRESSOR)
endif
endif
ifeq ("$(COMPRESS_W_HTMLCOMPRESSOR)","yes")
$(BUILD_BASE)/espfs_img.o: tools/$(HTML_COMPRESSOR)

@ -128,9 +128,9 @@ void ICACHE_FLASH_ATTR wifiStartMDNS(struct ip_addr ip) {
mdns_info->server_name = flashConfig.mdns_servername;
mdns_info->server_port = 80;
mdns_info->ipAddr = ip.addr;
espconn_mdns_init(mdns_info);
espconn_mdns_init(mdns_info);
}
else {
else {
espconn_mdns_server_unregister();
espconn_mdns_close();
}
@ -304,7 +304,7 @@ static void ICACHE_FLASH_ATTR resetTimerCb(void *arg) {
int x = wifi_station_get_connect_status();
int m = wifi_get_opmode() & 0x3;
DBG("Wifi check: mode=%s status=%d\n", wifiMode[m], x);
if(m!=2){
if ( x == STATION_GOT_IP ) {
if (m != 1) {
@ -509,9 +509,9 @@ int ICACHE_FLASH_ATTR cgiWiFiSpecial(HttpdConnData *connData) {
// Change Soft-AP main settings
int ICACHE_FLASH_ATTR cgiApSettingsChange(HttpdConnData *connData) {
if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up.
// No changes for Soft-AP in STA mode
int mode = wifi_get_opmode();
if ( mode == 1 ){
@ -519,12 +519,10 @@ int ICACHE_FLASH_ATTR cgiApSettingsChange(HttpdConnData *connData) {
httpdSend(connData, "No changes allowed in STA mode", -1);
return HTTPD_CGI_DONE;
}
char buff[96];
int len;
// Do we need a password or auth mode?
bool pass_need=true;
// Check extra security measure, this must be 1
len=httpdFindArg(connData->getArgs, "100", buff, sizeof(buff));
if(len>0){
@ -540,32 +538,26 @@ int ICACHE_FLASH_ATTR cgiApSettingsChange(HttpdConnData *connData) {
os_memset(apconf.ssid, 0, 32);
os_memcpy(apconf.ssid, buff, len);
apconf.ssid_len = len;
pass_need = true; // ssid ok, look for a valid password
}else{
pass_need = false; // ssid wrong, neither pass nor auth mode are needed
jsonHeader(connData, 400);
httpdSend(connData, "SSID not valid or out of range", -1);
return HTTPD_CGI_DONE;
}
// Set new PASSWORD
if( pass_need ){
len=httpdFindArg(connData->getArgs, "ap_password", buff, sizeof(buff));
if(checkString(buff) && len>7 && len<64){
// String preprocessing done in client side, wifiap.js line 31
os_memset(apconf.password, 0, 64);
os_memcpy(apconf.password, buff, len);
pass_need = true; // pass ok, look for auth mode
}else if (len == 0){
pass_need = false; // pass wrong, don't look for auth mode
os_memset(apconf.password, 0, 64);
}else{
jsonHeader(connData, 400);
httpdSend(connData, "PASSWORD not valid or out of range", -1);
return HTTPD_CGI_DONE;
}
len=httpdFindArg(connData->getArgs, "ap_password", buff, sizeof(buff));
if(checkString(buff) && len>7 && len<64){
// String preprocessing done in client side, wifiap.js line 31
os_memset(apconf.password, 0, 64);
os_memcpy(apconf.password, buff, len);
}else if (len == 0){
os_memset(apconf.password, 0, 64);
}else{
jsonHeader(connData, 400);
httpdSend(connData, "PASSWORD not valid or out of range", -1);
return HTTPD_CGI_DONE;
}
// Set auth mode
if(pass_need){
if(len != 0){
// Set authentication mode, before password to check open settings
len=httpdFindArg(connData->getArgs, "ap_authmode", buff, sizeof(buff));
if(len>0){
@ -586,7 +578,7 @@ int ICACHE_FLASH_ATTR cgiApSettingsChange(HttpdConnData *connData) {
// Set max connection number
len=httpdFindArg(connData->getArgs, "ap_maxconn", buff, sizeof(buff));
if(len>0){
int value = atoi(buff);
if(value > 0 && value <= 4){
apconf.max_connection = value;
@ -619,14 +611,14 @@ int ICACHE_FLASH_ATTR cgiApSettingsChange(HttpdConnData *connData) {
}
// Store new configuration
wifi_softap_set_config(&apconf);
jsonHeader(connData, 200);
return HTTPD_CGI_DONE;
}
// Get current Soft-AP settings
int ICACHE_FLASH_ATTR cgiApSettingsInfo(HttpdConnData *connData) {
char buff[1024];
if (connData->conn == NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up.
os_sprintf(buff,
@ -645,7 +637,7 @@ int ICACHE_FLASH_ATTR cgiApSettingsInfo(HttpdConnData *connData) {
apconf.beacon_interval,
apconf.ssid_hidden ? "enabled" : "disabled"
);
jsonHeader(connData, 200);
httpdSend(connData, buff, -1);
return HTTPD_CGI_DONE;
@ -660,16 +652,16 @@ int ICACHE_FLASH_ATTR cgiWiFiSetMode(HttpdConnData *connData) {
len=httpdFindArg(connData->getArgs, "mode", buff, sizeof(buff));
int next_mode = atoi(buff);
if (len!=0) {
if (next_mode == 2){
// moving to AP mode, so disconnect before leave STA mode
wifi_station_disconnect();
}
DBG("Wifi switching to mode %d\n", next_mode);
wifi_set_opmode(next_mode&3);
if (previous_mode == 2) {
// moving to STA or STA+AP mode from AP, try to connect and set timer
stconf.bssid_set = 0;
@ -720,7 +712,7 @@ int ICACHE_FLASH_ATTR printWifiInfo(char *buff) {
wifi_station_get_config(&stconf);
//struct softap_config apconf;
wifi_softap_get_config(&apconf);
uint8_t op = wifi_get_opmode() & 0x3;
char *mode = wifiMode[op];
char *status = "unknown";
@ -739,14 +731,14 @@ int ICACHE_FLASH_ATTR printWifiInfo(char *buff) {
wifi_get_macaddr(0, mac_addr);
wifi_get_macaddr(1, apmac_addr);
uint8_t chan = wifi_get_channel();
len = os_sprintf(buff,
"\"mode\": \"%s\", \"modechange\": \"%s\", \"ssid\": \"%s\", \"status\": \"%s\", \"phy\": \"%s\", "
"\"rssi\": \"%ddB\", \"warn\": \"%s\", \"apwarn\": \"%s\",\"mac\":\"%02x:%02x:%02x:%02x:%02x:%02x\", \"chan\":\"%d\", \"apssid\": \"%s\", "
"\"appass\": \"%s\", \"apchan\": \"%d\", \"apmaxc\": \"%d\", \"aphidd\": \"%s\", \"apbeac\": \"%d\", \"apauth\": \"%s\",\"apmac\":\"%02x:%02x:%02x:%02x:%02x:%02x\"",
mode, MODECHANGE, (char*)stconf.ssid, status, phy, rssi, warn, apwarn,
mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5], chan, (char*)apconf.ssid,(char*)apconf.password,apconf.channel,apconf.max_connection,apconf.ssid_hidden?"enabled":"disabled",apconf.beacon_interval, apauth,apmac_addr[0], apmac_addr[1], apmac_addr[2], apmac_addr[3], apmac_addr[4], apmac_addr[5]);
struct ip_info info;
if (wifi_get_ip_info(0, &info)) {
len += os_sprintf(buff+len, ", \"ip\": \"%d.%d.%d.%d\"", IP2STR(&info.ip.addr));
@ -758,7 +750,7 @@ int ICACHE_FLASH_ATTR printWifiInfo(char *buff) {
}
len += os_sprintf(buff+len, ", \"staticip\": \"%d.%d.%d.%d\"", IP2STR(&flashConfig.staticip));
len += os_sprintf(buff+len, ", \"dhcp\": \"%s\"", flashConfig.staticip > 0 ? "off" : "on");
return len;
}
@ -835,34 +827,34 @@ int ICACHE_FLASH_ATTR checkString(char *str){
* Call a timer to check the STA connection
*/
void ICACHE_FLASH_ATTR wifiInit() {
// Check te wifi opmode
int x = wifi_get_opmode() & 0x3;
// Set opmode to 3 to let system scan aps, otherwise it won't scan
wifi_set_opmode(3);
// Call both STATION and SOFTAP default config
wifi_station_get_config_default(&stconf);
wifi_softap_get_config_default(&apconf);
DBG("Wifi init, mode=%s\n",wifiMode[x]);
// STATION parameters
#if defined(STA_SSID) && defined(STA_PASS)
// Set parameters
if (os_strlen((char*)stconf.ssid) == 0 && os_strlen((char*)stconf.password) == 0) {
os_strncpy((char*)stconf.ssid, VERS_STR(STA_SSID), 32);
os_strncpy((char*)stconf.password, VERS_STR(STA_PASS), 64);
DBG("Wifi pre-config trying to connect to AP %s pw %s\n",(char*)stconf.ssid, (char*)stconf.password);
// wifi_set_phy_mode(2); // limit to 802.11b/g 'cause n is flaky
stconf.bssid_set = 0;
wifi_station_set_config(&stconf);
}
#endif
// Change SOFT_AP settings if defined
#if defined(AP_SSID)
// Check if ssid and pass are alphanumeric values
@ -915,20 +907,20 @@ void ICACHE_FLASH_ATTR wifiInit() {
// Check softap config
bool softap_set_conf = wifi_softap_set_config(&apconf);
// Debug info
DBG("Wifi Soft-AP parameters change: %s\n",softap_set_conf? "success":"fail");
#endif // AP_SSID && AP_PASS
configWifiIP();
// The default sleep mode should be modem_sleep, but we set it here explicitly for good
// measure. We can't use light_sleep because that powers off everthing and we would loose
// all connections.
wifi_set_sleep_type(MODEM_SLEEP_T);
wifi_set_event_handler_cb(wifiHandleEventCb);
// check on the wifi in a few seconds to see whether we need to switch mode
os_timer_disarm(&resetTimer);
os_timer_setfn(&resetTimer, resetTimerCb, NULL);
os_timer_arm(&resetTimer, RESET_TIMEOUT, 0);
}
}

@ -126,7 +126,7 @@
<tr><td>Current partition</td><td class="system-partition"></td></tr>
<tr><td colspan=2 class="popup-target">Description:<br>
<div class="click-to-edit system-description">
<div class="edit-off"></div>
<span class="edit-off" style="display:block; width:auto;"></span>
<textarea class="edit-on" rows=3 maxlength=127 hidden> </textarea>
<div class="popup">Click to edit!<br>A short description or memo for this esp-link
module, 128 chars max</div>

@ -28,11 +28,14 @@
<div id="mqtt-spinner" class="spinner spinner-small"></div>
</h1>
<form action="#" id="mqtt-form" class="pure-form" hidden>
<input type="checkbox" name="mqtt-enable"/>
<label>Enable MQTT client</label>
<br>
<label>MQTT client state: </label>
<b id="mqtt-state"></b>
<div>
<input type="checkbox" name="mqtt-enable"/>
<label>Enable MQTT client</label>
</div>
<div>
<label>MQTT client state: </label>
<b id="mqtt-state"></b>
</div>
<br>
<legend>MQTT server settings</legend>
<div class="pure-form-stacked">
@ -68,11 +71,11 @@
<label>Enable status reporting via MQTT</label>
</div>
<br>
<legend>Status reporting settings</legend>
<div class="pure-form-stacked">
<label>Topic</label>
<label>Status topic</label>
<input type="text" name="mqtt-status-topic"/>
Message: <tt id="mqtt-status-value"></tt>
<div class="popup">MQTT topic to which status message is sent</div>
</div>
<button id="mqtt-status-button" type="submit" class="pure-button button-primary">
Update status settings!

@ -12,35 +12,41 @@
<div id="syslog-spinner" class="spinner spinner-small"></div>
</h1>
<form action="#" id="Syslog-form" class="pure-form" hidden>
<legend>Syslog settings</legend>
<div class="pure-form-stacked">
<label>Syslog Host</label>
<input type="text" name="syslog_host" />
<div class="popup">Use server [hostname:port] as UDP Syslog server</div>
<div class="popup">Esp-link sends event/debug info to this syslog host
(hostname:port). Leave empty to disable syslog.</div>
</div>
<div class="pure-form-stacked">
<label>Min Heap</label>
<input type="text" name="syslog_minheap" />
<label>Filter</label>
<select name="syslog_filter" href="#">
<option value="0">EMERG</option>
<option value="1">ALERT</option>
<option value="2">CRIT</option>
<option value="3">ERR</option>
<option value="4">WARNING</option>
<option value="5">NOTICE</option>
<option value="6">INFO</option>
<option value="7">DEBUG</option>
</select>
<div>
<input type="text" name="syslog_minheap" />
<div class="popup">Stop sending syslog if free heap drops below this many bytes</div>
</div>
<div>
<label>Filter</label>
<select name="syslog_filter" href="#">
<option value="0">EMERG</option>
<option value="1">ALERT</option>
<option value="2">CRIT</option>
<option value="3">ERR</option>
<option value="4">WARNING</option>
<option value="5">NOTICE</option>
<option value="6">INFO</option>
<option value="7">DEBUG</option>
</select>
<div class="popup">Minimum severity to send</div>
</div>
</div>
<div class="form-horizontal">
<label>Show ESP &#xb5;C Ticker in log message</label>
<div>
<input type="checkbox" name="syslog_showtick" />
<label>Include esp-link millisecond ticker</label>
</div>
<div class="form-horizontal">
<label>Show date in log message</label>
<div>
<input type="checkbox" name="syslog_showdate" />
<div class="popup">Synology does a log rotate if timestamp is in the past so disable to prevent this</div>
<label>Include esp-link datetime</label>
<div class="popup">Some syslog servers rotate log if timestamp is in the past so disable to prevent this</div>
</div>
<button id="Syslog-button" type="submit" class="pure-button button-primary">
Update Syslog settings!
@ -56,12 +62,14 @@
<div class="form-horizontal">
<input type="checkbox" name="mdns_enable"/>
<label>Enable mDNS</label>
<div class="popup">Esp-link can advertise its hostname and service name (both
with a .local suffix) via multicast DNS.</div>
</div>
<br>
<legend>mDNS server settings</legend>
<div class="pure-form-stacked">
<label>Server Name</label>
<label>Service Name</label>
<input type="text" name="mdns_servername"/>
<div class="popup">The default service is http. For the arduino IDE use arduino</div>
</div>
<button id="mDNS-button" type="submit" class="pure-button button-primary">
Update mDNS settings!
@ -76,12 +84,18 @@
<div id="sntp-spinner" class="spinner spinner-small"></div>
</h1>
<form action="#" id="SNTP-form" class="pure-form" hidden>
<legend>SNTP server settings</legend>
<div class="pure-form-stacked">
<label>Timezone Offset</label>
<input type="text" name="timezone_offset" />
<label>SNTP Server</label>
<input type="text" name="sntp_server" />
<div>
<label>SNTP Server</label>
<input type="text" name="sntp_server" />
<div class="popup">Simple Network Time Protocol server to query.
Leave empty to disable SNTP</div>
</div>
<div>
<label>Timezone Offset</label>
<input type="text" name="timezone_offset" />
<div class="popup">Offset hours to apply (no daylight savings support)</div>
</div>
</div>
<button id="SNTP-button" type="submit" class="pure-button button-primary">
Update SNTP settings!
@ -103,4 +117,4 @@ onLoad(function() {
bnd($("#mDNS-form"), "submit", changeServices);
});
</script>
</body></html>
</body></html>

@ -85,10 +85,10 @@ a:hover {
.popup, div.popup {
position: absolute;
/*top: 100%;*/
bottom: 100%;
bottom: 125%;
background-color: #fff0b3;
border-radius: 5px;
border: 0px solid #000;
border: 1px solid #e6b800;
color: #333;
font-size: 80%;
line-height: 110%;

Loading…
Cancel
Save