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)
Revision:
19:e8058fd532d6
Parent:
18:133e42dc82b0
--- a/ssWi.cpp	Thu Jan 19 23:29:34 2017 +0000
+++ b/ssWi.cpp	Sun Jan 22 23:25:16 2017 +0000
@@ -12,7 +12,6 @@
 
 #include <map>
 
-
 /** \brief first byte of the header
  *
  * The header is composed of 3 bytes
@@ -31,13 +30,11 @@
  */
 #define START_2 255
 
-
 /** 
  * dimension of the buffers used by the sender and receiver procedure
  */ 
 #define INTERNAL_BUFFER_SIZE 100
 
-
 /** \brief channel abstraction
  *
  * This object represent the communication channel that can be
@@ -94,8 +91,6 @@
 void functionSender ()
 {
     while (1) {
-        DigitalOut l(LED1);
-        l = 1;
         static char buffer[INTERNAL_BUFFER_SIZE];
         int n = 3;
         int numFrames = 0;
@@ -113,13 +108,10 @@
             buffer[0] = START_0;
             buffer[1] = START_1;
             buffer[2] = START_2;
-
             mutexChannel.lock();
             channel->write(buffer, n);
             mutexChannel.unlock();
-            
         }
-        l = 0;
         Thread::wait(TXRate);
     }
 }
@@ -131,8 +123,6 @@
         mutexChannel.lock();
         int n = channel->read(buffer);
         mutexChannel.unlock();
-        DigitalOut l(LED2);
-        l = 1;
         bool found = false;
         for (int i=0; i < (n - 2); ) {
             if (!found && buffer[i] == START_0 && buffer[i+1] == START_1 && 
@@ -150,7 +140,6 @@
             } else 
                 i++;
         }
-        l = 0;
         Thread::wait(RXRate);
     }
 }