forked from UCMAndesLab/CSE160-Project-Skeleton-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pingTest.py
33 lines (24 loc) · 832 Bytes
/
pingTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from TestSim import TestSim
def main():
# Get simulation ready to run.
s = TestSim();
# Before we do anything, lets simulate the network off.
s.runTime(1);
# Load the the layout of the network.
s.loadTopo("long_line.topo");
# Add a noise model to all of the motes.
s.loadNoise("no_noise.txt");
# Turn on all of the sensors.
s.bootAll();
# Add the main channels. These channels are declared in includes/channels.h
s.addChannel(s.COMMAND_CHANNEL);
s.addChannel(s.GENERAL_CHANNEL);
s.addChannel(s.NEIGHBOR_CHANNEL); # Added channel to the simulation
# After sending a ping, simulate a little to prevent collision.
s.runTime(1);
s.ping(2, 3, "Hello, World");
s.runTime(1);
s.ping(1, 10, "Hi!");
s.runTime(1);
if __name__ == '__main__':
main()