A simple wireless protocol to let my examples communicate each other. ssWi stands for Shared Slotted Wireless protocol
Dependents: rover_car rover_pc supervisor watering_unit ... more
This library aims at implementing a simple communication protocol among nodes, abstracting from the hardware. The name ssWi stands for Shared Slotted Wireless. Wireless is part of the name, even though the library abstracts from the hardware, as the first version was entirely focused on the XBee modules and then the name has not been changed.
The communication channel is represented by ssWiChannel, an abstract class which models the channel that the transceivers access to. The concrete classes must implement the functions: init, read and write. The protocol automatically sends and receives data through the selected channel, exploiting the operting system timers. Addresses are not considered as the communication lays on broadcast transmissions.
The protocol provides the ssWiPort abstraction which is like memory areas shared among all the connected nodes. Reading from one port lets the node retrieve the last written value from the other nodes. Writing on one port means sending such value to other nodes.
Objects instantiated from ssWiSocket are the interface for allowing nodes to access the protocol ports.
TODO:
- improve the parsing of the received messages
- communication tests with many nodes (so far, only 2 nodes have been tested)
Diff: ssWi.hpp
- Revision:
- 13:69ff47a83260
- Parent:
- 9:b5b5d0533fa6
- Child:
- 20:36931ee9af85
diff -r f35f9195d598 -r 69ff47a83260 ssWi.hpp --- a/ssWi.hpp Tue Oct 16 11:24:49 2012 +0000 +++ b/ssWi.hpp Wed Mar 06 08:21:41 2013 +0000 @@ -1,19 +1,19 @@ +/** \file ssWi.hpp + * \brief internal functions for mananing the protocol + * + */ + #ifndef __SHARED_SLOTTED_WIRELESS_HPP__ #define __SHARED_SLOTTED_WIRELESS_HPP__ #include "ssWiTypes.hpp" -#define START_0 255 -#define START_1 130 -#define START_2 255 - - /** \brief number of provided ports - * */ #define N_PORTS 256 + class ssWiChannel; /** \brief Initialize the ssWi protocol @@ -21,18 +21,38 @@ * It is not possible to have two instances of this protocol at the same time. * * \param c channel to be used for sending/receving data - * \param rateTX transmission rate - * \param rateRX receiving rate + * \param rateTX transmission rate (how many time every second) + * \param rateRX receiving rate (how many time every second) * \return true if the network has been correctly initialized, false otherwise + * + * \warning rx should be at least twice more frequent than tx (rateRX >= 2*rateTX) */ bool ssWi_init (ssWiChannel* c, int rateTX, int rateRX); +/** \brief disable the communication protocol + * + */ void ssWi_stop (); +/** \brief check if the communication port is open + * + * \param port port identified to check + * \return true if the port is open, false otherwise + */ bool ssWi_isActive (PortID port); +/** \brief open the specified port + * + * \param port port identified to open + * \return true if the port has been opened, false otherwise + */ bool ssWi_setPort (PortID port); +/** \brief free the specified port + * + * \param port port identified to close + * \return true if the port has been closed, false otherwise + */ bool ssWi_unsetPort (PortID port);