COSA
An Object-Oriented Platform for Arduino Programming
Wireless::Driver Class Referenceabstract

#include <Wireless.hh>

Inheritance diagram for Wireless::Driver:
Inheritance graph
Collaboration diagram for Wireless::Driver:
Collaboration graph

Classes

struct  addr_t
 

Public Member Functions

 Driver (int16_t network, uint8_t device)
 
uint8_t channel () const
 
int16_t network_address () const
 
uint8_t device_address () const
 
void address (int16_t net, uint8_t dev)
 
void channel (uint8_t channel)
 
virtual bool begin (const void *config=NULL)=0
 
virtual bool end ()
 
virtual void powerup ()
 
virtual void powerdown ()
 
virtual void wakeup_on_radio ()
 
virtual bool available ()
 
virtual bool room ()
 
virtual int send (uint8_t dest, uint8_t port, const iovec_t *vec)=0
 
virtual int send (uint8_t dest, uint8_t port, const void *buf, size_t len)
 
virtual int broadcast (uint8_t port, const iovec_t *vec)
 
virtual int broadcast (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)=0
 
virtual bool is_broadcast ()
 
virtual void output_power_level (int8_t dBm)
 
virtual int input_power_level ()
 
virtual int link_quality_indicator ()
 

Static Public Attributes

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

Detailed Description

Common Wireless device driver interface.

Definition at line 35 of file Wireless.hh.

Constructor & Destructor Documentation

Wireless::Driver::Driver ( int16_t  network,
uint8_t  device 
)
inline

Construct Wireless device driver with given network and device address.

Parameters
[in]networkaddress.
[in]deviceaddress.

Definition at line 66 of file Wireless.hh.

Member Function Documentation

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

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 Wireless::Driver::available ( )
inlinevirtual

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

Returns
bool.

Reimplemented in VWI, and NRF24L01P.

Definition at line 165 of file Wireless.hh.

virtual bool Wireless::Driver::begin ( const void *  config = NULL)
pure virtual

Start the Wireless device driver. Return true(1) if successful otherwise false(0). Must be implemented by sub-class.

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

Implemented in VWI, NRF24L01P, CC1101, and RFM69.

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

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

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
inline

Get driver channel.

Returns
channel.

Definition at line 77 of file Wireless.hh.

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

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
inline

Get driver device address.

Returns
device address.

Definition at line 95 of file Wireless.hh.

virtual bool Wireless::Driver::end ( )
inlinevirtual

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

Returns
bool.

Reimplemented in VWI, NRF24L01P, CC1101, and RFM69.

Definition at line 137 of file Wireless.hh.

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

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

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

Definition at line 262 of file Wireless.hh.

virtual int Wireless::Driver::link_quality_indicator ( )
inlinevirtual

Return link quality indicator. Default zero(0).

Returns
quality indicator.

Reimplemented in VWI, and CC1101.

Definition at line 292 of file Wireless.hh.

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

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

Set output power level in dBm.

Parameters
[in]dBm.

Reimplemented in NRF24L01P, CC1101, and RFM69.

Definition at line 272 of file Wireless.hh.

virtual void Wireless::Driver::powerdown ( )
inlinevirtual

Set device in power down mode.

Reimplemented in VWI, CC1101, RFM69, and NRF24L01P.

Definition at line 152 of file Wireless.hh.

virtual void Wireless::Driver::powerup ( )
inlinevirtual

Set device in power up mode.

Reimplemented in VWI, and NRF24L01P.

Definition at line 146 of file Wireless.hh.

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

Receive message and store into given buffer with given maximum length. The source network address is returned in the parameter src. Returns the number of received bytes or a negative error code. Must be implemented by sub-class.

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.

Implemented in VWI, NRF24L01P, CC1101, and RFM69.

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

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 Wireless::Driver::send ( uint8_t  dest,
uint8_t  port,
const iovec_t vec 
)
pure virtual

Send message in given null terminated io vector. Returns number of bytes sent if successful otherwise a negative error code. Must be implemented by sub-class.

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.

Implemented in VWI, NRF24L01P, CC1101, and RFM69.

virtual int Wireless::Driver::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 if successful otherwise a negative error code.

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 in VWI, NRF24L01P, CC1101, and RFM69.

Definition at line 203 of file Wireless.hh.

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

Set device in wakeup on radio mode.

Reimplemented in CC1101, and RFM69.

Definition at line 158 of file Wireless.hh.

Member Data Documentation

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

Broadcast device address.

Definition at line 58 of file Wireless.hh.

addr_t Wireless::Driver::m_addr
protected

Current network and device address.

Definition at line 299 of file Wireless.hh.

volatile bool Wireless::Driver::m_avail
protected

Message available. May be set by ISR.

Definition at line 300 of file Wireless.hh.

uint8_t Wireless::Driver::m_channel
protected

Current channel (device dependent.

Definition at line 298 of file Wireless.hh.

uint8_t Wireless::Driver::m_dest
protected

Latest message destination device address.

Definition at line 301 of file Wireless.hh.


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