2018-11-20 14:53:56 +00:00
|
|
|
// Copyright 2017 David Conran
|
|
|
|
#include "ir_Toshiba.h"
|
2020-04-09 09:25:50 +01:00
|
|
|
#include "IRac.h"
|
2018-11-20 14:53:56 +00:00
|
|
|
#include "IRrecv.h"
|
|
|
|
#include "IRrecv_test.h"
|
|
|
|
#include "IRsend.h"
|
|
|
|
#include "IRsend_test.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
// Tests for Toshiba A/C methods.
|
|
|
|
|
|
|
|
// Test sending typical data only.
|
|
|
|
TEST(TestSendToshibaAC, SendDataOnly) {
|
2020-07-29 12:57:44 +01:00
|
|
|
IRsendTest irsend(kGpioUnused);
|
2018-11-20 14:53:56 +00:00
|
|
|
irsend.begin();
|
|
|
|
|
|
|
|
uint8_t toshiba_code[kToshibaACStateLength] = {0xF2, 0x0D, 0x03, 0xFC, 0x01,
|
|
|
|
0x00, 0x00, 0x00, 0x00};
|
|
|
|
irsend.reset();
|
|
|
|
irsend.sendToshibaAC(toshiba_code);
|
|
|
|
EXPECT_EQ(
|
2019-05-27 13:11:01 +01:00
|
|
|
"f38000d50"
|
2018-11-20 14:53:56 +00:00
|
|
|
"m4400s4300"
|
2020-07-29 12:57:44 +01:00
|
|
|
"m580s1600m580s1600m580s1600m580s1600m580s490m580s490m580s1600m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s1600m580s1600m580s490m580s1600"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s1600m580s1600"
|
|
|
|
"m580s1600m580s1600m580s1600m580s1600m580s1600m580s1600m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s1600"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s7400"
|
2018-11-20 14:53:56 +00:00
|
|
|
"m4400s4300"
|
2020-07-29 12:57:44 +01:00
|
|
|
"m580s1600m580s1600m580s1600m580s1600m580s490m580s490m580s1600m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s1600m580s1600m580s490m580s1600"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s1600m580s1600"
|
|
|
|
"m580s1600m580s1600m580s1600m580s1600m580s1600m580s1600m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s1600"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s7400",
|
2018-11-20 14:53:56 +00:00
|
|
|
irsend.outputStr());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test sending with repeats.
|
|
|
|
TEST(TestSendToshibaAC, SendWithRepeats) {
|
2020-07-29 12:57:44 +01:00
|
|
|
IRsendTest irsend(kGpioUnused);
|
2018-11-20 14:53:56 +00:00
|
|
|
irsend.begin();
|
|
|
|
|
|
|
|
irsend.reset();
|
|
|
|
uint8_t toshiba_code[kToshibaACStateLength] = {0xF2, 0x0D, 0x03, 0xFC, 0x01,
|
|
|
|
0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
|
|
|
irsend.sendToshibaAC(toshiba_code, kToshibaACStateLength, 0);
|
|
|
|
EXPECT_EQ(
|
2019-05-27 13:11:01 +01:00
|
|
|
"f38000d50"
|
2018-11-20 14:53:56 +00:00
|
|
|
"m4400s4300"
|
2020-07-29 12:57:44 +01:00
|
|
|
"m580s1600m580s1600m580s1600m580s1600m580s490m580s490m580s1600m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s1600m580s1600m580s490m580s1600"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s1600m580s1600"
|
|
|
|
"m580s1600m580s1600m580s1600m580s1600m580s1600m580s1600m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s1600"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s7400",
|
2018-11-20 14:53:56 +00:00
|
|
|
irsend.outputStr());
|
|
|
|
|
|
|
|
irsend.reset();
|
|
|
|
irsend.sendToshibaAC(toshiba_code, kToshibaACStateLength, 2);
|
|
|
|
EXPECT_EQ(
|
2019-05-27 13:11:01 +01:00
|
|
|
"f38000d50"
|
2018-11-20 14:53:56 +00:00
|
|
|
"m4400s4300"
|
2020-07-29 12:57:44 +01:00
|
|
|
"m580s1600m580s1600m580s1600m580s1600m580s490m580s490m580s1600m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s1600m580s1600m580s490m580s1600"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s1600m580s1600"
|
|
|
|
"m580s1600m580s1600m580s1600m580s1600m580s1600m580s1600m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s1600"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s7400"
|
2018-11-20 14:53:56 +00:00
|
|
|
"m4400s4300"
|
2020-07-29 12:57:44 +01:00
|
|
|
"m580s1600m580s1600m580s1600m580s1600m580s490m580s490m580s1600m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s1600m580s1600m580s490m580s1600"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s1600m580s1600"
|
|
|
|
"m580s1600m580s1600m580s1600m580s1600m580s1600m580s1600m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s1600"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s7400"
|
2018-11-20 14:53:56 +00:00
|
|
|
"m4400s4300"
|
2020-07-29 12:57:44 +01:00
|
|
|
"m580s1600m580s1600m580s1600m580s1600m580s490m580s490m580s1600m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s1600m580s1600m580s490m580s1600"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s1600m580s1600"
|
|
|
|
"m580s1600m580s1600m580s1600m580s1600m580s1600m580s1600m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s1600"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s7400",
|
2018-11-20 14:53:56 +00:00
|
|
|
irsend.outputStr());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tests for IRToshibaAC class.
|
|
|
|
|
|
|
|
TEST(TestToshibaACClass, Power) {
|
2020-07-29 12:57:44 +01:00
|
|
|
IRToshibaAC ac(kGpioUnused);
|
|
|
|
ac.begin();
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.on();
|
|
|
|
EXPECT_TRUE(ac.getPower());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.off();
|
|
|
|
EXPECT_FALSE(ac.getPower());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setPower(true);
|
|
|
|
EXPECT_TRUE(ac.getPower());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setPower(false);
|
|
|
|
EXPECT_FALSE(ac.getPower());
|
2018-11-20 14:53:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestToshibaACClass, Temperature) {
|
2020-07-29 12:57:44 +01:00
|
|
|
IRToshibaAC ac(kGpioUnused);
|
|
|
|
ac.begin();
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setTemp(0);
|
|
|
|
EXPECT_EQ(kToshibaAcMinTemp, ac.getTemp());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setTemp(255);
|
|
|
|
EXPECT_EQ(kToshibaAcMaxTemp, ac.getTemp());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setTemp(kToshibaAcMinTemp);
|
|
|
|
EXPECT_EQ(kToshibaAcMinTemp, ac.getTemp());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setTemp(kToshibaAcMaxTemp);
|
|
|
|
EXPECT_EQ(kToshibaAcMaxTemp, ac.getTemp());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setTemp(kToshibaAcMinTemp - 1);
|
|
|
|
EXPECT_EQ(kToshibaAcMinTemp, ac.getTemp());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setTemp(kToshibaAcMaxTemp + 1);
|
|
|
|
EXPECT_EQ(kToshibaAcMaxTemp, ac.getTemp());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setTemp(17);
|
|
|
|
EXPECT_EQ(17, ac.getTemp());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setTemp(21);
|
|
|
|
EXPECT_EQ(21, ac.getTemp());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setTemp(25);
|
|
|
|
EXPECT_EQ(25, ac.getTemp());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setTemp(30);
|
|
|
|
EXPECT_EQ(30, ac.getTemp());
|
2018-11-20 14:53:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestToshibaACClass, OperatingMode) {
|
2020-07-29 12:57:44 +01:00
|
|
|
IRToshibaAC ac(kGpioUnused);
|
|
|
|
ac.begin();
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setMode(kToshibaAcAuto);
|
|
|
|
EXPECT_EQ(kToshibaAcAuto, ac.getMode());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setMode(kToshibaAcCool);
|
|
|
|
EXPECT_EQ(kToshibaAcCool, ac.getMode());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setMode(kToshibaAcHeat);
|
|
|
|
EXPECT_EQ(kToshibaAcHeat, ac.getMode());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setMode(kToshibaAcDry);
|
|
|
|
EXPECT_EQ(kToshibaAcDry, ac.getMode());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setMode(kToshibaAcFan);
|
|
|
|
EXPECT_EQ(kToshibaAcFan, ac.getMode());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setMode(kToshibaAcFan + 1);
|
|
|
|
EXPECT_EQ(kToshibaAcAuto, ac.getMode());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setMode(255);
|
|
|
|
EXPECT_EQ(kToshibaAcAuto, ac.getMode());
|
|
|
|
|
|
|
|
// Setting the power off changes the underlying mode in the state to a special
|
|
|
|
// off mode.
|
|
|
|
ac.setPower(true);
|
|
|
|
ac.setMode(kToshibaAcCool);
|
|
|
|
EXPECT_EQ(kToshibaAcCool, ac.getMode());
|
|
|
|
ac.setPower(false);
|
|
|
|
EXPECT_EQ(kToshibaAcCool, ac.getMode());
|
2018-11-20 14:53:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestToshibaACClass, FanSpeed) {
|
2020-07-29 12:57:44 +01:00
|
|
|
IRToshibaAC ac(kGpioUnused);
|
|
|
|
ac.begin();
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setFan(kToshibaAcFanAuto);
|
|
|
|
EXPECT_EQ(kToshibaAcFanAuto, ac.getFan());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setFan(255);
|
|
|
|
EXPECT_EQ(kToshibaAcFanMax, ac.getFan());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setFan(kToshibaAcFanMax);
|
|
|
|
EXPECT_EQ(kToshibaAcFanMax, ac.getFan());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setFan(kToshibaAcFanMax - 1);
|
|
|
|
EXPECT_EQ(kToshibaAcFanMax - 1, ac.getFan());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setFan(1);
|
|
|
|
EXPECT_EQ(1, ac.getFan());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setFan(2);
|
|
|
|
EXPECT_EQ(2, ac.getFan());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setFan(3);
|
|
|
|
EXPECT_EQ(3, ac.getFan());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setFan(4);
|
|
|
|
EXPECT_EQ(4, ac.getFan());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setFan(kToshibaAcFanMax + 1);
|
|
|
|
EXPECT_EQ(kToshibaAcFanMax, ac.getFan());
|
2018-11-20 14:53:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestToshibaACClass, RawState) {
|
2020-07-29 12:57:44 +01:00
|
|
|
IRToshibaAC ac(kGpioUnused);
|
|
|
|
ac.begin();
|
2018-11-20 14:53:56 +00:00
|
|
|
|
|
|
|
uint8_t initial_state[kToshibaACStateLength] = {0xF2, 0x0D, 0x03, 0xFC, 0x01,
|
2020-07-29 12:57:44 +01:00
|
|
|
0x50, 0x00, 0x00, 0x51};
|
2018-11-20 14:53:56 +00:00
|
|
|
uint8_t modified_state[kToshibaACStateLength] = {0xF2, 0x0D, 0x03, 0xFC, 0x01,
|
|
|
|
0x00, 0xC1, 0x00, 0xC0};
|
|
|
|
|
|
|
|
// Verify the starting state.
|
2020-07-29 12:57:44 +01:00
|
|
|
EXPECT_STATE_EQ(initial_state, ac.getRaw(), kToshibaACBits);
|
|
|
|
EXPECT_TRUE(ac.getPower());
|
|
|
|
EXPECT_EQ(kToshibaAcAuto, ac.getMode());
|
|
|
|
EXPECT_EQ(kToshibaAcFanAuto, ac.getFan());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
|
|
|
// Change some settings.
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setMode(kToshibaAcCool);
|
|
|
|
ac.setFan(kToshibaAcFanMax);
|
|
|
|
ac.setTemp(kToshibaAcMinTemp);
|
2018-11-20 14:53:56 +00:00
|
|
|
// Verify those were set.
|
2020-07-29 12:57:44 +01:00
|
|
|
EXPECT_EQ(kToshibaAcCool, ac.getMode());
|
|
|
|
EXPECT_EQ(kToshibaAcFanMax, ac.getFan());
|
|
|
|
EXPECT_EQ(kToshibaAcMinTemp, ac.getTemp());
|
2018-11-20 14:53:56 +00:00
|
|
|
// Retrieve the modified state.
|
2020-07-29 12:57:44 +01:00
|
|
|
EXPECT_STATE_EQ(modified_state, ac.getRaw(), kToshibaACBits);
|
2018-11-20 14:53:56 +00:00
|
|
|
|
|
|
|
// Set it back to the initial state.
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setRaw(initial_state);
|
2018-11-20 14:53:56 +00:00
|
|
|
|
|
|
|
// Check the new state was set correctly.
|
2020-07-29 12:57:44 +01:00
|
|
|
EXPECT_TRUE(ac.getPower());
|
|
|
|
EXPECT_EQ(kToshibaAcAuto, ac.getMode());
|
|
|
|
EXPECT_EQ(kToshibaAcFanAuto, ac.getFan());
|
|
|
|
EXPECT_STATE_EQ(initial_state, ac.getRaw(), kToshibaACBits);
|
2018-11-20 14:53:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestToshibaACClass, Checksums) {
|
2020-07-29 12:57:44 +01:00
|
|
|
IRToshibaAC ac(kGpioUnused);
|
|
|
|
ac.begin();
|
2018-11-20 14:53:56 +00:00
|
|
|
|
|
|
|
uint8_t initial_state[kToshibaACStateLength] = {0xF2, 0x0D, 0x03, 0xFC, 0x01,
|
|
|
|
0x00, 0x00, 0x00, 0x01};
|
|
|
|
uint8_t modified_state[kToshibaACStateLength] = {0xF2, 0x0D, 0x03, 0xFC, 0x01,
|
|
|
|
0x00, 0xC1, 0x00, 0xC0};
|
|
|
|
uint8_t invalid_state[kToshibaACStateLength] = {0xF2, 0x0D, 0x03, 0xFC, 0x01,
|
|
|
|
0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
EXPECT_EQ(0x01, ac.calcChecksum(initial_state));
|
|
|
|
EXPECT_EQ(0xC0, ac.calcChecksum(modified_state));
|
2018-11-20 14:53:56 +00:00
|
|
|
// Check we can call it without instantiating the object.
|
|
|
|
EXPECT_EQ(0x01, IRToshibaAC::calcChecksum(initial_state));
|
|
|
|
// Use different lengths.
|
|
|
|
EXPECT_EQ(0x01, IRToshibaAC::calcChecksum(initial_state,
|
|
|
|
kToshibaACStateLength - 1));
|
|
|
|
EXPECT_EQ(0xFF, IRToshibaAC::calcChecksum(initial_state, 3));
|
|
|
|
// Minimum length that actually means anything.
|
|
|
|
EXPECT_EQ(0xF2, IRToshibaAC::calcChecksum(initial_state, 2));
|
|
|
|
// Technically, there is no such thing as a checksum for a length of < 2
|
|
|
|
// But test it anyway
|
|
|
|
EXPECT_EQ(0x00, IRToshibaAC::calcChecksum(initial_state, 1));
|
|
|
|
EXPECT_EQ(0x00, IRToshibaAC::calcChecksum(initial_state, 0));
|
|
|
|
|
|
|
|
// Validity tests.
|
|
|
|
EXPECT_TRUE(IRToshibaAC::validChecksum(initial_state));
|
|
|
|
EXPECT_TRUE(IRToshibaAC::validChecksum(modified_state));
|
|
|
|
EXPECT_FALSE(IRToshibaAC::validChecksum(invalid_state));
|
|
|
|
EXPECT_FALSE(IRToshibaAC::validChecksum(initial_state, 0));
|
|
|
|
EXPECT_FALSE(IRToshibaAC::validChecksum(initial_state, 1));
|
|
|
|
EXPECT_FALSE(IRToshibaAC::validChecksum(initial_state, 2));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestToshibaACClass, HumanReadableOutput) {
|
2020-07-29 12:57:44 +01:00
|
|
|
IRToshibaAC ac(kGpioUnused);
|
|
|
|
ac.begin();
|
2018-11-20 14:53:56 +00:00
|
|
|
|
|
|
|
uint8_t initial_state[kToshibaACStateLength] = {0xF2, 0x0D, 0x03, 0xFC, 0x01,
|
|
|
|
0x00, 0x00, 0x00, 0x01};
|
|
|
|
uint8_t modified_state[kToshibaACStateLength] = {0xF2, 0x0D, 0x03, 0xFC, 0x01,
|
|
|
|
0x00, 0xC1, 0x00, 0xC0};
|
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setRaw(initial_state);
|
|
|
|
EXPECT_EQ("Temp: 17C, Power: On, Mode: 0 (Auto), Fan: 0 (Auto), "
|
|
|
|
"Turbo: Off, Econo: Off",
|
|
|
|
ac.toString());
|
|
|
|
ac.setRaw(modified_state);
|
|
|
|
EXPECT_EQ("Temp: 17C, Power: On, Mode: 1 (Cool), Fan: 5 (High), "
|
|
|
|
"Turbo: Off, Econo: Off",
|
|
|
|
ac.toString());
|
|
|
|
ac.setTemp(25);
|
|
|
|
ac.setFan(3);
|
|
|
|
ac.setMode(kToshibaAcDry);
|
|
|
|
EXPECT_EQ("Temp: 25C, Power: On, Mode: 2 (Dry), Fan: 3 (Medium), "
|
|
|
|
"Turbo: Off, Econo: Off",
|
|
|
|
ac.toString());
|
|
|
|
ac.off();
|
|
|
|
EXPECT_EQ("Temp: 25C, Power: Off, Fan: 3 (Medium), Turbo: Off, Econo: Off",
|
|
|
|
ac.toString());
|
2018-11-20 14:53:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestToshibaACClass, MessageConstuction) {
|
2020-07-29 12:57:44 +01:00
|
|
|
IRToshibaAC ac(kGpioUnused);
|
|
|
|
ac.begin();
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.on();
|
|
|
|
ac.setFan(1);
|
|
|
|
ac.setMode(kToshibaAcCool);
|
|
|
|
ac.setTemp(27);
|
2018-11-20 14:53:56 +00:00
|
|
|
|
|
|
|
// Check everything for kicks.
|
2020-07-29 12:57:44 +01:00
|
|
|
EXPECT_EQ(1, ac.getFan());
|
|
|
|
EXPECT_EQ(kToshibaAcCool, ac.getMode());
|
|
|
|
EXPECT_EQ(27, ac.getTemp());
|
|
|
|
EXPECT_TRUE(ac.getPower());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
|
|
|
// Turn off the power and re-check.
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setPower(false);
|
2018-11-20 14:53:56 +00:00
|
|
|
// Check everything for kicks.
|
2020-07-29 12:57:44 +01:00
|
|
|
EXPECT_EQ(1, ac.getFan());
|
|
|
|
EXPECT_EQ(kToshibaAcCool, ac.getMode());
|
|
|
|
EXPECT_EQ(27, ac.getTemp());
|
|
|
|
EXPECT_FALSE(ac.getPower());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
|
|
|
// Turn the power back on, and check nothing changed.
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.on();
|
2018-11-20 14:53:56 +00:00
|
|
|
|
2020-07-29 12:57:44 +01:00
|
|
|
EXPECT_EQ(1, ac.getFan());
|
|
|
|
EXPECT_EQ(kToshibaAcCool, ac.getMode());
|
|
|
|
EXPECT_EQ(27, ac.getTemp());
|
|
|
|
EXPECT_TRUE(ac.getPower());
|
2018-11-20 14:53:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Decoding a message we entirely constructed based solely on a given state.
|
|
|
|
TEST(TestDecodeToshibaAC, SyntheticExample) {
|
2020-07-29 12:57:44 +01:00
|
|
|
IRsendTest irsend(kGpioUnused);
|
|
|
|
IRrecv irrecv(kGpioUnused);
|
2018-11-20 14:53:56 +00:00
|
|
|
irsend.begin();
|
|
|
|
|
|
|
|
uint8_t expectedState[kToshibaACStateLength] = {0xF2, 0x0D, 0x03, 0xFC, 0x01,
|
|
|
|
0x00, 0x00, 0x00, 0x01};
|
|
|
|
|
|
|
|
irsend.reset();
|
|
|
|
irsend.sendToshibaAC(expectedState);
|
|
|
|
irsend.makeDecodeResult();
|
|
|
|
EXPECT_TRUE(irrecv.decode(&irsend.capture));
|
|
|
|
ASSERT_EQ(TOSHIBA_AC, irsend.capture.decode_type);
|
|
|
|
ASSERT_EQ(kToshibaACBits, irsend.capture.bits);
|
|
|
|
EXPECT_STATE_EQ(expectedState, irsend.capture.state, irsend.capture.bits);
|
2020-04-09 09:25:50 +01:00
|
|
|
EXPECT_EQ(
|
2020-07-29 12:57:44 +01:00
|
|
|
"Temp: 17C, Power: On, Mode: 0 (Auto), Fan: 0 (Auto), Turbo: Off, "
|
|
|
|
"Econo: Off",
|
2020-04-09 09:25:50 +01:00
|
|
|
IRAcUtils::resultAcToString(&irsend.capture));
|
|
|
|
stdAc::state_t r, p;
|
|
|
|
ASSERT_TRUE(IRAcUtils::decodeToState(&irsend.capture, &r, &p));
|
2018-11-20 14:53:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Test decoding against captures from a real Toshiba A/C remote.
|
|
|
|
// Recorded by @mwildbolz
|
|
|
|
TEST(TestDecodeToshibaAC, RealExamples) {
|
2020-07-29 12:57:44 +01:00
|
|
|
IRToshibaAC ac(kGpioUnused);
|
|
|
|
IRsendTest irsend(kGpioUnused);
|
|
|
|
IRrecv irrecv(kGpioUnused);
|
2018-11-20 14:53:56 +00:00
|
|
|
irsend.begin();
|
|
|
|
|
|
|
|
uint16_t rawData1[295] = {
|
|
|
|
4442, 4292, 612, 1544, 616, 1544, 616, 1544, 612, 1548, 610, 468,
|
|
|
|
612, 468, 662, 1494, 640, 438, 616, 464, 614, 464, 616, 464,
|
|
|
|
612, 468, 610, 1544, 616, 1544, 616, 468, 612, 1544, 616, 464,
|
|
|
|
694, 386, 616, 464, 612, 468, 612, 468, 636, 444, 610, 1546,
|
|
|
|
616, 1544, 612, 1546, 614, 1546, 616, 1546, 740, 1420, 612, 1544,
|
|
|
|
616, 1546, 616, 464, 610, 468, 610, 470, 612, 468, 610, 468,
|
|
|
|
610, 470, 636, 438, 616, 464, 616, 464, 616, 1546, 636, 442,
|
|
|
|
612, 1546, 614, 1544, 616, 464, 614, 464, 610, 468, 612, 468,
|
|
|
|
612, 468, 612, 468, 636, 440, 614, 464, 616, 464, 616, 464,
|
|
|
|
612, 468, 636, 442, 638, 442, 662, 418, 610, 464, 616, 464,
|
|
|
|
616, 464, 610, 468, 612, 468, 636, 444, 610, 468, 638, 438,
|
|
|
|
614, 1546, 612, 1548, 612, 470, 610, 468, 636, 442, 612, 468,
|
|
|
|
612, 1544, 612, 7396, 4442, 4292, 610, 1546, 616, 1544, 612, 1548,
|
|
|
|
612, 1546, 616, 464, 616, 464, 616, 1544, 612, 468, 662, 418,
|
|
|
|
610, 468, 638, 442, 638, 438, 616, 1546, 616, 1544, 612, 468,
|
|
|
|
610, 1546, 616, 464, 616, 464, 642, 438, 616, 464, 612, 468,
|
|
|
|
610, 470, 610, 1546, 616, 1544, 612, 1546, 616, 1546, 614, 1546,
|
|
|
|
612, 1550, 610, 1544, 616, 1546, 614, 464, 642, 438, 610, 468,
|
|
|
|
612, 468, 612, 468, 612, 468, 610, 468, 638, 438, 614, 464,
|
|
|
|
616, 1544, 636, 444, 636, 1520, 616, 1544, 616, 464, 616, 464,
|
|
|
|
612, 468, 612, 468, 612, 468, 612, 468, 612, 464, 612, 470,
|
|
|
|
636, 442, 638, 442, 612, 470, 692, 384, 614, 464, 616, 464,
|
|
|
|
612, 468, 610, 468, 612, 468, 610, 470, 610, 464, 616, 464,
|
|
|
|
616, 464, 616, 464, 610, 1550, 610, 1546, 640, 444, 688, 386,
|
|
|
|
616, 464, 612, 468, 612, 1544, 642};
|
|
|
|
|
|
|
|
irsend.reset();
|
|
|
|
irsend.sendRaw(rawData1, 295, 38000);
|
|
|
|
irsend.makeDecodeResult();
|
|
|
|
EXPECT_TRUE(irrecv.decode(&irsend.capture));
|
|
|
|
ASSERT_EQ(TOSHIBA_AC, irsend.capture.decode_type);
|
|
|
|
ASSERT_EQ(kToshibaACBits, irsend.capture.bits);
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setRaw(irsend.capture.state);
|
|
|
|
EXPECT_TRUE(ac.getPower());
|
|
|
|
EXPECT_EQ(23, ac.getTemp());
|
|
|
|
EXPECT_EQ(kToshibaAcFanAuto, ac.getFan());
|
|
|
|
EXPECT_EQ(kToshibaAcAuto, ac.getMode());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
|
|
|
uint16_t rawData2[295] = {
|
|
|
|
4500, 4236, 636, 1520, 642, 1520, 640, 1520, 664, 1492, 642, 440,
|
|
|
|
668, 412, 642, 1518, 638, 438, 666, 414, 640, 438, 642, 438,
|
|
|
|
638, 442, 642, 1516, 640, 1520, 642, 438, 642, 1520, 636, 438,
|
|
|
|
668, 412, 640, 440, 666, 412, 642, 438, 668, 412, 640, 1516,
|
|
|
|
668, 1492, 642, 1520, 666, 1494, 638, 1520, 642, 1520, 668, 1490,
|
|
|
|
666, 1494, 642, 438, 638, 438, 668, 412, 668, 412, 642, 438,
|
|
|
|
642, 438, 664, 412, 642, 438, 642, 438, 642, 1518, 642, 434,
|
|
|
|
668, 412, 642, 438, 668, 412, 692, 388, 666, 412, 642, 434,
|
|
|
|
642, 438, 642, 1518, 668, 412, 668, 412, 640, 438, 638, 438,
|
|
|
|
642, 438, 640, 438, 668, 1492, 642, 440, 666, 412, 640, 438,
|
|
|
|
642, 438, 642, 434, 668, 412, 668, 412, 666, 414, 666, 1494,
|
|
|
|
640, 438, 642, 434, 668, 412, 642, 438, 642, 438, 668, 412,
|
|
|
|
668, 414, 640, 7362, 4474, 4262, 642, 1518, 638, 1520, 640, 1520,
|
|
|
|
668, 1494, 640, 434, 642, 438, 640, 1520, 642, 438, 642, 438,
|
|
|
|
642, 438, 642, 438, 642, 434, 668, 1494, 642, 1518, 638, 442,
|
|
|
|
638, 1520, 642, 438, 642, 438, 668, 414, 664, 408, 642, 438,
|
|
|
|
668, 412, 642, 1520, 666, 1494, 642, 1514, 642, 1518, 642, 1520,
|
|
|
|
636, 1520, 668, 1494, 666, 1494, 638, 438, 666, 414, 640, 440,
|
|
|
|
666, 412, 668, 412, 668, 412, 642, 434, 668, 412, 668, 412,
|
|
|
|
668, 1494, 642, 438, 642, 434, 642, 438, 642, 438, 642, 438,
|
|
|
|
642, 438, 642, 434, 646, 434, 642, 1518, 668, 412, 642, 438,
|
|
|
|
642, 434, 666, 414, 640, 438, 642, 438, 642, 1518, 642, 438,
|
|
|
|
642, 434, 668, 412, 642, 438, 642, 438, 642, 438, 642, 438,
|
|
|
|
642, 438, 640, 1520, 636, 438, 642, 438, 642, 438, 666, 414,
|
|
|
|
668, 412, 642, 440, 640, 438, 640};
|
|
|
|
|
|
|
|
irsend.reset();
|
|
|
|
irsend.sendRaw(rawData2, 295, 38000);
|
|
|
|
irsend.makeDecodeResult();
|
|
|
|
EXPECT_TRUE(irrecv.decode(&irsend.capture));
|
|
|
|
ASSERT_EQ(TOSHIBA_AC, irsend.capture.decode_type);
|
|
|
|
ASSERT_EQ(kToshibaACBits, irsend.capture.bits);
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setRaw(irsend.capture.state);
|
|
|
|
EXPECT_TRUE(ac.getPower());
|
|
|
|
EXPECT_EQ(17, ac.getTemp());
|
|
|
|
EXPECT_EQ(3, ac.getFan());
|
|
|
|
EXPECT_EQ(kToshibaAcCool, ac.getMode());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
|
|
|
uint16_t rawData3[295] = {
|
|
|
|
4474, 4262, 642, 1514, 642, 1520, 642, 1520, 642, 1514, 642, 438,
|
|
|
|
642, 438, 642, 1520, 636, 438, 642, 438, 642, 438, 642, 438,
|
|
|
|
642, 438, 640, 1520, 638, 1520, 642, 438, 640, 1520, 642, 438,
|
|
|
|
642, 434, 642, 438, 642, 438, 642, 438, 668, 414, 636, 1520,
|
|
|
|
642, 1520, 642, 1514, 642, 1520, 642, 1520, 640, 1518, 638, 1520,
|
|
|
|
666, 1494, 642, 438, 642, 434, 642, 438, 640, 438, 642, 438,
|
|
|
|
642, 440, 640, 434, 642, 438, 642, 438, 642, 1520, 642, 438,
|
|
|
|
642, 1514, 642, 1520, 640, 1520, 636, 438, 642, 438, 642, 438,
|
|
|
|
666, 414, 642, 1520, 636, 1520, 642, 438, 642, 438, 640, 438,
|
|
|
|
642, 434, 642, 1518, 642, 1520, 642, 438, 642, 434, 640, 438,
|
|
|
|
642, 438, 642, 438, 642, 440, 642, 438, 668, 408, 642, 1520,
|
|
|
|
642, 438, 642, 1520, 638, 1518, 642, 438, 642, 438, 640, 1520,
|
|
|
|
640, 438, 642, 7362, 4474, 4262, 642, 1518, 638, 1520, 640, 1520,
|
|
|
|
642, 1520, 638, 438, 642, 438, 642, 1518, 642, 438, 638, 438,
|
|
|
|
642, 438, 642, 438, 642, 438, 642, 1514, 642, 1520, 642, 438,
|
|
|
|
666, 1490, 642, 438, 642, 438, 642, 440, 640, 438, 642, 434,
|
|
|
|
640, 438, 642, 1520, 642, 1520, 636, 1520, 642, 1520, 642, 1514,
|
|
|
|
642, 1518, 642, 1518, 640, 1516, 642, 438, 642, 438, 642, 438,
|
|
|
|
640, 438, 638, 442, 642, 434, 642, 440, 640, 438, 642, 438,
|
|
|
|
642, 1518, 642, 438, 642, 1514, 642, 1520, 642, 1518, 642, 438,
|
|
|
|
642, 432, 642, 438, 642, 438, 642, 1520, 642, 1514, 642, 438,
|
|
|
|
642, 438, 642, 438, 642, 438, 642, 1514, 642, 1520, 642, 438,
|
|
|
|
642, 438, 638, 438, 642, 438, 642, 438, 640, 440, 642, 438,
|
|
|
|
640, 434, 642, 1520, 642, 438, 640, 1520, 668, 1490, 666, 414,
|
|
|
|
640, 438, 642, 1520, 642, 438, 636};
|
|
|
|
|
|
|
|
irsend.reset();
|
|
|
|
irsend.sendRaw(rawData3, 295, 38000);
|
|
|
|
irsend.makeDecodeResult();
|
|
|
|
EXPECT_TRUE(irrecv.decode(&irsend.capture));
|
|
|
|
ASSERT_EQ(TOSHIBA_AC, irsend.capture.decode_type);
|
|
|
|
ASSERT_EQ(kToshibaACBits, irsend.capture.bits);
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setRaw(irsend.capture.state);
|
|
|
|
EXPECT_TRUE(ac.getPower());
|
|
|
|
EXPECT_EQ(24, ac.getTemp());
|
|
|
|
EXPECT_EQ(kToshibaAcFanMax, ac.getFan());
|
|
|
|
EXPECT_EQ(kToshibaAcHeat, ac.getMode());
|
2018-11-20 14:53:56 +00:00
|
|
|
|
|
|
|
uint16_t rawData4[295] = {
|
|
|
|
4474, 4262, 636, 1520, 640, 1520, 640, 1520, 638, 1518, 642, 438,
|
|
|
|
642, 438, 642, 1520, 636, 438, 642, 438, 642, 438, 642, 438,
|
|
|
|
636, 444, 636, 1520, 640, 1520, 642, 438, 638, 1524, 638, 438,
|
|
|
|
640, 438, 642, 438, 640, 438, 642, 438, 638, 438, 642, 1518,
|
|
|
|
642, 1520, 666, 1494, 636, 1520, 640, 1520, 640, 1520, 636, 1524,
|
|
|
|
638, 1520, 640, 440, 640, 438, 642, 438, 636, 444, 636, 438,
|
|
|
|
642, 438, 640, 440, 640, 438, 642, 438, 642, 1518, 638, 438,
|
|
|
|
642, 1518, 642, 438, 640, 1520, 636, 444, 636, 438, 640, 438,
|
|
|
|
642, 438, 668, 1494, 640, 438, 642, 1518, 636, 444, 636, 438,
|
|
|
|
640, 1520, 642, 1518, 642, 1520, 636, 444, 636, 438, 642, 438,
|
|
|
|
642, 438, 640, 440, 640, 438, 640, 440, 640, 438, 640, 1518,
|
|
|
|
642, 1520, 636, 1524, 636, 1518, 642, 438, 642, 1518, 642, 1518,
|
|
|
|
640, 438, 642, 7364, 4472, 4262, 642, 1518, 642, 1518, 638, 1518,
|
|
|
|
642, 1520, 642, 438, 642, 438, 640, 1520, 636, 440, 640, 438,
|
|
|
|
642, 438, 640, 438, 642, 438, 642, 1518, 636, 1524, 636, 438,
|
|
|
|
640, 1520, 642, 438, 642, 438, 640, 438, 636, 444, 636, 438,
|
|
|
|
668, 412, 642, 1518, 642, 1520, 642, 1520, 636, 1518, 642, 1518,
|
|
|
|
642, 1520, 636, 1520, 668, 1494, 642, 438, 636, 444, 664, 412,
|
|
|
|
642, 438, 668, 412, 642, 438, 636, 442, 638, 442, 638, 438,
|
|
|
|
642, 1518, 642, 438, 642, 1518, 638, 438, 642, 1518, 642, 440,
|
|
|
|
640, 438, 636, 444, 636, 444, 636, 1520, 642, 438, 642, 1520,
|
|
|
|
636, 444, 636, 438, 642, 1520, 640, 1520, 636, 1520, 668, 412,
|
|
|
|
642, 438, 642, 438, 642, 438, 638, 442, 636, 438, 642, 438,
|
|
|
|
668, 412, 640, 1520, 638, 1524, 636, 1520, 642, 1520, 636, 444,
|
|
|
|
638, 1522, 638, 1518, 640, 438, 642};
|
|
|
|
|
|
|
|
irsend.reset();
|
|
|
|
irsend.sendRaw(rawData4, 295, 38000);
|
|
|
|
irsend.makeDecodeResult();
|
|
|
|
EXPECT_TRUE(irrecv.decode(&irsend.capture));
|
|
|
|
ASSERT_EQ(TOSHIBA_AC, irsend.capture.decode_type);
|
|
|
|
ASSERT_EQ(kToshibaACBits, irsend.capture.bits);
|
2020-07-29 12:57:44 +01:00
|
|
|
ac.setRaw(irsend.capture.state);
|
|
|
|
EXPECT_FALSE(ac.getPower());
|
|
|
|
EXPECT_EQ(22, ac.getTemp());
|
|
|
|
EXPECT_EQ(4, ac.getFan());
|
2018-11-20 14:53:56 +00:00
|
|
|
}
|
2019-07-21 15:01:43 +01:00
|
|
|
|
|
|
|
TEST(TestToshibaACClass, toCommon) {
|
|
|
|
IRToshibaAC ac(0);
|
|
|
|
ac.setPower(true);
|
|
|
|
ac.setMode(kToshibaAcCool);
|
|
|
|
ac.setTemp(20);
|
|
|
|
ac.setFan(kToshibaAcFanMax);
|
|
|
|
// Now test it.
|
|
|
|
ASSERT_EQ(decode_type_t::TOSHIBA_AC, ac.toCommon().protocol);
|
|
|
|
ASSERT_EQ(-1, ac.toCommon().model);
|
|
|
|
ASSERT_TRUE(ac.toCommon().power);
|
|
|
|
ASSERT_TRUE(ac.toCommon().celsius);
|
|
|
|
ASSERT_EQ(20, ac.toCommon().degrees);
|
|
|
|
ASSERT_EQ(stdAc::opmode_t::kCool, ac.toCommon().mode);
|
|
|
|
ASSERT_EQ(stdAc::fanspeed_t::kMax, ac.toCommon().fanspeed);
|
|
|
|
// Unsupported.
|
|
|
|
ASSERT_EQ(stdAc::swingv_t::kOff, ac.toCommon().swingv);
|
|
|
|
ASSERT_EQ(stdAc::swingh_t::kOff, ac.toCommon().swingh);
|
|
|
|
ASSERT_FALSE(ac.toCommon().turbo);
|
|
|
|
ASSERT_FALSE(ac.toCommon().econo);
|
|
|
|
ASSERT_FALSE(ac.toCommon().light);
|
|
|
|
ASSERT_FALSE(ac.toCommon().filter);
|
|
|
|
ASSERT_FALSE(ac.toCommon().clean);
|
|
|
|
ASSERT_FALSE(ac.toCommon().beep);
|
|
|
|
ASSERT_FALSE(ac.toCommon().quiet);
|
|
|
|
ASSERT_EQ(-1, ac.toCommon().sleep);
|
|
|
|
ASSERT_EQ(-1, ac.toCommon().clock);
|
|
|
|
}
|
2020-07-29 12:57:44 +01:00
|
|
|
|
|
|
|
// Tests for CarrierAc2
|
|
|
|
/// Decode a "real" long example message.
|
|
|
|
TEST(TestDecodeToshibaAC, RealLongExample) {
|
|
|
|
IRsendTest irsend(kGpioUnused);
|
|
|
|
IRrecv irrecv(kGpioUnused);
|
|
|
|
irsend.begin();
|
|
|
|
|
|
|
|
irsend.reset();
|
|
|
|
// Data from:
|
|
|
|
// https://github.com/crankyoldgit/IRremoteESP8266/issues/1205#issuecomment-650475434
|
|
|
|
const uint16_t high_power_on[327] = {
|
|
|
|
4424, 4320,
|
|
|
|
582, 1574, 588, 1578, 582, 1574, 586, 1578, 586, 496, 582, 492, 586, 1576,
|
|
|
|
586, 492, 586, 492, 588, 496, 584, 496, 584, 496, 584, 1626, 534, 1626,
|
|
|
|
534, 494, 586, 1578, 582, 494, 586, 494, 586, 494, 588, 492, 586, 492,
|
|
|
|
586, 1576, 586, 494, 588, 492, 588, 1574, 588, 1576, 584, 1578, 584, 1574,
|
|
|
|
588, 1574, 588, 492, 588, 1572, 590, 1570, 590, 492, 588, 492, 590, 488,
|
|
|
|
590, 494, 584, 1570, 592, 492, 586, 490, 590, 1572, 590, 490, 590, 1570,
|
|
|
|
590, 490, 590, 1570, 590, 492, 588, 490, 588, 492, 588, 492, 590, 490,
|
|
|
|
590, 494, 586, 490, 590, 490, 588, 490, 590, 490, 588, 492, 590, 490,
|
|
|
|
588, 492, 590, 490, 590, 490, 590, 494, 584, 490, 590, 490, 590, 490,
|
|
|
|
590, 490, 588, 490, 588, 492, 588, 492, 586, 492, 588, 490, 588, 492,
|
|
|
|
588, 490, 590, 1572, 588, 494, 586, 1574, 588, 492, 588, 1572, 590, 1572,
|
|
|
|
588, 492, 588, 492, 586, 494, 588,
|
|
|
|
7422,
|
|
|
|
4424, 4320,
|
|
|
|
586, 1572, 588, 1572, 588, 1576, 584, 1574, 588, 494, 586, 492, 588, 1572,
|
|
|
|
588, 492, 588, 492, 588, 492, 588, 494, 586, 496, 584, 1574, 586, 1578,
|
|
|
|
582, 494, 586, 1578, 584, 494, 586, 492, 588, 492, 586, 496, 584, 494,
|
|
|
|
586, 1578, 584, 494, 586, 494, 584, 1574, 588, 1572, 586, 1574, 588, 1574,
|
|
|
|
588, 1572, 588, 494, 590, 1572, 588, 1574, 588, 492, 588, 492, 588, 492,
|
|
|
|
586, 492, 588, 1572, 588, 498, 582, 492, 588, 1576, 586, 492, 588, 1572,
|
|
|
|
588, 494, 588, 1572, 588, 492, 586, 492, 588, 492, 590, 490, 588, 492,
|
|
|
|
586, 492, 588, 492, 590, 490, 588, 490, 588, 492, 590, 490, 588, 492,
|
|
|
|
590, 490, 588, 490, 590, 490, 590, 490, 592, 488, 592, 494, 584, 494,
|
|
|
|
586, 490, 590, 494, 586, 494, 588, 488, 592, 490, 588, 492, 586, 490,
|
|
|
|
592, 490, 588, 1576, 584, 494, 586, 1570, 590, 494, 586, 1576, 582, 1572,
|
|
|
|
590, 490, 590, 490, 588, 490, 590}; // UNKNOWN 54926187
|
|
|
|
|
|
|
|
const uint8_t expectedState[kToshibaACStateLengthLong] = {
|
|
|
|
0xF2, 0x0D, 0x04, 0xFB, 0x09, 0x50, 0x00, 0x00, 0x01, 0x58};
|
|
|
|
irsend.sendRaw(high_power_on, 327, 38000);
|
|
|
|
irsend.makeDecodeResult();
|
|
|
|
ASSERT_TRUE(irrecv.decode(&irsend.capture));
|
|
|
|
EXPECT_EQ(decode_type_t::TOSHIBA_AC, irsend.capture.decode_type);
|
|
|
|
EXPECT_EQ(kToshibaACBitsLong, irsend.capture.bits);
|
|
|
|
EXPECT_STATE_EQ(expectedState, irsend.capture.state, irsend.capture.bits);
|
|
|
|
EXPECT_EQ(
|
|
|
|
"Temp: 22C, Power: On, Mode: 0 (Auto), Fan: 0 (Auto), Turbo: On, "
|
|
|
|
"Econo: Off",
|
|
|
|
IRAcUtils::resultAcToString(&irsend.capture));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Decode a synthetic long message.
|
|
|
|
TEST(TestDecodeToshibaAC, SyntheticLongExample) {
|
|
|
|
IRsendTest irsend(0);
|
|
|
|
IRrecv irrecv(0);
|
|
|
|
|
|
|
|
const uint8_t expectedState[kToshibaACStateLengthLong] = {
|
|
|
|
0xF2, 0x0D, 0x04, 0xFB, 0x09, 0x50, 0x00, 0x00, 0x01, 0x58};
|
|
|
|
irsend.begin();
|
|
|
|
irsend.reset();
|
|
|
|
irsend.sendToshibaAC(expectedState, kToshibaACStateLengthLong);
|
|
|
|
irsend.makeDecodeResult();
|
|
|
|
ASSERT_TRUE(irrecv.decode(&irsend.capture));
|
|
|
|
EXPECT_EQ(decode_type_t::TOSHIBA_AC, irsend.capture.decode_type);
|
|
|
|
EXPECT_EQ(kToshibaACBitsLong, irsend.capture.bits);
|
|
|
|
EXPECT_STATE_EQ(expectedState, irsend.capture.state, irsend.capture.bits);
|
|
|
|
EXPECT_EQ(
|
|
|
|
"f38000d50"
|
|
|
|
// 4424 4320
|
|
|
|
"m4400s4300"
|
|
|
|
// 582 1574 588 1578 582 1574 586 1578 586 496 582 492 586 1576 586 492
|
|
|
|
"m580s1600m580s1600m580s1600m580s1600m580s490m580s490m580s1600m580s490"
|
|
|
|
// 586 492 588 496 584 496 584 496 584 1626 534 1626 534 494 586 1578
|
|
|
|
"m580s490m580s490m580s490m580s490m580s1600m580s1600m580s490m580s1600"
|
|
|
|
// 582 494 586 494 586 494 588 492 586 492 586 1576 586 494 588 492
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s1600m580s490m580s490"
|
|
|
|
// 588 1574 588 1576 584 1578 584 1574 588 1574 588 492 588 1572 590 1570
|
|
|
|
"m580s1600m580s1600m580s1600m580s1600m580s1600m580s490m580s1600m580s1600"
|
|
|
|
// 590 492 588 492 590 488 590 494 584 1570 592 492 586 490 590 1572
|
|
|
|
"m580s490m580s490m580s490m580s490m580s1600m580s490m580s490m580s1600"
|
|
|
|
// 590 490 590 1570 590 490 590 1570 590 492 588 490 588 492 588 492
|
|
|
|
"m580s490m580s1600m580s490m580s1600m580s490m580s490m580s490m580s490"
|
|
|
|
// 590 490 590 494 586 490 590 490 588 490 590 490 588 492 590 490
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
// 588 492 590 490 590 490 590 494 584 490 590 490 590 490 590 490
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
// 588 490 588 492 588 492 586 492 588 490 588 492 588 490 590 1572
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s1600"
|
|
|
|
// 588 494 586 1574 588 492 588 1572 590 1572 588 492 588 492 586 494
|
|
|
|
"m580s490m580s1600m580s490m580s1600m580s1600m580s490m580s490m580s490"
|
|
|
|
// 588 7422
|
|
|
|
"m580s7400"
|
|
|
|
"m4400s4300"
|
|
|
|
"m580s1600m580s1600m580s1600m580s1600m580s490m580s490m580s1600m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s1600m580s1600m580s490m580s1600"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s1600m580s490m580s490"
|
|
|
|
"m580s1600m580s1600m580s1600m580s1600m580s1600m580s490m580s1600m580s1600"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s1600m580s490m580s490m580s1600"
|
|
|
|
"m580s490m580s1600m580s490m580s1600m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s490"
|
|
|
|
"m580s490m580s490m580s490m580s490m580s490m580s490m580s490m580s1600"
|
|
|
|
"m580s490m580s1600m580s490m580s1600m580s1600m580s490m580s490m580s490"
|
|
|
|
"m580s7400",
|
|
|
|
irsend.outputStr());
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Decode a "real" short example message.
|
|
|
|
TEST(TestDecodeToshibaAC, RealShortExample) {
|
|
|
|
IRsendTest irsend(kGpioUnused);
|
|
|
|
IRrecv irrecv(kGpioUnused);
|
|
|
|
irsend.begin();
|
|
|
|
|
|
|
|
irsend.reset();
|
|
|
|
// Data from:
|
|
|
|
// https://github.com/crankyoldgit/IRremoteESP8266/issues/1205#issuecomment-650475096
|
|
|
|
const uint16_t air_direction[115] = {
|
|
|
|
4424, 4318,
|
|
|
|
588, 1574, 588, 1572, 588, 1574, 586, 1572, 590, 490, 586, 494, 586, 1574,
|
|
|
|
588, 492, 586, 494, 586, 494, 586, 496, 584, 492, 588, 1572, 588, 1572,
|
|
|
|
590, 492, 588, 1572, 590, 490, 588, 492, 586, 494, 588, 492, 588, 492,
|
|
|
|
588, 494, 584, 492, 588, 1572, 588, 1574, 588, 1574, 588, 1572, 588, 1572,
|
|
|
|
588, 1572, 588, 1574, 590, 1570, 588, 494, 586, 496, 584, 494, 588, 1572,
|
|
|
|
588, 492, 588, 492, 588, 490, 588, 492, 590, 1572, 588, 492, 588, 496,
|
|
|
|
586, 492, 588, 492, 586, 492, 588, 492, 588, 490, 590, 490, 588, 492,
|
|
|
|
588, 490, 588, 1572, 588, 492, 588, 492, 588, 490, 588, 492, 588, 1572,
|
|
|
|
586}; // UNKNOWN DEB8845C
|
|
|
|
const uint8_t expectedState[kToshibaACStateLengthShort] = {
|
|
|
|
0xF2, 0x0D, 0x01, 0xFE, 0x21, 0x00, 0x21};
|
|
|
|
irsend.sendRaw(air_direction, 115, 38000);
|
|
|
|
irsend.makeDecodeResult();
|
|
|
|
ASSERT_TRUE(irrecv.decode(&irsend.capture));
|
|
|
|
EXPECT_EQ(decode_type_t::TOSHIBA_AC, irsend.capture.decode_type);
|
|
|
|
EXPECT_EQ(kToshibaACBitsShort, irsend.capture.bits);
|
|
|
|
EXPECT_STATE_EQ(expectedState, irsend.capture.state, irsend.capture.bits);
|
|
|
|
EXPECT_EQ(
|
|
|
|
"Temp: 17C, Swing(V): 0 (Step)",
|
|
|
|
IRAcUtils::resultAcToString(&irsend.capture));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestToshibaACClass, ConstructLongState) {
|
|
|
|
IRToshibaAC ac(kGpioUnused);
|
|
|
|
ac.setPower(true);
|
|
|
|
ac.setMode(kToshibaAcDry);
|
|
|
|
ac.setTemp(29);
|
|
|
|
ac.setFan(2);
|
|
|
|
ac.setSwing(false);
|
|
|
|
ac.setTurbo(false);
|
|
|
|
ac.setEcono(true);
|
|
|
|
EXPECT_EQ(
|
|
|
|
"Temp: 29C, Power: On, Mode: 2 (Dry), Fan: 2 (UNKNOWN), "
|
|
|
|
"Turbo: Off, Econo: On",
|
|
|
|
ac.toString());
|
|
|
|
EXPECT_EQ(kToshibaACStateLengthLong, ac.getStateLength());
|
|
|
|
const uint8_t expectedState[kToshibaACStateLengthLong] = {
|
|
|
|
0xF2, 0x0D, 0x04, 0xFB, 0x09, 0xC0, 0x62, 0x00, 0x03, 0xA8};
|
|
|
|
EXPECT_STATE_EQ(expectedState, ac.getRaw(), kToshibaACBitsLong);
|
|
|
|
EXPECT_EQ(kToshibaACStateLengthLong, ac.getStateLength());
|
|
|
|
}
|