40 #include <sys/select.h>
41 #include <sys/types.h>
44 #include <mraa/uart.h>
46 #define ZFM20_DEFAULT_UART 0
49 #define ZFM20_START1 0xef
50 #define ZFM20_START2 0x01
52 #define ZFM20_MAX_PKT_LEN 256
54 #define ZFM20_TIMEOUT 5000 // in ms
56 #define ZFM20_DEFAULT_PASSWORD 0x00000000
57 #define ZFM20_DEFAULT_ADDRESS 0xffffffff
100 CMD_LOAD_TMPL = 0x07,
101 CMD_UPLOAD_TMPL = 0x08,
102 CMD_DOWNLOAD_TMPL = 0x09,
103 CMD_UPLOAD_IMAGE = 0x0a,
104 CMD_DOWNLOAD_IMAGE = 0x0b,
105 CMD_DELETE_TMPL = 0x0c,
107 CMD_SET_SYSPARAMS = 0x0e,
108 CMD_GET_SYSPARAMS = 0x0f,
109 CMD_SET_PASSWORD = 0x12,
110 CMD_VERIFY_PASSWORD = 0x13,
111 CMD_GET_RANDOM_NUMBER = 0x14,
112 CMD_SET_ADDRESS = 0x15,
113 CMD_GET_TMPL_COUNT = 0x1d,
114 CMD_GET_INDEX_TABLE = 0x1f
120 ERR_PACKET_RX_ERROR = 0x01,
121 ERR_NO_FINGER = 0x02,
122 ERR_FP_IMAGE_FAILED = 0x03,
123 ERR_FP_TOO_MESSY = 0x06,
124 ERR_FP_IMAGE_FEW_FEATURES = 0x07,
125 ERR_FP_NOMATCH = 0x08,
126 ERR_FP_NOTFOUND = 0x09,
127 ERR_FP_ENROLLMISMATCH = 0x0a,
128 ERR_BAD_LOCATION = 0x0b,
130 ERR_UPLOAD_FEAT_FAILED = 0x0d,
131 ERR_NO_MORE_PACKETS = 0x0e,
132 ERR_UPLOAD_IMG_FAILED = 0x0f,
133 ERR_RM_TMPL_FAILED = 0x10,
134 ERR_EMPTY_DB_FAILED = 0x11,
135 ERR_INVALID_PWD = 0x13,
136 ERR_INVALID_IMAGE = 0x15,
137 ERR_RW_FLASH_ERROR = 0x18,
138 ERR_INVALID_REG = 0x1a,
139 ERR_INVALID_ADDR = 0x20,
140 ERR_NEEDS_PWD = 0x21,
142 ERR_INTERNAL_ERR = 0xff
182 int readData(
char *buffer,
int len);
355 uint8_t
search(
int slot, uint16_t *
id, uint16_t *score);
364 uint8_t
match(uint16_t *score);
368 int ttyFd() {
return m_ttyFd; };
371 mraa_uart_context m_uart;
375 struct timeval m_startTime;
uint8_t search(int slot, uint16_t *id, uint16_t *score)
Definition: zfm20.cxx:545
uint8_t match(uint16_t *score)
Definition: zfm20.cxx:584
bool getResponse(uint8_t *pkt, int len)
Definition: zfm20.cxx:275
int writeData(char *buffer, int len)
Definition: zfm20.cxx:127
uint8_t storeModel(int slot, uint16_t id)
Definition: zfm20.cxx:483
bool setNewPassword(uint32_t pwd)
Definition: zfm20.cxx:367
API for the ZFM-20 Fingerprint Sensor Module.
Definition: zfm20.h:89
void setPassword(uint32_t pw)
Definition: zfm20.h:246
uint8_t deleteDB()
Definition: zfm20.cxx:529
uint8_t generateImage()
Definition: zfm20.cxx:427
bool verifyPassword()
Definition: zfm20.cxx:322
ZFM20(int uart)
Definition: zfm20.cxx:36
bool verifyPacket(uint8_t *pkt, int len)
Definition: zfm20.cxx:254
uint8_t createModel()
Definition: zfm20.cxx:467
void setAddress(uint32_t addr)
Definition: zfm20.h:239
~ZFM20()
Definition: zfm20.cxx:74
uint32_t getMillis()
Definition: zfm20.cxx:226
int readData(char *buffer, int len)
Definition: zfm20.cxx:106
bool setupTty(speed_t baud=B57600)
Definition: zfm20.cxx:157
int getNumTemplates()
Definition: zfm20.cxx:343
uint8_t image2Tz(int slot)
Definition: zfm20.cxx:443
uint8_t deleteModel(uint16_t id)
Definition: zfm20.cxx:509
int writeCmdPacket(uint8_t *pkt, int len)
Definition: zfm20.cxx:187
bool setNewAddress(uint32_t addr)
Definition: zfm20.cxx:397
void initClock()
Definition: zfm20.cxx:221
bool dataAvailable(unsigned int millis)
Definition: zfm20.cxx:82