]> git.basschouten.com Git - openhab-addons.git/blob
bea49d7d14ad467a1c57cce06942fd28dec49575
[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.novafinedust.internal.sds011protocol.messages;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.novafinedust.internal.sds011protocol.WorkMode;
17
18 /**
19  * Reply from sensor to a set mode command
20  *
21  * @author Stefan Triller - Initial contribution
22  *
23  */
24 @NonNullByDefault
25 public class ModeReply extends SensorReply {
26
27     private final byte actionType;
28     private final WorkMode mode;
29
30     public ModeReply(byte[] bytes) {
31         super(bytes);
32
33         this.actionType = bytes[3];
34         if (bytes[4] == (byte) 1) {
35             this.mode = WorkMode.POLLING;
36         } else {
37             this.mode = WorkMode.REPORTING;
38         }
39     }
40
41     /**
42      * Get the type of action
43      *
44      * @return 0 = query 1 = set mode
45      */
46     public byte getActionType() {
47         return actionType;
48     }
49
50     /**
51      * Get the set work mode
52      *
53      * @return work mode set on the sensor
54      */
55     public WorkMode getMode() {
56         return mode;
57     }
58
59     @Override
60     public String toString() {
61         return "ModeReply: [mode=" + mode + "]";
62     }
63 }