private String user = "";
private String password = "";
private int onvifPort = 80;
- private String deviceXAddr = "/onvif/device_service";
- private String eventXAddr = "/onvif/device_service";
- private String mediaXAddr = "/onvif/device_service";
+ private String deviceXAddr = "http://" + ipAddress + "/onvif/device_service";
+ private String eventXAddr = "http://" + ipAddress + "/onvif/device_service";
+ private String mediaXAddr = "http://" + ipAddress + "/onvif/device_service";
@SuppressWarnings("unused")
- private String imagingXAddr = "/onvif/device_service";
- private String ptzXAddr = "/onvif/ptz_service";
- private String subscriptionXAddr = "/onvif/device_service";
+ private String imagingXAddr = "http://" + ipAddress + "/onvif/device_service";
+ private String ptzXAddr = "http://" + ipAddress + "/onvif/ptz_service";
+ private String subscriptionXAddr = "http://" + ipAddress + "/onvif/device_service";
private boolean isConnected = false;
private int mediaProfileIndex = 0;
private String snapshotUri = "";
} else if (message.contains("GetEventPropertiesResponse")) {
sendOnvifRequest(requestBuilder(RequestType.CreatePullPointSubscription, eventXAddr));
} else if (message.contains("CreatePullPointSubscriptionResponse")) {
- subscriptionXAddr = removeIPfromUrl(Helper.fetchXML(message, "SubscriptionReference>", "Address>"));
+ subscriptionXAddr = Helper.fetchXML(message, "SubscriptionReference>", "Address>");
logger.debug("subscriptionXAddr={}", subscriptionXAddr);
sendOnvifRequest(requestBuilder(RequestType.PullMessages, subscriptionXAddr));
} else if (message.contains("GetStatusResponse")) {
String getXmlCache = getXml(requestType);
if (requestType.equals(RequestType.CreatePullPointSubscription) || requestType.equals(RequestType.PullMessages)
|| requestType.equals(RequestType.Renew) || requestType.equals(RequestType.Unsubscribe)) {
- headerTo = "<a:To s:mustUnderstand=\"1\">http://" + ipAddress + xAddr + "</a:To>";
+ headerTo = "<a:To s:mustUnderstand=\"1\">" + xAddr + "</a:To>";
extraEnvelope = " xmlns:a=\"http://www.w3.org/2005/08/addressing\"";
}
String headers;
} else {// GetSystemDateAndTime must not be password protected as per spec.
headers = "";
}
- FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, new HttpMethod("POST"), xAddr);
+ FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, new HttpMethod("POST"),
+ removeIPfromUrl(xAddr));
String actionString = Helper.fetchXML(getXmlCache, requestType.toString(), "xmlns=\"");
request.headers().add("Content-Type",
"application/soap+xml; charset=utf-8; action=\"" + actionString + "/" + requestType + "\"");
request.headers().add("Charset", "utf-8");
- if (onvifPort != 80) {
- request.headers().set("Host", ipAddress + ":" + onvifPort);
- } else {
- request.headers().set("Host", ipAddress);
- }
+ request.headers().set("Host", extractIPportFromUrl(xAddr));
request.headers().set("Connection", HttpHeaderValues.CLOSE);
request.headers().set("Accept-Encoding", "gzip, deflate");
String fullXml = "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"" + extraEnvelope + ">"
return url.substring(index);
}
+ String extractIPportFromUrl(String url) {
+ int startIndex = url.indexOf("//") + 2;
+ int endIndex = url.indexOf("/", startIndex);// skip past any :port to the slash /
+ if (startIndex != -1 && endIndex != -1) {
+ return url.substring(startIndex, endIndex);
+ }
+ logger.debug("We hit an issue extracting IP:PORT from url:{}", url);
+ return "";
+ }
+
void parseXAddr(String message) {
// Normally I would search '<tt:XAddr>' instead but Foscam needed this work around.
- String temp = removeIPfromUrl(Helper.fetchXML(message, "<tt:Device", "tt:XAddr"));
+ String temp = Helper.fetchXML(message, "<tt:Device", "tt:XAddr");
if (!temp.isEmpty()) {
deviceXAddr = temp;
logger.debug("deviceXAddr:{}", deviceXAddr);
}
- temp = removeIPfromUrl(Helper.fetchXML(message, "<tt:Events", "tt:XAddr"));
+ temp = Helper.fetchXML(message, "<tt:Events", "tt:XAddr");
if (!temp.isEmpty()) {
subscriptionXAddr = eventXAddr = temp;
logger.debug("eventsXAddr:{}", eventXAddr);
}
- temp = removeIPfromUrl(Helper.fetchXML(message, "<tt:Media", "tt:XAddr"));
+ temp = Helper.fetchXML(message, "<tt:Media", "tt:XAddr");
if (!temp.isEmpty()) {
mediaXAddr = temp;
logger.debug("mediaXAddr:{}", mediaXAddr);
}
- ptzXAddr = removeIPfromUrl(Helper.fetchXML(message, "<tt:PTZ", "tt:XAddr"));
+ ptzXAddr = Helper.fetchXML(message, "<tt:PTZ", "tt:XAddr");
if (ptzXAddr.isEmpty()) {
ptzDevice = false;
logger.trace("Camera must not support PTZ, it failed to give a <tt:PTZ><tt:XAddr>:{}", message);
<channel id="mp4History" typeId="mp4History"/>
<channel id="mp4HistoryLength" typeId="mp4HistoryLength"/>
<channel id="lastMotionType" typeId="lastMotionType"/>
+ <channel id="lastEventData" typeId="lastEventData"/>
<channel id="ffmpegMotionControl" typeId="ffmpegMotionControl"/>
<channel id="ffmpegMotionAlarm" typeId="ffmpegMotionAlarm"/>
<channel id="enableMotionAlarm" typeId="enableMotionAlarm"/>
<channel id="mp4History" typeId="mp4History"/>
<channel id="mp4HistoryLength" typeId="mp4HistoryLength"/>
<channel id="lastMotionType" typeId="lastMotionType"/>
+ <channel id="lastEventData" typeId="lastEventData"/>
<channel id="ffmpegMotionControl" typeId="ffmpegMotionControl"/>
<channel id="ffmpegMotionAlarm" typeId="ffmpegMotionAlarm"/>
<channel id="enableMotionAlarm" typeId="enableMotionAlarm"/>
<state readOnly="true"/>
</channel-type>
+ <channel-type id="lastEventData" advanced="true">
+ <item-type>String</item-type>
+ <label>Last Event Data</label>
+ <description>A string that contains detailed data on the last alarm that was triggered.</description>
+ <state readOnly="true"/>
+ </channel-type>
+
<channel-type id="motionAlarm">
<item-type>Switch</item-type>
<label>Motion Alarm</label>