Skip to content

Commit a21b941

Browse files
Updated the suggested linting changes
1 parent 6745861 commit a21b941

File tree

4 files changed

+14
-96
lines changed

4 files changed

+14
-96
lines changed

src/IRrecv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,8 +885,8 @@ class IRrecv {
885885
#endif // DECODE_YORK
886886
#if DECODE_BLUESTARHEAVY
887887
bool decodeBluestarHeavy(decode_results *results,
888-
uint16_t kStartOffset,
889-
const uint16_t kBluestarHeavyBits,
888+
uint16_t offset = kStartOffset,
889+
const uint16_t nbits = kBluestarHeavyBits,
890890
const bool strict = true);
891891
#endif // DECODE_BLUESTARHEAVY
892892
};

src/IRremoteESP8266.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ const uint16_t kArgo3ConfigStateLength = 4; // Bytes
11741174
const uint16_t kArgoDefaultRepeat = kNoRepeat;
11751175
const uint16_t kArrisBits = 32;
11761176
const uint16_t kBluestarHeavyStateLength = 13;
1177-
const uint16_t kBluestarHeavyBits = 104;
1177+
const uint16_t kBluestarHeavyBits = kBluestarHeavyStateLength * 8;
11781178
const uint16_t kBosch144StateLength = 18;
11791179
const uint16_t kBosch144Bits = kBosch144StateLength * 8;
11801180
const uint16_t kCoolixBits = 24;
@@ -1446,8 +1446,6 @@ const uint16_t kClimaButlerBits = 52;
14461446
const uint16_t kYorkBits = 136;
14471447
const uint16_t kYorkStateLength = 17;
14481448

1449-
1450-
14511449
// Legacy defines. (Deprecated)
14521450
#define AIWA_RC_T501_BITS kAiwaRcT501Bits
14531451
#define ARGO_COMMAND_LENGTH kArgoStateLength

src/IRsend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,7 @@ class IRsend {
890890
const uint16_t nbytes = kBluestarHeavyStateLength,
891891
const uint16_t repeat = kNoRepeat);
892892
#endif // SEND_BLUESTARHEAVY
893+
893894
protected:
894895
#ifdef UNIT_TEST
895896
#ifndef HIGH

src/ir_BluestarHeavy.cpp

Lines changed: 10 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,25 @@
1-
// Copyright 2020 David Conran (crankyoldgit)
1+
// Copyright 2024 Harsh Bhosale (harshbhosale01)
22
/// @file
33
/// @brief Support for BluestarHeavy protocol
44

55
// Supports:
6-
// Brand: Bluestar, Model: TODO add device and remote
6+
// Brand: Bluestar, Model: TODO add device and remote
77

88
#include "IRrecv.h"
99
#include "IRsend.h"
1010
#include "IRutils.h"
1111

12-
// WARNING: This probably isn't directly usable. It's a guide only.
13-
14-
// See https://github.com/crankyoldgit/IRremoteESP8266/wiki/Adding-support-for-a-new-IR-protocol
15-
// for details of how to include this in the library.
1612
const uint16_t kBluestarHeavyHdrMark = 4912;
1713
const uint16_t kBluestarHeavyBitMark = 465;
1814
const uint16_t kBluestarHeavyHdrSpace = 5058;
1915
const uint16_t kBluestarHeavyOneSpace = 1548;
2016
const uint16_t kBluestarHeavyZeroSpace = 572;
21-
const uint16_t kBluestarHeavyFreq = 38000; // Hz. (Guessing the most common frequency.)
22-
//const uint16_t kBluestarHeavyBits = 104; // Move to IRremoteESP8266.h
23-
//const uint16_t kBluestarHeavyStateLength = 13; // Move to IRremoteESP8266.h
17+
const uint16_t kBluestarHeavyFreq = 38000;
2418
const uint16_t kBluestarHeavyOverhead = 3;
25-
// DANGER: More than 64 bits detected. A uint64_t for 'data' won't work!
26-
2719

2820
#if SEND_BLUESTARHEAVY
29-
// Alternative >64bit function to send BLUESTARHEAVY messages
30-
// Function should be safe over 64 bits.
3121
/// Send a BluestarHeavy formatted message.
32-
/// Status: ALPHA / Untested.
22+
/// Status: BETA / Tested.
3323
/// @param[in] data An array of bytes containing the IR command.
3424
/// It is assumed to be in MSB order for this code.
3525
/// e.g.
@@ -39,108 +29,37 @@ const uint16_t kBluestarHeavyOverhead = 3;
3929
/// @param[in] nbytes Nr. of bytes of data in the array. (>=kBluestarHeavyStateLength)
4030
/// @param[in] repeat Nr. of times the message is to be repeated.
4131
void IRsend::sendBluestarHeavy(const uint8_t data[], const uint16_t nbytes, const uint16_t repeat) {
42-
for (uint16_t r = 0; r <= repeat; r++) {
43-
uint16_t pos = 0;
44-
// Data Section #2
45-
// e.g.
46-
// bits = 104; bytes = 13;
47-
// *(data + pos) = {0xD5, 0xFE, 0xD7, 0x4F, 0xFA, 0x5F, 0xFA, 0x5F, 0xFF, 0x7F, 0x5C, 0xFD, 0xDC};
48-
sendGeneric(kBluestarHeavyHdrMark, kBluestarHeavyHdrSpace,
32+
sendGeneric(kBluestarHeavyHdrMark, kBluestarHeavyHdrSpace,
4933
kBluestarHeavyBitMark, kBluestarHeavyOneSpace,
5034
kBluestarHeavyBitMark, kBluestarHeavyZeroSpace,
5135
kBluestarHeavyHdrMark, kDefaultMessageGap,
52-
data + pos, nbytes, // Bytes
53-
kBluestarHeavyFreq, true, kNoRepeat, kDutyDefault);
54-
pos += nbytes; // Adjust by how many bytes of data we sent
55-
}
36+
data, nbytes, // Bytes
37+
kBluestarHeavyFreq, true, repeat, kDutyDefault);
5638
}
5739
#endif // SEND_BLUESTARHEAVY
5840

59-
60-
// DANGER: More than 64 bits detected. A uint64_t for 'data' won't work!
61-
// #if DECODE_BLUESTARHEAVY
62-
// // Function should be safe up to 64 bits.
63-
// /// Decode the supplied BluestarHeavy message.
64-
// /// Status: ALPHA / Untested.
65-
// /// @param[in,out] results Ptr to the data to decode & where to store the decode
66-
// /// @param[in] offset The starting index to use when attempting to decode the
67-
// /// raw data. Typically/Defaults to kStartOffset.
68-
// /// @param[in] nbits The number of data bits to expect.
69-
// /// @param[in] strict Flag indicating if we should perform strict matching.
70-
// /// @return A boolean. True if it can decode it, false if it can't.
71-
72-
73-
// bool IRrecv::decodeBluestarHeavy(decode_results *results, uint16_t offset, const uint16_t nbits, const bool strict) {
74-
// if (results->rawlen < 2 * nbits + kBluestarHeavyOverhead - offset)
75-
// return false; // Too short a message to match.
76-
// if (strict && nbits != kBluestarHeavyBits)
77-
// return false;
78-
79-
// uint64_t data = 0;
80-
// match_result_t data_result;
81-
82-
// // Header
83-
// if (!matchMark(results->rawbuf[offset++], kBluestarHeavyHdrMark))
84-
// return false;
85-
// if (!matchSpace(results->rawbuf[offset++], kBluestarHeavyHdrSpace))
86-
// return false;
87-
88-
// // Data Section #1
89-
// // e.g. data_result.data = 0xD5FED74FFA5FFA5FFF7F5CFDDC, nbits = 104
90-
// data_result = matchData(&(results->rawbuf[offset]), 104,
91-
// kBluestarHeavyBitMark, kBluestarHeavyOneSpace,
92-
// kBluestarHeavyBitMark, kBluestarHeavyZeroSpace);
93-
// offset += data_result.used;
94-
// if (data_result.success == false) return false; // Fail
95-
// data <<= 104; // Make room for the new bits of data.
96-
// data |= data_result.data;
97-
98-
// // Header
99-
// if (!matchMark(results->rawbuf[offset++], kBluestarHeavyHdrMark))
100-
// return false;
101-
102-
// // Success
103-
// results->decode_type = decode_type_t::BLUESTARHEAVY;
104-
// results->bits = nbits;
105-
// results->value = data;
106-
// results->command = 0;
107-
// results->address = 0;
108-
// return true;
109-
// }
110-
// #endif // DECODE_BLUESTARHEAVY
111-
11241
#if DECODE_BLUESTARHEAVY
113-
// Function should be safe over 64 bits.
11442
/// Decode the supplied BluestarHeavy message.
115-
/// Status: ALPHA / Untested.
43+
/// Status: BETA / Tested.
11644
/// @param[in,out] results Ptr to the data to decode & where to store the decode
11745
/// @param[in] offset The starting index to use when attempting to decode the
11846
/// raw data. Typically/Defaults to kStartOffset.
11947
/// @param[in] nbits The number of data bits to expect.
12048
/// @param[in] strict Flag indicating if we should perform strict matching.
12149
/// @return A boolean. True if it can decode it, false if it can't.
12250
bool IRrecv::decodeBluestarHeavy(decode_results *results, uint16_t offset, const uint16_t nbits, const bool strict) {
123-
if (results->rawlen < 2 * nbits + kBluestarHeavyOverhead - offset)
124-
return false; // Too short a message to match.
12551
if (strict && nbits != kBluestarHeavyBits)
12652
return false;
12753

128-
uint16_t pos = 0;
12954
uint16_t used = 0;
13055

131-
// Data Section #2
132-
// e.g.
133-
// bits = 104; bytes = 13;
134-
// *(results->state + pos) = {0xD5, 0xFE, 0xD7, 0x4F, 0xFA, 0x5F, 0xFA, 0x5F, 0xFF, 0x7F, 0x5C, 0xFD, 0xDC};
135-
used = matchGeneric(results->rawbuf + offset, results->state + pos,
136-
results->rawlen - offset, 104,
56+
used = matchGeneric(results->rawbuf + offset, results->state,
57+
results->rawlen - offset, nbits,
13758
kBluestarHeavyHdrMark, kBluestarHeavyHdrSpace,
13859
kBluestarHeavyBitMark, kBluestarHeavyOneSpace,
13960
kBluestarHeavyBitMark, kBluestarHeavyZeroSpace,
14061
kBluestarHeavyHdrMark, kDefaultMessageGap, true);
14162
if (used == 0) return false; // We failed to find any data.
142-
offset += used; // Adjust for how much of the message we read.
143-
pos += 13; // Adjust by how many bytes of data we read
14463

14564
// Success
14665
results->decode_type = decode_type_t::BLUESTARHEAVY;

0 commit comments

Comments
 (0)