Skip to content

Commit

Permalink
Merge pull request #106 from omersiar/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
omersiar authored Apr 17, 2018
2 parents 37c8a77 + 82706fd commit 25d6483
Show file tree
Hide file tree
Showing 6 changed files with 306 additions and 301 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Change Log
All notable changes to this project will be documented in this file.

## [0.7.3] - 2018-04-04
#### Added
- [firmware] More debug messages

#### Fixed
- [webui] minor fixes suggested by Codacy
- [webui] get javascript values as real integers

## [0.7.2] - 2018-04-02
#### Fixed
- [webui] MQTT is enabled by default.
Expand Down
Binary file modified bin/firmware.bin
Binary file not shown.
18 changes: 1 addition & 17 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ board_f_cpu = 160000000L
platform = ${common.platform}
framework = arduino
board = esp12e
board_flash_mode = qio
upload_resetmethod = nodemcu
lib_deps = ${common.lib_deps}
build_flags = -Wl,-Teagle.flash.4m2m.ld
Expand All @@ -33,22 +32,7 @@ board_f_cpu = 160000000L
platform = ${common.platform}
framework = arduino
board = esp12e
board_flash_mode = qio
lib_deps = ${common.lib_deps}
extra_scripts = scripts/pio_script.py
build_flags = -Wl,-Teagle.flash.4m2m.ld
src_build_flags = !echo "-DBUILD_TAG="$TRAVIS_TAG

[env:dout]
board_f_cpu = 160000000L
platform = ${common.platform}
framework = arduino
board = esp12e
board_flash_mode = dout
upload_resetmethod = ck
lib_deps = ${common.lib_deps}
build_flags = -Wl,-Teagle.flash.4m2m.ld
extra_scripts = scripts/pio_script.py
upload_speed = 921600
; Serial Monitor options
monitor_baud = 115200
src_build_flags = !echo "-DBUILD_TAG="$TRAVIS_TAG
99 changes: 58 additions & 41 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,6 @@ String ICACHE_FLASH_ATTR printIP(IPAddress adress) {
return (String)adress[0] + "." + (String)adress[1] + "." + (String)adress[2] + "." + (String)adress[3];
}

/*
time_t ICACHE_FLASH_ATTR checkTimeSync() {
if (nextSyncTime <= sysTime) {
timerequest = true;
return millis();
}
else {
return now();
}
}*/

void ICACHE_FLASH_ATTR writeEvent(String type, String src, String desc, String data) {
DynamicJsonBuffer jsonBuffer44333;
JsonObject& root = jsonBuffer44333.createObject();
Expand Down Expand Up @@ -535,6 +524,10 @@ void ICACHE_FLASH_ATTR rfidloop() {
return;
}
}
else {
delay(50);
return;
}
if (mqttenabled == 1) {
const char * topic = mqttTopic;
mqttClient.publish(topic, 0, true, uid.c_str());
Expand Down Expand Up @@ -858,30 +851,30 @@ void ICACHE_FLASH_ATTR onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient *
void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) {
String reasonstr = "";
switch (reason) {
case (AsyncMqttClientDisconnectReason::TCP_DISCONNECTED):
reasonstr = "TCP_DISCONNECTED";
break;
case (AsyncMqttClientDisconnectReason::MQTT_UNACCEPTABLE_PROTOCOL_VERSION):
reasonstr = "MQTT_UNACCEPTABLE_PROTOCOL_VERSION";
break;
case (AsyncMqttClientDisconnectReason::MQTT_IDENTIFIER_REJECTED):
reasonstr = "MQTT_IDENTIFIER_REJECTED";
break;
case (AsyncMqttClientDisconnectReason::MQTT_SERVER_UNAVAILABLE):
reasonstr = "MQTT_SERVER_UNAVAILABLE";
break;
case (AsyncMqttClientDisconnectReason::MQTT_MALFORMED_CREDENTIALS):
reasonstr = "MQTT_MALFORMED_CREDENTIALS";
break;
case (AsyncMqttClientDisconnectReason::MQTT_NOT_AUTHORIZED):
reasonstr = "MQTT_NOT_AUTHORIZED";
break;
case (AsyncMqttClientDisconnectReason::ESP8266_NOT_ENOUGH_SPACE):
reasonstr = "ESP8266_NOT_ENOUGH_SPACE";
break;
default:
reasonstr = "Unknown";
break;
case (AsyncMqttClientDisconnectReason::TCP_DISCONNECTED):
reasonstr = "TCP_DISCONNECTED";
break;
case (AsyncMqttClientDisconnectReason::MQTT_UNACCEPTABLE_PROTOCOL_VERSION):
reasonstr = "MQTT_UNACCEPTABLE_PROTOCOL_VERSION";
break;
case (AsyncMqttClientDisconnectReason::MQTT_IDENTIFIER_REJECTED):
reasonstr = "MQTT_IDENTIFIER_REJECTED";
break;
case (AsyncMqttClientDisconnectReason::MQTT_SERVER_UNAVAILABLE):
reasonstr = "MQTT_SERVER_UNAVAILABLE";
break;
case (AsyncMqttClientDisconnectReason::MQTT_MALFORMED_CREDENTIALS):
reasonstr = "MQTT_MALFORMED_CREDENTIALS";
break;
case (AsyncMqttClientDisconnectReason::MQTT_NOT_AUTHORIZED):
reasonstr = "MQTT_NOT_AUTHORIZED";
break;
case (AsyncMqttClientDisconnectReason::ESP8266_NOT_ENOUGH_SPACE):
reasonstr = "ESP8266_NOT_ENOUGH_SPACE";
break;
default:
reasonstr = "Unknown";
break;
}
writeEvent("WARN", "mqtt", "Disconnected from MQTT server", reasonstr);
if (WiFi.isConnected()) {
Expand Down Expand Up @@ -954,8 +947,8 @@ bool ICACHE_FLASH_ATTR loadConfiguration() {
setupPN532Reader(rfidss);
}

autoRestartIntervalSeconds = general["restart"].as<int>();
wifiTimeout = network["offtime"].as<int>();
autoRestartIntervalSeconds = general["restart"];
wifiTimeout = network["offtime"];

const char * bssidmac = network["bssid"];
byte bssid[6];
Expand Down Expand Up @@ -993,7 +986,7 @@ bool ICACHE_FLASH_ATTR loadConfiguration() {
ws.setAuthentication("admin", http_pass);

if (wmode == 1) {
int hid = network["hide"].as<int>();
int hid = network["hide"];
Serial.println(F("[ INFO ] ESP-RFID is running in AP Mode "));
return startAP(ssid, password, hid);
}
Expand Down Expand Up @@ -1024,8 +1017,9 @@ bool ICACHE_FLASH_ATTR loadConfiguration() {
}




#ifdef DEBUG
Serial.println("Trying to setup NTP Server");
#endif

IPAddress timeserverip;
WiFi.hostByName(ntpserver, timeserverip);
Expand All @@ -1038,8 +1032,13 @@ bool ICACHE_FLASH_ATTR loadConfiguration() {
const char * muser = mqtt["user"];
const char * mpas = mqtt["pswd"];

mqttenabled = mqtt["enabled"].as<int>();
mqttenabled = mqtt["enabled"];


if (mqttenabled == 1) {
#ifdef DEBUG
Serial.println("Trying to setup MQTT");
#endif
mqttTopic = strdup(mqtt["topic"]);
mqttClient.setServer(mhs, mport);
mqttClient.setCredentials(muser, mpas);
Expand Down Expand Up @@ -1247,6 +1246,24 @@ void ICACHE_FLASH_ATTR setup() {

Serial.println();
Serial.println(F("[ INFO ] ESP RFID v0.7"));
#ifdef DEBUG
uint32_t realSize = ESP.getFlashChipRealSize();
uint32_t ideSize = ESP.getFlashChipSize();
FlashMode_t ideMode = ESP.getFlashChipMode();

Serial.printf("Flash real id: %08X\n", ESP.getFlashChipId());
Serial.printf("Flash real size: %u\n\n", realSize);

Serial.printf("Flash ide size: %u\n", ideSize);
Serial.printf("Flash ide speed: %u\n", ESP.getFlashChipSpeed());
Serial.printf("Flash ide mode: %s\n", (ideMode == FM_QIO ? "QIO" : ideMode == FM_QOUT ? "QOUT" : ideMode == FM_DIO ? "DIO" : ideMode == FM_DOUT ? "DOUT" : "UNKNOWN"));

if(ideSize != realSize) {
Serial.println("Flash Chip configuration wrong!\n");
} else {
Serial.println("Flash Chip configuration ok.\n");
}
#endif
// Start SPIFFS filesystem
if (!SPIFFS.begin()) {
#ifdef DEBUG
Expand Down
Loading

0 comments on commit 25d6483

Please sign in to comment.