Fix spacing, tag debug with ONVIF

pull/3750/head
Isaac Connor 2023-07-25 13:24:37 -04:00
parent 30c8052e60
commit c54a20ba70
1 changed files with 62 additions and 67 deletions

View File

@ -1035,7 +1035,7 @@ bool Monitor::connect() {
tev__PullMessages.Timeout = "PT20S"; tev__PullMessages.Timeout = "PT20S";
tev__PullMessages.MessageLimit = 10; tev__PullMessages.MessageLimit = 10;
std::string Termination_time = "PT60S"; std::string Termination_time = "PT60S";
wsnt__Renew.TerminationTime=&Termination_time; wsnt__Renew.TerminationTime = &Termination_time;
soap = soap_new(); soap = soap_new();
soap->connect_timeout = 0; soap->connect_timeout = 0;
soap->recv_timeout = 0; soap->recv_timeout = 0;
@ -1048,79 +1048,74 @@ bool Monitor::connect() {
std::string full_url = onvif_url + "/Events"; std::string full_url = onvif_url + "/Events";
proxyEvent.soap_endpoint = full_url.c_str(); proxyEvent.soap_endpoint = full_url.c_str();
set_credentials(soap); set_credentials(soap);
const char *RequestMessageID = soap_wsa_rand_uuid(soap); const char *RequestMessageID = soap_wsa_rand_uuid(soap);
if (soap_wsa_request(soap, RequestMessageID, proxyEvent.soap_endpoint , "CreatePullPointSubscriptionRequest") == SOAP_OK) if (soap_wsa_request(soap, RequestMessageID, proxyEvent.soap_endpoint , "CreatePullPointSubscriptionRequest") == SOAP_OK) {
{ Debug(1, "ONVIF Endpoint: %s", proxyEvent.soap_endpoint);
Debug(1, ":soap_wsa_request OK "); if (proxyEvent.CreatePullPointSubscription(&request, response) != SOAP_OK) {
Debug(1, "ONVIF Endpoint: %s", proxyEvent.soap_endpoint); const char *detail = soap_fault_detail(soap);
if (proxyEvent.CreatePullPointSubscription(&request, response) != SOAP_OK) { Error("ONVIF Couldn't create subscription! %s, %s", soap_fault_string(soap), detail ? detail : "null");
const char *detail = soap_fault_detail(soap); _wsnt__Unsubscribe wsnt__Unsubscribe;
Error("Couldn't create subscription! %s, %s", soap_fault_string(soap), detail ? detail : "null"); _wsnt__UnsubscribeResponse wsnt__UnsubscribeResponse;
_wsnt__Unsubscribe wsnt__Unsubscribe; proxyEvent.Unsubscribe(response.SubscriptionReference.Address, NULL, &wsnt__Unsubscribe, wsnt__UnsubscribeResponse);
_wsnt__UnsubscribeResponse wsnt__UnsubscribeResponse; soap_destroy(soap);
proxyEvent.Unsubscribe(response.SubscriptionReference.Address, NULL, &wsnt__Unsubscribe, wsnt__UnsubscribeResponse); soap_end(soap);
soap_destroy(soap); soap_free(soap);
soap_end(soap); soap = nullptr;
soap_free(soap); } else {
soap = nullptr; //Empty the stored messages
} else { set_credentials(soap);
//Empty the stored messages RequestMessageID = soap_wsa_rand_uuid(soap);
set_credentials(soap); if (soap_wsa_request(soap, RequestMessageID, response.SubscriptionReference.Address , "PullMessageRequest") == SOAP_OK) {
RequestMessageID = soap_wsa_rand_uuid(soap); Debug(1, "ONVIF :soap_wsa_request OK ");
if (soap_wsa_request(soap, RequestMessageID, response.SubscriptionReference.Address , "PullMessageRequest") == SOAP_OK) if ((proxyEvent.PullMessages(response.SubscriptionReference.Address, NULL, &tev__PullMessages, tev__PullMessagesResponse) != SOAP_OK) &&
{ (soap->error != SOAP_EOF)
Debug(1, ":soap_wsa_request OK "); ) { //SOAP_EOF could indicate no messages to pull.
if ((proxyEvent.PullMessages(response.SubscriptionReference.Address, NULL, &tev__PullMessages, tev__PullMessagesResponse) != SOAP_OK) && Error("Couldn't do initial event pull! Error %i %s, %s", soap->error, soap_fault_string(soap), soap_fault_detail(soap));
( soap->error != SOAP_EOF)) { //SOAP_EOF could indicate no messages to pull. Event_Poller_Healthy = FALSE;
Error("Couldn't do initial event pull! Error %i %s, %s", soap->error, soap_fault_string(soap), soap_fault_detail(soap)); } else {
Event_Poller_Healthy = FALSE; Debug(1, "Good Initial ONVIF Pull%i %s, %s", soap->error, soap_fault_string(soap), soap_fault_detail(soap));
} else { Event_Poller_Healthy = TRUE;
Debug(1, "Good Initial ONVIF Pull%i %s, %s", soap->error, soap_fault_string(soap), soap_fault_detail(soap)); }
Event_Poller_Healthy = TRUE; } else {
} Error("ONVIF Couldn't set wsa headers RequestMessageID= %s ; TO= %s ; Request= PullMessageRequest .... ! Error %i %s, %s",RequestMessageID , response.SubscriptionReference.Address , soap->error, soap_fault_string(soap), soap_fault_detail(soap));
} else { Event_Poller_Healthy = FALSE;
Error("Couldn't set wsa headers RequestMessageID= %s ; TO= %s ; Request= PullMessageRequest .... ! Error %i %s, %s",RequestMessageID , response.SubscriptionReference.Address , soap->error, soap_fault_string(soap), soap_fault_detail(soap)); }
Event_Poller_Healthy = FALSE;
}
// we renew the current subscription .........
//////////////////////////////////////////////////// set_credentials(soap);
// we renew the current subscription ......... RequestMessageID = soap_wsa_rand_uuid(soap);
if (soap_wsa_request(soap, RequestMessageID, response.SubscriptionReference.Address, "RenewRequest") == SOAP_OK) {
set_credentials(soap); Debug(1, "ONVIF :soap_wsa_request OK");
RequestMessageID = soap_wsa_rand_uuid(soap); if (proxyEvent.Renew(response.SubscriptionReference.Address, NULL, &wsnt__Renew, wsnt__RenewResponse) != SOAP_OK) {
if (soap_wsa_request(soap, RequestMessageID, response.SubscriptionReference.Address , "RenewRequest") == SOAP_OK) Error("ONVIF Couldn't do initial Renew ! Error %i %s, %s", soap->error, soap_fault_string(soap), soap_fault_detail(soap));
{ Event_Poller_Healthy = FALSE;
Debug(1, ":soap_wsa_request OK "); } else {
if (proxyEvent.Renew(response.SubscriptionReference.Address, NULL, &wsnt__Renew, wsnt__RenewResponse) != SOAP_OK) { Debug(1, "Good Initial ONVIF Renew %i %s, %s", soap->error, soap_fault_string(soap), soap_fault_detail(soap));
Error("Couldn't do initial Renew ! Error %i %s, %s", soap->error, soap_fault_string(soap), soap_fault_detail(soap)); Event_Poller_Healthy = TRUE;
Event_Poller_Healthy = FALSE; }
} else { } else {
Debug(1, "Good Initial ONVIF Renew %i %s, %s", soap->error, soap_fault_string(soap), soap_fault_detail(soap)); Error("ONVIF Couldn't set wsa headers RequestMessageID= %s ; TO= %s ; Request= RenewRequest .... ! Error %i %s, %s",
Event_Poller_Healthy = TRUE; RequestMessageID,
} response.SubscriptionReference.Address,
} else { soap->error,
Error("Couldn't set wsa headers RequestMessageID= %s ; TO= %s ; Request= RenewRequest .... ! Error %i %s, %s",RequestMessageID , response.SubscriptionReference.Address , soap->error, soap_fault_string(soap), soap_fault_detail(soap)); soap_fault_string(soap),
Event_Poller_Healthy = FALSE; soap_fault_detail(soap));
} Event_Poller_Healthy = FALSE;
////////////////////////////////////////////////////// }
}
} } else {
Error("ONVIF Couldn't set wsa headers RequestMessageID= %s ; TO= %s ; Request= CreatePullPointSubscriptionRequest .... ! Error %i %s, %s",RequestMessageID , proxyEvent.soap_endpoint , soap->error, soap_fault_string(soap), soap_fault_detail(soap));
} else { }
Error("Couldn't set wsa headers RequestMessageID= %s ; TO= %s ; Request= CreatePullPointSubscriptionRequest .... ! Error %i %s, %s",RequestMessageID , proxyEvent.soap_endpoint , soap->error, soap_fault_string(soap), soap_fault_detail(soap));
}
} else { } else {
Warning("You must specify the url to the onvif endpoint"); Warning("You must specify the url to the ONVIF endpoint");
} }
#else #else
Error("zmc not compiled with GSOAP. ONVIF support not built in!"); Error("zmc not compiled with GSOAP. ONVIF support not built in!");
#endif #endif
} // end if Armcrest of GSOAP } // end if Armcrest or GSOAP
} else { } else {
Debug(1, "Not Starting ONVIF"); Debug(1, "Not Starting ONVIF");
} } //End ONVIF Setup
//End ONVIF Setup
#if MOSQUITTOPP_FOUND #if MOSQUITTOPP_FOUND
if (mqtt_enabled) { if (mqtt_enabled) {