Program for R306 fingerprint module

Dependencies:   FPC_R306_fingerprintmodule SDFileSystem WIZnetInterface mbed-src

Fork of GT511C3_TimeStamp_WIZwiki-W7500 by WIZnet

Files at this revision

API Documentation at this revision

Comitter:
hjjeon
Date:
Thu Jul 30 08:18:00 2015 +0000
Parent:
9:9becf9ddb86e
Child:
11:32515dcc6993
Commit message:
Time stamp using fingerprint with WIZwiki-W7500.

Changed in this revision

NTPClient.lib Show annotated file Show diff for this revision Revisions of this file
SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
WIZnetInterface.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-src.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NTPClient.lib	Thu Jul 30 08:18:00 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/donatien/code/NTPClient/#36be990f21be
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Thu Jul 30 08:18:00 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/azsymaivan/code/SDFileSystem/#f242d7bdef28
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIZnetInterface.lib	Thu Jul 30 08:18:00 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/#3b64df29662f
--- a/main.cpp	Thu Jul 30 00:46:05 2015 +0000
+++ b/main.cpp	Thu Jul 30 08:18:00 2015 +0000
@@ -1,47 +1,78 @@
 #include "mbed.h"
 #include "GT511C3.hpp"
+#include "SDFileSystem.h"
+#include "EthernetInterface.h"
+#include "NTPClient.h"
 
 #define MAX_ID_NUM  20
 
-Serial debug(USBTX,USBRX);
-
-
 #ifdef TARGET_WIZWIKI_W7500
 GT511C3 finger(PA_13,PA_14);
 DigitalIn del_ID(D7);
 DigitalIn enroll_ID(D8);
+InterruptIn in(D9);
+SDFileSystem sd(PB_3, PB_2, PB_1, PB_0, "sd"); // the pinout on the mbed
+uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x11, 0x22, 0xab};
 #endif
 
+Serial pc(USBTX,USBRX);
+EthernetInterface eth;
+NTPClient ntpClient;
+
+FILE *fp;
+
+
 int progress(int status,char *msg)
 {
-    debug.printf("%s",msg);
+    pc.printf("%s",msg);
     return 0;
 }
 
+void close_file(void)
+{
+    fclose(fp);
+}
+
 int main()
 {
+    int i;
     int sts = 0;
     int ID = 0;
     int cnt = 0;
     int EnrollID;
+    
+    char domainName[3][80] = {"kr.pool.ntp.org", "time.bora.net", "time.nuri.net"};//SET TO DOMAIN NAME OF SERVER GETTING TIME FROM
+    char buffer[80]; //BUFFER TO HOLD FORMATTED TIME DATA
+    time_t sysTime;
+        
+    in.rise(&close_file);
 
-    debug.baud(115200);
-    printf("Try to Open Device....\r\n");
+    pc.baud(115200);
+    
+    printf("File open...\r\n");
+    
+    if((fp = fopen("/sd/time.txt", "w")) == NULL)
+    {
+        printf("Cannot open file!!\r\n");
+        return 0;
+    }
+    
+    printf("GT511C3 open....\r\n");
     
     while(1)
     {
         sts = finger.Open();
         if(sts == -1)
         {
-            printf("Open failed!!\r\n");
+            printf("GT511C3 Open failed!!\r\n");
             cnt++;
             while(cnt > 5);
         }
         else
         {
-            printf("Open Success!!\r\n");
             break;
         }
+        
         wait(0.2);
     }
     
@@ -72,6 +103,42 @@
         finger.Enroll(EnrollID,progress);
     }
     
+    eth.init(mac_addr); //Use DHCP
+    printf("Check Ethernet Link\r\n");
+    while(1) //Wait link up
+    {
+        if(eth.link() == true) 
+            break;
+    }
+    printf("Link up\r\n");
+    printf("Getting IP address by DHCP...\r\n");
+    eth.connect();
+    printf("Server IP Address is %s\r\n", eth.getIPAddress());
+    
+    printf("Getting time information by using NTP...\r\n");
+    
+    cnt = 0;
+    while(1)
+    {
+        if(ntpClient.setTime(domainName[cnt],123,0x00005000) != NTP_OK)
+        {
+            printf("Cannot get time information by NTP\r\n");
+            cnt++;
+        }
+        else
+            break;
+            
+        if(cnt > 3)
+        {
+            printf("All NTP servers are not resposed!!\r\n");
+            return 1;
+        }
+    }
+        
+    printf("Completed Get and Set Time\r\n\r\n");
+    eth.disconnect();
+    
+    //Start to capture fingerprint
     finger.CmosLed(1);
     
     while(1)
@@ -86,13 +153,17 @@
         if(ID == -1)
             printf("\r\nERROR : There is no ID!!Enroll first!!\r\n\r\n");
         else
+        {
             printf("ID = %d\r\n",ID); 
+            sysTime = time(NULL)+(3600*9); //TIME with offset for eastern time KR
+            //FORMAT TIME FOR DISPLAY AND STORE FORMATTED RESULT IN BUFFER
+            strftime(buffer,80,"%Y/%m/%d  %p %I:%M:%S \r\n",localtime(&sysTime));
+            fprintf(fp, "ID : %d\r\nTime : %s\r\n", ID, buffer);
+            printf("Univ Time Clock\r\n%s\r\n", buffer);
+        }
             
         printf("Remove finger\r\n");
         finger.WaitPress(0);
-        
     }
-    
-        
 }
 
--- a/mbed-src.lib	Thu Jul 30 00:46:05 2015 +0000
+++ b/mbed-src.lib	Thu Jul 30 08:18:00 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-src/#5e59b9938d4a
+http://mbed.org/users/mbed_official/code/mbed-src/#2d5fc5624619