# node-red-contrib-axeapi

This package includes a set of Node-RED nodes which are designed to communicate with Axiomtek EAPI C/C++ library running on your local machine.  

**Update on 2022/01/12**: New Node-RED nodes for RDM (Remote Device Management) are created. Native addon (`src/ax-eapi-rdm.cpp`) for RDM C/C++ library is also added.  This requires the new EAPI library with RDM support.  The define `EAPI_ID_RDM_FIRMWARE_VERSION` in the file `EApi.h` is checked.  If not defined, RDM's native addon will not be built.  The Node-RED nodes for RDM would not work.

## Requirements

* A Node-RED native addon using N-API to provide an interface to Axiomtek EAPI C/C++ library from JavaScript running in Node.js. This natvie addon is included in the package.
* The Axiomtek EAPI library must be installed.

## Installation

1. Copy or download the released package.
2. Uncompress the package.

       tar xzf axiomtek-eapi-node-red.tar.gz
       cd node-red-contrib-axeapi

3. Install the node-red dependencies

       npm install

4. Set the variable `AX_EAPI_LIB_DIR` in the binding.gyp file to the `libax_eapi`
   directory on your machine.

5. Build the native addon

       npm install -S node-addon-api
       npm run build

6. Run the following command in your Node-RED user directory - typically `~/.node-red`

       npm install <dir-path-to node-red-contrib-axeapi>

## Usage

After installation you will find the nodes inside the Node-RED palette.  These 
installed EAPI nodes include:

* ax-hwmon   (HW Monitor)
* ax-dio in  (DIO/GPIO Input node)
* ax-dio out (DIO/GPIO Output node)
* ax-wdt     (Watchdog node)
* ax-board   (Board Info node)

These installed RDM nodes include:

* rdm-edidemu  (EDID Emulator node)
* rdm-system   (System node)
* rdm-lan      (LAN node)
* rdm-usb      (USB node)
* rdm-hdmi     (HDMI node)
* rdm-schedule (Display Schedule node)
* rdm-wd (Watchdog node)

### Input/Output

For more information on the input/output of each node, please refer to the help text in the info tab.

## Testing

Automated test scripts are created to test and verify all Node-RED nodes and 
the native addon for EAPI C/C++ library.  The JavaScript unit test framework 
`Mocha` is used.  In addition, there is an option to report the test results 
to Axiomtek's TestLink server.

By default, reporting to TestLink is disabled.  Add the option `--global testlink` 
to the Mocha command-line, as follows:

```
mocha --global testlink test/nodes/hwmon_spec.js --reporter ./test/ax_reporter.js
```

To run Mocha without reporting, use this command:

```
mocha test/nodes/hwmon_spec.js --reporter ./test/ax_reporter.js
```

Or to run Mocha with the default reporter `spec`, use this command:

```
mocha test/nodes/hwmon_spec.js
```

### Test Configuration

Before you run any automated tests with TestLink reporting enabled, you need 
to modify the test configuration file `./test/_test.config.js`.  In this file,
the following TestLink related parameters need to be modified:

1. Tester's apiKey
2. Tester's account name

If you want to report to a different TestLink project, then you need to 
provide the following information in this file:

1. Your test plan ID
2. Prefix for the test cases.
3. Your build ID
4. Your platform ID
