From bdeb13ed811d5f47cb1a638408e0885c7a41ebaa Mon Sep 17 00:00:00 2001 From: harshbhosale01 Date: Tue, 23 Jul 2024 11:31:57 +0530 Subject: [PATCH 1/7] Added support for IRsend for Bluestar Heavy AC --- src/IRremoteESP8266.h | 16 +++- src/IRsend.cpp | 7 ++ src/IRsend.h | 6 +- src/IRtext.cpp | 2 + src/IRutils.cpp | 1 + src/ir_BluestarHeavy.cpp | 151 +++++++++++++++++++++++++++++++++ src/locale/defaults.h | 3 + test/ir_BluestarHeavy_test.cpp | 0 8 files changed, 182 insertions(+), 4 deletions(-) create mode 100644 src/ir_BluestarHeavy.cpp create mode 100644 test/ir_BluestarHeavy_test.cpp diff --git a/src/IRremoteESP8266.h b/src/IRremoteESP8266.h index 949de1ecf..0acda04da 100644 --- a/src/IRremoteESP8266.h +++ b/src/IRremoteESP8266.h @@ -952,6 +952,13 @@ #define SEND_YORK _IR_ENABLE_DEFAULT_ #endif // SEND_YORK +#ifndef DECODE_BLUESTARHEAVY +#define DECODE_BLUESTARHEAVY _IR_ENABLE_DEFAULT_ +#endif // DECODE_BLUESTARHEAVY +#ifndef SEND_BLUESTARHEAVY +#define SEND_BLUESTARHEAVY _IR_ENABLE_DEFAULT_ +#endif // SEND_BLUESTARHEAVY + #if (DECODE_ARGO || DECODE_DAIKIN || DECODE_FUJITSU_AC || DECODE_GREE || \ DECODE_KELVINATOR || DECODE_MITSUBISHI_AC || DECODE_TOSHIBA_AC || \ DECODE_TROTEC || DECODE_HAIER_AC || DECODE_HITACHI_AC || \ @@ -970,7 +977,7 @@ DECODE_KELON168 || DECODE_HITACHI_AC296 || DECODE_CARRIER_AC128 || \ DECODE_DAIKIN200 || DECODE_HAIER_AC160 || DECODE_TCL96AC || \ DECODE_BOSCH144 || DECODE_SANYO_AC152 || DECODE_DAIKIN312 || \ - DECODE_CARRIER_AC84 || DECODE_YORK || \ + DECODE_CARRIER_AC84 || DECODE_YORK || DECODE_BLUESTARHEAVY || \ false) // Add any DECODE to the above if it uses result->state (see kStateSizeMax) // you might also want to add the protocol to hasACState function @@ -1136,9 +1143,9 @@ enum decode_type_t { GORENJE, WOWWEE, CARRIER_AC84, // 125 - YORK, + BLUESTARHEAVY, // Add new entries before this one, and update it to point to the last entry. - kLastDecodeType = YORK, + kLastDecodeType = BLUESTARHEAVY, }; // Message lengths & required repeat values @@ -1165,6 +1172,8 @@ const uint16_t kArgo3TimerStateLength = 9; // Bytes const uint16_t kArgo3ConfigStateLength = 4; // Bytes const uint16_t kArgoDefaultRepeat = kNoRepeat; const uint16_t kArrisBits = 32; +const uint16_t kBluestarHeavyStateLength = 13; +const uint16_t kBluestarHeavyBits = 104; const uint16_t kBosch144StateLength = 18; const uint16_t kBosch144Bits = kBosch144StateLength * 8; const uint16_t kCoolixBits = 24; @@ -1437,6 +1446,7 @@ const uint16_t kYorkBits = 136; const uint16_t kYorkStateLength = 17; + // Legacy defines. (Deprecated) #define AIWA_RC_T501_BITS kAiwaRcT501Bits #define ARGO_COMMAND_LENGTH kArgoStateLength diff --git a/src/IRsend.cpp b/src/IRsend.cpp index 10e440b32..1864ee2a3 100644 --- a/src/IRsend.cpp +++ b/src/IRsend.cpp @@ -798,6 +798,8 @@ uint16_t IRsend::defaultBits(const decode_type_t protocol) { return kXmpBits; case YORK: return kYorkBits; + case BLUESTARHEAVY: + return kBluestarHeavyBits; // No default amount of bits. case FUJITSU_AC: case MWM: @@ -1434,6 +1436,11 @@ bool IRsend::send(const decode_type_t type, const uint8_t *state, sendYork(state, nbytes); break; #endif // SEND_YORK +#if SEND_BLUESTARHEAVY + case BLUESTARHEAVY: + sendBluestarHeavy(state, nbytes); + break; +#endif // SEND_BLUESTARHEAVY default: return false; } diff --git a/src/IRsend.h b/src/IRsend.h index 38491372a..a8ee54fcc 100644 --- a/src/IRsend.h +++ b/src/IRsend.h @@ -885,7 +885,11 @@ class IRsend { const uint16_t nbytes = kYorkStateLength, const uint16_t repeat = kNoRepeat); #endif // SEND_YORK - +#if SEND_BLUESTARHEAVY + void sendBluestarHeavy(const unsigned char data[], + const uint16_t nbytes = kBluestarHeavyStateLength, + const uint16_t repeat = kNoRepeat); +#endif // SEND_BLUESTARHEAVY protected: #ifdef UNIT_TEST #ifndef HIGH diff --git a/src/IRtext.cpp b/src/IRtext.cpp index 9cb39b772..0e832fde4 100644 --- a/src/IRtext.cpp +++ b/src/IRtext.cpp @@ -555,6 +555,8 @@ IRTEXT_CONST_BLOB_DECL(kAllProtocolNamesStr) { D_STR_CARRIER_AC84, D_STR_UNSUPPORTED) "\x0" COND(DECODE_YORK || SEND_YORK, D_STR_YORK, D_STR_UNSUPPORTED) "\x0" + COND(DECODE_BLUESTARHEAVY || SEND_BLUESTARHEAVY, + D_STR_BLUESTARHEAVY, D_STR_UNSUPPORTED) "\x0" ///< New protocol (macro) strings should be added just above this line. "\x0" ///< This string requires double null termination. }; diff --git a/src/IRutils.cpp b/src/IRutils.cpp index e9af0b28f..02bd88aaf 100644 --- a/src/IRutils.cpp +++ b/src/IRutils.cpp @@ -169,6 +169,7 @@ bool hasACState(const decode_type_t protocol) { // This is kept sorted by name case AMCOR: case ARGO: + case BLUESTARHEAVY: case BOSCH144: case CARRIER_AC84: case CARRIER_AC128: diff --git a/src/ir_BluestarHeavy.cpp b/src/ir_BluestarHeavy.cpp new file mode 100644 index 000000000..a795d9c95 --- /dev/null +++ b/src/ir_BluestarHeavy.cpp @@ -0,0 +1,151 @@ +// Copyright 2020 David Conran (crankyoldgit) +/// @file +/// @brief Support for BluestarHeavy protocol + +// Supports: +// Brand: Bluestar, Model: TODO add device and remote + +#include "IRrecv.h" +#include "IRsend.h" +#include "IRutils.h" + +// WARNING: This probably isn't directly usable. It's a guide only. + +// See https://github.com/crankyoldgit/IRremoteESP8266/wiki/Adding-support-for-a-new-IR-protocol +// for details of how to include this in the library. +const uint16_t kBluestarHeavyHdrMark = 4912; +const uint16_t kBluestarHeavyBitMark = 465; +const uint16_t kBluestarHeavyHdrSpace = 5058; +const uint16_t kBluestarHeavyOneSpace = 1548; +const uint16_t kBluestarHeavyZeroSpace = 572; +const uint16_t kBluestarHeavyFreq = 38000; // Hz. (Guessing the most common frequency.) +//const uint16_t kBluestarHeavyBits = 104; // Move to IRremoteESP8266.h +//const uint16_t kBluestarHeavyStateLength = 13; // Move to IRremoteESP8266.h +const uint16_t kBluestarHeavyOverhead = 3; +// DANGER: More than 64 bits detected. A uint64_t for 'data' won't work! + + +#if SEND_BLUESTARHEAVY +// Alternative >64bit function to send BLUESTARHEAVY messages +// Function should be safe over 64 bits. +/// Send a BluestarHeavy formatted message. +/// Status: ALPHA / Untested. +/// @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[kBluestarHeavyStateLength] = {0xD5, 0xFE, 0xD7, 0x4F, 0xFA, 0x5F, 0xFA, 0x5F, 0xFF, 0x7F, 0x5C, 0xFD, 0xDC}; +/// @endcode +/// @param[in] nbytes Nr. of bytes of data in the array. (>=kBluestarHeavyStateLength) +/// @param[in] repeat Nr. of times the message is to be repeated. +void IRsend::sendBluestarHeavy(const uint8_t data[], const uint16_t nbytes, const uint16_t repeat) { + for (uint16_t r = 0; r <= repeat; r++) { + uint16_t pos = 0; + // Data Section #2 + // e.g. + // bits = 104; bytes = 13; + // *(data + pos) = {0xD5, 0xFE, 0xD7, 0x4F, 0xFA, 0x5F, 0xFA, 0x5F, 0xFF, 0x7F, 0x5C, 0xFD, 0xDC}; + sendGeneric(kBluestarHeavyHdrMark, kBluestarHeavyHdrSpace, + kBluestarHeavyBitMark, kBluestarHeavyOneSpace, + kBluestarHeavyBitMark, kBluestarHeavyZeroSpace, + kBluestarHeavyHdrMark, kDefaultMessageGap, + data + pos, 13, // Bytes + kBluestarHeavyFreq, true, kNoRepeat, kDutyDefault); + pos += 13; // Adjust by how many bytes of data we sent + } +} +#endif // SEND_BLUESTARHEAVY + +/* +// DANGER: More than 64 bits detected. A uint64_t for 'data' won't work! +#if DECODE_BLUESTARHEAVY +// Function should be safe up to 64 bits. +/// Decode the supplied BluestarHeavy message. +/// Status: ALPHA / Untested. +/// @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::decodeBluestarHeavy(decode_results *results, uint16_t offset, const uint16_t nbits, const bool strict) { + if (results->rawlen < 2 * nbits + kBluestarHeavyOverhead - offset) + return false; // Too short a message to match. + if (strict && nbits != kBluestarHeavyBits) + return false; + + uint128_t data = 0; + match_result_t data_result; + + // Header + if (!matchMark(results->rawbuf[offset++], kBluestarHeavyHdrMark)) + return false; + if (!matchSpace(results->rawbuf[offset++], kBluestarHeavyHdrSpace)) + return false; + + // Data Section #1 + // e.g. data_result.data = 0xD5FED74FFA5FFA5FFF7F5CFDDC, nbits = 104 + data_result = matchData(&(results->rawbuf[offset]), 104, + kBluestarHeavyBitMark, kBluestarHeavyOneSpace, + kBluestarHeavyBitMark, kBluestarHeavyZeroSpace); + offset += data_result.used; + if (data_result.success == false) return false; // Fail + data <<= 104; // Make room for the new bits of data. + data |= data_result.data; + + // Header + if (!matchMark(results->rawbuf[offset++], kBluestarHeavyHdrMark)) + return false; + + // Success + results->decode_type = decode_type_t::BLUESTARHEAVY; + results->bits = nbits; + results->value = data; + results->command = 0; + results->address = 0; + return true; +} +#endif // DECODE_BLUESTARHEAVY + +#if DECODE_BLUESTARHEAVY +// Function should be safe over 64 bits. +/// Decode the supplied BluestarHeavy message. +/// Status: ALPHA / Untested. +/// @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::decodeBluestarHeavy(decode_results *results, uint16_t offset, const uint16_t nbits, const bool strict) { + if (results->rawlen < 2 * nbits + kBluestarHeavyOverhead - offset) + return false; // Too short a message to match. + if (strict && nbits != kBluestarHeavyBits) + return false; + + uint16_t pos = 0; + uint16_t used = 0; + + // Data Section #2 + // e.g. + // bits = 104; bytes = 13; + // *(results->state + pos) = {0xD5, 0xFE, 0xD7, 0x4F, 0xFA, 0x5F, 0xFA, 0x5F, 0xFF, 0x7F, 0x5C, 0xFD, 0xDC}; + used = matchGeneric(results->rawbuf + offset, results->state + pos, + results->rawlen - offset, 104, + kBluestarHeavyHdrMark, kBluestarHeavyHdrSpace, + kBluestarHeavyBitMark, kBluestarHeavyOneSpace, + kBluestarHeavyBitMark, kBluestarHeavyZeroSpace, + kBluestarHeavyHdrMark, kDefaultMessageGap, true); + if (used == 0) return false; // We failed to find any data. + offset += used; // Adjust for how much of the message we read. + pos += 13; // Adjust by how many bytes of data we read + + // Success + results->decode_type = decode_type_t::BLUESTARHEAVY; + results->bits = nbits; + return true; +} +#endif // DECODE_BLUESTARHEAVY +*/ \ No newline at end of file diff --git a/src/locale/defaults.h b/src/locale/defaults.h index 438cc5da3..774969c39 100644 --- a/src/locale/defaults.h +++ b/src/locale/defaults.h @@ -751,6 +751,9 @@ D_STR_INDIRECT " " D_STR_MODE #ifndef D_STR_ARRIS #define D_STR_ARRIS "ARRIS" #endif // D_STR_ARRIS +#ifndef D_STR_BLUESTARHEACY +#define D_STR_BLUESTARHEAVY "BLUESTARHEAVY" +#endif // D_STR_TESTEXAMPLE #ifndef D_STR_BOSCH #define D_STR_BOSCH "BOSCH" #endif // D_STR_BOSCH diff --git a/test/ir_BluestarHeavy_test.cpp b/test/ir_BluestarHeavy_test.cpp new file mode 100644 index 000000000..e69de29bb From 4d8eef1881da709c8d7e7b82eeca4bd357704089 Mon Sep 17 00:00:00 2001 From: harshbhosale01 Date: Tue, 23 Jul 2024 11:43:37 +0530 Subject: [PATCH 2/7] Resolved the errors with working IRsend --- src/IRremoteESP8266.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/IRremoteESP8266.h b/src/IRremoteESP8266.h index 0acda04da..839d23c67 100644 --- a/src/IRremoteESP8266.h +++ b/src/IRremoteESP8266.h @@ -1143,6 +1143,7 @@ enum decode_type_t { GORENJE, WOWWEE, CARRIER_AC84, // 125 + YORK, BLUESTARHEAVY, // Add new entries before this one, and update it to point to the last entry. kLastDecodeType = BLUESTARHEAVY, From dc9f9b091abc191602cb0be5de0ff52536afa74e Mon Sep 17 00:00:00 2001 From: harshbhosale01 Date: Wed, 24 Jul 2024 12:15:28 +0530 Subject: [PATCH 3/7] Changes ready to for PR --- src/IRrecv.cpp | 4 ++ src/IRrecv.h | 6 ++ src/ir_BluestarHeavy.cpp | 103 ++++++++++++++++----------------- test/ir_BluestarHeavy_test.cpp | 0 4 files changed, 61 insertions(+), 52 deletions(-) delete mode 100644 test/ir_BluestarHeavy_test.cpp diff --git a/src/IRrecv.cpp b/src/IRrecv.cpp index 173526104..316dfc149 100644 --- a/src/IRrecv.cpp +++ b/src/IRrecv.cpp @@ -1185,6 +1185,10 @@ bool IRrecv::decode(decode_results *results, irparams_t *save, DPRINTLN("Attempting York decode"); if (decodeYork(results, offset, kYorkBits)) return true; #endif // DECODE_YORK +#if DECODE_BLUESTARHEAVY + DPRINTLN("Attempting BluestarHeavy decode"); + if (decodeBluestarHeavy(results, offset, kBluestarHeavyBits)) return true; +#endif // DECODE_BLUESTARHEAVY // Typically new protocols are added above this line. } #if DECODE_HASH diff --git a/src/IRrecv.h b/src/IRrecv.h index 7adf5eb1b..3af26ae53 100644 --- a/src/IRrecv.h +++ b/src/IRrecv.h @@ -883,6 +883,12 @@ class IRrecv { const uint16_t kYorkBits, const bool strict = true); #endif // DECODE_YORK +#if DECODE_BLUESTARHEAVY + bool decodeBluestarHeavy(decode_results *results, + uint16_t kStartOffset, + const uint16_t kBluestarHeavyBits, + const bool strict = true); +#endif // DECODE_BLUESTARHEAVY }; #endif // IRRECV_H_ diff --git a/src/ir_BluestarHeavy.cpp b/src/ir_BluestarHeavy.cpp index a795d9c95..18366c2a5 100644 --- a/src/ir_BluestarHeavy.cpp +++ b/src/ir_BluestarHeavy.cpp @@ -56,58 +56,58 @@ void IRsend::sendBluestarHeavy(const uint8_t data[], const uint16_t nbytes, cons } #endif // SEND_BLUESTARHEAVY -/* -// DANGER: More than 64 bits detected. A uint64_t for 'data' won't work! -#if DECODE_BLUESTARHEAVY -// Function should be safe up to 64 bits. -/// Decode the supplied BluestarHeavy message. -/// Status: ALPHA / Untested. -/// @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::decodeBluestarHeavy(decode_results *results, uint16_t offset, const uint16_t nbits, const bool strict) { - if (results->rawlen < 2 * nbits + kBluestarHeavyOverhead - offset) - return false; // Too short a message to match. - if (strict && nbits != kBluestarHeavyBits) - return false; - - uint128_t data = 0; - match_result_t data_result; - - // Header - if (!matchMark(results->rawbuf[offset++], kBluestarHeavyHdrMark)) - return false; - if (!matchSpace(results->rawbuf[offset++], kBluestarHeavyHdrSpace)) - return false; - - // Data Section #1 - // e.g. data_result.data = 0xD5FED74FFA5FFA5FFF7F5CFDDC, nbits = 104 - data_result = matchData(&(results->rawbuf[offset]), 104, - kBluestarHeavyBitMark, kBluestarHeavyOneSpace, - kBluestarHeavyBitMark, kBluestarHeavyZeroSpace); - offset += data_result.used; - if (data_result.success == false) return false; // Fail - data <<= 104; // Make room for the new bits of data. - data |= data_result.data; - - // Header - if (!matchMark(results->rawbuf[offset++], kBluestarHeavyHdrMark)) - return false; - // Success - results->decode_type = decode_type_t::BLUESTARHEAVY; - results->bits = nbits; - results->value = data; - results->command = 0; - results->address = 0; - return true; -} -#endif // DECODE_BLUESTARHEAVY +// DANGER: More than 64 bits detected. A uint64_t for 'data' won't work! +// #if DECODE_BLUESTARHEAVY +// // Function should be safe up to 64 bits. +// /// Decode the supplied BluestarHeavy message. +// /// Status: ALPHA / Untested. +// /// @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::decodeBluestarHeavy(decode_results *results, uint16_t offset, const uint16_t nbits, const bool strict) { +// if (results->rawlen < 2 * nbits + kBluestarHeavyOverhead - offset) +// return false; // Too short a message to match. +// if (strict && nbits != kBluestarHeavyBits) +// return false; + +// uint64_t data = 0; +// match_result_t data_result; + +// // Header +// if (!matchMark(results->rawbuf[offset++], kBluestarHeavyHdrMark)) +// return false; +// if (!matchSpace(results->rawbuf[offset++], kBluestarHeavyHdrSpace)) +// return false; + +// // Data Section #1 +// // e.g. data_result.data = 0xD5FED74FFA5FFA5FFF7F5CFDDC, nbits = 104 +// data_result = matchData(&(results->rawbuf[offset]), 104, +// kBluestarHeavyBitMark, kBluestarHeavyOneSpace, +// kBluestarHeavyBitMark, kBluestarHeavyZeroSpace); +// offset += data_result.used; +// if (data_result.success == false) return false; // Fail +// data <<= 104; // Make room for the new bits of data. +// data |= data_result.data; + +// // Header +// if (!matchMark(results->rawbuf[offset++], kBluestarHeavyHdrMark)) +// return false; + +// // Success +// results->decode_type = decode_type_t::BLUESTARHEAVY; +// results->bits = nbits; +// results->value = data; +// results->command = 0; +// results->address = 0; +// return true; +// } +// #endif // DECODE_BLUESTARHEAVY #if DECODE_BLUESTARHEAVY // Function should be safe over 64 bits. @@ -148,4 +148,3 @@ bool IRrecv::decodeBluestarHeavy(decode_results *results, uint16_t offset, const return true; } #endif // DECODE_BLUESTARHEAVY -*/ \ No newline at end of file diff --git a/test/ir_BluestarHeavy_test.cpp b/test/ir_BluestarHeavy_test.cpp deleted file mode 100644 index e69de29bb..000000000 From 67458616b327c6c052f7882f0ef7310f12c2e65d Mon Sep 17 00:00:00 2001 From: harshbhosale01 Date: Wed, 24 Jul 2024 15:25:54 +0530 Subject: [PATCH 4/7] Applied changes to avoid warning that were encountered while running testing script --- src/ir_BluestarHeavy.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ir_BluestarHeavy.cpp b/src/ir_BluestarHeavy.cpp index 18366c2a5..dab7e012a 100644 --- a/src/ir_BluestarHeavy.cpp +++ b/src/ir_BluestarHeavy.cpp @@ -49,9 +49,9 @@ void IRsend::sendBluestarHeavy(const uint8_t data[], const uint16_t nbytes, cons kBluestarHeavyBitMark, kBluestarHeavyOneSpace, kBluestarHeavyBitMark, kBluestarHeavyZeroSpace, kBluestarHeavyHdrMark, kDefaultMessageGap, - data + pos, 13, // Bytes + data + pos, nbytes, // Bytes kBluestarHeavyFreq, true, kNoRepeat, kDutyDefault); - pos += 13; // Adjust by how many bytes of data we sent + pos += nbytes; // Adjust by how many bytes of data we sent } } #endif // SEND_BLUESTARHEAVY From a21b941ff0af0c8fef55d2a250e348dedb2be706 Mon Sep 17 00:00:00 2001 From: harshbhosale01 Date: Fri, 26 Jul 2024 12:14:13 +0530 Subject: [PATCH 5/7] Updated the suggested linting changes --- src/IRrecv.h | 4 +- src/IRremoteESP8266.h | 4 +- src/IRsend.h | 1 + src/ir_BluestarHeavy.cpp | 101 ++++----------------------------------- 4 files changed, 14 insertions(+), 96 deletions(-) diff --git a/src/IRrecv.h b/src/IRrecv.h index 3af26ae53..565db2b6c 100644 --- a/src/IRrecv.h +++ b/src/IRrecv.h @@ -885,8 +885,8 @@ class IRrecv { #endif // DECODE_YORK #if DECODE_BLUESTARHEAVY bool decodeBluestarHeavy(decode_results *results, - uint16_t kStartOffset, - const uint16_t kBluestarHeavyBits, + uint16_t offset = kStartOffset, + const uint16_t nbits = kBluestarHeavyBits, const bool strict = true); #endif // DECODE_BLUESTARHEAVY }; diff --git a/src/IRremoteESP8266.h b/src/IRremoteESP8266.h index 839d23c67..59be68ff0 100644 --- a/src/IRremoteESP8266.h +++ b/src/IRremoteESP8266.h @@ -1174,7 +1174,7 @@ const uint16_t kArgo3ConfigStateLength = 4; // Bytes const uint16_t kArgoDefaultRepeat = kNoRepeat; const uint16_t kArrisBits = 32; const uint16_t kBluestarHeavyStateLength = 13; -const uint16_t kBluestarHeavyBits = 104; +const uint16_t kBluestarHeavyBits = kBluestarHeavyStateLength * 8; const uint16_t kBosch144StateLength = 18; const uint16_t kBosch144Bits = kBosch144StateLength * 8; const uint16_t kCoolixBits = 24; @@ -1446,8 +1446,6 @@ const uint16_t kClimaButlerBits = 52; const uint16_t kYorkBits = 136; const uint16_t kYorkStateLength = 17; - - // Legacy defines. (Deprecated) #define AIWA_RC_T501_BITS kAiwaRcT501Bits #define ARGO_COMMAND_LENGTH kArgoStateLength diff --git a/src/IRsend.h b/src/IRsend.h index a8ee54fcc..1cd3f72c4 100644 --- a/src/IRsend.h +++ b/src/IRsend.h @@ -890,6 +890,7 @@ class IRsend { const uint16_t nbytes = kBluestarHeavyStateLength, const uint16_t repeat = kNoRepeat); #endif // SEND_BLUESTARHEAVY + protected: #ifdef UNIT_TEST #ifndef HIGH diff --git a/src/ir_BluestarHeavy.cpp b/src/ir_BluestarHeavy.cpp index dab7e012a..5301bf299 100644 --- a/src/ir_BluestarHeavy.cpp +++ b/src/ir_BluestarHeavy.cpp @@ -1,35 +1,25 @@ -// Copyright 2020 David Conran (crankyoldgit) +// Copyright 2024 Harsh Bhosale (harshbhosale01) /// @file /// @brief Support for BluestarHeavy protocol // Supports: -// Brand: Bluestar, Model: TODO add device and remote +// Brand: Bluestar, Model: TODO add device and remote #include "IRrecv.h" #include "IRsend.h" #include "IRutils.h" -// WARNING: This probably isn't directly usable. It's a guide only. - -// See https://github.com/crankyoldgit/IRremoteESP8266/wiki/Adding-support-for-a-new-IR-protocol -// for details of how to include this in the library. const uint16_t kBluestarHeavyHdrMark = 4912; const uint16_t kBluestarHeavyBitMark = 465; const uint16_t kBluestarHeavyHdrSpace = 5058; const uint16_t kBluestarHeavyOneSpace = 1548; const uint16_t kBluestarHeavyZeroSpace = 572; -const uint16_t kBluestarHeavyFreq = 38000; // Hz. (Guessing the most common frequency.) -//const uint16_t kBluestarHeavyBits = 104; // Move to IRremoteESP8266.h -//const uint16_t kBluestarHeavyStateLength = 13; // Move to IRremoteESP8266.h +const uint16_t kBluestarHeavyFreq = 38000; const uint16_t kBluestarHeavyOverhead = 3; -// DANGER: More than 64 bits detected. A uint64_t for 'data' won't work! - #if SEND_BLUESTARHEAVY -// Alternative >64bit function to send BLUESTARHEAVY messages -// Function should be safe over 64 bits. /// Send a BluestarHeavy formatted message. -/// Status: ALPHA / Untested. +/// Status: BETA / Tested. /// @param[in] data An array of bytes containing the IR command. /// It is assumed to be in MSB order for this code. /// e.g. @@ -39,80 +29,18 @@ const uint16_t kBluestarHeavyOverhead = 3; /// @param[in] nbytes Nr. of bytes of data in the array. (>=kBluestarHeavyStateLength) /// @param[in] repeat Nr. of times the message is to be repeated. void IRsend::sendBluestarHeavy(const uint8_t data[], const uint16_t nbytes, const uint16_t repeat) { - for (uint16_t r = 0; r <= repeat; r++) { - uint16_t pos = 0; - // Data Section #2 - // e.g. - // bits = 104; bytes = 13; - // *(data + pos) = {0xD5, 0xFE, 0xD7, 0x4F, 0xFA, 0x5F, 0xFA, 0x5F, 0xFF, 0x7F, 0x5C, 0xFD, 0xDC}; - sendGeneric(kBluestarHeavyHdrMark, kBluestarHeavyHdrSpace, + sendGeneric(kBluestarHeavyHdrMark, kBluestarHeavyHdrSpace, kBluestarHeavyBitMark, kBluestarHeavyOneSpace, kBluestarHeavyBitMark, kBluestarHeavyZeroSpace, kBluestarHeavyHdrMark, kDefaultMessageGap, - data + pos, nbytes, // Bytes - kBluestarHeavyFreq, true, kNoRepeat, kDutyDefault); - pos += nbytes; // Adjust by how many bytes of data we sent - } + data, nbytes, // Bytes + kBluestarHeavyFreq, true, repeat, kDutyDefault); } #endif // SEND_BLUESTARHEAVY - -// DANGER: More than 64 bits detected. A uint64_t for 'data' won't work! -// #if DECODE_BLUESTARHEAVY -// // Function should be safe up to 64 bits. -// /// Decode the supplied BluestarHeavy message. -// /// Status: ALPHA / Untested. -// /// @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::decodeBluestarHeavy(decode_results *results, uint16_t offset, const uint16_t nbits, const bool strict) { -// if (results->rawlen < 2 * nbits + kBluestarHeavyOverhead - offset) -// return false; // Too short a message to match. -// if (strict && nbits != kBluestarHeavyBits) -// return false; - -// uint64_t data = 0; -// match_result_t data_result; - -// // Header -// if (!matchMark(results->rawbuf[offset++], kBluestarHeavyHdrMark)) -// return false; -// if (!matchSpace(results->rawbuf[offset++], kBluestarHeavyHdrSpace)) -// return false; - -// // Data Section #1 -// // e.g. data_result.data = 0xD5FED74FFA5FFA5FFF7F5CFDDC, nbits = 104 -// data_result = matchData(&(results->rawbuf[offset]), 104, -// kBluestarHeavyBitMark, kBluestarHeavyOneSpace, -// kBluestarHeavyBitMark, kBluestarHeavyZeroSpace); -// offset += data_result.used; -// if (data_result.success == false) return false; // Fail -// data <<= 104; // Make room for the new bits of data. -// data |= data_result.data; - -// // Header -// if (!matchMark(results->rawbuf[offset++], kBluestarHeavyHdrMark)) -// return false; - -// // Success -// results->decode_type = decode_type_t::BLUESTARHEAVY; -// results->bits = nbits; -// results->value = data; -// results->command = 0; -// results->address = 0; -// return true; -// } -// #endif // DECODE_BLUESTARHEAVY - #if DECODE_BLUESTARHEAVY -// Function should be safe over 64 bits. /// Decode the supplied BluestarHeavy message. -/// Status: ALPHA / Untested. +/// Status: BETA / Tested. /// @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. @@ -120,27 +48,18 @@ void IRsend::sendBluestarHeavy(const uint8_t data[], const uint16_t nbytes, cons /// @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::decodeBluestarHeavy(decode_results *results, uint16_t offset, const uint16_t nbits, const bool strict) { - if (results->rawlen < 2 * nbits + kBluestarHeavyOverhead - offset) - return false; // Too short a message to match. if (strict && nbits != kBluestarHeavyBits) return false; - uint16_t pos = 0; uint16_t used = 0; - // Data Section #2 - // e.g. - // bits = 104; bytes = 13; - // *(results->state + pos) = {0xD5, 0xFE, 0xD7, 0x4F, 0xFA, 0x5F, 0xFA, 0x5F, 0xFF, 0x7F, 0x5C, 0xFD, 0xDC}; - used = matchGeneric(results->rawbuf + offset, results->state + pos, - results->rawlen - offset, 104, + used = matchGeneric(results->rawbuf + offset, results->state, + results->rawlen - offset, nbits, kBluestarHeavyHdrMark, kBluestarHeavyHdrSpace, kBluestarHeavyBitMark, kBluestarHeavyOneSpace, kBluestarHeavyBitMark, kBluestarHeavyZeroSpace, kBluestarHeavyHdrMark, kDefaultMessageGap, true); if (used == 0) return false; // We failed to find any data. - offset += used; // Adjust for how much of the message we read. - pos += 13; // Adjust by how many bytes of data we read // Success results->decode_type = decode_type_t::BLUESTARHEAVY; From dcd6e593fad197ba9d3529298cf9ed0c16f82156 Mon Sep 17 00:00:00 2001 From: harshbhosale01 Date: Fri, 26 Jul 2024 13:31:48 +0530 Subject: [PATCH 6/7] Changes according to lint tool suggestions --- src/IRremoteESP8266.h | 4 ++-- src/ir_BluestarHeavy.cpp | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/IRremoteESP8266.h b/src/IRremoteESP8266.h index 59be68ff0..b5daffaf8 100644 --- a/src/IRremoteESP8266.h +++ b/src/IRremoteESP8266.h @@ -957,7 +957,7 @@ #endif // DECODE_BLUESTARHEAVY #ifndef SEND_BLUESTARHEAVY #define SEND_BLUESTARHEAVY _IR_ENABLE_DEFAULT_ -#endif // SEND_BLUESTARHEAVY +#endif // SEND_BLUESTARHEAVY #if (DECODE_ARGO || DECODE_DAIKIN || DECODE_FUJITSU_AC || DECODE_GREE || \ DECODE_KELVINATOR || DECODE_MITSUBISHI_AC || DECODE_TOSHIBA_AC || \ @@ -1173,7 +1173,7 @@ const uint16_t kArgo3TimerStateLength = 9; // Bytes const uint16_t kArgo3ConfigStateLength = 4; // Bytes const uint16_t kArgoDefaultRepeat = kNoRepeat; const uint16_t kArrisBits = 32; -const uint16_t kBluestarHeavyStateLength = 13; +const uint16_t kBluestarHeavyStateLength = 13; const uint16_t kBluestarHeavyBits = kBluestarHeavyStateLength * 8; const uint16_t kBosch144StateLength = 18; const uint16_t kBosch144Bits = kBosch144StateLength * 8; diff --git a/src/ir_BluestarHeavy.cpp b/src/ir_BluestarHeavy.cpp index 5301bf299..5cc44bdac 100644 --- a/src/ir_BluestarHeavy.cpp +++ b/src/ir_BluestarHeavy.cpp @@ -14,7 +14,7 @@ const uint16_t kBluestarHeavyBitMark = 465; const uint16_t kBluestarHeavyHdrSpace = 5058; const uint16_t kBluestarHeavyOneSpace = 1548; const uint16_t kBluestarHeavyZeroSpace = 572; -const uint16_t kBluestarHeavyFreq = 38000; +const uint16_t kBluestarHeavyFreq = 38000; const uint16_t kBluestarHeavyOverhead = 3; #if SEND_BLUESTARHEAVY @@ -24,11 +24,13 @@ const uint16_t kBluestarHeavyOverhead = 3; /// It is assumed to be in MSB order for this code. /// e.g. /// @code -/// uint8_t data[kBluestarHeavyStateLength] = {0xD5, 0xFE, 0xD7, 0x4F, 0xFA, 0x5F, 0xFA, 0x5F, 0xFF, 0x7F, 0x5C, 0xFD, 0xDC}; +/// uint8_t data[kBluestarHeavyStateLength] = +/// {0xD5,0xFE,0xD7,0x4F,0xFA,0x5F,0xFA,0x5F,0xFF,0x7F,0x5C,0xFD,0xDC}; /// @endcode -/// @param[in] nbytes Nr. of bytes of data in the array. (>=kBluestarHeavyStateLength) +/// @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::sendBluestarHeavy(const uint8_t data[], const uint16_t nbytes, const uint16_t repeat) { +void IRsend::sendBluestarHeavy(const uint8_t data[], const uint16_t nbytes, + const uint16_t repeat) { sendGeneric(kBluestarHeavyHdrMark, kBluestarHeavyHdrSpace, kBluestarHeavyBitMark, kBluestarHeavyOneSpace, kBluestarHeavyBitMark, kBluestarHeavyZeroSpace, @@ -47,7 +49,8 @@ void IRsend::sendBluestarHeavy(const uint8_t data[], const uint16_t nbytes, cons /// @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::decodeBluestarHeavy(decode_results *results, uint16_t offset, const uint16_t nbits, const bool strict) { +bool IRrecv::decodeBluestarHeavy(decode_results *results, uint16_t offset, + const uint16_t nbits, const bool strict) { if (strict && nbits != kBluestarHeavyBits) return false; From d84ae2fbde1ab4f0abe3e8b2f76d935e0c79e68e Mon Sep 17 00:00:00 2001 From: harshbhosale01 Date: Fri, 26 Jul 2024 15:09:07 +0530 Subject: [PATCH 7/7] Swapped the values of the Zero and One Space --- src/ir_BluestarHeavy.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ir_BluestarHeavy.cpp b/src/ir_BluestarHeavy.cpp index 5cc44bdac..5d6452767 100644 --- a/src/ir_BluestarHeavy.cpp +++ b/src/ir_BluestarHeavy.cpp @@ -3,7 +3,7 @@ /// @brief Support for BluestarHeavy protocol // Supports: -// Brand: Bluestar, Model: TODO add device and remote +// Brand: Bluestar, Model: D716LXM0535A2400313 (Remote) #include "IRrecv.h" #include "IRsend.h" @@ -12,8 +12,8 @@ const uint16_t kBluestarHeavyHdrMark = 4912; const uint16_t kBluestarHeavyBitMark = 465; const uint16_t kBluestarHeavyHdrSpace = 5058; -const uint16_t kBluestarHeavyOneSpace = 1548; -const uint16_t kBluestarHeavyZeroSpace = 572; +const uint16_t kBluestarHeavyOneSpace = 572; +const uint16_t kBluestarHeavyZeroSpace = 1548; const uint16_t kBluestarHeavyFreq = 38000; const uint16_t kBluestarHeavyOverhead = 3; @@ -25,7 +25,7 @@ const uint16_t kBluestarHeavyOverhead = 3; /// e.g. /// @code /// uint8_t data[kBluestarHeavyStateLength] = -/// {0xD5,0xFE,0xD7,0x4F,0xFA,0x5F,0xFA,0x5F,0xFF,0x7F,0x5C,0xFD,0xDC}; +/// {0x2A,0x00,0x20,0xD0,0x05,0xA0,0x05,0xA0,0x00,0x80,0xBA,0x02,0x23}; /// @endcode /// @param[in] nbytes Nr. of bytes of data in the array. /// @param[in] repeat Nr. of times the message is to be repeated.