Skip to content

Commit

Permalink
new version 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Asyasyarif committed Jun 23, 2020
1 parent ae13164 commit 975931f
Show file tree
Hide file tree
Showing 12 changed files with 880 additions and 364 deletions.
35 changes: 31 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{

"git.ignoreLimitWarning": true,
"editor.fontFamily": "Operator Mono",
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"editor.cursorStyle": "line-thin",
"editor.cursorBlinking": "smooth",
"workbench.fontAliasing": "auto",
"editor.fontSize": 15,
"editor.fontSize": 13.5,
"editor.smoothScrolling": true,
"editor.tabSize": 2,
"window.zoomLevel": 0,
Expand All @@ -24,6 +24,33 @@
"unordered_map": "cpp",
"vector": "cpp",
"initializer_list": "cpp",
"functional": "cpp"
}
"functional": "cpp",
"atomic": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"exception": "cpp",
"fstream": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"ostream": "cpp",
"numeric": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"cinttypes": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"typeinfo": "cpp"
},
"editor.fontWeight": "600"
}
159 changes: 65 additions & 94 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ With this library you can easily manage the users with RFID card data stored in

Youtube Videos (Bahasa) [here](https://youtu.be/dyNRkAb60So)

Youtube Videos (English) *Soon*

## Hardware Requirements
>Spacecat is primary built for ESP8266 Chip. but for now ESP32 is a bit of a problem, now still in progress :)
- Any board with ESP8266/ESP32 chips (Wemos, NodeMCU board, etc).
Expand Down Expand Up @@ -41,83 +43,17 @@ Now grab the hardware and some jumper wire and connect it like image shown below
![](https://github.com/AsyaSyarif/RFID-Spacecat/blob/master/circuits/basic.PNG)

#### Wiring
| ESP8266 | RC522 |
| ------------- |:-------------:|
| 3V3 | 3.3V |
| GND | GND |
| D8 (GPIO15) | SDA / SS |
| D5 (GPIO14) | SCK |
| D7 (GPIO13) | MOSI |
| D6 (GPIO12) | MISO |
| -| IRQ |
| GND / X | RST |

### Simple Usage or Open this [Examples](https://github.com/AsyaSyarif/RFID-Spacecat/tree/master/examples) folder.
```
#include "Spacecat.h"
const char WIFI_SSID[] = ""; // your network SSID (name)
const char WIFI_PASSWORD[] = ""; // your network password
const char DEVICE_NAME[] = "";
const char SPACECAT_USERNAME[] = "";
const char SPACECAT_PASSWORD[] = "";
#define RC522_SS_PIN 15
Spacecat cat(SPACECAT_USERNAME, SPACECAT_PASSWORD, DEVICE_NAME);
void handleCallback(int code, String refrenceID, String name, String messages){
Serial.print("Code : ");
Serial.println(code);
Serial.print("Ref : ");
Serial.println(refrenceID);
Serial.print("Name : ");
Serial.println(name);
Serial.print("Messages : ");
Serial.println(messages);
}
void setup() {
//for debuging purpose
Serial.begin(115200);
|ESP32 | ESP8266 | RC522 |
| --- | ------------- |:-------------:|
| - | 3V3 | 3.3V |
| - | GND | GND |
| - | D8 (GPIO15) | SDA / SS |
| - | D5 (GPIO14) | SCK |
| - | D7 (GPIO13) | MOSI |
| - | D6 (GPIO12) | MISO |
| - | -| IRQ |
| - | GND / X | RST |

Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.print(WIFI_SSID);
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(200);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
cat.begin(RC522_SS_PIN);
cat.setSimpleCallback(&handleCallback);
}
void loop() {
if(WiFi.status() == WL_CONNECTED){
cat.loop();
}
}
```

## Get The Authentication Key
+ **Please pay attention to accessing our website, please use desktop version instead mobile version [only temporary]**
Expand All @@ -131,10 +67,11 @@ void loop() {
const char SPACECAT_USERNAME[] = "";
const char SPACECAT_PASSWORD[] = "";
```

## Usage
Please check [Example's](https://github.com/Asyasyarif/RFID-Spacecat/tree/master/examples) folder

## API Docs
Basically every we doing request to the server, that will return 4 basic data, which will be explained below
Basically every we doing request to the server that will return the data, which will be explained below

| Value | Description |
| ------------- | ------------- |
Expand All @@ -148,26 +85,60 @@ Basically every we doing request to the server, that will return 4 basic data, w
| | `` [109] `` Not found|
| | `` [110] `` User parameter updated|
| | `` [111] `` Password OK|
| **Reference** | ID Reference for every requests |
| **Name** | Name of user |
| **Messages** | Messages status from requests |

| | `` [112] `` Password Confirmation|

## Structures
We'll separate the code structures into 3 parts : `.user`, `.ruleParameter`, `.placementParameter`

| Struct | Data | Data Type | Description |
| ------------- | ------------- | --------- | --------- |
| `{objectName}.user` | `.name` | `String` | Username |
| | `.rfid` | `String` | User RFID |
| | `.email` | `char` | Email |
| | `.isMaster` | `char` | `true` if user has set to Master |
| | `.messages` | `char` | Message of every request |
| | `.phoneNumber` | `char` | Phone Number |
| | `.amount` | `int` | Amount of default parameter |
| | `.referenceID` | `int` | Unique ID for every requests |
| | `.havePassword` | `bool` | If user have password that's will be `true` |
| | `.status` | `bool` | User status |
| | `.statusCode` | `uint16_t` | Return code |
|`{objectName}.ruleParameter` | `.amount` | `int` | Amount of rule parameter |
|`{objectName}.placementParameter` | `.Name1` | `char` | Name of Placement parameter 1 |
| | `.value1` | `int` | Amount of rule parameter 1|
| | `.Name2` | `char` | Name of Placement parameter 2 |
| | `.value2` | `int` | Amount of rule parameter 2|
| | `.Name3` | `char` | Name of Placement parameter 3 |
| | `.value3` | `int` | Amount of rule parameter 3|
| | `.Name4` | `char` | Name of Placement parameter 4 |
| | `.value4` | `int` | Amount of rule parameter 4|

## Functions
| Function | Description | Default |
| Function | Default | Description |
| ------------- | ------------- | --------- |
| ``clear()`` | Clear data and proccess | - |
| ``readCard()`` | Just only reading RFID Card | - |
| ``registerID()`` | Registering the ID and added to waiting list | - |
| ``setDebug(bool debug)`` | Debugging purpose | ``true `` | |
| ``intervalReading(int time)`` | Delay for every reading the card| ``1000ms`` |
| ``begin(uint8_t SS_PIN)`` | Initialization RC522 Module SS Pin and Reset to GND| - |
| ``begin(uint8_t SS_PIN, uint8_t RESET_PIN)`` |Initialization RC522 Module SS Pin & Reset Pin | - |
| ``enteredPassword(String password)`` | User inserting password | - |
|`` Spacecat(String Username, String Password, String DeviceName)`` | Initialization your credentials | - |

| ``cancel()`` | | Cancel data and proccess |
| ``confirm()`` | | Confirm for changes parameters |
| ``onlyReadingCard()`` | | Just only reading RFID Card |
| ``registerID()`` | | Registering the ID and added to waiting list |
| ``setDebug(bool debug)`` | ``true `` | Debugging purpose |
| ``setIntervalReading(int time)`` | ``1000ms`` | Delay for every reading the card
| `` setTimeoutPassword(int time)`` | ``10000ms`` | Timer for user inserting the password
| ``begin(uint8_t SS_PIN)`` | | Initialization RC522 Module SS Pin and Reset to GND |
| ``begin(uint8_t SS_PIN, uint8_t RESET_PIN)`` | | Initialization RC522 Module SS Pin & Reset Pin |
| ``enteredPassword(String password)`` | | User inserting password|
|`` Spacecat(String Username, String Password, String DeviceName)`` | | Initialization your credentials |
|`` setCallback(&handleCallback);`` | | Receive all the data feedback on any requests |



## Contribute
There are several ways to contribute to Spacecat development. You can contribute to the repository by doing:
- Pull requests
- Create the issues

## To Do
- Write clean code / Refactoring
- Write API's
- Write Documentations
- Write Documentations

<sup> [just contact me if you had any questions](https://www.instagram.com/asya_syarif/) </sup>
86 changes: 86 additions & 0 deletions examples/AuthWithPassword/AuthWithPassword.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@

/*******************************************************************
*
* Spacecat requires :
* RC522 : https://github.com/miguelbalboa/rfid
* ArduinoJson : https://github.com/bblanchon/ArduinoJson
* - im use the latest version (Currently is 6.14.1)
*
* Makes sure the user entered the password
*
*
* Written by Arif @2019.
* Bandung, Indonesia
* https://rfid.asyarif.net
*
*******************************************************************/


#include "Spacecat.h"

const char WIFI_SSID[] = ""; // your network SSID (name)
const char WIFI_PASSWORD[] = ""; // your network password

const char DEVICE_NAME[] = "";
const char SPACECAT_USERNAME[] = "";
const char SPACECAT_PASSWORD[] = "";

#define RC522_SS_PIN 15 //D8
Spacecat cat(SPACECAT_USERNAME, SPACECAT_PASSWORD, DEVICE_NAME);

void handleCallback(bool userFound){

if(userFound){
Serial.print("hello ");
Serial.println(cat.user.name);
Serial.println(cat.user.messages);

/*
- Make sure the user have a password
- the password must be 6 digits and numeric
- In this case For example I'd with simple password and hard-coded "123456"
*/
if(cat.user.statusCode == FILL_THE_PASSWORD){
if(cat.enteredPassword("123456")){
Serial.println("The Password correct");
}else{
Serial.println("The Password incorrect");
}
}
}

}


void setup() {
//for debuging purpose
Serial.begin(115200);

Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.print(WIFI_SSID);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}

Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());

cat.setTimeoutPassword(5000); // 5 seconds
cat.begin(RC522_SS_PIN);
cat.setCallback(&handleCallback);
}

void loop() {

if(WiFi.status() == WL_CONNECTED){
cat.loop();
}

}
8 changes: 6 additions & 2 deletions examples/ReadCard/ReadCard.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include "Spacecat.h"

#define RC522_SS_PIN 15
#define RC522_SS_PIN 5
Spacecat cat;

void setup(){
Expand All @@ -26,8 +26,12 @@ void setup(){

void loop(){

cat.readCard();
if(cat.onlyReadCard()){
Serial.print("ID: ");
Serial.println(cat.user.rfid);
}
delay (10);

}


Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* ArduinoJson : https://github.com/bblanchon/ArduinoJson
* - im use the latest version (Currently is 6.14.1)
*
* If you don't want to copy paste the ID card,
* If you don't want to copy an dpaste the ID card,
* you can use this example and automatically the ID card will appear on your project
*
* Written by Arif @2019.
Expand All @@ -29,7 +29,6 @@ const char SPACECAT_PASSWORD[] = "";

Spacecat cat(SPACECAT_USERNAME, SPACECAT_PASSWORD, DEVICE_NAME);


void setup() {
//for debuging purpose
Serial.begin(115200);
Expand Down
Loading

0 comments on commit 975931f

Please sign in to comment.