set radio interfered even when it is turned off -> cca is set immediately when radio is turned on

This commit is contained in:
fros4943 2009-12-07 11:03:19 +00:00
parent 2f105e933a
commit 38e0b7918a

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: UDGM.java,v 1.28 2009/11/25 10:36:08 fros4943 Exp $ * $Id: UDGM.java,v 1.29 2009/12/07 11:03:19 fros4943 Exp $
*/ */
package se.sics.cooja.radiomediums; package se.sics.cooja.radiomediums;
@ -196,23 +196,27 @@ public class UDGM extends AbstractRadioMedium {
} }
/* Fail if radio is turned off */ /* Fail if radio is turned off */
if (!recv.isReceiverOn()) { // if (!recv.isReceiverOn()) {
/* Special case: allow connection if source is Contiki radio, // /* Special case: allow connection if source is Contiki radio,
* and destination is something else (byte radio). // * and destination is something else (byte radio).
* Allows cross-level communication with power-saving MACs. */ // * Allows cross-level communication with power-saving MACs. */
if (sender instanceof ContikiRadio && // if (sender instanceof ContikiRadio &&
!(recv instanceof ContikiRadio)) { // !(recv instanceof ContikiRadio)) {
/*logger.info("Special case: creating connection to turned off radio");*/ // /*logger.info("Special case: creating connection to turned off radio");*/
} else { // } else {
continue; // recv.interfereAnyReception();
} // continue;
} // }
// }
double distance = senderPos.getDistanceTo(recvPos); double distance = senderPos.getDistanceTo(recvPos);
if (distance <= moteTransmissionRange) { if (distance <= moteTransmissionRange) {
/* Within transmission range */ /* Within transmission range */
if (recv.isInterfered()) { if (!recv.isReceiverOn()) {
newConnection.addInterfered(recv);
recv.interfereAnyReception();
} else if (recv.isInterfered()) {
/* Was interfered: keep interfering */ /* Was interfered: keep interfering */
newConnection.addInterfered(recv); newConnection.addInterfered(recv);
} else if (recv.isTransmitting()) { } else if (recv.isTransmitting()) {
@ -225,11 +229,8 @@ public class UDGM extends AbstractRadioMedium {
/* Interfere receiver in all other active radio connections */ /* Interfere receiver in all other active radio connections */
for (RadioConnection conn : getActiveConnections()) { for (RadioConnection conn : getActiveConnections()) {
for (Radio dstRadio : conn.getDestinations()) { if (conn.isDestination(recv)) {
if (dstRadio == recv) {
conn.addInterfered(recv); conn.addInterfered(recv);
break;
}
} }
} }