Open RTS
Full implementation of the Somfy RTS protocol
Loading...
Searching...
No Matches
RTSReceiver Class Reference

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

Detailed Description

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".

Member Typedef Documentation

◆ FrameCallback

typedef void(* RTSReceiver::FrameCallback) (enum rts_receiver_event event, RTSFrame *frame, void *userData)

Frame event callback function type.

Parameters
eventthe rts_recevier_event that was detected, eg RTS_RECEIVER_EVENT_PRESS, RTS_RECEIVER_EVENT_HOLD, etc
framethe RTSFrame that was detected
userDatacustom userdata provided to RTSReceiver::setFrameCallback, if any

◆ ModeCallback

typedef void(* RTSReceiver::ModeCallback) (enum rts_receiver_mode mode, void *userData)

Mode change callback function type.

Parameters
modethe mode the receiver changed to, eg RTS_RECEIVER_MODE_PROGRAMMING, RTS_RECEIVER_MODE_COMMAND, etc
userDatacustom userdata provided to RTSReceiver::setModeCallback, if any

Constructor & Destructor Documentation

◆ RTSReceiver()

RTSReceiver::RTSReceiver ( RTSPulseSource pulseSource,
RTSRemoteStore remoteStore 
)

Construct an RTSReceiver.

Parameters
pulseSourcethe RTSPulseSource to receive pulses from
remoteStorethe RTSRemoteStore to persist paired remotes to

Member Function Documentation

◆ setFrameCallback()

void RTSReceiver::setFrameCallback ( FrameCallback  callback,
void *  userData = nullptr 
)

Set a callback function to call when new receiver events are received.

Parameters
callbackthe callback function to call when new frame events are received. Frame events are fired after RTS frames are parsed and deduplicated.
userDataoptional user_data pointer to pass to every callback.

◆ setModeCallback()

void RTSReceiver::setModeCallback ( ModeCallback  callback,
void *  userData = nullptr 
)

Set a callback function to call when the receiver mode changes.

Parameters
callbackthe callback function to call when the mode changes
userDataoptional user_data pointer top pass to every callback

◆ setMode()

void RTSReceiver::setMode ( enum rts_receiver_mode  mode)

Change the receiver mode.

Receivers can be either "off", in "programming" mode or "command" mode.

Parameters
modethe rts_receiver_mode to change to

◆ update()

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).


The documentation for this class was generated from the following files: