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.

/media/uploads/mariob/scheme.png

TODO:

  • improve the parsing of the received messages
  • communication tests with many nodes (so far, only 2 nodes have been tested)
Committer:
mariob
Date:
Tue Apr 21 08:23:47 2020 +0000
Revision:
25:83172a067b57
Parent:
24:80345e511574
added comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mariob 13:69ff47a83260 1 /** \file ssWi.hpp
mariob 24:80345e511574 2 *
mariob 13:69ff47a83260 3 * \brief internal functions for mananing the protocol
mariob 13:69ff47a83260 4 *
mariob 13:69ff47a83260 5 */
mariob 13:69ff47a83260 6
mariob 4:dbbf82c966c2 7 #ifndef __SHARED_SLOTTED_WIRELESS_HPP__
mariob 4:dbbf82c966c2 8 #define __SHARED_SLOTTED_WIRELESS_HPP__
mariob 4:dbbf82c966c2 9
mariob 4:dbbf82c966c2 10 #include "ssWiTypes.hpp"
mariob 4:dbbf82c966c2 11
mariob 9:b5b5d0533fa6 12
mariob 24:80345e511574 13 /** \brief max number of provided ports
mariob 4:dbbf82c966c2 14 */
mariob 24:80345e511574 15 #define N_PORTS 255
mariob 4:dbbf82c966c2 16
mariob 13:69ff47a83260 17
mariob 4:dbbf82c966c2 18 class ssWiChannel;
mariob 4:dbbf82c966c2 19
mariob 4:dbbf82c966c2 20 /** \brief Initialize the ssWi protocol
mariob 4:dbbf82c966c2 21 *
mariob 4:dbbf82c966c2 22 * It is not possible to have two instances of this protocol at the same time.
mariob 4:dbbf82c966c2 23 *
mariob 4:dbbf82c966c2 24 * \param c channel to be used for sending/receving data
mariob 13:69ff47a83260 25 * \param rateTX transmission rate (how many time every second)
mariob 13:69ff47a83260 26 * \param rateRX receiving rate (how many time every second)
mariob 4:dbbf82c966c2 27 * \return true if the network has been correctly initialized, false otherwise
mariob 13:69ff47a83260 28 *
mariob 13:69ff47a83260 29 * \warning rx should be at least twice more frequent than tx (rateRX >= 2*rateTX)
mariob 4:dbbf82c966c2 30 */
mariob 4:dbbf82c966c2 31 bool ssWi_init (ssWiChannel* c, int rateTX, int rateRX);
mariob 4:dbbf82c966c2 32
mariob 13:69ff47a83260 33 /** \brief check if the communication port is open
mariob 13:69ff47a83260 34 *
mariob 13:69ff47a83260 35 * \param port port identified to check
mariob 13:69ff47a83260 36 * \return true if the port is open, false otherwise
mariob 13:69ff47a83260 37 */
mariob 4:dbbf82c966c2 38 bool ssWi_isActive (PortID port);
mariob 4:dbbf82c966c2 39
mariob 13:69ff47a83260 40 /** \brief open the specified port
mariob 13:69ff47a83260 41 *
mariob 13:69ff47a83260 42 * \param port port identified to open
mariob 13:69ff47a83260 43 * \return true if the port has been opened, false otherwise
mariob 13:69ff47a83260 44 */
mariob 4:dbbf82c966c2 45 bool ssWi_setPort (PortID port);
mariob 4:dbbf82c966c2 46
mariob 13:69ff47a83260 47 /** \brief free the specified port
mariob 13:69ff47a83260 48 *
mariob 13:69ff47a83260 49 * \param port port identified to close
mariob 13:69ff47a83260 50 * \return true if the port has been closed, false otherwise
mariob 13:69ff47a83260 51 */
mariob 4:dbbf82c966c2 52 bool ssWi_unsetPort (PortID port);
mariob 4:dbbf82c966c2 53
mariob 4:dbbf82c966c2 54
mariob 4:dbbf82c966c2 55 #endif //__SHARED_SLOTTED_WIRELESS_HPP__