-
Notifications
You must be signed in to change notification settings - Fork 839
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support the WowWee 11-Bit RoboRaptor-X protocol.
* Basic `sendWowwee()` & decodeWowwee()` routines. * Unit test coverage including decoding of two different captured messages from a real remote. Fixes #1938
- Loading branch information
1 parent
3a81664
commit bcbd326
Showing
9 changed files
with
209 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright 2022 David Conran | ||
|
||
/// @file | ||
/// @brief Support for WowWee RoboRapter protocol | ||
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues1938 | ||
|
||
// Supports: | ||
// Brand: WowWee, Model: RoboRapter-X | ||
|
||
#include <algorithm> | ||
#include "IRrecv.h" | ||
#include "IRsend.h" | ||
#include "IRutils.h" | ||
|
||
// Constants | ||
const uint16_t kWowweeHdrMark = 6684; | ||
const uint16_t kWowweeHdrSpace = 723; | ||
const uint16_t kWowweeBitMark = 912; | ||
const uint16_t kWowweeOneSpace = 3259; | ||
const uint16_t kWowweeZeroSpace = kWowweeHdrSpace; | ||
const uint16_t kWowweeFreq = 38000; // Hz. (Just a guess) | ||
|
||
|
||
#if SEND_WOWWEE | ||
/// Send a WowWee formatted message. | ||
/// Status: BETA / Untested on a real device. | ||
/// @param[in] data The message to be sent. | ||
/// @param[in] nbits The number of bits of message to be sent. | ||
/// @param[in] repeat The number of times the command is to be repeated. | ||
void IRsend::sendWowwee(uint64_t data, uint16_t nbits, uint16_t repeat) { | ||
sendGeneric(kWowweeHdrMark, kWowweeHdrSpace, | ||
kWowweeBitMark, kWowweeOneSpace, | ||
kWowweeBitMark, kWowweeZeroSpace, | ||
kWowweeBitMark, kDefaultMessageGap, data, | ||
nbits, kWowweeFreq, true, repeat, 33); | ||
} | ||
#endif // SEND_WOWWEE | ||
|
||
#if DECODE_WOWWEE | ||
/// Decode the supplied WowWee message. | ||
/// Status: BETA / Untested on a real device. | ||
/// @param[in,out] results Ptr to the data to decode & where to store the result | ||
/// @param[in] offset The starting index to use when attempting to decode the | ||
/// raw data. Typically/Defaults to kStartOffset. | ||
/// @param[in] nbits The number of data bits to expect. | ||
/// @param[in] strict Flag indicating if we should perform strict matching. | ||
bool IRrecv::decodeWowwee(decode_results *results, uint16_t offset, | ||
const uint16_t nbits, const bool strict) { | ||
if (strict && nbits != kWowweeBits) | ||
return false; // We expect Wowwee to be a certain sized message. | ||
|
||
uint64_t data = 0; | ||
|
||
// Match Header + Data + Footer | ||
if (!matchGeneric(results->rawbuf + offset, &data, | ||
results->rawlen - offset, nbits, | ||
kWowweeHdrMark, kWowweeHdrSpace, | ||
kWowweeBitMark, kWowweeOneSpace, | ||
kWowweeBitMark, kWowweeZeroSpace, | ||
kWowweeBitMark, kDefaultMessageGap, true)) return false; | ||
// Success | ||
results->bits = nbits; | ||
results->value = data; | ||
results->decode_type = WOWWEE; | ||
results->command = 0; | ||
results->address = 0; | ||
return true; | ||
} | ||
#endif // DECODE_WOWWEE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// Copyright 2022 David Conran | ||
|
||
#include "IRac.h" | ||
#include "IRrecv.h" | ||
#include "IRrecv_test.h" | ||
#include "IRsend.h" | ||
#include "IRsend_test.h" | ||
#include "gtest/gtest.h" | ||
|
||
TEST(TestUtils, Housekeeping) { | ||
ASSERT_EQ("WOWWEE", typeToString(decode_type_t::WOWWEE)); | ||
ASSERT_EQ(decode_type_t::WOWWEE, strToDecodeType("WOWWEE")); | ||
ASSERT_FALSE(hasACState(decode_type_t::WOWWEE)); | ||
ASSERT_FALSE(IRac::isProtocolSupported(decode_type_t::WOWWEE)); | ||
ASSERT_EQ(kWowweeBits, IRsend::defaultBits(decode_type_t::WOWWEE)); | ||
ASSERT_EQ(kWowweeDefaultRepeat, IRsend::minRepeats(decode_type_t::WOWWEE)); | ||
} | ||
|
||
// Tests for sendWowwee(). | ||
// Test sending typical data only. | ||
TEST(TestSendWowwee, SendDataOnly) { | ||
IRsendTest irsend(kGpioUnused); | ||
irsend.begin(); | ||
|
||
irsend.reset(); | ||
irsend.sendWowwee(0x186); // Nikai TV Power Off. | ||
EXPECT_EQ( | ||
"f38000d33" | ||
"m6684s723" | ||
"m912s723m912s723m912s3259m912s3259m912s723m912s723m912s723m912s723" | ||
"m912s3259m912s3259m912s723m912s100000", | ||
irsend.outputStr()); | ||
|
||
irsend.reset(); | ||
} | ||
|
||
// Tests for decodeWowwee(). | ||
|
||
// Decode normal Wowwee messages. | ||
TEST(TestDecodeWowwee, RealDecode) { | ||
IRsendTest irsend(kGpioUnused); | ||
IRrecv irrecv(kGpioUnused); | ||
irsend.begin(); | ||
|
||
// Ref: https://github.com/crankyoldgit/IRremoteESP8266/issues/1938#issue-1513240242 | ||
const uint16_t rawForward[25] = { | ||
6684, 740, 918, 724, 942, 724, 918, 3250, 870, 3268, 872, 770, 940, 690, | ||
942, 688, 942, 738, 942, 3250, 868, 3268, 872, 732, 918 | ||
}; // UNKNOWN 7469BF81 | ||
irsend.reset(); | ||
irsend.sendRaw(rawForward, 25, 38); | ||
irsend.makeDecodeResult(); | ||
ASSERT_TRUE(irrecv.decode(&irsend.capture)); | ||
EXPECT_EQ(decode_type_t::WOWWEE, irsend.capture.decode_type); | ||
EXPECT_EQ(kWowweeBits, irsend.capture.bits); | ||
EXPECT_EQ(0x186, irsend.capture.value); | ||
EXPECT_EQ(0x0, irsend.capture.command); | ||
EXPECT_EQ(0x0, irsend.capture.address); | ||
|
||
// Ref: https://github.com/crankyoldgit/IRremoteESP8266/issues/1938#issue-1513240242 | ||
const uint16_t rawLeft[25] = { | ||
6630, 764, 868, 762, 892, 788, 866, 3324, 792, 3348, 818, 760, 866, 788, | ||
894, 772, 892, 750, 870, 786, 920, 750, 864, 776, 868 | ||
}; // UNKNOWN 28A1120F | ||
irsend.reset(); | ||
irsend.sendRaw(rawLeft, 25, 38); | ||
irsend.makeDecodeResult(); | ||
ASSERT_TRUE(irrecv.decode(&irsend.capture)); | ||
EXPECT_EQ(decode_type_t::WOWWEE, irsend.capture.decode_type); | ||
EXPECT_EQ(kWowweeBits, irsend.capture.bits); | ||
EXPECT_EQ(0x180, irsend.capture.value); | ||
EXPECT_EQ(0x0, irsend.capture.command); | ||
EXPECT_EQ(0x0, irsend.capture.address); | ||
} | ||
|
||
// Decode normal repeated Wowwee messages. | ||
TEST(TestDecodeWowwee, SyntheticDecode) { | ||
IRsendTest irsend(kGpioUnused); | ||
IRrecv irrecv(kGpioUnused); | ||
irsend.begin(); | ||
|
||
// Normal Wowwee 11-bit message. | ||
irsend.reset(); | ||
irsend.sendWowwee(0x186); | ||
irsend.makeDecodeResult(); | ||
ASSERT_TRUE(irrecv.decode(&irsend.capture)); | ||
EXPECT_EQ(decode_type_t::WOWWEE, irsend.capture.decode_type); | ||
EXPECT_EQ(kWowweeBits, irsend.capture.bits); | ||
EXPECT_EQ(0x186, irsend.capture.value); | ||
EXPECT_EQ(0x0, irsend.capture.command); | ||
EXPECT_EQ(0x0, irsend.capture.address); | ||
|
||
// Normal Wowwee 11-bit message. | ||
irsend.reset(); | ||
irsend.sendWowwee(0x180); | ||
irsend.makeDecodeResult(); | ||
ASSERT_TRUE(irrecv.decode(&irsend.capture)); | ||
EXPECT_EQ(decode_type_t::WOWWEE, irsend.capture.decode_type); | ||
EXPECT_EQ(kWowweeBits, irsend.capture.bits); | ||
EXPECT_EQ(0x180, irsend.capture.value); | ||
EXPECT_EQ(0x0, irsend.capture.command); | ||
EXPECT_EQ(0x0, irsend.capture.address); | ||
} |