RCKit
|
Remote Control Receiver module for RCOIP protocol on Arduino. More...
#include <RCRx.h>
Public Member Functions | |
RCRx () | |
void | setTransceiver (Transceiver *transceiver) |
void | setOutputs (Setter **analogOutputs, uint8_t numAnalogOutputs) |
virtual void | setAnalogOutput (uint8_t channel, int value) |
void | init () |
void | run () |
void | handleRequest (uint8_t *msg, uint16_t len, uint16_t rssi) |
void | failsafe () |
void | periodicTask () |
boolean | connected () |
void | sendReply () |
Remote Control Receiver module for RCOIP protocol on Arduino.
RCRx::RCRx | ( | ) |
Constructor. After contruction and initialisation, call the init() and run() functions.
References RCOIP_DEFAULT_FAIL_INTERVAL, and RCOIP_DEFAULT_REPLY_INTERVAL.
boolean RCRx::connected | ( | ) |
Returns whether the RCRx considers itself to be connected to the transmitter. Initialsed to false. Whenever an RCOIP request is receved, set to true. If no RCOIP request is receved for more than failInterval miliseconds, set to false.
void RCRx::failsafe | ( | ) |
Called by RCRx when no RCOIP message has been received for more than failInterval milliseconds. Calls the failsafe function for all configured output Setters.
References Setter::failsafe().
Referenced by periodicTask().
void RCRx::handleRequest | ( | uint8_t * | msg, |
uint16_t | len, | ||
uint16_t | rssi | ||
) |
Call to handle an incoming UDP message containing an RCOIP command message. This is usually only called from the Transceiver, but could be called externally for testing purposes etc.
[in] | msg | Pointer to the RCOIP message |
[in] | len | Length of the PCOIP mesage in bytes |
[in] | rssi | Receiver Signal Strength as reported by the WiFi receiver (if any) when the message was received. |
References RCOIPv1CmdSetAnalogChannels::channels, RC_VERSION1, sendReply(), setAnalogOutput(), and RCOIPv1CmdSetAnalogChannels::version.
Referenced by Transceiver::receivedRequest().
void RCRx::init | ( | ) |
Initialises the wireless WiFi receiver Call once at startup time after addresses etc have been configured.
References Transceiver::init().
void RCRx::periodicTask | ( | ) |
Called by RCRx periodically (typically twice per second) to do period processing such as detecting loss of incoming messages
References failsafe().
Referenced by run().
void RCRx::run | ( | ) |
Call this to process pending Wireless events. Call this as often as possible in your main loop. Runs the wireless driver stack or whatever in the Transceiver, and does internal housekeeping.
References periodicTask(), and Transceiver::run().
void RCRx::sendReply | ( | ) |
Sends an RCOIP reply message Usually called internally at most once every _replyInterval milliseconds.
References RCOIPv1ReplyReceiverStatus::batteryVoltage, RC_VERSION, RCOIPv1ReplyReceiverStatus::RSSI, Transceiver::sendReply(), and RCOIPv1ReplyReceiverStatus::version.
Referenced by handleRequest().
|
virtual |
Set the output for channel n. Calls the Setter at index n of the analogOutputs array. Not usuallly called exernally, this is usually only called from within RCRx. Subclasses can override this to get control when new analog output values become available
[in] | channel | The analog channel number output to set |
[in] | value | The new value to set |
References Setter::input().
Referenced by handleRequest().
void RCRx::setOutputs | ( | Setter ** | analogOutputs, |
uint8_t | numAnalogOutputs | ||
) |
Specifies the Setters that will be used by this receiver to set its output values Whenever a RCOIP message is received with a new value for channel n, it will be passed to the Setter at index n by calling the Setters input() function.
[in] | analogOutputs | Pointer to an array pointers to Setter objects. |
[in] | numAnalogOutputs | Number of elements in analogOutputs |
void RCRx::setTransceiver | ( | Transceiver * | transceiver | ) |
Tells this object where to find the transceiver object. RCRx requires an instance of a Transceiver object for the device that you are using to Received RCOIP requests from the transmitter. A number of Transceivers are provided with RCRx:
References Transceiver::setDelegate().