Library for R306 fingerprint module
Dependents: R306_fingerprintmodule_WizwikiW7500
Fork of GT511C3 by
GT511C3.cpp@0:90c64cb9db58, 2014-01-03 (annotated)
- Committer:
- tosihisa
- Date:
- Fri Jan 03 16:00:00 2014 +0000
- Revision:
- 0:90c64cb9db58
- Child:
- 1:e53c3965131e
Class library of fingerprint reader module "GT-511C3 / GT-511C31".;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tosihisa | 0:90c64cb9db58 | 1 | /** |
tosihisa | 0:90c64cb9db58 | 2 | * @section LICENSE |
tosihisa | 0:90c64cb9db58 | 3 | * |
tosihisa | 0:90c64cb9db58 | 4 | * Copyright (c) 2013 @tosihisa, MIT License |
tosihisa | 0:90c64cb9db58 | 5 | * |
tosihisa | 0:90c64cb9db58 | 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
tosihisa | 0:90c64cb9db58 | 7 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
tosihisa | 0:90c64cb9db58 | 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
tosihisa | 0:90c64cb9db58 | 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
tosihisa | 0:90c64cb9db58 | 10 | * furnished to do so, subject to the following conditions: |
tosihisa | 0:90c64cb9db58 | 11 | * |
tosihisa | 0:90c64cb9db58 | 12 | * The above copyright notice and this permission notice shall be included in all copies or |
tosihisa | 0:90c64cb9db58 | 13 | * substantial portions of the Software. |
tosihisa | 0:90c64cb9db58 | 14 | * |
tosihisa | 0:90c64cb9db58 | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
tosihisa | 0:90c64cb9db58 | 16 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
tosihisa | 0:90c64cb9db58 | 17 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
tosihisa | 0:90c64cb9db58 | 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
tosihisa | 0:90c64cb9db58 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
tosihisa | 0:90c64cb9db58 | 20 | * |
tosihisa | 0:90c64cb9db58 | 21 | * @section DESCRIPTION |
tosihisa | 0:90c64cb9db58 | 22 | * |
tosihisa | 0:90c64cb9db58 | 23 | * Fingerprint reader module "GT-511C3" class. |
tosihisa | 0:90c64cb9db58 | 24 | * |
tosihisa | 0:90c64cb9db58 | 25 | * http://www.adh-tech.com.tw/?22,gt-511c3-gt-511c31 |
tosihisa | 0:90c64cb9db58 | 26 | * http://www.adh-tech.com.tw/files/GT-511C3_datasheet_V1%201_20131127[1].pdf |
tosihisa | 0:90c64cb9db58 | 27 | * https://www.sparkfun.com/products/11792 |
tosihisa | 0:90c64cb9db58 | 28 | * https://github.com/sparkfun/Fingerprint_Scanner-TTL/ |
tosihisa | 0:90c64cb9db58 | 29 | */ |
tosihisa | 0:90c64cb9db58 | 30 | |
tosihisa | 0:90c64cb9db58 | 31 | #include "mbed.h" |
tosihisa | 0:90c64cb9db58 | 32 | #include "GT511C3.hpp" |
tosihisa | 0:90c64cb9db58 | 33 | |
tosihisa | 0:90c64cb9db58 | 34 | #define SET_AND_SUMADD(idx,val) sendbuf[idx]=((unsigned char)(val));sum += sendbuf[idx] |
tosihisa | 0:90c64cb9db58 | 35 | |
tosihisa | 0:90c64cb9db58 | 36 | int GT511C3::Init(void) |
tosihisa | 0:90c64cb9db58 | 37 | { |
tosihisa | 0:90c64cb9db58 | 38 | baud(9600); |
tosihisa | 0:90c64cb9db58 | 39 | ClearLine(); |
tosihisa | 0:90c64cb9db58 | 40 | return 0; |
tosihisa | 0:90c64cb9db58 | 41 | } |
tosihisa | 0:90c64cb9db58 | 42 | |
tosihisa | 0:90c64cb9db58 | 43 | int GT511C3::SendCommand(unsigned long Parameter,unsigned short Command) |
tosihisa | 0:90c64cb9db58 | 44 | { |
tosihisa | 0:90c64cb9db58 | 45 | unsigned char sendbuf[12]; |
tosihisa | 0:90c64cb9db58 | 46 | unsigned short sum = 0; |
tosihisa | 0:90c64cb9db58 | 47 | int idx = 0; |
tosihisa | 0:90c64cb9db58 | 48 | int i; |
tosihisa | 0:90c64cb9db58 | 49 | |
tosihisa | 0:90c64cb9db58 | 50 | SET_AND_SUMADD(idx,0x55); idx++; |
tosihisa | 0:90c64cb9db58 | 51 | SET_AND_SUMADD(idx,0xAA); idx++; |
tosihisa | 0:90c64cb9db58 | 52 | SET_AND_SUMADD(idx,0x01); idx++; |
tosihisa | 0:90c64cb9db58 | 53 | SET_AND_SUMADD(idx,0x00); idx++; |
tosihisa | 0:90c64cb9db58 | 54 | SET_AND_SUMADD(idx,Parameter & 0xff); idx++; |
tosihisa | 0:90c64cb9db58 | 55 | SET_AND_SUMADD(idx,(Parameter >> 8) & 0xff); idx++; |
tosihisa | 0:90c64cb9db58 | 56 | SET_AND_SUMADD(idx,(Parameter >> 16) & 0xff); idx++; |
tosihisa | 0:90c64cb9db58 | 57 | SET_AND_SUMADD(idx,(Parameter >> 24) & 0xff); idx++; |
tosihisa | 0:90c64cb9db58 | 58 | SET_AND_SUMADD(idx,Command & 0xff); idx++; |
tosihisa | 0:90c64cb9db58 | 59 | SET_AND_SUMADD(idx,(Command >> 8) & 0xff); idx++; |
tosihisa | 0:90c64cb9db58 | 60 | sendbuf[idx] = sum & 0xff; idx++; |
tosihisa | 0:90c64cb9db58 | 61 | sendbuf[idx] = (sum >> 8) & 0xff; idx++; |
tosihisa | 0:90c64cb9db58 | 62 | |
tosihisa | 0:90c64cb9db58 | 63 | for(i = 0;i < idx;i++){ |
tosihisa | 0:90c64cb9db58 | 64 | while(!writeable()); |
tosihisa | 0:90c64cb9db58 | 65 | putc(sendbuf[i]); |
tosihisa | 0:90c64cb9db58 | 66 | } |
tosihisa | 0:90c64cb9db58 | 67 | return 0; |
tosihisa | 0:90c64cb9db58 | 68 | } |
tosihisa | 0:90c64cb9db58 | 69 | |
tosihisa | 0:90c64cb9db58 | 70 | int GT511C3::RecvResponse(unsigned long *Parameter,unsigned short *Response) |
tosihisa | 0:90c64cb9db58 | 71 | { |
tosihisa | 0:90c64cb9db58 | 72 | const unsigned char fixedbuf[4] = { 0x55,0xAA,0x01,0x00 }; |
tosihisa | 0:90c64cb9db58 | 73 | unsigned char buf[12]; |
tosihisa | 0:90c64cb9db58 | 74 | unsigned short sum = 0; |
tosihisa | 0:90c64cb9db58 | 75 | int i; |
tosihisa | 0:90c64cb9db58 | 76 | |
tosihisa | 0:90c64cb9db58 | 77 | *Parameter = 0; |
tosihisa | 0:90c64cb9db58 | 78 | *Response = CMD_Nack; |
tosihisa | 0:90c64cb9db58 | 79 | |
tosihisa | 0:90c64cb9db58 | 80 | for(i = 0;i < sizeof(buf);i++){ |
tosihisa | 0:90c64cb9db58 | 81 | while(!readable()); |
tosihisa | 0:90c64cb9db58 | 82 | buf[i] = getc(); |
tosihisa | 0:90c64cb9db58 | 83 | if(i < 9){ |
tosihisa | 0:90c64cb9db58 | 84 | sum += buf[i]; |
tosihisa | 0:90c64cb9db58 | 85 | } |
tosihisa | 0:90c64cb9db58 | 86 | if(i < 4){ |
tosihisa | 0:90c64cb9db58 | 87 | if(buf[i] != fixedbuf[i]){ |
tosihisa | 0:90c64cb9db58 | 88 | return -1; |
tosihisa | 0:90c64cb9db58 | 89 | } |
tosihisa | 0:90c64cb9db58 | 90 | } |
tosihisa | 0:90c64cb9db58 | 91 | } |
tosihisa | 0:90c64cb9db58 | 92 | if(buf[10] != (sum & 0xff)) |
tosihisa | 0:90c64cb9db58 | 93 | return -2; |
tosihisa | 0:90c64cb9db58 | 94 | if(buf[11] != ((sum >> 8) & 0xff)) |
tosihisa | 0:90c64cb9db58 | 95 | return -2; |
tosihisa | 0:90c64cb9db58 | 96 | |
tosihisa | 0:90c64cb9db58 | 97 | *Parameter = buf[7]; |
tosihisa | 0:90c64cb9db58 | 98 | *Parameter = (*Parameter << 8) | buf[6]; |
tosihisa | 0:90c64cb9db58 | 99 | *Parameter = (*Parameter << 8) | buf[5]; |
tosihisa | 0:90c64cb9db58 | 100 | *Parameter = (*Parameter << 8) | buf[4]; |
tosihisa | 0:90c64cb9db58 | 101 | |
tosihisa | 0:90c64cb9db58 | 102 | *Response = buf[9]; |
tosihisa | 0:90c64cb9db58 | 103 | *Response = (*Response << 8) | buf[8]; |
tosihisa | 0:90c64cb9db58 | 104 | |
tosihisa | 0:90c64cb9db58 | 105 | return 0; |
tosihisa | 0:90c64cb9db58 | 106 | } |
tosihisa | 0:90c64cb9db58 | 107 | |
tosihisa | 0:90c64cb9db58 | 108 | int GT511C3::RecvData(unsigned char *data,unsigned long size) |
tosihisa | 0:90c64cb9db58 | 109 | { |
tosihisa | 0:90c64cb9db58 | 110 | const unsigned char fixedbuf[4] = { 0x5A,0xA5,0x01,0x00 }; |
tosihisa | 0:90c64cb9db58 | 111 | unsigned short sum = 0; |
tosihisa | 0:90c64cb9db58 | 112 | int i; |
tosihisa | 0:90c64cb9db58 | 113 | |
tosihisa | 0:90c64cb9db58 | 114 | for(i = 0;i < size;i++){ |
tosihisa | 0:90c64cb9db58 | 115 | while(!readable()); |
tosihisa | 0:90c64cb9db58 | 116 | *(data + i) = getc(); |
tosihisa | 0:90c64cb9db58 | 117 | if(i < (size-2)){ |
tosihisa | 0:90c64cb9db58 | 118 | sum += *(data + i); |
tosihisa | 0:90c64cb9db58 | 119 | } |
tosihisa | 0:90c64cb9db58 | 120 | if(i < 4){ |
tosihisa | 0:90c64cb9db58 | 121 | if(*(data + i) != fixedbuf[i]){ |
tosihisa | 0:90c64cb9db58 | 122 | return -1; |
tosihisa | 0:90c64cb9db58 | 123 | } |
tosihisa | 0:90c64cb9db58 | 124 | } |
tosihisa | 0:90c64cb9db58 | 125 | } |
tosihisa | 0:90c64cb9db58 | 126 | if(*(data + size - 2) != (sum & 0xff)) |
tosihisa | 0:90c64cb9db58 | 127 | return -2; |
tosihisa | 0:90c64cb9db58 | 128 | if(*(data + size - 1) != ((sum >> 8) & 0xff)) |
tosihisa | 0:90c64cb9db58 | 129 | return -2; |
tosihisa | 0:90c64cb9db58 | 130 | return 0; |
tosihisa | 0:90c64cb9db58 | 131 | } |
tosihisa | 0:90c64cb9db58 | 132 | |
tosihisa | 0:90c64cb9db58 | 133 | int GT511C3::SendRecv(unsigned short Command,unsigned long *Parameter,unsigned short *Response) |
tosihisa | 0:90c64cb9db58 | 134 | { |
tosihisa | 0:90c64cb9db58 | 135 | int sts; |
tosihisa | 0:90c64cb9db58 | 136 | if((sts = SendCommand(*Parameter,Command)) == 0){ |
tosihisa | 0:90c64cb9db58 | 137 | *Parameter = 0; |
tosihisa | 0:90c64cb9db58 | 138 | if((sts = RecvResponse(Parameter,Response)) != 0){ |
tosihisa | 0:90c64cb9db58 | 139 | *Response = CMD_Nack; |
tosihisa | 0:90c64cb9db58 | 140 | *Parameter = NACK_IO_ERR; |
tosihisa | 0:90c64cb9db58 | 141 | } |
tosihisa | 0:90c64cb9db58 | 142 | } |
tosihisa | 0:90c64cb9db58 | 143 | if(*Response == CMD_Nack){ |
tosihisa | 0:90c64cb9db58 | 144 | LastError = *Parameter; |
tosihisa | 0:90c64cb9db58 | 145 | } |
tosihisa | 0:90c64cb9db58 | 146 | return sts; |
tosihisa | 0:90c64cb9db58 | 147 | } |
tosihisa | 0:90c64cb9db58 | 148 | |
tosihisa | 0:90c64cb9db58 | 149 | int GT511C3::ClearLine(void) |
tosihisa | 0:90c64cb9db58 | 150 | { |
tosihisa | 0:90c64cb9db58 | 151 | while(readable()){ |
tosihisa | 0:90c64cb9db58 | 152 | (void)getc(); |
tosihisa | 0:90c64cb9db58 | 153 | } |
tosihisa | 0:90c64cb9db58 | 154 | return 0; |
tosihisa | 0:90c64cb9db58 | 155 | } |
tosihisa | 0:90c64cb9db58 | 156 | |
tosihisa | 0:90c64cb9db58 | 157 | int GT511C3::Open(void) |
tosihisa | 0:90c64cb9db58 | 158 | { |
tosihisa | 0:90c64cb9db58 | 159 | unsigned long Parameter = 1; |
tosihisa | 0:90c64cb9db58 | 160 | unsigned short Response = 0; |
tosihisa | 0:90c64cb9db58 | 161 | unsigned char buf[4+sizeof(FirmwareVersion)+sizeof(IsoAreaMaxSize)+sizeof(DeviceSerialNumber)+2]; |
tosihisa | 0:90c64cb9db58 | 162 | int sts = 0; |
tosihisa | 0:90c64cb9db58 | 163 | |
tosihisa | 0:90c64cb9db58 | 164 | if((sts = Init()) != 0) |
tosihisa | 0:90c64cb9db58 | 165 | return -1; |
tosihisa | 0:90c64cb9db58 | 166 | |
tosihisa | 0:90c64cb9db58 | 167 | sts = SendRecv(CMD_Open,&Parameter,&Response); |
tosihisa | 0:90c64cb9db58 | 168 | if((sts != 0) || (Response != CMD_Ack)){ |
tosihisa | 0:90c64cb9db58 | 169 | return -1; |
tosihisa | 0:90c64cb9db58 | 170 | } |
tosihisa | 0:90c64cb9db58 | 171 | if((sts = RecvData(buf,sizeof(buf))) == 0){ |
tosihisa | 0:90c64cb9db58 | 172 | memcpy(&FirmwareVersion,&buf[4+0],sizeof(FirmwareVersion)); |
tosihisa | 0:90c64cb9db58 | 173 | memcpy(&IsoAreaMaxSize,&buf[4+sizeof(FirmwareVersion)],sizeof(IsoAreaMaxSize)); |
tosihisa | 0:90c64cb9db58 | 174 | memcpy(DeviceSerialNumber,&buf[4+sizeof(FirmwareVersion)+sizeof(IsoAreaMaxSize)],sizeof(DeviceSerialNumber)); |
tosihisa | 0:90c64cb9db58 | 175 | } |
tosihisa | 0:90c64cb9db58 | 176 | return sts; |
tosihisa | 0:90c64cb9db58 | 177 | } |
tosihisa | 0:90c64cb9db58 | 178 | |
tosihisa | 0:90c64cb9db58 | 179 | int GT511C3::WaitPress(int press) |
tosihisa | 0:90c64cb9db58 | 180 | { |
tosihisa | 0:90c64cb9db58 | 181 | while(IsPress() != press); |
tosihisa | 0:90c64cb9db58 | 182 | return 0; |
tosihisa | 0:90c64cb9db58 | 183 | } |
tosihisa | 0:90c64cb9db58 | 184 | |
tosihisa | 0:90c64cb9db58 | 185 | int GT511C3::CmosLed(int onoff) |
tosihisa | 0:90c64cb9db58 | 186 | { |
tosihisa | 0:90c64cb9db58 | 187 | unsigned long Parameter = onoff & 1; |
tosihisa | 0:90c64cb9db58 | 188 | unsigned short Response = 0; |
tosihisa | 0:90c64cb9db58 | 189 | int sts = 0; |
tosihisa | 0:90c64cb9db58 | 190 | |
tosihisa | 0:90c64cb9db58 | 191 | sts = SendRecv(CMD_CmosLed,&Parameter,&Response); |
tosihisa | 0:90c64cb9db58 | 192 | if((sts != 0) || (Response != CMD_Ack)){ |
tosihisa | 0:90c64cb9db58 | 193 | return -1; |
tosihisa | 0:90c64cb9db58 | 194 | } |
tosihisa | 0:90c64cb9db58 | 195 | return 0; |
tosihisa | 0:90c64cb9db58 | 196 | } |
tosihisa | 0:90c64cb9db58 | 197 | |
tosihisa | 0:90c64cb9db58 | 198 | int GT511C3::IsPress(void) |
tosihisa | 0:90c64cb9db58 | 199 | { |
tosihisa | 0:90c64cb9db58 | 200 | unsigned long Parameter = 0; |
tosihisa | 0:90c64cb9db58 | 201 | unsigned short Response = 0; |
tosihisa | 0:90c64cb9db58 | 202 | int sts = 0; |
tosihisa | 0:90c64cb9db58 | 203 | sts = SendRecv(CMD_IsPressFinger,&Parameter,&Response); |
tosihisa | 0:90c64cb9db58 | 204 | if((sts != 0) || (Response != CMD_Ack)) |
tosihisa | 0:90c64cb9db58 | 205 | return 0; |
tosihisa | 0:90c64cb9db58 | 206 | if(Parameter != 0) |
tosihisa | 0:90c64cb9db58 | 207 | return 0; |
tosihisa | 0:90c64cb9db58 | 208 | return 1; |
tosihisa | 0:90c64cb9db58 | 209 | } |
tosihisa | 0:90c64cb9db58 | 210 | |
tosihisa | 0:90c64cb9db58 | 211 | int GT511C3::Capture(int best) |
tosihisa | 0:90c64cb9db58 | 212 | { |
tosihisa | 0:90c64cb9db58 | 213 | unsigned long Parameter = best; |
tosihisa | 0:90c64cb9db58 | 214 | unsigned short Response = 0; |
tosihisa | 0:90c64cb9db58 | 215 | int sts = 0; |
tosihisa | 0:90c64cb9db58 | 216 | |
tosihisa | 0:90c64cb9db58 | 217 | sts = SendRecv(CMD_CaptureFinger,&Parameter,&Response); |
tosihisa | 0:90c64cb9db58 | 218 | if((sts != 0) || (Response != CMD_Ack)) |
tosihisa | 0:90c64cb9db58 | 219 | return -1; |
tosihisa | 0:90c64cb9db58 | 220 | return 0; |
tosihisa | 0:90c64cb9db58 | 221 | } |
tosihisa | 0:90c64cb9db58 | 222 | |
tosihisa | 0:90c64cb9db58 | 223 | int GT511C3::Enroll_N(int N) |
tosihisa | 0:90c64cb9db58 | 224 | { |
tosihisa | 0:90c64cb9db58 | 225 | unsigned long Parameter = 0; |
tosihisa | 0:90c64cb9db58 | 226 | unsigned short Response = 0; |
tosihisa | 0:90c64cb9db58 | 227 | int sts = 0; |
tosihisa | 0:90c64cb9db58 | 228 | enum Command cmd; |
tosihisa | 0:90c64cb9db58 | 229 | |
tosihisa | 0:90c64cb9db58 | 230 | switch(N){ |
tosihisa | 0:90c64cb9db58 | 231 | default: |
tosihisa | 0:90c64cb9db58 | 232 | case 1: cmd = CMD_Enroll1; break; |
tosihisa | 0:90c64cb9db58 | 233 | case 2: cmd = CMD_Enroll2; break; |
tosihisa | 0:90c64cb9db58 | 234 | case 3: cmd = CMD_Enroll3; break; |
tosihisa | 0:90c64cb9db58 | 235 | } |
tosihisa | 0:90c64cb9db58 | 236 | sts = SendRecv(cmd,&Parameter,&Response); |
tosihisa | 0:90c64cb9db58 | 237 | if((sts != 0) || (Response != CMD_Ack)) |
tosihisa | 0:90c64cb9db58 | 238 | return -1; |
tosihisa | 0:90c64cb9db58 | 239 | return 0; |
tosihisa | 0:90c64cb9db58 | 240 | } |
tosihisa | 0:90c64cb9db58 | 241 | |
tosihisa | 0:90c64cb9db58 | 242 | int GT511C3::Identify(void) |
tosihisa | 0:90c64cb9db58 | 243 | { |
tosihisa | 0:90c64cb9db58 | 244 | unsigned long Parameter = 0; |
tosihisa | 0:90c64cb9db58 | 245 | unsigned short Response = 0; |
tosihisa | 0:90c64cb9db58 | 246 | int sts = 0; |
tosihisa | 0:90c64cb9db58 | 247 | |
tosihisa | 0:90c64cb9db58 | 248 | sts = SendRecv(CMD_Identify,&Parameter,&Response); |
tosihisa | 0:90c64cb9db58 | 249 | if((sts != 0) || (Response != CMD_Ack)) |
tosihisa | 0:90c64cb9db58 | 250 | return -1; |
tosihisa | 0:90c64cb9db58 | 251 | return Parameter; |
tosihisa | 0:90c64cb9db58 | 252 | } |
tosihisa | 0:90c64cb9db58 | 253 | |
tosihisa | 0:90c64cb9db58 | 254 | int GT511C3::Enroll(int ID,int (*progress)(int status,char *msg)) |
tosihisa | 0:90c64cb9db58 | 255 | { |
tosihisa | 0:90c64cb9db58 | 256 | unsigned long Parameter = 0; |
tosihisa | 0:90c64cb9db58 | 257 | unsigned short Response = 0; |
tosihisa | 0:90c64cb9db58 | 258 | int sts = 0; |
tosihisa | 0:90c64cb9db58 | 259 | |
tosihisa | 0:90c64cb9db58 | 260 | CmosLed(1); |
tosihisa | 0:90c64cb9db58 | 261 | |
tosihisa | 0:90c64cb9db58 | 262 | while(1){ |
tosihisa | 0:90c64cb9db58 | 263 | if((sts = (*progress)(1,"EnrollStart\n")) != 0) |
tosihisa | 0:90c64cb9db58 | 264 | return -9999; |
tosihisa | 0:90c64cb9db58 | 265 | Parameter = ID; |
tosihisa | 0:90c64cb9db58 | 266 | sts = SendRecv(CMD_EnrollStart,&Parameter,&Response); |
tosihisa | 0:90c64cb9db58 | 267 | if(sts != 0) |
tosihisa | 0:90c64cb9db58 | 268 | return sts; |
tosihisa | 0:90c64cb9db58 | 269 | if(Response != CMD_Ack) |
tosihisa | 0:90c64cb9db58 | 270 | return -100; |
tosihisa | 0:90c64cb9db58 | 271 | |
tosihisa | 0:90c64cb9db58 | 272 | if((sts = (*progress)(0,"Remove finger\n")) != 0) |
tosihisa | 0:90c64cb9db58 | 273 | return -9999; |
tosihisa | 0:90c64cb9db58 | 274 | WaitPress(0); |
tosihisa | 0:90c64cb9db58 | 275 | |
tosihisa | 0:90c64cb9db58 | 276 | while(1){ |
tosihisa | 0:90c64cb9db58 | 277 | if((sts = (*progress)(10,"Press finger to Enroll (1st)\n")) != 0) |
tosihisa | 0:90c64cb9db58 | 278 | return -9999; |
tosihisa | 0:90c64cb9db58 | 279 | WaitPress(1); |
tosihisa | 0:90c64cb9db58 | 280 | if(Capture(1) == 0) |
tosihisa | 0:90c64cb9db58 | 281 | break; |
tosihisa | 0:90c64cb9db58 | 282 | } |
tosihisa | 0:90c64cb9db58 | 283 | |
tosihisa | 0:90c64cb9db58 | 284 | if((sts = (*progress)(0,"Remove finger\n")) != 0) |
tosihisa | 0:90c64cb9db58 | 285 | return -9999; |
tosihisa | 0:90c64cb9db58 | 286 | if(Enroll_N(1) != 0) |
tosihisa | 0:90c64cb9db58 | 287 | continue; |
tosihisa | 0:90c64cb9db58 | 288 | WaitPress(0); |
tosihisa | 0:90c64cb9db58 | 289 | |
tosihisa | 0:90c64cb9db58 | 290 | while(1){ |
tosihisa | 0:90c64cb9db58 | 291 | if((sts = (*progress)(20,"Press finger to Enroll (2nd)\n")) != 0) |
tosihisa | 0:90c64cb9db58 | 292 | return -9999; |
tosihisa | 0:90c64cb9db58 | 293 | WaitPress(1); |
tosihisa | 0:90c64cb9db58 | 294 | if(Capture(1) == 0) |
tosihisa | 0:90c64cb9db58 | 295 | break; |
tosihisa | 0:90c64cb9db58 | 296 | } |
tosihisa | 0:90c64cb9db58 | 297 | |
tosihisa | 0:90c64cb9db58 | 298 | if((sts = (*progress)(0,"Remove finger\n")) != 0) |
tosihisa | 0:90c64cb9db58 | 299 | return -9999; |
tosihisa | 0:90c64cb9db58 | 300 | if(Enroll_N(2) != 0) |
tosihisa | 0:90c64cb9db58 | 301 | continue; |
tosihisa | 0:90c64cb9db58 | 302 | WaitPress(0); |
tosihisa | 0:90c64cb9db58 | 303 | |
tosihisa | 0:90c64cb9db58 | 304 | while(1){ |
tosihisa | 0:90c64cb9db58 | 305 | if((sts = (*progress)(30,"Press finger to Enroll (3rd)\n")) != 0) |
tosihisa | 0:90c64cb9db58 | 306 | return -9999; |
tosihisa | 0:90c64cb9db58 | 307 | WaitPress(1); |
tosihisa | 0:90c64cb9db58 | 308 | if(Capture(1) == 0) |
tosihisa | 0:90c64cb9db58 | 309 | break; |
tosihisa | 0:90c64cb9db58 | 310 | } |
tosihisa | 0:90c64cb9db58 | 311 | |
tosihisa | 0:90c64cb9db58 | 312 | if((sts = (*progress)(0,"Remove finger\n")) != 0) |
tosihisa | 0:90c64cb9db58 | 313 | return -9999; |
tosihisa | 0:90c64cb9db58 | 314 | if(Enroll_N(3) != 0) |
tosihisa | 0:90c64cb9db58 | 315 | continue; |
tosihisa | 0:90c64cb9db58 | 316 | WaitPress(0); |
tosihisa | 0:90c64cb9db58 | 317 | |
tosihisa | 0:90c64cb9db58 | 318 | if((sts = (*progress)(100,"Enroll OK\n")) != 0) |
tosihisa | 0:90c64cb9db58 | 319 | return -9999; |
tosihisa | 0:90c64cb9db58 | 320 | |
tosihisa | 0:90c64cb9db58 | 321 | break; |
tosihisa | 0:90c64cb9db58 | 322 | } |
tosihisa | 0:90c64cb9db58 | 323 | return 0; |
tosihisa | 0:90c64cb9db58 | 324 | } |
tosihisa | 0:90c64cb9db58 | 325 | |
tosihisa | 0:90c64cb9db58 | 326 | int GT511C3::CheckEnrolled(int ID) |
tosihisa | 0:90c64cb9db58 | 327 | { |
tosihisa | 0:90c64cb9db58 | 328 | unsigned long Parameter = ID; |
tosihisa | 0:90c64cb9db58 | 329 | unsigned short Response = 0; |
tosihisa | 0:90c64cb9db58 | 330 | int sts = 0; |
tosihisa | 0:90c64cb9db58 | 331 | |
tosihisa | 0:90c64cb9db58 | 332 | sts = SendRecv(CMD_CheckEnrolled,&Parameter,&Response); |
tosihisa | 0:90c64cb9db58 | 333 | if((sts == 0) && (Response == CMD_Ack)) |
tosihisa | 0:90c64cb9db58 | 334 | return 0; //This ID is enrolled |
tosihisa | 0:90c64cb9db58 | 335 | return -1; |
tosihisa | 0:90c64cb9db58 | 336 | } |
tosihisa | 0:90c64cb9db58 | 337 | |
tosihisa | 0:90c64cb9db58 | 338 | int GT511C3::DeleteID(int ID) |
tosihisa | 0:90c64cb9db58 | 339 | { |
tosihisa | 0:90c64cb9db58 | 340 | unsigned long Parameter = ID; |
tosihisa | 0:90c64cb9db58 | 341 | unsigned short Response = 0; |
tosihisa | 0:90c64cb9db58 | 342 | int sts = 0; |
tosihisa | 0:90c64cb9db58 | 343 | |
tosihisa | 0:90c64cb9db58 | 344 | sts = SendRecv(CMD_DeleteID,&Parameter,&Response); |
tosihisa | 0:90c64cb9db58 | 345 | if((sts == 0) && (Response == CMD_Ack)) |
tosihisa | 0:90c64cb9db58 | 346 | return 0; |
tosihisa | 0:90c64cb9db58 | 347 | return -1; |
tosihisa | 0:90c64cb9db58 | 348 | } |