Difference between revisions of "Device-Node.js SDK"
From ESS-WIKI
Eric.liang (talk | contribs) |
Eric.liang (talk | contribs) |
||
Line 78: | Line 78: | ||
#Rename the '''[https://gitlab.edgecenter.io/edgesense-open/device-template-node.js/-/blob/master/module/pluginClassTemp.js pluginClassTemp.js] ''' by your applicaton name | #Rename the '''[https://gitlab.edgecenter.io/edgesense-open/device-template-node.js/-/blob/master/module/pluginClassTemp.js pluginClassTemp.js] ''' by your applicaton name | ||
− | #Chang the plugin path in ''' | + | #Chang the plugin path in index_plugin.js''' : '''var agentplugin = require('./module/pluginClassTest.js'); |
#<span style="color:#0000FF;">'''InitPlugin'''</span>: InitPlugin => Refer < InitTest > in '''pluginClassTest.js''' | #<span style="color:#0000FF;">'''InitPlugin'''</span>: InitPlugin => Refer < InitTest > in '''pluginClassTest.js''' | ||
#<span style="color:#0000FF;">'''AutoReport'''</span>: start auto report callback function by interval; To implement send data in this function=> Refer < AutoUpdateTest > in Simple-plugin_test.js | #<span style="color:#0000FF;">'''AutoReport'''</span>: start auto report callback function by interval; To implement send data in this function=> Refer < AutoUpdateTest > in Simple-plugin_test.js |
Revision as of 11:54, 5 January 2021
Contents
Introduction
This is a EdgeSense southbound device service SDK in node.js. User can use this SDK to easy to develop your application to integrate with EdgeSense Core System.
Device-Node.js SDK
Pre-Requirement
- MQTT Broker ( Download ) : Please install the MQTT Broker on target platform.
- Node.js >= 5.x: Please install above 5.x Nodejs on target platform.
How To
How To Run - SamplePlugin Setp: 1 -> 2 -> 3
1. == Download == $git clone git@gitlab.edgecenter.io:edgesense-open/device-template-node.js.git sdk-sample $cd sdk-sample 2. == Install packages == $npm install 3. == Run == $node index_plugin.js
Development
config
agent_config.json
- DeivceNam: <XXX> Name of application - ServiceType: <xxx> Category of application - Description: A brief description - version: version of application - plugin: path of main entry program => ./module/<xxx>.js
Example: iAlarm
{
"DeviceName": "<code>OPCUAClient</code>",
"ServiceType": "<code>Protocol-Converter</code>",
"Description": "<code>OPC-UA Client to access OPC-UA Server node</code>",
"version": "v2.0.2",
<code>"plugin": "/module/opcua-client-plugin.js"</code>
}
log.json
confinuration of advlog-node.js
https://gitlab.edgecenter.io/edgesense-open/advlog-node.js
static: log file
- level: debug level
- information: log format
- path: log folder
- duration: how long to create a new log file ( default : 1 Hr 3600000 ms, Max: 1 day )
- buffer: how long to write to file ( default: 1 sec, 1000 ms, Max: 1 min )
- files: Max log file
dynamic: print to console
- level: debug level
- information: log format
- trace: enable(1)/disable(0) consloe trace
Debug Level
0: NONE 2: ERROR - consloe.error 3: WARN - console.warn 5: INFO - consloe.log ( Default ) 7: DEBUG - consloe.debug 8: TRACE - consloe.trace
Plugin
- Rename the pluginClassTemp.js by your applicaton name
- Chang the plugin path in index_plugin.js : var agentplugin = require('./module/pluginClassTest.js');
- InitPlugin: InitPlugin => Refer < InitTest > in pluginClassTest.js
- AutoReport: start auto report callback function by interval; To implement send data in this function=> Refer < AutoUpdateTest > in Simple-plugin_test.js
- setSenseData: DeviceOn server or other apps to set sensor value to the service. This callback function will be called and you need to implement a set function with your application at this.
- sendEvent: You can refer to "sendEventTest" in pluginClassTest.js to trigger an event alarm to the local MQTT Broker and transfer to DeviceOn server.
Note
- If the plugin needs to send OPTS to DeviceOn, OPTS can not be assigned to 0 in plugin's capability. OPTS must set timestamps according to your application.