store current radio transmission bitrate in .csc

trigger radio event when device radio channel is changed
This commit is contained in:
Fredrik Osterlind 2013-08-14 13:56:39 +02:00
parent 9929cc2a10
commit ba39d98a86

View file

@ -30,17 +30,8 @@
package se.sics.cooja.contikimote.interfaces; package se.sics.cooja.contikimote.interfaces;
import java.awt.BorderLayout; import java.util.ArrayList;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection; import java.util.Collection;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.jdom.Element; import org.jdom.Element;
@ -105,7 +96,7 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface, PolledA
/** /**
* Transmission bitrate (kbps). * Transmission bitrate (kbps).
*/ */
public final double RADIO_TRANSMISSION_RATE_kbps; private double RADIO_TRANSMISSION_RATE_kbps;
private RadioPacket packetToMote = null; private RadioPacket packetToMote = null;
@ -125,6 +116,8 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface, PolledA
private int oldOutputPowerIndicator = -1; private int oldOutputPowerIndicator = -1;
private int oldRadioChannel = -1;
/** /**
* Creates an interface to the radio at mote. * Creates an interface to the radio at mote.
* *
@ -294,6 +287,14 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface, PolledA
this.notifyObservers(); this.notifyObservers();
} }
/* Check if radio channel changed */
if (getChannel() != oldRadioChannel) {
oldRadioChannel = getChannel();
lastEvent = RadioEvent.UNKNOWN;
this.setChanged();
this.notifyObservers();
}
/* Ongoing transmission */ /* Ongoing transmission */
if (isTransmitting && now >= transmissionEndTime) { if (isTransmitting && now >= transmissionEndTime) {
myMoteMemory.setIntValueOf("simOutSize", 0); myMoteMemory.setIntValueOf("simOutSize", 0);
@ -345,10 +346,26 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface, PolledA
} }
public Collection<Element> getConfigXML() { public Collection<Element> getConfigXML() {
return null; ArrayList<Element> config = new ArrayList<Element>();
Element element;
/* Radio bitrate */
element = new Element("bitrate");
element.setText("" + RADIO_TRANSMISSION_RATE_kbps);
config.add(element);
return config;
} }
public void setConfigXML(Collection<Element> configXML, boolean visAvailable) { public void setConfigXML(Collection<Element> configXML,
boolean visAvailable) {
for (Element element : configXML) {
if (element.getName().equals("bitrate")) {
RADIO_TRANSMISSION_RATE_kbps = Double.parseDouble(element.getText());
logger.info("Radio bitrate reconfigured to (kbps): " + RADIO_TRANSMISSION_RATE_kbps);
}
}
} }
public Mote getMote() { public Mote getMote() {