Fingerprint Scanner Library  0.5
Library for the Fingerprint Scanner (261
fingerprint.h
Go to the documentation of this file.
1 
14 #include "simpletools.h" // Include simple tools
15 #include "fdserial.h"
16 
17 #ifndef FINGERPRINT_H
18 #define FINGERPRINT_H
19 
20 
21 #define ACK_SUCCESS 0x00 // Operation successfully
22 #define ACK_FAIL 0x01 // Operation failed
23 #define ACK_FULL 0x04 // Fingerprint database is full
24 #define ACK_NOUSER 0x05 // No such user
25 #define ACK_USER_EXISTS 0x07 // already exists
26 #define ACK_TIMEOUT 0x08 // Acquisition timeout
27 
28 #define CMD_SLEEP 0x2C // Sleeps the device
29 #define CMD_SET_MODE 0x2D
30 #define CMD_ADD_FINGERPRINT_1 0x01
31 #define CMD_ADD_FINGERPRINT_2 0x02
32 #define CMD_ADD_FINGERPRINT_3 0x03
33 #define CMD_DELETE_USER 0x04
34 #define CMD_DELETE_ALL_USERS 0x05
35 #define CMD_GET_USERS_COUNT 0x09
36 #define CMD_SCAN_COMPARE_1_TO_1 0x0B
37 #define CMD_SCAN_COMPARE_1_TO_N 0x0C
38 #define CMD_READ_USER_PRIVLAGE 0x0A
39 #define CMD_SENSITIVITY 0x28
40 #define CMD_SCAN_GET_IMAGE 0x24
41 #define CMD_SCAN_GET_EIGENVALS 0x23
42 #define CMD_SCAN_PUT_EIGENVALS 0x44
43 #define CMD_PUT_EIGENVALS_COMPARE_1_TO_1 0x42
44 #define CMD_PUT_EIGENVALS_COMPARE_1_TO_N 0x43
45 #define CMD_GET_USER_EIGENVALS 0x31
46 #define CMD_PUT_USER_EIGENVALS 0x41
47 #define CMD_GET_USERS_INFO 0x2B
48 #define CMD_SET_SCAN_TIMEOUT 0x2E // How long to try scanning - multiples of ~0.25s
49 
50 
51 #if defined(__cplusplus)
52 extern "C" {
53 #endif
54 
55 
61 typedef struct fpScanner_st
62 {
63  int rx_head; /* receive queue head */
64  int rx_tail; /* receive queue tail */
65  int tx_head; /* transmit queue head */
66  int tx_tail; /* transmit queue tail */
67  int rx_pin; /* recieve pin */
68  int tx_pin; /* transmit pin */
69  int mode; /* interface mode */
70  int ticks; /* clkfreq / baud */
71  char *buffptr; /* pointer to rx buffer */
72  //char *idstr;
73  //int en;
74 } fpScanner_t;
75 
76 
81 typedef text_t fpScanner;
82 
83 
101 fpScanner *fingerprint_open(int pin_rx, int pin_tx);
102 
109 void fingerprint_close(fpScanner *device);
110 
111 
127 void fingerprint_sendCommand(fpScanner *device, char __fpCmd, char __fpParam1, char __fpParam2, char __fpParam3);
128 
129 
139 void fingerprint_readResponse(fpScanner *device, char *__fpResponse);
140 
141 
142 //ACK_SUCCESS, ACK_FAIL, ACK_FULL, ACK_NOUSER, ACK_FIN_EXIST, or ACK_TIMEOUT
143 
144 
154 int fingerprint_allowOverwrite(fpScanner *device, char b);
155 
156 
175 int fingerprint_add(fpScanner *device, int userId, char userLevel, int scanNumber);
176 
177 
189 int fingerprint_deleteUser(fpScanner *device, int userId);
190 
191 
199 int fingerprint_countUsers(fpScanner *device);
200 
201 
216 int fingerprint_scan(fpScanner *device, int userId, int *uid);
217 
218 
228 int fingerprint_lookupUserPrivlage(fpScanner *device, int userId);
229 
240 int fingerprint_setTimeout(fpScanner *device, int timeout);
241 
252 int fingerprint_setStrictness(fpScanner *device, char s_level);
253 
254 
255 
256 #if defined(__cplusplus)
257 }
258 #endif
259 /* __cplusplus */
260 #endif
261 /* FINGERPRINT_H */
262 
263 
void fingerprint_close(fpScanner *device)
Close a connection and recover all memory set aside for the fingerprint scanner instance.
Definition: fingerprint.c:64
int fingerprint_scan(fpScanner *device, int userId, int *uid)
Scans a user fingerprint and compares it to the provided User ID. If no User ID is provided...
Definition: fingerprint.c:201
int fingerprint_lookupUserPrivlage(fpScanner *device, int userId)
Looks up the stored user privalage for the provided User ID.
Definition: fingerprint.c:228
int fingerprint_deleteUser(fpScanner *device, int userId)
Deletes a user (or all users if no user is specified) from the fingerprint module's memory...
Definition: fingerprint.c:168
void fingerprint_sendCommand(fpScanner *device, char __fpCmd, char __fpParam1, char __fpParam2, char __fpParam3)
Low-level function used to send a command to the Fingerprint Scanner.
Definition: fingerprint.c:82
void fingerprint_readResponse(fpScanner *device, char *__fpResponse)
Low-level function used to read a response from the Fingerprint Scanner.
Definition: fingerprint.c:103
int fingerprint_setTimeout(fpScanner *device, int timeout)
Sets the timeout for a single scan.
Definition: fingerprint.c:244
int fingerprint_add(fpScanner *device, int userId, char userLevel, int scanNumber)
Add a user's fingerprint and info to the fingerprint scanner's memory.
Definition: fingerprint.c:131
int fingerprint_countUsers(fpScanner *device)
Returns the number or users stored in the fingerprint scanner's memory.
Definition: fingerprint.c:188
fpScanner * fingerprint_open(int pin_rx, int pin_tx)
Open a connection to a WaveShare fingerprint scanner module.
Definition: fingerprint.c:18
int fingerprint_allowOverwrite(fpScanner *device, char b)
Allow overwriting of fingerprints already stored in the memory of the Fingerprint Scanner...
Definition: fingerprint.c:119
int fingerprint_setStrictness(fpScanner *device, char s_level)
Sets the comparison strictness.
Definition: fingerprint.c:257