]> git.basschouten.com Git - openhab-addons.git/blob
c3e6d50be4a110628d5d662ce2d8223c7d77eef6
[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.util.Map;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19
20 /**
21  * The {@link RouterosWlanInterface} is a model class for `waln` interface models having casting accessors for
22  * data that is specific to this network interface kind. Is a subclass of {@link RouterosInterfaceBase}.
23  *
24  * @author Oleg Vivtash - Initial contribution
25  */
26 @NonNullByDefault
27 public class RouterosWlanInterface extends RouterosInterfaceBase {
28     public RouterosWlanInterface(Map<String, String> props) {
29         super(props);
30     }
31
32     @Override
33     public RouterosInterfaceType getDesignedType() {
34         return RouterosInterfaceType.WLAN;
35     }
36
37     @Override
38     public String getApiType() {
39         return "wireless";
40     }
41
42     @Override
43     public boolean hasDetailedReport() {
44         return true;
45     }
46
47     @Override
48     public boolean hasMonitor() {
49         return true;
50     }
51
52     public boolean isMaster() {
53         return !getProp("master-interface", "").isBlank();
54     }
55
56     public @Nullable String getCurrentState() {
57         return getProp("status");
58     }
59
60     public @Nullable String getSSID() {
61         return getProp("ssid");
62     }
63
64     public @Nullable String getMode() {
65         return getProp("mode");
66     }
67
68     public @Nullable String getRate() {
69         return getProp("band");
70     }
71
72     public @Nullable String getInterfaceType() {
73         return getProp("interface-type");
74     }
75
76     public int getRegisteredClients() {
77         Integer registeredClients = getIntProp("registered-clients");
78         return registeredClients == null ? 0 : registeredClients;
79     }
80
81     public int getAuthorizedClients() {
82         Integer authedClients = getIntProp("authenticated-clients");
83         return authedClients == null ? 0 : authedClients;
84     }
85 }