Open RTS
Full implementation of the Somfy RTS protocol
Loading...
Searching...
No Matches
RTSReceiver.hpp
Go to the documentation of this file.
1#ifndef RTS_RECEIVER_HPP
2#define RTS_RECEIVER_HPP
3
5
6#include "RTSFrame.hpp"
7#include "RTSPulseSource.hpp"
8#include "RTSRemoteStore.hpp"
9
49class RTSReceiver : protected rts_receiver
50{
51 public:
61 typedef void (*FrameCallback)(enum rts_receiver_event event,
62 RTSFrame *frame, void *userData);
63
72 typedef void (*ModeCallback)(enum rts_receiver_mode mode, void *userData);
73
80 RTSReceiver(RTSPulseSource *pulseSource, RTSRemoteStore *remoteStore);
81
90 void setFrameCallback(FrameCallback callback, void *userData = nullptr);
91
98 void setModeCallback(ModeCallback callback, void *userData = nullptr);
99
106 void setMode(enum rts_receiver_mode mode);
107
112 void forgetAllRemotes();
113
119 void update();
120
121 private:
122 // Wrapper function to convert rts_receiver frame callbacks
123 static void frameCallbackWrapper(enum rts_receiver_event event,
124 rts_frame *frame, void *userData);
125
126 // Wrapper function to convert rts_receiver mode callbacks
127 static void modeCallbackWrapper(enum rts_receiver_mode mode,
128 void *userData);
129
130 // User provided frame callback
131 FrameCallback frameCallback = nullptr;
132 void *frameCallbackUserData = nullptr;
133
134 // User provided mode callback
135 ModeCallback modeCallback = nullptr;
136 void *modeCallbackUserData = nullptr;
137};
138
143#endif // RTS_RECEIVER_HPP
Represents the message "payload" sent by RTS remote controls.
Definition RTSFrame.hpp:24
Provides an interface for a source of RTS pulses, eg a GPIO or radio.
Definition RTSPulseSource.hpp:28
Simulates a physical RTS receiver device, such as a shade or drapery motor.
Definition RTSReceiver.hpp:50
void setMode(enum rts_receiver_mode mode)
Change the receiver mode.
Definition RTSReceiver.cpp:25
void forgetAllRemotes()
Convenience function to forget all paired remotes by clearing the receiver's RTSRemoteStore.
Definition RTSReceiver.cpp:30
void setFrameCallback(FrameCallback callback, void *userData=nullptr)
Set a callback function to call when new receiver events are received.
Definition RTSReceiver.cpp:9
void(* FrameCallback)(enum rts_receiver_event event, RTSFrame *frame, void *userData)
Frame event callback function type.
Definition RTSReceiver.hpp:61
void(* ModeCallback)(enum rts_receiver_mode mode, void *userData)
Mode change callback function type.
Definition RTSReceiver.hpp:72
void setModeCallback(ModeCallback callback, void *userData=nullptr)
Set a callback function to call when the receiver mode changes.
Definition RTSReceiver.cpp:17
void update()
Instruct the receiver's RTSPulseSource to check for new pulse data, should be called every loop() if ...
Definition RTSReceiver.cpp:35
Provides an interface for a datastore which contains details about remote controls and rolling codes.
Definition RTSRemoteStore.hpp:23
rts_receiver_mode
Receiver modes.
Definition rts_receiver.h:36
rts_receiver_event
De-duplicated "frame" events.
Definition rts_receiver.h:25
Represents the message "payload" sent by RTS remote controls.
Definition rts_frame.h:32
Simulates a physical RTS receiver device, such as a shade or drapery motor.
Definition rts_receiver.h:72