Wiselib
Public Types | Public Member Functions | Public Attributes
concepts::Radio_concept Class Reference

Basic Concept for Radios. More...

Inherited by concepts::ExtendedDataRadio_concept, concepts::ReliableRadio_concept, concepts::Routing_concept, and concepts::TxRadio_concept.

List of all members.

Public Types

enum  SpecialNodeIds { BROADCAST_ADDRESS, NULL_NODE_ID }
enum  Restrictions { MAX_MESSAGE_LENGTH }

Public Member Functions

int enable_radio ()
 Turn on radio.
int disable_radio ()
 Turn off radio.
int send (node_id_t receiver, size_t len, block_data_t *data)
 Send message of len units beginning at *data to given receiver.
node_id_t id ()
 Return id of node for current radio.
template<class T , void(T::*)(node_id_t, size_t, block_data_t *) TMethod>
int reg_recv_callback (T *obj_pnt)
 Register message reception callback function.
int unreg_recv_callback (int idx)
 Unregister message reception callback function - use unique identifier returned by registration.

Public Attributes

typedef OsModel
 Type of Os Concept which has been set for the radio.
typedef self_pointer_t
 Defines type of pointer to this radio.
typedef node_id_t
 Type of node id - must be unique for a node in the network.
typedef block_data_t
 Data type used for raw data in message sending process.
typedef size_t
 Unsigned integer that represents length information.
typedef message_id_t
 Type of message Ids - should be common for all radios if heterogeneity should be supported.

Detailed Description

Basic Concept for Radios.

The radio facet is responsible for sending and receiving messages. This can be done either over a real hardware radio, or as a virtual implementation that does, say, node ID conversion.

First of all, a radio must define certain data types. These are the current OS model, the type for node ids, the type for block data (usually a uint8_t), the size type, and a type for message ids.

A radio also provides some constants. These are the ones related to node IDs: BROADCAST_ADDRESS, which defines the node ID used for a local broadcast when sending a message, and NULL_NODE_ID, which represents an unknown or unset node address. MAX_MESSAGE_LENGTH must be set to the maximal message length the radio can handle.

Next, there are the member functions. The most important one is send, which sends a block of data to the given destination address. The radio can also be enabled and disabled, and it provides the current node ID. At last, the registration of a callback function works with the templated method reg_recv_callback. Usually, delegates should be used to store the passed member function pointer. Since the used delegates are not comparable at the moment, the registration method returns an unique id that in turn must be used for de-registration of the method.


Member Enumeration Documentation

Enumerator:
MAX_MESSAGE_LENGTH 

Maximal size of a message in bytes.

Enumerator:
BROADCAST_ADDRESS 

Send a message to all nodes in communication range of the radio.

NULL_NODE_ID 

Used if node id is not known or not (yet) set.


Member Function Documentation

int concepts::Radio_concept::disable_radio ( )

Turn off radio.

Messages can
not be sent and received.

Returns:
Error (or success) value from Basic Return Values.

Reimplemented in concepts::Routing_concept.

int concepts::Radio_concept::enable_radio ( )

Turn on radio.

Messages can be sent and received.

Returns:
Error (or success) value from Basic Return Values.

Reimplemented in concepts::Routing_concept.

node_id_t concepts::Radio_concept::id ( )

Return id of node for current radio.

This can just be the id provided by the Os, but also any other one for special models. For example, a virtual radio model providing IPv6 addresses.

Returns:
Unique node identifier of type node_id_t.
template<class T , void(T::*)(node_id_t, size_t, block_data_t *) TMethod>
int concepts::Radio_concept::reg_recv_callback ( T *  obj_pnt)

Register message reception callback function.

Returns:
Unique identifier for this registration. Value must be used when
un-registering a callback.

Reimplemented in concepts::Routing_concept, and concepts::ExtendedDataRadio_concept.

int concepts::Radio_concept::send ( node_id_t  receiver,
size_t  len,
block_data_t data 
)

Send message of len units beginning at *data to given receiver.

Returns:
If message has successfully passed to radio.
Not if message has really been sent!

Reimplemented in concepts::Routing_concept.

int concepts::Radio_concept::unreg_recv_callback ( int  idx)

Unregister message reception callback function - use unique identifier returned by registration.

Returns:
Error (or success) value from Basic Return Values.

Reimplemented in concepts::Routing_concept.


Member Data Documentation

Data type used for raw data in message sending process.

Usually an\ uint8_t.

Reimplemented in concepts::Routing_concept.

Type of message Ids - should be common for all radios if heterogeneity should be supported.

Standard is unit16_t.

Reimplemented in concepts::Routing_concept.

Type of node id - must be unique for a node in the network.

Reimplemented in concepts::Routing_concept.

Type of Os Concept which has been set for the radio.

Reimplemented in concepts::Routing_concept.

Defines type of pointer to this radio.

Reimplemented in concepts::Routing_concept.

Unsigned integer that represents length information.

Reimplemented in concepts::Routing_concept.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines