How to manage remote devices, install agent tools, and configure certificates in FlowForge

freeFree Technical Resource

This content is free to read, suitable for basic learning and search traffic.

How to manage remote devices, install agent tools, and configure certificates in FlowForge

Devices in FlowForge

Apart from creating multiple instances of Node-RED, the FlowForge platform can also be used to manage remote devices. All that is needed is to install the official toolkit on the device, which can then be used to link to the platform and accept its instructions.

This article will introduce how to manage remote devices

Installing the Device Agent Toolkit

The official Device Agent Toolkit is available in a public npm repository,@flowforge/flowforge-device-agent.

For ease of use, you can install it globally on the remote device.
Installation Command

sudo npm install -g @flowforge/flowforge-device-agent

If you prefer to use a Docker container instead of an npm package, you will need to mount thedevice.yamlfile when running the container, so as to access registered device data.
The command to install the Device Agent Toolkit using Docker is as follows

docker run --mount /path/to/device.yml:/opt/flowforge/device.yaml -p 1880:1880 flowforge/device-agent:latest

Configuration

Working Directory

The default working directory for the device proxy tool is/opt/flowforge-device.
. If you want to overwrite it, you can use the-d/--dirparameter.

Note that the specified directory must exist and have permissions for the current user to run the proxy tool.

Commands to create a working directory and assign permissions.

sudo mkdir /opt/flowforge-device
sudo chown -R $USER /opt/flowforge-device

Listening Port

The Node-RED instance uses port1880by default. In the device proxy tool, you can modify this configuration by specifying a port number using the parameter-p/--port. This is useful for customizing firewall rules and when there are many instances on a single device.

Command to specify a port

flowforge-device-agent --port=1881

Register Device

In order to link a device to the FF platform, you need to set up a certificate for the device.
There are two types of integers on the FF platform:

  • Device certificates, which are used for individual devices to link to the platform, and
  • Provisioning certificates, which are used to set up one or more devices for batch registration on the FF platform.

Device certificates can be generated on the device management page.
Provisioning certificates can be generated on the team's settings page, under the Devices tab.

To connect a device

and link it to the FF platform using a device certificate, you need to copy the content of the device certificate intodevice.yml, which is usually stored in/opt/flowforge-device.
. Then run the following command

flowforge-device-agent

, and you will see that the device has been linked to the FF platform.

If you are using a provisioning certificate, you also need to copy the provisioning certificate todevice.ymlin the file. Then run the same command as above.
After the provisioning certificate is used, it cannot be used again and will be overwritten by a new device certificate.

Run

when npmjs.org is unreachable. By default, the device agent will attempt to download the correct version of Node-RED and any nodes required to run the project snapshot assigned on the device.

If the device is running on an offline network, or if security policies prevent the device agent from connecting to npmjs.org, it can be configured to use a pre-cached module set.

You can enable this mode by adding a command line option to the file. This will cause the device agent to load modules from a directory in the device agent configuration directory, as described above. By default, this will be for .-mmoduleCache: truedevice.ymlmodule_cache/opt/flowforge-device/module_cache

Create a module cache

To create a suitable module cache, you need to install on the local device. Access npmjs.org, ensure you are using the same operating system and architecture as the target device, and then copy the module to the device.

On the "Project Snapshot" page, select the snapshot you want to deploy, and then choose the option to download its files.package.json

Place this file in an empty directory on the local device.

Run npm install to install the module. This will create a directory.node_modules

On the target device, create a directory called in the device agent configuration directory.module_cache

Copy the directory from the local device to the target device, ensuring it is located under the specified directory. node_modulesmodule_cache

Related Tags
Put this resource to use in a real project?

Go to the Tool Center for message parsing, CRC verification and device debugging, or submit your requirements for selection and integration advice.

Engineer Membership

Turn this article into actionable debugging resources

After activation, you can use advanced message parsing, resource pack downloads, code examples, engineering cases and priority technical support, suitable for real project delivery.

Unlimited Advanced Tools
Resource & Code Packs
Complete Engineering Case Library
Priority Technical Support

Leave a Reply

Your email address will not be published. Required fields are marked *.