2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.mikrotik.internal.model;
15 import static org.openhab.binding.mikrotik.internal.model.RouterosDevice.PROP_ID_KEY;
17 import java.math.BigInteger;
18 import java.time.LocalDateTime;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.eclipse.jdt.annotation.Nullable;
23 import org.openhab.binding.mikrotik.internal.util.Converter;
26 * The {@link RouterosRegistrationBase} is a base model class for WiFi client models having casting accessors for
27 * data that is same for all WiFi client types.
29 * @author Oleg Vivtash - Initial contribution
32 public class RouterosRegistrationBase extends RouterosBaseData {
34 public RouterosRegistrationBase(Map<String, String> props) {
39 protected void postProcess() {
40 if (hasProp("bytes")) {
41 String bytesStr = getProp("bytes");
42 if (bytesStr != null) {
43 String[] bytes = bytesStr.split(",");
44 setProp("tx-byte", bytes[0]);
45 setProp("rx-byte", bytes[1]);
48 if (hasProp("packets")) {
49 String packetsStr = getProp("packets");
50 if (packetsStr != null) {
51 String[] packets = packetsStr.split(",");
52 setProp("tx-packet", packets[0]);
53 setProp("rx-packet", packets[1]);
58 public @Nullable String getId() {
59 return getProp(PROP_ID_KEY);
62 public @Nullable String getName() {
63 return getProp("name");
66 public @Nullable String getComment() {
67 return getProp("comment");
70 public @Nullable String getMacAddress() {
71 return getProp("mac-address");
74 public @Nullable String getSSID() {
75 return getProp("ssid");
78 public @Nullable String getInterfaceName() {
79 return getProp("interface");
82 public @Nullable BigInteger getTxBytes() {
83 return getBigIntProp("tx-byte");
86 public @Nullable BigInteger getRxBytes() {
87 return getBigIntProp("rx-byte");
90 public @Nullable BigInteger getTxPackets() {
91 return getBigIntProp("tx-packet");
94 public @Nullable BigInteger getRxPackets() {
95 return getBigIntProp("rx-packet");
98 public @Nullable String getUptime() {
99 return getProp("uptime");
102 public @Nullable LocalDateTime getUptimeStart() {
103 return Converter.routerosPeriodBack(getUptime());