Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

candy-red

CANDY-LINE14Apache-2.09.11.0

CANDY RED :: Visual Programming Editor and Runtime for CANDY Pi Lite powered by Node-RED

rpi, raspberry-pi, raspbian, atb, asus tinkerboard, tinkerboard, enocean, SmartMesh, lwm2m, CANDY EGG, CANDY Pi Lite, CANDY Pi Lite+

readme

CANDY RED

GitHub release master Build Status

CANDY RED is IoT gateway software designed for CANDY Pi Lite board with Raspberry Pi and ASUS Tinker Board powered by Node-RED.

Features

*1 CANDY Pi Lite Board is required.
*2 CANDY EGG cloud service account is required.

OS and Hardwares

Screenshots

CANDY RED flow editor page on browser

This is the default screen theme.

CANDY RED Screenshot

Raspberry Pi + Raspbian

Prerequisites

Raspbian version

  • 2020-02-13-raspbian-buster

Tested Node.js versions

  • v10 (Active LTS)
  • v12 (Active LTS)

Supported npm version

  • v6.x+

Install/Version-up

The module installation will take around 30 minutes on RPi1. On RPi2+, the installation time will be shorter.

Please consider to change your hostname as described below prior to installing CANDY RED.

--unsafe-perm flag is required for installing this project module since npm performs privileged actions during the installation. This is discussed in the issue.

You can ignore npm WARNs, gyp WARNs, gyp ERR!s and node-pre-gyp ERR!s unless the installation terminates normally. You can check if the installation is successful by sudo service candy-red status command after running install.sh script as well as npm install.

** Please export your flow data prior to performing version-up **

Please refer to the following commands to install.

$ sudo npm install -g --unsafe-perm --production candy-red

You can access http://<hostname.local or ip address>:8100 with your browser on the same LAN where <hostname.local or ip address> is a host name with .local suffix or IP address.

Authentication

PAM authentication is enabled by default for both Linux (Raspbian/Debian/Ubuntu) and macOS. So you need to login with your OS account such as pi user. You can add custom user ID/password as well by providing the following environmental variables on installation.

When providing the credentials, PAM authentication is disabled.

$ sudo \
    CANDY_RED_ADMIN_USER_ID=... \
    CANDY_RED_ADMIN_PASSWORD=... \
    npm install -g --unsafe-perm --production candy-red

The password is encrypted while the installation process.

Note that PAM authentication feature (not custom credentials authentication) is disabled unless NODE_ENV is production.

Stop/Start/Status Service (Raspbian)

The service name is candy-red. As of Jessie, systemd comes as a default system manager.

$ sudo systemctl stop candy-red
$ sudo systemctl start candy-red
$ sudo systemctl status candy-red
$ sudo journalctl -f -u candy-red -o cat

Uninstall

$ sudo npm uninstall -g --unsafe-perm candy-red

If you run sudo npm uninstall -g candy-red (without --unsafe-perm) and see [ERROR] This script must be run as root message, please run the following commands in order to reset systemd configurations.

$ sudo systemctl stop candy-red
$ sudo systemctl disable candy-red
$ sudo rm -f "$(dirname $(dirname $(which systemctl)))/lib/systemd/system/candy-red.service"

RPi Tips

Change Hostname

Since RPi hostname is raspberrypi by default, you will get confused when you have 2 or more devices and they're online.

You can change the host name by either sudo raspi-config.

BLE USB adaptor/dongle

CANDY RED service tries to activate the hci0 device if it exists on boot so that you can use BLE devices on the flow editor. This is performed silently at background and you usually don't have to care of it.

However, you need to tell the system to restart the CANDY RED service by performing sudo systemctl restart candy-red when you insert the dongle after boot. Or BLE is not available.

Node-RED home

The Node-RED home path, where flow files are placed, is found at $(npm root -g)/candy-red/.node-red/. Alternately, you can provide the arbitrary path with CANDY_RED_HOME environment variable defined in $(npm root -g)/candy-red/.node-red/environment file.

BlueZ source code build

The latest Raspbian offers you to install BlueZ with apt-get command as described above. However, you can still use the latest version of BlueZ if you want.

You can find the installation instruction in the article. The compilation takes around 40 minutes (RPi B+).

Here is a brief instruction. (Check the latest version of BlueZ at www.bluez.org)

$ BLUEZ_VER=5.52
$ sudo apt-get install -y build-essential libdbus-1-dev \
    libdbus-glib-1-dev libglib2.0-dev libical-dev \
    libreadline-dev libudev-dev libusb-dev make
$ wget https://www.kernel.org/pub/linux/bluetooth/bluez-${BLUEZ_VER}.tar.xz
$ tar xvf bluez-${BLUEZ_VER}.tar.xz
$ cd bluez-${BLUEZ_VER}
$ ./configure
$ make
$ sudo make install

Configuration

Initial Welcome Flow

Welcome flow is a sample flow for helping users to understand the flow editor, which is created by CANDY RED when user's flow is missing.

WELCOME_FLOW_URL environmental variable allows users to specify the initial welcome flow file in URL form. You can set it on installation by, for example, WELCOME_FLOW_URL=http://... npm install -g .....

By default, welcome-flow.json is used as the initial flow.

Note that the downloaded flow file will be discarded if it is not a valid JSON data.

Preinstalled nodes

$ sudo NODES_CSV="node-ed-contib-cache,>=1.0.4 node-ed-contib-geneic-ble,>=2.0.4 node-ed-contib-smartmesh,>=1.0.0" npm install -g --unsafe-perm --production candy-red

Either a single space or \n can be a delimiter of NODE_CSV value.

Development

Prerequisites

Supported Node.js versions

  • v10 (Active LTS)
  • v12 (Active LTS)

Setup for Building

Install the local dependencies.

$ git clone https://github.com/CANDY-LINE/candy-red.git
$ cd candy-red
$ DEVEL=true npm install
# Run one of the following command to install default nodes
$ make #=> default nodes are installed into ~/.node-red/node_modules
$ make CANDY_RED_HOME=$(pwd)/tmp #=> default nodes are installed into $(pwd)/tmp/.node-red/node_modules

Build

$ npm run build

The processed files are placed under dist directory.

Version up

Just pull the update on the candy-red directory and perform npm install.

$ cd candy-red
$ git pull
$ npm install --production

Run on localhost for development use

Try the following commands after npm run build: (Prepends sudo for Raspbian)

$ npm run start

With a remote welcome flow file:

$ WELCOME_FLOW_URL=https://git.io/vKx5r npm run start

And you'll see the sensor info like this:

[INFO] Default welcome flow has been created
29 Jul 21:52:35 - [info] [CANDY RED] Deploying Flow Editor UI...


Welcome to Node-RED
===================

29 Jul 21:52:35 - [info] Node-RED version: v0.14.6 [candy-red v2.6.3]
29 Jul 21:52:35 - [info] Node.js  version: v4.4.7
29 Jul 21:52:35 - [info] Darwin 15.6.0 x64 LE
29 Jul 21:52:35 - [info] Loading palette nodes
29 Jul 21:52:36 - [info] UI started at /api/ui
29 Jul 21:52:36 - [warn] ------------------------------------------------------
29 Jul 21:52:36 - [warn] [rpi-gpio] Info : Ignoring Raspberry Pi specific node
29 Jul 21:52:36 - [warn] ------------------------------------------------------
29 Jul 21:52:36 - [info] User directory : /Users/guest/.node-red
29 Jul 21:52:36 - [info] Flows file     : /Users/guest/.node-red/flows_candy-red.json
29 Jul 21:52:36 - [info] [BLE] Set up done
29 Jul 21:52:36 - [info] Listen port=8100
29 Jul 21:52:36 - [info] Starting flows
29 Jul 21:52:36 - [info] [inject:89c364b0.763c98] repeat = 1000
29 Jul 21:52:36 - [info] Started flows

With password authentication:

$ CANDY_RED_ADMIN_USER_ID=admin \
  CANDY_RED_ADMIN_PASSWORD_ENC=`node -e "console.log(require('bcryptjs').hashSync(process.argv[1], 8));" password` \
  CANDY_RED_SESSION_TIMEOUT=3600 \
  npm run start

The above variables allows you to use the following credentials,

  • username: admin
  • password: password
  • session timeout: 1 hour

Test

$ npm test

Package

# Development Machine
$ npm pack
$ scp ./candy-red-9.11.0.tgz pi@raspberrypi.local:~

# RPi (on ~)
$ sudo npm uninstall -g --unsafe-perm candy-red
$ sudo rm -fr /opt/candy-red # to prune user specific files if necessary
$ time sudo npm install -g --unsafe-perm ./candy-red-9.11.0.tgz
$ sudo journalctl -f -u candy-red -o cat # to show logs

Upload dist

$ scp -rp ./dist/* pi@raspberrypi.local:/usr/lib/node_modules/candy-red/dist

Docker

Image Building

$ cd candy-red
$ docker build -t candy-red .
$ docker build --build-arg CANDY_RED_VERSION=9.9.0  -t candy-red .

Run CANDY RED container

Run in foreground:

$ docker run -ti --rm candy-red

Ctrl+C to exit.

Run in background:

$ docker run -tid --name candy-red candy-red

Run docker rm -f candy-red to stop (and remove) the container.

Run CANDY RED container with manually built code

Run in foreground:

$ npm run build
$ docker run -ti --rm -v ./dist:/candy-red-dist candy-red

Run in background:

$ npm run build
$ docker run -tid -v ./dist:/candy-red-dist candy-red

How to release

  1. Publish NPM package: npm publish
  2. Tag Release and Push

Coding Styles

  1. Use ES6 (except gulpfile.js and *.html)
  2. 2-space soft tabs
  3. Append .es6.js suffix to ES6 JS files
  4. See .jshintrc for detail

TODO

  • publish local Node-RED nodes in this project to npm repository

Files including the package version

  1. README.md
  2. package.json

Copyright and License

Source Code License

© CANDY LINE INC.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Creative works

PNG/ICO images under src/public folder are released under CC BY-NC-SA, Copyright (c) 2019 CANDY LINE INC.

changelog

Revision History

  • 9.11.0

    • Add Node-RED v1.3.1+ support
  • 9.10.0

    • Bump preinstalled nodes
      • node-red-dashboard
      • node-red-twitter
      • node-red-contrib-schedex
      • node-red-contrib-lwm2m
      • @mindconnect/node-red-contrib-mindconnect
      • node-red-contrib-web-worldmap
      • node-red-node-pi-sense-hat
      • node-red-contrib-influxdb
  • 9.9.3

    • Bump Node-RED version to v1.2.9
    • Add node-red-contrib-ble-scan
    • Bump preinstalled nodes
      • node-red-dashboard
  • 9.9.2

    • Bump preinstalled nodes
      • node-red-dashboard
      • node-red-node-ui-table
      • node-red-contrib-web-worldmap
      • @mindconnect/node-red-contrib-mindconnect
      • node-red-contrib-influxdb
      • node-red-contrib-statistics
  • 9.9.1

    • Bump Node-RED version to v1.2.6
    • Bump preinstalled nodes
      • node-red-dashboard
      • node-red-node-ui-table
      • node-red-node-twitter
  • 9.9.0

    • Use systeminformation to resolve a serial number for generic computers
    • Enable GZIP compression for HTTP transfer
    • Bump Node-RED version to v1.2.2
    • Bump preinstalled nodes
      • node-red-contrib-lwm2m
      • @mindconnect/node-red-contrib-mindconnect
      • node-red-dashboard
      • node-red-node-ui-table
  • 9.8.1

    • Bump preinstalled nodes
      • node-red-contrib-generic-ble
      • node-red-contrib-web-worldmap
      • node-red-contrib-adxl-vibration-fft
      • @mindconnect/mindconnect-nodejs
      • @mindconnect/node-red-contrib-mindconnect
      • node-red-contrib-influxdb
  • 9.8.0

    • Bump preinstalled nodes
      • node-red-dashboard
      • node-red-contrib-schedex
      • node-red-contrib-adxl-vibration-fft
      • node-red-node-ui-table
  • 9.7.0

    • Fix an issue where locally preinstalled nodes caused runtime errors on deployment
    • Bump Node-RED version to v1.1.3
    • Bump node-red-dashboard to v2.23.2
    • Bump other preinstalled nodes
  • 9.6.0

    • Bump Node-RED version to v1.1.2
    • Bump node-red-dashboard to v2.23.0
    • Bump other preinstalled nodes
  • 9.5.0

    • Add node-red-contrib-influxdb
    • Add node-red-contrib-statistics
  • 9.4.0

    • Bump Node-RED version to v1.0.6
    • Bump node-red-dashboard to v2.22.1
    • Bump node-red-contrib-generic-ble to v4.0.1
    • Fix an issue where some python libraries for Python 2.7 are installed on Python 3 when pip command is running on Python 3.
      • Most existing Python dependent nodes such as Raspberry Pi's GPIO node still depend on Python 2.7.
      • Not using pip to install the dependencies
  • 9.3.0

    • Bump node-red-contrib-adxl-vibration-fft to v2.0.0
  • 9.2.0

    • Add node-red-contrib-conect-plus
    • Bump node-red-dashboard to v2.19.4
  • 9.1.0

    • Bump Node-RED version to v1.0.4
    • Bump lwm2m node version to v2.10.0
    • Strip the experimental feature
  • 9.0.2

    • Bump lwm2m node
    • Update the experimental feature (not affecting normal use)
    • Add node-red-node-ui-table
    • Update node-red-node-twitter
  • 9.0.1

    • Modify the method to install authenticate-pam package
    • Restart process when failing to retrieve modem info
  • 9.0.0

    • Upgrade Node-RED to v1.0.3
    • Add support for Node.js v12
    • Drop support for Node.js v8
    • Add Devcie Management support (Opt-in, disabled by default)
  • 8.3.0-8.3.2

    • Add new preinstalled nodes
      • @candy-line/node-red-contrib-eh-terminal-g2
      • @candy-line/node-red-contrib-omron-2jcie-bu
  • 8.2.3

    • Add support for Node.js v10
  • 8.2.2

    • Fix an issue where cwd was not reverted after installing default nodes
  • 8.2.1

    • Fix npm init error
  • 8.2.0

    • Fix an issue where package.json on the preinstalled module directory never contained the preinstalled dependencies
  • 8.1.0

    • Add a new preinstalled node
      • node-red-contrib-adxl-vibration-fft
    • Bump up Node-RED Dashboard version to v2.10.1
  • 8.0.2

    • Fix an issue where node-red-contrib-lwm2m was missing
  • 8.0.1

    • Fix typo
  • 8.0.0

    • Renew all icons and logo images
    • Add new preinstalled nodes
      • node-red-contrib-camerapi
    • Bump up Node-RED Dashboard version to v2.9.7
  • 7.1.0

    • Remove Node.js v6 from the supported versions (still should work on Node.js v6 though)
    • Move the following nodes to user directory so that users can remove them if necessary
      • node-red-contrib-cache
      • node-red-contrib-web-worldmap
      • node-red-node-pi-sense-hat
    • Remove config cache files after upgrading CANDY RED to discard expired data
  • 7.0.2

    • Add a missing package
  • 7.0.1

    • Remove devDependencies by default on generating a shrinkwrap file
    • Remove devDependencies from the shrinkwrap file
  • 7.0.0

    • Add new preinstalled nodes
      • node-red-node-smooth
      • node-red-node-base64
      • node-red-node-data-generator
      • node-red-node-random
      • node-red-node-suncalc
      • node-red-contrib-web-worldmap
    • Add GNSS nodes with example flows dedicated to CANDY Pi Lite 3G and CANDY Pi Lite+
    • Add a new category for CANDY LINE (CANDY EGG nodes and GNSS nodes are placed there)
  • 6.1.0

    • Bump up Node-RED Dashboard version to v2.9.1
    • Add a new preinstalled package (SmartMesh IP™ device node)
    • Install PySerial for preinstalled SmartMesh IP™ device node
  • 6.0.1

    • Fix an issue where ATB with Tinker OS v2.0.5+ was misidentified as RPi because of preinstalled RPI.GPIO package
  • 6.0.0

    • Bump up Node-RED version to v0.18.4
    • Bump up Node-RED Dashboard version to v2.8.2
    • Remove node-red-contrib-sequence-functions nodes as the similar nodes are now included as core nodes
    • Add a new option NODE_RED_PROJECTS_ENABLED to enable/disable Node-RED Projects support, which allows you git-based version control on your flow files (disabled by default for now)
  • 5.6.1

    • Fix issues where type errors can be thrown on some node state
  • 5.6.0

    • Add support for binding IPv4 interface as well as IPv6/dual-stack interfaces
    • Bump dependency versions
  • 5.5.0

    • Add device id prefix support for Tinker Board and generic Linux boards as well as RPi
    • Warn weak passwords as well as Raspberry Pi default password
  • 5.4.0

    • Add Show warning alert when the given username and password are Raspberry Pi's default
    • Add Raspberry Pi Sense HAT support
  • 5.3.0

    • Add PAM authentication support (enabled by default)
    • Fix an issue where API authentication didn't work when basic authentication is enabled
    • Compute --max-old-space-size value when the option is missing
    • Fix an issue where ESP3Parser doesn't support node-serialport@5+ interface
    • Add a new endpoint to provide enocean ports as well as serial ports
  • 5.2.0

    • Add basic authentication support for admin role account
    • Add a new option to enable/disable the warning output on unknown originator ids being detected
    • Add node-red-contrib-lwm2m node as a builtin node
    • Add support for Node.js v8.9+
    • Fix an issue where the runtime error can be thrown when properties in accountConfig is missing
    • Fix an issue where WS client failed to connect to non-default port
  • 5.1.0

    • Add a new environment NODES_CSV to provide preinstalled nodes on installing CANDY RED
    • Add CANDY RED icons to appear on Node-RED Dashboard
    • Fix an issue where install_preinstalled_nodes were invoked on installation test
    • Disable drop_console in order to show logs at pre-initialized state
    • Fix an issue where folders under node_moudles cannot be removed
  • 5.0.1

    • Fix an issue where some of default packages cannot be installed because of existing packages
  • 5.0.0

    • Migrate to Apache Software License 2.0 as of this version
    • Add a feature to allow users to install additional node packages on installing CANDY RED
      • Set NODES_CSV_PATH pointing to the path to node package list CSV file
    • Bump default Node.js version to 6.11
    • DO NOT bump node-enocean version to 2.x or later as Node.js 7+ isn't yet supported
    • Remove obsolete board support (CANDY BOX)
    • node-red-contrib-asakusa_giken is now an optional node, which can be installed via the Node Palette
    • node-red-contrib-generic-ble is installed as a preinstalled BLE node
  • 4.0.0

    • Set NODE_PALETTE_ENABLED=true by default
    • Repo transferred to CANDY-LINE
    • Fix an issue where ws complained of the credentials containing unescaped special characters like '%'
    • Allow hyphen as CANDY EGG account id
    • Migrate to gulp
    • Use credentials property for CANDY EGG account node (with backward compatibilities)
  • 3.0.0

    • Bump up Node-RED version to v0.16.2 (NOTE: Node-RED Node Palette is disabled by default, set NODE_PALETTE_ENABLED=true for enabling the palette UI)
    • Node.js v0.12 is no longer supported
    • Intel Edison is no longer supported
    • LTEPiGPS is retired
  • 2.9.1

    • Add a new switch to enable/disable learning mode on start up for test use (local-node-enocean)
    • Add a new boolean property whether or not to ignore LRN bit while learning mode (local-node-enocean)
  • 2.9.0

    • Bump up Node-RED version to v0.15.2 (NOTE: Node-RED Node Palette is disabled by default, set NODE_PALETTE_ENABLED=true for enabling the palette UI)
    • Bump up Dashboard UI version to v2.1.0
    • Add a new EnOcean device support for A5-07-01(4BS/Occupancy with Supply voltage monitor)
    • Add teach-in feature to EnOcean node
  • 2.8.2

    • Fix an issue where a socket wasn't closed when WebSocketListener handled redirect response
  • 2.8.1

    • Fix an issue where the process will exit on the flow file being empty
  • 2.8.0

    • Accept the latest version of node-red-contrib-asakusa_giken and node-red-contrib-device-stats packages
    • Fix validation rules (local-nodecandy-egg)
    • Parse JSON string when the incoming message is a JSON string (local-nodecandy-egg)
  • 2.7.0

    • Modify the way to detect if candy-iot board is installed so that the valid UI theme is chosen even when the modem is offline
    • Add new functions for detecting LTEPi-II board
  • 2.6.3

    • Bump up Node-RED version to v0.14.6
    • Bump up Dashboard UI version to v2.0.1
  • 2.6.2

    • Fix welcome flow download error
  • 2.6.1

    • Fix publish error
  • 2.6.0

    • Add a new feature to setup the default flow when user flow file is missing
    • Enable to pretty flow file format by default
    • Enable node-red-contrib-moment v2.0.0 by default for better date/time operation
    • Disable LTEPiGPS on unsupported device
  • 2.5.0

    • Bump up Node-RED version to v0.14.5
    • Enable node-red-dashboard v2.0.0 by default
    • Bump up asakusa_giken node version to v1.1.0
    • Fix CSS
  • 2.4.0

    • Bump up Node-RED version to v0.13.4
  • 2.3.0

    • Remove global dependencies (npm install -g ... is no longer required to build the project)
    • Show device ID on the editor header
    • Bump up Node-RED version to v0.13.3
    • Interact with a service for CANDY IoT Board for Intel® Edison in order to collect the modem information
    • Add a new node for providing GPS location with LTEPi board (RPi series only)
  • 2.2.0

    • Create a dedicated user data directory on /opt/candy-red, where flow files are stored so that they're left on performing version up
    • Add a new experimental local node for collecting device statistics
    • Bump up Node-RED version to v0.13.2
    • Modify the flow file name definition (not depending on hostname but always flows_candy-red.json)
    • LTEPi Board for Raspberry Pi is now automatically detected and RED.settings.ltepiVersion will be set if LTEPi is available
    • Improve device management connection stability
  • 2.1.2

    • Fix jshint error
  • 2.1.1

    • Publish to npm
    • npm installation/uninstallation/version-up support
  • 2.1.0

    • SysVinit is no longer supported
    • Publish the asakusa_giken local nodes as node-red-contrib-asakusa_giken and separate the repo
    • Add Dockerfile for development and testing
    • Add Vagrantfile for development and testing
  • 2.0.1

    • Fix CANDY EGG nodes issues
  • 2.0.0

    • Node-RED integration
    • Add CANDY EGG cloud endpoint nodes
    • Add Asakusa Giken-made BLE nodes
    • Add EnOcean node
    • Add device management features provided with CANDY EGG cloud
      • This feature includes process restart which should work with system services like systemd/sysvinit
    • Bump up Node.js version and BlueZ version for RPi devices
  • 1.3.0

    • Add an option to enable to generate a list of copied files
    • [Edison (Yocto)] Fix an issue where npm install with a github repo id didn't work
    • npm test now works
  • 1.2.0

    • EnOcean Protocol and Profile support (ESP3 with ERP2 and EEP2.6)
    • Source map support for transpiled code
    • [RaspberryPi (Raspbian)] --unsafe-perm flag is required for installation
  • 1.1.0

    • Modifies the installation process, running npm install then install.sh
    • Renames the module name
    • Raspberry Pi (Raspbian) Support
  • 1.0.0

    • Initial Release