RCKit
Transceiver.h
1 // Transceiver.h
2 //
3 // Base class for an RCRx transceiver device
4 // Copyright (C) 2010 Mike McCauley
5 // $Id: Transceiver.h,v 1.1 2012/09/23 21:55:57 mikem Exp $
6 
7 #ifndef Transceiver_h
8 #define Transceiver_h
9 
10 #include <RCRx.h>
11 
12 /////////////////////////////////////////////////////////////////////
13 /// \class Transceiver Transceiver.h <Transceiver.h>
14 /// \brief Abstract base class for a transceiver device that will send and receive messages
15 /// on behalf of RCRx class.
16 ///
17 /// RXRx class requires to be connected to a Transceiver, and the transceiver is responsible for
18 /// receiving requests from an RCOIP transmitter and sending replies back to it.
19 /// Any transport or media can in principle be supported. RCRx includes some specific implementations
20 /// for example for WiShield and Ethernet
21 ///
22 /// Real transceiver objects must inherit from this subclass and implement the
23 /// sendReply() function and call delegate->handleRequest(uint8_t *msg, uint16_t len, uint16_t rssi)
24 /// whenever an RCOI message is received.
26 {
27 public:
28  /// Initialise the object.
29  /// You are required to call this once during setup().
30  /// Subclasses must implement this: there is no base implementation.
31  virtual void init();
32 
33  /// Poll the object for activity.
34  /// You are required to call this frequently in your main loop
35  /// Subclasses must implement this: there is no base implementation.
36  virtual void run();
37 
38  /// Sets the delegate object.
39  /// The delegate will get its handleRequest(uint8_t *msg, uint16_t len, uint16_t rssi)
40  /// function called whenever an RCOIP message is received.
41  /// The delegate can use the sendReply() function to send an RCOIP message back to the
42  /// sender of the currently received message.
43  /// \param[in] delegate Pointer to the delegate RXRx object
44  virtual void setDelegate(RCRx* delegate);
45 
46  /// Passes the received message to the delegate.
47  /// Call this when the Transceiver has received a message from the RCOIP transmitter.
48  /// The optional rssi parameter is an indication of the received signal strength, but if your
49  /// Transceiver has no such measure, you dont need to supply it
50  /// \param[in] msg Pointer to the RCOP message.
51  /// \param[in] len Length of the RCOIP message in bytes.
52  /// \param[in] rssi Receiver Signal Strength as reported by the WiFi receiver (if any)
53  virtual void receivedRequest(uint8_t* msg, uint16_t len, uint16_t rssi = 0);
54 
55  /// Sends an RCOIP reply message to the sender of the current message
56  /// Subclasses must implement this: there is no base implementation.
57  /// \param[in] msg Pointer to the RCOP message.
58  /// \param[in] len Length of the RCOIP message in bytes.
59  virtual void sendReply(uint8_t* msg, uint16_t len);
60 
61 protected:
62  /// Object whose handleRequest() function will be called whenever an RCOIP message is received
64 };
65 
66 #endif
Transceiver::init
virtual void init()
Transceiver::_delegate
RCRx * _delegate
Object whose handleRequest() function will be called whenever an RCOIP message is received.
Definition: Transceiver.h:63
RCRx::handleRequest
void handleRequest(uint8_t *msg, uint16_t len, uint16_t rssi)
Definition: RCRx.cpp:84
Transceiver::run
virtual void run()
Transceiver::setDelegate
virtual void setDelegate(RCRx *delegate)
Definition: Transceiver.cpp:12
Transceiver
Abstract base class for a transceiver device that will send and receive messages on behalf of RCRx cl...
Definition: Transceiver.h:25
RCRx
Remote Control Receiver module for RCOIP protocol on Arduino.
Definition: RCRx.h:361
Transceiver::receivedRequest
virtual void receivedRequest(uint8_t *msg, uint16_t len, uint16_t rssi=0)
Definition: Transceiver.cpp:18
Transceiver::sendReply
virtual void sendReply(uint8_t *msg, uint16_t len)