Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

dctdevelop/syrus4-nodejs

Repository files navigation

⚠️ This Repo has been migrated, check out the new one here https://github.com/digitalcomtech/syrus4-sdk-nodejs ⚠️


Syrus 4 SDK for nodejs

Interactive function to consult enable or disable multiple modules for APEX OS

Quick Start

Install using npm github

$ npm install https://github.com/dctdevelop/syrus4-nodejs/tarball/master

Modules

Accelerometer

Accelerometer module get information about hardware acceleration and events in ApexOS

Apps

Apps module to start/stop/enable/disable/install third parts apps running in apex-os

Serial

Serial module, get information about serial state

Counters

Counters module setup get and set counters from APEX OS

ECU

ECU module get information about EcU monitor and vehicle in ApexOS

Fatigue

Fatigue module, get fatigue sensor information and events

GPS

GPS module get information about gps and location in ApexOS

Geofences

Geofences module

Hotspot

Hotspot module to interacte with the enable/disable Hotspot mode with Apex OS

IButton

IButton module get information about onewire

IOS

IOS module allow to get and set status from Input and Outputs in Syrus 4 Apex OS

Network

Network module get information about networks and events in ApexOS

Onewire

Onewire module get information about onewire

Serial

Serial module, get information about serial state

System-Info

System module get information about ApexOS

Temperature

Temperature module get information about temperature sensors

Update

Update module check for update and make update for ApexOS

Utils

Utils module some utlities in ApexOS

WIFI

WIFI module to interacte with the enable/disable WIFI mode with Apex OS

Functions

getInfo()

returns a JSON with the configured values in RF

set(key, value)

Use this option to configure the network variable for mobile networks

watchTrackingResolution(callback, opts)

define a tracking resolution using apx-tracking tool to receive filtered data gps

getActiveTrackingsResolutions(prefixed)

get all the active tracking resolutions`in the apex tol apx-tracking

setTrackingResolution(opts)

set options for a tracking_resolution for the apex tool apx-tracking

Accelerometer

Accelerometer module get information about hardware acceleration and events in ApexOS

Accelerometer~onMotionChange(callback, errorCallback)

Watch the motion state of the Syrus Apex accceleration hardware module

Kind: inner method of Accelerometer

Param Description
callback callback to executed when motion state changes
errorCallback callback to execute in case of error

Accelerometer~on(callback, errorCallback)

Watch for accelerations events in Apex OS. possible events: FORWARD_COLLISION, BACKWARD_COLLISION, LAT_COLLISION_FROM_RIGHT, LAT_COLLISION_FROM_LEFT, HARSH_FWD_ACCELERATION, HARD_BRAKING, CORNERING_RIGHT, CORNERING_LEFT

Kind: inner method of Accelerometer

Param Description
callback callback to executed when new acceleration event received
errorCallback callback to execute in case of error

Accelerometer~startAutoAlignment(state)

Set the state for the auto alignment procces of the APEX OS acceleration hardware

Kind: inner method of Accelerometer

Param Default Description
state true desired state of auto alignment proccess

Accelerometer~startSelfAccelerationTest(state)

Set the state for the self acceleration test of the APEX OS acceleration hardware

Kind: inner method of Accelerometer

Param Default Description
state true desired state of self acceleration test proccess

Accelerometer~isAutoAligning()

check is hardware is on state auto aligning returns a promise with the state

Kind: inner method of Accelerometer

Accelerometer~isAccelerationTest()

check is hardware is on state acceleration test returns a promise with the state

Kind: inner method of Accelerometer

Accelerometer~isMoving()

Check the current state of the acceloremeter hardware is moving

Kind: inner method of Accelerometer

Apps

Apps module to start/stop/enable/disable/install third parts apps running in apex-os

Apps~execute(action, app, zipPath)

allows to execute commands from the apps-manager utility from ApexOs

Kind: inner method of Apps

Param Default Description
action action to execute
app the name of the App
zipPath the zip location unde where unzip the app

Apps~start(app)

Start an application under /data/applications folder

Kind: inner method of Apps

Param Description
app the name of the app

Apps~stop(app)

Stop an application under /data/applications folder

Kind: inner method of Apps

Param Description
app the name of the app

Apps~restart(app)

Restart an application under /data/applications folder

Kind: inner method of Apps

Param Description
app the name of the app

Apps~enable(app)

Enable an application for start on boot under /data/applications folder

Kind: inner method of Apps

Param Description
app the name of the app

Apps~disable(app)

Disable an application for start on boot under /data/applications folder

Kind: inner method of Apps

Param Description
app the name of the app

Apps~list()

List all the running applications

Kind: inner method of Apps

Apps~state(app)

return the state of the app

Kind: inner method of Apps

Param Description
app the name of the app

Apps~install(app, zipPath)

Allows install an app receive as parameter the name of the app and the zip location or the data of the zip in question

Kind: inner method of Apps

Param Description
app the name of the app
zipPath the zip location

Apps~uninstall(app)

Uninstall and deletes the data from an app

Kind: inner method of Apps

Param Description
app the name of the app

Apps~setConfiguration(app, newConfig)

write .env file configuration of the app, if the .env exists, replace it

Kind: inner method of Apps

Param Description
app the name of the app
newConfig

Apps~getConfiguration(app)

Get the contents of SYRUS4G_APP_CONF_FILE file where it stored the configuration of the app

Kind: inner method of Apps

Param Description
app the name of the app

Serial

Serial module, get information about serial state

Serial~getSerialMode()

get serial mode

Kind: inner method of Serial

Serial~setSerialMode()

set serial mode (console or modem)

Kind: inner method of Serial

Serial~getSerialModemState()

get serial modem state

Kind: inner method of Serial

Serial~getModemBufferSize()

get modem buffer size

Kind: inner method of Serial

Serial~setModemBufferSize()

set the buffer size

Kind: inner method of Serial

Serial~send()

send a message

Kind: inner method of Serial

Serial~onIncomingMessage()

monitor incoming serial messages

Kind: inner method of Serial

Counters

Counters module setup get and set counters from APEX OS

ECU

ECU module get information about EcU monitor and vehicle in ApexOS

ECU~getECUInfo()

ECU PARAM LIST from the ecu monitor

Kind: inner method of ECU

ECU~watchECUParams(cb, errorCallback)

allows to subscribe for ECU parameter changes

Kind: inner method of ECU

Param Description
cb calbback to execute when new ECU data arrives
errorCallback errorCallback when something wrong goes with the subscription

ECU~getECUParams()

Get all the most recent data from ECU parameters

Kind: inner method of ECU

ECU~getECUList()

get ecu paramas list associated to all the pgn and id for ecu and taip tag associated

Kind: inner method of ECU

Fatigue

Fatigue module, get fatigue sensor information and events

GPS

GPS module get information about gps and location in ApexOS

GPS~distanceBetweenCoordinates(coord1, coord2)

return distance in km between two coordinates points

Kind: inner method of GPS

Param Description
coord1 first coordinate to calculate the distance
coord2 second coordinate to calculate the distance

GPS~getCurrentPosition()

Get last current location from GPS

Kind: inner method of GPS

GPS~watchPosition(callback, errorCallback, config)

allows to subscribe to position events in GPS module

Kind: inner method of GPS

Param Description
callback handler to execute when new gps position arrives
errorCallback Errorcallback executes when is unable to get gps location
config Object coniguration how evaluate criteria for watchPosition

GPS~watchGPS(callback, errorCallback)

allows to subscribe to gps data changes in GPS module

Kind: inner method of GPS

Param Description
callback handler to execute when new gps data arrives
errorCallback Errorcallback executes when is unable to get gps location

GPS~watchTrackingResolution(callback, opts)

define a tracking resolution using apx-tracking tool to receive filtered data gps

Kind: inner method of GPS

Param Description
callback callback to execute when new data arrive from tracking resolution
opts tracking_resolution: * namespace: The name used as a reference to identify a tracking criteria. * *Max 30 characters * * heading: The heading threshold for triggering notifications based on heading * *changes. Use 0 to disable. Range (0 - 180) * * time: The time limit in seconds for triggering tracking notifications. * *Use 0 to disable. Range (0 - 86400) * * distance: The distance threshold in meters for triggering tracking * *notifications based on the traveled distance. Use 0 to disable. * *Range (0 - 100000)

GPS~getActiveTrackingsResolutions(prefixed)

get all the active tracking resolutions`in the apex tol apx-tracking

Kind: inner method of GPS

Param Description
prefixed prefix to lookup tracking_resolution

GPS~setTrackingResolution(opts)

set options for a tracking_resolution for the apex tool apx-tracking

Kind: inner method of GPS

Param Description
opts tracking_resolution: * namespace: The name used as a reference to identify a tracking criteria. * *Max 30 characters * * heading: The heading threshold for triggering notifications based on heading * *changes. Use 0 to disable. Range (0 - 180) * * time: The time limit in seconds for triggering tracking notifications. * *Use 0 to disable. Range (0 - 86400) * * distance: The distance threshold in meters for triggering tracking * *notifications based on the traveled distance. Use 0 to disable. * *Range (0 - 100000)

GPS~getTrackingResolution(opts)

get options for a tracking_resolution for the apex tool apx-tracking

Kind: inner method of GPS

Param Description
opts tracking_resolution: * namespace: The name used as a reference to identify a tracking criteria.

Geofences

Geofences module

Geofences~addGeofence(opts)

Add Geofence to the apx-tool

Kind: inner method of Geofences

Param Description
opts options hash name: name of the fence; lngLats: array of (lon,lat) coordinate pairs; group: group name; namespace: namespace; type: geofence type could be circular or poly; radius: radius for circular fences, in meters, must be >= 50;

Geofences~updateGeofence(opts)

Update Geofence to the apx-tool

Kind: inner method of Geofences

Param Description
opts options hash name: name of the fence; lngLats: array of (lon,lat) coordinate pairs; group: group name; namespace: namespace; type: geofence type could be circular or poly; radius: radius for circular fences, in meters, must be >= 50;

Geofences~removeGeofence(opts)

Remove Geofence from the apx-tool

Kind: inner method of Geofences

Param Description
opts options hash name: name of the fence; group: group name; namespace: namespace;

Geofences~getNamespaces() ⇒ *

get all available namespaces

Kind: inner method of Geofences

Geofences~get(opts)

Get geofence state from the apx-tool

Kind: inner method of Geofences

Param Description
opts options hash name: name of the fence; namespace: namespace;

Geofences~getAll(opts)

Get states from all Geofences for a given namespace

Kind: inner method of Geofences

Param Description
opts options hash namespace: namespace that belongs of geofence;

Geofences~deleteAll(opts)

remove all Geofences from the namespace

Kind: inner method of Geofences

Param Description
opts options hash namespace: namespace that belongs of geofence;

Geofences~watchGeofences(callback, errorCb, opts)

Kind: inner method of Geofences

Param Description
callback callback to execute when the device enters or exits from a geofence
errorCb error callback to execute if there is an unexpected error
opts options hash namespace: namespace to check if entered or exited from geofence;

Geofences~watchGroups(callback, errorCb, opts)

Kind: inner method of Geofences

Param Description
callback callback to execute when the device enters or exits a geofence group
errorCb error callback to execute if something fails
opts namespace: namespace to check if entered or exited from group of geofence;

Hotspot

Hotspot module to interacte with the enable/disable Hotspot mode with Apex OS

Hotspot~list()

returns the list of the connected clients to the hotspot

Kind: inner method of Hotspot

Hotspot~state()

returns the state of the connected clients to the hotspot

Kind: inner method of Hotspot

Hotspot~start()

start the hotspot service, also stop wifi service

Kind: inner method of Hotspot

Hotspot~stop()

stops the hotspot service

Kind: inner method of Hotspot

Hotspot~reset()

executes a stop-start in the same call

Kind: inner method of Hotspot

Hotspot~route(netInterface)

Use this option for forwarding the wlan traffic to another interface, it allows you to have internet access by specifying the output interface

Kind: inner method of Hotspot

Param Default Description
netInterface ppp0 Interface you ant allow internet access default="ppp0"

Hotspot~edit(parameter, newValue)

edits the parameter received in the hotspot configuration file.
Example apx-hotspot edit wpa_passphrase myNewPass1234 Possible Values: "wpa_passphrase" | "ssid" | "max_num_sta" | "channel" | "wpa_key_mgmt"

Kind: inner method of Hotspot

Param Default Description
parameter wpa_passphrase param to edit config
newValue new value for the parameter

IButton

IButton module get information about onewire

IButton~IButtonUpdate

Kind: inner class of IButton

new IButtonUpdate()

Event published by the sdk composed of of multiple IButtonEvent authorized contains events from whitelisted ibuttons

IButton~getIButtons()

allow to get al lthe state of the ibuttons connected

Kind: inner method of IButton

IButton~getIButton()

allow to get al lthe state of the ibuttons connected

Kind: inner method of IButton

IButton~setIButtonAlias()

allow to get al lthe state of the ibuttons connected

Kind: inner method of IButton

IButton~removeIButtonAlias()

remove Alias from ibutton whitelist

Kind: inner method of IButton

IButton~onIButtonChange()

monitor iButton notifications

Kind: inner method of IButton

IOS

IOS module allow to get and set status from Input and Outputs in Syrus 4 Apex OS

IOS~watchInputState(inputName, cb, errorCallback)

Allow to subcribe to changes in a input or output accepts sub patterns

Kind: inner method of IOS

Param Default Description
inputName * input or patter to subscribe
cb callback execute everytime the input state changed, first argument contains the new state
errorCallback

IOS~getInputState(inputName)

get a promise that resolve the current input or output state

Kind: inner method of IOS

Param Default Description
inputName IGN the input/output requested

IOS~setOutputState(inputName, state)

Allow to change the state of an output

Kind: inner method of IOS

Param Default Description
inputName OUT1 the output to change state
state true the new state of the output

IOS~getAll()

Get the current state of all inputs, outputs and analogs in the Syrus4 device

Kind: inner method of IOS

Network

Network module get information about networks and events in ApexOS

Network~onNetworkChange(callback, errorCallback)

Watch the network state change

Kind: inner method of Network

Param Description
callback callback to executed when network state changes
errorCallback callback to execute in case of error

Network~getActiveNetwork()

get the current state of the network of the APEX OS, returns a promise with the info

Kind: inner method of Network

Network~getNetworkInfo(net)

get Network Information about specific network

Kind: inner method of Network

Param Description
net network that want to know the information valid options are: eth0, ppp0, wlan0

Network~getNetworks()

get network information about all the available networks on APEX OS

Kind: inner method of Network

Onewire

Onewire module get information about onewire

Onewire~getAll()

allow to get al lthe state of the ibuttons connected

Kind: inner method of Onewire

Onewire~get()

allow to get al lthe state of the ibuttons connected

Kind: inner method of Onewire

Onewire~create()

allow to get al lthe state of the ibuttons connected

Kind: inner method of Onewire

Serial

Serial module, get information about serial state

Serial~getSerialMode()

get serial mode

Kind: inner method of Serial

Serial~setSerialMode()

set serial mode (console or modem)

Kind: inner method of Serial

Serial~getSerialModemState()

get serial modem state

Kind: inner method of Serial

Serial~getModemBufferSize()

get modem buffer size

Kind: inner method of Serial

Serial~setModemBufferSize()

set the buffer size

Kind: inner method of Serial

Serial~send()

send a message

Kind: inner method of Serial

Serial~onIncomingMessage()

monitor incoming serial messages

Kind: inner method of Serial

System-Info

System module get information about ApexOS

System-Info~info()

Get Info about the system like RAM,CPU,uptime, etc

Kind: inner method of System-Info

System-Info~modem()

Get Modem about the system like RAM,CPU,uptime, etc

Kind: inner method of System-Info

System-Info~onSleepOn(callback, errorCallback)

handler to detect power save mode and execute callback 15 seconds before the device goes to sleep

Kind: inner method of System-Info

Param Description
callback callback to execute when power save mode is on and device is about to turn off
errorCallback callbac to execute in case of any error

System-Info~getLastWakeUp()

Get the latest wakeup reason and timestamp from sleep on from APEX OS

Kind: inner method of System-Info

System-Info~getlastSleepOn()

Get the latest time from sleep on event from APEX OS

Kind: inner method of System-Info

System-Info~getWakeUpList()

Get the list of latets sleep on and wakeup events with reason and timestamp

Kind: inner method of System-Info

System-Info~addDisconnectListener(callback)

add a callback from stack to execute when app signal termination

Kind: inner method of System-Info

Param Description
callback callback to execute when application goes offline

System-Info~removeDisconnectListener(callback)

remove a callback from stack to execute when app signal termination

Kind: inner method of System-Info

Param Description
callback callback to remove from listener

Temperature

Temperature module get information about temperature sensors

Temperature~TemperatureUpdate

Kind: inner class of Temperature

new TemperatureUpdate()

Event published by the sdk composed of of multiple TemperatureEvents authorized object contains events from whitelisted ibuttons

Temperature~getTemperatures()

get the current temperature state

Kind: inner method of Temperature

Temperature~getTemperature()

get reading from a specific sensor, by id or alias

Kind: inner method of Temperature

Temperature~setTemperatureAlias()

set alias to a temperature sensor

Kind: inner method of Temperature

Temperature~removeTemperatureAlias()

remove alias from temperature sensor

Kind: inner method of Temperature

Temperature~removeTemperatureAliases()

remove aliases from all temperature sensors

Kind: inner method of Temperature

Temperature~onTemperatureChange()

monitor temperature notifications

Kind: inner method of Temperature

Update

Update module check for update and make update for ApexOS

Update~checkCore()

Check if an update is available in the dctserver for Core Ccomponentss

Kind: inner method of Update

Update~UpdateCore(force)

Start the update of the core packages by using the dctserver

Kind: inner method of Update

Param Default Description
force false The same as start but without checking the network interface

Update~listOS()

list installed packages from OS components in the distribution

Kind: inner method of Update

Update~checkOS()

Check if an update is available in the dctserver for OS apps and return a list of the latest version of the packages

Kind: inner method of Update

Update~recoverOS()

allows to recover from broken packages when a bad install or updates happens

Kind: inner method of Update

Update~updateOS(force)

Start the update of the OS components by using the dctserver

Kind: inner method of Update

Param Description
force The same as start but without checking the network interface

Update~installOS(package_name)

upgrade a package to the lastest version available in the dctserver

Kind: inner method of Update

Param Description
package_name the name of the package that it wants to be updated

Utils

Utils module some utlities in ApexOS

Utils~OSExecute(...args)

Execute a command using sudo in the shell of the APEXOS and returns a promise with the stdout. Promise is rejected if status code is different than 0

Kind: inner method of Utils

Param Description
...args arguments to pass to the function to execute

Utils~getPrefix() ⇒ *

Fetch application prefix, uses env=SYRUS4G_APP_NAME when available otherwise it builds it from the directory where the app is running

Kind: inner method of Utils

Utils~$trycatch(promise) ⇒ *

Utility for try/catching promises in one line, avoiding the need for try/catch blocks let [response, error] = $trycatch(await awaitable())

Kind: inner method of Utils
Returns: * - {(Promise<[ any | null, Error | null ]>)}

Param Type
promise Promise.<any>

Utils~$throw(error)

Utility for throwing errors inside a catch, reduces need for try/catch await awaitable().catch($throw)

Kind: inner method of Utils

Param Type
error Error

Utils~$sleep(ms) ⇒ *

Sleep Utility await $sleep(10*1000)

Kind: inner method of Utils
Returns: * - {Promise}

Param Type
ms number

WIFI

WIFI module to interacte with the enable/disable WIFI mode with Apex OS

WIFI~scan()

It starts a WIFI scan and returns a list of SSIDs

Kind: inner method of WIFI

WIFI~state()

It returns the wifi status

Kind: inner method of WIFI

WIFI~list()

It returns the list of networks configured

Kind: inner method of WIFI

WIFI~start()

It enables the WIFI interface and starts the service for connecting with preconfigured networks

Kind: inner method of WIFI

WIFI~stop()

It stops the WIFI service and disables the interface

Kind: inner method of WIFI

WIFI~reset()

It executes a stop-start in the same call

Kind: inner method of WIFI

WIFI~add(ssid, password)

It adds a new network to the WIFI configuration file, in this case you have to include the SSID and psk as parameters. Example apx-wifi add myNet myPass

Kind: inner method of WIFI

Param Description
ssid The name of SSID you want to connect
password the password of the SSID

WIFI~remove(ssid)

It removes a network from the WIFI configuration file, in this case you have to include the SSID as parametes

Kind: inner method of WIFI

Param Description
ssid Name of the SSID you want to remove

getInfo()

returns a JSON with the configured values in RF

Kind: global function

set(key, value)

Use this option to configure the network variable for mobile networks

Kind: global function

Param Description
key the paramter to be configured, posible values are: "apn", "user", "pin", "pass"
value the new value of the parameter

watchTrackingResolution(callback, opts)

define a tracking resolution using apx-tracking tool to receive filtered data gps

Kind: global function

Param Description
callback callback to execute when new data arrive from tracking resolution
opts tracking_resolution: * namespace: The name used as a reference to identify a tracking criteria. * *Max 30 characters * * heading: The heading threshold for triggering notifications based on heading * *changes. Use 0 to disable. Range (0 - 180) * * time: The time limit in seconds for triggering tracking notifications. * *Use 0 to disable. Range (0 - 86400) * * distance: The distance threshold in meters for triggering tracking * *notifications based on the traveled distance. Use 0 to disable. * *Range (0 - 100000)

getActiveTrackingsResolutions(prefixed)

get all the active tracking resolutions`in the apex tol apx-tracking

Kind: global function

Param Description
prefixed prefix to lookup tracking_resolution

setTrackingResolution(opts)

set options for a tracking_resolution for the apex tool apx-tracking

Kind: global function

Param Description
opts tracking_resolution: * namespace: The name used as a reference to identify a tracking criteria. * *Max 30 characters * * heading: The heading threshold for triggering notifications based on heading * *changes. Use 0 to disable. Range (0 - 180) * * time: The time limit in seconds for triggering tracking notifications. * *Use 0 to disable. Range (0 - 86400) * * distance: The distance threshold in meters for triggering tracking * *notifications based on the traveled distance. Use 0 to disable. * *Range (0 - 100000)

© 2020 Digitalcomtech

About

Syrus 4 Node JS SDK

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 5