Open RTS
Full implementation of the Somfy RTS protocol
|
Simulates a physical RTS receiver device, such as a shade or drapery motor. More...
#include <RTSReceiver.hpp>
Inherits rts_receiver.
Public Types | |
typedef void(* | FrameCallback) (enum rts_receiver_event event, RTSFrame *frame, void *userData) |
Frame event callback function type. | |
typedef void(* | ModeCallback) (enum rts_receiver_mode mode, void *userData) |
Mode change callback function type. | |
Public Member Functions | |
RTSReceiver (RTSPulseSource *pulseSource, RTSRemoteStore *remoteStore) | |
Construct an RTSReceiver. | |
void | setFrameCallback (FrameCallback callback, void *userData=nullptr) |
Set a callback function to call when new receiver events are received. | |
void | setModeCallback (ModeCallback callback, void *userData=nullptr) |
Set a callback function to call when the receiver mode changes. | |
void | setMode (enum rts_receiver_mode mode) |
Change the receiver mode. | |
void | forgetAllRemotes () |
Convenience function to forget all paired remotes by clearing the receiver's RTSRemoteStore. | |
void | update () |
Instruct the receiver's RTSPulseSource to check for new pulse data, should be called every loop() if the pulse source does not keep itself updated (eg. | |
Additional Inherited Members | |
Related Symbols inherited from rts_receiver | |
void | rts_receiver_init (struct rts_receiver *receiver, struct rts_pulse_source *pulse_source, struct rts_remote_store *remote_store) |
Initialize an rts_receiver. | |
void | rts_receiver_set_frame_callback (struct rts_receiver *receiver, void(*callback)(enum rts_receiver_event, struct rts_frame *frame, void *user_data), void *user_data) |
Set a callback function to call when new receiver events are received. | |
void | rts_receiver_set_mode_callback (struct rts_receiver *receiver, void(*callback)(enum rts_receiver_mode, void *user_data), void *user_data) |
Set a callback function to call when the receiver mode changes. | |
void | rts_receiver_set_mode (struct rts_receiver *receiver, uint8_t mode) |
Change the receiver mode. | |
void | rts_receiver_forget_all_remotes (struct rts_receiver *receiver) |
Convenience function to forget all paired remotes by clearing the receiver's rts_remote_store. | |
void | rts_receiver_update (struct rts_receiver *receiver) |
Instruct the receiver's rts_pulse_source to check for new pulse data, should be called every loop() if the pulse source does not keep itself updated (eg. | |
Simulates a physical RTS receiver device, such as a shade or drapery motor.
It connects an RTSPulseSource (eg. a GPIO or radio) to an internal RTSFrameBuilder and adds common receiver functionality such as frame de-duplication, remote pairing, and rolling code validation.
De-duplicated frame "events" such as "remote button pressed" and "remote button held" are sent to the event callback you attach with RTSReceiver::setFrameCallback.
Paired remotes and rolling codes can be persisted by providing a RTSRemoteStore backend (eg. ESP32's non-volatile storage, Arduino's EEPROM, or something custom if you'd prefer).
Receivers can be in one of three modes: "off", "programming" or "command".
In "off" mode, the receiver will not process any commands from remotes. To re-enable processing of commands, you'll need to call RTSReceiver::setMode. Typically you'll want to call this when the user presses a physical button on the receiver, as on real RTS devices.
In "programming" mode, the receiver will process pairing/unpairing commands from remotes (Prog button pressed), and also process "RTS Off" commands from remotes (My+Up+Down buttons pressed and held).
In "command" mode, the receiver will process regular RTS frame events with rolling code validation, and handle certain special events such as allowing a paired remote to enter "programming" mode by pressing and holding "Prog".
typedef void(* RTSReceiver::FrameCallback) (enum rts_receiver_event event, RTSFrame *frame, void *userData) |
Frame event callback function type.
event | the rts_recevier_event that was detected, eg RTS_RECEIVER_EVENT_PRESS, RTS_RECEIVER_EVENT_HOLD, etc |
frame | the RTSFrame that was detected |
userData | custom userdata provided to RTSReceiver::setFrameCallback, if any |
typedef void(* RTSReceiver::ModeCallback) (enum rts_receiver_mode mode, void *userData) |
Mode change callback function type.
mode | the mode the receiver changed to, eg RTS_RECEIVER_MODE_PROGRAMMING, RTS_RECEIVER_MODE_COMMAND, etc |
userData | custom userdata provided to RTSReceiver::setModeCallback, if any |
RTSReceiver::RTSReceiver | ( | RTSPulseSource * | pulseSource, |
RTSRemoteStore * | remoteStore | ||
) |
Construct an RTSReceiver.
pulseSource | the RTSPulseSource to receive pulses from |
remoteStore | the RTSRemoteStore to persist paired remotes to |
void RTSReceiver::setFrameCallback | ( | FrameCallback | callback, |
void * | userData = nullptr |
||
) |
Set a callback function to call when new receiver events are received.
callback | the callback function to call when new frame events are received. Frame events are fired after RTS frames are parsed and deduplicated. |
userData | optional user_data pointer to pass to every callback. |
void RTSReceiver::setModeCallback | ( | ModeCallback | callback, |
void * | userData = nullptr |
||
) |
Set a callback function to call when the receiver mode changes.
callback | the callback function to call when the mode changes |
userData | optional user_data pointer top pass to every callback |
void RTSReceiver::setMode | ( | enum rts_receiver_mode | mode | ) |
Change the receiver mode.
Receivers can be either "off", in "programming" mode or "command" mode.
mode | the rts_receiver_mode to change to |
void RTSReceiver::update | ( | ) |
Instruct the receiver's RTSPulseSource to check for new pulse data, should be called every loop() if the pulse source does not keep itself updated (eg.
using interrupts).