This class was tested on the Grove Fingerprint Sensor Module. It can store up to 163 fingerprints.
It is connected via a UART at 57,600 baud.
 This example demonstrates how to register and store a new fingerprint 
    
    
    if (!fp.setupTty(B57600)) {
        cerr << "Failed to setup tty port parameters" << endl;
        return 1;
    }
    
    
    
    
    
    
    
    fp.setPassword(ZFM20_DEFAULT_PASSWORD);
    fp.setAddress(ZFM20_DEFAULT_ADDRESS);
    
    
    if (fp.verifyPassword()) {
        cout << "Password verified." << endl;
    } else {
        cerr << "Password verification failed." << endl;
        return 1;
    }
    cout << endl;
    uint8_t rv;
    
    cout << "Place a finger on the sensor." << endl;
    while (fp.generateImage() != ZFM20::ERR_OK)
        ;
    
    cout << "Image captured, converting..." << endl;
    if ((rv = fp.image2Tz(1)) != ZFM20::ERR_OK) {
        cerr << "Image conversion failed with error code " << int(rv) << endl;
        return 1;
    }
    cout << "Image conversion succeeded, remove finger." << endl;
    upm_delay(1);
    while (fp.generateImage() != ZFM20::ERR_NO_FINGER)
        ;
    cout << endl;
    cout << "Now place the same finger on the sensor." << endl;
    while (fp.generateImage() != ZFM20::ERR_OK)
        ;
    cout << "Image captured, converting..." << endl;
    
    if ((rv = fp.image2Tz(2)) != ZFM20::ERR_OK) {
        cerr << "Image conversion failed with error code " << int(rv) << endl;
        return 1;
    }
    cout << "Image conversion succeeded, remove finger." << endl;
    cout << endl;
    cout << "Storing fingerprint at id 1" << endl;
    
    if ((rv = fp.createModel()) != ZFM20::ERR_OK) {
        if (rv == ZFM20::ERR_FP_ENROLLMISMATCH)
            cerr << "Fingerprints did not match." << endl;
        else
            cerr << "createModel failed with error code " << int(rv) << endl;
        return 1;
    }
    
    if ((rv = fp.storeModel(1, 1)) != ZFM20::ERR_OK) {
        cerr << "storeModel failed with error code " << int(rv) << endl;
        return 1;
    }
    cout << endl;
    cout << "Fingerprint stored at id 1." << endl;
This example demonstrates reading a fingerprint and locating it in the DB 
    
    
    if (!fp.setupTty(57600)) {
        cerr << "Failed to setup tty port parameters" << endl;
        return 1;
    }
    
    fp.setPassword(ZFM20_DEFAULT_PASSWORD);
    fp.setAddress(ZFM20_DEFAULT_ADDRESS);
    
    
    if (fp.verifyPassword()) {
        cout << "Password verified." << endl;
    } else {
        cerr << "Password verification failed." << endl;
        return 1;
    }
    
    cout << "Total stored templates: " << fp.getNumTemplates() << endl;
    cout << endl;
    
    cout << "Waiting for finger print..." << endl;
    while (fp.generateImage() == ZFM20::ERR_NO_FINGER)
        ;
    
    cout << "Image captured, converting..." << endl;
    uint8_t rv;
    if ((rv = fp.image2Tz(1)) != ZFM20::ERR_OK) {
        cerr << "Image conversion failed with error code " << int(rv) << endl;
        return 1;
    }
    cout << "Image conversion succeeded." << endl;
    cout << "Searching database..." << endl;
    uint16_t id = 0;
    uint16_t score = 0;
    
    
    if ((rv = fp.search(1, id, score)) != ZFM20::ERR_OK) {
        if (rv == ZFM20::ERR_FP_NOTFOUND) {
            cout << "Finger Print not found" << endl;
            return 0;
        } else {
            cerr << "Search failed with error code " << int(rv) << endl;
            return 1;
        }
    }
    cout << "Fingerprint found!" << endl;
    cout << "ID: " << int(id) << ", Score: " << int(score) << endl;
 
|  | 
| enum | ZFM20_COMMAND_T { CMD_GEN_IMAGE = 0x01, 
CMD_IMG2TZ = 0x02, 
CMD_MATCH = 0x03, 
CMD_SEARCH = 0x04,
 CMD_REGMODEL = 0x05, 
CMD_STORE = 0x06, 
CMD_LOAD_TMPL = 0x07, 
CMD_UPLOAD_TMPL = 0x08,
 CMD_DOWNLOAD_TMPL = 0x09, 
CMD_UPLOAD_IMAGE = 0x0a, 
CMD_DOWNLOAD_IMAGE = 0x0b, 
CMD_DELETE_TMPL = 0x0c,
 CMD_EMPTYDB = 0x0d, 
CMD_SET_SYSPARAMS = 0x0e, 
CMD_GET_SYSPARAMS = 0x0f, 
CMD_SET_PASSWORD = 0x12,
 CMD_VERIFY_PASSWORD = 0x13, 
CMD_GET_RANDOM_NUMBER = 0x14, 
CMD_SET_ADDRESS = 0x15, 
CMD_GET_TMPL_COUNT = 0x1d,
 CMD_GET_INDEX_TABLE = 0x1f
 }
 | 
|  | 
| enum | ZFM20_ERRORS_T { ERR_OK = 0x00, 
ERR_PACKET_RX_ERROR = 0x01, 
ERR_NO_FINGER = 0x02, 
ERR_FP_IMAGE_FAILED = 0x03,
 ERR_FP_TOO_MESSY = 0x06, 
ERR_FP_IMAGE_FEW_FEATURES = 0x07, 
ERR_FP_NOMATCH = 0x08, 
ERR_FP_NOTFOUND = 0x09,
 ERR_FP_ENROLLMISMATCH = 0x0a, 
ERR_BAD_LOCATION = 0x0b, 
ERR_DB_ERROR = 0x0c, 
ERR_UPLOAD_FEAT_FAILED = 0x0d,
 ERR_NO_MORE_PACKETS = 0x0e, 
ERR_UPLOAD_IMG_FAILED = 0x0f, 
ERR_RM_TMPL_FAILED = 0x10, 
ERR_EMPTY_DB_FAILED = 0x11,
 ERR_INVALID_PWD = 0x13, 
ERR_INVALID_IMAGE = 0x15, 
ERR_RW_FLASH_ERROR = 0x18, 
ERR_INVALID_REG = 0x1a,
 ERR_INVALID_ADDR = 0x20, 
ERR_NEEDS_PWD = 0x21, 
ERR_INTERNAL_ERR = 0xff
 }
 | 
|  | 
| enum | ZFM20_PKTCODES_T { PKT_COMMAND = 0x01, 
PKT_DATA = 0x02, 
PKT_ACK = 0x07, 
PKT_END_DATA = 0x08
 } | 
|  |