Skip to content

Commit

Permalink
feat: modemManager based position provider (#5471)
Browse files Browse the repository at this point in the history
* feat: provider skeleton

Signed-off-by: SimoneFiorani <[email protected]>

* feat: first working implementation of provider

Signed-off-by: SimoneFiorani <[email protected]>

* feat: missing copyright

Signed-off-by: SimoneFiorani <[email protected]>

* fix: fixed nm manifest import version

Signed-off-by: SimoneFiorani <[email protected]>

* refactor: refactor of entire architecture

Signed-off-by: SimoneFiorani <[email protected]>

* feat: added nmea parser and raw location

Signed-off-by: SimoneFiorani <[email protected]>

* feat: missing copyright and addition

Signed-off-by: SimoneFiorani <[email protected]>

* Update MMPositionProviderTest.java

* fix: backup to avoid missing parts

Signed-off-by: SimoneFiorani <[email protected]>

* feat: added nmea position and raw utc-time

Signed-off-by: SimoneFiorani <[email protected]>

* refactor: pr suggestion

Signed-off-by: SimoneFiorani <[email protected]>

* refactor: mm position provider

Signed-off-by: SimoneFiorani <[email protected]>

* fix: fixed test import on linux position

Signed-off-by: SimoneFiorani <[email protected]>

* fix: missing copyright

Signed-off-by: SimoneFiorani <[email protected]>

* fix: fixed web ui problem

Signed-off-by: SimoneFiorani <[email protected]>

---------

Signed-off-by: SimoneFiorani <[email protected]>
  • Loading branch information
sfiorani authored Nov 4, 2024
1 parent 11218d4 commit e20efa6
Show file tree
Hide file tree
Showing 34 changed files with 862 additions and 97 deletions.
2 changes: 2 additions & 0 deletions kura/org.eclipse.kura.linux.position/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ Import-Package: de.taimos.gpsd4java.api;version="[1.0,2.0)",
org.osgi.util.measurement;version="1.0.1",
org.osgi.util.position;version="1.0.1",
org.slf4j;version="1.6.4"
Export-Package: org.eclipse.kura.linux.position.options;version="1.0.0";x-internal:=true,
org.eclipse.kura.linux.position.provider;version="1.0.0";x-internal:=true
8 changes: 4 additions & 4 deletions kura/org.eclipse.kura.linux.position/OSGI-INF/gpsTracker.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2018, 2020 Eurotech and/or its affiliates and others
Copyright (c) 2018, 2024 Eurotech and/or its affiliates and others
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
Expand All @@ -14,12 +14,12 @@
-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" enabled="true" immediate="false" name="GpsDeviceTracker">
<implementation class="org.eclipse.kura.linux.position.GpsDeviceTracker"/>
<implementation class="org.eclipse.kura.linux.position.serial.GpsDeviceTracker"/>
<service>
<provide interface="org.osgi.service.event.EventHandler"/>
<provide interface="org.eclipse.kura.linux.position.GpsDeviceTracker"/>
<provide interface="org.eclipse.kura.linux.position.serial.GpsDeviceTracker"/>
</service>
<property name="service.pid" value="org.eclipse.kura.linux.position.GpsDeviceTracker"/>
<property name="service.pid" value="org.eclipse.kura.linux.position.serial.GpsDeviceTracker"/>
<property name="event.topics" type="String">org/eclipse/kura/usb/NetworkEvent/device/ADDED
org/eclipse/kura/usb/NetworkEvent/device/REMOVED
</property>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2022 Eurotech and/or its affiliates and others
Copyright (c) 2024 Eurotech and/or its affiliates and others
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
Expand All @@ -14,11 +14,11 @@
-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" enabled="true" immediate="false" name="GpsdPositionProvider">
<implementation class="org.eclipse.kura.linux.position.GpsdPositionProvider"/>
<implementation class="org.eclipse.kura.linux.position.gpsd.GpsdPositionProvider"/>
<service>
<provide interface="org.eclipse.kura.linux.position.PositionProvider"/>
<provide interface="org.eclipse.kura.linux.position.GpsdPositionProvider" />
<provide interface="org.eclipse.kura.linux.position.provider.PositionProvider"/>
<provide interface="org.eclipse.kura.linux.position.gpsd.GpsdPositionProvider" />
</service>

<property name="service.pid" value="org.eclipse.kura.linux.position.GpsdPositionProvider"/>
<property name="service.pid" value="org.eclipse.kura.linux.position.gpsd.GpsdPositionProvider"/>
</scr:component>
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,20 @@

<Option label="serial" value="serial" />
<Option label="gpsd" value="gpsd" />
<Option label="modemManager" value="modemManager" />

</AD>

<AD id="modem.manager.refresh.rate.seconds"
name="modem.manager.refresh.rate.seconds"
type="Integer"
cardinality="0"
required="true"
default="30"
min="0"
description="Refresh time in seconds at which the position is updated when using the Modem Manager Position Provider">
</AD>

<AD id="gpsd.host"
name="gpsd.host"
type="String"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2018, 2020 Eurotech and/or its affiliates and others
Copyright (c) 2018, 2024 Eurotech and/or its affiliates and others
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
Expand All @@ -14,12 +14,12 @@
-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" enabled="true" immediate="false" name="ModemGpsStatusTracker">
<implementation class="org.eclipse.kura.linux.position.ModemGpsStatusTracker"/>
<implementation class="org.eclipse.kura.linux.position.serial.ModemGpsStatusTracker"/>
<service>
<provide interface="org.osgi.service.event.EventHandler"/>
<provide interface="org.eclipse.kura.linux.position.ModemGpsStatusTracker"/>
<provide interface="org.eclipse.kura.linux.position.serial.ModemGpsStatusTracker"/>
</service>
<property name="service.pid" value="org.eclipse.kura.linux.position.ModemGpsStatusTracker"/>
<property name="service.pid" value="org.eclipse.kura.linux.position.serial.ModemGpsStatusTracker"/>
<property name="event.topics" type="String">org/eclipse/kura/net/modem/gps/ENABLED
org/eclipse/kura/net/modem/gps/DISABLED
</property>
Expand Down
6 changes: 3 additions & 3 deletions kura/org.eclipse.kura.linux.position/OSGI-INF/position.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2011, 2020 Eurotech and/or its affiliates and others
Copyright (c) 2011, 2024 Eurotech and/or its affiliates and others
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
Expand All @@ -13,14 +13,14 @@
Eurotech
-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" configuration-policy="require" deactivate="deactivate" enabled="true" immediate="true" modified="updated" name="org.eclipse.kura.position.PositionService">
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.2.0" activate="activate" configuration-policy="require" deactivate="deactivate" enabled="true" immediate="true" modified="updated" name="org.eclipse.kura.position.PositionService">
<implementation class="org.eclipse.kura.linux.position.PositionServiceImpl"/>
<service>
<provide interface="org.eclipse.kura.position.PositionService"/>
<provide interface="org.eclipse.kura.configuration.ConfigurableComponent"/>
</service>

<reference bind="setPositionProviders" cardinality="1..n" interface="org.eclipse.kura.linux.position.PositionProvider" name="PositionProviders" policy="static" unbind="unsetPositionProviders"/>
<reference bind="setPositionProviders" cardinality="1..n" interface="org.eclipse.kura.linux.position.provider.PositionProvider" name="PositionProviders" policy-option="greedy" policy="static" unbind="unsetPositionProviders"/>

<property name="service.pid" value="org.eclipse.kura.position.PositionService"/>
<reference bind="setEventAdmin" cardinality="1..1" interface="org.osgi.service.event.EventAdmin" name="EventAdmin" policy="static" unbind="unsetEventAdmin"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2022 Eurotech and/or its affiliates and others
Copyright (c) 2024 Eurotech and/or its affiliates and others
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
Expand All @@ -14,14 +14,14 @@
-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" enabled="true" immediate="false" name="SerialDevicePositionProvider">
<implementation class="org.eclipse.kura.linux.position.SerialDevicePositionProvider"/>
<implementation class="org.eclipse.kura.linux.position.serial.SerialDevicePositionProvider"/>
<service>
<provide interface="org.eclipse.kura.linux.position.PositionProvider"/>
<provide interface="org.eclipse.kura.linux.position.SerialDevicePositionProvider" />
<provide interface="org.eclipse.kura.linux.position.provider.PositionProvider"/>
<provide interface="org.eclipse.kura.linux.position.serial.SerialDevicePositionProvider" />
</service>
<property name="service.pid" value="org.eclipse.kura.linux.position.SerialDevicePositionProvider"/>
<reference bind="setModemGpsStatusTracker" cardinality="1..1" interface="org.eclipse.kura.linux.position.ModemGpsStatusTracker" name="ModemGpsStatusTracker" policy="static" unbind="unsetModemGpsStatusTracker"/>
<reference bind="setGpsDeviceTracker" cardinality="1..1" interface="org.eclipse.kura.linux.position.GpsDeviceTracker" name="GpsDeviceTracker" policy="static" unbind="unsetGpsDeviceTracker"/>
<property name="service.pid" value="org.eclipse.kura.linux.position.serial.SerialDevicePositionProvider"/>
<reference bind="setModemGpsStatusTracker" cardinality="1..1" interface="org.eclipse.kura.linux.position.serial.ModemGpsStatusTracker" name="ModemGpsStatusTracker" policy="static" unbind="unsetModemGpsStatusTracker"/>
<reference bind="setGpsDeviceTracker" cardinality="1..1" interface="org.eclipse.kura.linux.position.serial.GpsDeviceTracker" name="GpsDeviceTracker" policy="static" unbind="unsetGpsDeviceTracker"/>
<reference bind="setConnectionFactory" cardinality="1..1" interface="org.osgi.service.io.ConnectionFactory" name="ConnectionFactory" policy="static" unbind="unsetConnectionFactory"/>
</scr:component>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
import org.eclipse.kura.KuraErrorCode;
import org.eclipse.kura.KuraException;
import org.eclipse.kura.configuration.ConfigurableComponent;
import org.eclipse.kura.linux.position.options.PositionServiceOptions;
import org.eclipse.kura.linux.position.provider.GpsDeviceAvailabilityListener;
import org.eclipse.kura.linux.position.provider.LockStatusListener;
import org.eclipse.kura.linux.position.provider.PositionProvider;
import org.eclipse.kura.position.GNSSType;
import org.eclipse.kura.position.NmeaPosition;
import org.eclipse.kura.position.PositionListener;
Expand All @@ -41,7 +45,7 @@
import org.slf4j.LoggerFactory;

public class PositionServiceImpl
implements PositionService, ConfigurableComponent, GpsDeviceAvailabilityListener, GpsDevice.Listener {
implements PositionService, ConfigurableComponent, GpsDeviceAvailabilityListener, LockStatusListener {

private static final Logger logger = LoggerFactory.getLogger(PositionServiceImpl.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Contributors:
* Eurotech
*******************************************************************************/
package org.eclipse.kura.linux.position;
package org.eclipse.kura.linux.position.gpsd;

import static java.lang.Math.toRadians;

Expand All @@ -29,7 +29,11 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

import org.eclipse.kura.linux.position.GpsDevice.Listener;
import org.eclipse.kura.linux.position.options.PositionServiceOptions;
import org.eclipse.kura.linux.position.provider.GpsDeviceAvailabilityListener;
import org.eclipse.kura.linux.position.provider.LockStatusListener;
import org.eclipse.kura.linux.position.provider.PositionProvider;
import org.eclipse.kura.linux.position.provider.PositionProviderType;
import org.eclipse.kura.position.GNSSType;
import org.eclipse.kura.position.NmeaPosition;
import org.osgi.util.measurement.Measurement;
Expand Down Expand Up @@ -59,7 +63,7 @@ public class GpsdPositionProvider implements PositionProvider, IObjectListener {
private GPSdEndpoint gpsEndpoint;
private PositionServiceOptions configuration;

private Listener gpsDeviceListener;
private LockStatusListener gpsDeviceListener;
private ScheduledExecutorService executor;
private Future<?> checkFuture = CompletableFuture.completedFuture(null);

Expand Down Expand Up @@ -148,7 +152,7 @@ public String getLastSentence() {
}

@Override
public void init(PositionServiceOptions configuration, Listener gpsDeviceListener,
public void init(PositionServiceOptions configuration, LockStatusListener gpsDeviceListener,
GpsDeviceAvailabilityListener gpsDeviceAvailabilityListener) {
stop();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
* Eurotech
*******************************************************************************/

package org.eclipse.kura.linux.position;
package org.eclipse.kura.linux.position.options;

import java.util.HashMap;
import java.util.Map;
import java.util.OptionalInt;

import org.eclipse.kura.comm.CommURI;
import org.eclipse.kura.linux.position.provider.PositionProviderType;

public class PositionServiceOptions {

Expand All @@ -38,6 +39,7 @@ public class PositionServiceOptions {
private static final Property<Integer> GPSD_PORT = new Property<>("gpsd.port", 2947);
private static final Property<Integer> GPSD_MAX_FIX_VALIDITY_INTERVAL = new Property<>(
"gpsd.max.fix.validity.interval.seconds", 60);
private static final Property<Integer> MM_REFRESH_RATE = new Property<>("modem.manager.refresh.rate.seconds", 30);

private final Map<String, Object> properties;

Expand Down Expand Up @@ -110,6 +112,10 @@ public OptionalInt getGpsdMaxValidityInterval() {
}
}

public int getModemManagerRefreshRate() {
return MM_REFRESH_RATE.get(this.properties);
}

public CommURI getGpsDeviceUri() {
if (getPort().isEmpty()) {
return null;
Expand Down Expand Up @@ -140,7 +146,8 @@ && getPort().equals(other.getPort()) && getBaudRate() == other.getBaudRate()
&& getBitsPerWord() == other.getBitsPerWord() && getStopBits() == other.getStopBits()
&& getParity() == other.getParity() && getPositionProvider().equals(other.getPositionProvider())
&& getGpsdHost().equals(other.getGpsdHost()) && getGpsdPort() == other.getGpsdPort()
&& getGpsdMaxValidityInterval().equals(other.getGpsdMaxValidityInterval());
&& getGpsdMaxValidityInterval().equals(other.getGpsdMaxValidityInterval())
&& getModemManagerRefreshRate() == other.getModemManagerRefreshRate();
}

private static final class Property<T> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2020 Eurotech and/or its affiliates and others
* Copyright (c) 2018, 2024 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -11,7 +11,7 @@
* Eurotech
*******************************************************************************/

package org.eclipse.kura.linux.position;
package org.eclipse.kura.linux.position.provider;

public interface GpsDeviceAvailabilityListener {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*******************************************************************************
* Copyright (c) 2018, 2024 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Eurotech
*******************************************************************************/

package org.eclipse.kura.linux.position.provider;

import org.eclipse.kura.position.PositionListener;

public interface LockStatusListener extends PositionListener {

public void onLockStatusChanged(final boolean hasLock);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
* Eurotech
*******************************************************************************/

package org.eclipse.kura.linux.position;
package org.eclipse.kura.linux.position.provider;

import java.time.LocalDateTime;
import java.util.Set;

import org.eclipse.kura.linux.position.GpsDevice.Listener;
import org.eclipse.kura.linux.position.options.PositionServiceOptions;
import org.eclipse.kura.position.GNSSType;
import org.eclipse.kura.position.NmeaPosition;
import org.osgi.util.position.Position;
Expand All @@ -41,7 +41,7 @@ public interface PositionProvider {

public String getLastSentence();

public void init(PositionServiceOptions configuration, Listener gpsDeviceListener,
public void init(PositionServiceOptions configuration, LockStatusListener gpsDeviceListener,
GpsDeviceAvailabilityListener gpsDeviceAvailabilityListener);

public PositionProviderType getType();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022 Eurotech and/or its affiliates and others
* Copyright (c) 2024 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -11,15 +11,16 @@
* Eurotech
*******************************************************************************/

package org.eclipse.kura.linux.position;
package org.eclipse.kura.linux.position.provider;

import java.util.HashMap;
import java.util.Map;

public enum PositionProviderType {

SERIAL("serial"),
GPSD("gpsd");
GPSD("gpsd"),
MODEM_MANAGER("modemManager");

private String value;

Expand Down
Loading

0 comments on commit e20efa6

Please sign in to comment.