• And here is some example using the library :
    Async function series (Thanks Gordon) :

    function series(arr,done) {
      var i=0;
      function next(err, result) {
        if (((err!==undefined) && (err!==null)) || i>=arr.length)
          done(err, result);
        else
          setTimeout(function() {arr[i++](next);}, 0);
      }
      next();
    }
    

    Enrollment example :

    function enrollFingerprint(id) {
      series([
        function(done) {
          getImage(function(err, result) {
            var error = getErrorCode(result.responseCode);
            if(error === null && ((result.responseCode & 0xFF) == C.FINGERPRINT_OK)) 
                console.log("Image taken");
            done(error);
          });
        },
        function(done) {
          image2Tz(1, function(err, result) {
            var error = getErrorCode(result.responseCode);
            if(error === null && ((result.responseCode & 0xFF) == C.FINGERPRINT_OK)) 
                console.log("Image converted");
            done(error);
          });
        },
        function(done) {
          console.log('Remove finger');
          setTimeout(function(e) { console.log(e.time); done(null); }, 2000);
        },
        function(done) {
          console.log('Place same finger again');
          setTimeout(function(e) { console.log(e.time); done(null);}, 2000);
        },
        function(done) {
          getImage(function(err, result) {
            var error = getErrorCode(result.responseCode);
            if(error === null && ((result.responseCode & 0xFF) == C.FINGERPRINT_OK)) 
                console.log("Image taken");
            done(error);
          });
        },
        function(done) {
          image2Tz(2, function(err, result) {
            var error = getErrorCode(result.responseCode);
            if(error === null && ((result.responseCode & 0xFF) == C.FINGERPRINT_OK)) 
                console.log("Image converted");
            done(error);
          });
        },
        function(done) {
          createModel(function(err, result) {
            var error = getErrorCode(result.responseCode);
            if(error === null && ((result.responseCode & 0xFF) == C.FINGERPRINT_OK)) 
                console.log("Prints matched");
            done(error);
          });
        },
        function(done) {
          storeModel(id, function(err, result) {
            var error = getErrorCode(result.responseCode);
            if(error === null && ((result.responseCode & 0xFF) == C.FINGERPRINT_OK)) 
                console.log("Stored");
            done(error);
          });
        }
      ], function (err, result) {
        console.log(err);
      });
    }
    
    connect(Serial4);
    
    enrollFingerprint(8);
    

    Recogniton example :

    function getFingerprintIDez(callback) {
      series([
          function(done) {
            getImage(function(err, result) {
              var error = getErrorCode(result.responseCode);
              done(error);
            });
          },
          function(done) {
            image2Tz(1, function(err, result) {
              var error = getErrorCode(result.responseCode);
              done(error);
            });
          },
          function(done) {
            fingerFastSearch(function(err, result) {
              var error = getErrorCode(result.responseCode);
              done(error, result);
            });
          }
      ], function(err, result) {
           callback(err, result);
        }
      );
    }
    
    connect(Serial4);
    
    getFingerprintIDez(function(err, result) {
      console.log('final');
      console.log('Error : ' + err);
      if(err === null) {
      console.log(result);
        console.log('#ID : ' + result.fingerID);
        console.log('level : ' + result.confidence); 
      }
    });
    
About

Avatar for ChrisB @ChrisB started