Eugene Gonzalez
/
GT511C3_demo
small GT511C3 demo that enrolls a finger by downloading the template then setting the template.
main.cpp@1:4c720110a2a8, 2015-12-01 (annotated)
- Committer:
- beanmachine44
- Date:
- Tue Dec 01 20:49:44 2015 +0000
- Revision:
- 1:4c720110a2a8
- Parent:
- 0:4bbfc068d864
- Child:
- 2:61e0f5bec6ff
Updated with the fixes to the library to properly work to enroll a template by downloading it and then using SetTemplate
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
beanmachine44 | 0:4bbfc068d864 | 1 | #include "mbed.h" |
beanmachine44 | 0:4bbfc068d864 | 2 | #include "GT511C3.hpp" |
beanmachine44 | 0:4bbfc068d864 | 3 | |
beanmachine44 | 0:4bbfc068d864 | 4 | Serial debug(USBTX,USBRX); |
beanmachine44 | 0:4bbfc068d864 | 5 | |
beanmachine44 | 0:4bbfc068d864 | 6 | DigitalOut myled(LED1); |
beanmachine44 | 1:4c720110a2a8 | 7 | GT511C3 finger(p9,p10); |
beanmachine44 | 0:4bbfc068d864 | 8 | |
beanmachine44 | 0:4bbfc068d864 | 9 | int progress(int status,char *msg) |
beanmachine44 | 0:4bbfc068d864 | 10 | { |
beanmachine44 | 0:4bbfc068d864 | 11 | debug.printf("%s",msg); |
beanmachine44 | 0:4bbfc068d864 | 12 | return 0; |
beanmachine44 | 0:4bbfc068d864 | 13 | } |
beanmachine44 | 0:4bbfc068d864 | 14 | |
beanmachine44 | 0:4bbfc068d864 | 15 | int main() { |
beanmachine44 | 0:4bbfc068d864 | 16 | int sts = 0; |
beanmachine44 | 0:4bbfc068d864 | 17 | int ID = 0; |
beanmachine44 | 0:4bbfc068d864 | 18 | |
beanmachine44 | 0:4bbfc068d864 | 19 | debug.format(8,Serial::None,1); |
beanmachine44 | 0:4bbfc068d864 | 20 | debug.baud(115200); |
beanmachine44 | 0:4bbfc068d864 | 21 | |
beanmachine44 | 0:4bbfc068d864 | 22 | debug.printf("Fingerprint reader module \"GT-511C3 / GT-511C31\" test program.\n"); |
beanmachine44 | 0:4bbfc068d864 | 23 | debug.printf("Build: %s %s\n",__DATE__,__TIME__); |
beanmachine44 | 0:4bbfc068d864 | 24 | |
beanmachine44 | 0:4bbfc068d864 | 25 | debug.printf("Open\n"); |
beanmachine44 | 0:4bbfc068d864 | 26 | sts = finger.Open(); |
beanmachine44 | 0:4bbfc068d864 | 27 | debug.printf("sts = %d\n",sts); |
beanmachine44 | 0:4bbfc068d864 | 28 | if(sts == 0){ |
beanmachine44 | 0:4bbfc068d864 | 29 | int i; |
beanmachine44 | 0:4bbfc068d864 | 30 | debug.printf("FirmwareVersion = %lx\n",finger.FirmwareVersion); |
beanmachine44 | 0:4bbfc068d864 | 31 | debug.printf("IsoAreaMaxSize = %ld\n",finger.IsoAreaMaxSize); |
beanmachine44 | 0:4bbfc068d864 | 32 | debug.printf("DeviceSerialNumber = "); |
beanmachine44 | 0:4bbfc068d864 | 33 | for(i = 0; i < sizeof(finger.DeviceSerialNumber);i++){ |
beanmachine44 | 0:4bbfc068d864 | 34 | debug.printf("%02X",finger.DeviceSerialNumber[i]); |
beanmachine44 | 0:4bbfc068d864 | 35 | } |
beanmachine44 | 0:4bbfc068d864 | 36 | debug.printf("\n"); |
beanmachine44 | 0:4bbfc068d864 | 37 | } |
beanmachine44 | 0:4bbfc068d864 | 38 | |
beanmachine44 | 1:4c720110a2a8 | 39 | |
beanmachine44 | 0:4bbfc068d864 | 40 | int EnrollID = -1; |
beanmachine44 | 1:4c720110a2a8 | 41 | unsigned char data[498]; |
beanmachine44 | 1:4c720110a2a8 | 42 | debug.printf("Deleting IDs = %d\n", finger.DeleteAllIDs()); |
beanmachine44 | 0:4bbfc068d864 | 43 | finger.Enroll(EnrollID,progress); |
beanmachine44 | 1:4c720110a2a8 | 44 | debug.printf("RecvData = %d\n", finger.RecvData(data, 498)); |
beanmachine44 | 1:4c720110a2a8 | 45 | debug.printf("Data[0-3] = %X %X %X %X\n", data[0], data[1],data[2],data[3]); |
beanmachine44 | 1:4c720110a2a8 | 46 | debug.printf("SetTemplate = %d\n", finger.SetTemplate(11,data,498)); |
beanmachine44 | 0:4bbfc068d864 | 47 | |
beanmachine44 | 0:4bbfc068d864 | 48 | |
beanmachine44 | 0:4bbfc068d864 | 49 | finger.CmosLed(1); |
beanmachine44 | 0:4bbfc068d864 | 50 | while(1) { |
beanmachine44 | 0:4bbfc068d864 | 51 | debug.printf("Press finger for Identify\n"); |
beanmachine44 | 0:4bbfc068d864 | 52 | finger.WaitPress(1); |
beanmachine44 | 0:4bbfc068d864 | 53 | if(finger.Capture(1) != 0) |
beanmachine44 | 0:4bbfc068d864 | 54 | continue; |
beanmachine44 | 0:4bbfc068d864 | 55 | ID = finger.Identify(); |
beanmachine44 | 1:4c720110a2a8 | 56 | debug.printf("ID = %d\n",ID); |
beanmachine44 | 0:4bbfc068d864 | 57 | debug.printf("Remove finger\n"); |
beanmachine44 | 0:4bbfc068d864 | 58 | finger.WaitPress(0); |
beanmachine44 | 0:4bbfc068d864 | 59 | } |
beanmachine44 | 0:4bbfc068d864 | 60 | } |