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:
Mon Apr 20 20:27:01 2020 +0000
Revision:
24:80345e511574
Parent:
13:69ff47a83260
few more comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mariob 7:ca87b7287af9 1 /** \file ssWiSocket.hpp
mariob 24:80345e511574 2 *
mariob 7:ca87b7287af9 3 * \brief Header for the communication socket
mariob 4:dbbf82c966c2 4 *
mariob 4:dbbf82c966c2 5 */
mariob 4:dbbf82c966c2 6
mariob 0:cc7218c5e5f7 7 #ifndef __SHARED_SLOTTED_WIRELESS_SOCKET_HPP__
mariob 0:cc7218c5e5f7 8 #define __SHARED_SLOTTED_WIRELESS_SOCKET_HPP__
mariob 0:cc7218c5e5f7 9
mariob 4:dbbf82c966c2 10
mariob 4:dbbf82c966c2 11 #include "ssWiTypes.hpp"
mariob 4:dbbf82c966c2 12
mariob 0:cc7218c5e5f7 13
mariob 4:dbbf82c966c2 14 /** \brief Socket to communciate through ssWi
mariob 4:dbbf82c966c2 15 *
mariob 4:dbbf82c966c2 16 * It is not possible to instanciate directly a ssWiSocket, use the static
mariob 4:dbbf82c966c2 17 * method createSocket
mariob 4:dbbf82c966c2 18 */
mariob 0:cc7218c5e5f7 19 class ssWiSocket
mariob 0:cc7218c5e5f7 20 {
mariob 4:dbbf82c966c2 21 /** \brief Port identifier */
mariob 4:dbbf82c966c2 22 PortID _id;
mariob 0:cc7218c5e5f7 23
mariob 4:dbbf82c966c2 24 /** \brief Hidden constructor */
mariob 4:dbbf82c966c2 25 ssWiSocket(PortID id) : _id(id) {}
mariob 0:cc7218c5e5f7 26
mariob 0:cc7218c5e5f7 27 public:
mariob 0:cc7218c5e5f7 28
mariob 4:dbbf82c966c2 29 /** \brief create a new socket
mariob 4:dbbf82c966c2 30 *
mariob 4:dbbf82c966c2 31 * If the network is not inizialized yet, the method returns false
mariob 4:dbbf82c966c2 32 *
mariob 4:dbbf82c966c2 33 * \param id port identifier to connect the socket with
mariob 13:69ff47a83260 34 * \return the created socket
mariob 4:dbbf82c966c2 35 */
mariob 4:dbbf82c966c2 36 static ssWiSocket* createSocket(PortID id);
mariob 0:cc7218c5e5f7 37
mariob 4:dbbf82c966c2 38 /** \brief read the last value read through the network on such socket
mariob 13:69ff47a83260 39 *
mariob 13:69ff47a83260 40 * \return the read value
mariob 4:dbbf82c966c2 41 */
mariob 4:dbbf82c966c2 42 PortValue read ();
mariob 4:dbbf82c966c2 43
mariob 4:dbbf82c966c2 44 /** \brief write a new value to be sent through the socket
mariob 4:dbbf82c966c2 45 *
mariob 4:dbbf82c966c2 46 * \param value value to be sent
mariob 4:dbbf82c966c2 47 */
mariob 4:dbbf82c966c2 48 void write (PortValue value);
mariob 4:dbbf82c966c2 49
mariob 0:cc7218c5e5f7 50 };
mariob 0:cc7218c5e5f7 51
mariob 0:cc7218c5e5f7 52
mariob 0:cc7218c5e5f7 53 #endif //__SHARED_SLOTTED_WIRELESS_SOCKET_HPP__