Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/ir_Toshiba.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 David Conran
// Copyright 2017-2021 David Conran

/// @file
/// @brief Support for Toshiba protocols.
Expand Down Expand Up @@ -27,7 +27,10 @@ const uint16_t kToshibaAcHdrSpace = 4300;
const uint16_t kToshibaAcBitMark = 580;
const uint16_t kToshibaAcOneSpace = 1600;
const uint16_t kToshibaAcZeroSpace = 490;
const uint16_t kToshibaAcMinGap = 7400;
// Some models have a different inter-message gap.
// See: https://github.com/crankyoldgit/IRremoteESP8266/issues/1420
const uint16_t kToshibaAcMinGap = 4600; // WH-UB03NJ remote
const uint16_t kToshibaAcUsualGap = 7400; // Others

using irutils::addBoolToString;
using irutils::addFanToString;
Expand All @@ -48,7 +51,7 @@ void IRsend::sendToshibaAC(const uint8_t data[], const uint16_t nbytes,
const uint16_t repeat) {
sendGeneric(kToshibaAcHdrMark, kToshibaAcHdrSpace, kToshibaAcBitMark,
kToshibaAcOneSpace, kToshibaAcBitMark, kToshibaAcZeroSpace,
kToshibaAcBitMark, kToshibaAcMinGap, data, nbytes, 38, true,
kToshibaAcBitMark, kToshibaAcUsualGap, data, nbytes, 38, true,
repeat, 50);
}
#endif // SEND_TOSHIBA_AC
Expand Down
2 changes: 2 additions & 0 deletions src/ir_Toshiba.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// Brand: Toshiba, Model: RAS 18SKP-ES
// Brand: Toshiba, Model: WH-TA04NE
// Brand: Toshiba, Model: WC-L03SE
// Brand: Toshiba, Model: WH-UB03NJ remote
// Brand: Toshiba, Model: RAS-2558V A/C
// Brand: Carrier, Model: 42NQV060M2 / 38NYV060M2 A/C
// Brand: Carrier, Model: 42NQV050M2 / 38NYV050M2 A/C
// Brand: Carrier, Model: 42NQV035M2 / 38NYV035M2 A/C
Expand Down
60 changes: 57 additions & 3 deletions test/ir_Toshiba_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ TEST(TestDecodeToshibaAC, RealExamples) {
}

TEST(TestToshibaACClass, toCommon) {
IRToshibaAC ac(0);
IRToshibaAC ac(kGpioUnused);
ac.setPower(true);
ac.setMode(kToshibaAcCool);
ac.setTemp(20);
Expand Down Expand Up @@ -633,8 +633,8 @@ TEST(TestDecodeToshibaAC, RealLongExample) {

/// Decode a synthetic long message.
TEST(TestDecodeToshibaAC, SyntheticLongExample) {
IRsendTest irsend(0);
IRrecv irrecv(0);
IRsendTest irsend(kGpioUnused);
IRrecv irrecv(kGpioUnused);

const uint8_t expectedState[kToshibaACStateLengthLong] = {
0xF2, 0x0D, 0x04, 0xFB, 0x09, 0x50, 0x00, 0x00, 0x01, 0x58};
Expand Down Expand Up @@ -739,3 +739,57 @@ TEST(TestToshibaACClass, ConstructLongState) {
EXPECT_STATE_EQ(expectedState, ac.getRaw(), kToshibaACBitsLong);
EXPECT_EQ(kToshibaACStateLengthLong, ac.getStateLength());
}

// Decode a real WH-UB03NJ message.
TEST(TestDecodeToshibaAC, RealExample_WHUB03NJ) {
IRsendTest irsend(kGpioUnused);
IRrecv irrecv(kGpioUnused);
irsend.begin();

irsend.reset();
// Data from:
// https://github.com/crankyoldgit/IRremoteESP8266/issues/1420#issue-817430242
const uint16_t rawData[295] = {4438, 4364, 558, 1604, 558, 1580, 580, 1604,
558, 1580, 582, 522, 556, 500, 580, 1582, 580, 500, 580, 498, 582, 498,
582, 498, 580, 500, 582, 1582, 580, 1582, 582, 500, 582, 1580, 582, 520,
558, 522, 558, 496, 582, 524, 560, 520, 556, 500, 582, 1604, 558, 1584,
580, 1582, 580, 1582, 582, 1580, 582, 1580, 582, 1580, 582, 1582, 580,
522, 556, 524, 556, 500, 580, 522, 560, 498, 582, 522, 558, 500, 554, 524,
582, 498, 580, 1582, 580, 500, 582, 496, 582, 1582, 582, 1604, 558, 524,
558, 522, 560, 498, 580, 500, 582, 498, 582, 522, 558, 498, 582, 520, 558,
500, 528, 1634, 580, 1584, 578, 1582, 582, 496, 584, 496, 582, 498, 582,
498, 582, 498, 582, 500, 582, 522, 558, 498, 584, 498, 582, 496, 582,
1580, 582, 1604, 558, 500, 582, 1580, 554, 1608, 580, 500, 580,
4630, 4416, 4316, 606, 1604, 558, 1580, 580, 1606, 556, 1604, 558, 500,
580, 498, 554, 1606, 582, 498, 582, 498, 584, 496, 584, 498, 582, 522,
558, 1586, 556, 1608, 580, 498, 584, 1580, 580, 500, 582, 498, 582, 500,
582, 498, 580, 498, 582, 522, 558, 1580, 554, 1610, 580, 1604, 532, 1606,
582, 1604, 558, 1604, 560, 1582, 580, 1582, 554, 548, 560, 498, 582, 500,
580, 500, 580, 500, 582, 520, 558, 500, 580, 524, 558, 498, 582, 1582,
582, 498, 580, 522, 532, 1608, 582, 1604, 558, 498, 582, 522, 556, 500,
580, 500, 582, 498, 582, 522, 560, 496, 582, 500, 582, 498, 582, 1604,
558, 1604, 558, 1604, 560, 496, 582, 522, 558, 500, 580, 500, 582, 500,
554, 524, 582, 500, 580, 500, 582, 498, 554, 524, 582, 1604, 558, 1582,
582, 496, 582, 1582, 580, 1604, 558, 500, 580}; // TOSHIBA_AC

const uint8_t expectedState[kToshibaACStateLength] = {
0xF2, 0x0D, 0x03, 0xFC, 0x01, 0x30, 0x07, 0x00, 0x36};
irsend.sendRaw(rawData, 295, 38000);
irsend.makeDecodeResult();
ASSERT_TRUE(irrecv.decode(&irsend.capture));
EXPECT_EQ(decode_type_t::TOSHIBA_AC, irsend.capture.decode_type);
EXPECT_EQ(kToshibaACBits, irsend.capture.bits);
EXPECT_STATE_EQ(expectedState, irsend.capture.state, irsend.capture.bits);
EXPECT_EQ(
"Temp: 20C, Power: Off, Fan: 0 (Auto), Turbo: Off, Econo: Off",
IRAcUtils::resultAcToString(&irsend.capture));
}

TEST(TestUtils, Housekeeping) {
ASSERT_EQ("TOSHIBA_AC", typeToString(decode_type_t::TOSHIBA_AC));
ASSERT_EQ(decode_type_t::TOSHIBA_AC, strToDecodeType("TOSHIBA_AC"));
ASSERT_TRUE(hasACState(decode_type_t::TOSHIBA_AC));
ASSERT_TRUE(IRac::isProtocolSupported(decode_type_t::TOSHIBA_AC));
ASSERT_EQ(kToshibaACBits, IRsend::defaultBits(decode_type_t::TOSHIBA_AC));
ASSERT_EQ(kSingleRepeat, IRsend::minRepeats(decode_type_t::TOSHIBA_AC));
}