send empty packet if node reboots during transmission
This commit is contained in:
parent
bb4885abdc
commit
9b267036a4
@ -82,8 +82,8 @@ public class SkyByteRadio extends Radio implements CustomDataRadio {
|
|||||||
private RadioPacket lastOutgoingPacket = null;
|
private RadioPacket lastOutgoingPacket = null;
|
||||||
private RadioPacket lastIncomingPacket = null;
|
private RadioPacket lastIncomingPacket = null;
|
||||||
|
|
||||||
public SkyByteRadio(Mote mote) {
|
public SkyByteRadio(Mote m) {
|
||||||
this.mote = (MspMote)mote;
|
this.mote = (MspMote)m;
|
||||||
this.cc2420 = (CC2420) this.mote.getCPU().getChip(CC2420.class);
|
this.cc2420 = (CC2420) this.mote.getCPU().getChip(CC2420.class);
|
||||||
if (cc2420 == null) {
|
if (cc2420 == null) {
|
||||||
throw new IllegalStateException("Mote is not equipped with a CC2420");
|
throw new IllegalStateException("Mote is not equipped with a CC2420");
|
||||||
@ -98,6 +98,7 @@ public class SkyByteRadio extends Radio implements CustomDataRadio {
|
|||||||
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
||||||
lastEvent = RadioEvent.TRANSMISSION_STARTED;
|
lastEvent = RadioEvent.TRANSMISSION_STARTED;
|
||||||
isTransmitting = true;
|
isTransmitting = true;
|
||||||
|
len = 0;
|
||||||
/*logger.debug("----- SKY TRANSMISSION STARTED -----");*/
|
/*logger.debug("----- SKY TRANSMISSION STARTED -----");*/
|
||||||
setChanged();
|
setChanged();
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
@ -133,9 +134,6 @@ public class SkyByteRadio extends Radio implements CustomDataRadio {
|
|||||||
setChanged();
|
setChanged();
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
|
|
||||||
|
|
||||||
// System.out.println("## CC2420 Transmission finished...");
|
|
||||||
|
|
||||||
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
||||||
/*logger.debug("----- SKY TRANSMISSION FINISHED -----");*/
|
/*logger.debug("----- SKY TRANSMISSION FINISHED -----");*/
|
||||||
isTransmitting = false;
|
isTransmitting = false;
|
||||||
@ -150,36 +148,59 @@ public class SkyByteRadio extends Radio implements CustomDataRadio {
|
|||||||
cc2420.addOperatingModeListener(new OperatingModeListener() {
|
cc2420.addOperatingModeListener(new OperatingModeListener() {
|
||||||
public void modeChanged(Chip source, int mode) {
|
public void modeChanged(Chip source, int mode) {
|
||||||
if (isReceiverOn()) {
|
if (isReceiverOn()) {
|
||||||
|
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
||||||
lastEvent = RadioEvent.HW_ON;
|
lastEvent = RadioEvent.HW_ON;
|
||||||
|
setChanged();
|
||||||
|
notifyObservers();
|
||||||
} else {
|
} else {
|
||||||
/* Radio was turned off during transmission.
|
radioOff();
|
||||||
* May for example happen if watchdog triggers */
|
|
||||||
if (isTransmitting()) {
|
|
||||||
logger.fatal("Turning off radio while transmitting");
|
|
||||||
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
|
||||||
/*logger.debug("----- SKY TRANSMISSION FINISHED -----");*/
|
|
||||||
isTransmitting = false;
|
|
||||||
lastEvent = RadioEvent.TRANSMISSION_FINISHED;
|
|
||||||
setChanged();
|
|
||||||
notifyObservers();
|
|
||||||
}
|
|
||||||
lastEvent = RadioEvent.HW_OFF;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cc2420.setChannelListener(new CC2420.ChannelListener() {
|
||||||
|
public void changedChannel(int channel) {
|
||||||
|
/* XXX Currently assumes zero channel switch time */
|
||||||
|
lastEvent = RadioEvent.UNKNOWN;
|
||||||
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
||||||
setChanged();
|
setChanged();
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
cc2420.setChannelListener(new CC2420.ChannelListener() {
|
private void radioOff() {
|
||||||
public void changedChannel(int channel) {
|
/* Radio was turned off during transmission.
|
||||||
/* XXX Currently assumes zero channel switch time */
|
* May for example happen if watchdog triggers */
|
||||||
lastEvent = RadioEvent.UNKNOWN;
|
if (isTransmitting()) {
|
||||||
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
logger.warn("Turning off radio while transmitting, ending packet prematurely");
|
||||||
setChanged();
|
|
||||||
notifyObservers();
|
/* Simulate end of packet */
|
||||||
}
|
lastOutgoingPacket = new RadioPacket() {
|
||||||
});
|
public byte[] getPacketData() {
|
||||||
|
return new byte[0];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
||||||
|
lastEvent = RadioEvent.PACKET_TRANSMITTED;
|
||||||
|
/*logger.debug("----- SKY PACKET TRANSMITTED -----");*/
|
||||||
|
setChanged();
|
||||||
|
notifyObservers();
|
||||||
|
|
||||||
|
/* Register that transmission ended in radio medium */
|
||||||
|
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
||||||
|
/*logger.debug("----- SKY TRANSMISSION FINISHED -----");*/
|
||||||
|
isTransmitting = false;
|
||||||
|
lastEvent = RadioEvent.TRANSMISSION_FINISHED;
|
||||||
|
setChanged();
|
||||||
|
notifyObservers();
|
||||||
|
}
|
||||||
|
|
||||||
|
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
||||||
|
lastEvent = RadioEvent.HW_OFF;
|
||||||
|
setChanged();
|
||||||
|
notifyObservers();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Packet radio support */
|
/* Packet radio support */
|
||||||
|
Loading…
Reference in New Issue
Block a user