This sample shows how to organize the simplest peer-to-peer link. A simple buffering strategy is employed to avoid byte-by-byte data transfer.
At least 2 nodes are participating. Up to 7 nodes can be engaged. In order to define the node logical addresses, set DIP switches as shown below. One of the nodes should be configured as coordinator (i.e. its logical address should be set to zero). All of the nodes which are connected over UART to their own USB ports (see connection settings), simply exchange over UART with data sent to them by their hosts. The nodes communicate strictly in pairs defined by their logical addresses as follows:
Node | DIP switches | ||
---|---|---|---|
SW4:1 | SW4:2 | SW4:3 | |
0 | OFF | OFF | OFF |
1 | ON | OFF | OFF |
2 | OFF | ON | OFF |
3 | ON | ON | OFF |
4 | OFF | OFF | ON |
5 | ON | OFF | ON |
6 | OFF | ON | ON |
7 | ON | ON | ON |
The network organizes automatically on startup. You may connect two devices to a PC (or to different PCs, thus introducing a rough functional equivalent of an instant messenger), start two instances of HyperTerminal, type some message in one terminal window and observe it appearing in the another.
Pressing SW1 button on a node results in sending a single
LEDs indicate network activity as follows:
The source code and Makefile of Peer-to-peer application are located at