Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions src/IRrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,10 @@ bool IRrecv::decode(decode_results *results, irparams_t *save,
DPRINTLN("Attempting Bose decode");
if (decodeBose(results, offset)) return true;
#endif // DECODE_BOSE
#if DECODE_ARRIS
DPRINTLN("Attempting Arris decode");
if (decodeArris(results, offset)) return true;
#endif // DECODE_ARRIS
// Typically new protocols are added above this line.
}
#if DECODE_HASH
Expand Down Expand Up @@ -1811,6 +1815,7 @@ uint16_t IRrecv::matchManchesterData(volatile const uint16_t *data_ptr,
const int16_t excess,
const bool MSBfirst,
const bool GEThomas) {
DPRINTLN("DEBUG: Entered matchManchesterData");
uint16_t offset = 0;
uint64_t data = 0;
uint16_t nr_half_periods = 0;
Expand All @@ -1824,7 +1829,10 @@ uint16_t IRrecv::matchManchesterData(volatile const uint16_t *data_ptr,
uint16_t min_remaining = nbits;

// Check if there is enough capture buffer to possibly have the message.
if (remaining < min_remaining) return 0; // Nope, so abort.
if (remaining < min_remaining) {
DPRINTLN("DEBUG: Ran out of capture buffer!");
return 0; // Nope, so abort.
}

// Convert to ticks. Optimisation: Saves on math/extra instructions later.
uint16_t bank = starting_balance / kRawTick;
Expand All @@ -1847,33 +1855,52 @@ uint16_t IRrecv::matchManchesterData(volatile const uint16_t *data_ptr,
while ((offset < remaining || bank) &&
nr_half_periods < expected_half_periods) {
// Get the next entry if we haven't anything existing to process.
DPRINT("DEBUG: Offset = ");
DPRINTLN(offset);
if (!bank) bank = *(data_ptr + offset++);
DPRINT("DEBUG: Bank = ");
DPRINTLN(bank * kRawTick);
// Check if we don't have a short interval.
if (!match(bank, half_period, tolerance, excess)) return 0; // Not valid.
DPRINTLN("DEBUG: Checking for short interval");
if (!match(bank, half_period, tolerance, excess)) {
DPRINTLN("DEBUG: It is. Exiting");
return 0; // Not valid.
}
// We've succeeded in matching half a period, so count it.
nr_half_periods++;
DPRINT("DEBUG: Half Periods = ");
DPRINTLN(nr_half_periods);
// We've now used up our bank, so refill it with the next item, unless we
// are at the end of the capture buffer.
// If we are assume a single half period of "space".
if (offset < remaining)
if (offset < remaining) {
DPRINT("DEBUG: Offset = ");
DPRINTLN(offset);
bank = *(data_ptr + offset++);
else if (offset == remaining)
} else if (offset == remaining) {
bank = raw_half_period;
else
} else {
return 0; // We are out of buffer, so abort!
}
DPRINT("DEBUG: Bank = ");
DPRINTLN(bank * kRawTick);

// Shift the data along and add our new bit.
DPRINT("DEBUG: Adding bit: ");
DPRINTLN((currentBit ? "1" : "0"));
data <<= 1;
data |= currentBit;

// Check if we have a long interval.
if (match(bank, half_period * 2, tolerance, excess)) {
// It is, so flip the bit we need to append, and remove a half_period of
// time from the bank.
DPRINTLN("DEBUG: long interval detected");
currentBit = !currentBit;
bank -= raw_half_period;
} else if (match(bank, half_period, tolerance, excess)) {
// It is a short interval, so eat up all the time and move on.
DPRINTLN("DEBUG: short interval detected");
bank = 0;
} else if (nr_half_periods == expected_half_periods - 1 &&
matchAtLeast(bank, half_period, tolerance, excess)) {
Expand Down
4 changes: 4 additions & 0 deletions src/IRrecv.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ class IRrecv {
bool decodeArgo(decode_results *results, uint16_t offset = kStartOffset,
const uint16_t nbits = kArgoBits, const bool strict = true);
#endif // DECODE_ARGO
#if DECODE_ARRIS
bool decodeArris(decode_results *results, uint16_t offset = kStartOffset,
const uint16_t nbits = kArrisBits, const bool strict = true);
#endif // DECODE_ARRIS
#if DECODE_SONY
bool decodeSony(decode_results *results, uint16_t offset = kStartOffset,
const uint16_t nbits = kSonyMinBits,
Expand Down
11 changes: 10 additions & 1 deletion src/IRremoteESP8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,13 @@
#define SEND_BOSE _IR_ENABLE_DEFAULT_
#endif // SEND_BOSE

#ifndef DECODE_ARRIS
#define DECODE_ARRIS _IR_ENABLE_DEFAULT_
#endif // DECODE_ARRIS
#ifndef SEND_ARRIS
#define SEND_ARRIS _IR_ENABLE_DEFAULT_
#endif // SEND_ARRIS

#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 || \
Expand Down Expand Up @@ -951,8 +958,9 @@ enum decode_type_t {
TROTEC_3550,
SANYO_AC88, // 105
BOSE,
ARRIS,
// Add new entries before this one, and update it to point to the last entry.
kLastDecodeType = BOSE,
kLastDecodeType = ARRIS,
};

// Message lengths & required repeat values
Expand All @@ -970,6 +978,7 @@ const uint16_t kAmcorDefaultRepeat = kSingleRepeat;
const uint16_t kArgoStateLength = 12;
const uint16_t kArgoBits = kArgoStateLength * 8;
const uint16_t kArgoDefaultRepeat = kNoRepeat;
const uint16_t kArrisBits = 32;
const uint16_t kCoolixBits = 24;
const uint16_t kCoolixDefaultRepeat = kSingleRepeat;
const uint16_t kCarrierAcBits = 32;
Expand Down
8 changes: 7 additions & 1 deletion src/IRsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ uint16_t IRsend::defaultBits(const decode_type_t protocol) {
case LG:
case LG2:
return 28;
case ARRIS:
case CARRIER_AC:
case ELITESCREENS:
case EPSON:
Expand Down Expand Up @@ -790,7 +791,12 @@ bool IRsend::send(const decode_type_t type, const uint64_t data,
case AIWA_RC_T501:
sendAiwaRCT501(data, nbits, min_repeat);
break;
#endif
#endif // SEND_AIWA_RC_T501
#if SEND_ARRIS
case ARRIS:
sendArris(data, nbits, min_repeat);
break;
#endif // SEND_ARRIS
#if SEND_BOSE
case BOSE:
sendBose(data, nbits, min_repeat);
Expand Down
4 changes: 4 additions & 0 deletions src/IRsend.h
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,10 @@ class IRsend {
void sendBose(const uint64_t data, const uint16_t nbits = kBoseBits,
const uint16_t repeat = kNoRepeat);
#endif // SEND_BOSE
#if SEND_ARRIS
void sendArris(const uint64_t data, const uint16_t nbits = kArrisBits,
const uint16_t repeat = kNoRepeat);
#endif // SEND_ARRIS

protected:
#ifdef UNIT_TEST
Expand Down
1 change: 1 addition & 0 deletions src/IRtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,5 +293,6 @@ const PROGMEM char *kAllProtocolNamesStr =
D_STR_TROTEC_3550 "\x0"
D_STR_SANYO_AC88 "\x0"
D_STR_BOSE "\x0"
D_STR_ARRIS "\x0"
///< New protocol strings should be added just above this line.
"\x0"; ///< This string requires double null termination.
79 changes: 79 additions & 0 deletions src/ir_Arris.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Copyright 2021 David Conran
#include "IRrecv.h"
#include "IRsend.h"

/// @file
/// @brief Arris "Manchester code" based protocol.
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/1595

// Supports:
// Brand: Arris, Model: VIP1113M Set-top box

const uint8_t kArrisOverhead = 2;
const uint16_t kArrisHalfClockPeriod = 320; // uSeconds
const uint16_t kArrisHdrMark = 8 * kArrisHalfClockPeriod; // uSeconds
const uint16_t kArrisHdrSpace = 6 * kArrisHalfClockPeriod; // uSeconds
const uint16_t kArrisGapSpace = 18.5 * kArrisHalfClockPeriod; // uSeconds

#if SEND_ARRIS
/// Send an Arris Manchester Code formatted message.
/// Status: ALPHA / Untested.
/// @param[in] data The message to be sent.
/// @param[in] nbits The number of bits of the message to be sent.
/// @param[in] repeat The number of times the command is to be repeated.
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/1595
void IRsend::sendArris(const uint64_t data, const uint16_t nbits,
const uint16_t repeat) {
enableIROut(38);
for (uint16_t r = 0; r <= repeat; r++) {
// Header (part 1)
mark(kArrisHdrMark);
space(kArrisHdrSpace);
// Header (part 2) + Data + Footer
sendManchester(kArrisHalfClockPeriod * 2, 0, kArrisHalfClockPeriod,
0, kArrisGapSpace, data, nbits);
}
}
#endif // SEND_ARRIS

#if DECODE_ARRIS
/// Decode the supplied Arris "Manchester code" message.
///
/// Status: ALPHA / Untested.
/// @param[in,out] results Ptr to the data to decode & where to store the decode
/// result.
/// @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.
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/1595
bool IRrecv::decodeArris(decode_results *results, uint16_t offset,
const uint16_t nbits, const bool strict) {
if (results->rawlen < nbits + kArrisOverhead - offset)
return false; // Too short a message to match.

// Compliance
if (strict && nbits != kArrisBits)
return false; // Doesn't match our protocol defn.

// Header (part 1)
if (!matchMark(results->rawbuf[offset++], kArrisHdrMark)) return false;
if (!matchSpace(results->rawbuf[offset++], kArrisHdrSpace)) return false;

// Header (part 2) + Data
if (!matchManchester(results->rawbuf + offset, &results->value,
results->rawlen - offset, nbits,
kArrisHalfClockPeriod * 2, 0,
kArrisHalfClockPeriod, 0, 0,
false, kUseDefTol, kMarkExcess, true, false))
return false;

// Success
results->decode_type = decode_type_t::ARRIS;
results->bits = nbits;
results->address = 0;
results->command = 0;
return true;
}
#endif // DECODE_ARRIS
3 changes: 3 additions & 0 deletions src/locale/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,9 @@
#ifndef D_STR_ARGO
#define D_STR_ARGO "ARGO"
#endif // D_STR_ARGO
#ifndef D_STR_ARRIS
#define D_STR_ARRIS "ARRIS"
#endif // D_STR_ARRIS
#ifndef D_STR_BOSE
#define D_STR_BOSE "BOSE"
#endif // D_STR_BOSE
Expand Down
Loading