added new mote type method that returns the by default used mote interfaces, as opposed to all compatible mote
interfaces this allows a user to override default settings in the create-new-mote-type dialogs
This commit is contained in:
parent
8e264badb7
commit
9929cc2a10
|
@ -32,16 +32,17 @@ package se.sics.cooja.avrmote.interfaces;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import se.sics.cooja.ClassDescription;
|
||||||
|
import se.sics.cooja.Mote;
|
||||||
|
import se.sics.cooja.avrmote.MicaZMote;
|
||||||
|
import se.sics.cooja.emulatedmote.Radio802154;
|
||||||
|
import se.sics.cooja.interfaces.CustomDataRadio;
|
||||||
import avrora.sim.FiniteStateMachine;
|
import avrora.sim.FiniteStateMachine;
|
||||||
import avrora.sim.FiniteStateMachine.Probe;
|
import avrora.sim.FiniteStateMachine.Probe;
|
||||||
import avrora.sim.platform.MicaZ;
|
import avrora.sim.platform.MicaZ;
|
||||||
import avrora.sim.radio.CC2420Radio;
|
import avrora.sim.radio.CC2420Radio;
|
||||||
import avrora.sim.radio.Medium;
|
import avrora.sim.radio.Medium;
|
||||||
|
|
||||||
import se.sics.cooja.*;
|
|
||||||
import se.sics.cooja.avrmote.MicaZMote;
|
|
||||||
import se.sics.cooja.emulatedmote.Radio802154;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CC2420 to COOJA wrapper.
|
* CC2420 to COOJA wrapper.
|
||||||
*
|
*
|
||||||
|
@ -152,4 +153,11 @@ public class MicaZRadio extends Radio802154 {
|
||||||
//System.out.println("MicaZ: Received: " + (b &0xff));
|
//System.out.println("MicaZ: Received: " + (b &0xff));
|
||||||
recv.nextByte(true, (byte)b);
|
recv.nextByte(true, (byte)b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canReceiveFrom(CustomDataRadio radio) {
|
||||||
|
if (radio.getClass().equals(this.getClass())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -423,4 +423,11 @@ public class Msp802154Radio extends Radio implements CustomDataRadio {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canReceiveFrom(CustomDataRadio radio) {
|
||||||
|
if (radio.getClass().equals(this.getClass())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -357,4 +357,12 @@ public class TR1001Radio extends Radio implements USARTListener, CustomDataRadio
|
||||||
/* TODO Implement me */
|
/* TODO Implement me */
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canReceiveFrom(CustomDataRadio radio) {
|
||||||
|
if (radio.getClass().equals(this.getClass())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@ package se.sics.cooja.interfaces;
|
||||||
*/
|
*/
|
||||||
public interface CustomDataRadio {
|
public interface CustomDataRadio {
|
||||||
|
|
||||||
|
public boolean canReceiveFrom(CustomDataRadio radio);
|
||||||
|
|
||||||
public void receiveCustomData(Object data);
|
public void receiveCustomData(Object data);
|
||||||
|
|
||||||
public Object getLastCustomDataTransmitted();
|
public Object getLastCustomDataTransmitted();
|
||||||
|
|
|
@ -341,8 +341,8 @@ public abstract class AbstractRadioMedium extends RadioMedium {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Radio dstRadio : connection.getAllDestinations()) {
|
for (Radio dstRadio : connection.getAllDestinations()) {
|
||||||
|
if (!(dstRadio instanceof CustomDataRadio) ||
|
||||||
if (!radio.getClass().equals(dstRadio.getClass()) || !(radio instanceof CustomDataRadio)) {
|
!((CustomDataRadio) dstRadio).canReceiveFrom((CustomDataRadio)radio)) {
|
||||||
/* Radios communicate via radio packets */
|
/* Radios communicate via radio packets */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -383,11 +383,14 @@ public abstract class AbstractRadioMedium extends RadioMedium {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Radio dstRadio : connection.getAllDestinations()) {
|
for (Radio dstRadio : connection.getAllDestinations()) {
|
||||||
|
|
||||||
if (radio.getClass().equals(dstRadio.getClass()) && radio instanceof CustomDataRadio) {
|
if ((radio instanceof CustomDataRadio) &&
|
||||||
/* Radios instead communicate via custom data objects */
|
(dstRadio instanceof CustomDataRadio) &&
|
||||||
continue;
|
((CustomDataRadio) dstRadio).canReceiveFrom((CustomDataRadio)radio)) {
|
||||||
}
|
/* Radios instead communicate via custom data objects */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Forward radio packet */
|
/* Forward radio packet */
|
||||||
if (connection.getDestinationDelay(dstRadio) == 0) {
|
if (connection.getDestinationDelay(dstRadio) == 0) {
|
||||||
|
|
Loading…
Reference in a new issue