RCKit
Public Member Functions | List of all members
RCRx Class Reference

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

Detailed Description

Remote Control Receiver module for RCOIP protocol on Arduino.

Overview
This class implements a receiver for RCOIP (Remote Control Over IP). It starts and manages a WiFi receiver, which receives UDP messages containing RCOIP commands such as remote control channel values. When channel setting commands are received they are translated into output values which are sent to Setter objects to control the phycical output devices and pins on the Arduino. Supports WiShield 1.0 etc.
Outputs
RCRx maps RCOIP channels to physical output devices through the analogOutputs array. This is an array of Setter objects, one for each physical output to be controlled by RCRx. Whenever a RCOIP message is received with new channel settings, the input() function of each Setter with new data will be called. This will cause each Setter to set its physical output in response to the remote control data received by an RCOIP.
Failsafe
RCRx supports failsafe behaviour if a connection to the transmitter is lost. RCRx monitors the time of each received RCOIP request. If no request is received for more than failInterval milliseconds, it will be considered as disconnected, and the failsafe() function of every Setter will be called, allowing each Setter to adopt its failsafe configuration (eg throttle to 0 etc). This allows remote control vehicles to fail safe if the transmitter fails or goes out of range.

Constructor & Destructor Documentation

◆ RCRx()

RCRx::RCRx ( )

Constructor. After contruction and initialisation, call the init() and run() functions.

References RCOIP_DEFAULT_FAIL_INTERVAL, and RCOIP_DEFAULT_REPLY_INTERVAL.

Member Function Documentation

◆ connected()

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.

Returns
true if the RCRx is still receiving messages from the transmitter.

◆ failsafe()

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

◆ handleRequest()

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.

Parameters
[in]msgPointer to the RCOIP message
[in]lenLength of the PCOIP mesage in bytes
[in]rssiReceiver 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().

◆ init()

void RCRx::init ( )

Initialises the wireless WiFi receiver Call once at startup time after addresses etc have been configured.

References Transceiver::init().

◆ periodicTask()

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

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

◆ sendReply()

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

◆ setAnalogOutput()

void RCRx::setAnalogOutput ( uint8_t  channel,
int  value 
)
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

Parameters
[in]channelThe analog channel number output to set
[in]valueThe new value to set

References Setter::input().

Referenced by handleRequest().

◆ setOutputs()

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.

Parameters
[in]analogOutputsPointer to an array pointers to Setter objects.
[in]numAnalogOutputsNumber of elements in analogOutputs

◆ setTransceiver()

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


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