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.
TODO:
- improve the parsing of the received messages
- communication tests with many nodes (so far, only 2 nodes have been tested)
Diff: xbee/xbee.cpp
- Revision:
- 17:8ba1b278b407
- Parent:
- 15:fb0f6cbc0ed5
- Child:
- 18:133e42dc82b0
--- a/xbee/xbee.cpp Thu Mar 07 15:44:05 2013 +0000 +++ b/xbee/xbee.cpp Wed Jan 18 21:01:25 2017 +0000 @@ -19,7 +19,6 @@ } } - bool XBeeModule::executeWithOk (const char* cmd) { char msg[5]; @@ -31,7 +30,6 @@ return true; } - void XBeeModule::executeWithRes (const char* cmd, char* res) { xbee.printf("%s", cmd); @@ -39,11 +37,6 @@ //printf("\n\r%s -> %s\n\r", cmd, res); } - - - - - XBeeModule::XBeeModule (PinName tx, PinName rx, int panID, int channel) : xbee(tx, rx, 64) { status = false; @@ -60,12 +53,6 @@ status = true; } - - - - - - XBeeAddress XBeeModule::getDstAddress () { char tmp[10]; @@ -93,7 +80,6 @@ return XBeeAddress(low, high); } - bool XBeeModule::setDstAddress (XBeeAddress addr) { char s[10]; @@ -118,7 +104,6 @@ return true; } - bool XBeeModule::_getLocalAddr () { char tmp[10]; @@ -200,8 +185,6 @@ return id; } - - int XBeeModule::read (char* msg) { int i = 0; @@ -210,8 +193,6 @@ return i; } - - void XBeeModule::write (const char* msg, int n) { for (int i=0; i<n; i++) {