/* Mote IP address */
if (mote.getInterfaces().getIPAddress() == null) {
throw new RuntimeException("No IP address interface found (need IP address)");
}
moteIP = mote.getInterfaces().getIPAddress().getIPString();
mote.getInterfaces().getIPAddress().addObserver(new Observer() {
public void update(Observable obs, Object obj) {
moteIP = NativeIPGateway.this.mote.getInterfaces().getIPAddress().getIPString();
try {
if (captor != null) {
String[] ipSplit = moteIP.split("\\.");
String filter = "ip and dst net " + ipSplit[0] + "." + ipSplit[1];
if (autoRegisterRoutes.isSelected()) {
updateNativeRoute();
}
captor.setFilter(filter, true);
if (ipLabel != null) {
ipLabel.setText(moteIP);
}
}
} catch (IOException e) {
logger.fatal("Error when updating native route: " + e.getMessage(), e);
}
}
});
/* Observe serial port for outgoing IP packets */
serialPort.addSerialDataObserver(new Observer() {
public void update(Observable obs, Object obj) {
readSlipAccumulated(serialPort.getLastSerialData());
}
});