coordinate-adapt

Assess node's coordnate according to received statsions info and each RSSI.

Usage no npm install needed!

<script type="module">
  import coordinateAdapt from 'https://cdn.skypack.dev/coordinate-adapt';
</script>

README

coordinate-adapt

coordinate-adapt is design for missed GPS node, according to Bases info and RSSI to calculation node's coordinate.

Installation

npm install coordinate-adapt --save

Example

var adapt = require('./coordinate-adapt/coordinate-adapt');

console.log('Hello SmartLocation test ...');

adapt.InitBase_db('couchbase://127.0.0.1', {bucketname: 'System_Config'});

adapt.InitLF_db({
    host: 'http://127.0.0.1:9200',
    index: 'fingerprint-test'
});

var data = {
    "nodeMAC": "040006e5"
    "nodeDATA": "015cbb017161ef043ac214"
    "Gateway": [
        {
            "rssi": 6,
            "snr": 15,
            "time": "1471248279124",
            "gatewayID": "0000000c437620b1",
            "mac": "abcdef300012",
        },
        {
            "rssi": 1,
            "snr": 12,
            "time": "1471248279124",
            "gatewayID": "00001c497b30b7ee",
            "mac": "abcdef300012",
        }]
    };

adapt.CoorTrans(data, function(err, result) {

    if (err) {
        console.log('Check coordinate failed:');
        console.log(err);
        return;
    }

    console.log('Check coordinate result: ' + result.GpsX + ' ' + result.GpsY + ' ' + result.Type);

});

API

Status Code


InitBase_db(dbUrl, args, callback)

Initialize Gateway List database dbUrl is Base list db URL args is bucket info, name and password (if needed) * bucketname : Base db's bucket name, string * pw : access bucket password, fill if needed otherwise empty string, string

        coordinate.InitBase_db('couchbase://127.0.0.1', {bucketname: "base", pw: ''});

callback (err) The callback is passed a argument

Return code: 2001 if initial failed

InitLF_db(configs)

Initialize Location Fingerprint elasticsearch database

configs is an object to configure elasticsearch

Reference elasticsearch Configuration

InitLF_db({
    ... config options ...
});

----------------------------------

InitLF_db({
    host: 'localhost:9200'
});

disconnectBase_db()

Disconnect base datebase

CoorTrans(object, callback(err, result))

object: content node MAC Data and Those GWs receives data of node

Following object data format

    CoorTrans({
    "nodeMAC": "040006e5"
    "nodeDATA": ""
    "Gateway": [
        {
            "rssi": 6,
            "snr": 15,
            "time": "1471248279124",
            "gatewayID": "0000000c437620b1",
            "mac": "abcdef300012", //Tracker MAC
        },
        {
            "rssi": 1,
            "snr": 12,
            "time": "1471248279124",
            "gatewayID": "00001c497b30b7ee",
            "mac": "abcdef300012", //Tracker MAC
        }]
    }, callback)

The callback is passed two arguments (err, result), where result is the coordinate.

err :

result: (object)

The result object with following content:

  • GpsX : East Longitude (string)
  • GpsY :North Latitude (string)
  • Type : What kind of method to generates the coordinate (int)
    • FingerPrint type is 0
    • Triangulation typs is 1

NodeGPSInsert(object, callback callback(err))

object: content node GPS coordinate and Those GWs receives data of node

Following object data format

    NodeGPSInsert({
    "nodeGPS_N": "24.871675",
    "nodeGPS_E": "121.009478",
    "nodeMAC": "040006e5"
    "nodeDATA": ""
    "Gateway": [
        {
            "rssi": 6,
            "snr": 15,
            "time": "1471248279124",
            "gatewayID": "0000000c437620b1",
            "mac": "abcdef300012", //Tracker MAC
        },
        {
            "rssi": 1,
            "snr": 12,
            "time": "1471248279124",
            "gatewayID": "00001c497b30b7ee",
            "mac": "abcdef300012", //Tracker MAC
        }]
    }, callback)

callback(err) The callback is passed a argument

Return code: 2002 if insert failed