for (Byte b : arr) {
data.addLast(b);
}
/* Feed incoming bytes to radio "slowly" via time events */
TimeEvent receiveCrosslevelDataEvent = new MspMoteTimeEvent(mote, 0) {
public void execute(long t) {
super.execute(t);
/* Stop receiving data when buffer is empty */
if (data.isEmpty()) {
return;
}
byte b = data.pop();
if (isInterfered) {
radioUSART.byteReceived(0xFF); /* Corrupted data */
} else {
radioUSART.byteReceived(b);
}
mote.requestImmediateWakeup();
mote.getSimulation().scheduleEvent(this, t + DELAY_BETWEEN_BYTES);
}
};
receiveCrosslevelDataEvent.execute(mote.getSimulation().getSimulationTime());
}