Skip to content
Snippets Groups Projects
Commit 51d615dc authored by Dorababu A's avatar Dorababu A
Browse files

Init

parent 0401e708
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
/*!
* @file DFRobot_ID809.h
* @brief Define basic structure of DFRobot_ID809 class
* @n This is an library for capacitive fingerprint module
* @n Main functions: fingerprint image capturing, fingerprint comparison, fingerprint deletion
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @licence The MIT License (MIT)
* @author [Eddard](eddard.liu@dfrobot.com)
* @version V1.0
* @date 2020-03-19
* @get from https://www.dfrobot.com
* @url https://github.com/cdjq/DFRobot_ID809
*/
#ifndef _DFRobot_ID809_H
#define _DFRobot_ID809_H
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include <Wire.h>
#include <stdint.h>
//Open this macro to see the detailed running process of the program
//#define ENABLE_DBG
#ifdef ENABLE_DBG
#define LDBG(...) if(dbg) {dbg->print("["); dbg->print(__FUNCTION__); dbg->print("(): "); dbg->print(__LINE__); dbg->print(" ] "); dbg->println(__VA_ARGS__);}
#else
#define LDBG(...)
#endif
extern Stream *dbg;
/*
Frame struct of command packet
*/
typedef struct{
uint16_t PREFIX;
uint8_t SID;
uint8_t DID;
uint16_t CMD;
uint16_t LEN;
uint8_t payload[0];
}__attribute__ ((packed)) sCmdPacketHeader_t, *pCmdPacketHeader_t;
/*
Frame struct of response packet
*/
typedef struct{
uint16_t PREFIX;
uint8_t SID;
uint8_t DID;
uint16_t RCM;
uint16_t LEN;
uint16_t RET;
uint8_t payload[0];
}__attribute__ ((packed)) sRcmPacketHeader_t, *pRcmPacketHeader_t;
class DFRobot_ID809{
public:
//#define FINGERPRINT_CAPACITY 80 //Fingerprint module capacity
#define MODULE_SN_SIZE 16 //Module SN length
#define DELALL 0xFF //Delete all fingerprints
#define CMD_PREFIX_CODE 0xAA55 //Command packet prefix code
#define RCM_PREFIX_CODE 0x55AA //Response packet prefix code
#define CMD_DATA_PREFIX_CODE 0xA55A //Command data packet prefix code
#define RCM_DATA_PREFIX_CODE 0x5AA5 //Response data packet prefix code
#define CMD_TYPE 0xF0 //Command packet type
#define RCM_TYPE 0xF0 //Response packet type
#define DATA_TYPE 0x0F //Data packet type
#define CMD_TEST_CONNECTION 0X0001 //Test connection
#define CMD_SET_PARAM 0X0002 //Set parameter
#define CMD_GET_PARAM 0X0003 //Read parameter
#define CMD_DEVICE_INFO 0X0004 //Read device information
#define CMD_SET_MODULE_SN 0X0008 //Set module serial number
#define CMD_GET_MODULE_SN 0X0009 //Read module serial number
#define CMD_ENTER_STANDBY_STATE 0X000C //Enter sleep mode
#define CMD_GET_IMAGE 0X0020 //Capture fingerprint image
#define CMD_FINGER_DETECT 0X0021 //Detect fingerprint
#define CMD_UP_IMAGE_CODE 0X0022 //Upload fingerprint image to host
#define CMD_DOWN_IMAGE 0X0023 //Download fingerprint image to module
#define CMD_SLED_CTRL 0X0024 //Control collector backlight
#define CMD_STORE_CHAR 0X0040 //Save fingerprint template data into fingerprint library
#define CMD_LOAD_CHAR 0X0041 //Read fingerprint in module and save it in RAMBUFFER temporarily
#define CMD_UP_CHAR 0X0042 //Upload the fingerprint template saved in RAMBUFFER to host
#define CMD_DOWN_CHAR 0X0043 //Download fingerprint template to module designated RAMBUFFER
#define CMD_DEL_CHAR 0X0044 //Delete fingerprint in specific ID range
#define CMD_GET_EMPTY_ID 0X0045 //Get the first registerable ID in specific ID range
#define CMD_GET_STATUS 0X0046 //Check if the designated ID has been registered
#define CMD_GET_BROKEN_ID 0X0047 //Check whether there is damaged data in fingerprint library of specific range
#define CMD_GET_ENROLL_COUNT 0X0048 //Get the number of registered fingerprints in specific ID range
#define CMD_GET_ENROLLED_ID_LIST 0X0049 //Get registered ID list
#define CMD_GENERATE 0X0060 //Generate template from the fingerprint images saved in IMAGEBUFFER temporarily
#define CMD_MERGE 0X0061 //Synthesize fingerprint template data
#define CMD_MATCH 0X0062 //Compare templates in 2 designated RAMBUFFER
#define CMD_SEARCH 0X0063 //1:N Recognition in specific ID range
#define CMD_VERIFY 0X0064 //Compare specific RAMBUFFER template with specific ID template in fingerprint library
#define ERR_SUCCESS 0x00 //Command processed successfully
#define ERR_ID809 0xFF //error
public:
typedef enum{
eBreathing = 1, //Breathing
eFastBlink, //Quick blink
eKeepsOn, //On
eNormalClose, //Off
eFadeIn, //Fade in
eFadeOut, //Fade out
eSlowBlink //Slow blink
}eLEDMode_t;
typedef enum{
eLEDGreen = 1, //green
eLEDRed, //red
eLEDYellow, //yellow
eLEDBlue, //blue
eLEDCyan, //cyan
eLEDMagenta, //magenta
eLEDWhite //white
}eLEDColor_t;
typedef enum{
e9600bps = 1,
e19200bps,
e38400bps,
e57600bps,
e115200bps
}eDeviceBaudrate_t;
typedef enum{
eErrorSuccess = 0x00, //Command processed successfully
eErrorFail = 0x01, //Command processing failed
eErrorVerify = 0x10, //1:1 Templates comparison in specific ID failed
eErrorIdentify = 0x11, //1:N comparison has been made, no same templates here
eErrorTmplEmpty = 0x12, //No registered template in the designated ID
eErrorTmplNotEmpty = 0x13, //Template already exists in the specified ID
eErrorAllTmplEmpty = 0x14, //No registered Template
eErrorEmptyIDNoexist = 0x15, //No registerable Template ID
eErrorBrokenIDNoexist = 0x16, //No damaged Template
eErrorInvalidTmplData = 0x17, //The designated Template Data is invalid
eErrorDuplicationID = 0x18, //The fingerprint has been registered
eErrorBadQuality = 0x19, //Poor quality fingerprint image
eErrorMergeFail = 0x1A, //Template synthesis failed
eErrorNotAuthorized = 0x1B, //Communication password not authorized
eErrorMemory = 0x1C, //Error in exernal Flash burning
eErrorInvalidTmplNo = 0x1D, //The designated template ID is invalid
eErrorInvalidParam = 0x22, //Incorrect parameter has been used
eErrorTimeOut = 0x23, //Acquisition timeout
eErrorGenCount = 0x25, //Invalid number of fingerprint synthesis
eErrorInvalidBufferID = 0x26, //Wrong Buffer ID value
eErrorFPNotDetected = 0x28, //No fingerprint input into fingerprint reader
eErrorFPCancel = 0x41, //Command cancelled
eErrorRecvLength = 0x42, //Wrong length of recieved data
eErrorRecvCks = 0x43, //Wrong check code
eErrorGatherOut = 0x45, //Exceed upper limit of acquisition times
eErrorRecvTimeout = 0x46 //Communication timeout
}eError_t;
typedef struct{
/**< Gesture enumeration variable X */
eError_t error;
/**< Description about the gesture enumeration variable X */
const char * description;
}sErrorDescription_t;
public:
DFRobot_ID809();
~DFRobot_ID809();
/**
* @brief Init communication port
* @param Software serial or hardware serial
* @return true or false
*/
bool begin(Stream &s_);
/**
* @brief Test whether the module connection is ok
* @return true or false
*/
bool isConnected();
/**
* @brief Set module ID
* @param ID:1-255
* @return 0(succeed) or ERR_ID809
*/
uint8_t setDeviceID(uint8_t deviceID);
/**
* @brief Set module security level
* @param security level:1-5
* @return 0(succeed) or ERR_ID809
*/
uint8_t setSecurityLevel(uint8_t securityLevel);
/**
* @brief Set module fingerprint replication check (Check whether the fingperint has been registered when saving it)
* @param 1(ON) or 0(OFF)
* @return 0(succeed) or ERR_ID809
*/
uint8_t setDuplicationCheck(uint8_t duplicationCheck);
/**
* @brief Set module baud rate
* @param Baudrate:in typedef enum eDeviceBaudrate_t
* @return 0(succeed) or ERR_ID809
*/
uint8_t setBaudrate(eDeviceBaudrate_t baudrate);
/**
* @brief Set module self-learning function (Update fingeprint when fingerprint comparison succeeds)
* @param 1(ON) or 0(OFF)
* @return 0(succeed) or ERR_ID809
*/
uint8_t setSelfLearn(uint8_t selfLearn);
/**
* @brief Read module ID
* @return ID号:1-255 or ERR_ID809
*/
uint8_t getDeviceID();
/**
* @brief Read module security level
* @return Security level:1-5 or ERR_ID809
*/
uint8_t getSecurityLevel();
/**
* @brief Read module fingerprint replication check status
* @return Status:1(ON), 0(OFF) or ERR_ID809
*/
uint8_t getDuplicationCheck();
/**
* @brief Read module baud rate
* @return Baudrate:in typedef enum eDEVICE_BAUDRATE_t or ERR_ID809
*/
uint8_t getBaudrate();
/**
* @brief Read module self-learning function status
* @return Status:1(ON), 0(OFF) or ERR_ID809
*/
uint8_t getSelfLearn();
uint8_t getTemplate(uint16_t id,uint8_t * temp);
uint8_t downLoadTemplate(uint16_t id,uint8_t * temp);
uint8_t getFingerImage(uint8_t *image);
uint8_t downLoadImage(uint16_t id,uint8_t * temp);
uint8_t receiveImageData(uint8_t *image);
uint8_t getQuarterFingerImage(uint8_t *image);
uint8_t contrastTemplate(uint8_t *temp);
/**
* @brief Read device number
* @return Device number
*/
String getDeviceInfo();
/**
* @brief Set serial number
* @param String pointer
* @return 0(succeed) or ERR_ID809
*/
uint8_t setModuleSN(const char* SN);
/**
* @brief Read serial number
* @return Serial number
*/
String getModuleSN();
/**
* @brief Set LED
* @param mode:in typedef enum eLEDMode_t
* @param color:in typedef enum eLEDColor_t
* @param blink Count: 00 represents blinking all the time
* @This parameter will only be valid in mode eBreathing, eFastBlink, eSlowBlink
* @return 0(succeed) or ERR_ID809
*/
uint8_t ctrlLED(eLEDMode_t mode,eLEDColor_t color,uint8_t blinkCount);
/**
* @brief Detect if there is finger touched
* @return 1(Touched) or 0(No touch)
*/
uint8_t detectFinger();
/**
* @brief Get the first registerable ID
* @return Registerable ID or ERR_ID809
*/
uint8_t getEmptyID();
/**
* @brief Check if the ID has been registered
* @return 0(Registered), 1(Unregistered) or ERR_ID809
*/
uint8_t getStatusID(uint8_t ID);
/**
* @brief Get the number of registered users
* @return Number of registered users or ERR_ID809
*/
uint8_t getEnrollCount();
/**
* @brief Get registered user list
* @return 0(succeed) or ERR_ID809
*/
uint8_t getEnrolledIDList(uint8_t* list);
/**
* @brief Fingerprint acquisition
* @return 0(succeed) or ERR_ID809
*/
uint8_t collectionFingerprint(uint16_t timeout,int ramNumber = -1);
/**
* @brief Save fingerprint
* @param Fingerprint ID
* @return 0(succeed) or ERR_ID809
*/
uint8_t storeFingerprint(uint8_t ID);
/**
* @brief Delete fingerprint
* @param Delete ID or DELALL(delete all)
* @return 0(succeed) or ERR_ID809
*/
uint8_t delFingerprint(uint8_t ID);
/**
* @brief Match the fingerprint with all fingeprints
* @return Successfully matched fingerprint ID, 0(Matching failed) or ERR_ID809
*/
uint8_t search();
/**
* @brief Match the fingerprint with specific fingerprint
* @return Successfully matched fingerprint ID, 0(Matching failed) or ERR_ID809
*/
uint8_t verify(uint8_t ID);
/**
* @brief Compare templates in two specific RamBuffers
* @param RamBuffer number
* @param RamBuffer number
* @return 0(succeed) or ERR_ID809
*/
uint8_t match(uint8_t RamBufferID0, uint8_t RamBufferID1);
/**
* @brief Get the number of damaged fingerprints
* @return Damaged fingerprint ID or ERR_ID809
*/
uint8_t getBrokenQuantity();
/**
* @brief Get the first damaged fingerprint ID
* @return Damaged fingerprint ID or ERR_ID809
*/
uint8_t getBrokenID();
/**
* @brief Take out fingerprint template, temporarily save into RamBuffer
* @param Fingerprint ID
* @param RamBuffer number 0-2
* @return 0(succeed) or ERR_ID809
*/
uint8_t loadFingerprint(uint8_t ID, uint8_t RamBufferID);
/**
* @brief Enter Standby mode
* @return 0(succeed) or ERR_ID809
*/
uint8_t enterStandbyState();
/**
* @brief Get error information
* @return Text description of error information
*/
String getErrorDescription();
bool setDbgSerial(Stream &s_){dbg = &s_; return true;}
uint16_t FINGERPRINT_CAPACITY = 80;
protected:
/**
* @brief Set parameter
* @param Data type+ data
* @return 0(succeed) or ERR_ID809
*/
uint8_t setParam(uint8_t* data);
/**
* @brief Read parameter
* @param Data type
* @return data or ERR_ID809
*/
uint8_t getParam(uint8_t* data);
/**
* @brief Capture fingerprint image
* @return 0(succeed) or ERR_ID809
*/
uint8_t getImage();
/**
* @brief Take image as template
* @param Ram Buffer number
* @return 0(succeed) or ERR_ID809
*/
uint8_t generate(uint8_t RamBufferID);
/**
* @brief Fingerprint synthesis
* @return 0(succeed) or ERR_ID809
*/
uint8_t merge();
/**
* @brief Packing data frame
* @param Data type:CMD_TYPE or DATA_TYPE
* @param Command
* @param Data
* @param Length
* @return Data frame
*/
pCmdPacketHeader_t pack(uint8_t type, uint16_t cmd, const char *payload, uint16_t len);
/**
* @brief Send data
* @param Data frame
*/
void sendPacket(pCmdPacketHeader_t header);
/**
* @brief Read byte
* @param Pointer for saving data
* @param Length of data to be received
* @return Actual received data length
*/
size_t readN(void* buf_, size_t len);
/**
* @brief Read frame header
* @param Frame header struct of response packet
* @return Response packet type:RCM_TYPE,DATA_TYPE or 1(reading timeout)
*/
uint16_t readPrefix( pRcmPacketHeader_t header );
/**
* @brief Read data
* @param Pointer for saving data
* @return 0(success) or ERR_ID809
*/
uint8_t responsePayload(void* buf);
/**
* @brief Get command packet CKS
* @param Command packet frame
* @return CKS
*/
uint16_t getCmdCKS(pCmdPacketHeader_t packet);
/**
* @brief Get response packet CKS
* @param Response packet frame
* @return CKS
*/
uint16_t getRcmCKS(pRcmPacketHeader_t packet);
uint8_t store(uint8_t ID);
private:
Stream *s;
uint8_t buf[20]; //For saving response packet data
pCmdPacketHeader_t sendHeader;
pRcmPacketHeader_t recHeader;
static const sErrorDescription_t /*PROGMEM*/ errorDescriptionsTable[26]; //Error information list
uint8_t _number = 0; //Fingerprint acquisistion times
uint8_t _state = 0; //Collect fingerprint state
eError_t _error; //Error code
uint16_t _PacketSize = 0; //Data packet length to be sent
};
#endif
all: desktop_test
uECC.o : uECC.c
gcc -Wall -c uECC.c
desktop_test: desktop_test.cpp sha256.c u2f.ino uECC.o
g++ -Wall -DIS_DESKTOP_TEST=1 desktop_test.cpp sha256.c uECC.o -o desktop_test
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// to prevent arduino IDE from compiling this
#ifdef IS_DESKTOP_TEST
// test in desktop
#define _POSIX_C_SOURCE 200809L
#include <inttypes.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>
// for storing fake eprom
#include <map>
// for fake input
#include <cctype>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#define DESKTOP_TEST
// fake eprom
#define F(X) X
typedef unsigned char byte;
// this is used for random
enum OUTPUT_FORMAT_ENUM { HEX = 1 };
std::vector<std::string> fake_input;
int current_fake_input;
int hexchar2int(int c)
{
if (c <= '9')
return c - '0';
return 10 + (c - 'A');
}
void hex2bytes(const std::string& inp, unsigned char** res, int* len)
{
std::string tmp;
// ignore non hex characters (e.g: space, tab)
for (size_t i = 0; i < inp.size(); i++) {
int c = toupper(inp[i]);
if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) {
tmp += (char)c;
}
}
*len = tmp.size() / 2;
unsigned char* tmpres = (unsigned char*)malloc(*len);
size_t j = 0;
for (size_t i = 0; i < tmp.size(); i += 2, j++) {
unsigned int c1 = hexchar2int(tmp[i]);
unsigned int c2 = hexchar2int(tmp[i + 1]);
unsigned int c = (c1 << 4) + c2;
tmpres[j] = c;
}
*res = tmpres;
}
int get_next_fake_input(unsigned char** res)
{
if (current_fake_input >= fake_input.size())
return -1;
int len;
printf("CURRENT FAKE INPUT: %s\n", fake_input[current_fake_input].c_str());
hex2bytes(fake_input[current_fake_input++], res, &len);
return len;
}
void read_file(const std::string& filename)
{
std::ifstream file(filename);
std::string temp;
while (std::getline(file, temp)) {
fake_input.push_back(temp);
}
current_fake_input = 0;
}
int RNG(uint8_t* dest, unsigned size)
{
for (int i = 0; i < size; i++) {
dest[i] = rand() % 255;
}
return 1;
}
long system_millis()
{
#if 0
long ms; // Milliseconds
time_t s; // Seconds
struct timespec spec;
clock_gettime(CLOCK_REALTIME, &spec);
s = spec.tv_sec;
ms = round(spec.tv_nsec / 1.0e6); // Convert nanoseconds to milliseconds
return s*1000 + ms;
#endif
struct timeval tv;
gettimeofday(&tv, NULL);
long time_in_mill = (tv.tv_sec) * 1000
+ (tv.tv_usec) / 1000; // convert tv_sec & tv_usec to millisecond
return time_in_mill;
}
int millis() { return 0; }
void delayMicroseconds(int micro) { }
class EEPROMClass {
std::map<int, unsigned int> values;
public:
void get(int address, unsigned int& value) { value = values[address]; }
void put(int address, int value) { values[address] = value; }
};
class SerialClass {
public:
void begin(int speed) { }
void print(const char* msg) { printf("%s", msg); }
void println() { printf("\n"); }
void println(const char* msg) { printf("%s\n", msg); }
void println(int number) { printf("%d\n", number); }
void print(int number, OUTPUT_FORMAT_ENUM e) { printf("%02x", number); }
void println(int number, OUTPUT_FORMAT_ENUM e) { printf("%02x", number); }
};
class RawHIDClass {
public:
void send(byte* buffer, int to)
{
printf("HID SEND: ");
for (int i = 0; i < 64; i++) {
printf("%02x ", buffer[i]);
}
printf("\n");
}
int recv(byte* buffer, int timeout)
{
unsigned char* inp;
int len = get_next_fake_input(&inp);
if (len == -1) {
printf("END OF INPUT\n");
exit(0);
}
printf("HID READ: ");
for (int i = 0; i < len; i++) {
printf("%02x ", inp[i]);
}
printf("\n");
memcpy(buffer, inp, len);
free(inp);
return len;
}
};
SerialClass Serial;
RawHIDClass RawHID;
EEPROMClass EEPROM;
#include "u2f.ino"
int main(int argc, char* argv[])
{
if (argc < 2) {
printf("usage desktop_test <INPUT>\n");
return 0;
}
read_file(argv[1]);
setup();
while (1) {
loop();
}
}
#endif
/* Copyright 2015, Kenneth MacKay. Licensed under the BSD 2-clause license. */
#ifndef _UECC_PLATFORM_SPECIFIC_H_
#define _UECC_PLATFORM_SPECIFIC_H_
#include "types.h"
#if (defined(_WIN32) || defined(_WIN64))
/* Windows */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <wincrypt.h>
static int default_RNG(uint8_t *dest, unsigned size) {
HCRYPTPROV prov;
if (!CryptAcquireContext(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
return 0;
}
CryptGenRandom(prov, size, (BYTE *)dest);
CryptReleaseContext(prov, 0);
return 1;
}
#define default_RNG_defined 1
#elif defined(unix) || defined(__linux__) || defined(__unix__) || defined(__unix) || \
(defined(__APPLE__) && defined(__MACH__)) || defined(uECC_POSIX)
/* Some POSIX-like system with /dev/urandom or /dev/random. */
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
static int default_RNG(uint8_t *dest, unsigned size) {
int fd = open("/dev/urandom", O_RDONLY | O_CLOEXEC);
if (fd == -1) {
fd = open("/dev/random", O_RDONLY | O_CLOEXEC);
if (fd == -1) {
return 0;
}
}
char *ptr = (char *)dest;
size_t left = size;
while (left > 0) {
ssize_t bytes_read = read(fd, ptr, left);
if (bytes_read <= 0) { // read failed
close(fd);
return 0;
}
left -= bytes_read;
ptr += bytes_read;
}
close(fd);
return 1;
}
#define default_RNG_defined 1
#endif /* platform */
#endif /* _UECC_PLATFORM_SPECIFIC_H_ */
void readFingerPrint() {
static uint8_t codeBlock = 1;
static uint8_t ret = 0;
/*Set fingerprint LED ring mode, color, and number of blinks
Can be set as follows:
Parameter 1:<LEDMode>
eBreathing eFastBlink eKeepsOn eNormalClose
eFadeIn eFadeOut eSlowBlink
Parameter 2:<LEDColor>
eLEDGreen eLEDRed eLEDYellow eLEDBlue
eLEDCyan eLEDMagenta eLEDWhite
Parameter 3:<number of blinks> 0 represents blinking all the time
This parameter will only be valid in mode eBreathing, eFastBlink, eSlowBlink
*/
Serial.print("codeBlock");
Serial.println(codeBlock);
Serial.println("ret:");
Serial.println(ret);
switch(codeBlock){
case 1: fingerprint.ctrlLED(/*LEDMode = */fingerprint.eBreathing, /*LEDColor = */fingerprint.eLEDBlue, /*blinkCount = */0);
//Serial.println("Please press down your finger");
/*Capture fingerprint image, Disable the collection timeout function
If succeed return 0, otherwise return ERR_ID809
*/
++codeBlock;
return;
case 2: if(((fingerprint.collectionFingerprint(/*timeout=*/0)) != ERR_ID809)){
++codeBlock;
return;
}
else
return;
// fingerprint.collectionFingerprint(0);
/*Set fingerprint LED ring to quick blink in yellow 3 times*/
case 3: fingerprint.ctrlLED(/*LEDMode = */fingerprint.eFastBlink, /*LEDColor = */fingerprint.eLEDYellow, /*blinkCount = */3);
// Serial.println("Capturing succeeds");
// Serial.println("Please release your finger");
/*Wait for finger to release
Return 1 when finger is detected, otherwise return 0
*/
++codeBlock;
return;
case 4: while (fingerprint.detectFinger());
//fingerprint.detectFinger();
/*Compare the captured fingerprint with all the fingerprints in the fingerprint library
Return fingerprint ID(1-80) if succeed, return 0 when failed
*/
++codeBlock;
return;
case 5: ret = fingerprint.search();
/*Compare the captured fingerprint with a fingerprint of specific ID
Return fingerprint ID(1-80) if succeed, return 0 when failed
*/
//ret = fingerprint.verify(/*Fingerprint ID = */1);
++codeBlock;
return;
case 6: if (ret != 0) {
/*Set fingerprint LED ring to always ON in green */
fingerprint.ctrlLED(/*LEDMode = */fingerprint.eKeepsOn, /*LEDColor = */fingerprint.eLEDGreen, /*blinkCount = */0);
Serial.print("Matching succeeds,ID=");
Serial.println(ret);
//delay(1000);
//return 1;
button_pressed = 1;
} else {
/*Set fingerprint LED ring to always ON in red*/
fingerprint.ctrlLED(/*LEDMode = */fingerprint.eKeepsOn, /*LEDColor = */fingerprint.eLEDRed, /*blinkCount = */0);
Serial.println("Matching fails");
//delay(1000);
//return 0;
button_pressed = 0;
}
codeBlock = 1;
break;
default: codeBlock = 1 ;
break;
}
// //Serial.println("-----------------------------");
// delay(1000);
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
src/uECC.c 0 → 100644
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment