version-0

This commit is contained in:
bedirkaraabali 2024-05-16 16:06:18 +03:00
commit b4b2891189
13 changed files with 576 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch

10
.vscode/extensions.json vendored Normal file
View File

@ -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"
]
}

39
include/README Normal file
View File

@ -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

46
lib/README Normal file
View File

@ -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 <Foo.h>
#include <Bar.h>
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

240
lib/fProcess/fProcess.cpp Normal file
View File

@ -0,0 +1,240 @@
#include "fProcess.h"
#include <Adafruit_Fingerprint.h>
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() {
}

22
lib/fProcess/fProcess.h Normal file
View File

@ -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

16
lib/user/user.cpp Normal file
View File

@ -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;
}

23
lib/user/user.h Normal file
View File

@ -0,0 +1,23 @@
#pragma once
#ifndef USER_H
#define USER_H
#include <Arduino.h>
class User {
public:
User(String name);
void setID(uint8_t ID);
uint8_t getID();
private:
String name;
uint8_t ID;
};
#endif

View File

@ -0,0 +1,58 @@
#include "wifiConnect.h"
#include <HTTPClient.h>
#include <WiFi.h>
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";
}

View File

@ -0,0 +1,32 @@
#pragma once
#ifndef WIFICONNECT_H
#define WIFICONNECT_H
#include <iostream>
#include <string>
#include <WiFi.h>
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

17
platformio.ini Normal file
View File

@ -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

57
src/main.cpp Normal file
View File

@ -0,0 +1,57 @@
#include <Arduino.h>
#include <wifiConnect.h>
#include <user.h>
#include <fProcess.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_Fingerprint.h>
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());
}

11
test/README Normal file
View File

@ -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