IRremote
ir_BoseWave.hpp
Go to the documentation of this file.
1 /*
2  * ir_BoseWave.cpp
3  *
4  * Contains functions for receiving and sending Bose IR Protocol
5  *
6  * This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
7  *
8  */
9 #ifndef _IR_BOSEWAVE_HPP
10 #define _IR_BOSEWAVE_HPP
11 
12 #if defined(DEBUG) && !defined(LOCAL_DEBUG)
13 #define LOCAL_DEBUG
14 #else
15 //#define LOCAL_DEBUG // This enables debug output only for this file
16 #endif
17 
21 //==============================================================================
22 // BBBB OOO SSSS EEEEE
23 // B B O O S E
24 // BB B O O SSS EEEE
25 // B B O O S E
26 // BBBB OOO SSSS EEEEE
27 //==============================================================================
28 // see http://lirc.sourceforge.net/remotes/bose/WAVERADIO
29 // see: https://www.mikrocontroller.net/articles/IRMP_-_english#BOSE
30 //
31 // Support for Bose Wave Radio CD initially provided by https://github.com/uvotguy.
32 //
33 // As seen on my trusty oscilloscope, there is no repeat code. Instead, when I
34 // press and hold a button on my remote, it sends a command, makes a 51.2ms space,
35 // and resends the command, etc, etc.
36 // LSB first, 1 start bit + 8 bit data + 8 bit inverted data + 1 stop bit.
37 #define BOSEWAVE_BITS 16 // Command and inverted command
38 
39 #define BOSEWAVE_HEADER_MARK 1014 // 1014 are 39 clock periods (I counted 3 times!)
40 #define BOSEWAVE_HEADER_SPACE 1468 // 1468(measured), 1456 are 56 clock periods
41 #define BOSEWAVE_BIT_MARK 520 // 520 are 20 clock periods
42 #define BOSEWAVE_ZERO_SPACE 468 // 468 are 18 clock periods
43 #define BOSEWAVE_ONE_SPACE 1468 // 1468(measured), 1456 are 56 clock periods
44 
45 #define BOSEWAVE_REPEAT_PERIOD 75000
46 #define BOSEWAVE_REPEAT_DISTANCE 50000
47 #define BOSEWAVE_MAXIMUM_REPEAT_DISTANCE 62000
48 
52 
53 /************************************
54  * Start of send and decode functions
55  ************************************/
56 
57 void IRsend::sendBoseWave(uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
58 
59  // send 8 command bits and then 8 inverted command bits LSB first
60  uint16_t tData = ((~aCommand) << 8) | aCommand;
62 }
63 
65 
67  return false;
68  }
69 
70  // Check we have enough data +4 for initial gap, start bit mark and space + stop bit mark
71  if (decodedIRData.rawlen != (2 * BOSEWAVE_BITS) + 4) {
72  IR_DEBUG_PRINT(F("Bose: "));
73  IR_DEBUG_PRINT(F("Data length="));
75  IR_DEBUG_PRINTLN(F(" is not 36"));
76  return false;
77  }
78 
80 #if defined(LOCAL_DEBUG)
81  Serial.print(F("Bose: "));
82  Serial.println(F("Decode failed"));
83 #endif
84  return false;
85  }
86 
87  // Stop bit
89 #if defined(LOCAL_DEBUG)
90  Serial.print(F("Bose: "));
91  Serial.println(F("Stop bit mark length is wrong"));
92 #endif
93  return false;
94  }
95 
96  // Success
97 // decodedIRData.flags = IRDATA_FLAGS_IS_LSB_FIRST; // Not required, since this is the start value
98  uint16_t tDecodedValue = decodedIRData.decodedRawData;
99  uint8_t tCommandNotInverted = tDecodedValue & 0xFF; // comes first and is in the lower bits (LSB first :-))
100  uint8_t tCommandInverted = tDecodedValue >> 8;
101  // parity check for command. Use this variant to avoid compiler warning "comparison of promoted ~unsigned with unsigned [-Wsign-compare]"
102  if ((tCommandNotInverted ^ tCommandInverted) != 0xFF) {
103 #if defined(LOCAL_DEBUG)
104  Serial.print(F("Bose: "));
105  Serial.println(F("Command and inverted command check failed"));
106 #endif
107  return false;
108  }
109  decodedIRData.command = tCommandNotInverted;
112 
113  // check for repeat
115 
116  return true;
117 }
118 
120 #if defined(LOCAL_DEBUG)
121 #undef LOCAL_DEBUG
122 #endif
123 #endif // _IR_BOSEWAVE_HPP
MICROS_PER_TICK
#define MICROS_PER_TICK
microseconds per clock interrupt tick
Definition: IRremote.hpp:249
BOSEWAVE_HEADER_SPACE
#define BOSEWAVE_HEADER_SPACE
Definition: ir_BoseWave.hpp:40
IRData::numberOfBits
uint16_t numberOfBits
Number of bits received for data (address + command + parity) - to determine protocol length if diffe...
Definition: IRProtocol.h:118
IRsend::aNumberOfRepeats
void int_fast8_t aNumberOfRepeats
Definition: IRremoteInt.h:520
MICROS_IN_ONE_MILLI
#define MICROS_IN_ONE_MILLI
Definition: IRremote.hpp:254
IRsend::sendBoseWave
void sendBoseWave(uint8_t aCommand, int_fast8_t aNumberOfRepeats=NO_REPEATS)
Definition: ir_BoseWave.hpp:57
IRData::rawlen
uint_fast8_t rawlen
counter of entries in rawbuf
Definition: IRProtocol.h:123
IRsend::sendPulseDistanceWidth
void sendPulseDistanceWidth(PulseDistanceWidthProtocolConstants *aProtocolConstants, IRRawDataType aData, uint_fast8_t aNumberOfBits, int_fast8_t aNumberOfRepeats)
Sends PulseDistance frames and repeats and enables receiver again.
Definition: IRSend.hpp:702
BOSEWAVE
@ BOSEWAVE
Definition: IRProtocol.h:67
irparams_struct::rawbuf
uint16_t rawbuf[RAW_BUFFER_LENGTH]
raw data / tick counts per mark/space, first entry is the length of the gap between previous and curr...
Definition: IRremoteInt.h:113
IRData::rawDataPtr
irparams_struct * rawDataPtr
Pointer of the raw timing data to be decoded. Mainly the OverflowFlag and the data buffer filled by r...
Definition: IRProtocol.h:129
IRData::decodedRawData
IRRawDataType decodedRawData
Up to 32/64 bit decoded raw data, to be used for send functions.
Definition: IRProtocol.h:112
IRrecv::checkForRepeatSpaceTicksAndSetFlag
void checkForRepeatSpaceTicksAndSetFlag(uint16_t aMaximumRepeatSpaceTicks)
Definition: IRReceive.hpp:1042
IR_DEBUG_PRINT
#define IR_DEBUG_PRINT(...)
If DEBUG, print the arguments, otherwise do nothing.
Definition: IRremoteInt.h:137
IRrecv::decodePulseDistanceWidthData
bool decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits, uint_fast8_t aStartOffset=3)
Decode pulse distance protocols for PulseDistanceWidthProtocolConstants.
Definition: IRReceive.hpp:845
BOSEWAVE_MAXIMUM_REPEAT_DISTANCE
#define BOSEWAVE_MAXIMUM_REPEAT_DISTANCE
Definition: ir_BoseWave.hpp:47
PulseDistanceWidthProtocolConstants
Definition: IRProtocol.h:132
BOSEWAVE_ZERO_SPACE
#define BOSEWAVE_ZERO_SPACE
Definition: ir_BoseWave.hpp:42
IRrecv::decodedIRData
IRData decodedIRData
Definition: IRremoteInt.h:321
BOSEWAVE_BIT_MARK
#define BOSEWAVE_BIT_MARK
Definition: ir_BoseWave.hpp:41
PROTOCOL_IS_LSB_FIRST
#define PROTOCOL_IS_LSB_FIRST
Definition: IRProtocol.h:146
BOSEWAVE_HEADER_MARK
#define BOSEWAVE_HEADER_MARK
Definition: ir_BoseWave.hpp:39
IRrecv::checkHeader
bool checkHeader(PulseDistanceWidthProtocolConstants *aProtocolConstants)
Definition: IRReceive.hpp:1018
IRData::command
uint16_t command
Decoded command, Distance protocol (tMarkTicksShort << 8) | tSpaceTicksShort.
Definition: IRProtocol.h:110
BOSEWAVE_ONE_SPACE
#define BOSEWAVE_ONE_SPACE
Definition: ir_BoseWave.hpp:43
matchMark
bool matchMark(uint16_t aMeasuredTicks, uint16_t aMatchValueMicros)
Compensate for marks exceeded by demodulator hardware.
Definition: IRReceive.hpp:1083
BOSEWAVE_KHZ
#define BOSEWAVE_KHZ
Definition: IRProtocol.h:158
BOSEWAVE_REPEAT_PERIOD
#define BOSEWAVE_REPEAT_PERIOD
Definition: ir_BoseWave.hpp:45
IRrecv::decodeBoseWave
bool decodeBoseWave()
Definition: ir_BoseWave.hpp:64
BOSEWAVE_BITS
#define BOSEWAVE_BITS
Definition: ir_BoseWave.hpp:37
IR_DEBUG_PRINTLN
#define IR_DEBUG_PRINTLN(...)
If DEBUG, print the arguments as a line, otherwise do nothing.
Definition: IRremoteInt.h:141
BoseWaveProtocolConstants
struct PulseDistanceWidthProtocolConstants BoseWaveProtocolConstants
Definition: ir_BoseWave.hpp:49
IRData::protocol
decode_type_t protocol
UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
Definition: IRProtocol.h:108
IRsend::aCommand
void aCommand
Definition: IRremoteInt.h:582