mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-22 10:30:13 +00:00
store current radio transmission bitrate in .csc
trigger radio event when device radio channel is changed
This commit is contained in:
parent
9929cc2a10
commit
ba39d98a86
@ -30,17 +30,8 @@
|
||||
|
||||
package se.sics.cooja.contikimote.interfaces;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
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.jdom.Element;
|
||||
@ -105,7 +96,7 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface, PolledA
|
||||
/**
|
||||
* Transmission bitrate (kbps).
|
||||
*/
|
||||
public final double RADIO_TRANSMISSION_RATE_kbps;
|
||||
private double RADIO_TRANSMISSION_RATE_kbps;
|
||||
|
||||
private RadioPacket packetToMote = null;
|
||||
|
||||
@ -125,6 +116,8 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface, PolledA
|
||||
|
||||
private int oldOutputPowerIndicator = -1;
|
||||
|
||||
private int oldRadioChannel = -1;
|
||||
|
||||
/**
|
||||
* Creates an interface to the radio at mote.
|
||||
*
|
||||
@ -294,6 +287,14 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface, PolledA
|
||||
this.notifyObservers();
|
||||
}
|
||||
|
||||
/* Check if radio channel changed */
|
||||
if (getChannel() != oldRadioChannel) {
|
||||
oldRadioChannel = getChannel();
|
||||
lastEvent = RadioEvent.UNKNOWN;
|
||||
this.setChanged();
|
||||
this.notifyObservers();
|
||||
}
|
||||
|
||||
/* Ongoing transmission */
|
||||
if (isTransmitting && now >= transmissionEndTime) {
|
||||
myMoteMemory.setIntValueOf("simOutSize", 0);
|
||||
@ -345,10 +346,26 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface, PolledA
|
||||
}
|
||||
|
||||
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() {
|
||||
|
Loading…
Reference in New Issue
Block a user