COSA
An Object-Oriented Platform for Arduino Programming
VWI Class Reference

#include <VWI.hh>

Inheritance diagram for VWI:
Inheritance graph
Collaboration diagram for VWI:
Collaboration graph

Classes

class  Codec
 
struct  header_t
 
class  Receiver
 
class  Transmitter
 

Public Member Functions

 VWI (int16_t net, uint8_t dev, uint16_t speed, Receiver *rx)
 
 VWI (int16_t net, uint8_t dev, uint16_t speed, Transmitter *tx)
 
 VWI (int16_t net, uint8_t dev, uint16_t speed, Receiver *rx, Transmitter *tx)
 
virtual bool begin (const void *config=NULL)
 
virtual bool end ()
 
virtual void powerup ()
 
virtual void powerdown ()
 
virtual bool available ()
 
virtual int send (uint8_t dest, uint8_t port, const iovec_t *vec)
 
virtual int send (uint8_t dest, uint8_t port, const void *buf, size_t len)
 
virtual int recv (uint8_t &src, uint8_t &port, void *buf, size_t len, uint32_t ms=0L)
 
virtual int link_quality_indicator ()
 
uint8_t channel () const
 
void channel (uint8_t channel)
 
int16_t network_address () const
 
uint8_t device_address () const
 
void address (int16_t net, uint8_t dev)
 
virtual void wakeup_on_radio ()
 
virtual bool room ()
 
virtual int broadcast (uint8_t port, const iovec_t *vec)
 
virtual int broadcast (uint8_t port, const void *buf, size_t len)
 
virtual bool is_broadcast ()
 
virtual void output_power_level (int8_t dBm)
 
virtual int input_power_level ()
 

Static Public Attributes

static const uint8_t PAYLOAD_MAX = 30 + sizeof(header_t)
 
static const uint8_t BROADCAST = 0x00
 

Protected Attributes

uint8_t m_channel
 Current channel (device dependent. More...
 
addr_t m_addr
 Current network and device address. More...
 
volatile bool m_avail
 Message available. May be set by ISR. More...
 
uint8_t m_dest
 Latest message destination device address. More...
 

Static Protected Attributes

static const uint8_t MESSAGE_MAX = PAYLOAD_MAX + 3
 
static const uint8_t MESSAGE_MIN = sizeof(header_t)
 
static const uint8_t SAMPLES_PER_BIT = 8
 

Friends

void TIMER1_COMPA_vect (void)
 

Detailed Description

VWI is an Cosa library that provides features to send short messages using inexpensive radio transmitters and receivers (VWI). This library is an object-oriented refactoring and extension of the Virtual Wire library (vers. 1.19).

Circuit

RF433/RX V
+------------+ |
|0-----------|-------------------+
|ANT | 17.3 cm
| |
| |
| |
| |
(VCC)---------------1-|VCC |
2-|DATA |
(RX)----------------3-|DATA |
(GND)---------------4-|GND |
+------------+
RF433/TX
+------------+
(TX)----------------1-|DATA |
(VCC)---------------2-|VCC | V
(GND)---------------3-|GND | |
|ANT 0-|--------------------+
+------------+ 17.3 cm

Limitations

Cannot be used together with other classes that use Timer#1.

Definition at line 64 of file VWI.hh.

Constructor & Destructor Documentation

VWI::VWI ( int16_t  net,
uint8_t  dev,
uint16_t  speed,
Receiver rx 
)
inline

Construct Virtual Wire Interface with given network, device address and speed (bits per second).

Definition at line 446 of file VWI.hh.

VWI::VWI ( int16_t  net,
uint8_t  dev,
uint16_t  speed,
Transmitter tx 
)
inline

Construct Virtual Wire Interface with given network, device address and speed (bits per second).

Definition at line 459 of file VWI.hh.

VWI::VWI ( int16_t  net,
uint8_t  dev,
uint16_t  speed,
Receiver rx,
Transmitter tx 
)
inline

Construct Virtual Wire Interface with given network, device address and speed (bits per second).

Definition at line 472 of file VWI.hh.

Member Function Documentation

void Wireless::Driver::address ( int16_t  net,
uint8_t  dev 
)
inlineinherited

Set network and device address. Do not use the broadcast address(0). Should be used before calling begin().

Parameters
[in]netnetwork address.
[in]devdevice address.

Definition at line 106 of file Wireless.hh.

virtual bool VWI::available ( )
inlinevirtual

Return true(1) if a message is available otherwise false(0).

Returns
bool

Reimplemented from Wireless::Driver.

Definition at line 518 of file VWI.hh.

bool VWI::begin ( const void *  config = NULL)
virtual

Start the Wireless device driver. Return true(1) if successful otherwise false(0).

Parameters
[in]configconfiguration vector (default NULL)
Returns
bool

Implements Wireless::Driver.

Definition at line 74 of file VWI.cpp.

virtual int Wireless::Driver::broadcast ( uint8_t  port,
const iovec_t vec 
)
inlinevirtualinherited

Broadcast message in given null terminated io vector. Returns number of bytes sent if successful otherwise a negative error code.

Parameters
[in]portdevice port (or message type).
[in]vecnull termianted io vector.
Returns
number of bytes send or negative error code.

Definition at line 220 of file Wireless.hh.

virtual int Wireless::Driver::broadcast ( uint8_t  port,
const void *  buf,
size_t  len 
)
inlinevirtualinherited

Boardcast message in given buffer, with given number of bytes. Returns number of bytes sent if successful otherwise a negative error code.

Parameters
[in]portdevice port (or message type).
[in]bufbuffer to transmit.
[in]lennumber of bytes in buffer.
Returns
number of bytes send or negative error code.

Definition at line 235 of file Wireless.hh.

uint8_t Wireless::Driver::channel ( ) const
inlineinherited

Get driver channel.

Returns
channel.

Definition at line 77 of file Wireless.hh.

void Wireless::Driver::channel ( uint8_t  channel)
inlineinherited

Set device transmission channel. Should be used before calling begin().

Parameters
[in]channel.

Definition at line 117 of file Wireless.hh.

uint8_t Wireless::Driver::device_address ( ) const
inlineinherited

Get driver device address.

Returns
device address.

Definition at line 95 of file Wireless.hh.

bool VWI::end ( )
virtual

Shut down the device driver. Return true(1) if successful otherwise false(0).

Returns
bool

Reimplemented from Wireless::Driver.

Definition at line 128 of file VWI.cpp.

virtual int Wireless::Driver::input_power_level ( )
inlinevirtualinherited

Return estimated input power level (dBm). Default zero(0).

Returns
power level in dBm.

Reimplemented in CC1101, and RFM69.

Definition at line 282 of file Wireless.hh.

virtual bool Wireless::Driver::is_broadcast ( )
inlinevirtualinherited

Return true(1) if the latest received message was a broadcast otherwise false(0).

Definition at line 262 of file Wireless.hh.

virtual int VWI::link_quality_indicator ( )
inlinevirtual

Return link quality indicator.

Reimplemented from Wireless::Driver.

Definition at line 587 of file VWI.hh.

int16_t Wireless::Driver::network_address ( ) const
inlineinherited

Get driver network address.

Returns
network address.

Definition at line 86 of file Wireless.hh.

virtual void Wireless::Driver::output_power_level ( int8_t  dBm)
inlinevirtualinherited

Set output power level in dBm.

Parameters
[in]dBm.

Reimplemented in NRF24L01P, CC1101, and RFM69.

Definition at line 272 of file Wireless.hh.

void VWI::powerdown ( )
virtual

Set device in power down mode.

Reimplemented from Wireless::Driver.

Definition at line 143 of file VWI.cpp.

void VWI::powerup ( )
virtual

Set device in power up mode.

Reimplemented from Wireless::Driver.

Definition at line 136 of file VWI.cpp.

virtual int VWI::recv ( uint8_t &  src,
uint8_t &  port,
void *  buf,
size_t  len,
uint32_t  ms = 0L 
)
inlinevirtual

Receive message and store into given buffer with given maximum length. The source network address is returned in the parameter src. Returns error code(ETIME) if no message is available and/or a timeout occured. Returns error code(EMSGSIZE) if the buffer size if to small for incoming message or if the receiver fifo has overflowed. Otherwise the actual number of received bytes is returned

Parameters
[out]srcsource network address.
[out]portdevice port (or message type).
[in]bufbuffer to store incoming message.
[in]lenmaximum number of bytes to receive.
[in]msmaximum time out period.
Returns
number of bytes received or negative error code.

Implements Wireless::Driver.

Definition at line 575 of file VWI.hh.

virtual bool Wireless::Driver::room ( )
inlinevirtualinherited

Return true(1) if there is room to send on the device otherwise false(0).

Returns
bool.

Definition at line 176 of file Wireless.hh.

virtual int VWI::send ( uint8_t  dest,
uint8_t  port,
const iovec_t vec 
)
inlinevirtual

Send message in given null terminated io vector. Returns number of bytes sent. Returns error code(-1) if number of bytes is greater than PAYLOAD_MAX. Return error code(-2) if fails to set transmit mode.

Parameters
[in]destdestination network address.
[in]portdevice port (or message type).
[in]vecnull termianted io vector.
Returns
number of bytes send or negative error code.

Implements Wireless::Driver.

Definition at line 535 of file VWI.hh.

virtual int VWI::send ( uint8_t  dest,
uint8_t  port,
const void *  buf,
size_t  len 
)
inlinevirtual

Send message in given buffer, with given number of bytes. Returns number of bytes sent. Returns error code(-1) if number of bytes is greater than PAYLOAD_MAX. Return error code(-2) if fails to set transmit mode.

Parameters
[in]destdestination network address.
[in]portdevice port (or message type).
[in]bufbuffer to transmit.
[in]lennumber of bytes in buffer.
Returns
number of bytes send or negative error code.

Reimplemented from Wireless::Driver.

Definition at line 553 of file VWI.hh.

virtual void Wireless::Driver::wakeup_on_radio ( )
inlinevirtualinherited

Set device in wakeup on radio mode.

Reimplemented in CC1101, and RFM69.

Definition at line 158 of file Wireless.hh.

Friends And Related Function Documentation

void TIMER1_COMPA_vect ( void  )
friend

Interrupt service routine.

Interrupt Service Routines.

Member Data Documentation

const uint8_t Wireless::Driver::BROADCAST = 0x00
staticinherited

Broadcast device address.

Definition at line 58 of file Wireless.hh.

addr_t Wireless::Driver::m_addr
protectedinherited

Current network and device address.

Definition at line 299 of file Wireless.hh.

volatile bool Wireless::Driver::m_avail
protectedinherited

Message available. May be set by ISR.

Definition at line 300 of file Wireless.hh.

uint8_t Wireless::Driver::m_channel
protectedinherited

Current channel (device dependent.

Definition at line 298 of file Wireless.hh.

uint8_t Wireless::Driver::m_dest
protectedinherited

Latest message destination device address.

Definition at line 301 of file Wireless.hh.

const uint8_t VWI::MESSAGE_MAX = PAYLOAD_MAX + 3
staticprotected

Maximum number of bytes in a message (incl. byte count and FCS).

Definition at line 162 of file VWI.hh.

const uint8_t VWI::MESSAGE_MIN = sizeof(header_t)
staticprotected

Minimum number of bytes in a message.

Definition at line 165 of file VWI.hh.

const uint8_t VWI::PAYLOAD_MAX = 30 + sizeof(header_t)
static

The maximum payload length; 30 byte application payload and 4 byte frame header with network(2).

Definition at line 158 of file VWI.hh.

const uint8_t VWI::SAMPLES_PER_BIT = 8
staticprotected

Number of samples per bit.

Definition at line 168 of file VWI.hh.


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