forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mikrotik] Basic PPP/LTE interface support (openhab#11395)
Signed-off-by: Oleg Vivtash <[email protected]>
- Loading branch information
Showing
6 changed files
with
194 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...rotik/src/main/java/org/openhab/binding/mikrotik/internal/model/RouterosLTEInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* Copyright (c) 2010-2021 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.mikrotik.internal.model; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.Map; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.openhab.binding.mikrotik.internal.util.Converter; | ||
|
||
/** | ||
* The {@link RouterosLTEInterface} is a model class for `lte` interface models having casting accessors for | ||
* data that is specific to this network interface kind. Is a subclass of {@link RouterosInterfaceBase}. | ||
* | ||
* @author Oleg Vivtash - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class RouterosLTEInterface extends RouterosInterfaceBase { | ||
public RouterosLTEInterface(Map<String, String> props) { | ||
super(props); | ||
} | ||
|
||
@Override | ||
public RouterosInterfaceType getDesignedType() { | ||
return RouterosInterfaceType.LTE; | ||
} | ||
|
||
@Override | ||
public String getApiType() { | ||
return "lte"; | ||
} | ||
|
||
@Override | ||
public boolean hasDetailedReport() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean hasMonitor() { | ||
return false; | ||
} | ||
|
||
public @Nullable String getStatus() { | ||
// I only have an RNDIS/HiLink 4G modem which doesn't report status at all. This should be tested/fixed | ||
// by someone who has PCIe/serial 4G modem. | ||
return getProp("status"); | ||
} | ||
|
||
public @Nullable String getUptime() { | ||
// Same as above. Also a custom info command need to be implemented for this to work. | ||
// https://forum.mikrotik.com/viewtopic.php?t=164035#p808281 | ||
return getProp("session-uptime"); | ||
} | ||
|
||
public @Nullable LocalDateTime getUptimeStart() { | ||
return Converter.routerosPeriodBack(getUptime()); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...ik/src/main/java/org/openhab/binding/mikrotik/internal/model/RouterosPPPCliInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* Copyright (c) 2010-2021 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.mikrotik.internal.model; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.Map; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.openhab.binding.mikrotik.internal.util.Converter; | ||
|
||
/** | ||
* The {@link RouterosPPPCliInterface} is a model class for `pppoe-out` interface models having casting accessors for | ||
* data that is specific to this network interface kind. Is a subclass of {@link RouterosInterfaceBase}. | ||
* | ||
* @author Oleg Vivtash - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class RouterosPPPCliInterface extends RouterosInterfaceBase { | ||
public RouterosPPPCliInterface(Map<String, String> props) { | ||
super(props); | ||
} | ||
|
||
@Override | ||
public RouterosInterfaceType getDesignedType() { | ||
return RouterosInterfaceType.PPP_CLIENT; | ||
} | ||
|
||
@Override | ||
public String getApiType() { | ||
return "ppp-client"; | ||
} | ||
|
||
@Override | ||
public boolean hasDetailedReport() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean hasMonitor() { | ||
return true; | ||
} | ||
|
||
public @Nullable String getMacAddress() { | ||
return null; | ||
} | ||
|
||
public @Nullable String getLocalAddress() { | ||
return getProp("local-address"); | ||
} | ||
|
||
public @Nullable String getRemoteAddress() { | ||
return getProp("remote-address"); | ||
} | ||
|
||
public @Nullable String getStatus() { | ||
return getProp("status"); | ||
} | ||
|
||
public @Nullable String getUptime() { | ||
return getProp("uptime"); | ||
} | ||
|
||
public @Nullable LocalDateTime getUptimeStart() { | ||
return Converter.routerosPeriodBack(getUptime()); | ||
} | ||
} |