2017-11-19 17:02:03 +00:00
|
|
|
// Copyright 2017 David Conran
|
|
|
|
|
|
|
|
#include "IRsend.h"
|
|
|
|
#include "IRsend_test.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
// Tests for sendDenon().
|
|
|
|
|
|
|
|
// Test sending typical data only.
|
|
|
|
TEST(TestSendDenon, SendDataOnly) {
|
|
|
|
IRsendTest irsend(4);
|
|
|
|
irsend.begin();
|
|
|
|
|
|
|
|
irsend.reset();
|
|
|
|
irsend.sendDenon(0x2278); // Denon AVR Power On. (Sharp)
|
|
|
|
EXPECT_EQ(
|
2019-05-27 13:11:01 +01:00
|
|
|
"f38000d33"
|
2017-11-19 17:02:03 +00:00
|
|
|
"m260s780m260s1820m260s780m260s780m260s780m260s1820m260s780m260s780"
|
|
|
|
"m260s1820m260s1820m260s1820m260s1820m260s780m260s780m260s780"
|
|
|
|
"m260s43602"
|
|
|
|
"m260s780m260s1820m260s780m260s780m260s780m260s780m260s1820m260s1820"
|
|
|
|
"m260s780m260s780m260s780m260s780m260s1820m260s1820m260s1820"
|
2018-11-20 14:53:56 +00:00
|
|
|
"m260s43602",
|
|
|
|
irsend.outputStr());
|
2017-11-19 17:02:03 +00:00
|
|
|
|
|
|
|
irsend.reset();
|
|
|
|
// Denon Eco Mode On. (Panasonic/Kaseikyo)
|
2019-07-21 15:01:43 +01:00
|
|
|
irsend.sendDenon(0x2A4C028D6CE3, kDenon48Bits);
|
2017-11-19 17:02:03 +00:00
|
|
|
EXPECT_EQ(
|
2019-05-27 13:11:01 +01:00
|
|
|
"f36700d50"
|
2017-11-19 17:02:03 +00:00
|
|
|
"m3456s1728"
|
|
|
|
"m432s432m432s432m432s1296m432s432m432s1296m432s432m432s1296m432s432"
|
|
|
|
"m432s432m432s1296m432s432m432s432m432s1296m432s1296m432s432m432s432"
|
|
|
|
"m432s432m432s432m432s432m432s432m432s432m432s432m432s1296m432s432"
|
|
|
|
"m432s1296m432s432m432s432m432s432m432s1296m432s1296m432s432m432s1296"
|
|
|
|
"m432s432m432s1296m432s1296m432s432m432s1296m432s1296m432s432m432s432"
|
|
|
|
"m432s1296m432s1296m432s1296m432s432m432s432m432s432m432s1296m432s1296"
|
2018-11-20 14:53:56 +00:00
|
|
|
"m432s98928",
|
|
|
|
irsend.outputStr());
|
2017-11-19 17:02:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Test sending with different repeats.
|
|
|
|
TEST(TestSendDenon, SendNormalWithRepeats) {
|
|
|
|
IRsendTest irsend(4);
|
|
|
|
irsend.begin();
|
|
|
|
|
|
|
|
irsend.reset();
|
2019-07-21 15:01:43 +01:00
|
|
|
irsend.sendDenon(0x2278, kDenonBits, 1); // 1 repeat.
|
2017-11-19 17:02:03 +00:00
|
|
|
EXPECT_EQ(
|
2019-05-27 13:11:01 +01:00
|
|
|
"f38000d33"
|
2017-11-19 17:02:03 +00:00
|
|
|
"m260s780m260s1820m260s780m260s780m260s780m260s1820m260s780m260s780"
|
|
|
|
"m260s1820m260s1820m260s1820m260s1820m260s780m260s780m260s780"
|
|
|
|
"m260s43602"
|
|
|
|
"m260s780m260s1820m260s780m260s780m260s780m260s780m260s1820m260s1820"
|
|
|
|
"m260s780m260s780m260s780m260s780m260s1820m260s1820m260s1820"
|
|
|
|
"m260s43602"
|
|
|
|
"m260s780m260s1820m260s780m260s780m260s780m260s1820m260s780m260s780"
|
|
|
|
"m260s1820m260s1820m260s1820m260s1820m260s780m260s780m260s780"
|
|
|
|
"m260s43602"
|
|
|
|
"m260s780m260s1820m260s780m260s780m260s780m260s780m260s1820m260s1820"
|
|
|
|
"m260s780m260s780m260s780m260s780m260s1820m260s1820m260s1820"
|
2018-11-20 14:53:56 +00:00
|
|
|
"m260s43602",
|
|
|
|
irsend.outputStr());
|
2019-07-21 15:01:43 +01:00
|
|
|
irsend.sendDenon(0x2278, kDenonBits, 2); // 2 repeats.
|
2017-11-19 17:02:03 +00:00
|
|
|
EXPECT_EQ(
|
2019-05-27 13:11:01 +01:00
|
|
|
"f38000d33"
|
2017-11-19 17:02:03 +00:00
|
|
|
"m260s780m260s1820m260s780m260s780m260s780m260s1820m260s780m260s780"
|
|
|
|
"m260s1820m260s1820m260s1820m260s1820m260s780m260s780m260s780"
|
|
|
|
"m260s43602"
|
|
|
|
"m260s780m260s1820m260s780m260s780m260s780m260s780m260s1820m260s1820"
|
|
|
|
"m260s780m260s780m260s780m260s780m260s1820m260s1820m260s1820"
|
|
|
|
"m260s43602"
|
|
|
|
"m260s780m260s1820m260s780m260s780m260s780m260s1820m260s780m260s780"
|
|
|
|
"m260s1820m260s1820m260s1820m260s1820m260s780m260s780m260s780"
|
|
|
|
"m260s43602"
|
|
|
|
"m260s780m260s1820m260s780m260s780m260s780m260s780m260s1820m260s1820"
|
|
|
|
"m260s780m260s780m260s780m260s780m260s1820m260s1820m260s1820"
|
|
|
|
"m260s43602"
|
|
|
|
"m260s780m260s1820m260s780m260s780m260s780m260s1820m260s780m260s780"
|
|
|
|
"m260s1820m260s1820m260s1820m260s1820m260s780m260s780m260s780"
|
|
|
|
"m260s43602"
|
|
|
|
"m260s780m260s1820m260s780m260s780m260s780m260s780m260s1820m260s1820"
|
|
|
|
"m260s780m260s780m260s780m260s780m260s1820m260s1820m260s1820"
|
2018-11-20 14:53:56 +00:00
|
|
|
"m260s43602",
|
|
|
|
irsend.outputStr());
|
2017-11-19 17:02:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestSendDenon, Send48BitWithRepeats) {
|
|
|
|
IRsendTest irsend(4);
|
|
|
|
irsend.begin();
|
|
|
|
|
|
|
|
irsend.reset();
|
2019-07-21 15:01:43 +01:00
|
|
|
irsend.sendDenon(0x2A4C028D6CE3, kDenon48Bits, 1); // 1 repeat.
|
2017-11-19 17:02:03 +00:00
|
|
|
EXPECT_EQ(
|
2019-05-27 13:11:01 +01:00
|
|
|
"f36700d50"
|
2017-11-19 17:02:03 +00:00
|
|
|
"m3456s1728"
|
|
|
|
"m432s432m432s432m432s1296m432s432m432s1296m432s432m432s1296m432s432"
|
|
|
|
"m432s432m432s1296m432s432m432s432m432s1296m432s1296m432s432m432s432"
|
|
|
|
"m432s432m432s432m432s432m432s432m432s432m432s432m432s1296m432s432"
|
|
|
|
"m432s1296m432s432m432s432m432s432m432s1296m432s1296m432s432m432s1296"
|
|
|
|
"m432s432m432s1296m432s1296m432s432m432s1296m432s1296m432s432m432s432"
|
|
|
|
"m432s1296m432s1296m432s1296m432s432m432s432m432s432m432s1296m432s1296"
|
2018-11-20 14:53:56 +00:00
|
|
|
"m432s98928"
|
2017-11-19 17:02:03 +00:00
|
|
|
"m3456s1728"
|
|
|
|
"m432s432m432s432m432s1296m432s432m432s1296m432s432m432s1296m432s432"
|
|
|
|
"m432s432m432s1296m432s432m432s432m432s1296m432s1296m432s432m432s432"
|
|
|
|
"m432s432m432s432m432s432m432s432m432s432m432s432m432s1296m432s432"
|
|
|
|
"m432s1296m432s432m432s432m432s432m432s1296m432s1296m432s432m432s1296"
|
|
|
|
"m432s432m432s1296m432s1296m432s432m432s1296m432s1296m432s432m432s432"
|
|
|
|
"m432s1296m432s1296m432s1296m432s432m432s432m432s432m432s1296m432s1296"
|
2018-11-20 14:53:56 +00:00
|
|
|
"m432s98928",
|
|
|
|
irsend.outputStr());
|
2019-07-21 15:01:43 +01:00
|
|
|
irsend.sendDenon(0x2A4C028D6CE3, kDenon48Bits, 2); // 2 repeats.
|
2017-11-19 17:02:03 +00:00
|
|
|
EXPECT_EQ(
|
2019-05-27 13:11:01 +01:00
|
|
|
"f36700d50"
|
2017-11-19 17:02:03 +00:00
|
|
|
"m3456s1728"
|
|
|
|
"m432s432m432s432m432s1296m432s432m432s1296m432s432m432s1296m432s432"
|
|
|
|
"m432s432m432s1296m432s432m432s432m432s1296m432s1296m432s432m432s432"
|
|
|
|
"m432s432m432s432m432s432m432s432m432s432m432s432m432s1296m432s432"
|
|
|
|
"m432s1296m432s432m432s432m432s432m432s1296m432s1296m432s432m432s1296"
|
|
|
|
"m432s432m432s1296m432s1296m432s432m432s1296m432s1296m432s432m432s432"
|
|
|
|
"m432s1296m432s1296m432s1296m432s432m432s432m432s432m432s1296m432s1296"
|
2018-11-20 14:53:56 +00:00
|
|
|
"m432s98928"
|
2017-11-19 17:02:03 +00:00
|
|
|
"m3456s1728"
|
|
|
|
"m432s432m432s432m432s1296m432s432m432s1296m432s432m432s1296m432s432"
|
|
|
|
"m432s432m432s1296m432s432m432s432m432s1296m432s1296m432s432m432s432"
|
|
|
|
"m432s432m432s432m432s432m432s432m432s432m432s432m432s1296m432s432"
|
|
|
|
"m432s1296m432s432m432s432m432s432m432s1296m432s1296m432s432m432s1296"
|
|
|
|
"m432s432m432s1296m432s1296m432s432m432s1296m432s1296m432s432m432s432"
|
|
|
|
"m432s1296m432s1296m432s1296m432s432m432s432m432s432m432s1296m432s1296"
|
2018-11-20 14:53:56 +00:00
|
|
|
"m432s98928"
|
2017-11-19 17:02:03 +00:00
|
|
|
"m3456s1728"
|
|
|
|
"m432s432m432s432m432s1296m432s432m432s1296m432s432m432s1296m432s432"
|
|
|
|
"m432s432m432s1296m432s432m432s432m432s1296m432s1296m432s432m432s432"
|
|
|
|
"m432s432m432s432m432s432m432s432m432s432m432s432m432s1296m432s432"
|
|
|
|
"m432s1296m432s432m432s432m432s432m432s1296m432s1296m432s432m432s1296"
|
|
|
|
"m432s432m432s1296m432s1296m432s432m432s1296m432s1296m432s432m432s432"
|
|
|
|
"m432s1296m432s1296m432s1296m432s432m432s432m432s432m432s1296m432s1296"
|
2018-11-20 14:53:56 +00:00
|
|
|
"m432s98928",
|
|
|
|
irsend.outputStr());
|
2017-11-19 17:02:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Test sending an atypical data size.
|
|
|
|
TEST(TestSendDenon, SendUnusualSize) {
|
|
|
|
IRsendTest irsend(4);
|
|
|
|
irsend.begin();
|
|
|
|
|
|
|
|
irsend.reset();
|
|
|
|
irsend.sendDenon(0x12, 8);
|
|
|
|
EXPECT_EQ(
|
2019-05-27 13:11:01 +01:00
|
|
|
"f38000d33"
|
2017-11-19 17:02:03 +00:00
|
|
|
"m260s780m260s780m260s780m260s1820m260s780m260s780m260s1820m260s780"
|
|
|
|
"m260s43602"
|
|
|
|
"m260s1820m260s1820m260s1820m260s780m260s1820m260s1820m260s780m260s1820"
|
2018-11-20 14:53:56 +00:00
|
|
|
"m260s43602",
|
|
|
|
irsend.outputStr());
|
2017-11-19 17:02:03 +00:00
|
|
|
|
|
|
|
irsend.reset();
|
|
|
|
irsend.sendDenon(0x1234567890ABCDEF, 64);
|
|
|
|
EXPECT_EQ(
|
2019-05-27 13:11:01 +01:00
|
|
|
"f36700d50"
|
2017-11-19 17:02:03 +00:00
|
|
|
"m3456s1728"
|
|
|
|
"m432s432m432s432m432s432m432s1296m432s432m432s432m432s1296m432s432"
|
|
|
|
"m432s432m432s432m432s1296m432s1296m432s432m432s1296m432s432m432s432"
|
|
|
|
"m432s432m432s1296m432s432m432s1296m432s432m432s1296m432s1296m432s432"
|
|
|
|
"m432s432m432s1296m432s1296m432s1296m432s1296m432s432m432s432m432s432"
|
|
|
|
"m432s1296m432s432m432s432m432s1296m432s432m432s432m432s432m432s432"
|
|
|
|
"m432s1296m432s432m432s1296m432s432m432s1296m432s432m432s1296m432s1296"
|
|
|
|
"m432s1296m432s1296m432s432m432s432m432s1296m432s1296m432s432m432s1296"
|
|
|
|
"m432s1296m432s1296m432s1296m432s432m432s1296m432s1296m432s1296m432s1296"
|
2018-11-20 14:53:56 +00:00
|
|
|
"m432s74736",
|
|
|
|
irsend.outputStr());
|
2017-11-19 17:02:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Tests for decodeDenon().
|
|
|
|
|
|
|
|
// Decode normal Denon messages.
|
|
|
|
TEST(TestDecodeDenon, NormalDecodeWithStrict) {
|
|
|
|
IRsendTest irsend(4);
|
|
|
|
IRrecv irrecv(4);
|
|
|
|
irsend.begin();
|
|
|
|
|
|
|
|
// Normal Denon 15-bit message. (Sharp)
|
|
|
|
irsend.reset();
|
|
|
|
irsend.sendDenon(0x2278);
|
|
|
|
irsend.makeDecodeResult();
|
|
|
|
|
2020-02-29 12:51:16 +00:00
|
|
|
ASSERT_TRUE(irrecv.decodeDenon(&irsend.capture, kStartOffset, kDenonBits,
|
|
|
|
true));
|
2017-11-19 17:02:03 +00:00
|
|
|
EXPECT_EQ(DENON, irsend.capture.decode_type);
|
2019-07-21 15:01:43 +01:00
|
|
|
EXPECT_EQ(kDenonBits, irsend.capture.bits);
|
2017-11-19 17:02:03 +00:00
|
|
|
EXPECT_EQ(0x2278, irsend.capture.value);
|
|
|
|
EXPECT_EQ(0x2, irsend.capture.address);
|
|
|
|
EXPECT_EQ(0x79, irsend.capture.command);
|
|
|
|
EXPECT_FALSE(irsend.capture.repeat);
|
|
|
|
|
|
|
|
// Legacy Denon 14-bit message.
|
|
|
|
irsend.reset();
|
2018-11-20 14:53:56 +00:00
|
|
|
irsend.sendDenon(0x1278, kDenonLegacyBits);
|
2017-11-19 17:02:03 +00:00
|
|
|
irsend.makeDecodeResult();
|
|
|
|
|
2020-02-29 12:51:16 +00:00
|
|
|
ASSERT_TRUE(irrecv.decodeDenon(&irsend.capture, kStartOffset,
|
|
|
|
kDenonLegacyBits, true));
|
2017-11-19 17:02:03 +00:00
|
|
|
EXPECT_EQ(DENON, irsend.capture.decode_type);
|
2018-11-20 14:53:56 +00:00
|
|
|
EXPECT_EQ(kDenonLegacyBits, irsend.capture.bits);
|
2017-11-19 17:02:03 +00:00
|
|
|
EXPECT_EQ(0x1278, irsend.capture.value);
|
|
|
|
EXPECT_EQ(0x0, irsend.capture.address);
|
|
|
|
EXPECT_EQ(0x0, irsend.capture.command);
|
|
|
|
EXPECT_FALSE(irsend.capture.repeat);
|
|
|
|
|
|
|
|
// Normal Denon 48-bit message. (Panasonic/Kaseikyo)
|
|
|
|
irsend.reset();
|
2019-07-21 15:01:43 +01:00
|
|
|
irsend.sendDenon(0x2A4C028D6CE3, kDenon48Bits);
|
2017-11-19 17:02:03 +00:00
|
|
|
irsend.makeDecodeResult();
|
2020-02-29 12:51:16 +00:00
|
|
|
ASSERT_TRUE(irrecv.decodeDenon(&irsend.capture, kStartOffset,
|
|
|
|
kDenon48Bits, true));
|
2017-11-19 17:02:03 +00:00
|
|
|
EXPECT_EQ(DENON, irsend.capture.decode_type);
|
2019-07-21 15:01:43 +01:00
|
|
|
EXPECT_EQ(kDenon48Bits, irsend.capture.bits);
|
2017-11-19 17:02:03 +00:00
|
|
|
EXPECT_EQ(0x2A4C028D6CE3, irsend.capture.value);
|
|
|
|
EXPECT_EQ(0x2A4C, irsend.capture.address);
|
|
|
|
EXPECT_EQ(0x028D6CE3, irsend.capture.command);
|
|
|
|
EXPECT_FALSE(irsend.capture.repeat);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Decode a 'real' example via GlobalCache
|
|
|
|
TEST(TestDecodeDenon, DecodeGlobalCacheExample) {
|
|
|
|
IRsendTest irsend(4);
|
|
|
|
IRrecv irrecv(4);
|
|
|
|
irsend.begin();
|
|
|
|
|
|
|
|
irsend.reset();
|
|
|
|
// Denon AVR series Power On code from Global Cache. (Sharp style)
|
2018-11-20 14:53:56 +00:00
|
|
|
uint16_t gc_test_power[67] = {
|
|
|
|
38000, 1, 1, 10, 30, 10, 70, 10, 30, 10, 30, 10, 30, 10, 70, 10, 30,
|
|
|
|
10, 30, 10, 70, 10, 70, 10, 70, 10, 70, 10, 30, 10, 30, 10, 30, 10,
|
|
|
|
1657, 10, 30, 10, 70, 10, 30, 10, 30, 10, 30, 10, 30, 10, 70, 10, 70,
|
|
|
|
10, 30, 10, 30, 10, 30, 10, 30, 10, 70, 10, 70, 10, 70, 10, 1657};
|
2017-11-19 17:02:03 +00:00
|
|
|
irsend.sendGC(gc_test_power, 67);
|
|
|
|
irsend.makeDecodeResult();
|
|
|
|
|
2020-02-29 12:51:16 +00:00
|
|
|
ASSERT_TRUE(irrecv.decodeDenon(&irsend.capture, kStartOffset, kDenonBits,
|
|
|
|
true));
|
2017-11-19 17:02:03 +00:00
|
|
|
EXPECT_EQ(DENON, irsend.capture.decode_type);
|
2019-07-21 15:01:43 +01:00
|
|
|
EXPECT_EQ(kDenonBits, irsend.capture.bits);
|
2017-11-19 17:02:03 +00:00
|
|
|
EXPECT_EQ(0x2278, irsend.capture.value);
|
|
|
|
EXPECT_EQ(0x2, irsend.capture.address);
|
|
|
|
EXPECT_EQ(0x79, irsend.capture.command);
|
|
|
|
EXPECT_FALSE(irsend.capture.repeat);
|
|
|
|
|
|
|
|
// Denon "Eco Mode Auto" code from Global Cache. (Panasonic style)
|
2018-11-20 14:53:56 +00:00
|
|
|
uint16_t gc_test_eco[103] = {
|
|
|
|
37000, 1, 1, 128, 64, 16, 16, 16, 16, 16, 48, 16, 16, 16, 48,
|
|
|
|
16, 16, 16, 48, 16, 16, 16, 16, 16, 48, 16, 16, 16, 16, 16,
|
|
|
|
48, 16, 48, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
|
|
|
|
16, 16, 16, 16, 16, 48, 16, 16, 16, 48, 16, 16, 16, 16, 16,
|
|
|
|
16, 16, 48, 16, 48, 16, 16, 16, 48, 16, 16, 16, 48, 16, 48,
|
|
|
|
16, 16, 16, 48, 16, 48, 16, 16, 16, 16, 16, 48, 16, 48, 16,
|
|
|
|
48, 16, 16, 16, 16, 16, 16, 16, 48, 16, 48, 16, 2766};
|
2017-11-19 17:02:03 +00:00
|
|
|
irsend.reset();
|
|
|
|
irsend.sendGC(gc_test_eco, 103);
|
|
|
|
irsend.makeDecodeResult();
|
|
|
|
|
2020-02-29 12:51:16 +00:00
|
|
|
ASSERT_TRUE(irrecv.decodeDenon(&irsend.capture, kStartOffset, kDenon48Bits,
|
|
|
|
true));
|
2017-11-19 17:02:03 +00:00
|
|
|
EXPECT_EQ(DENON, irsend.capture.decode_type);
|
2019-07-21 15:01:43 +01:00
|
|
|
EXPECT_EQ(kDenon48Bits, irsend.capture.bits);
|
2017-11-19 17:02:03 +00:00
|
|
|
EXPECT_EQ(0x2A4C028D6CE3, irsend.capture.value);
|
|
|
|
EXPECT_EQ(0x2A4C, irsend.capture.address);
|
|
|
|
EXPECT_EQ(0x028D6CE3, irsend.capture.command);
|
|
|
|
EXPECT_FALSE(irsend.capture.repeat);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fail to decode a non-Denon example via GlobalCache
|
|
|
|
TEST(TestDecodeDenon, FailToDecodeNonDenonExample) {
|
|
|
|
IRsendTest irsend(4);
|
|
|
|
IRrecv irrecv(4);
|
|
|
|
irsend.begin();
|
|
|
|
|
|
|
|
irsend.reset();
|
2018-11-20 14:53:56 +00:00
|
|
|
uint16_t gc_test[39] = {38000, 1, 1, 322, 162, 20, 61, 20, 61, 20,
|
|
|
|
20, 20, 20, 20, 20, 20, 127, 20, 61, 9,
|
|
|
|
20, 20, 61, 20, 20, 20, 61, 20, 61, 20,
|
|
|
|
61, 20, 20, 20, 20, 20, 20, 20, 884};
|
2017-11-19 17:02:03 +00:00
|
|
|
irsend.sendGC(gc_test, 39);
|
|
|
|
irsend.makeDecodeResult();
|
|
|
|
|
|
|
|
ASSERT_FALSE(irrecv.decodeDenon(&irsend.capture));
|
2020-02-29 12:51:16 +00:00
|
|
|
ASSERT_FALSE(irrecv.decodeDenon(&irsend.capture, kStartOffset,
|
|
|
|
kDenonLegacyBits, false));
|
|
|
|
ASSERT_FALSE(irrecv.decodeDenon(&irsend.capture, kStartOffset, kDenonBits,
|
|
|
|
false));
|
|
|
|
ASSERT_FALSE(irrecv.decodeDenon(&irsend.capture, kStartOffset, kDenon48Bits,
|
|
|
|
false));
|
2017-11-19 17:02:03 +00:00
|
|
|
}
|