]> git.basschouten.com Git - openhab-addons.git/blob
a02d2cb0c2cbfc8f0a03912708b6ea60f532865d
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.NonNull;
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
38  *
39  */
40 public class UartProcessorTest implements ResponseListener {
41
42     private boolean completed = false;
43
44     @Test
45     public void testUartProcessor() {
46         BRC1HUartProcessor processor = new BRC1HUartProcessor(this);
47
48         processor.chunkReceived(
49                 new byte[] { 0x01, 0x1F, 0x01, 0x03, 0x20, 0x01, 0x04, 0x21, 0x01, 0x01, 0x30, 0x01, 0x00 });
50
51         processor.chunkReceived(new byte[] { 0x00, 0x1F, 0x00, 0x00, 0x30, 0x10, 0x01, 0x00, 0x13, 0x01, 0x1F, 0x15,
52                 0x01, 0x10, 0x16, 0x01, 0x12, 0x17, 0x01, 0x20 });
53
54         assertTrue(completed);
55
56         this.completed = false;
57
58         processor.chunkReceived(new byte[] { 0x01, 0x01, 0x00, 0x31, 0x01, 0x01, 0x32, 0x01, 0x00, 0x40, 0x01, 0x00,
59                 (byte) 0xA0, 0x01, 0x10, (byte) 0xA1, 0x01, 0x10, (byte) 0xA2, 0x02 });
60         assertFalse(completed);
61         processor.chunkReceived(new byte[] { 0x00, 0x49, 0x00, 0x00, 0x40, 0x12, 0x01, 0x1C, 0x15, 0x01, (byte) 0xF0,
62                 0x20, 0x02, 0x0A, (byte) 0x80, 0x21, 0x02, 0x0A, (byte) 0x80, 0x30 });
63         assertFalse(completed);
64         processor.chunkReceived(new byte[] { 0x02, 0x08, 0x00, (byte) 0xA3, 0x02, 0x08, 0x00, (byte) 0xA4, 0x01, 0x11,
65                 (byte) 0xA5, 0x01, 0x11, (byte) 0xB0, 0x01, 0x20, (byte) 0xB1, 0x01, 0x20, (byte) 0xB2 });
66         assertFalse(completed);
67         processor.chunkReceived(new byte[] { 0x03, 0x02, 0x10, 0x00, (byte) 0xB3, 0x02, 0x10, 0x00, (byte) 0xB4, 0x01,
68                 0x17, (byte) 0xB5, 0x01, 0x17, (byte) 0xFE, 0x01, 0x02 });
69         assertTrue(completed);
70     }
71
72     @Override
73     public void receivedResponse(byte @NonNull [] bytes) {
74         this.completed = true;
75     }
76
77     @Override
78     public void receivedResponse(@NonNull GetVersionCommand command) {
79     }
80
81     @Override
82     public void receivedResponse(@NonNull GetFanspeedCommand command) {
83     }
84
85     @Override
86     public void receivedResponse(@NonNull GetOperationmodeCommand command) {
87     }
88
89     @Override
90     public void receivedResponse(@NonNull GetPowerstateCommand command) {
91     }
92
93     @Override
94     public void receivedResponse(@NonNull GetSetpointCommand command) {
95     }
96
97     @Override
98     public void receivedResponse(@NonNull GetIndoorOutoorTemperatures command) {
99     }
100
101     @Override
102     public void receivedResponse(@NonNull SetPowerstateCommand command) {
103     }
104
105     @Override
106     public void receivedResponse(@NonNull SetSetpointCommand command) {
107     }
108
109     @Override
110     public void receivedResponse(@NonNull SetOperationmodeCommand command) {
111     }
112
113     @Override
114     public void receivedResponse(@NonNull SetFanspeedCommand command) {
115     }
116
117     @Override
118     public void receivedResponse(@NonNull GetOperationHoursCommand command) {
119     }
120
121     @Override
122     public void receivedResponse(@NonNull GetEyeBrightnessCommand command) {
123     }
124
125     @Override
126     public void receivedResponse(@NonNull GetCleanFilterIndicatorCommand command) {
127     }
128
129     @Override
130     public void receivedResponse(@NonNull SetEyeBrightnessCommand command) {
131     }
132 }