commit b4b28911896afb88def8a32e1a3c66666f38363b Author: bedirkaraabali <69633060+bdrtr@users.noreply.github.com> Date: Thu May 16 16:06:18 2024 +0300 version-0 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..89cc49c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..080e70d --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/include/README b/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/lib/README b/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/lib/fProcess/fProcess.cpp b/lib/fProcess/fProcess.cpp new file mode 100644 index 0000000..e5fd941 --- /dev/null +++ b/lib/fProcess/fProcess.cpp @@ -0,0 +1,240 @@ +#include "fProcess.h" +#include + + + +fProcess::fProcess() { + +}; + +void fProcess::Initialize() { + +} + +void fProcess::delDB() { + + Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial2); + finger.emptyDatabase(); +} + +void fProcess::enRoll(User usr) { + + + Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial2); + finger.begin(57600); + + int data = -1; + Serial.print("Parmak izi şu kullanıcı için bekleniyor # "); Serial.println(usr.getID()); + while (data != FINGERPRINT_OK) { + data = finger.getImage(); + switch (data) { + case FINGERPRINT_OK: + Serial.println("Parmak izi alındı "); + break; + case FINGERPRINT_NOFINGER: + Serial.print("."); + break; + case FINGERPRINT_PACKETRECIEVEERR: + Serial.println("Bağlantı hatası"); + break; + case FINGERPRINT_IMAGEFAIL: + Serial.println("Hatalı resim"); + break; + default: + Serial.println("Bir hata meydana geldi"); + break; + } + } + + + data = finger.image2Tz(1); + switch (data) { + case FINGERPRINT_OK: + Serial.println("Resim dönüştürüldü"); + break; + case FINGERPRINT_IMAGEMESS: + Serial.println("Resim belirsiz"); + return; + case FINGERPRINT_PACKETRECIEVEERR: + Serial.println("Bağlantı hatası"); + return; + case FINGERPRINT_FEATUREFAIL: + Serial.println("Parmak izinin nitelikleri belirgin değil"); + return; + case FINGERPRINT_INVALIDIMAGE: + Serial.println("Parmak izi niteliği anlaşılamadı"); + return; + default: + Serial.println("Hata"); + return; + } + + Serial.println("Yeniden girmeye hazır"); + delay(50); + data = 0; + while (data != FINGERPRINT_NOFINGER) { + data = finger.getImage(); + } + Serial.print("ID "); Serial.println(usr.getID()); + data = -1; + Serial.println("aynı parmak tekrar girilmeli"); + while (data != FINGERPRINT_OK) { + data = finger.getImage(); + switch (data) { + case FINGERPRINT_OK: + Serial.println("resim alındı"); + break; + case FINGERPRINT_NOFINGER: + Serial.print("."); + break; + case FINGERPRINT_PACKETRECIEVEERR: + Serial.println("iletişim hatası"); + break; + case FINGERPRINT_IMAGEFAIL: + Serial.println("hata"); + break; + default: + Serial.println("hata"); + break; + } + } + + // OK success! + + data = finger.image2Tz(2); + switch (data) { + case FINGERPRINT_OK: + Serial.println("resim dönüştürüldü"); + break; + case FINGERPRINT_IMAGEMESS: + Serial.println("resim meşgul"); + return; + case FINGERPRINT_PACKETRECIEVEERR: + Serial.println("bağlantı hatası"); + return; + case FINGERPRINT_FEATUREFAIL: + Serial.println("parmak izi özellikleri eşleşmedi"); + return; + case FINGERPRINT_INVALIDIMAGE: + Serial.println("parmak izi özellikleri eşleşmedi"); + return; + default: + Serial.println("hata"); + return; + } + + Serial.print("Model Oluşturuldu #"); Serial.println(usr.getID()); + + data = finger.createModel(); + if (data == FINGERPRINT_OK) { + Serial.println("Parmak izleri eşleşti!"); + } else if (data == FINGERPRINT_PACKETRECIEVEERR) { + Serial.println("Bağlantı hatası"); + return; + } else if (data == FINGERPRINT_ENROLLMISMATCH) { + Serial.println("Farklı parmak izleri"); + return; + } else { + Serial.println("hata"); + return; + } + + Serial.print("ID "); Serial.println(usr.getID()); + + data = finger.storeModel(usr.getID()); + + if (data == FINGERPRINT_OK) { + Serial.println("Hafızaya alındı"); + } else if (data == FINGERPRINT_PACKETRECIEVEERR) { + Serial.println("Communication error"); + return; + } else if (data == FINGERPRINT_BADLOCATION) { + Serial.println("Bu bölümde bir boşluk iz bulunamadı"); + return; + } else if (data == FINGERPRINT_FLASHERR) { + Serial.println("Belleğe yazma hatası"); + return; + } else { + Serial.println("Unknown error"); + return; + } + return; + +} + + +uint8_t fProcess::logIn() { + + + Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial2); + finger.begin(57600); + + uint8_t data; + while (data != FINGERPRINT_OK) { + data = finger.getImage(); + switch (data) { + case FINGERPRINT_OK: + Serial.println("Parmak izi alındı "); + break; + case FINGERPRINT_NOFINGER: + Serial.print("."); + break; + case FINGERPRINT_PACKETRECIEVEERR: + Serial.println("Bağlantı hatası"); + break; + case FINGERPRINT_IMAGEFAIL: + Serial.println("Hatalı resim"); + break; + default: + Serial.println("Bir hata meydana geldi"); + break; + } + } + + data = finger.image2Tz(); + switch (data) { + case FINGERPRINT_OK: + Serial.println("Resim dönüştürüldü"); + break; + case FINGERPRINT_IMAGEMESS: + Serial.println("resim bozuk"); + return data; + case FINGERPRINT_PACKETRECIEVEERR: + Serial.println("Bağlantı hatası"); + return data; + case FINGERPRINT_FEATUREFAIL: + Serial.println("Could not find fingerprint features"); + return data; + case FINGERPRINT_INVALIDIMAGE: + Serial.println("Could not find fingerprint features"); + return data; + default: + Serial.println("Unknown error"); + return data; + } + + data = finger.fingerSearch(); + if (data == FINGERPRINT_OK) { + Serial.println("Parmak izi eşleşti"); + } else if (data == FINGERPRINT_PACKETRECIEVEERR) { + Serial.println("Bağlantı hatası"); + return data; + } else if (data == FINGERPRINT_NOTFOUND) { + Serial.println("Did not find a match"); + return data; + } else { + Serial.println("Unknown error"); + return data; + } + + + Serial.print("Found ID #"); Serial.print(finger.fingerID); + Serial.print(" with confidence of "); Serial.println(finger.confidence); + + return finger.fingerID; + +} + +void fProcess::showUserList() { + +} \ No newline at end of file diff --git a/lib/fProcess/fProcess.h b/lib/fProcess/fProcess.h new file mode 100644 index 0000000..96652fd --- /dev/null +++ b/lib/fProcess/fProcess.h @@ -0,0 +1,22 @@ +#ifndef FPROCESS_H +#define FPROCESS_H + +#include "user.h" + +class fProcess{ + + + public: + + fProcess(); + void Initialize(); + void enRoll(User usr); + uint8_t logIn(); + void showUserList(); + void delDB(); + private: + String name; + +}; + +#endif \ No newline at end of file diff --git a/lib/user/user.cpp b/lib/user/user.cpp new file mode 100644 index 0000000..c9fa1b9 --- /dev/null +++ b/lib/user/user.cpp @@ -0,0 +1,16 @@ +#include "user.h" +#include "WString.h" + +User::User(String name) { + this->name = name; +} + +void User::setID(uint8_t ID) { + + this->ID = ID; +} + +uint8_t User::getID() { + + return ID; +} \ No newline at end of file diff --git a/lib/user/user.h b/lib/user/user.h new file mode 100644 index 0000000..624a054 --- /dev/null +++ b/lib/user/user.h @@ -0,0 +1,23 @@ +#pragma once +#ifndef USER_H +#define USER_H + +#include + +class User { + + public: + + User(String name); + void setID(uint8_t ID); + uint8_t getID(); + + private: + + String name; + uint8_t ID; + + +}; + +#endif \ No newline at end of file diff --git a/lib/wifiConnect/wifiConnect.cpp b/lib/wifiConnect/wifiConnect.cpp new file mode 100644 index 0000000..107b691 --- /dev/null +++ b/lib/wifiConnect/wifiConnect.cpp @@ -0,0 +1,58 @@ +#include "wifiConnect.h" +#include +#include + +WifiConnect::WifiConnect(String SSID, String PASSWD) { + + this->SSID = SSID; + this->PASSWD = PASSWD; +} + +void WifiConnect::Initialize() { + + + connection_state = false; + + WiFi.begin(SSID, PASSWD); + Serial.print("connection try to be in"); + + unsigned int get_current_time = millis(); + + while ( WiFi.status() != WL_CONNECTED && (millis() - get_current_time) < timeout) { + + delay(30); + Serial.print("."); + } + + connection_state = true; + IP = WiFi.localIP().toString(); + + Serial.print("connection okey"); +} + +String WifiConnect::get_IP() { + + return WiFi.localIP().toString(); +} + +void WifiConnect::get_info() { + + Serial.printf("Ip adress : %s, SSID : %s \n", IP, SSID); +} + +void WifiConnect::set_timeout(unsigned int timeout) { + + this->timeout = timeout; +} + +void WifiConnect::matchTrue() { + + HTTPClient http; + + String serverIP = "localhost"; + String serverPort = "8080"; + String endpoint = "/endpoint"; + +} + + diff --git a/lib/wifiConnect/wifiConnect.h b/lib/wifiConnect/wifiConnect.h new file mode 100644 index 0000000..71f8678 --- /dev/null +++ b/lib/wifiConnect/wifiConnect.h @@ -0,0 +1,32 @@ +#pragma once +#ifndef WIFICONNECT_H +#define WIFICONNECT_H + +#include +#include +#include + +class WifiConnect { + + + public: + WifiConnect(String SSID, String PASSWD); + void Initialize(); + String get_IP(); + void get_info(); + void set_timeout(unsigned int timeout); + void matchTrue(); + + + private: + + String SSID; + String PASSWD; + String IP; + unsigned int timeout = 20000; + bool connection_state; + + +}; + +#endif \ No newline at end of file diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..622b784 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,17 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:esp32doit-devkit-v1] +platform = espressif32 +board = esp32doit-devkit-v1 +framework = arduino +lib_deps = + adafruit/Adafruit GFX Library@^1.11.9 + adafruit/Adafruit Fingerprint Sensor Library@^2.1.3 \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..33f0045 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,57 @@ +#include + +#include +#include +#include + +#include +#include +#include + + + + +const String SSID = "Kilicarslan"; +const String PASSWD = "14531453"; + + + +//Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial2); +WifiConnect connect(SSID, PASSWD); + +User usr("bedir"); +fProcess fp; + +void setup() { + + fp.delDB(); + usr.setID(12); + + Serial.begin(9600); + connect.Initialize(); + //fp.Initialize(); + fp.enRoll(usr); + + delay(20); + +} + + +void loop(){ + + while (!fp.logIn()) { + Serial.println(" >>"); + delay(1000); + } + User u(""); + uint8_t temp_id; + if ((temp_id = fp.logIn())) { + + u.setID(temp_id); + //connect.matchTrue(); + } + Serial.print("user id : "); Serial.println(u.getID()); + + + +} diff --git a/test/README b/test/README new file mode 100644 index 0000000..9b1e87b --- /dev/null +++ b/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html