2009-01-08 19:01:36 +01:00
|
|
|
TIMEOUT(300000, log.log("received/node: " + count[1] + " " + count[2] + " " + count[3] + " " + count[4] + " " + count[5] + " " + count[6] + " " + count[7] + "\n"));
|
2009-01-08 18:11:06 +01:00
|
|
|
|
|
|
|
/* Conf. */
|
|
|
|
booted = new Array();
|
|
|
|
count = new Array();
|
|
|
|
nrNodes = 7;
|
|
|
|
nodes_starting = true;
|
|
|
|
for (i = 1; i <= nrNodes; i++) {
|
|
|
|
booted[i] = false;
|
|
|
|
count[i] = 0;
|
2008-11-05 20:22:18 +01:00
|
|
|
}
|
2009-01-08 18:11:06 +01:00
|
|
|
|
|
|
|
/* Wait until all nodes have started */
|
|
|
|
while (nodes_starting) {
|
2009-01-08 19:01:36 +01:00
|
|
|
YIELD_THEN_WAIT_UNTIL(msg.startsWith('Starting'));
|
|
|
|
|
2009-01-08 18:11:06 +01:00
|
|
|
log.log("Node " + id + " booted\n");
|
|
|
|
booted[id] = true;
|
|
|
|
|
|
|
|
for (i = 1; i <= nrNodes; i++) {
|
|
|
|
if (!booted[i]) break;
|
|
|
|
if (i == nrNodes) nodes_starting = false;
|
2008-11-05 20:22:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create sink */
|
2009-01-08 18:11:06 +01:00
|
|
|
log.log("All nodes booted, creating sink at node " + id + "\n");
|
|
|
|
mote.getInterfaces().getButton().clickButton()
|
2008-11-05 20:22:18 +01:00
|
|
|
|
2009-01-08 18:11:06 +01:00
|
|
|
while (true) {
|
|
|
|
YIELD();
|
|
|
|
|
|
|
|
/* Count sensor data packets */
|
|
|
|
source = msg.split(" ")[0];
|
|
|
|
count[source]++;
|
2009-01-08 19:01:36 +01:00
|
|
|
log.log("Got data from node " + source + ": tot=" + count[source] + "\n");
|
2009-01-08 18:11:06 +01:00
|
|
|
|
|
|
|
/* Fail if any node has transmitted more than 20 packets */
|
|
|
|
for (i = 1; i <= nrNodes; i++) {
|
|
|
|
if (count[i] > 20) {
|
|
|
|
log.log("received/node: " + count[1] + " " + count[2] + " " + count[3] + " " + count[4] + " " + count[5] + " " + count[6] + " " + count[7] + "\n");
|
|
|
|
log.testFailed(); /* We are done! */
|
|
|
|
}
|
2008-12-03 15:19:41 +01:00
|
|
|
}
|
|
|
|
|
2009-01-08 18:11:06 +01:00
|
|
|
/* Wait until we have received data from all nodes */
|
|
|
|
for (i = 1; i <= nrNodes; i++) {
|
|
|
|
if (count[i] < 5) break;
|
|
|
|
if (i == nrNodes) log.testOK();
|
2008-11-05 20:22:18 +01:00
|
|
|
}
|
|
|
|
|
2009-01-08 18:11:06 +01:00
|
|
|
}
|