MCPcopy Create free account
hub / github.com/Arduino-IRremote/Arduino-IRremote / decodeNECMSB

Method decodeNECMSB

src/ir_NEC.hpp:332–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330 *********************************************************************************/
331
332bool IRrecv::decodeNECMSB(decode_results *aResults) {
333 unsigned int offset = 1; // Index in to results; Skip first space.
334
335// Check header "mark"
336 if (!matchMark(aResults->rawbuf[offset], NEC_HEADER_MARK)) {
337 return false;
338 }
339 offset++;
340
341// Check for repeat
342 if ((aResults->rawlen == 4) && matchSpace(aResults->rawbuf[offset], NEC_REPEAT_HEADER_SPACE)
343 && matchMark(aResults->rawbuf[offset + 1], NEC_BIT_MARK)) {
344 aResults->bits = 0;
345 aResults->value = 0xFFFFFFFF;
346 decodedIRData.flags |= IRDATA_FLAGS_IS_REPEAT;
347 decodedIRData.protocol = NEC;
348 return true;
349 }
350
351 // Check we have the right amount of data (32). +4 for initial gap, start bit mark and space + stop bit mark
352 if (aResults->rawlen != (2 * NEC_BITS) + 4) {
353 DEBUG_PRINT(F("NEC MSB: Data length="));
354 DEBUG_PRINT(aResults->rawlen);
355 DEBUG_PRINTLN(F(" is not 68"));
356 return false;
357 }
358
359// Check header "space"
360 if (!matchSpace(aResults->rawbuf[offset], NEC_HEADER_SPACE)) {
361 DEBUG_PRINTLN(F("NEC MSB: Header space length is wrong"));
362 return false;
363 }
364 offset++;
365
366 decodePulseDistanceWidthData(NEC_BITS, offset, NEC_BIT_MARK, NEC_ONE_SPACE, 0, PROTOCOL_IS_MSB_FIRST);
367
368 // Stop bit
369 if (!matchMark(aResults->rawbuf[offset + (2 * NEC_BITS)], NEC_BIT_MARK)) {
370 DEBUG_PRINTLN(F("NEC MSB: Stop bit mark length is wrong"));
371 return false;
372 }
373
374// Success
375 aResults->value = decodedIRData.decodedRawData;
376 aResults->bits = NEC_BITS;
377 aResults->decode_type = NEC;
378 decodedIRData.protocol = NEC;
379
380 return true;
381}
382
383/**
384 * With Send sendNECMSB() you can send your old 32 bit codes.

Callers

nothing calls this directly

Calls 2

matchMarkFunction · 0.85
matchSpaceFunction · 0.85

Tested by

no test coverage detected