-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.c
71 lines (62 loc) · 1.81 KB
/
demo.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "R503_fingerprint.h"
int main(int argc, char ** argv)
{
__argc = argc;
__argv = argv;
int Err = 0, terminate = FALSE;
uint8_t flash_mem[2] = { 0x00, 0x00 };
#ifdef PIGPIO_PERMITTED
if(GpioConfig(NULL, &terminate))
return EGpioBadInit;
#endif
fprintf(stdout, "\n%s: Generate and store a reference finger template:", argv[0]);
if ((Err = GenFingerTemplate(flash_mem, &terminate)))
{
if (Err != ESigKill)
fprintf(stdout, "\n%s: Template creation unsuccessful.\n", argv[0]);
SetFpLed(R503_LED_OFF, 0x00, 0x00, 0x00);
return EOk;
}
fprintf(stdout, "\n\n\n%s: Match a finger with the stored template:", argv[0]);
if ((Err = GenFingerTemplate(NULL, &terminate)))
{
if (Err != ESigKill)
fprintf(stdout, "\n%s: Template creation unsuccessful.\n", argv[0]);
SetFpLed(R503_LED_OFF, 0x00, 0x00, 0x00);
return EOk;
}
if ((Err = LoadFingerTemplate(flash_mem, 2)))
{
fprintf(stdout, "\n%s: Stored template loading unsuccessful.\n", argv[0]);
SetFpLed(R503_LED_OFF, 0x00, 0x00, 0x00);
return EOk;
}
Err = MatchFingerTemplates();
if (!Err)
{
fprintf(stdout, "\n\n%s: SUCCESS! Finger matches.\n", argv[0]);
SetFpLed(R503_LED_FLASHING, R503_LED_BLUE, 0x20, 0x05);
WaitMicros((uint32_t)1500000);
SetFpLed(R503_LED_SLOW_ON, R503_LED_BLUE, 0x20, 0x00);
}
else if (Err == R503_ACK_ERR_NO_FP_MATCH)
{
fprintf(stdout, "\n\n%s: FAIL! Finger doesn't match.\n", argv[0]);
SetFpLed(R503_LED_FLASHING, R503_LED_RED, 0x20, 0x05);
WaitMicros((uint32_t)1500000);
SetFpLed(R503_LED_SLOW_ON, R503_LED_RED, 0x20, 0x00);
}
else
{
fprintf(stdout, "\n%s: Template matching unsuccessful.\n", argv[0]);
SetFpLed(R503_LED_OFF, 0x00, 0x00, 0x00);
return EOk;
}
while (!terminate)
{}
SetFpLed(R503_LED_OFF, 0x00, 0x00, 0x00);
#ifdef PIGPIO_PERMITTED
GpioCleanup();
#endif
return EOk;
}