]> git.basschouten.com Git - openhab-addons.git/blob
5dd1c812faf568b157958af18da313f554d966a6
[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.bluetooth.bluegiga.internal.command.system;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.bluetooth.bluegiga.internal.BlueGigaResponse;
17
18 /**
19  * Class to implement the BlueGiga command <b>getCounters</b>.
20  * <p>
21  * Read packet counters and resets them, also returns available packet buffers.
22  * <p>
23  * This class provides methods for processing BlueGiga API commands.
24  * <p>
25  * Note that this code is autogenerated. Manual changes may be overwritten.
26  *
27  * @author Chris Jackson - Initial contribution of Java code generator
28  */
29 @NonNullByDefault
30 public class BlueGigaGetCountersResponse extends BlueGigaResponse {
31     public static final int COMMAND_CLASS = 0x00;
32     public static final int COMMAND_METHOD = 0x05;
33
34     /**
35      * Number of transmitted packets
36      * <p>
37      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
38      */
39     private int txok;
40
41     /**
42      * Number of retransmitted packets
43      * <p>
44      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
45      */
46     private int txretry;
47
48     /**
49      * Number of received packets where CRC was OK
50      * <p>
51      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
52      */
53     private int rxok;
54
55     /**
56      * Number of received packets with CRC error
57      * <p>
58      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
59      */
60     private int rxfail;
61
62     /**
63      * Number of available packet buffers
64      * <p>
65      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
66      */
67     private int mbuf;
68
69     /**
70      * Response constructor
71      */
72     public BlueGigaGetCountersResponse(int[] inputBuffer) {
73         // Super creates deserializer and reads header fields
74         super(inputBuffer);
75
76         event = (inputBuffer[0] & 0x80) != 0;
77
78         // Deserialize the fields
79         txok = deserializeUInt8();
80         txretry = deserializeUInt8();
81         rxok = deserializeUInt8();
82         rxfail = deserializeUInt8();
83         mbuf = deserializeUInt8();
84     }
85
86     /**
87      * Number of transmitted packets
88      * <p>
89      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
90      *
91      * @return the current txok as {@link int}
92      */
93     public int getTxok() {
94         return txok;
95     }
96
97     /**
98      * Number of retransmitted packets
99      * <p>
100      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
101      *
102      * @return the current txretry as {@link int}
103      */
104     public int getTxretry() {
105         return txretry;
106     }
107
108     /**
109      * Number of received packets where CRC was OK
110      * <p>
111      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
112      *
113      * @return the current rxok as {@link int}
114      */
115     public int getRxok() {
116         return rxok;
117     }
118
119     /**
120      * Number of received packets with CRC error
121      * <p>
122      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
123      *
124      * @return the current rxfail as {@link int}
125      */
126     public int getRxfail() {
127         return rxfail;
128     }
129
130     /**
131      * Number of available packet buffers
132      * <p>
133      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
134      *
135      * @return the current mbuf as {@link int}
136      */
137     public int getMbuf() {
138         return mbuf;
139     }
140
141     @Override
142     public String toString() {
143         final StringBuilder builder = new StringBuilder();
144         builder.append("BlueGigaGetCountersResponse [txok=");
145         builder.append(txok);
146         builder.append(", txretry=");
147         builder.append(txretry);
148         builder.append(", rxok=");
149         builder.append(rxok);
150         builder.append(", rxfail=");
151         builder.append(rxfail);
152         builder.append(", mbuf=");
153         builder.append(mbuf);
154         builder.append(']');
155         return builder.toString();
156     }
157 }