Difference between revisions of "Device-Node.js SDK"

From ESS-WIKI
Jump to: navigation, search
Line 27: Line 27:
 
=== config ===
 
=== config ===
  
agent_config.json
+
==== agent_config.json ====
 
<pre>  - DeivceNam: <XXX> Name of application
 
<pre>  - DeivceNam: <XXX> Name of application
 
&nbsp; - ServiceType: <xxx> Category of application
 
&nbsp; - ServiceType: <xxx> Category of application
Line 35: Line 35:
 
</pre>
 
</pre>
  
log.json
+
==== log.json ====
  
 
confinuration of advlog-node.js
 
confinuration of advlog-node.js
  
[http://advgitlab.eastasia.cloudapp.azure.com/EdgeSense-Open/advlog-node.js http://advgitlab.eastasia.cloudapp.azure.com/EdgeSense-Open/advlog-node.js]
+
[https://gitlab.edgecenter.io/edgesense-open/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&nbsp; &nbsp; &nbsp;- console.warn
 +
*5: INFO&nbsp; &nbsp; &nbsp; &nbsp;- consloe.log ( Default )
 +
*7: DEBUG&nbsp; &nbsp;- consloe.debug
 +
*8: TRACE&nbsp; &nbsp; - consloe.trace
  
 
=== Plugin ===
 
=== Plugin ===

Revision as of 02:21, 8 May 2020

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

Demo  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.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

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

  1. Rename the Simple-plugin_temp.js by your applicaton name
  2. Chang the plugin path in config/agent_config.json : 'plugin'
  3. InitPlugin: InitPlugin  => Refer < InitTest > in Simple-plugin_test.js
  4. AutoReport: start auto report interval callback function; Implement to call send data in this=> Refer < AutoUpdateTest > in  Simple-plugin_test.js
  5. setSenseData: DeviceOn server or others 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.
  6. sendEventTest: You can refer to "sendEventTest" to trigger a event alarm to local MQTT Broker and transfer to DeviceOn server.

Note

  • If plugin need to send OPTS to DeviceOn, OPTS can not be assigned to 0 in plugin's capability. OPTS need to use current timestamp.