* We cannot decode frames with 8 command bits and then 8 inverted command bits LSB and 16 bit address, * because in this case we always assume 8 bit address. * This is, because we did not see 8 bit command and real 16 bit address in the wild. */
| 268 | * This is, because we did not see 8 bit command and real 16 bit address in the wild. |
| 269 | */ |
| 270 | bool IRrecv::decodeSamsung() { |
| 271 | |
| 272 | // Check we have enough data (68). The +4 is for initial gap, start bit mark and space + stop bit mark |
| 273 | if (!(decodedIRData.rawlen == ((2 * SAMSUNG_BITS) + 4) || decodedIRData.rawlen == ((2 * SAMSUNG48_BITS) + 4) |
| 274 | || (decodedIRData.rawlen == 6))) { |
| 275 | DEBUG_PRINT(F("Samsung: Data length=")); |
| 276 | DEBUG_PRINT(decodedIRData.rawlen); |
| 277 | DEBUG_PRINTLN(F(" is not 6 or 68 or 100")); |
| 278 | return false; |
| 279 | } |
| 280 | |
| 281 | if (!checkHeader_P(&SamsungProtocolConstants)) { |
| 282 | return false; |
| 283 | } |
| 284 | |
| 285 | // Check for SansungLG style repeat |
| 286 | if (lastDecodedProtocol == SAMSUNGLG && decodedIRData.rawlen == 6) { |
| 287 | decodedIRData.flags = IRDATA_FLAGS_IS_REPEAT | IRDATA_FLAGS_IS_PROTOCOL_WITH_DIFFERENT_REPEAT | IRDATA_FLAGS_IS_LSB_FIRST; |
| 288 | decodedIRData.address = lastDecodedAddress; |
| 289 | decodedIRData.command = lastDecodedCommand; |
| 290 | decodedIRData.protocol = SAMSUNGLG; |
| 291 | return true; |
| 292 | } |
| 293 | |
| 294 | /* |
| 295 | * Decode first 32 bits |
| 296 | */ |
| 297 | decodePulseDistanceWidthData_P(&SamsungProtocolConstants, SAMSUNG_BITS, 3); |
| 298 | LongUnion tValue; |
| 299 | tValue.ULong = decodedIRData.decodedRawData; |
| 300 | decodedIRData.address = tValue.UWord.LowWord; |
| 301 | |
| 302 | if (decodedIRData.rawlen == (2 * SAMSUNG48_BITS) + 4) { |
| 303 | /* |
| 304 | * Samsung48 |
| 305 | */ |
| 306 | // decode additional 16 bit |
| 307 | decodePulseDistanceWidthData_P(&SamsungProtocolConstants, (SAMSUNG_COMMAND32_BITS - SAMSUNG_COMMAND16_BITS), |
| 308 | 3 + (2 * SAMSUNG_BITS)); |
| 309 | |
| 310 | /* |
| 311 | * LSB data is already in tValue.UWord.HighWord! |
| 312 | * Put latest (MSB) bits in LowWord, LSB first would have them expect in HighWord so keep this in mind for decoding below |
| 313 | */ |
| 314 | tValue.UWord.LowWord = decodedIRData.decodedRawData; // We have only 16 bit in decodedRawData here |
| 315 | #if __INT_WIDTH__ >= 32 |
| 316 | // workaround until complete refactoring for 64 bit |
| 317 | decodedIRData.decodedRawData = (decodedIRData.decodedRawData << 32)| tValue.UWord.HighWord << 16 | decodedIRData.address; // store all 48 bits in decodedRawData |
| 318 | #endif |
| 319 | |
| 320 | /* |
| 321 | * Check parity of 32 bit command |
| 322 | */ |
| 323 | // receive 2 * (8 bits then 8 inverted bits) LSB first |
| 324 | if (tValue.UByte.MidHighByte != (uint8_t)(~tValue.UByte.HighByte) |
| 325 | && tValue.UByte.LowByte != (uint8_t)(~tValue.UByte.MidLowByte)) { |
| 326 | decodedIRData.flags = IRDATA_FLAGS_PARITY_FAILED | IRDATA_FLAGS_IS_LSB_FIRST; |
| 327 | } |
nothing calls this directly
no outgoing calls
no test coverage detected