From: rincon Date: Fri, 18 May 2007 18:53:24 +0000 (+0000) Subject: Automatic retries if the mote doesn't send back a proper ack. This helps work around... X-Git-Tag: release_tools_1_2_4_1~182 X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=commitdiff_plain;h=a0a0ae61af06644b8936055120a001460189ca94;p=tinyos-2.x.git Automatic retries if the mote doesn't send back a proper ack. This helps work around the tmote dropped packet issue. --- diff --git a/support/sdk/java/net/tinyos/packet/Packetizer.java b/support/sdk/java/net/tinyos/packet/Packetizer.java index eec1498a..0c5d4879 100644 --- a/support/sdk/java/net/tinyos/packet/Packetizer.java +++ b/support/sdk/java/net/tinyos/packet/Packetizer.java @@ -31,6 +31,7 @@ package net.tinyos.packet; import net.tinyos.util.*; + import java.io.*; import java.util.*; import java.nio.*; @@ -115,7 +116,7 @@ public class Packetizer extends AbstractSource implements Runnable { synchronized public void open(Messenger messages) throws IOException { super.open(messages); - if(!reader.isAlive()) { + if (!reader.isAlive()) { reader.start(); } } @@ -181,16 +182,17 @@ public class Packetizer extends AbstractSource implements Runnable { // Write an ack-ed packet protected boolean writeSourcePacket(byte[] packet) throws IOException { - writeFramedPacket(P_PACKET_ACK, ++seqNo, packet, packet.length); + for (int retries = 0; retries < 25; retries++) { + writeFramedPacket(P_PACKET_ACK, ++seqNo, packet, packet.length); + + long deadline = System.currentTimeMillis() + ACK_TIMEOUT; - long deadline = System.currentTimeMillis() + ACK_TIMEOUT; - for (;;) { byte[] ack = readProtocolPacket(P_ACK, deadline); if (ack == null) { if (DEBUG) { message(name + ": ACK timed out"); } - return false; + continue; } if (ack[0] == (byte) seqNo) { if (DEBUG) { @@ -200,6 +202,7 @@ public class Packetizer extends AbstractSource implements Runnable { } } + return false; } static private byte ackPacket[] = new byte[0]; diff --git a/support/sdk/java/tinyos.jar b/support/sdk/java/tinyos.jar index cd6ec2e9..b1a4b485 100644 Binary files a/support/sdk/java/tinyos.jar and b/support/sdk/java/tinyos.jar differ