2 * Copyright (c) 2010-2023 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.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;
37 * @author blafois - Initial contribution
41 public class UartProcessorTest implements ResponseListener {
43 private boolean completed = false;
46 public void testUartProcessor() {
47 BRC1HUartProcessor processor = new BRC1HUartProcessor(this);
49 processor.chunkReceived(
50 new byte[] { 0x01, 0x1F, 0x01, 0x03, 0x20, 0x01, 0x04, 0x21, 0x01, 0x01, 0x30, 0x01, 0x00 });
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 });
55 assertTrue(completed);
57 this.completed = false;
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);
74 public void receivedResponse(byte[] bytes) {
75 this.completed = true;
79 public void receivedResponse(GetVersionCommand command) {
83 public void receivedResponse(GetFanspeedCommand command) {
87 public void receivedResponse(GetOperationmodeCommand command) {
91 public void receivedResponse(GetPowerstateCommand command) {
95 public void receivedResponse(GetSetpointCommand command) {
99 public void receivedResponse(GetIndoorOutoorTemperatures command) {
103 public void receivedResponse(SetPowerstateCommand command) {
107 public void receivedResponse(SetSetpointCommand command) {
111 public void receivedResponse(SetOperationmodeCommand command) {
115 public void receivedResponse(SetFanspeedCommand command) {
119 public void receivedResponse(GetOperationHoursCommand command) {
123 public void receivedResponse(GetEyeBrightnessCommand command) {
127 public void receivedResponse(GetCleanFilterIndicatorCommand command) {
131 public void receivedResponse(SetEyeBrightnessCommand command) {