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 
51 
52 /************************************
53  * Start of send and decode functions
54  ************************************/
55 
56 void IRsend::sendBoseWave(uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
57 
58  // send 8 command bits and then 8 inverted command bits LSB first
59  uint16_t tData = ((~aCommand) << 8) | aCommand;
61 }
62 
64 
66  return false;
67  }
68 
69  // Check we have enough data +4 for initial gap, start bit mark and space + stop bit mark
70  if (decodedIRData.rawDataPtr->rawlen != (2 * BOSEWAVE_BITS) + 4) {
71  IR_DEBUG_PRINT(F("Bose: "));
72  IR_DEBUG_PRINT(F("Data length="));
74  IR_DEBUG_PRINTLN(F(" is not 36"));
75  return false;
76  }
77 
79 #if defined(LOCAL_DEBUG)
80  Serial.print(F("Bose: "));
81  Serial.println(F("Decode failed"));
82 #endif
83  return false;
84  }
85 
86  // Stop bit
88 #if defined(LOCAL_DEBUG)
89  Serial.print(F("Bose: "));
90  Serial.println(F("Stop bit mark length is wrong"));
91 #endif
92  return false;
93  }
94 
95  // Success
96 // decodedIRData.flags = IRDATA_FLAGS_IS_LSB_FIRST; // Not required, since this is the start value
97  uint16_t tDecodedValue = decodedIRData.decodedRawData;
98  uint8_t tCommandNotInverted = tDecodedValue & 0xFF; // comes first and is in the lower bits (LSB first :-))
99  uint8_t tCommandInverted = tDecodedValue >> 8;
100  // parity check for command. Use this variant to avoid compiler warning "comparison of promoted ~unsigned with unsigned [-Wsign-compare]"
101  if ((tCommandNotInverted ^ tCommandInverted) != 0xFF) {
102 #if defined(LOCAL_DEBUG)
103  Serial.print(F("Bose: "));
104  Serial.println(F("Command and inverted command check failed"));
105 #endif
106  return false;
107  }
108  decodedIRData.command = tCommandNotInverted;
111 
112  // check for repeat
114 
115  return true;
116 }
117 
119 #if defined(LOCAL_DEBUG)
120 #undef LOCAL_DEBUG
121 #endif
122 #endif // _IR_BOSEWAVE_HPP
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:120
IRsend::aNumberOfRepeats
void uint8_t int_fast8_t aNumberOfRepeats
Definition: IRremoteInt.h:474
BOSEWAVE_REPEAT_DISTANCE
#define BOSEWAVE_REPEAT_DISTANCE
Definition: ir_BoseWave.hpp:46
MICROS_IN_ONE_MILLI
#define MICROS_IN_ONE_MILLI
Definition: IRremote.hpp:263
IRsend::sendBoseWave
void sendBoseWave(uint8_t aCommand, int_fast8_t aNumberOfRepeats=NO_REPEATS)
Definition: ir_BoseWave.hpp:56
IRsend::sendPulseDistanceWidth
void sendPulseDistanceWidth(PulseDistanceWidthProtocolConstants *aProtocolConstants, IRRawDataType aData, uint_fast8_t aNumberOfBits, int_fast8_t aNumberOfRepeats)
Sends PulseDistance frames and repeats.
Definition: IRSend.hpp:532
BOSEWAVE
@ BOSEWAVE
Definition: IRProtocol.h:67
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:126
IRData::decodedRawData
IRRawDataType decodedRawData
Up to 32/64 bit decoded raw data, to be used for send functions.
Definition: IRProtocol.h:122
IR_DEBUG_PRINT
#define IR_DEBUG_PRINT(...)
If DEBUG, print the arguments, otherwise do nothing.
Definition: IRremoteInt.h:133
irparams_struct::rawlen
uint_fast8_t rawlen
counter of entries in rawbuf
Definition: IRremoteInt.h:109
IRrecv::decodePulseDistanceWidthData
bool decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits, uint_fast8_t aStartOffset=3)
Decode pulse distance protocols for PulseDistanceWidthProtocolConstants.
Definition: IRReceive.hpp:768
PulseDistanceWidthProtocolConstants
Definition: IRProtocol.h:74
BOSEWAVE_ZERO_SPACE
#define BOSEWAVE_ZERO_SPACE
Definition: ir_BoseWave.hpp:42
IRrecv::decodedIRData
IRData decodedIRData
Definition: IRremoteInt.h:305
BOSEWAVE_BIT_MARK
#define BOSEWAVE_BIT_MARK
Definition: ir_BoseWave.hpp:41
SEND_STOP_BIT
#define SEND_STOP_BIT
Definition: IRremoteInt.h:393
PROTOCOL_IS_LSB_FIRST
#define PROTOCOL_IS_LSB_FIRST
Definition: IRProtocol.h:129
IRrecv::checkForRepeatSpaceAndSetFlag
void checkForRepeatSpaceAndSetFlag(unsigned int aMediumRepeatSpaceMicros)
Definition: IRReceive.hpp:962
BOSEWAVE_HEADER_MARK
#define BOSEWAVE_HEADER_MARK
Definition: ir_BoseWave.hpp:39
IRrecv::checkHeader
bool checkHeader(PulseDistanceWidthProtocolConstants *aProtocolConstants)
Definition: IRReceive.hpp:943
irparams_struct::rawbuf
unsigned int 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::command
uint16_t command
Decoded command, Distance protocol (tMarkTicksShort << 8) | tSpaceTicksShort.
Definition: IRProtocol.h:118
BOSEWAVE_ONE_SPACE
#define BOSEWAVE_ONE_SPACE
Definition: ir_BoseWave.hpp:43
BOSEWAVE_KHZ
#define BOSEWAVE_KHZ
Definition: IRProtocol.h:139
BOSEWAVE_REPEAT_PERIOD
#define BOSEWAVE_REPEAT_PERIOD
Definition: ir_BoseWave.hpp:45
IRrecv::decodeBoseWave
bool decodeBoseWave()
Definition: ir_BoseWave.hpp:63
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:137
matchMark
bool matchMark(unsigned int aMeasuredTicks, unsigned int aMatchValueMicros)
Compensate for marks exceeded by demodulator hardware.
Definition: IRReceive.hpp:1000
BoseWaveProtocolConstants
struct PulseDistanceWidthProtocolConstants BoseWaveProtocolConstants
Definition: ir_BoseWave.hpp:48
IRData::protocol
decode_type_t protocol
UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
Definition: IRProtocol.h:116
IRsend::aCommand
void uint8_t aCommand
Definition: IRremoteInt.h:474