]> git.basschouten.com Git - openhab-addons.git/blob
dfc3ab0e7b7d008c5747df37e815cde4c9116fca
[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.asuswrt.internal.structures;
14
15 import static org.openhab.binding.asuswrt.internal.constants.AsuswrtBindingConstants.*;
16 import static org.openhab.binding.asuswrt.internal.constants.AsuswrtBindingSettings.INTERFACE_CLIENT;
17 import static org.openhab.binding.asuswrt.internal.helpers.AsuswrtUtils.*;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20
21 import com.google.gson.JsonObject;
22
23 /**
24  * The {@link AsuswrtClientInfo} class stores client data.
25  *
26  * @author Christian Wild - Initial contribution
27  */
28 @NonNullByDefault
29 public class AsuswrtClientInfo {
30     private AsuswrtTraffic traffic = new AsuswrtTraffic();
31     private Integer defaultType = 0;
32     private String dpiDevice = "";
33     private String dpiType = "";
34     private String from = "";
35     private String group = "";
36     private String internetMode = "";
37     private Boolean internetState = false;
38     private String ip = "";
39     private String ipMethod = "";
40     private Boolean isGateway = false;
41     private Boolean isGN = false;
42     private Boolean isITunes = false;
43     private Boolean isLogin = false;
44     private Boolean isOnline = false;
45     private Boolean isPrinter = false;
46     private Boolean isWebServer = false;
47     private Integer isWL = 0;
48     private String keeparp = "";
49     private String mac = "";
50     private Boolean macRepeat = false;
51     private String name = "";
52     private String nickName = "";
53     private Integer opMode = 0;
54     private String qosLevel = "";
55     private Integer rog = 0;
56     private Integer rssi = 0;
57     private String ssid = "";
58     private String vendor = "";
59     private String wlConnectTime = "";
60     private Integer wtfast = 0;
61
62     public AsuswrtClientInfo() {
63     }
64
65     public AsuswrtClientInfo(JsonObject jsonObject) {
66         traffic = new AsuswrtTraffic(INTERFACE_CLIENT);
67         setData(jsonObject);
68     }
69
70     public void setData(JsonObject jsonObject) {
71         traffic.setData(jsonObject);
72         defaultType = jsonObjectToInt(jsonObject, JSON_MEMBER_CLIENT_DEFTYPE, defaultType);
73         dpiDevice = jsonObjectToString(jsonObject, JSON_MEMBER_CLIENT_DPIDEVICE, dpiDevice);
74         dpiType = jsonObjectToString(jsonObject, JSON_MEMBER_CLIENT_DPITYPE, dpiType);
75         from = jsonObjectToString(jsonObject, JSON_MEMBER_CLIENT_IPFROM, from);
76         group = jsonObjectToString(jsonObject, JSON_MEMBER_CLIENT_GROUP, group);
77         internetMode = jsonObjectToString(jsonObject, JSON_MEMBER_CLIENT_INETMODE, internetMode);
78         internetState = jsonObjectToBool(jsonObject, JSON_MEMBER_CLIENT_INETSTATE, internetState);
79         ip = jsonObjectToString(jsonObject, JSON_MEMBER_CLIENT_IP, ip);
80         ipMethod = jsonObjectToString(jsonObject, JSON_MEMBER_CLIENT_IPMETHOD, ipMethod);
81         isGateway = jsonObjectToBool(jsonObject, JSON_MEMBER_CLIENT_IPGATEWAY, isGateway);
82         isGN = jsonObjectToBool(jsonObject, JSON_MEMBER_CLIENT_GN, isGN);
83         isITunes = jsonObjectToBool(jsonObject, JSON_MEMBER_CLIENT_ITUNES, isITunes);
84         isLogin = jsonObjectToBool(jsonObject, JSON_MEMBER_CLIENT_LOGIN, isLogin);
85         isOnline = jsonObjectToBool(jsonObject, JSON_MEMBER_CLIENT_ONLINE, isOnline);
86         isPrinter = jsonObjectToBool(jsonObject, JSON_MEMBER_CLIENT_PRINTER, isPrinter);
87         isWebServer = jsonObjectToBool(jsonObject, JSON_MEMBER_CLIENT_WEBSRV, isWebServer);
88         isWL = jsonObjectToInt(jsonObject, JSON_MEMBER_CLIENT_WIFI, isWL);
89         keeparp = jsonObjectToString(jsonObject, JSON_MEMBER_CLIENT_KEEPARP, keeparp);
90         mac = jsonObjectToString(jsonObject, JSON_MEMBER_CLIENT_MAC, mac);
91         macRepeat = jsonObjectToBool(jsonObject, JSON_MEMBER_CLIENT_MACREPEAT, macRepeat);
92         name = jsonObjectToString(jsonObject, JSON_MEMBER_CLIENT_NAME, name);
93         nickName = jsonObjectToString(jsonObject, JSON_MEMBER_CLIENT_NICK, nickName);
94         opMode = jsonObjectToInt(jsonObject, JSON_MEMBER_CLIENT_MODE, opMode);
95         qosLevel = jsonObjectToString(jsonObject, JSON_MEMBER_CLIENT_QOSLVL, qosLevel);
96         rog = jsonObjectToInt(jsonObject, JSON_MEMBER_CLIENT_ROG, rog);
97         rssi = jsonObjectToInt(jsonObject, JSON_MEMBER_CLIENT_RSSI, rssi);
98         ssid = jsonObjectToString(jsonObject, JSON_MEMBER_CLIENT_SSID, ssid);
99         vendor = jsonObjectToString(jsonObject, JSON_MEMBER_CLIENT_VENDOR, vendor);
100         wlConnectTime = jsonObjectToString(jsonObject, JSON_MEMBER_CLIENT_CONNECTTIME, wlConnectTime);
101         wtfast = jsonObjectToInt(jsonObject, JSON_MEMBER_CLIENT_WTFAST, wtfast);
102     }
103
104     /*
105      * Getters
106      */
107
108     public AsuswrtTraffic getTraffic() {
109         return traffic;
110     }
111
112     public Integer getDefaultType() {
113         return defaultType;
114     }
115
116     public String getDpiDevice() {
117         return dpiDevice;
118     }
119
120     public String getDpiType() {
121         return dpiType;
122     }
123
124     public String getIpFrom() {
125         return from;
126     }
127
128     public String getGroup() {
129         return group;
130     }
131
132     public String getInternetMode() {
133         return internetMode;
134     }
135
136     public Boolean getInternetState() {
137         return internetState;
138     }
139
140     public String getIP() {
141         return ip;
142     }
143
144     public String getIpMethod() {
145         return ipMethod;
146     }
147
148     public Boolean isGateway() {
149         return isGateway;
150     }
151
152     public Boolean isGN() {
153         return isGN;
154     }
155
156     public Boolean isITunes() {
157         return isITunes;
158     }
159
160     public Boolean isLogin() {
161         return isLogin;
162     }
163
164     public Boolean isOnline() {
165         return isOnline;
166     }
167
168     public Boolean isPrinter() {
169         return isPrinter;
170     }
171
172     public Boolean isWebServer() {
173         return isWebServer;
174     }
175
176     public Integer isWL() {
177         return isWL;
178     }
179
180     public Boolean isWiFiConnected() {
181         return isWL > 0;
182     }
183
184     public String getKeepArp() {
185         return keeparp;
186     }
187
188     public String getMac() {
189         return mac;
190     }
191
192     public Boolean getMacRepeat() {
193         return macRepeat;
194     }
195
196     public String getName() {
197         return name;
198     }
199
200     public String getNickName() {
201         return nickName;
202     }
203
204     public Integer getOpMode() {
205         return opMode;
206     }
207
208     public String getQosLevel() {
209         return qosLevel;
210     }
211
212     public Integer getROG() {
213         return rog;
214     }
215
216     public Integer getRSSI() {
217         return rssi;
218     }
219
220     public String getSSID() {
221         return ssid;
222     }
223
224     public String getVendor() {
225         return vendor;
226     }
227
228     public String getWlanConnectTime() {
229         return wlConnectTime;
230     }
231
232     public Integer getWtFast() {
233         return wtfast;
234     }
235 }