-
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.
Experimental support for Teknopoint A/C protocol
* Basic support added via `sendTeknopoint()` & `decodeTeknopoint()` * Unit test coverage for the additions/changes. * Minor code style cleanup. Note: Bit ordering not yet determined. May change without notice. For #1486
- Loading branch information
1 parent
609abce
commit 91dc3ea
Showing
10 changed files
with
214 additions
and
4 deletions.
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
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,73 @@ | ||
// Copyright 2021 David Conran (crankyoldgit) | ||
/// @file | ||
/// @brief Support for the Teknopoint protocol | ||
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/1486 | ||
|
||
// Supports: | ||
// Brand: Teknopoint, Model: Allegro SSA-09H A/C | ||
|
||
#include "IRrecv.h" | ||
#include "IRsend.h" | ||
#include "IRutils.h" | ||
|
||
// Protocol timings | ||
const uint16_t kTeknopointHdrMark = 3614; | ||
const uint16_t kTeknopointBitMark = 439; | ||
const uint16_t kTeknopointHdrSpace = 1610; | ||
const uint16_t kTeknopointOneSpace = 1238; | ||
const uint16_t kTeknopointZeroSpace = 567; | ||
const uint16_t kTeknopointFreq = 38000; // Hz. (Guess Only) | ||
const uint16_t kTeknopointOverhead = 3; | ||
|
||
#if SEND_TEKNOPOINT | ||
/// Send a Teknopoint formatted message. | ||
/// Status: BETA / Probably works however the bit order is not yet determined. | ||
/// @param[in] data An array of bytes containing the IR command. | ||
/// It is assumed to be in MSB order for this code. | ||
/// e.g. | ||
/// @code | ||
/// uint8_t data[kTeknopointStateLength] = { | ||
/// 0xC4, 0xD3, 0x64, 0x80, 0x00, 0x24, 0xC0, | ||
/// 0xF0, 0x10, 0x00, 0x00, 0x00, 0x00, 0xCA}; | ||
/// @endcode | ||
/// @param[in] nbytes Nr. of bytes of data in the array. | ||
/// @param[in] repeat Nr. of times the message is to be repeated. | ||
void IRsend::sendTeknopoint(const uint8_t data[], const uint16_t nbytes, | ||
const uint16_t repeat) { | ||
sendGeneric(kTeknopointHdrMark, kTeknopointHdrSpace, | ||
kTeknopointBitMark, kTeknopointOneSpace, | ||
kTeknopointBitMark, kTeknopointZeroSpace, | ||
kTeknopointBitMark, kDefaultMessageGap, | ||
data, nbytes, // Bytes | ||
kTeknopointFreq, true, repeat, kDutyDefault); | ||
} | ||
#endif // SEND_TEKNOPOINT | ||
|
||
#if DECODE_TEKNOPOINT | ||
/// Decode the supplied Teknopoint message. | ||
/// Status: Alpha / Probably works however the bit order is not yet determined. | ||
/// @param[in,out] results Ptr to the data to decode & where to store the decode | ||
/// @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. | ||
/// @return A boolean. True if it can decode it, false if it can't. | ||
bool IRrecv::decodeTeknopoint(decode_results *results, uint16_t offset, | ||
const uint16_t nbits, const bool strict) { | ||
if (results->rawlen < 2 * nbits + kHeader + kFooter - 1 - offset) | ||
return false; // Too short a message to match. | ||
if (strict && nbits != kTeknopointBits) | ||
return false; | ||
|
||
if (!matchGeneric(results->rawbuf + offset, results->state, | ||
results->rawlen - offset, nbits, | ||
kTeknopointHdrMark, kTeknopointHdrSpace, | ||
kTeknopointBitMark, kTeknopointOneSpace, | ||
kTeknopointBitMark, kTeknopointZeroSpace, | ||
kTeknopointBitMark, kDefaultMessageGap, true)) return false; | ||
// Success | ||
results->decode_type = decode_type_t::TEKNOPOINT; | ||
results->bits = nbits; | ||
return true; | ||
} | ||
#endif // DECODE_TEKNOPOINT |
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,101 @@ | ||
// Copyright 2021 David Conran (crankyoldgit) | ||
|
||
#include "IRac.h" | ||
#include "IRrecv.h" | ||
#include "IRrecv_test.h" | ||
#include "IRsend.h" | ||
#include "IRsend_test.h" | ||
#include "gtest/gtest.h" | ||
|
||
// Tests for decodeTeknopoint(). | ||
|
||
TEST(TestDecodeTeknopoint, RealExample) { | ||
IRsendTest irsend(kGpioUnused); | ||
IRrecv irrecv(kGpioUnused); | ||
// "On" | ||
// Ref: https://github.com/crankyoldgit/IRremoteESP8266/issues/1486#issue-904276382 | ||
const uint16_t rawData[227] = { | ||
3614, 1610, 474, 1210, 390, 1294, 454, 550, 394, 606, 474, 530, 474, 1186, | ||
394, 634, 390, 638, 450, 1210, 366, 1318, 450, 554, 394, 1270, 470, 554, | ||
450, 530, 390, 1318, 450, 1214, 470, 530, 474, 1210, 370, 1294, 474, 550, | ||
450, 554, 470, 1214, 450, 550, 394, 614, 466, 1218, 450, 550, 370, 634, | ||
474, 530, 474, 550, 450, 550, 450, 554, 366, 634, 502, 554, 446, 554, 450, | ||
550, 450, 554, 390, 614, 474, 526, 478, 526, 474, 550, 450, 534, 406, 614, | ||
390, 1294, 394, 610, 390, 614, 470, 1214, 366, 638, 470, 554, 450, 1214, | ||
366, 1318, 450, 550, 454, 550, 474, 530, 470, 530, 474, 550, 454, 550, | ||
450, 1238, 450, 1210, 470, 1214, 454, 1210, 474, 550, 450, 554, 394, 582, | ||
394, 634, 474, 526, 478, 550, 450, 526, 474, 1214, 474, 550, 454, 550, | ||
394, 606, 370, 634, 474, 526, 478, 550, 450, 550, 394, 610, 366, 638, 414, | ||
586, 478, 546, 454, 550, 422, 606, 390, 610, 474, 554, 450, 550, 454, 550, | ||
450, 530, 410, 614, 478, 526, 474, 550, 450, 550, 454, 550, 390, 614, 474, | ||
526, 474, 550, 454, 550, 450, 554, 366, 634, 474, 526, 478, 550, 450, 550, | ||
454, 550, 366, 638, 474, 526, 474, 550, 454, 1210, 414, 1270, 394, 610, | ||
390, 614, 470, 1214, 366, 638, 470, 1190, 474, 554, 390}; | ||
const uint8_t expectedState[kTeknopointStateLength] = { | ||
0xC4, 0xD3, 0x64, 0x80, 0x00, 0x24, 0xC0, | ||
0xF0, 0x10, 0x00, 0x00, 0x00, 0x00, 0xCA}; | ||
irsend.begin(); | ||
irsend.reset(); | ||
irsend.sendRaw(rawData, 227, 38); | ||
irsend.makeDecodeResult(); | ||
|
||
ASSERT_TRUE(irrecv.decode(&irsend.capture)); | ||
ASSERT_EQ(decode_type_t::TEKNOPOINT, irsend.capture.decode_type); | ||
ASSERT_EQ(kTeknopointBits, irsend.capture.bits); | ||
EXPECT_STATE_EQ(expectedState, irsend.capture.state, irsend.capture.bits); | ||
EXPECT_EQ( | ||
"", | ||
IRAcUtils::resultAcToString(&irsend.capture)); | ||
} | ||
|
||
TEST(TestDecodeTeknopoint, SyntheticExample) { | ||
IRsendTest irsend(kGpioUnused); | ||
IRrecv irrecv(kGpioUnused); | ||
irsend.begin(); | ||
irsend.reset(); | ||
|
||
// "On" | ||
const uint8_t expectedState[kTeknopointStateLength] = { | ||
0xC4, 0xD3, 0x64, 0x80, 0x00, 0x24, 0xC0, | ||
0xF0, 0x10, 0x00, 0x00, 0x00, 0x00, 0xCA}; | ||
|
||
irsend.sendTeknopoint(expectedState); | ||
irsend.makeDecodeResult(); | ||
|
||
ASSERT_TRUE(irrecv.decode(&irsend.capture)); | ||
ASSERT_EQ(decode_type_t::TEKNOPOINT, irsend.capture.decode_type); | ||
ASSERT_EQ(kTeknopointBits, irsend.capture.bits); | ||
EXPECT_STATE_EQ(expectedState, irsend.capture.state, irsend.capture.bits); | ||
EXPECT_EQ( | ||
"", | ||
IRAcUtils::resultAcToString(&irsend.capture)); | ||
|
||
EXPECT_EQ( | ||
"f38000d50" | ||
"m3614s1610" | ||
"m439s1238m439s1238m439s567m439s567m439s567m439s1238m439s567m439s567" | ||
"m439s1238m439s1238m439s567m439s1238m439s567m439s567m439s1238m439s1238" | ||
"m439s567m439s1238m439s1238m439s567m439s567m439s1238m439s567m439s567" | ||
"m439s1238m439s567m439s567m439s567m439s567m439s567m439s567m439s567" | ||
"m439s567m439s567m439s567m439s567m439s567m439s567m439s567m439s567" | ||
"m439s567m439s567m439s1238m439s567m439s567m439s1238m439s567m439s567" | ||
"m439s1238m439s1238m439s567m439s567m439s567m439s567m439s567m439s567" | ||
"m439s1238m439s1238m439s1238m439s1238m439s567m439s567m439s567m439s567" | ||
"m439s567m439s567m439s567m439s1238m439s567m439s567m439s567m439s567" | ||
"m439s567m439s567m439s567m439s567m439s567m439s567m439s567m439s567" | ||
"m439s567m439s567m439s567m439s567m439s567m439s567m439s567m439s567" | ||
"m439s567m439s567m439s567m439s567m439s567m439s567m439s567m439s567" | ||
"m439s567m439s567m439s567m439s567m439s567m439s567m439s567m439s567" | ||
"m439s1238m439s1238m439s567m439s567m439s1238m439s567m439s1238m439s567" | ||
"m439s100000", | ||
irsend.outputStr()); | ||
} | ||
|
||
TEST(TestUtils, Housekeeping) { | ||
ASSERT_EQ("TEKNOPOINT", typeToString(decode_type_t::TEKNOPOINT)); | ||
ASSERT_EQ(decode_type_t::TEKNOPOINT, strToDecodeType("TEKNOPOINT")); | ||
ASSERT_TRUE(hasACState(decode_type_t::TEKNOPOINT)); | ||
ASSERT_FALSE(IRac::isProtocolSupported(decode_type_t::TEKNOPOINT)); | ||
ASSERT_EQ(kTeknopointBits, IRsend::defaultBits(decode_type_t::TEKNOPOINT)); | ||
ASSERT_EQ(kNoRepeat, IRsend::minRepeats(decode_type_t::TEKNOPOINT)); | ||
} |