Code Monkey home page Code Monkey logo

anviz-protocol's Introduction

Anviz-protocol

Javascript library to communicate with Anviz devices.

Tested with FacePass 7

Features:

  • Real Time Mode (Record Events)
  • Get/Set Device Id
  • Get/Set Device Info1
  • Get/Set Device Info2
  • Get Serial Number
  • Get/Set Date Time
  • Get Record Information
  • Get Records
  • Clear Records
  • Get/Set User Info
  • Get/Set FP Template
  • Open Lock

How to use:

    const { Device, UserInfo } = require("./index.js");

    const host = '192.168.0.110'; // Device IP
    var device = new Device(host);

    device.listener = {

        onRecord: (record)=> {
            console.log(record);
            console.log(new Date(record.dateTime));
            device.clearAllRecordsSign();
            device.openLock();
        },

        onError: (e)=> {
            console.log(e);
        },

        onConnectionLost: () => {
            console.log("Connection lost");
        }

    }

    device.connect(); // Open connection

    device.getSerialNumber((serialNumber)=> {
        console.log("Serial: " + serialNumber);
    });

    // Set local date time
    device.setDateTime(new Date());

    device.getRecordInformation((info)=> {
        // console.log(info);
    });

    device.getDeviceInfo1((info)=> {
        info.volume = 0;
        // info.language = 4; // 4 spanish
        device.setDeviceInfo1(info);
    });

    device.getDeviceInfo2((info)=> {
        // console.log(info);
        info.realTimeModeSetting = 1; // enable real time mode
        info.relayMode  = 3; // 0 control lock, 1 scheduled bell, 3 disabled
        info.lockDelay  = 2; // 2 seconds
        device.setDeviceInfo2(info);
        // Notify records
        device.getNewRecords((records)=> {
            for(let i = 0; i < records.length; ++i) {
                device.listener.onRecord(records[i]);
            }
            device.clearAllRecordsSign();
        });
        
    });

    ...

    device.disconnect(); // Close connection

www.sergiosoriano.com

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.