1.0.3 • Published 2 years ago

biocv_node_api v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

biocv_node_API

This package allows you to fetch and process the data of the BioCV eartags. The data is automatically sent to the used Cloud and evaluated on abnormalities. If needed you can also get the raw data by registering a listener.

Functions - Parse only

async function parseData (advertisedData: Buffer) : Object<ParsedSensordata>

Return the parsed and cleaned sensordata of an advertised BLE package. The argument is the ByteBuffer of the BLE Package with the service UUID of '1803'

ParsedSensordata: {
	T: 0,
	x: 0,
	y: 0,
	z: 0,
	t: dateTimeMillis
}

The results are given in the following units:

  • T in Celsius
  • x, y, z in n-fold gravitational force
  • t in UNIX(millis)

Functions - Without Cloud Usage

scanForTags

async function scanForTags (callback: function, uploadInterval: Number) : void 

Returns a JSON in the given callback function in the form:

{
    mac: '21:36:00:00:01:52'    // MAC
	type: 'eartag',				// eartag or ant
	T: 26.66,      				// temperature
	gT: 27.31,	    			// group temperature
	A: 1.05,	    			// activity
	gA: 1.02,	    			// group activity
	t: 1636977523576,		    // time
	cT: 0.09713415584566931,    // temperature warning activator
	cA: 0.4926818469408952 	    // activity warning activator
}

The recieved data is the cleaned average of the last given time period.

Functions - With Cloud Usage

setup

You need to run this funtion once to enter all parameters for your node to setup.

 function setup () : void 

The resultung creds.js will look like:

module.exports = {
	nodeID:  "2021.000",		// ID of the node
	tableID:  "sens000",		// Resulting tableID
	uploadInterval: (60000),	// Uploadintervall
	userID:  'empty',			// Your user ID
	debug:  true,				// Show logs (y/n)
	rssiLimit: -70				// Limit the range
}

And can be used to tweak the parameters of the node.

scanForTagsAutoUpload

 async function scanForTagsAutoUpload () : void 

Usage

npm biocv_node_API
// Import the library
const api = require('./biocv_node_API');

// You need to run the setup function on first start
api.setup();

// After you set up the node you do not need to run the setup again.
// Calling the function without a callback will automatically use the BioCV ecosystem.
api.scanForTags();

// As a alternative you can use the function with a given callback to get the data directly
api.scanForTags((data) => console.log(data), 5);