Skip to content

Commit 63794b3

Browse files
authored
adding checksum hack in case of a power off
1 parent eabb0f0 commit 63794b3

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

rawirdecode/Samsung.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,14 @@
33
// Samsung with remote ARH-465 or remote ARH-1362
44

55
bool decodeSamsung(byte *bytes, int byteCount)
6-
{
6+
{
77
// If this looks like a Samsung code...
88
if (bytes[0] == 0x02
9-
&& ((byteCount == 21 && bytes[1] == 0xB2) || (byteCount == 14 && bytes[1] == 0x92))
9+
&& (byteCount == 14 && bytes[1] == 0x92)
1010
&& bytes[2] == 0x0F)
1111
{
1212
Serial.println(F("Looks like a short 14 bytes Samsung protocol"));
13-
14-
// Power mode
15-
if (byteCount == 21)
16-
{
17-
Serial.println(F("POWER OFF"));
18-
return true;
19-
}
13+
2014
Serial.println(F("POWER ON"));
2115

2216
// Operating mode
@@ -121,15 +115,15 @@ bool decodeSamsung(byte *bytes, int byteCount)
121115
&& ((byteCount == 21 && bytes[1] == 0xB2) || (byteCount == 21 && bytes[1] == 0x92))
122116
&& bytes[2] == 0x0F)
123117
{
124-
Serial.println(F("Looks like a 21 bytes long Samsung protocol specific ARH-1362 remote"));
118+
Serial.println(F("Looks like a 21 bytes long Samsung protocol"));
125119

126120
// Power mode
127121
if (byteCount == 21 && bytes[1] == 0xB2)
128122
{
129123
Serial.println(F("POWER OFF"));
130-
return true;
131124
}
132-
Serial.println(F("POWER ON"));
125+
else
126+
Serial.println(F("POWER ON"));
133127

134128
// Operating mode | fan speed auto
135129
switch (bytes[19] & 0xF0) {
@@ -187,7 +181,7 @@ bool decodeSamsung(byte *bytes, int byteCount)
187181
// Transform the number of ONE bits to the actual checksum
188182
checksum = 28 - checksum;
189183
checksum <<= 4;
190-
checksum += 0x02;
184+
checksum |= (byteCount == 21 && bytes[1] == 0xB2) ? 0x22 : 0x02;
191185

192186
Serial.print(F("Checksum '0x"));
193187
Serial.print(checksum, HEX);

0 commit comments

Comments
 (0)