Program for R306 fingerprint module interfaced with Wiz750SR S2E device
Dependencies: FPC_R306 MQTT WIZnetInterface mbed
Fork of GT511C3_TimeStamp_WIZwiki-W7500 by
Diff: main.cpp
- Revision:
- 8:574087f87b1e
- Parent:
- 7:8b9ef3211cd0
- Child:
- 10:7b0c02f61513
--- a/main.cpp Fri Jan 03 16:03:44 2014 +0000 +++ b/main.cpp Thu Jul 30 00:43:42 2015 +0000 @@ -1,10 +1,16 @@ #include "mbed.h" #include "GT511C3.hpp" +#define MAX_ID_NUM 20 + Serial debug(USBTX,USBRX); -DigitalOut myled(LED1); -GT511C3 finger(p28,p27); + +#ifdef TARGET_WIZWIKI_W7500 +GT511C3 finger(PA_13,PA_14); +DigitalIn del_ID(D7); +DigitalIn enroll_ID(D8); +#endif int progress(int status,char *msg) { @@ -12,50 +18,81 @@ return 0; } -int main() { +int main() +{ int sts = 0; int ID = 0; - - debug.format(8,Serial::None,1); - debug.baud(115200); - - debug.printf("Fingerprint reader module \"GT-511C3 / GT-511C31\" test program.\n"); - debug.printf("Build: %s %s\n",__DATE__,__TIME__); + int cnt = 0; + int EnrollID; - debug.printf("Open\n"); - sts = finger.Open(); - debug.printf("sts = %d\n",sts); - if(sts == 0){ - int i; - debug.printf("FirmwareVersion = %lx\n",finger.FirmwareVersion); - debug.printf("IsoAreaMaxSize = %ld\n",finger.IsoAreaMaxSize); - debug.printf("DeviceSerialNumber = "); - for(i = 0; i < sizeof(finger.DeviceSerialNumber);i++){ - debug.printf("%02X",finger.DeviceSerialNumber[i]); + debug.baud(115200); + printf("Try to Open Device....\r\n"); + + while(1) + { + sts = finger.Open(); + if(sts == -1) + { + printf("Open failed!!\r\n"); + cnt++; + while(cnt > 5); + } + else + { + printf("Open Success!!\r\n"); + break; } - debug.printf("\n"); + wait(0.2); + } + + if(del_ID == 1) + { + finger.DeleteID_All(); + printf("All ID are deleted!!\r\n"); } - - if(1){ - int EnrollID = 11; - if(finger.CheckEnrolled(EnrollID) == 0){ - debug.printf("EnrollID(%d) is already enrolled.Delete!\n",EnrollID); - if(finger.DeleteID(EnrollID) == 0){ - debug.printf("Delete OK!\n"); + + cnt = 0; + if(enroll_ID == 1) + { + while(1) + { + if(finger.CheckEnrolled(cnt) == -1) + { + EnrollID = cnt; + printf("ID(%d) is empty\r\n", EnrollID); + break; + } + cnt++; + if(cnt > MAX_ID_NUM) + { + printf("\r\nERROR : ID number is fulled!!Delete ID first!!\r\n\r\n"); + while(1); } } finger.Enroll(EnrollID,progress); } - + finger.CmosLed(1); - while(1) { - debug.printf("Press finger for Identify\n"); + + while(1) + { + printf("Press finger for Identify\r\n"); finger.WaitPress(1); if(finger.Capture(1) != 0) continue; + ID = finger.Identify(); - debug.printf("ID = %d\n",ID); - debug.printf("Remove finger\n"); + + if(ID == -1) + printf("\r\nERROR : There is no ID!!Enroll first!!\r\n\r\n"); + else + printf("ID = %d\r\n",ID); + + printf("Remove finger\r\n"); finger.WaitPress(0); + } + + } +