Skip to content

Commit

Permalink
Merge pull request #79 from omersiar/dev
Browse files Browse the repository at this point in the history
v0.6.1
  • Loading branch information
omersiar committed Mar 14, 2018
2 parents 0c18012 + 1c07ceb commit 702e713
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 147 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
# Change Log
All notable changes to this project will be documented in this file.

## [0.6]
## [0.6.1] - 2018-03-14
#### Added
- [firmware] ICACHE_FLASH_ATTR and ICACHE_RAM_ATTR decorators (did not feel any difference in terms of speed, keeping it anyway).
- [dev tools] Web UI Demo https://bitadvise.com/esp-rfid/
- [dev tools] Websocket emulator access log

#### Changed
- [webui] Always show sidebar on big screens
- [webui] Better versioning.

#### Fixed
- [build] Platformio bug

## [0.6] - 2018-03-11
#### Added
- [firmware] Restart ESP if softAP fails.
- [webui] Colorize access log based on result.
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

[![Chat at https://gitter.im/esp-rfid/Lobby](https://badges.gitter.im/esp-rfid.svg)](https://gitter.im/esp-rfid/Lobby) [![Build Status](https://travis-ci.org/omersiar/esp-rfid.svg?branch=stable)](https://travis-ci.org/omersiar/esp-rfid) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/fc424f75d12644da8b6fe248a5e95157)](https://www.codacy.com/app/omersiar/esp-rfid?utm_source=github.com&utm_medium=referral&utm_content=omersiar/esp-rfid&utm_campaign=Badge_Grade) [![Bountysource](https://api.bountysource.com/badge/team?team_id=242217)](https://salt.bountysource.com/checkout/amount?team=esp-rfid)

Access Control demonstration using a cheap MFRC522 RFID Hardware or Wiegand RFID readers and Espressif's ESP8266 Microcontroller. This is a community driven project.
Access Control system using a cheap MFRC522 RFID Hardware or Wiegand RFID readers and Espressif's ESP8266 Microcontroller.

![Showcase Gif](https://raw.githubusercontent.com/omersiar/esp-rfid/stable/demo/showcase.gif)
[See Demo Here](https://bitadvise.com/esp-rfid/)

[![Showcase Gif](https://raw.githubusercontent.com/omersiar/esp-rfid/stable/demo/showcase.gif)](https://bitadvise.com/esp-rfid/)

## Features
### For Users
Expand All @@ -24,6 +26,7 @@ Access Control demonstration using a cheap MFRC522 RFID Hardware or Wiegand RFID
## Getting Started
This project still in its development phase. New features (and also bugs) are introduced often and some functions may become deprecated. Please feel free to comment or give feedback.

* [See Demo Here](https://bitadvise.com/esp-rfid/)
* Get the latest release from [here.](https://github.com/omersiar/esp-rfid/releases)
* See [Known Issues](https://github.com/omersiar/esp-rfid#known-issues) before starting right away.
* See [Security](https://github.com/omersiar/esp-rfid#security) for your safety.
Expand Down
Binary file modified bin/firmware.bin
Binary file not shown.
5 changes: 3 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
env_default = nodemcu

[common]
version = -DBUILD_TAG=0.6.0
platform = espressif8266
lib_deps =
ArduinoJson
Expand Down Expand Up @@ -34,8 +35,8 @@ framework = arduino
board = esp12e
lib_deps = ${common.lib_deps}
extra_scripts = scripts/pio_script.py
build_flags = -Wl,-Teagle.flash.4m.ld
build_flags = !echo '-DBUILD_TAG='$TRAVIS_TAG
build_flags = -Wl,-Teagle.flash.4m.ld
src_build_flags = !echo "-DBUILD_TAG="$TRAVIS_TAG

[env:dout]
board_f_cpu = 160000000L
Expand Down
52 changes: 26 additions & 26 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ AsyncWebServer server(80);
AsyncWebSocket ws("/ws");

/* ------------------ TRIVIAL Functions ------------------- */
String printIP(IPAddress adress) {
String ICACHE_FLASH_ATTR printIP(IPAddress adress) {
return (String)adress[0] + "." + (String)adress[1] + "." + (String)adress[2] + "." + (String)adress[3];
}

void writeEvent(String type, String src, String desc, String data) {
void ICACHE_RAM_ATTR writeEvent(String type, String src, String desc, String data) {
DynamicJsonBuffer jsonBuffer44333;
JsonObject& root = jsonBuffer44333.createObject();
root["type"] = type;
Expand All @@ -120,7 +120,7 @@ void writeEvent(String type, String src, String desc, String data) {
eventlog.close();
}

void writeLatest(String uid, String username, int acctype) {
void ICACHE_RAM_ATTR writeLatest(String uid, String username, int acctype) {
DynamicJsonBuffer jsonBuffer;
JsonObject& root = jsonBuffer.createObject();
root["uid"] = uid;
Expand All @@ -133,7 +133,7 @@ void writeLatest(String uid, String username, int acctype) {
latestlog.close();
}

void sendEventLog(int page) {
void ICACHE_FLASH_ATTR sendEventLog(int page) {
DynamicJsonBuffer jsonBuffer44332;
JsonObject& root = jsonBuffer44332.createObject();
root["command"] = "eventlist";
Expand Down Expand Up @@ -163,7 +163,7 @@ void sendEventLog(int page) {
}
}

void sendLatestLog(int page) {
void ICACHE_FLASH_ATTR sendLatestLog(int page) {
DynamicJsonBuffer jsonBuffer44332;
JsonObject& root = jsonBuffer44332.createObject();
root["command"] = "latestlist";
Expand Down Expand Up @@ -193,7 +193,7 @@ void sendLatestLog(int page) {
}
}

void sendUserList(int page, AsyncWebSocketClient * client) {
void ICACHE_FLASH_ATTR sendUserList(int page, AsyncWebSocketClient * client) {
DynamicJsonBuffer jsonBuffer443;
JsonObject& root = jsonBuffer443.createObject();
root["command"] = "userlist";
Expand Down Expand Up @@ -247,7 +247,7 @@ void sendUserList(int page, AsyncWebSocketClient * client) {

/* ------------------ Other Functions ------------------- */
// Send system status on a WS request
void sendStatus() {
void ICACHE_FLASH_ATTR sendStatus() {
struct ip_info info;
FSInfo fsinfo;
if (!SPIFFS.info(fsinfo)) {
Expand Down Expand Up @@ -298,7 +298,7 @@ void sendStatus() {
}

// Send Scanned SSIDs to websocket clients as JSON object
void printScanResult(int networksFound) {
void ICACHE_FLASH_ATTR printScanResult(int networksFound) {
// sort by RSSI
int n = networksFound;
int indices[n];
Expand Down Expand Up @@ -342,13 +342,13 @@ void printScanResult(int networksFound) {
}


void mqttCallback(char* topic, byte* payload, unsigned int length) {
void ICACHE_FLASH_ATTR mqttCallback(char* topic, byte* payload, unsigned int length) {
if (length == 0) {
return;
}
}

void sendTime() {
void ICACHE_FLASH_ATTR sendTime() {
DynamicJsonBuffer jsonBuffer231;
JsonObject& root = jsonBuffer231.createObject();
root["command"] = "gettime";
Expand All @@ -363,7 +363,7 @@ void sendTime() {

}

void mqttConnect() {
void ICACHE_FLASH_ATTR mqttConnect() {
if (mqttHost != NULL && mqttPort != 0 && mqttTopic != NULL && !mqttClient.connected() ) {
Serial.print(F("[ INFO ] Trying to connect to MQTT server : "));
//setCallback();
Expand All @@ -386,7 +386,7 @@ void mqttConnect() {



void parseBytes(const char* str, char sep, byte* bytes, int maxBytes, int base) {
void ICACHE_FLASH_ATTR parseBytes(const char* str, char sep, byte* bytes, int maxBytes, int base) {
for (int i = 0; i < maxBytes; i++) {
bytes[i] = strtoul(str, NULL, base); // Convert byte
str = strchr(str, sep); // Find next separator
Expand All @@ -397,13 +397,13 @@ void parseBytes(const char* str, char sep, byte* bytes, int maxBytes, int base)
}
}

void disableWifi() {
void ICACHE_FLASH_ATTR disableWifi() {
isWifiConnected = false;
WiFi.disconnect(true);
Serial.println("Turn wifi off.");
}

bool startAP(const char * ssid, const char * password = NULL) {
bool ICACHE_FLASH_ATTR startAP(const char * ssid, const char * password = NULL) {
inAPMode = true;
WiFi.mode(WIFI_AP);
Serial.print(F("[ INFO ] Configuring access point... "));
Expand All @@ -420,7 +420,7 @@ bool startAP(const char * ssid, const char * password = NULL) {
}

// Fallback to AP Mode, so we can connect to ESP if there is no Internet connection
void fallbacktoAPMode() {
void ICACHE_FLASH_ATTR fallbacktoAPMode() {
Serial.println(F("[ INFO ] ESP-RFID is running in Fallback AP Mode"));
uint8_t macAddr[6];
WiFi.softAPmacAddress(macAddr);
Expand All @@ -430,7 +430,7 @@ void fallbacktoAPMode() {
}

// Try to connect Wi-Fi
bool connectSTA(const char* ssid, const char* password, byte bssid[6]) {
bool ICACHE_FLASH_ATTR connectSTA(const char* ssid, const char* password, byte bssid[6]) {
WiFi.disconnect(true);
WiFi.mode(WIFI_STA);
// First connect to a wi-fi network
Expand Down Expand Up @@ -470,7 +470,7 @@ bool connectSTA(const char* ssid, const char* password, byte bssid[6]) {

/* ------------------ RFID Functions ------------------- */
// RFID Specific Loop
void rfidloop() {
void ICACHE_RAM_ATTR rfidloop() {

String uid = "";
String type = "";
Expand Down Expand Up @@ -622,7 +622,7 @@ void rfidloop() {
// So far got we got UID of Scanned RFID Tag, checked it if it's on the database and access status, informed Administrator Portal
}

void ShowMFRC522ReaderDetails() {
void ICACHE_FLASH_ATTR ShowMFRC522ReaderDetails() {
// Get the MFRC522 software version
byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
Serial.print(F("[ INFO ] MFRC522 Version: 0x"));
Expand All @@ -643,7 +643,7 @@ void ShowMFRC522ReaderDetails() {
}

// Configure RFID Hardware
void setupMFRC522Reader(int rfidss, int rfidgain) {
void ICACHE_FLASH_ATTR setupMFRC522Reader(int rfidss, int rfidgain) {
SPI.begin(); // MFRC522 Hardware uses SPI protocol
mfrc522.PCD_Init(rfidss, UINT8_MAX); // Initialize MFRC522 Hardware
// Set RFID Hardware Antenna Gain
Expand All @@ -654,7 +654,7 @@ void setupMFRC522Reader(int rfidss, int rfidgain) {
ShowMFRC522ReaderDetails(); // Show details of PCD - MFRC522 Card Reader details
}

void setupWiegandReader(int d0, int d1) {
void ICACHE_FLASH_ATTR setupWiegandReader(int d0, int d1) {
wg.begin(d0, d0, d1, d1);
}

Expand All @@ -663,7 +663,7 @@ void setupWiegandReader(int d0, int d1) {


// Handles WebSocket Events
void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len) {
void ICACHE_RAM_ATTR onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len) {
if (type == WS_EVT_ERROR) {
Serial.printf("[ WARN ] WebSocket[%s][%u] error(%u): %s\r\n", server->url(), client->id(), *((uint16_t*)arg), (char*)data);
}
Expand Down Expand Up @@ -776,7 +776,7 @@ void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventT
}


bool loadConfiguration() {
bool ICACHE_FLASH_ATTR loadConfiguration() {
File configFile = SPIFFS.open("/config.json", "r");
if (!configFile) {
Serial.println(F("[ WARN ] Failed to open config file"));
Expand Down Expand Up @@ -894,14 +894,14 @@ bool loadConfiguration() {
return true;
}

void enableWifi() {
void ICACHE_FLASH_ATTR enableWifi() {
Serial.println("Turn wifi on.");
if (!loadConfiguration())
fallbacktoAPMode();
}

/* ------------------ BASIC SYSTEM Functions ------------------- */
void setupWebServer() {
void ICACHE_FLASH_ATTR setupWebServer() {
// Start WebSocket Plug-in and handle incoming message on "onWsEvent" function
server.addHandler(&ws);
ws.onEvent(onWsEvent);
Expand Down Expand Up @@ -1076,7 +1076,7 @@ void setupWebServer() {
}

// Set things up
void setup() {
void ICACHE_FLASH_ATTR setup() {
// Populate the last modification date based on build datetime
sprintf(last_modified, "%s %s GMT", __DATE__, __TIME__);
pinMode(FRESETPIN, INPUT_PULLUP);
Expand Down Expand Up @@ -1121,7 +1121,7 @@ void setup() {
}

// Main Loop
void loop() {
void ICACHE_RAM_ATTR loop() {
if (formatreq) {
Serial.println(F("[ WARN ] Factory reset initiated..."));
SPIFFS.end();
Expand Down

0 comments on commit 702e713

Please sign in to comment.