]> git.basschouten.com Git - openhab-addons.git/blob
ba1dfc0bd28da6f4809825948f53778c6fa269e2
[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.daikinmadoka.internal;
14
15 import static org.junit.jupiter.api.Assertions.*;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
19 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.GetCleanFilterIndicatorCommand;
20 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.GetEyeBrightnessCommand;
21 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.GetFanspeedCommand;
22 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.GetIndoorOutoorTemperatures;
23 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.GetOperationHoursCommand;
24 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.GetOperationmodeCommand;
25 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.GetPowerstateCommand;
26 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.GetSetpointCommand;
27 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.GetVersionCommand;
28 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.ResponseListener;
29 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.SetEyeBrightnessCommand;
30 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.SetFanspeedCommand;
31 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.SetOperationmodeCommand;
32 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.SetPowerstateCommand;
33 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.SetSetpointCommand;
34
35 /**
36  *
37  * @author blafois - Initial contribution
38  *
39  */
40 @NonNullByDefault
41 public class UartProcessorTest implements ResponseListener {
42
43     private boolean completed = false;
44
45     @Test
46     public void testUartProcessor() {
47         BRC1HUartProcessor processor = new BRC1HUartProcessor(this);
48
49         processor.chunkReceived(
50                 new byte[] { 0x01, 0x1F, 0x01, 0x03, 0x20, 0x01, 0x04, 0x21, 0x01, 0x01, 0x30, 0x01, 0x00 });
51
52         processor.chunkReceived(new byte[] { 0x00, 0x1F, 0x00, 0x00, 0x30, 0x10, 0x01, 0x00, 0x13, 0x01, 0x1F, 0x15,
53                 0x01, 0x10, 0x16, 0x01, 0x12, 0x17, 0x01, 0x20 });
54
55         assertTrue(completed);
56
57         this.completed = false;
58
59         processor.chunkReceived(new byte[] { 0x01, 0x01, 0x00, 0x31, 0x01, 0x01, 0x32, 0x01, 0x00, 0x40, 0x01, 0x00,
60                 (byte) 0xA0, 0x01, 0x10, (byte) 0xA1, 0x01, 0x10, (byte) 0xA2, 0x02 });
61         assertFalse(completed);
62         processor.chunkReceived(new byte[] { 0x00, 0x49, 0x00, 0x00, 0x40, 0x12, 0x01, 0x1C, 0x15, 0x01, (byte) 0xF0,
63                 0x20, 0x02, 0x0A, (byte) 0x80, 0x21, 0x02, 0x0A, (byte) 0x80, 0x30 });
64         assertFalse(completed);
65         processor.chunkReceived(new byte[] { 0x02, 0x08, 0x00, (byte) 0xA3, 0x02, 0x08, 0x00, (byte) 0xA4, 0x01, 0x11,
66                 (byte) 0xA5, 0x01, 0x11, (byte) 0xB0, 0x01, 0x20, (byte) 0xB1, 0x01, 0x20, (byte) 0xB2 });
67         assertFalse(completed);
68         processor.chunkReceived(new byte[] { 0x03, 0x02, 0x10, 0x00, (byte) 0xB3, 0x02, 0x10, 0x00, (byte) 0xB4, 0x01,
69                 0x17, (byte) 0xB5, 0x01, 0x17, (byte) 0xFE, 0x01, 0x02 });
70         assertTrue(completed);
71     }
72
73     @Override
74     public void receivedResponse(byte[] bytes) {
75         this.completed = true;
76     }
77
78     @Override
79     public void receivedResponse(GetVersionCommand command) {
80     }
81
82     @Override
83     public void receivedResponse(GetFanspeedCommand command) {
84     }
85
86     @Override
87     public void receivedResponse(GetOperationmodeCommand command) {
88     }
89
90     @Override
91     public void receivedResponse(GetPowerstateCommand command) {
92     }
93
94     @Override
95     public void receivedResponse(GetSetpointCommand command) {
96     }
97
98     @Override
99     public void receivedResponse(GetIndoorOutoorTemperatures command) {
100     }
101
102     @Override
103     public void receivedResponse(SetPowerstateCommand command) {
104     }
105
106     @Override
107     public void receivedResponse(SetSetpointCommand command) {
108     }
109
110     @Override
111     public void receivedResponse(SetOperationmodeCommand command) {
112     }
113
114     @Override
115     public void receivedResponse(SetFanspeedCommand command) {
116     }
117
118     @Override
119     public void receivedResponse(GetOperationHoursCommand command) {
120     }
121
122     @Override
123     public void receivedResponse(GetEyeBrightnessCommand command) {
124     }
125
126     @Override
127     public void receivedResponse(GetCleanFilterIndicatorCommand command) {
128     }
129
130     @Override
131     public void receivedResponse(SetEyeBrightnessCommand command) {
132     }
133 }