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 4:dbbf82c966c2 1 /** \file ssWiPort.hpp
mariob 4:dbbf82c966c2 2 * \brief Header for introducing the dual head port
mariob 4:dbbf82c966c2 3 *
mariob 4:dbbf82c966c2 4 */
mariob 4:dbbf82c966c2 5
mariob 0:cc7218c5e5f7 6 #ifndef __SHARED_SLOTTED_WIRELESS_PORT_HPP__
mariob 0:cc7218c5e5f7 7 #define __SHARED_SLOTTED_WIRELESS_PORT_HPP__
mariob 0:cc7218c5e5f7 8
mariob 4:dbbf82c966c2 9 #include "rtos.h"
mariob 0:cc7218c5e5f7 10
mariob 4:dbbf82c966c2 11 #include "ssWiTypes.hpp"
mariob 0:cc7218c5e5f7 12
mariob 24:80345e511574 13 #include <atomic>
mariob 2:5228774a6b99 14
mariob 2:5228774a6b99 15 /** \brief Internal type which represents a logical flow
mariob 2:5228774a6b99 16 *
mariob 3:1adc077d4906 17 * Ports are used internally to model a virtual memory are of the network.
mariob 3:1adc077d4906 18 * Note that a port is a dual gate memory area which means that if you write
mariob 3:1adc077d4906 19 * on it, the reading operation does not read that value but the one received
mariob 13:69ff47a83260 20 * through the network
mariob 2:5228774a6b99 21 */
mariob 0:cc7218c5e5f7 22 class ssWiPort
mariob 0:cc7218c5e5f7 23 {
mariob 4:dbbf82c966c2 24 /** \brief receiving buffer */
mariob 24:80345e511574 25 std::atomic<PortValue> valueRX;
mariob 4:dbbf82c966c2 26
mariob 4:dbbf82c966c2 27 /** \brief transmission buffer */
mariob 24:80345e511574 28 std::atomic<PortValue> valueTX;
mariob 3:1adc077d4906 29
mariob 4:dbbf82c966c2 30 /** \brief modification flag (if true a new value has to be sent) */
mariob 24:80345e511574 31 std::atomic<bool> modified;
mariob 0:cc7218c5e5f7 32
mariob 0:cc7218c5e5f7 33 public:
mariob 0:cc7218c5e5f7 34
mariob 4:dbbf82c966c2 35 /** \brief constructor */
mariob 0:cc7218c5e5f7 36 ssWiPort () {
mariob 0:cc7218c5e5f7 37 modified = false;
mariob 0:cc7218c5e5f7 38 valueTX = 0;
mariob 0:cc7218c5e5f7 39 valueRX = 0;
mariob 0:cc7218c5e5f7 40 }
mariob 0:cc7218c5e5f7 41
mariob 4:dbbf82c966c2 42 /** \brief get the value to be sent
mariob 4:dbbf82c966c2 43 */
mariob 0:cc7218c5e5f7 44 PortValue getTXValue();
mariob 4:dbbf82c966c2 45
mariob 4:dbbf82c966c2 46 /** \brief write a value to be sent
mariob 4:dbbf82c966c2 47 */
mariob 0:cc7218c5e5f7 48 void setTXValue(PortValue tmp);
mariob 4:dbbf82c966c2 49
mariob 4:dbbf82c966c2 50 /** \brief true if there is a value to be sent
mariob 4:dbbf82c966c2 51 */
mariob 0:cc7218c5e5f7 52 bool isModified();
mariob 0:cc7218c5e5f7 53
mariob 4:dbbf82c966c2 54 /** \brief Read the last received value
mariob 4:dbbf82c966c2 55 */
mariob 0:cc7218c5e5f7 56 PortValue getRXValue();
mariob 4:dbbf82c966c2 57
mariob 4:dbbf82c966c2 58 /** \brief Write the last received value
mariob 4:dbbf82c966c2 59 */
mariob 0:cc7218c5e5f7 60 void setRXValue(PortValue tmp);
mariob 0:cc7218c5e5f7 61
mariob 0:cc7218c5e5f7 62 };
mariob 0:cc7218c5e5f7 63
mariob 0:cc7218c5e5f7 64 #endif //__SHARED_SLOTTED_WIRELESS_PORT_HPP__