Inhaltsverzeichnis
< Alle Themen

PulseSensor – Eclipse Kura configuration

Eclipse Kura

This sub-chapter is about how to configure our Eclipse Kura™ framework to connect with both the Eclipse Kapua™ platform as well as with the openHAB3 Broker.

Configuring the Cloud connection to the Eclipse Kapua™ platform

An important task is to connect our Eclipse Kura™ framework with the Eclipse Kapua™ platform. There are three entities to configure. The CloudService as such the DataService and the MQTTDataTransport Service.

Configuring the CloudService

Configuring the CloudService

For configuring the CloudService, we go to [Cloud Connections] and select the [CloudService] tab.

AttributeValueNote
Device Display-Namecustomallows for own name
Device Custom-NameNatrix-Gateway-PulseSensor-Maker-Project 
Topic Control-Prefix$EDCDefault value
Encode gziptrueDefault value
Republish Mqtt Birth Cert On Gps LockfalseDefault value
Republish Mqtt Birth Cert On Modem DetectfalseDefault value
Enable Default SubscriptionstrueDefault value
Birth Cert PolicyPublish birth on connect and reconnectDefault value
Payload EncodingKura ProtobufDefault value

Push the configuration by [Apply] the configuration changes.

Configuring the DataService

For configuring the DataService, we go to [Cloud Connections] and select the [DataService] tab.

AttributeValueNote
Connect Auto-on-startuptrue 
Connect Retry-interval60Default value
Enable Recovery On Connection FailurefalseDefault value
Connection Recovery Max Failures10Default value
Disconnect Quiesce-timeout10Default value
Store DB Service PIDorg.eclipse.kura.db.H2DbServiceDefault value
Store Housekeeper-intervaltrueDefault value
Store Housekeeper-interval900Default value
Store Purge-age60Default value
Store Capacity1000Default value
In-flight-messages Republish-on-new-sessionTrueDefault value
In-flight-messages Max-number9Default value
In-flight-messages Congestion-timeout0Default value
Enable Rate LimittrueDefault value
Rate Limit Average1Default value
Rate Limit Time UnitSecondsDefault value
Rate Limit Burst Size1Default value

Push the configuration by [Apply] the configuration changes.

Configuring the MQTTDataTransport Service

For configuring the MQTTDataTransport Service, we go to [Cloud Connections] and select the [MQTTDataTransport] tab.

AttributeValueNote
Broker-urlmqtt://[Eclipse-Kapua-Server]:1883/This is our Eclipse Kapua server on port 1883
Topic Context Account-NameDerry-HospitalCreating a new Child Account
UsernamePhysician-1Creating a new User and assign it to the new account
Password<<your password here >>Creating a new User and assign it to the new account
Client-IDNatrix-Gateway-PulseSensor-Maker-ProjectLet’s use the custom name for it
Keep-Alive30Default value
Timeout20Default value
Clean-sessiontrueDefault value
LWT Topic$EDC/#account-name/#client-id/MQTT/LWTDefault value
LWT Payload Default value
LWT Qos0Default value
LWT RetaintrueDefault value
In-flight PersistenceMemoryDefault value
Protocol-version3.1.1Default value
SSL Default Protocol1Default value
SSL Hostname VerificationRely on SSL Manager Service configurationDefault value
SSL Default Cipher Suites Default value
SSL Certificate Alias Default value

Push the configuration by [Apply] the configuration changes.

Checking connectivity status to Eclipse Kapua™ platform

We have to places where we can check the successful connection status between Eclipse Kura™ and Eclipse Kapua™.

After applying all configuration parameters in Eclipse Kura™, the connection status is displayed at the top of the configuration page:

In Eclipse Kapua™ we see our Natrix Gateway connected under the Client-ID as configured (Natrix-Gateway-PulseSensor-Maker-Project) and with the user Physician-1.

Adding a Publisher and Subscriber Service for the PulseSensor project

Because we publish our PulseSensor Telemetry data to Eclipse Kapua™, we need to configure a Publisher Service in Eclipse Kura™. Although we don’t need a Subscription service yet in our project, for the sake of completeness we also add a Subscriber Service.

We go to [Cloud Connections]->[New Pub/Sub] , select the factory org.eclipse.kura.cloud.publisher.CloudPublisher  add a Publisher Service with the name ‘KuraPublisher’.

Same we do with the Subscriber Service, adding a Service ‘KuraSubscriber’ and assign it to the factory org.eclipse.kura.cloud.subscriber.CloudSubscriber.

Adding a Publisher and Subscriber Service for the PulseSensor project
Deploying the PulseSensor Deployment Package

Most of the configuration is done using the configuration settings of our PulseSensor project. So, the first step is to deploy the PulseSensor Deployment Package to the Eclipse Kura™ framework.

The PulseSensor Deployment Package is available for download from the Natrix Project GitHub account. (NatrixProject(1), 2021)

We need to download the ‘PulseSensorMQTT.dp’ file to your local PC.

Once we have done this, let’s open the Eclipse Kura™ Administration pages under http://[ip-address-of our-gateway]:80.

Navigate to [Packages]->[Install/Upgrade]

and choose the ‘PulseSensorMQTT.dp’ file from the location on your PC where you downloaded it.

Push [Submit] and we will see that the package has been successfully deployed into the Eclipse Kura™ framework.

Configuring the PulseSensor Plug-in

After the deployment of the package, the PulseSensorMQTT plug-in (bundle) appears in the active bundle list. With a click on it, the configuration section of the PulseSensor bundle opens on the right-hand site of the Administration page.

The following parameters need to be configured for the attributes provided by the PulseSensor bundle:

AttributeValueNote
BPM Multiplying factor1Disables value manipulation
CloudPublisher Target Filter(kura.service.pid=KuraPublisher)Available as target
CloudSubscriber Target Filter(kura.service.pid=KuraSubscriber)Available as target
Data Collection (true/false)true 
MQTT Publishing (true/false)true 
MQTT Publishing to 3rd party broker (true/false)true 
Serial Interface/dev/ttyACM0Arduino-Natrix-Gateway serial connection
Time out [ms]2000 
Sampling rate [ms]10000 
baud rate [Bytes/s]115200 
3rd Party MQTT Brokertcp://127.0.0.1:1883Local Mosquitto Broker
MQTT topic Publishcmnd/pulsesensor/Alarmsee here
MQTT topic Subscribestat/pulsesensor/Alarmsee here
MQTT topic for metrics Publish/topic/pulsesensor/metrics 
MQTT topic for metrics Subscribe/topic/pulsesensor/metrics 
MQTT payload for Alarm=’ON‘OFFPayload when sending Alarm=on
MQTT payload for Alarm=’OFF‘ONPayload when sending Alarm=off
Setting alarm for min.BPM [beats/minute]40Low threshold for Pulse alarm
Setting alarm for max. BPM [beats/minute]120High threshold for Pulse alarm
Setting filter for BPM false measures [beats/minute]180Everything above =false measure
Setting filter for InterBeatIntervall false measures [ms]1200Everything above =false measure
Setting filter for Sample Rate false measures [mV]1000Everything above =false measure
gpio.service.pidorg.eclipse.kura.gpio.GPIOService 
gpio.input.read.modePIN_STATUS_LISTENER 
gpio.pinsGPIO_GEN4,GPIO_GEN5The two Pins of our project
gpio.directionsBoth, init output 
gpio.modesDefault 
gpio.triggersDefault 

Push the configuration by [Apply] the configuration changes.

If everything works smoothly, we see our first data arriving in Eclipse Kapua™ when connecting the PulseSensor to our fingertips.

Changing the Eclipse Kura™ log-parameters

As we want to have all PulseSensor Project related logfiles separated from the standard Kura log-files, we need to adjust the log4j.xml file in the directory /opt/eclipse/kura/user.

We have a dedicated logger for each module of the PulseSensor Project -> PulseSensorMQTT, SerialInterface, openHABMQTT and GPIOComponent. For each new logger we also require a dedicated Appender (RollingFileAppender).

nano /opt/eclipse/kura/user/log4j.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
#
# Copyright (c) 2018, 2019 Eurotech and/or its affiliates
#
#  All rights reserved. This program and the accompanying materials
#  are made available under the terms of the Eclipse Public License v1.0
#  which accompanies this distribution, and is available at
#  http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
#   Eurotech
#
-->
<Configuration status="warn" strict="true" name="KuraConfig" monitorInterval="30">

    <Properties>
        <Property name="filename">/var/log/kura/kura</Property>
    </Properties>
    <Filter type="ThresholdFilter" level="trace"/>
 
    <Appenders>
        <RollingFile name="RollingFile" fileName="${filename}.log" filePattern="${filename}-%d{MM-dd-yy-HH-mm-ss}-%i.log.gz">
            <PatternLayout>
                <Pattern>%d{ISO8601} [%t] %-5p %c{1.} - %m%n%throwable{full}</Pattern>
            </PatternLayout>
            <Policies>
                <SizeBasedTriggeringPolicy size="20 MB"/>
            </Policies>
            <DefaultRolloverStrategy max="10"/>
        </RollingFile>
        <RollingFile name="PulseSensorMQTT" fileName="/var/log/kura/PulseSensorMQTT.log" filePattern="/var/log/kura/PulseSensorMQTT-%d{MM-dd-yy-HH-mm-ss}-%i.log.gz">
            <PatternLayout>
                <Pattern>%d{ISO8601} [%t] %-5p %c{1.} - %m%n%throwable{full}</Pattern>
            </PatternLayout>
            <Policies>
                <SizeBasedTriggeringPolicy size="20 MB"/>
            </Policies>
            <DefaultRolloverStrategy max="10"/>
        </RollingFile>
        <RollingFile name="SerialInterface" fileName="/var/log/kura/SerialInterface.log" filePattern="/var/log/kura/SerialInterface-%d{MM-dd-yy-HH-mm-ss}-%i.log.gz">
            <PatternLayout>
                <Pattern>%d{ISO8601} [%t] %-5p %c{1.} - %m%n%throwable{full}</Pattern>
            </PatternLayout>
            <Policies>
                <SizeBasedTriggeringPolicy size="20 MB"/>
            </Policies>
            <DefaultRolloverStrategy max="10"/>
        </RollingFile>
        <RollingFile name="ThirdPartyBroker" fileName="/var/log/kura/ThirdPartyBroker.log" filePattern="/var/log/kura/ThirdPartyBroker-%d{MM-dd-yy-HH-mm-ss}-%i.log.gz">
            <PatternLayout>
                <Pattern>%d{ISO8601} [%t] %-5p %c{1.} - %m%n%throwable{full}</Pattern>
            </PatternLayout>
            <Policies>
                <SizeBasedTriggeringPolicy size="20 MB"/>
            </Policies>
            <DefaultRolloverStrategy max="10"/>
        </RollingFile>
        <RollingFile name="GpioComponent" fileName="/var/log/kura/GpioOperations.log" filePattern="/var/log/kura/GpioOperations-%d{MM-dd-yy-HH-mm-ss}-%i.log.gz">
            <PatternLayout>
                <Pattern>%d{ISO8601} [%t] %-5p %c{1.} - %m%n%throwable{full}</Pattern>
            </PatternLayout>
            <Policies>
                <SizeBasedTriggeringPolicy size="20 MB"/>
            </Policies>
            <DefaultRolloverStrategy max="10"/>
        </RollingFile>
		
    </Appenders>
 
    <Loggers>
        <Logger name="org.eclipse" level="info" additivity="false">
            <AppenderRef ref="RollingFile"/>
        </Logger>
 
        <Root level="warn">
            <AppenderRef ref="RollingFile"/>
        </Root>
	<Logger name="de.natrix.kura.pulsemqtt.SerialInterface" level="info" additivity="false">
            <AppenderRef ref="SerialInterface"/>
        </Logger>
        <Logger name="de.natrix.kura.pulsemqtt.PulseSensorMQTT" level="info" additivity="false">
            <AppenderRef ref="PulseSensorMQTT"/>
        </Logger>
        <Logger name="de.natrix.kura.pulsemqtt.ThirdPartyBrokerMQTT" level="info" additivity="false">
            <AppenderRef ref="ThirdPartyBroker"/>
        </Logger>
        <Logger name="de.natrix.kura.pulsemqtt.GpioOperations" level="info" additivity="false">
            <AppenderRef ref="GpioComponent"/>
        </Logger>	
  </Loggers>
 
</Configuration>