Inhaltsverzeichnis
< Alle Themen

Setting up a development environment

In this chapter we discuss the installation and configuration of some useful tools which help us developing, maintaining and troubleshooting the Natrix Gateway.

Eclipse IDE

The primary use of the Eclipse IDE is to develop java-based software code and artifacts. Beside the pure development IDE, we also leverage some important plugins which are available for Eclipse and which will  ease our (development) life tremendously. These are primarily

  • Maven build tool for launching maven builds and managing dependencies in own projects (already built in)
  • Egit GIT integration for the support of the GIT distributed versioning system (already built in)
  • mToolkit for remote connectivity to the Eclipse Kura™ OSGI platform.
  • Eclipse PDE (Plug-in Development Environment) for developing Eclipse Plug-ins

Installing Eclipse IDE

While Eclipse only requires Java to run it is compatible with both Widows-,Linux- and Apple based systems. In our example we use Windows on our development machine.

The easiest way to install Eclipse is via the Eclipse (Oomph) Installer. (Eclipse IDE(2), 2021)

The oomph installer gives you the option to select from various different IDEs depending on somebodies need. For us it is the IDE for Java developers which we need to develop our value adding IoT services.

Define which (preinstalled) JVM you want to use to run Eclipse on and to compile your code. Furthermore, define a directory where you would like to have your Eclipse Ide installed to.

For the sake of clarity, especially if you have multiple IDEs up and running on your system, we prefer adding the workspace (directory) right beneath our Eclipse IDE installation folder.

Installing mToolkit

mToolkit from ProSyst Software extends the Eclipse IDE with the necessary tools for easier adoption of the OSGi technology. It provides the developers with remote management capabilities of OSGi containers (currently Equinox and ProSyst’s mBedded Server are supported). From within the Eclipse IDE the developer can execute bundle operations like installing bundles on a remote OSGi container. Additionally, mToolkit enables access to the OSGi service registry in order to validate the bundle’s service dependencies and registrations. mToolkit requires an ESF-enabled target device to operate with.

ESF stands for Everyware Software Framework and is provided by Eurotech. The enterprise-ready IoT Edge Framework Everyware Software Framework (ESF) is a high-level, multi-platform, and flexible application development environment for Edge Computers and IoT Gateways. ESF connects and interfaces with field devices thanks to its ready-to-use field protocol libraries. Field data can be processed at the edge through rich Java APIs or a web-based visual programming environment. (Eurotech(1), 2021)

The Eclipse Kura™ OSGI platform comes with ESF support out of the box.

To install the mToolkit, we have to go to [Help]->[Install New Software] and provide the following link in the [Work with] textbox: http://mtoolkit-mars.s3-website-us-east-1.amazonaws.com to add a new software repository to our Eclipse IDE under the name ‘mToolkit’.

Eclipse IDE searches for packages to install which we select.

Once the installation has been finished, and we restart the Eclipse IDE, we can check a successful installation under [Windows]->[Preferences]

Installing Eclipse PDE (Plug-in development environment

The Plug-in Development Environment (PDE) provides tools to create, develop, test, debug, build and deploy Eclipse plug-ins, fragments, features, update sites and RCP products. PDE also provides comprehensive OSGi tooling, which makes it an ideal environment for component programming, not just Eclipse plug-in development. (Eclipse IDE(3), 2021)

To install the Eclipse PDE, we ideally navigate to the [Help]->[Eclipse Marketplace] and search for a term which contains ‘PDE’. This way we will find the Eclipse PDE software which we can install directly from there.

Checking EGIT

Egit comes out of the box with this release of Eclipse IDE. It provides a dedicated view which we can launch by open a new perspective:

Once we launched the new perspective, we can see the main capabilities of EGIT to work with internal and external GIT repositories. This is the starting point of many of our Maker projects where we simply import existing projects into the Eclipse IDE workbench.

Checking Maven

Like EGIT, also Maven comes out of the box with this release of the Eclipse IDE. We see under [Windows]->[Preferences] all Maven specific configuration options, such as the predefined common Maven Archetype catalogs.

PiShrink – Managing Natrix Gateway image backups

PiShrink vents Rasp Pi images for a space-saving backup and automatically adjusts the partition size when restoring them. Just as you copy an image file to the SD memory card of a Raspberry Pi, you also back up a Raspberry Pi system that is in use as an image. The dd command is used for this under Linux. But there is a problem here: The image file is just as big as the memory card, even if it only contains free space besides the operating system. The empty sectors move into the image as it were. If you then restore the image, the new memory card must consistently offer at least as much space as the old one. In addition, the archived image occupies more space than necessary.

PiShrink is a small Linux program that does exactly this job. The tool grabs a Rasp Pi image and reduces the partition size to the absolutely necessary minimum. Even better: PiShrink also installs a script in the archived system that expands the partition to the maximum storage space the next time the system is booted on a Rasp Pi. In this way, the image of a Raspbian system shrinks from several gigabytes to a few hundred megabytes without you having to go to great lengths. When the compressed system is restored, the automatic expansion saves work again.

Installation of PiShrink

Since PiShrink is a simple bash script, installing the program is not particularly difficult: you download the script from the network and then set the rights accordingly.

mkdir /opt/pishrink
chmod +x ~/opt/pishrink.sh
cd /opt/pishrink
/opt/pishrink# wget https://raw.githubusercontent.com/Drewsif/PiShrink/master/pishrink.sh
--2021-09-30 21:23:39--  https://raw.githubusercontent.com/Drewsif/PiShrink/master/pishrink.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.110.133, 185.199.108.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10904 (11K) [text/plain]
Saving to: ‘pishrink.sh’

pishrink.sh              100%[================================]  10,65K  --.-KB/s    in 0,002s

2021-09-30 21:23:40 (4,24 MB/s) – ‘pishrink.sh’ saved [10904/10904]

Processing PiShrink

The script is fairly easy to execute. Presuming we have copied the image which we want to shrink (NatrixGateway1.0_22092021.img)into the /opt/pishrink folder, and we want to have a separate file which contains the shrinked image (NatrixGateway1.0_22092021_shrinked.img), then we can call the pishrink.sh script the following way:

/opt/pishrink# ./pishrink.sh  -s NatrixGateway1.0_22092021.img  NatrixGateway1.0_22092021_shrinked.img
pishrink.sh v0.1.2
pishrink.sh: Copying NatrixGateway1.0_22092021.img to NatrixGateway1.0_22092021_shrinked.img... ...
pishrink.sh: Gathering data ...
Skipping autoexpanding process...
pishrink.sh: Checking filesystem ...
rootfs: 117493/3740352 files (0.3% non-contiguous), 1176519/15117056 blocks
resize2fs 1.44.1 (24-Mar-2018)
pishrink.sh: Shrinking filesystem ...
resize2fs 1.44.1 (24-Mar-2018)
Resizing the filesystem on /dev/loop26 to 1022484 (4k) blocks.
Begin pass 2 (max = 13676)
Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 462)
Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 4 (max = 9518)
Updating inode references     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/loop26 is now 1022484 (4k) blocks long.

Pishrink.sh: Shrinking image ...
pishrink.sh: Shrunk NatrixGateway1.0_22092021_shrinked.img from 58G to 4.2G ...

MQTT.fx – Graphic tool for MQTT debugging

There are numerous tools for testing and debugging MQTT communication. The MQTT.fx tool, which is based on JavaFX and Eclipse Paho, is one of them. (MQTTfx(1), 2021)

Since 2021, MQTT.fx had been taken over by the company SOFTBLADE. From version MQTT.fx 5.0 this tool doesn’t seem to be open-source respectively free of charge any longer.

So far, MQTT.fx has provided the following functions:

  • Connection profiles for broker connections
  • Ad hoc connections
  • Security (username / password, support for SSL / TLS)
  • Publish and subscribe with full support of wildcard patterns and topic history.
  • Storage for predefined messages
  • Nashorn Engine Scripts: Interface for scripted „publish“ and „subscribe“
  • Evaluation of $ SYS topics (mosquitto and HiveMQ)
  • Logging console
  • Proxy support
  • Native installation packages for all platforms
  • Regular updates / bug fixes
  • Check for available updates when starting the app
  • „Free as free beer“ (not yet open source)

The main window provides functions for selecting a connection profile as well as connect and dispatcher buttons in the upper area. For the individual use cases there are tabs that can be dragged and dropped from the main window into separate windows. This z. B. a „Publish“ window can be placed next to a „Subscribe“ window. If such a window is closed, the tab returns to its original position.

Example message debugging with Mosquitto-broker

In this example we want to connect to the Mosquitto-Broker which we run on our Natrix Gateway. For this, we generate a separate profile and connect MQTT.fx with our Broker:

Now subscribe for a topic (“/test/topic”)…..

… and let’s publish a message to this topic.

Example message debugging with Eclipse Kapua™ MQTT Broker

The ‘payload’ of a message to be published to a Broker such as Mosquitto is quite simple. This is not for all MQTT-Brokers the same. They request the ‘payload’ formatted in a specific way, e.g. in a JSON format or others.

The Eclipse Kapua™ MQTT Broker is such a Broker which expects payload messages formatted in a specific way.

We create a new MQTT.fx profile where we configure our Eclipse Kapua™ Broker which is basically the IP-address of our Eclipse Kapua™ installation and port 1883. We give our client a unique and identifiable name and login to the Derry-Hospital account with the user which created and assigned to this account (Physician-1).