]> git.basschouten.com Git - openhab-addons.git/blob
6dd9e2f57961e68c297e6a57e6869622d30ba3b6
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.mikrotik.internal.model;
14
15 import java.time.LocalDateTime;
16 import java.util.Map;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.binding.mikrotik.internal.util.Converter;
21
22 /**
23  * The {@link RouterosLTEInterface} is a model class for `lte` interface models having casting accessors for
24  * data that is specific to this network interface kind. Is a subclass of {@link RouterosInterfaceBase}.
25  *
26  * @author Oleg Vivtash - Initial contribution
27  */
28 @NonNullByDefault
29 public class RouterosLTEInterface extends RouterosInterfaceBase {
30     public RouterosLTEInterface(Map<String, String> props) {
31         super(props);
32     }
33
34     @Override
35     public RouterosInterfaceType getDesignedType() {
36         return RouterosInterfaceType.LTE;
37     }
38
39     @Override
40     public String getApiType() {
41         return "lte";
42     }
43
44     @Override
45     public boolean hasDetailedReport() {
46         return false;
47     }
48
49     @Override
50     public boolean hasMonitor() {
51         return false;
52     }
53
54     public @Nullable String getStatus() {
55         // I only have an RNDIS/HiLink 4G modem which doesn't report status at all. This should be tested/fixed
56         // by someone who has PCIe/serial 4G modem.
57         return getProp("status");
58     }
59
60     public @Nullable String getUptime() {
61         // Same as above. Also a custom info command need to be implemented for this to work.
62         // https://forum.mikrotik.com/viewtopic.php?t=164035#p808281
63         return getProp("session-uptime");
64     }
65
66     public @Nullable LocalDateTime getUptimeStart() {
67         return Converter.routerosPeriodBack(getUptime());
68     }
69 }