12namespace remote_base {
64 int32_t
peek(uint32_t offset = 0)
const {
return this->
data_[this->
index_ + offset]; }
71 bool peek_item(uint32_t mark, uint32_t space, uint32_t offset = 0)
const {
94 return int32_t(100 - this->
tolerance_) * length / 100U;
102 return int32_t(100 + this->
tolerance_) * length / 100U;
122#include <soc/soc_caps.h>
132 return us * ticks_per_ten_us / 10;
136 return (ticks * 10) / ticks_per_ten_us;
166 template<
typename Protocol>
167 void transmit(
const typename Protocol::ProtocolData &data, uint32_t send_times = 1, uint32_t send_wait = 0) {
169 Protocol().encode(call.get_data(), data);
170 call.set_send_times(send_times);
171 call.set_send_wait(send_wait);
176 void send_(uint32_t send_times, uint32_t send_wait);
248 auto res = proto.decode(src);
249 return res.has_value() && *res == this->
data_;
264 auto res = proto.decode(src);
265 if (res.has_value()) {
280 template<
typename Protocol>
281 void transmit_(
const typename Protocol::ProtocolData &data, uint32_t send_times = 1, uint32_t send_wait = 0) {
288 TEMPLATABLE_VALUE(uint32_t, send_times)
289 TEMPLATABLE_VALUE(uint32_t, send_wait)
292 void play(
const Ts &...
x)
override {
294 this->
encode(call.get_data(),
x...);
295 call.set_send_times(this->send_times_.value_or(
x..., 1));
296 call.set_send_wait(this->send_wait_.value_or(
x..., 0));
306 auto decoded = proto.decode(src);
307 if (!decoded.has_value())
309 proto.dump(*decoded);
314#define DECLARE_REMOTE_PROTOCOL_(prefix) \
315 using prefix##BinarySensor = RemoteReceiverBinarySensor<prefix##Protocol>; \
316 using prefix##Trigger = RemoteReceiverTrigger<prefix##Protocol>; \
317 using prefix##Dumper = RemoteReceiverDumper<prefix##Protocol>;
318#define DECLARE_REMOTE_PROTOCOL(prefix) DECLARE_REMOTE_PROTOCOL_(prefix)
void trigger(const Ts &...x)
RemoteComponentBase(InternalGPIOPin *pin)
virtual void dump(const ProtocolData &data)=0
virtual optional< ProtocolData > decode(RemoteReceiveData src)=0
virtual void encode(RemoteTransmitData *dst, const ProtocolData &data)=0
RemoteComponentBase * remote_base_
void set_rmt_symbols(uint32_t rmt_symbols)
uint32_t to_microseconds_(uint32_t ticks)
uint32_t clock_resolution_
uint32_t from_microseconds_(uint32_t us)
void set_clock_resolution(uint32_t clock_resolution)
int32_t operator[](uint32_t index) const
bool peek_mark_at_most(uint32_t length, uint32_t offset=0) const
uint32_t get_index() const
bool expect_item(uint32_t mark, uint32_t space)
bool peek_space(uint32_t length, uint32_t offset=0) const
bool peek_space_at_most(uint32_t length, uint32_t offset=0) const
int32_t peek(uint32_t offset=0) const
bool peek_item(uint32_t mark, uint32_t space, uint32_t offset=0) const
bool expect_space(uint32_t length)
int32_t upper_bound_(uint32_t length) const
bool expect_mark(uint32_t length)
bool is_valid(uint32_t offset=0) const
const RawTimings & get_raw_data() const
ToleranceMode tolerance_mode_
void advance(uint32_t amount=1)
RemoteReceiveData(const RawTimings &data, uint32_t tolerance, ToleranceMode tolerance_mode)
void set_tolerance(uint32_t tolerance, ToleranceMode tolerance_mode)
bool peek_space_at_least(uint32_t length, uint32_t offset=0) const
ToleranceMode get_tolerance_mode()
int32_t lower_bound_(uint32_t length) const
bool peek_mark(uint32_t length, uint32_t offset=0) const
bool expect_pulse_with_gap(uint32_t mark, uint32_t space)
bool peek_mark_at_least(uint32_t length, uint32_t offset=0) const
ToleranceMode tolerance_mode_
std::vector< RemoteReceiverDumperBase * > dumpers_
std::vector< RemoteReceiverListener * > listeners_
void call_listeners_dumpers_()
void register_dumper(RemoteReceiverDumperBase *dumper)
std::vector< RemoteReceiverDumperBase * > secondary_dumpers_
void set_tolerance(uint32_t tolerance, ToleranceMode tolerance_mode)
void register_listener(RemoteReceiverListener *listener)
RemoteReceiverBase(InternalGPIOPin *pin)
virtual bool matches(RemoteReceiveData src)=0
RemoteReceiverBinarySensorBase()
bool on_receive(RemoteReceiveData src) override
void dump_config() override
RemoteReceiverBinarySensor()
void set_data(typename T::ProtocolData data)
bool matches(RemoteReceiveData src) override
virtual bool is_secondary()
virtual bool dump(RemoteReceiveData src)=0
bool dump(RemoteReceiveData src) override
virtual bool on_receive(RemoteReceiveData data)=0
bool on_receive(RemoteReceiveData src) override
bool set_data_from_base64url(const std::string &base64url)
Set data from base64url-encoded little-endian int32 values Base64url is URL-safe: uses '-' instead of...
uint32_t get_carrier_frequency() const
void space(uint32_t length)
void set_carrier_frequency(uint32_t carrier_frequency)
void mark(uint32_t length)
void item(uint32_t mark, uint32_t space)
const RawTimings & get_data() const
void set_data(const RawTimings &data)
void reserve(uint32_t len)
void set_data_from_packed_sint32(const uint8_t *data, size_t len, size_t count)
Set data from packed protobuf sint32 buffer (zigzag + varint encoded)
uint32_t carrier_frequency_
RemoteTransmitterBase * transmitter_
void set_transmitter(RemoteTransmitterBase *transmitter)
void transmit_(const typename Protocol::ProtocolData &data, uint32_t send_times=1, uint32_t send_wait=0)
RemoteTransmittable(RemoteTransmitterBase *transmitter)
virtual void encode(RemoteTransmitData *dst, Ts... x)=0
void play(const Ts &...x) override
void set_send_times(uint32_t send_times)
void set_send_wait(uint32_t send_wait)
TransmitCall(RemoteTransmitterBase *parent)
RemoteTransmitterBase * parent_
RemoteTransmitData * get_data()
void send_(uint32_t send_times, uint32_t send_wait)
RemoteTransmitterBase(InternalGPIOPin *pin)
void transmit(const typename Protocol::ProtocolData &data, uint32_t send_times=1, uint32_t send_wait=0)
virtual void send_internal(uint32_t send_times, uint32_t send_wait)=0
RemoteTransmitData temp_
Use same vector for all transmits, avoids many allocations.
std::vector< int32_t > RawTimings
@ TOLERANCE_MODE_PERCENTAGE
Providing packet encoding functions for exchanging data with a remote host.