15#if defined(USE_API) && defined(USE_IR_RF)
25 CAPABILITY_TRANSMITTER = 1 << 0,
26 CAPABILITY_RECEIVER = 1 << 1,
51#if defined(USE_API) && defined(USE_IR_RF)
58#if defined(USE_API) && defined(USE_IR_RF)
71template<
typename Call,
typename Entity>
class IrRfCall;
80 void setup()
override;
109#ifdef USE_IR_RF_TRANSMIT_COMPLETE
115#if defined(USE_API) && defined(USE_IR_RF)
116 void loop()
override;
122 template<
typename,
typename>
friend class IrRfCall;
126#if defined(USE_API) && defined(USE_IR_RF)
143#ifdef USE_IR_RF_TRANSMIT_COMPLETE
170#if defined(USE_API) && defined(USE_IR_RF)
174#ifdef USE_IR_RF_TRANSMIT_COMPLETE
180#if defined(USE_API) && defined(USE_IR_RF)
206 return this->
self_();
217 return this->
self_();
229 return this->
self_();
235 return this->
self_();
238#if defined(USE_API) && defined(USE_IR_RF)
242 return this->
self_();
249 Entity *parent = this->
parent_;
250 if (parent ==
nullptr)
252 parent->on_call_(this->
self_());
253#if defined(USE_API) && defined(USE_IR_RF)
256 if (this->
api_connection_ !=
nullptr && !parent->expect_api_reply_(this->api_connection_))
259 const bool started = parent->control(this->
self_());
260#if defined(USE_API) && defined(USE_IR_RF)
262 parent->settle_api_reply_(started);
268 Call &
self_() {
return static_cast<Call &
>(*this); }
void enable_loop()
Enable this component's loop.
void disable_loop()
Disable this component's loop.
Raw timings of a transmit call, in one of three caller-owned forms.
uint16_t get_packed_count() const
const std::string & get_base64url_data() const
Get the base64url data string.
const std::string * base64url_ptr_
const std::vector< int32_t > * raw_timings_
const uint8_t * get_packed_data() const
Get packed data (only valid if set via set_raw_timings_packed)
uint16_t get_packed_length() const
bool wants_api_reply() const
True for a frame an API client is waiting on.
const uint8_t * packed_data_
api::APIConnection * api_connection_
bool is_base64url() const
Check if using base64url data format.
uint32_t get_repeat_count() const
Get the repeat count.
bool has_raw_timings() const
Check if raw timings have been set (any format)
const std::vector< int32_t > & get_raw_timings() const
Get the raw timings (only valid if set via set_raw_timings)
bool is_packed() const
Check if using packed data format.
Builder for a transmit; Call is the concrete call type and Entity its entity, so the fluent setters r...
Call & set_repeat_count(uint32_t count)
Set the number of times to repeat transmission (1 = transmit once, 2 = transmit twice,...
Call & set_api_connection(api::APIConnection *conn)
Reply to this API client once the frame has left the transmitter (API 1.18+)
Call & set_raw_timings_base64url(const std::string &base64url)
Set the raw timings from base64url-encoded little-endian int32 data.
bool perform()
Perform the transmission; returns true if a frame was handed to the transmitter.
Call & set_raw_timings(const std::vector< int32_t > &timings)
Set the raw timings from a vector (positive = mark, negative = space)
Call & set_raw_timings_packed(const uint8_t *data, uint16_t length, uint16_t count)
Set the raw timings from packed protobuf sint32 data (zigzag + varint encoded)
Everything an infrared or radio frequency entity does that does not depend on the medium: the remote_...
void api_transmit_done_(bool sent)
Answers the API request for a control() override that transmits without a remote_base transmitter.
void on_transmit_complete(remote_base::RemoteTransmitterBase *transmitter, uint16_t seq, bool sent)
Called for every finished frame on every transmitter; answers the API request when the frame is the o...
remote_base::RemoteReceiverBase * receiver_
uint32_t get_capability_flags() const
Capability flags as reported to the API and web server.
void refuse_api_call_(api::APIConnection *conn)
api::APIConnection * api_reply_connection_
bool on_receive(remote_base::RemoteReceiveData data) override
Forwards a received frame to the API; never consumes it, so other listeners still run.
bool expect_api_reply_(api::APIConnection *conn)
Claims the reply slot for conn; false when it still owes a reply that cannot be sent.
remote_base::RemoteTransmitterBase * transmitter_
bool has_receiver() const
void setup() override
Reports the configured transports, listens on the receiver and hooks the transmitter's completion; a ...
bool has_transmitter() const
uint16_t api_reply_deadline_
void set_supports_receiver(bool supports)
void set_receiver(remote_base::RemoteReceiverBase *receiver)
Set the remote receiver component; the listener registration happens from codegen,...
float get_setup_priority() const override
void finish_api_reply_(bool success)
bool get_supports_transmitter() const
What the entity can do; platforms with their own hardware set these from their own setup(),...
bool get_supports_receiver() const
void set_supports_transmitter(bool supports)
void set_transmitter(remote_base::RemoteTransmitterBase *transmitter)
Set the remote transmitter component.
void settle_api_reply_(bool started)
After control(): a false start is answered now, and the loop only runs once something is pending,...
bool transmit_raw_(const IrRfCallData &call, uint32_t carrier_frequency_hz)
Hands the call's timings to the transmitter; the default transmit path of both entity types.
bool supports_transmitter_
void on_api_connection_closed(api::APIConnection *conn)
The API server calls this when a client disconnects, so no reply goes to a stale pointer.
IrRfCapability
Capability flags reported by infrared and radio frequency entities.
constexpr float AFTER_CONNECTION
For components that should be initialized after a data connection (API/MQTT) is connected.