2 * Copyright (c) 2010-2022 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.bluetooth.daikinmadoka.internal;
15 import static org.junit.jupiter.api.Assertions.*;
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;
40 public class UartProcessorTest implements ResponseListener {
42 private boolean completed = false;
45 public void testUartProcessor() {
46 BRC1HUartProcessor processor = new BRC1HUartProcessor(this);
48 processor.chunkReceived(
49 new byte[] { 0x01, 0x1F, 0x01, 0x03, 0x20, 0x01, 0x04, 0x21, 0x01, 0x01, 0x30, 0x01, 0x00 });
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 });
54 assertTrue(completed);
56 this.completed = false;
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);
73 public void receivedResponse(byte @NonNull [] bytes) {
74 this.completed = true;
78 public void receivedResponse(@NonNull GetVersionCommand command) {
82 public void receivedResponse(@NonNull GetFanspeedCommand command) {
86 public void receivedResponse(@NonNull GetOperationmodeCommand command) {
90 public void receivedResponse(@NonNull GetPowerstateCommand command) {
94 public void receivedResponse(@NonNull GetSetpointCommand command) {
98 public void receivedResponse(@NonNull GetIndoorOutoorTemperatures command) {
102 public void receivedResponse(@NonNull SetPowerstateCommand command) {
106 public void receivedResponse(@NonNull SetSetpointCommand command) {
110 public void receivedResponse(@NonNull SetOperationmodeCommand command) {
114 public void receivedResponse(@NonNull SetFanspeedCommand command) {
118 public void receivedResponse(@NonNull GetOperationHoursCommand command) {
122 public void receivedResponse(@NonNull GetEyeBrightnessCommand command) {
126 public void receivedResponse(@NonNull GetCleanFilterIndicatorCommand command) {
130 public void receivedResponse(@NonNull SetEyeBrightnessCommand command) {