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 7:ca87b7287af9 1 /** \file ssWiSocket.cpp
mariob 7:ca87b7287af9 2 * \brief Implementation of the communication socket
mariob 7:ca87b7287af9 3 *
mariob 7:ca87b7287af9 4 */
mariob 7:ca87b7287af9 5
mariob 0:cc7218c5e5f7 6 #include "ssWiSocket.hpp"
mariob 0:cc7218c5e5f7 7 #include "ssWiPort.hpp"
mariob 4:dbbf82c966c2 8 #include "ssWi.hpp"
mariob 0:cc7218c5e5f7 9
mariob 4:dbbf82c966c2 10 #include <map>
mariob 0:cc7218c5e5f7 11
mariob 0:cc7218c5e5f7 12
mariob 4:dbbf82c966c2 13 extern std::map<int, ssWiPort> ports;
mariob 0:cc7218c5e5f7 14
mariob 0:cc7218c5e5f7 15
mariob 4:dbbf82c966c2 16 PortValue ssWiSocket::read () {
mariob 4:dbbf82c966c2 17 return ports[_id].getRXValue();
mariob 0:cc7218c5e5f7 18 }
mariob 0:cc7218c5e5f7 19
mariob 4:dbbf82c966c2 20 void ssWiSocket::write (PortValue value) {
mariob 4:dbbf82c966c2 21 ports[_id].setTXValue(value);
mariob 0:cc7218c5e5f7 22 }
mariob 0:cc7218c5e5f7 23
mariob 4:dbbf82c966c2 24 ssWiSocket* ssWiSocket::createSocket(PortID id)
mariob 0:cc7218c5e5f7 25 {
mariob 4:dbbf82c966c2 26 if (!ssWi_setPort(id))
mariob 8:354a0e3087c1 27 return NULL;
mariob 24:80345e511574 28
mariob 4:dbbf82c966c2 29 return new ssWiSocket(id);
mariob 0:cc7218c5e5f7 30 }