sky motes output the new converted radio packets

This commit is contained in:
fros4943 2009-04-01 23:37:27 +00:00
parent 0a740aad63
commit 2ac3662ea8
2 changed files with 14 additions and 9 deletions

View file

@ -26,14 +26,15 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: CC2420RadioPacketConverter.java,v 1.6 2009/03/09 16:05:11 fros4943 Exp $ * $Id: CC2420RadioPacketConverter.java,v 1.7 2009/04/01 23:37:27 fros4943 Exp $
*/ */
package se.sics.cooja.mspmote.interfaces; package se.sics.cooja.mspmote.interfaces;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import se.sics.cooja.COOJARadioPacket; import se.sics.cooja.ConvertedRadioPacket;
import se.sics.cooja.RadioPacket;
/** /**
* Converts radio packets between X-MAC/CC24240/Sky and COOJA. * Converts radio packets between X-MAC/CC24240/Sky and COOJA.
@ -51,7 +52,7 @@ public class CC2420RadioPacketConverter {
public static final boolean WITH_TIMESTAMP = true; public static final boolean WITH_TIMESTAMP = true;
public static final boolean WITH_FOOTER = true; public static final boolean WITH_FOOTER = true;
public static byte[] fromCoojaToCC2420(COOJARadioPacket packet) { public static byte[] fromCoojaToCC2420(RadioPacket packet) {
byte cc2420Data[] = new byte[6+127]; byte cc2420Data[] = new byte[6+127];
int pos = 0; int pos = 0;
byte packetData[] = packet.getPacketData(); byte packetData[] = packet.getPacketData();
@ -132,9 +133,10 @@ public class CC2420RadioPacketConverter {
return cc2420DataStripped; return cc2420DataStripped;
} }
public static COOJARadioPacket fromCC2420ToCooja(byte[] data) { public static ConvertedRadioPacket fromCC2420ToCooja(byte[] data) {
int pos = 0; int pos = 0;
int len; /* Payload */ int len; /* Payload */
int originalLen;
/* Use some CC2420/MAC specific field such as X-MAC response */ /* Use some CC2420/MAC specific field such as X-MAC response */
@ -150,6 +152,7 @@ public class CC2420RadioPacketConverter {
/* 1 byte length */ /* 1 byte length */
len = data[pos]; len = data[pos];
originalLen = len;
pos += 1; pos += 1;
/* (IGNORED) 4 byte X-MAC */ /* (IGNORED) 4 byte X-MAC */
@ -176,9 +179,11 @@ public class CC2420RadioPacketConverter {
/*logger.info("Payload pos: " + pos); /*logger.info("Payload pos: " + pos);
logger.info("Payload length: " + len);*/ logger.info("Payload length: " + len);*/
byte coojaData[] = new byte[len]; byte convertedData[] = new byte[len];
System.arraycopy(data, pos, coojaData, 0, len); System.arraycopy(data, pos, convertedData, 0, len);
return new COOJARadioPacket(coojaData); byte originalData[] = new byte[originalLen];
System.arraycopy(data, 0, originalData, 0, originalLen);
return new ConvertedRadioPacket(convertedData, originalData);
} }
} }

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: SkyByteRadio.java,v 1.8 2009/03/09 17:14:35 fros4943 Exp $ * $Id: SkyByteRadio.java,v 1.9 2009/04/01 23:37:27 fros4943 Exp $
*/ */
package se.sics.cooja.mspmote.interfaces; package se.sics.cooja.mspmote.interfaces;
@ -193,7 +193,7 @@ public class SkyByteRadio extends Radio implements CustomDataRadio {
lastIncomingPacket = packet; lastIncomingPacket = packet;
/* TODO Receiving all bytes at the same time ok? */ /* TODO Receiving all bytes at the same time ok? */
byte[] packetData = CC2420RadioPacketConverter.fromCoojaToCC2420((COOJARadioPacket) packet); byte[] packetData = CC2420RadioPacketConverter.fromCoojaToCC2420(packet);
if (cc2420.getState() != CC2420.RadioState.RX_SFD_SEARCH) { if (cc2420.getState() != CC2420.RadioState.RX_SFD_SEARCH) {
/*logger.info("Radio is not currently active. Let's wait some...");*/ /*logger.info("Radio is not currently active. Let's wait some...");*/