Trung Nguyen / Mbed 2 deprecated FINAL_PROJECT_4180

Dependencies:   mbed

Fork of FINAL_PROJECT_4180 by Gedeon Nyengele

Files at this revision

API Documentation at this revision

Comitter:
nyengele
Date:
Mon Apr 25 00:50:42 2016 +0000
Parent:
2:1b1c0502bb08
Child:
4:9fbefd153e3e
Commit message:
face enrollment done!;

Changed in this revision

lib.cpp Show annotated file Show diff for this revision Revisions of this file
lib.h Show annotated file Show diff for this revision Revisions of this file
--- a/lib.cpp	Mon Apr 25 00:36:32 2016 +0000
+++ b/lib.cpp	Mon Apr 25 00:50:42 2016 +0000
@@ -1,6 +1,13 @@
 #include "mbed.h"
 #include "lib.h"
 
+#define CMD_ENROLL  0x01
+#define CMD_AUTH    0x02
+#define FACE_FID    0x01
+#define SPEECH_FID  0x02
+#define SUCCESS     0x55
+#define FAILURE     0x8A
+
 int hashcode(const char *data, int size)
 {
     int hash = 17;
@@ -55,4 +62,29 @@
     if (fp->Identify1_N() != 200) status = true;
     fp->SetLED(false);
     return status;
-}
\ No newline at end of file
+}
+
+bool face_enroll(char *user_id, Serial *android)
+{
+    char CMD[] = {
+        CMD_ENROLL,
+        0x02,
+        0x04,
+        0x01,
+        user_id[0],
+        user_id[1],
+        user_id[2],
+        user_id[3],
+        FACE_FID,
+        '\0'
+    };
+
+    for (int i = 0; i < sizeof(CMD)/ sizeof(char); i++) {
+        android->putc(CMD[i]);
+    }
+    
+    while (!android->readable());
+    char temp = android->getc();
+    if (temp == SUCCESS) return true;
+    else return false;
+}
--- a/lib.h	Mon Apr 25 00:36:32 2016 +0000
+++ b/lib.h	Mon Apr 25 00:50:42 2016 +0000
@@ -4,4 +4,5 @@
 int hashcode(const char *data, int size);
 void read_mag_card(Serial *device, char *dest, int *size);
 bool fp_enroll(FPScanner *fp);
-bool fp_auth(FPScanner *fp);
\ No newline at end of file
+bool fp_auth(FPScanner *fp);
+bool face_enroll(char *user_id, Serial *android);
\ No newline at end of file