Kura provides a set of services that runs on the Equinox OSGi framework for the IoT (Internet of Things) . With Reactive Blocks, you can develop OSGi bundles using Kura as described in this article.
If you have used Reactive Blocks for Kura feature before, you simply need to update. Do the following steps: (Error markings during the update prosess are OK)
If you have developed OSGi applications with Reactive Blocks before, you may need to rebuild them.
To install the Reactive Blocks for Kura feature, do the following steps:
mToolkit is an Eclipse plugin that enables creation of deployment package and connection to a Kura-enabled target device.
This plugin can be install from its update site:
In order to create a bundle for the Kura framework, you need to change the target platform in your Eclipse workspace to include bundles for Kura and Reactive Blocks libraries. It is advisable to first switch to a new workspace.
Before making an OSGi bundle for Kura framework, we first create a Reactive Blocks plug-in project.
If you choose application block with configuration option, you will get, in addition, a ‘metatype’ file for describing the configuration properties for your bundle. This file contains examples that you can modify.
Note that a Plug-in project must contain maximal one application block.
Depending on your application, you might need to import packages from other bundles, like californium for CoAP. Read About Dependency section to see how to add a bundle as project dependency.
You can also choose Select Build Target Platfrom… and then Java OSGi Bundle for Eclipse Kura in the Platform selection dialog to change build parameters.
When the build process is completed, you should see a new source folder gen containing generated code from your application and also the corresponding component definition component.xml in the folder OSGI-INF
Depending on your application, the generated code may also need dependency to other packages or bundles. Read About Dependency section to see how to add a bundle as project dependency.
Kura provides an emulator so that you can start Kura and your application in Eclipse. This emulator runs locally on your computer and currently supports OS X and Linux only.
You can also run your application on a remote target device, like Raspberry Pi.
A launch configuration to run Kura with Reactive Blocks libraries from within Eclipse is already provided.
You should see that Kura is running from the Console view. Your application is automatically run on the emulator.
There are many ways to deploy a bundle on Kura. Here, we will use deployment packages and Kura’s web console.
Make a deployment package from your application as follows:
To deploy the package on Kura, follow these steps:
If you add logging messages in your application, the messages are shown in Kura log file. In a Raspberry Pi, the file is located in
/var/log/kura.log. So, use the command
tail -f /var/log/kura.log to follow messages in the log file.
You can also change which log level you want to see. See here.
One way to find out whether your application bundle is running is to put a log (info level) message at the start of your application, i.e., after an initial node ().
If you don’t see the log message in the Kura log, chances are your application is not started due to missing dependencies. That is, additional bundle(s) must be installed in the OSGi framework you are using.
If you use the local emulation mode, see here.
If you run your application on a remote target device, find out the status of your bundle:
telnet localhost 5002
diag <bundle-id>as shown in the following figure
The figure above shows that bundle br.mqtt.sender (bundle id 95) has unresolved constraints. You need to solve the leaf constraints first, i.e., bunde com.bitreactive.library.mqtt (bundle id 90) needs other bundle(s) that export packages (org.eclipse.paho.client.mqttv3 and org.eclipse.paho.client.mqttv3.persist)
To solve this problem, you need to find a bundle that exports package org.eclipse.paho.client.mqttv3 and basically install the bundle in the OSGi framework.