Skip to content

Commit

Permalink
[BUG] defaultBits() returned incorrect result for PANASONIC_AC (#…
Browse files Browse the repository at this point in the history
…1314)

* Use the correct value.
* Add unit tests to make sure it doesn't happen again for Panasonic.
* Kudos to @taxx for finding the mistake.

For #1307
  • Loading branch information
crankyoldgit authored Oct 27, 2020
1 parent b77b0e1 commit 18c725d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/IRsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ uint16_t IRsend::defaultBits(const decode_type_t protocol) {
case NEOCLIMA:
return kNeoclimaBits;
case PANASONIC_AC:
return kNeoclimaBits;
return kPanasonicAcBits;
case SAMSUNG_AC:
return kSamsungAcBits;
case SANYO_AC:
Expand Down
19 changes: 19 additions & 0 deletions test/ir_Panasonic_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "IRrecv_test.h"
#include "IRsend.h"
#include "IRsend_test.h"
#include "IRtext.h"
#include "IRutils.h"
#include "gtest/gtest.h"

Expand Down Expand Up @@ -1250,3 +1251,21 @@ TEST(TestDecodePanasonicAC, DkeIonRealMessages) {
"Ion: On, Clock: 00:00, On Timer: 00:00, Off Timer: 00:00",
ac.toString());
}

// General housekeeping
TEST(TestPanasonic, Housekeeping) {
// Simple Panasonic protocol. e.g. TVs etc.
ASSERT_EQ(D_STR_PANASONIC, typeToString(decode_type_t::PANASONIC));
ASSERT_FALSE(hasACState(decode_type_t::PANASONIC));
ASSERT_EQ(decode_type_t::PANASONIC, strToDecodeType(D_STR_PANASONIC));
ASSERT_FALSE(IRac::isProtocolSupported(decode_type_t::PANASONIC));
ASSERT_EQ(kPanasonicBits, IRsend::defaultBits(decode_type_t::PANASONIC));
ASSERT_EQ(kNoRepeat, IRsend::minRepeats(decode_type_t::PANASONIC));
// Panasonic A/Cs
ASSERT_EQ(D_STR_PANASONIC_AC, typeToString(decode_type_t::PANASONIC_AC));
ASSERT_TRUE(hasACState(decode_type_t::PANASONIC_AC));
ASSERT_EQ(decode_type_t::PANASONIC_AC, strToDecodeType(D_STR_PANASONIC_AC));
ASSERT_TRUE(IRac::isProtocolSupported(decode_type_t::PANASONIC_AC));
ASSERT_EQ(kPanasonicAcBits, IRsend::defaultBits(decode_type_t::PANASONIC_AC));
ASSERT_EQ(kNoRepeat, IRsend::minRepeats(decode_type_t::PANASONIC_AC));
}

0 comments on commit 18c725d

Please sign in to comment.