AgentLite-Node.js
Contents
Introduction
AgentLite-Node.js is a light weight south-bound agent in Node.js. There are 3 main components of "1. Net-Protocol ( ./lib/WISECore3.3.js)", 2. main program ( AgentLite3.3.js) and 3. plugin module ( ./module/plugin_temp.js). Develop need to develop a plugin.js.
AgentLite-Node.js
Configure
./config/agent_config.json : in JSON Format
<code>{
"ServerIP":"127.0.0.1",
"ServerPort": 1883,
"DeviceName": "SNMP_Handler",
"DevType": "Service",
"version": "v1.0.1"
}</code>
Plugin
Internal Function
Developer needs to implement these internal functions by your application.
var InitPlugin()
- Description: To initialize process of your plugin.
var UnInitPlugin()
- Description: To uninitialize process of your plugin.
var AutoReport()
- Description: system will call this "AutoReport" after trigging auto report. To send auto report data by "g_sendreportcbf".
var getSenseData( iCmd, strSessionid, jsRequest )
- Description: To receive a get control command and call this function to query sensor data in capability cach.
var StartMonitorData(iCmd, strSessionid, jsMsg )
- Description: To receive a get monitor command and register a timer envet to call "MonitorUpdate" function.
var MonitorStop( )
- Description: To stop a timer event of Monitor sensor data.
var MonitorUpdate()
- Description: To upload sensor data by g_sendreplytopiccbf
Callback functions
| Parameter | Description |
|---|---|
| g_sendcbf | reply action function point |
| g_sendreportcbf | auto report function point |
| g_sendcapabilitycbf | send capability function point |
| g_sendeventcbf | send event message function point |
| g_sendreplytopiccbf | send update data by reply action topic ( Monitor page ) function point |
Export Interfaces of Plugin
var Handler_Initialize( param )
- Description: Main program calls "Handler_Initialize" to initialize this module.
| Parameter | Description |
|---|---|
| param.sendcbf | reply action function point |
| param.sendreportcbf | auto report function point |
| param.sendcapabilitycbf | send capability function point |
| param.sendeventcbf | send event message function point |
| param.sendreplytopiccbf | send update data by reply action topic ( Monitor page ) function point |
var Handler_Uninitialize( )
- Description: Main program calls "Handler_Uninitialize" to uninitialize this module.
void Handler_AutoReportStart( interval )
- Description: Main program calls the "Handler_AutoReportStart" to start auto report.
| Parameter | Description |
|---|---|
| interval | report interval in second |
var Handler_AutoReportStop()
- Description: Main program calls "'Handler_AutoReportStop'" to stop auto report.
var Handler_Get_Capability()
- Description: Main program calls "'Handler_AutoReportStop'" to get plugin's capability.
var Handler_Recv( strTopic, strMsg )
- Description: Main program calls "'Handler_Recv'" if receive a control message from others.
| Parameter | Description |
|---|---|
| strTopic | received mqtt topic |
| strMsg | received message |
Source Code
gitlab http://advgitlab.eastasia.cloudapp.azure.com/EdgeSense/AgentLite-Node.js