Skip to content

Commit

Permalink
Update interference status after channel hops and finished receptions
Browse files Browse the repository at this point in the history
  • Loading branch information
kkrentz committed Jan 14, 2024
1 parent fdb7091 commit 7241e57
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,9 @@ public void doActionsAfterTick() {
var currentChannel = getChannel();
if (currentChannel != oldRadioChannel) {
oldRadioChannel = currentChannel;
lastEvent = RadioEvent.UNKNOWN;
radioEventTriggers.trigger(RadioEvent.UNKNOWN, this);
isInterfered = false;
lastEvent = RadioEvent.CHANNEL_HOP;
radioEventTriggers.trigger(RadioEvent.CHANNEL_HOP, this);
}

/* Ongoing transmission */
Expand Down
2 changes: 1 addition & 1 deletion java/org/contikios/cooja/interfaces/Radio.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public abstract class Radio implements MoteInterface {
* Events that radios should notify observers about.
*/
public enum RadioEvent {
UNKNOWN, HW_OFF, HW_ON,
UNKNOWN, HW_OFF, HW_ON, CHANNEL_HOP,
RECEPTION_STARTED, RECEPTION_FINISHED, RECEPTION_INTERFERED,
TRANSMISSION_STARTED, TRANSMISSION_FINISHED,
PACKET_TRANSMITTED, CUSTOM_DATA_TRANSMITTED
Expand Down
14 changes: 12 additions & 2 deletions java/org/contikios/cooja/radiomediums/AbstractRadioMedium.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,19 @@ public AbstractRadioMedium(Simulation simulation) {
switch (event) {
case RECEPTION_STARTED:
case RECEPTION_INTERFERED:
case RECEPTION_FINISHED:
break;

case RECEPTION_FINISHED:
case CHANNEL_HOP: {
/* in such cases the radio reverts to "not interfered */
for (RadioConnection conn : getActiveConnections()) {
if (conn.isInterfered(radio)
&& (conn.getSource().getChannel() == radio.getChannel())) {
/* continue interfering due to transmission on radio's channel */
radio.interfereAnyReception();
}
}
}
break;
case UNKNOWN:
case HW_ON: {
updateSignalStrengths();
Expand Down

0 comments on commit 7241e57

Please sign in to comment.