Wiselib
Public Types | Public Member Functions | Protected Member Functions
wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P > Class Template Reference

A sensor that takes part in leader election and clustering. More...

#include <BGU_Sensor.h>

Inherits wiselib::MessageDestination, and wiselib::MessageDestination.

List of all members.

Public Types

typedef OsModel_P OsModel
typedef Radio_P Radio
typedef Timer_P Timer
typedef Clock_P Clock
typedef Debug_P Debug
typedef Sensor< OsModel, Radio,
Timer, Clock, Debug
self_type
typedef wiselib::Echo< Os,
Os::TxRadio, Os::Timer,
Os::Debug > 
NeighborDiscovery
typedef wiselib::vector_static
< wiselib::OSMODEL, nodeid_t, 10 > 
vector_static
typedef self_typeself_pointer_t
typedef delegate1< void, int > cluster_delegate_t
typedef Radio::node_id_t node_id_t
typedef Radio::size_t size_t
typedef Radio::block_data_t block_data_t
typedef Timer::millis_t millis_t
typedef OsModel_P OsModel
typedef Radio_P Radio
typedef Timer_P Timer
typedef Clock_P Clock
typedef Debug_P Debug
typedef Sensor< OsModel, Radio,
Timer, Clock, Debug
self_type
typedef wiselib::Echo< Os,
Os::TxRadio, Os::Timer,
Os::Debug > 
NeighborDiscovery
typedef wiselib::vector_static
< wiselib::OSMODEL, nodeid_t, 10 > 
vector_static
typedef self_typeself_pointer_t
typedef Radio::node_id_t node_id_t
typedef Radio::size_t size_t
typedef Radio::block_data_t block_data_t
typedef Timer::millis_t millis_t

Public Member Functions

 Sensor ()
 Constructor.
 ~Sensor ()
 Destructor.
error_code_t init (typename Timer::self_pointer_t timer, typename Radio::self_pointer_t radio, MessageQueue *mqueue, Os::Debug::self_pointer_t debug, Os::Clock::self_pointer_t clock, NeighborDiscovery &neighbor_discovery)
 Initialize the sensor.
error_code_t handle (TopologyMessage *msg)
 Handle a single incoming message.
nodeid_t cluster_head ()
nodeid_t parent ()
uint8_t hops ()
nodeid_t cluster_id ()
template<class T , void(T::*)(int) TMethod>
int reg_changed_callback (T *obj_pnt)
 Register callbacks.
void unreg_changed_callback (int idx)
 Unregister callbacks.
 Sensor ()
 Constructor.
error_code_t init (typename Timer::self_pointer_t timer, typename Radio::self_pointer_t radio, MessageQueue *mqueue, Os::Debug::self_pointer_t debug, Os::Clock::self_pointer_t clock, NeighborDiscovery &neighbor_discovery)
 Destructor.
error_code_t handle (TopologyMessage *msg)
nodeid_t cluster_head ()
nodeid_t parent ()
uint8_t hops ()
nodeid_t cluster_id ()
void doWork (void *)
void doBlink (void *)
bool shouldAccept (Message *)
uint8_t distanceToNode (nodeid_t node)
void resetTopology ()
bool shouldAssumeLeadership (const topology_record_t &)
error_code_t handleAllMessages ()
nodeid_t findLeader ()
error_code_t broadcastTopology ()

Protected Member Functions

void doWork (void *)
 Update the local topology and elect a leader if needed.
void doBlink (void *)
 Blink the sensor physical LED.
bool shouldAccept (Message *msg)
 Check if a message received should be discarded.
void resetTopology ()
 Reset the local information about the topology, except for information about the 'self' sensor.
bool shouldAssumeLeadership (const topology_record_t &rec)
 Given topology information about another sensor, should this sensor become its leader or not.
error_code_t handleAllMessages ()
 Handle all topology messages accumulated on this sensor's message queue.
nodeid_t findLeader ()
 Find a leader for this sensor, based on the currently known topology.
error_code_t broadcastTopology ()
 Send a message containing the topology information known by this node to all other nodes.
uint8_t distanceToNode (nodeid_t node)
 Find the distance to a given node, according to the current topology information.
void findMyNeighbors ()
void scheduleWorkCallback ()
 Schedule the next run of the doWork callback.
void scheduleBlinkCallback ()
 Schedule the next run of the doBlink callback.
void calculateNewTopology ()
 Calculate new topology from information in the Messages container.
bool isNeighbor (nodeid_t other)
 Check if a given node is a direct neighbor.

Detailed Description

template<typename OsModel_P, typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
class wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >

A sensor that takes part in leader election and clustering.

A sensor periodically accepts and sends topology update messages, and performs leader election according to the information contained in them and to the algorithm described in ftp://ftp.cs.bgu.ac.il/pub/people/dolev/60.pdf


Member Typedef Documentation

template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef Radio::block_data_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::block_data_t
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef Radio::block_data_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::block_data_t
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef Clock_P wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::Clock
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef Clock_P wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::Clock
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef delegate1<void, int> wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::cluster_delegate_t
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef Debug_P wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::Debug
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef Debug_P wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::Debug
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef Timer::millis_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::millis_t
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef Timer::millis_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::millis_t
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef wiselib::Echo<Os, Os::TxRadio, Os::Timer, Os::Debug> wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::NeighborDiscovery
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef wiselib::Echo<Os, Os::TxRadio, Os::Timer, Os::Debug> wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::NeighborDiscovery
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef Radio::node_id_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::node_id_t
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef Radio::node_id_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::node_id_t
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef OsModel_P wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::OsModel
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef OsModel_P wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::OsModel
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef Radio_P wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::Radio
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef Radio_P wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::Radio
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef self_type* wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::self_pointer_t
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef self_type* wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::self_pointer_t
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef Sensor<OsModel, Radio, Timer, Clock, Debug> wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::self_type
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef Sensor<OsModel, Radio, Timer, Clock, Debug> wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::self_type
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef Radio::size_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::size_t
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef Radio::size_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::size_t
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef Timer_P wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::Timer
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef Timer_P wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::Timer
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef wiselib::vector_static<wiselib::OSMODEL, nodeid_t, 10> wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::vector_static
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
typedef wiselib::vector_static<wiselib::OSMODEL, nodeid_t, 10> wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::vector_static

Constructor & Destructor Documentation

template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::Sensor ( ) [inline]

Constructor.

Actual initialization of a Sensor object is done in the init method

template<typename OsModel_P , typename Radio_P , typename Timer_P , typename Clock_P , typename Debug_P >
Sensor::~Sensor ( )

Destructor.

template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::Sensor ( ) [inline]

Constructor.


Member Function Documentation

template<typename OsModel_P , typename Radio_P , typename Timer_P , typename Clock_P , typename Debug_P >
error_code_t Sensor::broadcastTopology ( ) [protected]

Send a message containing the topology information known by this node to all other nodes.

Returns:
ecSuccess on success, some other code on failure.
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
error_code_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::broadcastTopology ( )
template<typename OsModel_P , typename Radio_P , typename Timer_P , typename Clock_P , typename Debug_P >
void Sensor::calculateNewTopology ( ) [protected]

Calculate new topology from information in the Messages container.

template<typename OsModel_P , typename Radio_P , typename Timer_P , typename Clock_P , typename Debug_P >
nodeid_t Sensor::cluster_head ( )
Returns:
id of the cluster head.
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
nodeid_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::cluster_head ( )
template<typename OsModel_P , typename Radio_P , typename Timer_P , typename Clock_P , typename Debug_P >
nodeid_t Sensor::cluster_id ( )
Returns:
cluster id (id of the cluster's leader)
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
nodeid_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::cluster_id ( )
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
uint8_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::distanceToNode ( nodeid_t  node)
template<typename OsModel_P , typename Radio_P , typename Timer_P , typename Clock_P , typename Debug_P >
uint8_t Sensor::distanceToNode ( nodeid_t  node) [protected]

Find the distance to a given node, according to the current topology information.

Parameters:
nodethe node to look for
Returns:
the distance (in 'hops') to the given node, or INFINITE_DISTANCE if the node does not appear in the topology information.
template<typename OsModel_P , typename Radio_P , typename Timer_P , typename Clock_P , typename Debug_P >
void Sensor::doBlink ( void *  ) [protected]

Blink the sensor physical LED.

This is a Timer callback, and so takes an unused parameter and returns nothing.

TODO turn the LED on/off according to _led_state.

TODO turn the LED on/off according to _led_state.

template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
void wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::doBlink ( void *  )
template<typename OsModel_P , typename Radio_P , typename Timer_P , typename Clock_P , typename Debug_P >
void Sensor::doWork ( void *  ) [protected]

Update the local topology and elect a leader if needed.

This is a Timer callback, and so takes an unused parameter and returns nothing.

template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
void wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::doWork ( void *  )
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
nodeid_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::findLeader ( )
template<typename OsModel_P , typename Radio_P , typename Timer_P , typename Clock_P , typename Debug_P >
nodeid_t Sensor::findLeader ( ) [protected]

Find a leader for this sensor, based on the currently known topology.

Returns:
the nodeid of the selected leader. If no node can be this node's leader, then this node's ID is returned.
template<typename OsModel_P , typename Radio_P , typename Timer_P , typename Clock_P , typename Debug_P >
void Sensor::findMyNeighbors ( ) [protected]
template<typename OsModel_P , typename Radio_P , typename Timer_P , typename Clock_P , typename Debug_P >
error_code_t Sensor::handle ( TopologyMessage msg) [virtual]

Handle a single incoming message.

Parameters:
msgthe message to handle
Returns:
ecSuccess on success, some other code on failure.

Implements wiselib::MessageDestination.

template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
error_code_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::handle ( TopologyMessage msg) [virtual]
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
error_code_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::handleAllMessages ( )
template<typename OsModel_P , typename Radio_P , typename Timer_P , typename Clock_P , typename Debug_P >
error_code_t Sensor::handleAllMessages ( ) [protected]

Handle all topology messages accumulated on this sensor's message queue.

Returns:
ecSuccess on success, some other code on failure.
template<typename OsModel_P , typename Radio_P , typename Timer_P , typename Clock_P , typename Debug_P >
uint8_t Sensor::hops ( )
Returns:
number of hops to cluster head
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
uint8_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::hops ( )
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
error_code_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::init ( typename Timer::self_pointer_t  timer,
typename Radio::self_pointer_t  radio,
MessageQueue mqueue,
Os::Debug::self_pointer_t  debug,
Os::Clock::self_pointer_t  clock,
NeighborDiscovery neighbor_discovery 
)

Initialize the sensor.

This method must be called exactly once, before any other method is used.

Parameters:
timerThe timer to use for periodic activities.
radioThe radio for this sensor
mqueueA source of topology messages
debugA debug stream to use for debugging messages
clockThe clock to use
neighbor_discoveryThe algorithm for discovering neighbors
Returns:
ecSuccess on success, some other code on failure.
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
error_code_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::init ( typename Timer::self_pointer_t  timer,
typename Radio::self_pointer_t  radio,
MessageQueue mqueue,
Os::Debug::self_pointer_t  debug,
Os::Clock::self_pointer_t  clock,
NeighborDiscovery neighbor_discovery 
)

Destructor.

Initialization method.

template<typename OsModel_P , typename Radio_P , typename Timer_P , typename Clock_P , typename Debug_P >
bool Sensor::isNeighbor ( nodeid_t  other) [protected]

Check if a given node is a direct neighbor.

Parameters:
otherthe nodeid to check
Returns:
true if the node is a direct neighbor, false otherwise.
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
nodeid_t wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::parent ( )
template<typename OsModel_P , typename Radio_P , typename Timer_P , typename Clock_P , typename Debug_P >
nodeid_t Sensor::parent ( )
Returns:
node's parent
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
template<class T , void(T::*)(int) TMethod>
int wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::reg_changed_callback ( T *  obj_pnt) [inline]

Register callbacks.

(notifys when something changes)

Returns:
returns the internal call back object.
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
void wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::resetTopology ( )
template<typename OsModel_P , typename Radio_P , typename Timer_P , typename Clock_P , typename Debug_P >
void Sensor::resetTopology ( ) [protected]

Reset the local information about the topology, except for information about the 'self' sensor.

template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
void wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::scheduleBlinkCallback ( ) [inline, protected]

Schedule the next run of the doBlink callback.

template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
void wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::scheduleWorkCallback ( ) [inline, protected]

Schedule the next run of the doWork callback.

template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
bool wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::shouldAccept ( Message )
template<typename OsModel_P , typename Radio_P , typename Timer_P , typename Clock_P , typename Debug_P >
bool Sensor::shouldAccept ( Message msg) [protected]

Check if a message received should be discarded.

The algorithm assumes that only messages from direct neighbors are received, so we discard any message that's received from a node that isn't a direct neighbor (distance=1).

Returns:
true if the message should be handled, false if it should be discarded.
template<typename OsModel_P , typename Radio_P , typename Timer_P , typename Clock_P , typename Debug_P >
bool Sensor::shouldAssumeLeadership ( const topology_record_t rec) [protected]

Given topology information about another sensor, should this sensor become its leader or not.

Parameters:
recthe information about the other sensor
Returns:
true if this sensor should become the leader, false if not.
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
bool wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::shouldAssumeLeadership ( const topology_record_t )
template<typename OsModel_P , typename Radio_P = typename OsModel_P::Radio, typename Timer_P = typename OsModel_P::Timer, typename Clock_P = typename OsModel_P::Clock, typename Debug_P = typename OsModel_P::Debug>
void wiselib::Sensor< OsModel_P, Radio_P, Timer_P, Clock_P, Debug_P >::unreg_changed_callback ( int  idx) [inline]

Unregister callbacks.


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