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)
ssWiChannel.hpp
- Committer:
- mariob
- Date:
- 2012-09-07
- Revision:
- 5:0b0ca40aeb81
- Parent:
- 4:dbbf82c966c2
- Child:
- 13:69ff47a83260
File content as of revision 5:0b0ca40aeb81:
/** \file ssWiChannel.hpp * \brief Abstract class for the communication channel * */ #ifndef __SHARED_SLOTTED_WIRELESS_CHANNEL_HPP__ #define __SHARED_SLOTTED_WIRELESS_CHANNEL_HPP__ #include "ssWi.hpp" /** \brief Abstract class for a communication channel * */ class ssWiChannel { protected: /** \brief Initialize the protocol */ bool _init (ssWiChannel* c, int TXRate, int RXRate) { return ssWi_init(c, TXRate, RXRate); } public: /** \brief Initialize ssWi on this channel * * \param TXRate number of transmissions per second * \param RXRate number of receptions per second * \return true if ssWi has been initialized succefully */ virtual bool init (int TXRate, int RXRate) = 0; /** \brief read from the socket * * \param msg buffer where to write the read message * \return the number of read bytes */ virtual int read (char* msg) = 0; /** \brief write to the socket * * \param msg buffer with the message to send * \n number of bytes to send */ virtual void write (const char* msg, int n) = 0; }; #endif //__SHARED_SLOTTED_WIRELESS_CHANNEL_HPP__