sky motes output the new converted radio packets
This commit is contained in:
parent
0a740aad63
commit
2ac3662ea8
|
@ -26,14 +26,15 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* 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;
|
||||
|
||||
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.
|
||||
|
@ -51,7 +52,7 @@ public class CC2420RadioPacketConverter {
|
|||
public static final boolean WITH_TIMESTAMP = 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];
|
||||
int pos = 0;
|
||||
byte packetData[] = packet.getPacketData();
|
||||
|
@ -132,9 +133,10 @@ public class CC2420RadioPacketConverter {
|
|||
return cc2420DataStripped;
|
||||
}
|
||||
|
||||
public static COOJARadioPacket fromCC2420ToCooja(byte[] data) {
|
||||
public static ConvertedRadioPacket fromCC2420ToCooja(byte[] data) {
|
||||
int pos = 0;
|
||||
int len; /* Payload */
|
||||
int originalLen;
|
||||
|
||||
/* Use some CC2420/MAC specific field such as X-MAC response */
|
||||
|
||||
|
@ -150,6 +152,7 @@ public class CC2420RadioPacketConverter {
|
|||
|
||||
/* 1 byte length */
|
||||
len = data[pos];
|
||||
originalLen = len;
|
||||
pos += 1;
|
||||
|
||||
/* (IGNORED) 4 byte X-MAC */
|
||||
|
@ -176,9 +179,11 @@ public class CC2420RadioPacketConverter {
|
|||
/*logger.info("Payload pos: " + pos);
|
||||
logger.info("Payload length: " + len);*/
|
||||
|
||||
byte coojaData[] = new byte[len];
|
||||
System.arraycopy(data, pos, coojaData, 0, len);
|
||||
return new COOJARadioPacket(coojaData);
|
||||
byte convertedData[] = new byte[len];
|
||||
System.arraycopy(data, pos, convertedData, 0, len);
|
||||
byte originalData[] = new byte[originalLen];
|
||||
System.arraycopy(data, 0, originalData, 0, originalLen);
|
||||
return new ConvertedRadioPacket(convertedData, originalData);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* 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;
|
||||
|
@ -193,7 +193,7 @@ public class SkyByteRadio extends Radio implements CustomDataRadio {
|
|||
lastIncomingPacket = packet;
|
||||
|
||||
/* 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) {
|
||||
/*logger.info("Radio is not currently active. Let's wait some...");*/
|
||||
|
|
Loading…
Reference in a new issue