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:
Thu Sep 06 12:05:52 2012 +0000
Revision:
2:5228774a6b99
Parent:
0:cc7218c5e5f7
Child:
4:dbbf82c966c2
added doc

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mariob 0:cc7218c5e5f7 1 #include "ssWiPort.hpp"
mariob 0:cc7218c5e5f7 2
mariob 0:cc7218c5e5f7 3 PortValue ssWiPort::getTXValue()
mariob 0:cc7218c5e5f7 4 {
mariob 0:cc7218c5e5f7 5 PortValue tmp;
mariob 0:cc7218c5e5f7 6 mutexTX.lock();
mariob 0:cc7218c5e5f7 7 tmp = valueTX;
mariob 0:cc7218c5e5f7 8 modified = false;
mariob 0:cc7218c5e5f7 9 mutexTX.unlock();
mariob 0:cc7218c5e5f7 10 return tmp;
mariob 0:cc7218c5e5f7 11 }
mariob 0:cc7218c5e5f7 12
mariob 0:cc7218c5e5f7 13 void ssWiPort::setTXValue(PortValue tmp)
mariob 0:cc7218c5e5f7 14 {
mariob 0:cc7218c5e5f7 15 mutexTX.lock();
mariob 0:cc7218c5e5f7 16 valueTX = tmp;
mariob 0:cc7218c5e5f7 17 modified = true;
mariob 0:cc7218c5e5f7 18 mutexTX.unlock();
mariob 0:cc7218c5e5f7 19 }
mariob 0:cc7218c5e5f7 20
mariob 0:cc7218c5e5f7 21 bool ssWiPort::isModified()
mariob 0:cc7218c5e5f7 22 {
mariob 0:cc7218c5e5f7 23 bool tmp;
mariob 0:cc7218c5e5f7 24 mutexTX.lock();
mariob 0:cc7218c5e5f7 25 tmp = modified;
mariob 0:cc7218c5e5f7 26 mutexTX.unlock();
mariob 0:cc7218c5e5f7 27 return tmp;
mariob 0:cc7218c5e5f7 28 }
mariob 0:cc7218c5e5f7 29
mariob 0:cc7218c5e5f7 30 PortValue ssWiPort::getRXValue()
mariob 0:cc7218c5e5f7 31 {
mariob 0:cc7218c5e5f7 32 PortValue tmp;
mariob 0:cc7218c5e5f7 33 mutexRX.lock();
mariob 0:cc7218c5e5f7 34 tmp = valueRX;
mariob 0:cc7218c5e5f7 35 mutexRX.unlock();
mariob 0:cc7218c5e5f7 36 return tmp;
mariob 0:cc7218c5e5f7 37 }
mariob 0:cc7218c5e5f7 38
mariob 0:cc7218c5e5f7 39 void ssWiPort::setRXValue(PortValue tmp)
mariob 0:cc7218c5e5f7 40 {
mariob 0:cc7218c5e5f7 41 mutexRX.lock();
mariob 0:cc7218c5e5f7 42 valueRX = tmp;
mariob 0:cc7218c5e5f7 43 mutexRX.unlock();
mariob 0:cc7218c5e5f7 44 }