use of de.janrufmonitor.fritzbox.firmware.exception.FritzBoxDetectFirmwareException in project janrufmonitor by tbrandt77.
the class UnitymediaFirmware method detectFritzBoxFirmware.
private FirmwareData detectFritzBoxFirmware() throws FritzBoxDetectFirmwareException {
StringBuffer data = new StringBuffer();
String urlstr = getProtocol() + this.m_address + ":" + this.m_port + "/home/pp_fbos.lua?sid=" + this.m_sid;
boolean detected = false;
try {
data.append(this.executeURL(urlstr, null, true).trim());
} catch (UnsupportedEncodingException e) {
this.m_logger.log(Level.WARNING, e.getMessage(), e);
} catch (IOException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
throw new FritzBoxDetectFirmwareException("Could not detect fritzbox firmware: " + e.getMessage());
}
Pattern p = Pattern.compile(PATTERN_DETECT_LANGUAGE);
Matcher m = p.matcher(data);
if (m.find()) {
this.m_language = "de";
detected = true;
}
if (!detected)
throw new FritzBoxDetectFirmwareException("Unable to detect FritzBox firmware.");
this.m_logger.info("Using firmware detection pattern: " + PATTERN_DETECT_FIRMWARE);
p = Pattern.compile(PATTERN_DETECT_FIRMWARE);
m = p.matcher(data);
if (m.find()) {
FirmwareData fwd = new FirmwareData(m.group(1), m.group(2), m.group(3), m.group(4).trim());
if (fwd.getMajor() >= 5 && fwd.getMinor() < 50)
return fwd;
}
throw new FritzBoxDetectFirmwareException("Could not detect FRITZ!Box firmware version.");
}
use of de.janrufmonitor.fritzbox.firmware.exception.FritzBoxDetectFirmwareException in project janrufmonitor by tbrandt77.
the class UnitymediaFirmware method init.
public void init() throws FritzBoxInitializationException, FritzBoxNotFoundException, InvalidSessionIDException {
try {
this.createSessionID();
this.m_firmware = this.detectFritzBoxFirmware();
} catch (CreateSessionIDException e) {
throw new FritzBoxInitializationException("FritzBox initialization failed: " + e.getMessage());
} catch (FritzBoxDetectFirmwareException e) {
throw new FritzBoxInitializationException("FritzBox initialization failed: " + e.getMessage());
}
}
Aggregations