User Guide for ADVANTECH models including: Node.js Router App, Node.js, Router App, App
Router Apps - Cellular Routers Engineering Portal
File Info : application/pdf, 13 Pages, 465.98KB
DocumentDocumentNode.js Advantech Czech s.r.o., Sokolska 71, 562 04 Usti nad Orlici, Czech Republic Document No. APP-0080-EN, revision from 12th October, 2023. © 2023 Advantech Czech s.r.o. No part of this publication may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photography, recording, or any information storage and retrieval system without written consent. Information in this manual is subject to change without notice, and it does not represent a commitment on the part of Advantech. Advantech Czech s.r.o. shall not be liable for incidental or consequential damages resulting from the furnishing, performance, or use of this manual. All brand names used in this manual are the registered trademarks of their respective owners. The use of trademarks or other designations in this publication is for reference purposes only and does not constitute an endorsement by the trademark holder. Used symbols Danger Information regarding user safety or potential damage to the router. Attention Problems that can arise in specific situations. Information Useful tips or information of special interest. Example Example of function, command or script. Contents 1. Changelog 1 1.1 Node.js Changelog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2. Node.js Router App 2 2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2.2 Building the Custom Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 3. Router Node 3 3.1 Node Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3.1.1 productName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3.1.2 productModel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 3.1.3 productRevision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 3.1.4 platformCode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 3.1.5 serialNumber . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 3.1.6 firmwareVersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 3.1.7 RTCBatteryOK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 3.1.8 powerSupply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.1.9 temperature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.1.10 usrLED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.1.11 bIn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.1.12 bOut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.1.13 XBus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.1.14 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 4. Related Documents 9 List of Figures 1 Loading the Node.js Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 List of Tables 1. Changelog 1.1 Node.js Changelog v1.0.0 (2017-10-02) · First release. v1.1.0 (2017-11-08) · Updated to Node.js 8.9.1. v1.2.0 (2018-02-18) · Added support for logging to file with rotating. v1.2.1 (2018-08-10) · Updated to Node.js 8.11.1. v2.0.0 (2020-02-21) · Updated to Node.js 10.15.3 and ffi 2.3.0. · Optimized installing nodes files to reduce size. · Prepared for new GCC 7.4. · Prepared for new kernel 4.14. · Prepared for V4 platform. · Added the custom node "router". · Set a default path for searching nodes to /usr/lib/node_modules. v2.1.0 (2021-05-06) · Updated to Node.js 10.23.1. · Moved license information from Node-RED module. v16.14.2 (2022-03-18) · Updated to Node.js 16.14.2 with npm 8.5.0. v16.15.0 (2022-05-10) · Added a object for working with the router configuration to the router node. · Updated to Node.js 16.15.0 with npm 8.5.5. · Fixed login on FW 6.3.5. v16.17.0 (2022-08-25) · Updated to Node.js 16.17.0 with npm 8.15.0. · Added property productModel to the router node. v18.15.0 (2023-04-06) · Updated to Node.js 18.15.0 with npm 9.5.0. · Removed obsolte useless node "when". Node.js Manual 1 2. Node.js Router App Router app Node.js is not contained in the standard router firmware. Uploading of this router app is described in the Configuration manual (see Chapter Related Documents). This router app is only compatible with v3 and v4 platform routers! 2.1 Introduction The Node.js node is a proprietary server-side JavaScript runtime environment node available for Advantech cellular routers. This node is used by Advantech modules written in JavaScript, but can be used by any other third-party JavaScript application for routers administration and maintenance. Router module contains this nodes addition to buil-in nodes: · node-authenticate-pam asynchronous PAM authentication for NodeJS, · router node a proprietary node for Advantech's cellular routers described in this document in detail. 2.2 Building the Custom Nodes An official way how to build and install a node is using command. However, there are some limitation as Advantech routers are embedded devices without a full Linux OS and with specialized hardware. You can install Router App to the router and use it in the common way, or prepare nodes with npm tool on your PC and then copy them to the router. But it is not possible to install all nodes you can find in the npm repository. For more details see: ttsrtrtsstrsrsr in the chapter 4.5 of Node-RED Application Note. Node.js Manual 2 3. Router Node This part of the document is dedicated especially to programmers. Router node (named "router") provides access to router specific functions and hardware. You can load the Node.js node in your code by require("router"), for example: r r rqrrtr We will use the r variable from this example to access all the properties in the next examples in this notes. Simple Example of Router Node Use In the next figure is an example of loading the Node.js node. Figure 1: Loading the Node.js Node 3.1 Node Properties 3.1.1 productName Read-only string variable loaded with router's product name. Example of usage: srrt Output: SPECTRE-v3T-LTE Node.js Manual 3 3.1 Node Properties 3.1.2 productModel Read-only string variable loaded with router's model indication. Example of usage: srrt Output: ICR-3201W 3.1.3 productRevision Read-only string variable loaded with router's product revision number. Example of usage: srrts Output: 1.0 3.1.4 platformCode Read-only string variable loaded with router's platform code. It is supported by routers of v3 and v4 production patform. Example of usage: srtr Output: V3 3.1.5 serialNumber Read-only string variable loaded with router's serial number. Example of usage: srsrr Output: ACZ1100000322054 3.1.6 firmwareVersion Read-only string variable loaded with router's firmware version. Example of usage: srrrrs Output: 6.2.1 (2019-10-16) 3.1.7 RTCBatteryOK Read-only boolean variable loaded with router's RTC battery state. True means OK, false means bad. Example of usage: srttr Node.js Manual 4 3.1 Node Properties Output: true 3.1.8 powerSupply Read-only decimal number variable loaded with router's power supply voltage. Example of usage: srr Output: 11.701 V 3.1.9 temperature Read-only integer number variable loaded with router's internal temperature in Celsius degrees. Example of usage: srtrtr Output: 39 °C 3.1.10 usrLED Write-only boolean variable for control router's "USR" LED. Example of usage: rsr tr Sets USR LED to ON (lighting). Node.js Manual 5 3.1 Node Properties 3.1.11 bIn Read-only array with values on router's binary inputs. Array has the items related to number of the binary inputs. E.g. the router has BIN0 and BIN1 so array has valid indexes 0 and 1. The array items can have values 0 or 1. Example of usage: s sr r t r Output: The secondary binary input: 0 3.1.12 bOut Array related to router's binary outputs. It is similar as B_IN but you can also write values. Writen value change output state. Example of usage: srt Output: 1 rt Sets the first binary output to 0. 3.1.13 XBus Object for working with X Bus. X Bus is a proprietary bus for communication between processes. E.g. you can subscribe informations which network interface go up/down or SMS from a mwan daemon. You can also send/subscribe your own topics between your applications. sst strs Sends message with topic String and payload String to X Bus. Example of usage: rsstr t Sends to the system watch request to watch your "myapp" application. The application must send this message regulary no later then period defined in the previous message (300 s in this example). Timeout 0 stops watching. sssrt Subscribes to get messages with topic. Example of usage: Function: sssrstts s ss Asynchronous output: strt tr Node.js Manual 6 3.1 Node Properties trt t sssrt Unsubscribe from topic. Example of usage: rsssr Stops receiving info abour registration to network from previous example. sst Lists stored messages. Example of usage: rsst Output: r r stts stts trr trr tr tr tr Node.js Manual 7 3.1 Node Properties XBus.read(topic) Read stored message from XBus. Example of usage: rsr Output: s rss t 3.1.14 configuration Object containing the router configuration. User can read a configuration item by geting a object property and write a configuration item by setting a object property. The object keys are the same as configuration keys as in the setting files. It is possible to look for a requested key name in related setting file. The firmware configurations are placed in the tstts files. Router App's configuration are placed in the ttstts files. The Router Report (Web UI: Status / System Log / Save Report) contains a full list of the current configuration and may be it is the easest way how to find the requested configuration key. If a given key does not exist a read value is undefined and a written value cause exception (in strict mode). It is not possible to add a new non-existing configuration item, only to modify an existing one. The all configuration values are treated as strings. If user need to work with a different type he must convert it himself. Node does not perform any value validation. The user is responsible for sending the correct values. Examples: srrt rtr P s rrtP For WIFI_AP_SSID=ROUTER_AP in /etc/settings.wifi_ap (or rather in the SSID field in the WiFi · Access Point 1 form) output will be: rrt rtr P s P An example how to set a configuration value: rrtP Changes the IP addres on eth0 interface NOTE: A new configuration is only written. If user wants it to apply to the running environment restarting the router or the related service is necessary. For example above it is possible to use the following shell command: ttt rstrt Node.js Manual 8 4. Related Documents [1] Router apps: icr.advantech.cz/user-modules [2] JS Foundation: https://nodered.org/ You can obtain product-related documents on Engineering Portal at icr.advantech.cz address. To get your router's Quick Start Guide, User Manual, Configuration Manual, or Firmware go to the Router Models page, find the required model, and switch to the Manuals or Firmware tab, respectively. The Router Apps installation packages and manuals are available on the Router Apps page. For the Development Documents, go to the DevZone page. Node.js Manual 9