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

From ESS-WIKI
Jump to: navigation, search
(.)
Line 7: Line 7:
 
== Pre-Requirement ==
 
== Pre-Requirement ==
  
*MQTT Broker ( [[MQTT_Broker|Download]] ) : Please install the MQTT Broker on target platform.
+
*MQTT Broker ( [[MQTT_Broker|Download]] ) : Please install the MQTT Broker on target platform.
 
*[https://nodejs.org/en/ Node.js] >= 5.x: Please install above 5.x Nodejs on target platform.
 
*[https://nodejs.org/en/ Node.js] >= 5.x: Please install above 5.x Nodejs on target platform.
  
Line 44: Line 44:
  
 
#Rename the '''Simple-plugin_temp.js''' by your applicaton name
 
#Rename the '''Simple-plugin_temp.js''' by your applicaton name
#Chang the plugin path in '''config/agent_config.json :&nbsp;''''''<span style="color:#0000FF;">plugin</span>'''
+
#Chang the plugin path in '''config/agent_config.json&nbsp;:&nbsp;''''''<span style="color:#0000FF;">plugin</span>'''
 
#<span style="color:#0000FF;">'''InitPlugin'''</span>: InitPlugin&nbsp; => Refer &lt; InitTest &gt; in '''Simple-plugin_test.js'''
 
#<span style="color:#0000FF;">'''InitPlugin'''</span>: InitPlugin&nbsp; => Refer &lt; InitTest &gt; in '''Simple-plugin_test.js'''
 
#<span style="color:#0000FF;">'''AutoReport'''</span>: start auto report interval callback function; Implement to call send data in this=> Refer &lt; AutoUpdateTest &gt; in&nbsp;&nbsp;Simple-plugin_test.js
 
#<span style="color:#0000FF;">'''AutoReport'''</span>: start auto report interval callback function; Implement to call send data in this=> Refer &lt; AutoUpdateTest &gt; in&nbsp;&nbsp;Simple-plugin_test.js
 
#<span style="color:#0000FF;">'''setSenseData'''</span>: 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.
 
#<span style="color:#0000FF;">'''setSenseData'''</span>: 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.
 
#<span style="color:#0000FF;">'''sendEventTest'''</span>: You can refer to "sendEventTest" to trigger a event alarm to local MQTT Broker and transfer to DeviceOn server.
 
#<span style="color:#0000FF;">'''sendEventTest'''</span>: 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&nbsp;OPTS to DeviceOn, OPTS can not be assigned to 0 in plugin's&nbsp;capability. OPTS need to use current timestamp.

Revision as of 09:12, 3 March 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@advgitlab.eastasia.cloudapp.azure.com: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

http://advgitlab.eastasia.cloudapp.azure.com/EdgeSense-Open/advlog-node.js

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.