About
This tutorial describes how to integrate the Syrus 4G IoT Telematics Gateway to your scriptr.io account to build IoT applications.
NOTE: The content has been suggested by DCT
Getting Started
- First, please check the Getting Started section of the Syrus 4G IoT Telematics Gateway documentation
- Make sure you have created an account on scriptr.io
Create an ingestion script on scriptr.io
Login to your scriptr.io workspace and paste the below code into a new script that will ingest the data sent by the gateway and persist it scriptr.io’s NoSQL data store:
var payload = request.body; var document = require("document"); document.save(payload); var queryObj = { query: "imei is not null", // this is the query expression fields: "imei,latitude,longitude,heading,hdop,speed,altitude,label,event,creationDate" // this lists the fields we need to obtain }; var resp = document.query(queryObj); // execute the query by passing the query object to the query function of the document API var historicalData = resp.result.documents; // the returned documents list if (resp.metadata.status == "success") { return resp.result.documents; } return payload;
Configure the Syrus 4G IoT Telematics Gateway
Open a text editor – such as notepad – and create a file with the following name: destinations.syrus.conf (for more about destinations, please refer to: https://syrus.pegasusgateway.com/syrdocs/syrus4/syruslang/#destinations)
Copy and paste the following text:
Replace [Your Script] with your script name on Scriptr.
Example: if you saved your script as /gateway/syrus4g the you must replace [your Script] with this path.
Replace [Your Token] with your personal Account token from scriptr.io. From the scriptr.io workspace, select your user name in the top-right corner of the screen as shown in the below image
Then get your token:
The final result in the configuration file should be similar to the below:
Using your text editor, create a second file and name it “configuration.syrus.conf” (for more information, please refer to: https://syrus.pegasusgateway.com/syrdocs/syrus4/syruslang/#syrusjs)
Copy and paste the following configuration into the file:
define group scriptr
set destinations group=scriptr scriptr
define fieldset scriptr fields=”imei”:$modem.imei,”latitude”:$gnss.latitude,”longitude”:$gnss.longitude,”heading”:$gnss.heading,”hdop”:$gnss.hdop,”speed”:$gnss.mph,”altitude”:$gnss.altitude,”label”:label,”event”:code
define signal ignitionON min_duration=5s $io.ign == true
define signal ignitionOFF min_duration=5s $io.ign == false
define tracking_resolution scriptr 10m 25deg 1000mts
define event ignitionOnScriptr group=scriptr fieldset=scriptr ack=none label=igonscrip code=202 trigger=ignitionON
define event ignitionOffScriptr group=scriptr fieldset=scriptr ack=none label=igoffscrip code=203 trigger=ignitionOFF
# Define tracking event, a single tracking resolution signal that can be controlled by different actions
define event trackingOffScriptr group=scriptr fieldset=scriptr ack=none label=prdtst code=200 trigger=@tracking_resolution.scriptr.signal,ignitionOFF,and
define event trackingOnScriptr group=scriptr fieldset=scriptr ack=none label=trckpnt code=201 trigger=@tracking_resolution.scriptr.time,ignitionON,and
define event trackingHeadingScriptr group=scriptr fieldset=scriptr ack=none label=heading code=240 trigger=@tracking_resolution.scriptr.heading,ignitionON,and
define event trackingDistanceScriptr group=scriptr fieldset=scriptr ack=none label=distance code=241 trigger=@tracking_resolution.scriptr.distance,ignitionON,and
###### END SCRIPTR CONFIG ######
Now go to Gateway’s Management Tool (http://192.168.9.2 if you’re over USB cable)
- In the lateral menu bar go to Application Manager and Select SyrusJS
- Click on Data Folder Tab and Upload the previous files (destinations and configuration)
- Select Information tab and click Restart
Now just toggle the Ignition switch (Yellow cable from Syrus 4G). Your gateway will start sending data to your scriptr.io account.
Check that you are receiving data on scriptr.io
Go to the scriptr.io Data Explorer:
Use Query Expression: imei is not null
And fields to return: creationDate,latitude,longitude,speed,heading,label,code
You should get a result similar to the following:
Congratulations! You are now receiving data from the Syrus Gateway!
NOTE: The content of this tutorial has been suggested by DCT