// Decode unsupported Sharp messages.
TEST(TestDecodeSharp, DecodeWithNonStrict) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

  irsend.reset();
  irsend.sendSharpRaw(0x0, 8);  // Illegal length Sharp 8-bit message.
  irsend.makeDecodeResult();
  // Should fail with strict on.
  ASSERT_FALSE(irrecv.decodeSharp(&irsend.capture, kSharpBits, true));
  // Should pass if strict off.
  ASSERT_TRUE(irrecv.decodeSharp(&irsend.capture, 8, false));
  EXPECT_EQ(SHARP, irsend.capture.decode_type);
  EXPECT_EQ(8, irsend.capture.bits);
  EXPECT_EQ(0x0, irsend.capture.value);
  EXPECT_EQ(0x0, irsend.capture.address);
  EXPECT_EQ(0x0, irsend.capture.command);

  irsend.reset();
  irsend.sendSharpRaw(0x12345678, 32);  // Illegal length Sharp 32-bit message.
  irsend.makeDecodeResult();
  // Should fail with strict on.
  ASSERT_FALSE(irrecv.decodeSharp(&irsend.capture, kSharpBits, true));

  // Should fail with strict when we ask for the wrong bit size.
  ASSERT_FALSE(irrecv.decodeSharp(&irsend.capture, 32, true));
  // Should pass if strict off.
  ASSERT_TRUE(irrecv.decodeSharp(&irsend.capture, 32, false));
  EXPECT_EQ(SHARP, irsend.capture.decode_type);
  EXPECT_EQ(32, irsend.capture.bits);
  EXPECT_EQ(0x12345678, irsend.capture.value);
  EXPECT_EQ(0x8, irsend.capture.address);
  EXPECT_EQ(0x79, irsend.capture.command);
}
Beispiel #2
0
// Decode a 'real' example via GlobalCache
TEST(TestDecodeLG, DecodeGlobalCacheExample) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

// TODO(anyone): Find a Global Cache example of the LG 28-bit message.
  irsend.reset();
  // LG (32-bit) code from Global Cache.
  uint16_t gc_test[75] = {38000, 1, 69, 341, 170, 21, 64, 21, 21, 21, 64,
                          21, 64, 21, 21, 21, 64, 21, 21, 21, 21, 21, 64,
                          21, 21, 21, 64, 21, 64, 21, 21, 21, 64, 21, 21,
                          21, 21, 21, 64, 21, 21, 21, 64, 21, 21, 21, 64,
                          21, 64, 21, 64, 21, 21, 21, 21, 21, 64, 21, 21,
                          21, 64, 21, 21, 21, 21, 21, 21, 21, 64, 21, 1517,
                          341, 85, 21, 3655};
  irsend.sendGC(gc_test, 75);
  irsend.makeDecodeResult();

  ASSERT_TRUE(irrecv.decodeLG(&irsend.capture, LG32_BITS, true));
  EXPECT_EQ(LG, irsend.capture.decode_type);
  EXPECT_EQ(LG32_BITS, irsend.capture.bits);
  EXPECT_EQ(0xB4B4AE51, irsend.capture.value);
  EXPECT_EQ(0xB4B, irsend.capture.address);
  EXPECT_EQ(0x4AE5, irsend.capture.command);
  EXPECT_FALSE(irsend.capture.repeat);
}
// Fail to decode a non-Sharp example via GlobalCache
TEST(TestDecodeSharp, FailToDecodeNonSharpExample) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

  irsend.reset();
  // Modified a few entries to unexpected values, based on previous test case.
  uint16_t gc_test[67] = {
      38000, 1,  1,  10, 70, 30, 30, 10, 30, 10, 30, 10, 70, 10, 30, 10,  70,
      10,    30, 10, 70, 10, 30, 10, 30, 10, 70, 10, 30, 10, 70, 10, 30,  10,
      1657,  10, 70, 10, 30, 10, 30, 10, 30, 10, 70, 10, 70, 10, 30, 10,  60,
      10,    30, 10, 70, 10, 70, 10, 30, 10, 10, 70, 30, 10, 70, 10, 1657};
  irsend.sendGC(gc_test, 67);
  irsend.makeDecodeResult();

  ASSERT_FALSE(irrecv.decodeSharp(&irsend.capture));
  ASSERT_FALSE(irrecv.decodeSharp(&irsend.capture, kSharpBits, false));

  // Test only half of a good message, as it is sent (sort of) twice.
  uint16_t gc_half[35] = {38000, 1,  1,  10, 70, 10, 30, 10, 30, 10, 30,  10,
                          70,    10, 30, 10, 70, 10, 30, 10, 70, 10, 30,  10,
                          30,    10, 70, 10, 30, 10, 70, 10, 30, 10, 1657};

  irsend.sendGC(gc_half, 35);
  irsend.makeDecodeResult();

  ASSERT_FALSE(irrecv.decodeSharp(&irsend.capture));
  ASSERT_FALSE(irrecv.decodeSharp(&irsend.capture, kSharpBits, false));
}
Beispiel #4
0
// Decode unsupported LG message values.
TEST(TestDecodeLG, DecodeWithNonStrictValues) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

  // Illegal values should be rejected when strict is on.
  // Illegal LG 28-bit message value.
  irsend.reset();
  irsend.sendLG(0x1);
  irsend.makeDecodeResult();
  ASSERT_FALSE(irrecv.decodeLG(&irsend.capture, LG_BITS, true));
  ASSERT_FALSE(irrecv.decodeLG(&irsend.capture, LG32_BITS, true));
  ASSERT_FALSE(irrecv.decodeLG(&irsend.capture, LG32_BITS, false));
  ASSERT_TRUE(irrecv.decodeLG(&irsend.capture, LG_BITS, false));

  // Illegal LG 32-bit message value.
  irsend.reset();
  irsend.sendLG(0x1111111, LG32_BITS);
  irsend.makeDecodeResult();
  ASSERT_FALSE(irrecv.decodeLG(&irsend.capture, LG32_BITS, true));
  ASSERT_FALSE(irrecv.decodeLG(&irsend.capture, LG_BITS, true));

  ASSERT_TRUE(irrecv.decodeLG(&irsend.capture, LG32_BITS, false));
  EXPECT_EQ(LG, irsend.capture.decode_type);
  EXPECT_EQ(LG32_BITS, irsend.capture.bits);
  EXPECT_EQ(0x1111111, irsend.capture.value);
  EXPECT_EQ(0x11, irsend.capture.address);
  EXPECT_EQ(0x1111, irsend.capture.command);
  EXPECT_FALSE(irsend.capture.repeat);

  irsend.reset();
  irsend.sendLG(0x1111111, LG32_BITS);
  irsend.makeDecodeResult();
  ASSERT_FALSE(irrecv.decodeLG(&irsend.capture, LG_BITS, false));
}
// Decode a real message from Raw Data.
TEST(TestDecodeVestelAc, RealNormalExample) {
  IRsendTest irsend(0);
  IRrecv irrecv(0);
  IRVestelAc ac(0);
  irsend.begin();

  uint16_t rawData[115] = {
      3098, 9080, 548, 1538, 526, 492,  526, 468,  524, 468,  526, 468,
      550,  466,  526, 466,  526, 504,  540, 466,  526, 1538, 526, 466,
      526,  466,  552, 1540, 522, 466,  526, 492,  526, 544,  526, 1536,
      526,  1536, 552, 1536, 526, 1536, 552, 1536, 552, 1536, 526, 1536,
      526,  1574, 542, 1536, 526, 492,  526, 466,  526, 494,  524, 468,
      524,  468,  526, 492,  526, 502,  540, 468,  524, 494,  524, 468,
      526,  468,  524, 468,  526, 492,  526, 468,  524, 520,  524, 1538,
      524,  468,  524, 468,  524, 468,  524, 468,  524, 468,  524, 1538,
      524,  506,  538, 468,  524, 468,  524, 1538, 524, 468,  550, 1538,
      550,  1538, 524, 1538, 534, 1528, 544};  // VESTEL_AC
  irsend.reset();
  irsend.sendRaw(rawData, 115, 38);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decode(&irsend.capture));
  EXPECT_EQ(VESTEL_AC, irsend.capture.decode_type);
  EXPECT_EQ(kVestelAcBits, irsend.capture.bits);
  EXPECT_FALSE(irsend.capture.repeat);
  EXPECT_EQ(0xF4410001FF1201ULL, irsend.capture.value);
  EXPECT_EQ(0, irsend.capture.address);
  EXPECT_EQ(0, irsend.capture.command);
  ac.begin();
  ac.setRaw(irsend.capture.value);
  EXPECT_EQ(
      "Power: On, Mode: 4 (HEAT), Temp: 16C, Fan: 1 (AUTO), Sleep: Off, "
      "Turbo: Off, Ion: On, Swing: Off",
      ac.toString());
}
Beispiel #6
0
// NEC-like messages without strict mode.
TEST(TestDecodeNEC, NormalNECDecodeWithoutStrict) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

  irsend.reset();
  irsend.sendNEC(0x0);
  irsend.makeDecodeResult();
  EXPECT_TRUE(irrecv.decodeNEC(&irsend.capture, 32, false));
  EXPECT_EQ(NEC, irsend.capture.decode_type);
  EXPECT_EQ(NEC_BITS, irsend.capture.bits);
  EXPECT_EQ(0, irsend.capture.value);
  EXPECT_EQ(0, irsend.capture.address);
  EXPECT_EQ(0, irsend.capture.command);

  irsend.reset();
  irsend.sendNEC(0x12345678);
  irsend.makeDecodeResult();
  EXPECT_TRUE(irrecv.decodeNEC(&irsend.capture, 32, false));
  EXPECT_EQ(NEC, irsend.capture.decode_type);
  EXPECT_EQ(NEC_BITS, irsend.capture.bits);
  EXPECT_EQ(0x12345678, irsend.capture.value);
  EXPECT_EQ(0x2C48, irsend.capture.address);
  EXPECT_EQ(0, irsend.capture.command);
}
// Decode synthetic Panasonic AC message.
TEST(TestDecodePanasonicAC, SyntheticExample) {
  IRsendTest irsend(0);
  IRrecv irrecv(0);
  irsend.begin();

  // Data from Issue #525
  uint8_t expectedState[kPanasonicAcStateLength] = {
      0x02, 0x20, 0xE0, 0x04, 0x00, 0x00, 0x00, 0x06, 0x02,
      0x20, 0xE0, 0x04, 0x00, 0x30, 0x32, 0x80, 0xAF, 0x00,
      0x00, 0x06, 0x60, 0x00, 0x00, 0x80, 0x00, 0x06, 0x83};

  irsend.sendPanasonicAC(expectedState);
  irsend.makeDecodeResult();

  ASSERT_TRUE(irrecv.decode(&irsend.capture));
  ASSERT_EQ(PANASONIC_AC, irsend.capture.decode_type);
  EXPECT_EQ(kPanasonicAcBits, irsend.capture.bits);
  EXPECT_STATE_EQ(expectedState, irsend.capture.state, irsend.capture.bits);
  EXPECT_FALSE(irsend.capture.repeat);

  IRPanasonicAc pana(0);
  pana.setRaw(irsend.capture.state);
  EXPECT_EQ(
      "Model: 4 (JKE), Power: Off, Mode: 3 (COOL), Temp: 25C, "
      "Fan: 7 (AUTO), Swing (Vertical): 15 (AUTO), Quiet: Off, "
      "Powerful: Off, Clock: 0:00, On Timer: Off, Off Timer: Off",
      pana.toString());
}
// Decode a documented example
TEST(TestDecodeLutron, DocumentedExampleFullOff) {
  IRsendTest irsend(0);
  IRrecv irrecv(0);
  irsend.begin();

  // Full Off code.
  // Ref: https://github.com/markszabo/IRremoteESP8266/issues/515
  uint16_t rawData[14] = {20518, 6839, 2280, 6839, 2280, 2280, 9119,
                          2280,  2280, 6839, 2280, 4560, 2280, 11399};
  irsend.reset();
  irsend.sendRaw(rawData, 14, 40);
  irsend.makeDecodeResult();
  EXPECT_TRUE(irrecv.decode(&irsend.capture));
  EXPECT_EQ(LUTRON, irsend.capture.decode_type);
  EXPECT_EQ(kLutronBits, irsend.capture.bits);
  EXPECT_EQ(0x7F88BD120, irsend.capture.value);
  EXPECT_EQ(0x0, irsend.capture.address);
  EXPECT_EQ(0x0, irsend.capture.command);

  uint16_t pronto[18] = {0x0000, 0x0069, 0x0007, 0x0000, 0x032a, 0x010e,
                         0x005a, 0x010e, 0x005a, 0x005a, 0x0168, 0x005a,
                         0x005a, 0x010e, 0x005a, 0x00b4, 0x005a, 0x01c2};
  irsend.reset();
  irsend.sendPronto(pronto, 18);
  irsend.makeDecodeResult();
  EXPECT_TRUE(irrecv.decode(&irsend.capture));
  EXPECT_EQ(LUTRON, irsend.capture.decode_type);
  EXPECT_EQ(kLutronBits, irsend.capture.bits);
  EXPECT_EQ(0x7F88BD120, irsend.capture.value);
  EXPECT_EQ(0x0, irsend.capture.address);
  EXPECT_EQ(0x0, irsend.capture.command);
}
// Test sending typical command with repeats.
TEST(TestSendGlobalCache, RepeatCode) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();
  irsend.reset();

    // Sherwood (NEC-like) "Power On" from Global Cache with 2 repeats
  uint16_t gc_test[75] = {38000, 2, 69, 341, 171, 21, 64, 21, 64, 21, 21, 21,
                          21, 21, 21, 21, 21, 21, 21, 21, 64, 21, 64, 21, 21,
                          21, 64, 21, 21, 21, 21, 21, 21, 21, 64, 21, 21, 21,
                          64, 21, 21, 21, 21, 21, 21, 21, 64, 21, 21, 21, 21,
                          21, 21, 21, 21, 21, 64, 21, 64, 21, 64, 21, 21, 21,
                          64, 21, 64, 21, 64, 21, 1600, 341, 85, 21, 3647};
  irsend.sendGC(gc_test, 75);
  irsend.makeDecodeResult();
  EXPECT_EQ("m8866s4446m546s1664m546s1664m546s546m546s546m546s546m546s546"
            "m546s546m546s1664m546s1664m546s546m546s1664m546s546m546s546"
            "m546s546m546s1664m546s546m546s1664m546s546m546s546m546s546"
            "m546s1664m546s546m546s546m546s546m546s546m546s1664m546s1664"
            "m546s1664m546s546m546s1664m546s1664m546s1664m546s41600"
            "m8866s2210m546s94822"
            "m8866s2210m546s94822", irsend.outputStr());
  EXPECT_TRUE(irrecv.decodeNEC(&irsend.capture));
  EXPECT_EQ(NEC, irsend.capture.decode_type);
  EXPECT_EQ(NEC_BITS, irsend.capture.bits);
  EXPECT_EQ(0xC1A28877, irsend.capture.value);
  EXPECT_EQ(0x4583, irsend.capture.address);
  EXPECT_EQ(0x11, irsend.capture.command);
}
TEST(TestDecodeVestelAc, RealTimerExample) {
  IRsendTest irsend(0);
  IRrecv irrecv(0);
  IRVestelAc ac(0);
  irsend.begin();

  uint16_t rawData[115] = {
      3022, 9080, 546, 1536, 526, 466,  526, 492,  526, 468,  526, 492,
      524,  468,  524, 494,  524, 504,  540, 492,  524, 1538, 526, 468,
      524,  492,  526, 466,  552, 1536, 526, 1536, 526, 1570, 542, 492,
      524,  1538, 550, 1538, 524, 1536, 526, 494,  524, 466,  526, 468,
      524,  1574, 540, 1536, 550, 1536, 526, 468,  550, 1536, 526, 492,
      526,  468,  524, 492,  526, 518,  526, 1536, 552, 1536, 550, 1536,
      526,  494,  550, 1538, 526, 492,  524, 1538, 526, 504,  540, 466,
      526,  1536, 526, 1536, 526, 468,  550, 1538, 524, 468,  524, 1538,
      550,  1574, 540, 468,  550, 1538, 526, 492,  524, 468,  526, 466,
      526,  468,  524, 494,  524, 468,  546};  // VESTEL_AC 2D6570B8EE201
  irsend.reset();
  irsend.sendRaw(rawData, 115, 38);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decode(&irsend.capture));
  EXPECT_EQ(VESTEL_AC, irsend.capture.decode_type);
  EXPECT_EQ(kVestelAcBits, irsend.capture.bits);
  EXPECT_FALSE(irsend.capture.repeat);
  EXPECT_EQ(0x2D6570B8EE201ULL, irsend.capture.value);
  EXPECT_EQ(0, irsend.capture.address);
  EXPECT_EQ(0, irsend.capture.command);
  ac.begin();
  ac.setRaw(irsend.capture.value);
  EXPECT_EQ(
      "Time: 5:45, Timer: Off, On Timer: 14:00, Off Timer: 23:00",
      ac.toString());
}
Beispiel #11
0
// Short NEC-like messages (without strict naturally)
TEST(TestDecodeNEC, ShortNECDecodeWithoutStrict) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

  irsend.reset();
  irsend.sendNEC(0x0, 16);
  irsend.makeDecodeResult();
  EXPECT_TRUE(irrecv.decodeNEC(&irsend.capture, 16, false));
  EXPECT_EQ(NEC, irsend.capture.decode_type);
  EXPECT_EQ(16, irsend.capture.bits);
  EXPECT_EQ(0, irsend.capture.value);
  EXPECT_EQ(0, irsend.capture.address);
  EXPECT_EQ(0, irsend.capture.command);

  // Expecting less than what was sent is not valid.
  irsend.reset();
  irsend.sendNEC(0x0, 32);
  irsend.makeDecodeResult();
  EXPECT_FALSE(irrecv.decodeNEC(&irsend.capture, 16, false));

  // Send 16 bits of data, but fail because we are expecting 17.
  irsend.reset();
  irsend.sendNEC(0x0, 16);
  irsend.makeDecodeResult();
  EXPECT_FALSE(irrecv.decodeNEC(&irsend.capture, 17, false));
}
Beispiel #12
0
// Decode a 'real' example via GlobalCache
TEST(TestDecodePanasonic, DecodeGlobalCacheExample) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

  irsend.reset();
  // Panasonic code from Global Cache.
  uint16_t gc_test[103] = {37000, 1, 1, 126, 64, 16, 17, 16, 49, 15, 16, 16, 16,
                          16, 16, 16, 17, 15, 17, 15, 17, 15, 17, 15, 16, 16,
                          16, 16, 16, 16, 17, 15, 49, 16, 16, 16, 16, 16, 17,
                          15, 17, 15, 17, 15, 17, 15, 16, 16, 16, 16, 16, 16,
                          49, 15, 49, 16, 17, 15, 17, 15, 49, 16, 16, 16, 17,
                          16, 17, 15, 17, 15, 49, 16, 49, 15, 49, 16, 17, 16,
                          49, 15, 49, 16, 17, 15, 48, 16, 16, 16, 49, 15, 48,
                          16, 49, 15, 49, 16, 49, 15, 17, 15, 16, 16, 2721};
  irsend.sendGC(gc_test, 103);
  irsend.makeDecodeResult();

  ASSERT_TRUE(irrecv.decodePanasonic(&irsend.capture, PANASONIC_BITS, true));
  EXPECT_EQ(PANASONIC, irsend.capture.decode_type);
  EXPECT_EQ(PANASONIC_BITS, irsend.capture.bits);
  EXPECT_EQ(0x40040190ED7C, irsend.capture.value);
  EXPECT_EQ(0x4004, irsend.capture.address);
  EXPECT_EQ(0x0190ED7C, irsend.capture.command);
  EXPECT_FALSE(irsend.capture.repeat);

  ASSERT_TRUE(irrecv.decodePanasonic(&irsend.capture));
  EXPECT_EQ(PANASONIC, irsend.capture.decode_type);
  EXPECT_EQ(PANASONIC_BITS, irsend.capture.bits);
  EXPECT_EQ(0x40040190ED7C, irsend.capture.value);
  EXPECT_EQ(0x4004, irsend.capture.address);
  EXPECT_EQ(0x0190ED7C, irsend.capture.command);
  EXPECT_FALSE(irsend.capture.repeat);
}
Beispiel #13
0
// Decode Panasonic messages with unsupported values.
TEST(TestDecodePanasonic, DecodeWithNonStrictValues) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

  irsend.reset();
  irsend.sendPanasonic64(0x0);  // Illegal value Panasonic 48-bit message.
  irsend.makeDecodeResult();
  // Should fail with strict on.
  ASSERT_FALSE(irrecv.decodePanasonic(&irsend.capture, PANASONIC_BITS, true));
  // Should pass if strict off.
  ASSERT_TRUE(irrecv.decodePanasonic(&irsend.capture, PANASONIC_BITS, false));
  EXPECT_EQ(PANASONIC, irsend.capture.decode_type);
  EXPECT_EQ(PANASONIC_BITS, irsend.capture.bits);
  EXPECT_EQ(0x0, irsend.capture.value);
  EXPECT_EQ(0x0, irsend.capture.address);
  EXPECT_EQ(0x0, irsend.capture.command);

  irsend.reset();
  // Illegal address/Manufacturer code. The rest is legal.
  irsend.sendPanasonic64(irsend.encodePanasonic(0, 1, 2, 3));
  irsend.makeDecodeResult();
  // Should fail with strict on.
  ASSERT_FALSE(irrecv.decodePanasonic(&irsend.capture, PANASONIC_BITS, true));
  // Should pass if strict off.
  ASSERT_TRUE(irrecv.decodePanasonic(&irsend.capture, PANASONIC_BITS, false));
  EXPECT_EQ(PANASONIC, irsend.capture.decode_type);
  EXPECT_EQ(PANASONIC_BITS, irsend.capture.bits);
  EXPECT_EQ(0x1020300, irsend.capture.value);
  EXPECT_EQ(0x0, irsend.capture.address);
  EXPECT_EQ(0x1020300, irsend.capture.command);
}
Beispiel #14
0
// Decode normal repeated Panasonic messages.
TEST(TestDecodePanasonic, NormalDecodeWithRepeatAndStrict) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

  // Normal Panasonic 48-bit message with 2 repeats.
  irsend.reset();
  irsend.sendPanasonic64(0x40040190ED7C, PANASONIC_BITS, 2);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decodePanasonic(&irsend.capture, PANASONIC_BITS, true));
  EXPECT_EQ(PANASONIC, irsend.capture.decode_type);
  EXPECT_EQ(PANASONIC_BITS, irsend.capture.bits);
  EXPECT_EQ(0x40040190ED7C, irsend.capture.value);
  EXPECT_EQ(0x4004, irsend.capture.address);
  EXPECT_EQ(0x190ED7C, irsend.capture.command);
  EXPECT_FALSE(irsend.capture.repeat);

  irsend.makeDecodeResult(2 * PANASONIC_BITS + 4);
  ASSERT_TRUE(irrecv.decodePanasonic(&irsend.capture, PANASONIC_BITS, true));
  EXPECT_EQ(PANASONIC, irsend.capture.decode_type);
  EXPECT_EQ(PANASONIC_BITS, irsend.capture.bits);
  EXPECT_EQ(0x40040190ED7C, irsend.capture.value);

  irsend.makeDecodeResult(2 * (2 * PANASONIC_BITS + 4));
  ASSERT_TRUE(irrecv.decodePanasonic(&irsend.capture, PANASONIC_BITS, true));
  EXPECT_EQ(PANASONIC, irsend.capture.decode_type);
  EXPECT_EQ(PANASONIC_BITS, irsend.capture.bits);
  EXPECT_EQ(0x40040190ED7C, irsend.capture.value);
}
// Decode normal "synthetic" messages.
TEST(TestDecodeHaierAC, NormalDecodeWithStrict) {
  IRsendTest irsend(0);
  IRrecv irrecv(0);
  irsend.begin();

  uint8_t expectedState[HAIER_AC_STATE_LENGTH] = {
      0xA5, 0x01, 0x20, 0x01, 0x00, 0xC0, 0x20, 0x00, 0xA7};
  // With the specific decoder.
  irsend.reset();
  irsend.sendHaierAC(expectedState);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decodeHaierAC(&irsend.capture, HAIER_AC_BITS, true));
  EXPECT_EQ(HAIER_AC, irsend.capture.decode_type);
  EXPECT_EQ(HAIER_AC_BITS, irsend.capture.bits);
  EXPECT_FALSE(irsend.capture.repeat);
  EXPECT_STATE_EQ(expectedState, irsend.capture.state, irsend.capture.bits);

  // With the all the decoders.
  irsend.reset();
  irsend.sendHaierAC(expectedState);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decode(&irsend.capture));
  EXPECT_EQ(HAIER_AC, irsend.capture.decode_type);
  EXPECT_EQ(HAIER_AC_BITS, irsend.capture.bits);
  EXPECT_FALSE(irsend.capture.repeat);
  EXPECT_STATE_EQ(expectedState, irsend.capture.state, irsend.capture.bits);
}
Beispiel #16
0
// Decode normal repeated LG messages.
TEST(TestDecodeLG, NormalDecodeWithRepeatAndStrict) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

  // Normal LG 28-bit message with 2 repeats.
  irsend.reset();
  irsend.sendLG(irsend.encodeLG(0x07, 0x99), LG_BITS, 2);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decodeLG(&irsend.capture, LG_BITS, true));
  EXPECT_EQ(LG, irsend.capture.decode_type);
  EXPECT_EQ(LG_BITS, irsend.capture.bits);
  EXPECT_EQ(0x700992, irsend.capture.value);
  EXPECT_EQ(0x07, irsend.capture.address);
  EXPECT_EQ(0x99, irsend.capture.command);
  EXPECT_FALSE(irsend.capture.repeat);

  // Normal LG 32-bit message with 2 repeats.
  irsend.reset();
  irsend.sendLG(irsend.encodeLG(0x07, 0x99), LG32_BITS, 2);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decodeLG(&irsend.capture, LG32_BITS, true));
  EXPECT_EQ(LG, irsend.capture.decode_type);
  EXPECT_EQ(LG32_BITS, irsend.capture.bits);
  EXPECT_EQ(0x700992, irsend.capture.value);
  EXPECT_EQ(0x07, irsend.capture.address);
  EXPECT_EQ(0x99, irsend.capture.command);
  EXPECT_FALSE(irsend.capture.repeat);
}
// Test sending a typical command wihtout a repeat.
TEST(TestSendGlobalCache, NonRepeatingCode) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();
  irsend.reset();

    // Modified NEC TV "Power On" from Global Cache with no repeats
  uint16_t gc_test[71] = {38000, 1, 1, 342, 172, 21, 22, 21, 21, 21, 65, 21, 21,
                          21, 22, 21, 22, 21, 21, 21, 22, 21, 65, 21, 65, 21,
                          22, 21, 65, 21, 65, 21, 65, 21, 65, 21, 65, 21, 65,
                          21, 22, 21, 22, 21, 21, 21, 22, 21, 22, 21, 65, 21,
                          22, 21, 21, 21, 65, 21, 65, 21, 65, 21, 64, 22, 65,
                          21, 22, 21, 65, 21, 1519};
  irsend.sendGC(gc_test, 71);
  irsend.makeDecodeResult();
  EXPECT_EQ("m8892s4472m546s572m546s546m546s1690m546s546m546s572m546s572"
            "m546s546m546s572m546s1690m546s1690m546s572m546s1690m546s1690"
            "m546s1690m546s1690m546s1690m546s1690m546s572m546s572m546s546"
            "m546s572m546s572m546s1690m546s572m546s546m546s1690m546s1690"
            "m546s1690m546s1664m572s1690m546s572m546s1690m546s39494",
            irsend.outputStr());
  EXPECT_TRUE(irrecv.decodeNEC(&irsend.capture));
  EXPECT_EQ(NEC, irsend.capture.decode_type);
  EXPECT_EQ(NEC_BITS, irsend.capture.bits);
  EXPECT_EQ(0x20DF827D, irsend.capture.value);
  EXPECT_EQ(0x4, irsend.capture.address);
  EXPECT_EQ(0x41, irsend.capture.command);
}
// Decode against a real capture reported by a user. See issue #354
TEST(TestDecodeMidea, DecodeRealExample) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();
  irsend.reset();

  uint16_t rawData[199] = {
      4366, 4470, 498, 1658, 522, 554, 498, 1658, 496, 580, 498, 580, 498, 578,
      498, 580, 498, 1658, 498, 1658, 498, 578, 498, 578, 498, 580, 496, 582,
      496, 578, 498, 1658, 498, 580, 498, 580, 498, 1656, 498, 1656, 500, 580,
      498, 578, 502, 576, 500, 1656, 498, 1656, 500, 1654, 500, 1656, 500, 1656,
      498, 1658, 498, 1656, 500, 1658, 498, 1656, 498, 1656, 500, 1656, 500,
      1654, 500, 1578, 578, 1658, 498, 1656, 500, 1658, 498, 1656, 498, 1656,
      500, 578, 498, 1638, 516, 1656, 500, 578, 500, 1656, 500, 1656, 498, 1658,
      522, 554, 500, 5258, 4366, 4472, 498, 580, 498, 1658, 498, 580, 498, 1656,
      500, 1600, 556, 1658, 500, 1656, 500, 578, 498, 578, 522, 1634, 498, 1588,
      568, 1658, 498, 1656, 500, 1654, 498, 580, 498, 1658, 498, 1658, 498, 580,
      496, 578, 500, 1654, 500, 1636, 518, 1656, 500, 578, 520, 558, 498, 578,
      498, 580, 498, 576, 500, 578, 498, 580, 498, 578, 498, 578, 498, 580, 498,
      578, 498, 580, 498, 580, 520, 556, 498, 580, 496, 580, 498, 578, 500, 578,
      498, 1658, 498, 580, 498, 578, 498, 1656, 500, 578, 498, 580, 498, 580,
      498, 1656, 522};
  irsend.sendRaw(rawData, 199, 38000);
  irsend.makeDecodeResult();

  ASSERT_TRUE(irrecv.decode(&irsend.capture));
  EXPECT_EQ(MIDEA, irsend.capture.decode_type);
  EXPECT_EQ(MIDEA_BITS, irsend.capture.bits);
  EXPECT_EQ(0xA18263FFFF6E, irsend.capture.value);
}
Beispiel #19
0
// Inconsistent decoding for unknown in Issue #264
// Reported issues decoding an Apple Remote. Apple doesn't appear to respect
// or use the command structure/checks in the NEC protocol.
TEST(TestDecodeNEC, NonStrictNECDecode_Issue264) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

  irsend.reset();
  // Slightly modified example than reported due to poor timings that are too
  // far out of spec.
  uint16_t rawData[67] = {9150, 4650, 550, 600, 550, 1800, 600, 1750, 600, 1800,
                          550, 600, 550, 1800, 550, 1750, 600, 1750, 600, 1750,
                          600, 1750, 600, 1700, 600, 600, 600, 600, 550, 600,
                          600, 600, 600, 1750, 600, 1750, 600, 600, 550, 1800,
                          600, 600, 600, 600, 600, 600, 500, 600, 600, 600,
                          600, 600, 600, 1750, 600, 600, 600, 550, 600, 600,
                          600, 600, 600, 600, 600, 550, 600};

  irsend.sendRaw(rawData, 67, 38);
  irsend.makeDecodeResult();
  EXPECT_FALSE(irrecv.decodeNEC(&irsend.capture));  // Not strictly NEC
  EXPECT_TRUE(irrecv.decodeNEC(&irsend.capture, NEC_BITS, false));
  EXPECT_EQ(0x77E1A040, irsend.capture.value);

  // Do it all again, but with a normal decode.
  irsend.reset();
  irsend.sendRaw(rawData, 67, 38);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decode(&irsend.capture));
  EXPECT_EQ(NEC_LIKE, irsend.capture.decode_type);
  EXPECT_EQ(NEC_BITS, irsend.capture.bits);
  EXPECT_EQ(0x77E1A040, irsend.capture.value);
}
// Decode normal repeated Midea messages.
TEST(TestDecodeMidea, NormalDecodeWithRepeatAndStrict) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

  // Normal Midea 48-bit message with 2 repeats.
  irsend.reset();
  irsend.sendMidea(0xA18263FFFF6E, MIDEA_BITS, 2);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decodeMidea(&irsend.capture, MIDEA_BITS, true));
  EXPECT_EQ(MIDEA, irsend.capture.decode_type);
  EXPECT_EQ(MIDEA_BITS, irsend.capture.bits);
  EXPECT_EQ(0xA18263FFFF6E, irsend.capture.value);
  EXPECT_FALSE(irsend.capture.repeat);

  irsend.makeDecodeResult(2 * (2 * MIDEA_BITS + 4));
  ASSERT_TRUE(irrecv.decodeMidea(&irsend.capture, MIDEA_BITS, true));
  EXPECT_EQ(MIDEA, irsend.capture.decode_type);
  EXPECT_EQ(MIDEA_BITS, irsend.capture.bits);
  EXPECT_EQ(0xA18263FFFF6E, irsend.capture.value);

  irsend.makeDecodeResult(4 * (2 * MIDEA_BITS + 4));
  ASSERT_TRUE(irrecv.decodeMidea(&irsend.capture, MIDEA_BITS, true));
  EXPECT_EQ(MIDEA, irsend.capture.decode_type);
  EXPECT_EQ(MIDEA_BITS, irsend.capture.bits);
  EXPECT_EQ(0xA18263FFFF6E, irsend.capture.value);
}
// Decode normal Panasonic AC messages.
TEST(TestDecodePanasonicAC, RealExample) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

  // Data from Issue #525
  uint16_t rawData[439] = {
      3582, 1686, 488, 378,  488, 1238, 488, 378,  488, 378,  488, 378,
      488,  378,  488, 378,  488, 384,  488, 378,  488, 378,  488, 378,
      488,  378,  488, 378,  488, 1242, 486, 378,  488, 384,  488, 378,
      488,  378,  488, 380,  486, 382,  484, 382,  484, 1264, 464, 1266,
      460,  1272, 462, 378,  488, 406,  460, 1266, 462, 380,  488, 382,
      484,  388,  478, 406,  462, 410,  462, 404,  462, 406,  462, 396,
      470,  406,  462, 404,  462, 406,  460, 404,  462, 410,  462, 404,
      462,  404,  462, 406,  464, 406,  462, 404,  462, 406,  462, 404,
      462,  410,  462, 404,  462, 406,  462, 404,  462, 404,  462, 404,
      462,  406,  460, 406,  462, 410,  462, 404,  462, 1264, 484, 1244,
      486,  382,  482, 382,  486, 382,  486, 378,  486, 382,  488, 9924,
      3554, 1686, 488, 378,  490, 1240, 486, 378,  488, 378,  488, 378,
      488,  378,  488, 382,  484, 386,  486, 378,  488, 382,  486, 378,
      488,  382,  486, 382,  484, 1242, 486, 380,  488, 386,  484, 382,
      486,  380,  486, 382,  486, 380,  486, 380,  486, 1242, 486, 1242,
      484,  1248, 484, 380,  488, 382,  484, 1242, 486, 382,  484, 382,
      484,  382,  484, 382,  486, 386,  484, 382,  486, 382,  484, 382,
      486,  382,  486, 380,  484, 382,  486, 382,  488, 380,  486, 382,
      484,  380,  462, 406,  488, 376,  484, 1246, 482, 1246, 460, 404,
      480,  392,  484, 386,  482, 1244, 484, 382,  484, 382,  484, 1242,
      482,  1244, 484, 382,  464, 410,  460, 404,  462, 406,  462, 404,
      462,  404,  470, 396,  462, 406,  462, 404,  462, 1286, 460, 1268,
      458,  1268, 460, 1266, 460, 1266, 460, 406,  460, 1266, 462, 406,
      460,  1272, 462, 406,  460, 406,  460, 406,  460, 406,  462, 404,
      462,  406,  460, 406,  462, 410,  462, 404,  462, 406,  460, 406,
      460,  406,  462, 404,  462, 406,  460, 406,  460, 410,  462, 406,
      460,  1268, 460, 1266, 460, 404,  460, 406,  462, 406,  460, 406,
      460,  412,  456, 410,  460, 410,  438, 428,  460, 410,  456, 410,
      456,  1272, 436, 1288, 438, 434,  438, 428,  438, 428,  438, 428,
      438,  428,  438, 428,  438, 428,  438, 428,  438, 434,  438, 428,
      438,  428,  438, 428,  438, 428,  438, 428,  440, 428,  438, 428,
      438,  432,  438, 428,  438, 428,  438, 428,  438, 428,  438, 428,
      438,  428,  438, 430,  438, 1294, 438, 428,  438, 428,  438, 428,
      438,  428,  438, 428,  438, 428,  438, 428,  438, 434,  438, 428,
      438,  1288, 438, 1290, 438, 428,  438, 428,  438, 428,  438, 428,
      438,  432,  438, 1288, 438, 1290, 438, 430,  438, 428,  438, 428,
      438,  428,  438, 428,  438, 1292, 438};
  uint8_t expectedState[kPanasonicAcStateLength] = {
      0x02, 0x20, 0xE0, 0x04, 0x00, 0x00, 0x00, 0x06, 0x02,
      0x20, 0xE0, 0x04, 0x00, 0x30, 0x32, 0x80, 0xAF, 0x00,
      0x00, 0x06, 0x60, 0x00, 0x00, 0x80, 0x00, 0x06, 0x83};

  irsend.sendRaw(rawData, 439, kPanasonicFreq);
  irsend.makeDecodeResult();

  ASSERT_TRUE(irrecv.decode(&irsend.capture));
  ASSERT_EQ(PANASONIC_AC, irsend.capture.decode_type);
  EXPECT_EQ(kPanasonicAcBits, irsend.capture.bits);
  EXPECT_STATE_EQ(expectedState, irsend.capture.state, irsend.capture.bits);
  EXPECT_FALSE(irsend.capture.repeat);
}
// Decode a real message from Raw Data.
TEST(TestDecodeTeco, RealNormalExample) {
  IRsendTest irsend(0);
  IRrecv irrecv(0);
  IRTecoAc ac(0);
  irsend.begin();

  uint16_t rawData1[73] = {
      9076, 4442,  670, 1620,  670, 516,  670, 516,  666, 1626,  670, 516,
      664, 520,  666, 1626,  666, 1626,  664, 1626,  666, 1626,  666, 520,
      666, 1626,  666, 520,  666, 1626,  666, 520,  666, 516,  670, 514,
      670, 516,  666, 520,  670, 516,  666, 520,  666, 516,  672, 514,  670,
      516,  666, 520,  666, 516,  672, 514,  670, 516,  666, 1624,  666, 520,
      666, 1626,  666, 520,  666, 516,  672, 1620,  670, 516,  670};
  uint64_t expected1 = 0b01001010000000000000010101111001001;  // 0x250002BC9
  irsend.reset();
  irsend.sendRaw(rawData1, 73, 38);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decode(&irsend.capture));
  EXPECT_EQ(TECO, irsend.capture.decode_type);
  EXPECT_EQ(kTecoBits, irsend.capture.bits);
  EXPECT_FALSE(irsend.capture.repeat);
  EXPECT_EQ(expected1, irsend.capture.value);
  EXPECT_EQ(0, irsend.capture.address);
  EXPECT_EQ(0, irsend.capture.command);
  ac.begin();
  ac.setRaw(irsend.capture.value);
  EXPECT_EQ(
      "Power: On, Mode: 1 (COOL), Temp: 27C, Fan: 0 (Auto), Sleep: On, "
      "Swing: On",
      ac.toString());

  uint16_t rawData2[73] = {
    9048, 4472, 636, 548, 636, 1654, 638, 546, 642, 1650, 642, 546, 638,
    1654, 638, 1654, 638, 546, 638, 1654, 636, 546, 642, 1650, 640, 548,
    636, 548, 638, 546, 636, 546, 642, 542, 642, 546, 638, 546, 638, 546,
    636, 548, 642, 542, 642, 546, 636, 548, 636, 546, 642, 542, 642, 546,
    638, 546, 638, 546, 636, 1654, 642, 542, 642, 1650, 642, 546, 638, 546,
    638, 1654, 638, 546, 642};  // TECO 25000056A
  uint64_t expected2 = 0b01001010000000000000000010101101010;  // 0x25000056A
  irsend.reset();
  irsend.sendRaw(rawData2, 73, 38);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decode(&irsend.capture));
  EXPECT_EQ(TECO, irsend.capture.decode_type);
  EXPECT_EQ(kTecoBits, irsend.capture.bits);
  EXPECT_FALSE(irsend.capture.repeat);
  EXPECT_EQ(expected2, irsend.capture.value);
  EXPECT_EQ(0, irsend.capture.address);
  EXPECT_EQ(0, irsend.capture.command);
  ac.begin();
  ac.setRaw(irsend.capture.value);
  EXPECT_EQ(
      "Power: On, Mode: 2 (DRY), Temp: 21C, Fan: 2 (Med), Sleep: Off, "
      "Swing: On",
      ac.toString());
}
// Decode a recorded example
TEST(TestDecodeWhirlpoolAC, RealExampleDecode) {
  IRsendTest irsend(0);
  IRrecv irrecv(0);
  irsend.begin();

  // Real WhirlpoolAC message.
  // Ref: https://github.com/markszabo/IRremoteESP8266/issues/509
  uint16_t rawData[343] = {
      8950, 4484, 598, 1642, 598, 1646, 594, 534,  594, 538,  602, 532,
      598,  540,  600, 542,  598, 1650, 600, 522,  598, 1644, 596, 1650,
      600,  532,  598, 538,  602, 536,  594, 548,  592, 538,  602, 518,
      600,  524,  596, 532,  598, 532,  598, 1654, 596, 544,  596, 544,
      596,  536,  594, 1644, 596, 528,  600, 528,  592, 538,  602, 1648,
      602,  1654, 596, 1664, 598, 534,  594, 526,  594, 530,  598, 528,
      602,  530,  600, 534,  596, 542,  598, 542,  598, 534,  596, 526,
      594,  530,  600, 528,  602, 530,  600, 534,  596, 542,  598, 544,
      596,  518,  602, 7916, 598, 1642, 598, 528,  600, 528,  602, 530,
      600,  1652, 598, 542,  598, 544,  596, 1654, 596, 1644, 596, 1648,
      602,  1644, 596, 1654, 596, 1656, 604, 536,  594, 548,  602, 528,
      600,  520,  600, 524,  596, 532,  598, 532,  596, 538,  602, 536,
      594,  546,  594, 538,  602, 518,  600, 524,  596, 532,  598, 532,
      598,  536,  594, 544,  596, 544,  596, 536,  594, 526,  592, 530,
      600,  528,  600, 530,  602, 532,  596, 542,  598, 542,  598, 534,
      596,  524,  596, 528,  600, 526,  592, 538,  592, 542,  598, 540,
      600,  540,  600, 530,  598, 522,  598, 526,  594, 534,  596, 534,
      594,  540,  602, 536,  592, 548,  592, 538,  600, 1636, 594, 1648,
      602,  1642, 598, 1652, 598, 538,  602, 1680, 570, 1662, 598, 1634,
      596,  7924, 600, 520,  598, 526,  592, 534,  596, 534,  596, 540,
      600,  536,  604, 538,  602, 530,  600, 520,  598, 1640, 600, 528,
      600,  530,  600, 534,  594, 544,  596, 544,  596, 534,  596, 526,
      594,  528,  600, 526,  594, 536,  592, 542,  598, 538,  602, 538,
      602,  528,  600, 520,  600, 524,  596, 530,  600, 532,  598, 534,
      596,  542,  598, 542,  598, 532,  598, 524,  596, 528,  602, 526,
      594,  536,  594, 540,  600, 536,  594, 548,  592, 538,  602, 518,
      602,  522,  596, 530,  600, 530,  600, 534,  596, 542,  598, 544,
      596,  534,  596, 524,  594, 1644, 596, 532,  596, 534,  596, 538,
      602,  536,  594, 546,  594, 520,  600};
  uint8_t expectedState[kWhirlpoolAcStateLength] = {
      0x83, 0x06, 0x10, 0x71, 0x00, 0x00, 0x91, 0x1F, 0x00, 0x00, 0x00,
      0x00, 0x00, 0xEF, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02};

  irsend.reset();
  irsend.sendRaw(rawData, 343, 38000);
  irsend.makeDecodeResult();
  EXPECT_TRUE(irrecv.decode(&irsend.capture));
  EXPECT_EQ(WHIRLPOOL_AC, irsend.capture.decode_type);
  EXPECT_EQ(kWhirlpoolAcBits, irsend.capture.bits);
  EXPECT_STATE_EQ(expectedState, irsend.capture.state, irsend.capture.bits);
  IRWhirlpoolAc ac(0);
  ac.setRaw(irsend.capture.state);
  EXPECT_EQ(
      "Model: 1 (DG11J13A), Power toggle: Off, Mode: 1 (AUTO), Temp: 25C, "
      "Fan: 0 (AUTO), Swing: Off, Light: On, Clock: 17:31, On Timer: Off, "
      "Off Timer: Off, Sleep: Off, Super: Off, Command: 2 (TEMP)",
      ac.toString());
}
// Decode normal Midea messages with strict set.
TEST(TestDecodeMidea, NormalDecodeWithStrict) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

  // Normal Midea 48-bit message.
  irsend.reset();
  irsend.sendMidea(0x1234567890DF);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decodeMidea(&irsend.capture, MIDEA_BITS, true));
  EXPECT_EQ(MIDEA, irsend.capture.decode_type);
  EXPECT_EQ(MIDEA_BITS, irsend.capture.bits);
  EXPECT_EQ(0x1234567890DF, irsend.capture.value);
  EXPECT_EQ(0x0, irsend.capture.address);
  EXPECT_EQ(0x0, irsend.capture.command);
  EXPECT_FALSE(irsend.capture.repeat);

  // Normal Midea 48-bit message.
  irsend.reset();
  irsend.sendMidea(0x0);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decodeMidea(&irsend.capture, MIDEA_BITS, true));
  EXPECT_EQ(MIDEA, irsend.capture.decode_type);
  EXPECT_EQ(MIDEA_BITS, irsend.capture.bits);
  EXPECT_EQ(0x0, irsend.capture.value);
  EXPECT_EQ(0x0, irsend.capture.address);
  EXPECT_EQ(0x0, irsend.capture.command);
  EXPECT_FALSE(irsend.capture.repeat);

  // Normal Midea 48-bit message.
  irsend.reset();
  irsend.sendMidea(0xFFFFFFFFFFA0);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decodeMidea(&irsend.capture, MIDEA_BITS, true));
  EXPECT_EQ(MIDEA, irsend.capture.decode_type);
  EXPECT_EQ(MIDEA_BITS, irsend.capture.bits);
  EXPECT_EQ(0xFFFFFFFFFFA0, irsend.capture.value);
  EXPECT_EQ(0x0, irsend.capture.address);
  EXPECT_EQ(0x0, irsend.capture.command);
  EXPECT_FALSE(irsend.capture.repeat);

  // Real Midea 48-bit message via just decode().
  // i.e. No conficts with other decoders.
  irsend.reset();
  irsend.sendMidea(0xA18263FFFF6E);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decode(&irsend.capture));
  EXPECT_EQ(MIDEA, irsend.capture.decode_type);
  EXPECT_EQ(MIDEA_BITS, irsend.capture.bits);
  EXPECT_EQ(0xA18263FFFF6E, irsend.capture.value);
  EXPECT_EQ(0x0, irsend.capture.address);
  EXPECT_EQ(0x0, irsend.capture.command);
  EXPECT_FALSE(irsend.capture.repeat);
}
TEST(TestDecodeWhirlpoolAC, RealTimerExample) {
  IRsendTest irsend(0);
  IRrecv irrecv(0);
  irsend.begin();

  irsend.reset();
  // Dehumidify timer on 7:40 off 8:05
  uint16_t rawData[343] = {
      9092, 4556, 604, 1664, 604, 1674, 630, 514,  630, 518,  628, 522,
      604,  550,  628, 530,  602, 1680, 630, 508,  630, 1644, 604, 1674,
      604,  544,  604, 548,  630, 524,  604, 554,  620, 530,  630, 506,
      602,  538,  602, 542,  604, 542,  604, 546,  630, 524,  602, 556,
      628,  518,  604, 1666, 632, 1644, 604, 540,  602, 546,  604, 1680,
      604,  1684, 604, 1686, 630, 520,  602, 534,  606, 538,  602, 540,
      604,  544,  604, 548,  602, 552,  630, 528,  602, 546,  602, 536,
      628,  510,  606, 540,  604, 544,  630, 522,  604, 554,  600, 554,
      602,  528,  602, 8032, 604, 1666, 604, 1668, 602, 1676, 630, 518,
      630,  520,  602, 550,  604, 554,  604, 1678, 630, 1640, 602, 1672,
      602,  542,  602, 544,  628, 522,  630, 1658, 604, 554,  628, 1652,
      630,  508,  602, 538,  630, 514,  630, 1652, 602, 546,  604, 550,
      602,  554,  602, 546,  630, 1638, 604, 536,  630, 1646, 602, 544,
      628,  522,  632, 524,  628, 528,  602, 1686, 594, 1666, 604, 1670,
      602,  1674, 632, 516,  604, 546,  638, 518,  622, 534,  628, 518,
      604,  532,  604, 536,  600, 550,  622, 1652, 630, 520,  602, 1684,
      602,  554,  602, 544,  630, 506,  628, 512,  602, 540,  628, 518,
      602,  550,  602, 552,  604, 554,  602, 544,  628, 1642, 602, 536,
      632,  1646, 630, 516,  602, 1680, 630, 1656, 604, 1688, 602, 1660,
      602,  8030, 604, 532,  604, 536,  604, 540,  602, 544,  628, 522,
      602,  552,  602, 556,  602, 544,  602, 1666, 630, 510,  602, 1674,
      604,  544,  628, 522,  602, 552,  630, 526,  628, 520,  602, 534,
      630,  510,  604, 540,  602, 544,  606, 544,  604, 550,  604, 554,
      602,  544,  604, 534,  602, 538,  602, 542,  604, 542,  604, 546,
      604,  550,  632, 526,  604, 544,  630, 506,  604, 536,  604, 540,
      628,  518,  602, 548,  604, 550,  604, 552,  630, 516,  602, 534,
      604,  536,  630, 512,  604, 544,  602, 548,  630, 524,  602, 554,
      602,  542,  604, 1666, 606, 532,  630, 1644, 602, 544,  630, 520,
      604,  550,  604, 554,  602, 526,  598};
  uint8_t expectedState[kWhirlpoolAcStateLength] = {
      0x83, 0x06, 0x00, 0x73, 0x00, 0x00, 0x87, 0xA3, 0x08, 0x85, 0x07,
      0x28, 0x00, 0xF5, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x05};
  irsend.sendRaw(rawData, 343, 38000);
  irsend.makeDecodeResult();
  EXPECT_TRUE(irrecv.decode(&irsend.capture));
  EXPECT_EQ(WHIRLPOOL_AC, irsend.capture.decode_type);
  EXPECT_EQ(kWhirlpoolAcBits, irsend.capture.bits);
  EXPECT_STATE_EQ(expectedState, irsend.capture.state, irsend.capture.bits);
  IRWhirlpoolAc ac(0);
  ac.setRaw(irsend.capture.state);
  EXPECT_EQ(
      "Model: 1 (DG11J13A), Power toggle: Off, Mode: 3 (DRY), Temp: 25C, "
      "Fan: 0 (AUTO), Swing: Off, Light: On, Clock: 07:35, On Timer: 07:40, "
      "Off Timer: 08:05, Sleep: Off, Super: Off, Command: 5 (ONTIMER)",
      ac.toString());
}
Beispiel #26
0
// Decode normal LG messages.
TEST(TestDecodeLG, NormalDecodeWithStrict) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

  // Normal LG 28-bit message.
  irsend.reset();
  irsend.sendLG(0x4B4AE51, LG_BITS);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decodeLG(&irsend.capture, LG_BITS, true));
  EXPECT_EQ(LG, irsend.capture.decode_type);
  EXPECT_EQ(LG_BITS, irsend.capture.bits);
  EXPECT_EQ(0x4B4AE51, irsend.capture.value);
  EXPECT_EQ(0x4B, irsend.capture.address);
  EXPECT_EQ(0x4AE5, irsend.capture.command);
  EXPECT_FALSE(irsend.capture.repeat);

  // Normal LG 32-bit message.
  irsend.reset();
  irsend.sendLG(0xB4B4AE51, LG32_BITS);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decodeLG(&irsend.capture, LG32_BITS, false));
  EXPECT_EQ(LG, irsend.capture.decode_type);
  EXPECT_EQ(LG32_BITS, irsend.capture.bits);
  EXPECT_EQ(0xB4B4AE51, irsend.capture.value);
  EXPECT_EQ(0xB4B, irsend.capture.address);
  EXPECT_EQ(0x4AE5, irsend.capture.command);
  EXPECT_FALSE(irsend.capture.repeat);

  // Synthesised Normal LG 28-bit message.
  irsend.reset();
  irsend.sendLG(irsend.encodeLG(0x07, 0x99));
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decodeLG(&irsend.capture, LG_BITS, true));
  EXPECT_EQ(LG, irsend.capture.decode_type);
  EXPECT_EQ(LG_BITS, irsend.capture.bits);
  EXPECT_EQ(0x700992, irsend.capture.value);
  EXPECT_EQ(0x07, irsend.capture.address);
  EXPECT_EQ(0x99, irsend.capture.command);
  EXPECT_FALSE(irsend.capture.repeat);

  // Synthesised Normal LG 32-bit message.
  irsend.reset();
  irsend.sendLG(irsend.encodeLG(0x800, 0x8000), LG32_BITS);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decodeLG(&irsend.capture, LG32_BITS, true));
  EXPECT_EQ(LG, irsend.capture.decode_type);
  EXPECT_EQ(LG32_BITS, irsend.capture.bits);
  EXPECT_EQ(0x80080008, irsend.capture.value);
  EXPECT_EQ(0x800, irsend.capture.address);
  EXPECT_EQ(0x8000, irsend.capture.command);
  EXPECT_FALSE(irsend.capture.repeat);
}
// Decode unsupported RC5 messages.
TEST(TestDecodeRC5, DecodeWithNonStrictValues) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

  irsend.reset();
  irsend.sendRC5(0xFA, 8);  // Illegal value RC5 8-bit message.
  irsend.makeDecodeResult();
  // Should fail with strict on.
  ASSERT_FALSE(irrecv.decodeRC5(&irsend.capture, RC5_BITS, true));
  ASSERT_FALSE(irrecv.decodeRC5(&irsend.capture, RC5X_BITS, true));
  // Should pass if strict off.
  ASSERT_TRUE(irrecv.decodeRC5(&irsend.capture, 8, false));
  EXPECT_EQ(RC5, irsend.capture.decode_type);
  EXPECT_EQ(8, irsend.capture.bits);
  EXPECT_EQ(0xFA, irsend.capture.value);
  EXPECT_EQ(0x3, irsend.capture.address);
  EXPECT_EQ(0x3A, irsend.capture.command);

  irsend.reset();
  irsend.sendRC5(0x12345678, 32);  // Illegal size RC5 32-bit message.
  irsend.makeDecodeResult();
  // Should fail with strict on.
  ASSERT_FALSE(irrecv.decodeRC5(&irsend.capture, RC5_BITS, true));
  ASSERT_FALSE(irrecv.decodeRC5(&irsend.capture, RC5X_BITS, true));

  irsend.makeDecodeResult();
  // Should fail with strict when we ask for the wrong bit size.
  ASSERT_FALSE(irrecv.decodeRC5(&irsend.capture, 32, true));
  // Should pass if strict off.
  ASSERT_TRUE(irrecv.decodeRC5(&irsend.capture, 32, false));
  EXPECT_EQ(RC5, irsend.capture.decode_type);
  EXPECT_EQ(31, irsend.capture.bits);
  EXPECT_EQ(0x12345678, irsend.capture.value);

  irsend.reset();
  irsend.sendRC5(0x87654321, 32);  // Illegal size RC5 32-bit message.
  irsend.makeDecodeResult();
  // Should fail with strict on.
  ASSERT_FALSE(irrecv.decodeRC5(&irsend.capture, RC5_BITS, true));
  ASSERT_FALSE(irrecv.decodeRC5(&irsend.capture, RC5X_BITS, true));

  irsend.makeDecodeResult();
  // Should fail with strict when we ask for the wrong bit size.
  ASSERT_FALSE(irrecv.decodeRC5(&irsend.capture, 32, true));
  // Should pass if strict off.
  ASSERT_TRUE(irrecv.decodeRC5(&irsend.capture, 32, false));
  EXPECT_EQ(RC5X, irsend.capture.decode_type);
  EXPECT_EQ(32, irsend.capture.bits);
  EXPECT_EQ(0x87654321, irsend.capture.value);
}
// Fail to decode a non-RC-5 example via GlobalCache
TEST(TestDecodeRC5, FailToDecodeNonRC5Example) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

  irsend.reset();
  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};
  irsend.sendGC(gc_test, 39);
  irsend.makeDecodeResult();

  ASSERT_FALSE(irrecv.decodeRC5(&irsend.capture));
  ASSERT_FALSE(irrecv.decodeRC5(&irsend.capture, RC5_BITS, false));
}
// Decode (non-standard) 64-bit messages.
TEST(TestDecodeMidea, Decode64BitMessages) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

  irsend.reset();
  // Illegal size Midea 64-bit message.
  irsend.sendMidea(0xFFFFFFFFFFFFFFFF, 64);
  irsend.makeDecodeResult();
  // Should work with a 'normal' match (not strict)
  ASSERT_TRUE(irrecv.decodeMidea(&irsend.capture, 64, false));
  EXPECT_EQ(MIDEA, irsend.capture.decode_type);
  EXPECT_EQ(64, irsend.capture.bits);
  EXPECT_EQ(0xFFFFFFFFFFFFFFFF, irsend.capture.value);
}
// Decode normal repeated Samsung messages.
TEST(TestDecodeSamsung, NormalDecodeWithRepeatAndStrict) {
  IRsendTest irsend(4);
  IRrecv irrecv(4);
  irsend.begin();

  // Normal Samsung 32-bit message.
  irsend.reset();
  irsend.sendSAMSUNG(0xE0E09966, SAMSUNG_BITS, 2);
  irsend.makeDecodeResult();
  ASSERT_TRUE(irrecv.decodeSAMSUNG(&irsend.capture, SAMSUNG_BITS, true));
  EXPECT_EQ(SAMSUNG, irsend.capture.decode_type);
  EXPECT_EQ(SAMSUNG_BITS, irsend.capture.bits);
  EXPECT_EQ(0xE0E09966, irsend.capture.value);
  EXPECT_EQ(0x07, irsend.capture.address);
  EXPECT_EQ(0x99, irsend.capture.command);
}