Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
omersiar committed Apr 28, 2018
1 parent ade041f commit 4e85eed
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 57 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# Change Log
All notable changes to this project will be documented in this file.

## Unreleased
## [0.7.3] - 2018-04-28
#### Fixed
- [webui] comment out access types
- [firmware] fix compile warning
- [firmware] fix a compile warning
- [firmware] change startAP behaviour
- [firmware] publish username to MQTT broker
- [firmware] mqtt username password memory collusion

#### Removed
- [firmware] Modified header

## [0.7.3] - 2018-04-04
#### Added
Expand Down
Binary file modified bin/firmware.bin
Binary file not shown.
65 changes: 12 additions & 53 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ bool activateRelay = false;
bool inAPMode = false;
bool isWifiConnected = false;
int autoRestartIntervalSeconds = 0;
// Variable to hold the last modification datetime
char last_modified[50];

bool wifiDisabled = true;
bool doDisableWifi = false;
Expand Down Expand Up @@ -1124,99 +1122,61 @@ void ICACHE_FLASH_ATTR setupWebServer() {
// Inspect impact on memory, firmware size.

server.on("/fonts/glyphicons-halflings-regular.woff", HTTP_GET, [](AsyncWebServerRequest * request) {
// Check if the client already has the same version and respond with a 304 (Not modified)
if (request->header("If-Modified-Since").equals(last_modified)) {
request->send(304);

} else {
// Dump the byte array in PROGMEM with a 200 HTTP code (OK)
// Dump the byte array in PROGMEM with a 200 HTTP code (OK)
AsyncWebServerResponse * response = request->beginResponse_P(200, "font/woff", glyphicons_halflings_regular_woff_gz, glyphicons_halflings_regular_woff_gz_len);
// Tell the browswer the contemnt is Gzipped
response->addHeader("Content-Encoding", "gzip");
// And set the last-modified datetime so we can check if we need to send it again next time or not
response->addHeader("Last-Modified", last_modified);
request->send(response);
}

});

server.on("/css/required.css", HTTP_GET, [](AsyncWebServerRequest * request) {
// Check if the client already has the same version and respond with a 304 (Not modified)
if (request->header("If-Modified-Since").equals(last_modified)) {
request->send(304);

} else {

// Dump the byte array in PROGMEM with a 200 HTTP code (OK)
AsyncWebServerResponse * response = request->beginResponse_P(200, "text/css", required_css_gz, required_css_gz_len);
// Tell the browswer the contemnt is Gzipped
response->addHeader("Content-Encoding", "gzip");
// And set the last-modified datetime so we can check if we need to send it again next time or not
response->addHeader("Last-Modified", last_modified);
request->send(response);
}

});

server.on("/js/required.js", HTTP_GET, [](AsyncWebServerRequest * request) {
// Check if the client already has the same version and respond with a 304 (Not modified)
if (request->header("If-Modified-Since").equals(last_modified)) {
request->send(304);

} else {

// Dump the byte array in PROGMEM with a 200 HTTP code (OK)
AsyncWebServerResponse * response = request->beginResponse_P(200, "text/javascript", required_js_gz, required_js_gz_len);
// Tell the browswer the contemnt is Gzipped
response->addHeader("Content-Encoding", "gzip");
// And set the last-modified datetime so we can check if we need to send it again next time or not
response->addHeader("Last-Modified", last_modified);
request-> send(response);
}

});

server.on("/js/esprfid.js", HTTP_GET, [](AsyncWebServerRequest * request) {
// Check if the client already has the same version and respond with a 304 (Not modified)
if (request->header("If-Modified-Since").equals(last_modified)) {
request->send(304);

} else {

// Dump the byte array in PROGMEM with a 200 HTTP code (OK)
AsyncWebServerResponse * response = request->beginResponse_P(200, "text/javascript", esprfid_js_gz, esprfid_js_gz_len);
// Tell the browswer the contemnt is Gzipped
response->addHeader("Content-Encoding", "gzip");
// And set the last-modified datetime so we can check if we need to send it again next time or not
response->addHeader("Last-Modified", last_modified);
request-> send(response);
}

});

server.on("/index.html", HTTP_GET, [](AsyncWebServerRequest * request) {
// Check if the client already has the same version and respond with a 304 (Not modified)
if (request->header("If-Modified-Since").equals(last_modified)) {
request->send(304);

} else {
// Dump the byte array in PROGMEM with a 200 HTTP code (OK)
AsyncWebServerResponse * response = request->beginResponse_P(200, "text/html", index_html_gz, index_html_gz_len);
// Tell the browswer the contemnt is Gzipped
response->addHeader("Content-Encoding", "gzip");
// And set the last-modified datetime so we can check if we need to send it again next time or not
response->addHeader("Last-Modified", last_modified);
request->send(response);
}

});

server.on("/esprfid.htm", HTTP_GET, [](AsyncWebServerRequest * request) {
// Check if the client already has the same version and respond with a 304 (Not modified)
if (request->header("If-Modified-Since").equals(last_modified)) {
request->send(304);

} else {

// Dump the byte array in PROGMEM with a 200 HTTP code (OK)
AsyncWebServerResponse * response = request->beginResponse_P(200, "text/html", esprfid_htm_gz, esprfid_htm_gz_len);
// Tell the browswer the contemnt is Gzipped
response->addHeader("Content-Encoding", "gzip");
// And set the last-modified datetime so we can check if we need to send it again next time or not
response->addHeader("Last-Modified", last_modified);
request->send(response);
}

});

if (http_pass == NULL) {
Expand Down Expand Up @@ -1249,8 +1209,7 @@ void onWifiDisconnect(const WiFiEventStationModeDisconnected& event) {

// Set things up
void ICACHE_FLASH_ATTR setup() {
// Populate the last modification date based on build datetime
sprintf(last_modified, "%s %s GMT", __DATE__, __TIME__);

delay(2000);
Serial.begin(115200);
wifiDisconnectHandler = WiFi.onStationModeDisconnected(onWifiDisconnect);
Expand Down
4 changes: 2 additions & 2 deletions src/websrc/js/esprfid.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var config = {
"hostnm": "esp-rfid",
"restart": 0,
"pswd": "admin",
"version": "0.7.3"
"version": "0.7.4"
},
"mqtt": {
"enabled": 0,
Expand Down Expand Up @@ -1009,7 +1009,7 @@ function socketMessageListener(evt) {
break;
case "configfile":
config = obj;
config.general.version = "v0.7.3";
config.general.version = "v0.7.4";
break;
default:
break;
Expand Down

0 comments on commit 4e85eed

Please sign in to comment.