diff --git a/Projects/la_mojo/build b/Projects/la_mojo/build
index 8c1e4e77..5181f2f3 100755
--- a/Projects/la_mojo/build
+++ b/Projects/la_mojo/build
@@ -7,7 +7,7 @@
#make clean -e "CFG=LRF_Proxy_ONLY"
#make -e "CFG=LRF_Proxy_ONLY" -j$(nproc)
-make clean -e "CFG=Debug86"
+#make clean -e "CFG=Debug86"
make -e "CFG=Debug86" -j$(nproc)
#cd Debug86
#strip ./mojo_d
diff --git a/Projects/la_mojo/la_mojo.vpj b/Projects/la_mojo/la_mojo.vpj
index 879aeaef..daf2ef56 100644
--- a/Projects/la_mojo/la_mojo.vpj
+++ b/Projects/la_mojo/la_mojo.vpj
@@ -261,7 +261,7 @@
SaveOption="SaveCurrent"
RunFromDir="%rw">
-
+
+
@@ -746,6 +747,7 @@
+
diff --git a/Projects/la_mojo/makefile b/Projects/la_mojo/makefile
index 20fa4417..e98427a7 100644
--- a/Projects/la_mojo/makefile
+++ b/Projects/la_mojo/makefile
@@ -57,9 +57,10 @@ COMMON_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \
$(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \
$(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \
$(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \
- $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \
- $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \
- $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \
+ $(OUTDIR)/kernelModuleAttentionCloud.o $(OUTDIR)/kernelModuleBosch.o \
+ $(OUTDIR)/kernelModuleEmbedVideo.o $(OUTDIR)/kernelModuleFactory.o \
+ $(OUTDIR)/kernelModuleFlyHunter.o $(OUTDIR)/kernelModuleKafka.o \
+ $(OUTDIR)/kernelModuleModemManager.o \
$(OUTDIR)/kernelModuleOnvifObserver.o \
$(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \
$(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \
@@ -112,9 +113,10 @@ ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \
$(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \
$(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \
$(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \
- $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \
- $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \
- $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \
+ $(OUTDIR)/kernelModuleAttentionCloud.o $(OUTDIR)/kernelModuleBosch.o \
+ $(OUTDIR)/kernelModuleEmbedVideo.o $(OUTDIR)/kernelModuleFactory.o \
+ $(OUTDIR)/kernelModuleFlyHunter.o $(OUTDIR)/kernelModuleKafka.o \
+ $(OUTDIR)/kernelModuleModemManager.o \
$(OUTDIR)/kernelModuleOnvifObserver.o \
$(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \
$(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \
@@ -261,9 +263,10 @@ COMMON_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \
$(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \
$(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \
$(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \
- $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \
- $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \
- $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \
+ $(OUTDIR)/kernelModuleAttentionCloud.o $(OUTDIR)/kernelModuleBosch.o \
+ $(OUTDIR)/kernelModuleEmbedVideo.o $(OUTDIR)/kernelModuleFactory.o \
+ $(OUTDIR)/kernelModuleFlyHunter.o $(OUTDIR)/kernelModuleKafka.o \
+ $(OUTDIR)/kernelModuleModemManager.o \
$(OUTDIR)/kernelModuleOnvifObserver.o \
$(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \
$(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \
@@ -316,9 +319,10 @@ ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \
$(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \
$(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \
$(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \
- $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \
- $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \
- $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \
+ $(OUTDIR)/kernelModuleAttentionCloud.o $(OUTDIR)/kernelModuleBosch.o \
+ $(OUTDIR)/kernelModuleEmbedVideo.o $(OUTDIR)/kernelModuleFactory.o \
+ $(OUTDIR)/kernelModuleFlyHunter.o $(OUTDIR)/kernelModuleKafka.o \
+ $(OUTDIR)/kernelModuleModemManager.o \
$(OUTDIR)/kernelModuleOnvifObserver.o \
$(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \
$(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \
@@ -465,9 +469,10 @@ COMMON_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \
$(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \
$(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \
$(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \
- $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \
- $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \
- $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \
+ $(OUTDIR)/kernelModuleAttentionCloud.o $(OUTDIR)/kernelModuleBosch.o \
+ $(OUTDIR)/kernelModuleEmbedVideo.o $(OUTDIR)/kernelModuleFactory.o \
+ $(OUTDIR)/kernelModuleFlyHunter.o $(OUTDIR)/kernelModuleKafka.o \
+ $(OUTDIR)/kernelModuleModemManager.o \
$(OUTDIR)/kernelModuleOnvifObserver.o \
$(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \
$(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \
@@ -520,9 +525,10 @@ ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \
$(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \
$(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \
$(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \
- $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \
- $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \
- $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \
+ $(OUTDIR)/kernelModuleAttentionCloud.o $(OUTDIR)/kernelModuleBosch.o \
+ $(OUTDIR)/kernelModuleEmbedVideo.o $(OUTDIR)/kernelModuleFactory.o \
+ $(OUTDIR)/kernelModuleFlyHunter.o $(OUTDIR)/kernelModuleKafka.o \
+ $(OUTDIR)/kernelModuleModemManager.o \
$(OUTDIR)/kernelModuleOnvifObserver.o \
$(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \
$(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \
@@ -551,8 +557,8 @@ ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \
opencv4 rdkafka++` -lliveMedia -lgroupsock -lBasicUsageEnvironment \
-lUsageEnvironment -ldarknet
-COMPILE=g++ -c -x c++ "-DDEBUG" "-DMEKOROT_PROJECT_" "-D__STDC_CONSTANT_MACROS" "-D_CLIENT_APPLICATION_" "-D_OPENCV_" -O0 -g3 -ggdb -p -pg -Wall -pedantic -W -std=c++17 -Wno-write-strings -I../../lib/include `pkg-config opencv4 libavcodec libavdevice libavfilter libavformat libavutil libpostproc libswresample libswscale live555 --cflags` -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $<
-LINK=g++ -O0 -g3 -ggdb -p -pg -Wall -pedantic -o "$(OUTFILE)" $(ALL_OBJ)
+COMPILE=g++ -c -x c++ "-DDEBUG" "-DMEKOROT_PROJECT_" "-D__STDC_CONSTANT_MACROS" "-D_CLIENT_APPLICATION_" "-D_OPENCV_" -O0 -Wall -pedantic -W -std=c++17 -Wno-write-strings -I../../lib/include `pkg-config opencv4 libavcodec libavdevice libavfilter libavformat libavutil libpostproc libswresample libswscale live555 --cflags` -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $<
+LINK=g++ -O0 -Wall -pedantic -o "$(OUTFILE)" $(ALL_OBJ)
# Pattern rules
$(OUTDIR)/%.o : ../../lib/components/object/%.cpp
@@ -674,9 +680,10 @@ COMMON_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \
$(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \
$(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \
$(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \
- $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \
- $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \
- $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \
+ $(OUTDIR)/kernelModuleAttentionCloud.o $(OUTDIR)/kernelModuleBosch.o \
+ $(OUTDIR)/kernelModuleEmbedVideo.o $(OUTDIR)/kernelModuleFactory.o \
+ $(OUTDIR)/kernelModuleFlyHunter.o $(OUTDIR)/kernelModuleKafka.o \
+ $(OUTDIR)/kernelModuleModemManager.o \
$(OUTDIR)/kernelModuleOnvifObserver.o \
$(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \
$(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \
@@ -729,9 +736,10 @@ ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \
$(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \
$(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \
$(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \
- $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \
- $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \
- $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \
+ $(OUTDIR)/kernelModuleAttentionCloud.o $(OUTDIR)/kernelModuleBosch.o \
+ $(OUTDIR)/kernelModuleEmbedVideo.o $(OUTDIR)/kernelModuleFactory.o \
+ $(OUTDIR)/kernelModuleFlyHunter.o $(OUTDIR)/kernelModuleKafka.o \
+ $(OUTDIR)/kernelModuleModemManager.o \
$(OUTDIR)/kernelModuleOnvifObserver.o \
$(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \
$(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \
@@ -880,9 +888,10 @@ COMMON_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \
$(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \
$(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \
$(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \
- $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \
- $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \
- $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \
+ $(OUTDIR)/kernelModuleAttentionCloud.o $(OUTDIR)/kernelModuleBosch.o \
+ $(OUTDIR)/kernelModuleEmbedVideo.o $(OUTDIR)/kernelModuleFactory.o \
+ $(OUTDIR)/kernelModuleFlyHunter.o $(OUTDIR)/kernelModuleKafka.o \
+ $(OUTDIR)/kernelModuleModemManager.o \
$(OUTDIR)/kernelModuleOnvifObserver.o \
$(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \
$(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \
@@ -935,9 +944,10 @@ ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \
$(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \
$(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \
$(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \
- $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \
- $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \
- $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \
+ $(OUTDIR)/kernelModuleAttentionCloud.o $(OUTDIR)/kernelModuleBosch.o \
+ $(OUTDIR)/kernelModuleEmbedVideo.o $(OUTDIR)/kernelModuleFactory.o \
+ $(OUTDIR)/kernelModuleFlyHunter.o $(OUTDIR)/kernelModuleKafka.o \
+ $(OUTDIR)/kernelModuleModemManager.o \
$(OUTDIR)/kernelModuleOnvifObserver.o \
$(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \
$(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \
@@ -1100,9 +1110,10 @@ $(OUTDIR)/kernelEventFilterAPF.o: ../../lib/App/common/kernelEventFilterAPF.cpp
$(OUTDIR)/kernelEventFilterBubble.o: ../../lib/App/common/kernelEventFilterBubble.cpp ../../lib/App/common/kernelEventFilterBubble.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/App/common/kernelEventFilter.h ../../lib/App/common/kernelPrototype.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicPosition.h ../../lib/components/base/basicTypes.h ../../lib/alg/generic/Transform.h ../../lib/components/object/objectSystemAnchor.h
$(OUTDIR)/kernelEventFilterTrain.o: ../../lib/App/common/kernelEventFilterTrain.cpp ../../lib/App/common/kernelEventFilterTrain.h ../../lib/components/base/basicFunctionality.h ../../lib/components/base/basicBuildTimeStamp.h ../../lib/components/base/basicTypes.h ../../lib/App/common/deviceNodeFactory.h
$(OUTDIR)/kernelModule.o: ../../lib/App/common/kernelModule.cpp ../../lib/App/common/kernelModule.h ../../lib/App/common/MySQL_dataBinder.h ../../lib/App/common/SQLite_dataBinder.h
+$(OUTDIR)/kernelModuleAttentionCloud.o: ../../lib/App/common/kernelModuleAttentionCloud.cpp ../../lib/App/common/kernelModuleAttentionCloud.h ../../lib/App/common/kernelModule.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicEventHeap.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicPosition.h ../../lib/components/base/basicTypes.h ../../lib/alg/generic/Transform.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/App/common/deviceNodeFactory.h ../../lib/App/common/deviceNodeCamera.h
$(OUTDIR)/kernelModuleBosch.o: ../../lib/App/common/kernelModuleBosch.cpp ../../lib/App/common/kernelModuleBosch.h
$(OUTDIR)/kernelModuleEmbedVideo.o: ../../lib/App/common/kernelModuleEmbedVideo.cpp ../../lib/App/common/kernelModuleEmbedVideo.h ../../lib/App/common/deviceNodeCamera.h ../../lib/App/common/deviceNodeFactory.h
-$(OUTDIR)/kernelModuleFactory.o: ../../lib/App/common/kernelModuleFactory.cpp ../../lib/App/common/kernelModuleFactory.h ../../lib/App/common/kernelModuleEmbedVideo.h ../../lib/App/common/kernelModuleFlyHunter.h ../../lib/App/common/kernelModuleKafka.h ../../lib/App/common/kernelModuleModemManager.h ../../lib/App/common/kernelModuleOnvifObserver.h ../../lib/App/common/kernelModuleSSDP.h ../../lib/App/common/kernelModuleUSBRelay.h ../../lib/App/common/kernelModuleBosch.h ../../lib/App/common/MySQL_dataBinder.h ../../lib/App/common/SQLite_dataBinder.h
+$(OUTDIR)/kernelModuleFactory.o: ../../lib/App/common/kernelModuleFactory.cpp ../../lib/App/common/kernelModuleFactory.h ../../lib/App/common/kernelModuleEmbedVideo.h ../../lib/App/common/kernelModuleFlyHunter.h ../../lib/App/common/kernelModuleKafka.h ../../lib/App/common/kernelModuleModemManager.h ../../lib/App/common/kernelModuleOnvifObserver.h ../../lib/App/common/kernelModuleSSDP.h ../../lib/App/common/kernelModuleUSBRelay.h ../../lib/App/common/kernelModuleBosch.h ../../lib/App/common/kernelModuleAttentionCloud.h ../../lib/App/common/kernelModule.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicEventHeap.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicPosition.h ../../lib/components/base/basicTypes.h ../../lib/alg/generic/Transform.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/App/common/MySQL_dataBinder.h ../../lib/App/common/SQLite_dataBinder.h
$(OUTDIR)/kernelModuleFlyHunter.o: ../../lib/App/common/kernelModuleFlyHunter.cpp ../../lib/App/common/kernelModuleFlyHunter.h
$(OUTDIR)/kernelModuleKafka.o: ../../lib/App/common/kernelModuleKafka.cpp ../../lib/App/common/kernelModuleKafka.h
$(OUTDIR)/kernelModuleModemManager.o: ../../lib/App/common/kernelModuleModemManager.cpp ../../lib/App/common/kernelModuleModemManager.h ../../lib/components/base/basicFunctionality.h ../../lib/components/base/basicBuildTimeStamp.h ../../lib/components/base/basicTypes.h
diff --git a/Projects/la_serva/make_c_bin.php b/Projects/la_serva/make_c_bin.php
new file mode 100644
index 00000000..ab89d6cd
--- /dev/null
+++ b/Projects/la_serva/make_c_bin.php
@@ -0,0 +1,42 @@
+
\ No newline at end of file
diff --git a/lib/App/common/SQLite_dataBinder.cpp b/lib/App/common/SQLite_dataBinder.cpp
index 99e2fe8f..2a243309 100644
--- a/lib/App/common/SQLite_dataBinder.cpp
+++ b/lib/App/common/SQLite_dataBinder.cpp
@@ -5084,6 +5084,132 @@ bool sqliteDBC::getAppDebugMode()
return rVal;
}
+DBC_ATC_MODULE_DATA * sqliteDBC::getAttentionModuleData( uint32_t id ){
+ DBC_ATC_MODULE_DATA * tVal = NULL;
+ if (m_bStoIsConnected)
+ {
+ char tQBuf[CTEXT];
+ AAssoc * result;
+ sprintf(tQBuf, "SELECT * FROM `module_attention` WHERE `id`=%d", id);
+#ifdef DEBUG_ALL
+ LOG(tQBuf);
+#endif
+ result = m_pDataStorage->Query(tQBuf);
+ if (result != NULL)
+ {
+ if (result->size() > 0)
+ {
+ Assoc * cArr;
+ tVal = (DBC_ATC_MODULE_DATA *) malloc(sizeof(DBC_ATC_MODULE_DATA));
+ if (tVal != NULL)
+ {
+ memset(tVal, 0, sizeof(DBC_ATC_MODULE_DATA));
+ ;
+ Assoc::iterator it;
+ cArr = result->at(0);
+ it = cArr->find("rest");
+ if (it != cArr->end())
+ {
+ tVal->rest_time = atoi(it->second.c_str());
+ };
+ it = cArr->find("persist");
+ if (it != cArr->end())
+ {
+ tVal->persist_time = atoi(it->second.c_str());
+ };
+ it = cArr->find("range");
+ if (it != cArr->end())
+ {
+ tVal->attention_zone_range = atof(it->second.c_str());
+ };
+ };
+ };
+ };
+ deleteResult(result);
+ };
+ return tVal;
+}
+
+REST_SETTINGS *sqliteDBC::getBoschData( uint32_t id ){
+ REST_SETTINGS * tVal = NULL;
+ if (m_bStoIsConnected){
+ char tQBuf[CTEXT];
+ AAssoc * result;
+ sprintf(tQBuf, "SELECT * FROM `module_bvms` WHERE `id`=%d", id);
+#ifdef DEBUG_ALL
+ LOG(tQBuf);
+#endif
+ result = m_pDataStorage->Query(tQBuf);
+ if (result != NULL)
+ {
+ if (result->size() > 0)
+ {
+ Assoc * cArr;
+ tVal = (REST_SETTINGS *) malloc(sizeof(REST_SETTINGS));
+ if (tVal != NULL)
+ {
+ memset(tVal, 0, sizeof(REST_SETTINGS));
+ ;
+ Assoc::iterator it;
+ cArr = result->at(0);
+ it = cArr->find("ip");
+ if (it != cArr->end())
+ {
+ strncpy(tVal->server_ip, it->second.c_str(), 48);
+ };
+ it = cArr->find("port");
+ if (it != cArr->end())
+ {
+ tVal->port = atoi(it->second.c_str());
+ };
+ it = cArr->find("api_uri");
+ if (it != cArr->end())
+ {
+ strncpy(tVal->rest_api, it->second.c_str(), 256);
+ };
+ it = cArr->find("auth_mode");
+ if (it != cArr->end())
+ {
+ tVal->auth_mode = atoi(it->second.c_str());
+ };
+ it = cArr->find("access_user");
+ if (it != cArr->end())
+ {
+ strncpy(tVal->access_user, it->second.c_str(), 48);
+ };
+ it = cArr->find("access_pass");
+ if (it != cArr->end())
+ {
+ strncpy(tVal->access_pass, it->second.c_str(), 48);
+ };
+ it = cArr->find("detection_evt_ena");
+ if (it != cArr->end())
+ {
+ tVal->detection_enabled = (bool) atoi(it->second.c_str());
+ };
+ it = cArr->find("detection_evt_id");
+ if (it != cArr->end())
+ {
+ tVal->detection_src = atoi(it->second.c_str());
+ };
+ it = cArr->find("camera_evt_ena");
+ if (it != cArr->end())
+ {
+ tVal->camera_enabled = (bool) atoi(it->second.c_str());
+ };
+ it = cArr->find("camera_evt_id");
+ if (it != cArr->end())
+ {
+ tVal->camera_src = atoi(it->second.c_str());
+ };
+ };
+ };
+ };
+ deleteResult(result);
+ };
+ return tVal;
+}
+
BUBBLE_FILTER_DATA * sqliteDBC::getBubbleFilterData(uint32_t id)
{
BUBBLE_FILTER_DATA * tVal = NULL;
diff --git a/lib/App/common/SQLite_dataBinder.h b/lib/App/common/SQLite_dataBinder.h
index ef05a2d3..a6632f37 100644
--- a/lib/App/common/SQLite_dataBinder.h
+++ b/lib/App/common/SQLite_dataBinder.h
@@ -115,11 +115,13 @@ class sqliteDBC : public dataBinder
virtual void deleteUART(uint32_t UARTID);
virtual bool fillShadow2D(uint32_t ID, SHADOW & SH);
virtual bool getAppDebugMode();
+ virtual DBC_ATC_MODULE_DATA * getAttentionModuleData( uint32_t id );
virtual DBC_CAM_DATA * getCamData(uint32_t CamID);
virtual uint32_t getCamId(CSTR UUID);
virtual CAM_PRESET * getCamPreset(uint32_t SETID);
virtual DBC_PRESETS_INFO * getCamPresetInfo(uint32_t CamID);
virtual CSTR getCurrentReportDir(void);
+ virtual REST_SETTINGS * getBoschData( uint32_t id );
virtual BUBBLE_FILTER_DATA * getBubbleFilterData(uint32_t id);
virtual DBC_MODULE_EMBED_VIDEO_DATA * getEmbedVideoData(uint32_t ID);
virtual DBC_LRF_INI * getINIData(uint32_t lrfID);
diff --git a/lib/App/common/dataBinder.h b/lib/App/common/dataBinder.h
index fee36337..162e13a4 100644
--- a/lib/App/common/dataBinder.h
+++ b/lib/App/common/dataBinder.h
@@ -390,7 +390,10 @@ class dataBinder
{
return false;
}
-
+ virtual DBC_ATC_MODULE_DATA *getAttentionModuleData( uint32_t id ){
+ if ( !id ) return NULL;
+ return NULL;
+ }
virtual BUBBLE_FILTER_DATA * getBubbleFilterData(uint32_t id)
{
if ( !id ) return NULL;
diff --git a/lib/App/common/deviceNode2D.cpp b/lib/App/common/deviceNode2D.cpp
index 61288439..da651de9 100644
--- a/lib/App/common/deviceNode2D.cpp
+++ b/lib/App/common/deviceNode2D.cpp
@@ -423,13 +423,11 @@ void device2DSensor::handshakeMode()
break;
};
case LRF_WS_STAGE_3:
- if (m_bDeviceIsSynced && 0)
- { // Fixes Jay FF problem. must be checked if VersionString is changed ....
+ //if (m_bDeviceIsSynced && 0){ // Fixes Jay FF problem. must be checked if VersionString is changed ....
+ if ( m_bDeviceIsSynced ){ // Set back as planed -> On Communication minor errors starts to readout device settings.
updateDataStatus(ARGUS_DS_READY);
setWM(LRF_WM_IDLE);
- }
- else
- {
+ } else {
setWM(LRF_WM_SYNC_UP);
};
break;
@@ -644,17 +642,14 @@ void device2DSensor::readMode()
};
}
-bool device2DSensor::reset()
-{
+bool device2DSensor::reset(){
DELAY_10MS(10); // 100 ms
- if (! doFullReset())
- {
+ m_bDeviceIsSynced = false;
+ if (! doFullReset()){
LOG_ERROR("Fall Back to Disconnected!");
setWM(LRF_WM_CONNECTION);
return false;
- }
- else
- {
+ } else {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
updateDataStatus(ARGUS_DS_BUSY);
DELAY_10MS(10); // 100 ms
diff --git a/lib/App/common/deviceNodeCamera.cpp b/lib/App/common/deviceNodeCamera.cpp
index f654f816..8c745bbe 100644
--- a/lib/App/common/deviceNodeCamera.cpp
+++ b/lib/App/common/deviceNodeCamera.cpp
@@ -283,25 +283,19 @@ bool deviceNodeCamera::create()
// m_oPosition.setOrientationDeg( m_sCamData.x_rot, m_sCamData.y_rot, m_sCamData.z_rot );
systemAnchor * SA = systemAnchor::getInstance();
- if (SA)
- {
+ if( SA ){
LOG("SysAnchor OK");
- if (SA->beLocal())
- {
+ if( SA->beLocal() ){
LOG("SysAnchor beLocal!");
m_oPosition.setPositionXYZ(m_sCamData.x, m_sCamData.y, m_sCamData.z, 0); // SA->getUTMZone() );
m_oPosition.setOrientationDeg(m_sCamData.x_rot, m_sCamData.y_rot, m_sCamData.z_rot);
- }
- else
- {
+ } else {
LOG("SysAnchor is Global Position System!");
C3D_DECART LD = SA->getXYZ();
m_oPosition.setPositionXYZ(LD.x + m_sCamData.x, LD.y + m_sCamData.y, LD.z + m_sCamData.z, SA->getUTMZone());
m_oPosition.setOrientationDeg(m_sCamData.x_rot, m_sCamData.y_rot, m_sCamData.z_rot);
};
- }
- else
- {
+ } else {
LOG("No SysAnchor!");
m_oPosition.setPositionXYZ(m_sCamData.x, m_sCamData.y, m_sCamData.z);
m_oPosition.setOrientationDeg(m_sCamData.x_rot, m_sCamData.y_rot, m_sCamData.z_rot);
@@ -508,7 +502,7 @@ bool deviceNodeCamera::create()
break;
};
case CAM_CTRL_PROTO_BRCP:{
- #ifdef DEBUG_EXTRA
+ #ifdef DEBUG
LOG("BRCP");
#endif
// m_pProtocol = (protocolPTZ *) new protocolPTZ_ONVIF( m_sCamData.ip, m_sCamData.port, m_sCamData.username, m_sCamData.password, m_sCamData.auth_mode );
@@ -529,7 +523,7 @@ bool deviceNodeCamera::create()
{
m_pProtocol = (protocolPTZ *) new protocolPTZ_BRCP(m_sCamData.onvif_ctrl, m_sCamData.username, m_sCamData.password, m_sCamData.auth_mode);
};
- #ifdef DEBUG_EXTRA
+ #ifdef DEBUG
LOG("BRCP-END");
#endif
if (m_pProtocol != NULL)
@@ -540,7 +534,7 @@ bool deviceNodeCamera::create()
delete((protocolPTZ_BRCP *) m_pProtocol);
m_pProtocol = NULL;
};
- #ifdef DEBUG_EXTRA
+ #ifdef DEBUG
LOG("PROTO CREATE DONE");
#endif
};
@@ -721,6 +715,8 @@ bool deviceNodeCamera::pushCamTask(CAM_TASK * ptr)
return true;
}
+#ifndef NO_CAMERA_FUSION_ENGINE
+
bool deviceNodeCamera::fusion_compare(CAM_ROI * ptr, C3D_SPH_DEGREES tp)
{
if (ptr == NULL)
@@ -998,9 +994,11 @@ void deviceNodeCamera::fusion_validate(void)
m_mROIsProtector.unlock();
}
+#endif // !NO_CAMERA_FUSION_ENGINE
+
bool deviceNodeCamera::absoluteMove(uint32_t TargetRefID, float PanPOS, float TiltPOS, float ZoomPOS)
{
- if (m_sCamData.online)
+ //if (m_sCamData.online)
{
CAM_TASK * tTask = (CAM_TASK *) malloc(sizeof(CAM_TASK));
if (tTask)
@@ -1034,8 +1032,9 @@ bool deviceNodeCamera::absoluteMove(uint32_t TargetRefID, float PanPOS, float Ti
bool deviceNodeCamera::absoluteMove(uint32_t TargetRefID, C3D_ORIENT_ONVIF O)
{
- if (m_sCamData.online)
+ //if (m_sCamData.online)
{
+
CAM_TASK * tTask = (CAM_TASK *) malloc(sizeof(CAM_TASK));
if (tTask)
{
@@ -1102,9 +1101,9 @@ void deviceNodeCamera::m_fThreadProc(void)
uint8_t tState = getWM();
//char tB[128];
-
+#ifndef NO_CAMERA_FUSION_ENGINE
fusion_validate();
-
+#endif
switch (tState)
{
case CAM_WS_INIT:
@@ -1291,6 +1290,37 @@ void deviceNodeCamera::m_fThreadProc(void)
};
break;
};
+ case CAM_CTRL_PROTO_BRCP:{
+#ifdef DEBUG
+ LOG("BRCP");
+#endif
+ // m_pProtocol = (protocolPTZ *) new protocolPTZ_ONVIF( m_sCamData.ip, m_sCamData.port, m_sCamData.username, m_sCamData.password, m_sCamData.auth_mode );
+ if (strstr(m_sCamData.onvif_ctrl, "http") == NULL){
+ char tURI[256];
+ if (m_sCamData.port) {
+ sprintf(tURI, "http://%s:%d%s", m_sCamData.ip, m_sCamData.port, m_sCamData.onvif_ctrl);
+ } else {
+ sprintf(tURI, "http://%s%s", m_sCamData.ip, m_sCamData.onvif_ctrl);
+ };
+ m_pProtocol = (protocolPTZ *) new protocolPTZ_BRCP(tURI, m_sCamData.username, m_sCamData.password, m_sCamData.auth_mode);
+ } else {
+ m_pProtocol = (protocolPTZ *) new protocolPTZ_BRCP(m_sCamData.onvif_ctrl, m_sCamData.username, m_sCamData.password, m_sCamData.auth_mode);
+ };
+#ifdef DEBUG
+ LOG("BRCP-END");
+#endif
+ if (m_pProtocol != NULL) {
+ if (! m_pProtocol->create()) {
+ LOG_ERROR("Error Creating Proto!");
+ delete((protocolPTZ_BRCP *) m_pProtocol);
+ m_pProtocol = NULL;
+ };
+#ifdef DEBUG
+ LOG("PROTO CREATE DONE");
+#endif
+ };
+ break;
+ };
default:
{
#ifdef DEBUG
@@ -1587,9 +1617,13 @@ void deviceNodeCamera::m_fThreadProc(void)
m_fCP_Zoom = m_pCurrentROI->cam_orientation.zoom;
#ifdef DEBUG_EXTRA
LOG("INSTANT BCAST CAM ONPOS");
-#endif
- // Send Capture event
+#endif
+ // Send Capture event
+#ifndef NO_CAMERA_FUSION_ENGINE
DBC_SNAPSHOT_DATA * tData = fusion_translate_ROI(m_pCurrentROI);
+#else
+ DBC_SNAPSHOT_DATA * tData = NULL;
+#endif
if (tData != NULL)
{
if (m_pBEH)
@@ -1638,7 +1672,11 @@ void deviceNodeCamera::m_fThreadProc(void)
LOG("INSTANT BCAST CAM ONPOS");
#endif
// Send Capture event
+#ifndef NO_CAMERA_FUSION_ENGINE
DBC_SNAPSHOT_DATA * tData = fusion_translate_ROI(m_pCurrentROI);
+#else
+ DBC_SNAPSHOT_DATA * tData = NULL;
+#endif
if (tData != NULL)
{
if (m_pBEH)
@@ -1700,7 +1738,11 @@ void deviceNodeCamera::m_fThreadProc(void)
LOG("INSTANT BCAST CAM ONPOS");
#endif
// Send Capture event
+#ifndef NO_CAMERA_FUSION_ENGINE
DBC_SNAPSHOT_DATA * tData = fusion_translate_ROI(m_pCurrentROI);
+#else
+ DBC_SNAPSHOT_DATA * tData = NULL;
+#endif
if (tData != NULL)
{
if (m_pBEH)
@@ -1744,7 +1786,11 @@ void deviceNodeCamera::m_fThreadProc(void)
if (m_pCurrentROI != NULL)
{
// Send Capture event
+#ifndef NO_CAMERA_FUSION_ENGINE
tData = fusion_translate_ROI(m_pCurrentROI);
+#else
+ tData = NULL;
+#endif
};
// To Accept any new ROI's ??
// setWM( CAM_WS_READY );
@@ -1866,7 +1912,11 @@ void deviceNodeCamera::m_fThreadProc(void)
};
case CAM_WS_READY:
{
+#ifndef NO_CAMERA_FUSION_ENGINE
m_pCurrentROI = fusion_fetchROI();
+#else
+
+#endif
if (m_pCurrentROI != NULL)
{
#ifdef DEBUG_EXTRA
@@ -2367,6 +2417,7 @@ bool deviceNodeCamera::lookAt(uint32_t TargetRefID, C3D_DECART L)
systemAnchor * tSystem = systemAnchor::getInstance();
if (tSystem == NULL)
{
+ LOG_ERROR("Cant Get Anchor!");
return false;
}
C3D_SPH_DEGREES SL;
@@ -2474,9 +2525,11 @@ bool deviceNodeCamera::lookAt(uint32_t TargetRefID, C3D_SPH_DEGREES L)
tROI->cam_position.fi = L.fi;
tROI->cam_position.tetta = L.tetta;
tROI->cam_position.r = L.r;
+#ifndef NO_CAMERA_FUSION_ENGINE
m_mROIsProtector.lock();
m_vROIS.push_back(tROI);
m_mROIsProtector.unlock();
+#endif
}
else
{
@@ -2490,7 +2543,11 @@ bool deviceNodeCamera::lookAt(uint32_t TargetRefID, C3D_SPH_DEGREES L)
}
return true;
};
+#ifndef NO_CAMERA_FUSION_ENGINE
return fusion_consumeData(TargetRefID, L);
+#else
+ return true;
+#endif
}
bool deviceNodeCamera::makeSnap(uint32_t TargetRefID)
diff --git a/lib/App/common/deviceNodeCamera.h b/lib/App/common/deviceNodeCamera.h
index b9806027..a44ad84c 100644
--- a/lib/App/common/deviceNodeCamera.h
+++ b/lib/App/common/deviceNodeCamera.h
@@ -32,6 +32,9 @@
#define CAM_POST_INIT
+
+//#define NO_CAMERA_FUSION_ENGINE
+
#define CAM_CTRL_PROTO_VISCA 1
#define CAM_CTRL_PROTO_PELCO 2
#define CAM_CTRL_PROTO_ONVIF 3
@@ -210,7 +213,7 @@ class deviceNodeCamera : public deviceNode, public basicThread
// bool m_bSourceConnected;
// uint32_t m_nActiveStreamID;
// bool inTheFOV( float lat, float lon, float alt );
-
+#ifndef NO_CAMERA_FUSION_ENGINE
/* tracking Fusion methods */
vCAM_ROIS m_vROIS;
basicMutex m_mROIsProtector;
@@ -220,7 +223,9 @@ class deviceNodeCamera : public deviceNode, public basicThread
void fusion_validate(void);
CAM_ROI * fusion_fetchROI(void);
DBC_SNAPSHOT_DATA * fusion_translate_ROI(CAM_ROI *(&ptr));
+#else
+#endif
/* presets Fusion methods */
CAM_PRESETS_SET m_sCamPresets;
@@ -275,6 +280,18 @@ class deviceNodeCamera : public deviceNode, public basicThread
virtual uint8_t getPtzStatus();
virtual uint8_t getStreamStatus();
+ virtual float getSystemLocationX(){
+ return m_sCamData.x;
+ };
+ virtual float getSystemLocationY(){
+ return m_sCamData.y;
+ };
+ virtual float getSystemLocationZ(){
+ return m_sCamData.z;
+ };
+ virtual float getMaxRange(){
+ return m_fMaxRange;
+ };
};
typedef std::vector vectorNodeCameras;
diff --git a/lib/App/common/deviceNodeEthernet2Serial.cpp b/lib/App/common/deviceNodeEthernet2Serial.cpp
index 9627a194..a820346b 100644
--- a/lib/App/common/deviceNodeEthernet2Serial.cpp
+++ b/lib/App/common/deviceNodeEthernet2Serial.cpp
@@ -706,6 +706,7 @@ void deviceETH2UART::m_fThreadAProc(void)
#ifdef DEBUG
LOG("Sender Thread Started!");
#endif
+ pthread_setname_np( pthread_self(), "E2S Sender" );
while (m_bThreadAStatus < TH_ENDED)
{
m_mBufferProtectorMutex.lock();
@@ -746,6 +747,7 @@ void deviceETH2UART::m_fThreadBProc(void)
#ifdef DEBUG
LOG("Recipient Thread Started!");
#endif
+ pthread_setname_np( pthread_self(), "E2S Receiver" );
while (m_bThreadBStatus < TH_ENDED)
{
RetVal = recptBlock(m_pInputBuffer, &m_nInputBufferSize);
diff --git a/lib/App/common/deviceNodePTZCamControl.cpp b/lib/App/common/deviceNodePTZCamControl.cpp
index d375fba0..d82c1b3e 100644
--- a/lib/App/common/deviceNodePTZCamControl.cpp
+++ b/lib/App/common/deviceNodePTZCamControl.cpp
@@ -37,58 +37,41 @@ bool deviceNodePTZCamControl::stopService()
bool deviceNodePTZCamControl::dispatchEvent(EVENT_CONTAINER * E)
{
- if (E == NULL)
- {
- return false;
- }
- // if( !m_sCamData.online ) return;
- // if( m_bBusy ) return;
- if (m_sCamData.prefered_events_only)
- {
- // Check if we eligable dest of event
- if (E->m_nDestinationNodeID != m_sNodeData.node_id)
- {
- return true;
- }
+ if (E == NULL) return false;
+ // if( !m_sCamData.online ) return true;
+ // if( m_bBusy ) return true;
+ if (m_sCamData.prefered_events_only){
+#ifdef DEBUG_EXTRA
+ char tB[200];
+ sprintf( tB, "comp Evt Dest %ld %ld", E->m_nDestinationNodeID, m_sNodeData.node_id );
+ LOG( tB );
+#endif
+ // Check if we are eligable dest of event
+ if( E->m_nDestinationNodeID != m_sNodeData.node_id ) return true;
};
- switch (E->m_eType)
- {
- case EVT_ROI_ACTIVE:
- {
- TARGET_DATA * tDATA;
- tDATA = (TARGET_DATA *) E->m_pEvtData;
- if (tDATA)
- {
- lookAt(E->m_db_id, tDATA->system_target);
- };
+ switch (E->m_eType){
+ case EVT_ROI_ACTIVE:{
+ TARGET_DATA * tDATA = (TARGET_DATA *) E->m_pEvtData;
+ if( tDATA ) lookAt(E->m_db_id, tDATA->system_target);
break;
};
- case EVT_CAMERA_MOVE_TO:
- {
- TARGET_DATA * tDATA;
- tDATA = (TARGET_DATA *) E->m_pEvtData;
- if (tDATA)
- {
- lookAt(E->m_db_id, tDATA->system_target);
- };
+ case EVT_CAMERA_MOVE_TO:{
+ TARGET_DATA * tDATA = (TARGET_DATA *) E->m_pEvtData;
+ if (tDATA) lookAt( E->m_db_id, tDATA->system_target );
break;
};
- case EVT_TARGET_1D:
+ case EVT_TARGET_1D:
case EVT_TARGET_2D_BLACK:
case EVT_TARGET_2D_WHITE:
case EVT_TARGET_3D_BLACK:
- case EVT_TARGET_3D_WHITE:
- {
- TARGET_DATA * tDATA;
- tDATA = (TARGET_DATA *) E->m_pEvtData;
- if (tDATA)
- {
+ case EVT_TARGET_3D_WHITE:{
+ TARGET_DATA * tDATA = (TARGET_DATA *) E->m_pEvtData;
+ if (tDATA){
#ifdef DEBUG_EXTRA
LOG("CHECK CAMERA FOV");
#endif
- if (testFOV(tDATA->system_target))
- {
+ if (testFOV(tDATA->system_target)){
#ifdef DEBUG_EXTRA
LOG("TARGET IN CAMERA FOV");
#endif
@@ -96,7 +79,7 @@ bool deviceNodePTZCamControl::dispatchEvent(EVENT_CONTAINER * E)
};
};
break;
- };
+ };
default: break;
};
return true;
diff --git a/lib/App/common/deviceNodeSensor.cpp b/lib/App/common/deviceNodeSensor.cpp
index 9e012bc3..3a26f30b 100644
--- a/lib/App/common/deviceNodeSensor.cpp
+++ b/lib/App/common/deviceNodeSensor.cpp
@@ -174,6 +174,7 @@ deviceNodeSensor::deviceNodeSensor(uint32_t id) :
m_nCommErrorsStatTO = COMMUNICATION_ERROR_STATISTIC_HARVEST_INTERVAL_IN_SECONDS;
m_pTargetPipeLine = NULL;
m_pEventHeap = basicEventHeap::getInstance();
+ //m_bInitialSyncIsDone = false;
switch (m_sNodeData.type)
{
case ARGUS_CLD_SENSOR : m_eEventClass = EVT_CLASS_SENSOR_CLD; break;
@@ -255,6 +256,7 @@ deviceNodeSensor::deviceNodeSensor(DBC_NODE_DATA * Data) :
m_bValidationSkipCounter = DAFAULT_VALIDATION_SKIP_COUNTER;
m_nCommErrorsStatTO = COMMUNICATION_ERROR_STATISTIC_HARVEST_INTERVAL_IN_SECONDS;
m_pEventHeap = basicEventHeap::getInstance();
+ //m_bInitialSyncIsDone = false;
memset(&m_sLRF_DATA, 0, sizeof(DBC_LRF_DATA));
m_pTargetPipeLine = NULL;
if (m_pDBC)
diff --git a/lib/App/common/deviceNodeSensor.h b/lib/App/common/deviceNodeSensor.h
index 078d3154..00d581d0 100644
--- a/lib/App/common/deviceNodeSensor.h
+++ b/lib/App/common/deviceNodeSensor.h
@@ -178,8 +178,9 @@ class deviceNodeSensor : public deviceNode, public basicThread
uint16_t m_bTimeOutCounter;
E_MODES m_bActualDeviceWM;
E_MODES m_bRequestedDeviceWM;
- uint32_t m_nChannelTO;
- uint8_t m_bValidationSkipCounter;
+ uint32_t m_nChannelTO;
+ uint8_t m_bValidationSkipCounter;
+ //bool m_bInitialSyncIsDone;
char m_pTGENFILENAMES[3][33];
uint8_t m_bTGENFILECNT;
diff --git a/lib/App/common/hardwareManager.cpp b/lib/App/common/hardwareManager.cpp
index 1419d715..eb7d013b 100644
--- a/lib/App/common/hardwareManager.cpp
+++ b/lib/App/common/hardwareManager.cpp
@@ -1773,7 +1773,7 @@ hardwareResource * hardwareManager::requestResource(HARDWARE_PROVIDERS type, uin
for (VECTOR_HW_RESOURCES::iterator idx = m_vResources.begin(); idx < m_vResources.end(); idx++)
{
-#ifdef DEBUG
+#ifdef DEBUG_EXTRA
char tB[256];
sprintf(tB, "Check Resources RR[%d] RI[%d] ?? CR[%d] CI[%d]", type, id, (*idx)->getProviderType(), (*idx)->getDbId());
LOG(tB);
diff --git a/lib/App/common/hardwareResource.cpp b/lib/App/common/hardwareResource.cpp
index 343247d1..f4d0b2aa 100644
--- a/lib/App/common/hardwareResource.cpp
+++ b/lib/App/common/hardwareResource.cpp
@@ -23,6 +23,7 @@ hardwareResource::hardwareResource() :
basicObject()
{
m_bValid = false;
+ m_bActive = false;
m_pLog = basicLogCollection::getInstance();
#ifdef USE_MYSQL
m_pDBC = mysqlDBC::getInstance();
diff --git a/lib/App/common/hardwareResource.h b/lib/App/common/hardwareResource.h
index f163d2e2..ca9c41e3 100644
--- a/lib/App/common/hardwareResource.h
+++ b/lib/App/common/hardwareResource.h
@@ -50,6 +50,7 @@ class hardwareResource : public basicObject
dataBinder * m_pDBC;
basicLogCollection * m_pLog;
bool m_bValid;
+ bool m_bActive;
public:
@@ -83,7 +84,8 @@ class hardwareResource : public basicObject
return m_eProviderType;
}
virtual bool activate( void ){
- return false;
+ if (!m_bActive) m_bActive = true;
+ return m_bActive;
}
};
diff --git a/lib/App/common/hardwareResourceSerialProvider.cpp b/lib/App/common/hardwareResourceSerialProvider.cpp
index 95a52019..72249c5f 100644
--- a/lib/App/common/hardwareResourceSerialProvider.cpp
+++ b/lib/App/common/hardwareResourceSerialProvider.cpp
@@ -102,12 +102,15 @@ bool hardwareResourceSerialProvider::create(void)
}
bool hardwareResourceSerialProvider::activate( void ){
- switch (m_sUartData.type)
- {
- case HARDWARE_UART : m_bValid = create_HW(); break;
- case HARDWARE_IP_UART: m_bValid = create_SOL(); break;
- };
- return m_bValid;
+ if (!m_bActive ) {
+ switch (m_sUartData.type)
+ {
+ case HARDWARE_UART : m_bValid = create_HW(); break;
+ case HARDWARE_IP_UART: m_bValid = create_SOL(); break;
+ };
+ m_bActive = m_bValid;
+ }
+ return m_bActive;
}
bool hardwareResourceSerialProvider::validate(void)
@@ -905,75 +908,57 @@ bool hardwareResourceSerialProvider::closePort()
}
#ifndef HALF_DUPLEX
-void hardwareResourceSerialProvider::m_fThreadAProc(void)
-{
+void hardwareResourceSerialProvider::m_fThreadAProc(void){
int index;
int RetVal;
- #ifdef FIO_SELECT_MODE
+#ifdef FIO_SELECT_MODE
int iActiveFDS;
fd_set sWorkingSet;
struct timeval sTimeOut;
- #endif
+#endif
m_bThreadAStatus = TH_WORKING;
- #ifdef DEBUG
+#ifdef DEBUG
pthread_setname_np( pthread_self(), "UART Sender" );
- #endif
- while (m_bThreadAStatus < TH_ENDED)
- {
- #ifdef FIO_SELECT_MODE
+#endif
+ while (m_bThreadAStatus < TH_ENDED){
+#ifdef FIO_SELECT_MODE
sTimeOut.tv_sec = 5;
sTimeOut.tv_usec = 0;
memcpy(&sWorkingSet, &m_sSenderSet, sizeof(m_sSenderSet));
iActiveFDS = select(m_nSenderSetMax + 1, &sWorkingSet, NULL, NULL, &sTimeOut);
- if (iActiveFDS == 0)
- {
- }
- else if (iActiveFDS == -1)
- {
+ if (iActiveFDS == 0){
+
+ } else if (iActiveFDS == -1){
// m_bThreadBStatus = TH_ENDED;
m_bThreadAStatus = TH_ENDED;
LOG_ERROR("Failure during Select[s]!");
- }
- else
- {
- for (int i = 0; i <= m_nSenderSetMax && iActiveFDS > 0; i++)
- {
- if (FD_ISSET(i, &sWorkingSet))
- {
+ } else {
+ for (int i = 0; i <= m_nSenderSetMax && iActiveFDS > 0; i++){
+ if (FD_ISSET(i, &sWorkingSet)){
iActiveFDS--;
// Successful
- if (i == m_iControlPipeFD[0])
- {
+ if (i == m_iControlPipeFD[0]){
char buffer;
RetVal = read(i, &buffer, 1);
- if (buffer == 'A')
- {
- #endif
+ if (buffer == 'A'){
+#endif
m_mBufferProtectorMutex.lock();
- if (m_nOutputBufferSize > 0)
- {
+ if (m_nOutputBufferSize > 0){
index = 0;
- while ((index < m_nOutputBufferSize) && (m_bThreadAStatus < TH_ENDED))
- {
- #ifdef DEBUG_EXTRA
+ while ((index < m_nOutputBufferSize) && (m_bThreadAStatus < TH_ENDED)){
+#ifdef DEBUG_EXTRA
char TT[64];
sprintf(TT, "Have %d Bytes to send!", m_nOutputBufferSize);
LOG(TT);
- #endif
+#endif
RetVal = sendBlock(m_pOutputBuffer + index, m_nOutputBufferSize - index);
- if (RetVal > 0)
- {
+ if (RetVal > 0){
index += RetVal;
- }
- else
- {
+ } else {
// if 0 or -(error)
- if (RetVal == 0)
- {
+ if (RetVal == 0){
usleep(100);
- }
- else
- {
+ } else {
setConnectionStatus(CS_DISCONNECTED);
m_nOutputBufferSize = 0;
// m_bThreadBStatus = TH_ENDED;
@@ -984,18 +969,15 @@ void hardwareResourceSerialProvider::m_fThreadAProc(void)
};
m_nOutputBufferSize = 0;
m_mBufferProtectorMutex.unlock();
- #ifndef FIO_SELECT_MODE
- }
- else
- {
+#ifndef FIO_SELECT_MODE
+ } else {
m_mBufferProtectorMutex.unlock();
SLEEP(5);
- #endif
+#endif
};
- #ifdef FIO_SELECT_MODE
+#ifdef FIO_SELECT_MODE
};
- if (buffer == 'E')
- {
+ if (buffer == 'E') {
// m_bThreadBStatus = TH_ENDED;
m_bThreadAStatus = TH_ENDED;
LOG("Requesting Destruction of Transport[s]!");
@@ -1004,107 +986,83 @@ void hardwareResourceSerialProvider::m_fThreadAProc(void)
};
};
};
- #endif
+#endif
};
}
-void hardwareResourceSerialProvider::m_fThreadBProc(void)
-{
+void hardwareResourceSerialProvider::m_fThreadBProc(void){
int RetVal;
- #ifdef FIO_SELECT_MODE
+#ifdef FIO_SELECT_MODE
int iActiveFDS;
fd_set sWorkingSet;
struct timeval sTimeOut;
- #endif
+#endif
m_bThreadBStatus = TH_WORKING;
- #ifdef DEBUG
+#ifdef DEBUG
pthread_setname_np(pthread_self(), "UART Receiver");
- #endif
- while (m_bThreadBStatus < TH_ENDED)
- {
- #ifdef FIO_SELECT_MODE
+#endif
+ while (m_bThreadBStatus < TH_ENDED){
+#ifdef FIO_SELECT_MODE
sTimeOut.tv_sec = 5;
sTimeOut.tv_usec = 0;
memcpy(&sWorkingSet, &m_sReaderSet, sizeof(m_sReaderSet));
iActiveFDS = select(m_nReaderSetMax + 1, &sWorkingSet, NULL, NULL, &sTimeOut);
- if (iActiveFDS == 0)
- {
- }
- else if (iActiveFDS == -1)
- {
+ if (iActiveFDS == 0){
+ } else if (iActiveFDS == -1){
m_bThreadBStatus = TH_ENDED;
// m_bThreadAStatus = TH_ENDED;
LOG_ERROR("Failure during Select[r]!");
- }
- else
- {
- for (int i = 0; i <= m_nReaderSetMax && iActiveFDS > 0; i++)
- {
- if (FD_ISSET(i, &sWorkingSet))
- {
- if (i == m_iControlPipeFD[1])
- {
+ } else {
+ for( int i = 0; i <= m_nReaderSetMax && iActiveFDS > 0; i++ ){
+ if (FD_ISSET(i, &sWorkingSet)){
+ if (i == m_iControlPipeFD[1]){
char buffer;
RetVal = read(i, &buffer, 1);
- if (buffer == 'E')
- {
+ if (buffer == 'E'){
m_bThreadBStatus = TH_ENDED;
LOG("Requesting Destruction of Transport[r]!");
};
- }
- else
- {
- #endif
+ } else {
+#endif
RetVal = recptBlock(m_pInputBuffer, &m_nInputBufferSize);
- if (RetVal == -1)
- {
+ if (RetVal == -1) {
setConnectionStatus(CS_DISCONNECTED);
m_nInputBufferSize = 0;
m_bThreadBStatus = TH_ENDED;
- #ifdef DEBUG_EXTRA
+#ifdef DEBUG_EXTRA
LOG("Connection Droped on Reception Data");
- #endif
- }
- else if (m_nInputBufferSize > 0)
- {
- do
- {
+#endif
+ } else if (m_nInputBufferSize > 0) {
+ do {
m_mQueueProtectorMutex.lock();
- if (m_vParsers.size())
- {
- for (parseQueue::iterator index = m_vParsers.begin(); index != m_vParsers.end(); index++)
- {
+ if (m_vParsers.size()) {
+ for (parseQueue::iterator index = m_vParsers.begin(); index != m_vParsers.end(); index++) {
(*index)->parse(m_pInputBuffer, m_nInputBufferSize);
}
m_nInputBufferSize = 0;
m_mQueueProtectorMutex.unlock();
- }
- else
- {
- #ifdef DEBUG_EXTRA
+ } else {
+#ifdef DEBUG_EXTRA
LOG(m_sUartData.path);
LOG((char *) m_pInputBuffer);
LOG_ERROR("Try to parse data but No Parsers Assigned!");
- #endif
+#endif
m_nInputBufferSize = 0;
m_mQueueProtectorMutex.unlock();
SLEEP(100);
};
- }
- while ((m_vParsers.size() == 0) /*&& ( m_bThreadAStatus < TH_ENDED )*/ && (m_bThreadBStatus < TH_ENDED));
- #ifndef FIO_SELECT_MODE
- }
- else
- {
+ } while ((m_vParsers.size() == 0) /*&& ( m_bThreadAStatus < TH_ENDED )*/ && (m_bThreadBStatus < TH_ENDED));
+#ifndef FIO_SELECT_MODE
+ } else {
SLEEP(5);
- #endif
+#endif
};
- #ifdef FIO_SELECT_MODE
+#ifdef FIO_SELECT_MODE
};
};
};
};
- #endif
+#endif
};
}
@@ -1161,46 +1119,34 @@ void hardwareResourceSerialProvider::m_fThreadProc(void)
int index;
int RetVal;
m_bThreadStatus = TH_WORKING;
- #ifdef DEBUG_EXTRA
pthread_setname_np(pthread_self(), "UART HalfDuplex");
- #endif
- while (m_bThreadStatus < TH_ENDED)
- {
+ while (m_bThreadStatus < TH_ENDED){
m_mBufferProtectorMutex.lock();
- if (! m_qIO.empty())
- {
+ if (! m_qIO.empty()){
SIO_TZ * tIOData;
tIOData = m_qIO.front();
m_mBufferProtectorMutex.unlock();
- if (tIOData)
- {
+ if( tIOData ){
// Remove from Queue
m_mBufferProtectorMutex.lock();
m_qIO.pop();
m_mBufferProtectorMutex.unlock();
index = 0;
- while ((index < tIOData->out_size) && (m_bThreadStatus < TH_ENDED))
- {
+ while ((index < tIOData->out_size) && (m_bThreadStatus < TH_ENDED)){
#ifdef DEBUG_EXTRA
char TT[64];
sprintf(TT, "Have %d Bytes to send!", tIOData->out_size - index);
LOG(TT);
#endif
RetVal = sendBlock(tIOData->out_buffer + index, tIOData->out_size - index);
- if (RetVal > 0)
- {
+ if (RetVal > 0){
index += RetVal;
- }
- else
- {
+ } else {
// if 0 or -(error)
- if (RetVal == 0)
- {
+ if (RetVal == 0) {
usleep(100);
- }
- else
- {
+ } else {
setConnectionStatus(CS_DISCONNECTED);
// m_nOutputBufferSize = 0;
tIOData->out_size = 0;
@@ -1212,80 +1158,67 @@ void hardwareResourceSerialProvider::m_fThreadProc(void)
tIOData->out_size = 0;
bool tDataOnline = false;
uint8_t tTOCounter = 20;
- do
- {
- RetVal = recptBlock(tIOData->inp_buffer, &tIOData->inp_size);
- if (RetVal == -1)
- {
+ do {
+ RetVal = recptBlock( tIOData->inp_buffer, &tIOData->inp_size );
+ if( RetVal == -1 ){
setConnectionStatus(CS_DISCONNECTED);
tIOData->inp_size = 0;
m_bThreadStatus = TH_ENDED;
LOG_ERROR("Connection Droped on Reception Data");
- }
- else if (tIOData->inp_size)
- {
+ } else if( tIOData->inp_size ){
tDataOnline = true;
- do
- {
- m_mQueueProtectorMutex.lock();
- if (m_vParsers.size())
- {
- for (parseQueue::iterator idx = m_vParsers.begin(); idx != m_vParsers.end(); idx++)
- {
- (*idx)->parse(tIOData->inp_buffer, tIOData->inp_size);
- }
- tIOData->inp_size = 0;
- m_mQueueProtectorMutex.unlock();
- }
- else
- {
- #ifdef DEBUG_EXTRA
- LOG(m_sUartData.path);
- LOG((char *) tIOData->inp_buffer);
- LOG_ERROR("Try to parse data but No Parsers Assigned!");
- #endif
- tIOData->inp_size = 0;
- m_mQueueProtectorMutex.unlock();
- SLEEP(100);
- };
- }
- while ((m_vParsers.size() == 0) && (m_bThreadStatus < TH_ENDED));
- }
- else
- {
- if (tTOCounter)
- {
+ if( tIOData->boundParser == NULL ){
+ //No Specified Parser in Package!!
+ /*
+ do {
+ m_mQueueProtectorMutex.lock();
+ if( m_vParsers.size() ){
+ for( parseQueue::iterator idx = m_vParsers.begin(); idx != m_vParsers.end(); idx++) {
+ (*idx)->parse(tIOData->inp_buffer, tIOData->inp_size);
+ }
+ tIOData->inp_size = 0;
+ m_mQueueProtectorMutex.unlock();
+ } else {
+ #ifdef DEBUG_EXTRA
+ LOG( m_sUartData.path );
+ LOG((char *) tIOData->inp_buffer );
+ LOG_ERROR("Try to parse data but No Parsers Assigned!");
+ #endif
+ tIOData->inp_size = 0;
+ m_mQueueProtectorMutex.unlock();
+ SLEEP(100);
+ };
+ } while ((m_vParsers.size() == 0) && (m_bThreadStatus < TH_ENDED));
+ */
+ } else {
+ tIOData->boundParser->parse( tIOData->inp_buffer, tIOData->inp_size );
+ };
+ } else {
+ if (tTOCounter) {
tTOCounter--;
SLEEP(5);
#ifdef DEBUG
- }
- else
- {
+ } else {
LOG_ERROR("PACK TIMEOUT!");
#endif
};
};
- }
- while ((m_bThreadStatus < TH_ENDED) && tTOCounter && ! (tDataOnline && RetVal == 0)); // Pack1 conditions -> White Space after Data.
+ } while ((m_bThreadStatus < TH_ENDED) && tTOCounter && ! (tDataOnline && RetVal == 0)); // Pack1 conditions -> White Space after Data.
// Free Package
// LOG("Del Pack");
free(tIOData);
- }
- else
- {
+ } else {
// Mutex already unlocked!
SLEEP(5);
};
- }
- else
- {
+ } else {
m_mBufferProtectorMutex.unlock();
SLEEP(5);
};
};
}
-bool hardwareResourceSerialProvider::sendData(uint8_t * Data, int DataSize)
+bool hardwareResourceSerialProvider::sendData(uint8_t * Data, int DataSize, protocolParser *src)
{
if (m_bThreadStatus != TH_WORKING)
{
@@ -1308,9 +1241,10 @@ bool hardwareResourceSerialProvider::sendData(uint8_t * Data, int DataSize)
SIO_TZ * tData = (SIO_TZ *) malloc(sizeof(SIO_TZ));
if (tData)
{
- memset(tData, 0, sizeof(SIO_TZ));
+ memset( tData, 0, sizeof(SIO_TZ) );
tData->out_size = DataSize;
- memcpy(tData->out_buffer, Data, DataSize);
+ tData->boundParser = src;
+ memcpy( tData->out_buffer, Data, DataSize );
m_mBufferProtectorMutex.lock();
m_qIO.push(tData);
m_mBufferProtectorMutex.unlock();
diff --git a/lib/App/common/hardwareResourceSerialProvider.h b/lib/App/common/hardwareResourceSerialProvider.h
index de1bd6c5..e054c748 100644
--- a/lib/App/common/hardwareResourceSerialProvider.h
+++ b/lib/App/common/hardwareResourceSerialProvider.h
@@ -4,7 +4,7 @@
#include "../components/base/basicTransport.h"
#include "hardwareResource.h"
-// #define HALF_DUPLEX
+#define HALF_DUPLEX
// #define FIO_SELECT_MODE
@@ -47,29 +47,29 @@
#define MAXIMAL_SERIAL_IO_BUFFER_LENGTH 102400
#endif
-#include
+#if defined( HALF_DUPLEX ) || defined( SERIAL_PING_PONG )
+ #include
+ typedef struct S_SIO_TZ {
+ bool wReplay;
+ bool finished;
+ bool success;
+ int inp_size;
+ int out_size;
+#ifdef SERIAL_PING_PONG
+ protocolParser * boundParser;
+#endif
+ uint8_t out_buffer[MAXIMAL_SERIAL_IO_BUFFER_LENGTH];
+ uint8_t inp_buffer[MAXIMAL_SERIAL_IO_BUFFER_LENGTH];
+ } SIO_TZ;
-typedef struct S_SIO_TZ
-{
- uint32_t id;
- bool wReplay;
- bool finished;
- bool success;
- int inp_size;
- int out_size;
- uint8_t out_buffer[MAXIMAL_SERIAL_IO_BUFFER_LENGTH];
- uint8_t inp_buffer[MAXIMAL_SERIAL_IO_BUFFER_LENGTH];
-} SIO_TZ;
-
-typedef std::queue Q_SIO_TZ;
+ typedef std::queue Q_SIO_TZ;
+class hardwareResourceSerialProvider : public hardwareResource, public basicTransport, public basicThread
-#ifndef HALF_DUPLEX
-class hardwareResourceSerialProvider : public hardwareResource, public basicTransport, public basicDualThread
{
-#else
-class hardwareResourceSerialProvider : public hardwareResource, public basicTransport, public basicThread
+#else // ! HALF_DUPLEX SERIAL_PING_PONG
+class hardwareResourceSerialProvider : public hardwareResource, public basicTransport, public basicDualThread
{
-#endif
+#endif // ! HALF_DUPLEX SERIAL_PING_PONG
private:
DBC_UART_DATA m_sUartData;
@@ -77,14 +77,14 @@ class hardwareResourceSerialProvider : public hardwareResource, public basicTran
int m_iDeviceFD;
int m_iMasterFD;
#ifdef __linux__
- struct termios m_sTTY;
- int m_iInFID;
- int m_iOutFID;
- bool m_bManualRTS;
- void setRTS(uint8_t Val);
+ struct termios m_sTTY;
+ int m_iInFID;
+ int m_iOutFID;
+ bool m_bManualRTS;
+ void setRTS(uint8_t Val);
#else
- DCB PortDCB;
- HANDLE m_ioFID;
+ DCB PortDCB;
+ HANDLE m_ioFID;
#endif
bool pingDevice();
bool create_SOL();
@@ -103,18 +103,17 @@ class hardwareResourceSerialProvider : public hardwareResource, public basicTran
int m_iControlPipeFD[2];
#endif
-#ifndef HALF_DUPLEX
+#if defined( HALF_DUPLEX ) || defined( SERIAL_PING_PONG )
+ virtual void m_fThreadProc(void);
+ Q_SIO_TZ m_qIO;
+ // Q_SIO_TZ m_qREADY;
+#else
U8 m_pInputBuffer[MAXIMAL_SERIAL_IO_BUFFER_LENGTH]; // 100KB
U8 m_pOutputBuffer[MAXIMAL_SERIAL_IO_BUFFER_LENGTH];
int m_nInputBufferSize;
int m_nOutputBufferSize;
-
virtual void m_fThreadAProc(void);
virtual void m_fThreadBProc(void);
-#else
- virtual void m_fThreadProc(void);
- Q_SIO_TZ m_qIO;
- // Q_SIO_TZ m_qREADY;
#endif
public:
@@ -122,7 +121,11 @@ class hardwareResourceSerialProvider : public hardwareResource, public basicTran
virtual ~hardwareResourceSerialProvider();
virtual bool create(void);
virtual bool validate(void);
- virtual bool sendData(uint8_t * Data, int DataSize);
+#ifdef SERIAL_PING_PONG
+ virtual bool sendData(uint8_t * Data, int DataSize, protocolParser *src = NULL );
+#else
+ virtual bool sendData(uint8_t * Data, int DataSize );
+#endif
virtual bool reconnect(void);
virtual bool activate( void );
};
diff --git a/lib/App/common/kernelModule.h b/lib/App/common/kernelModule.h
index 2a394c12..6e4e0a53 100644
--- a/lib/App/common/kernelModule.h
+++ b/lib/App/common/kernelModule.h
@@ -24,7 +24,8 @@ typedef enum E_KERNEL_MODULE_TYPE
KERNEL_MODULE_MODEM_MANAGER = 9,
KERNEL_MODULE_REMOTE_SERVER = 10,
KERNEL_MODULE_REPORT_BACKUPPER = 11,
- KERNEL_MODULE_BOSCH_REST = 12
+ KERNEL_MODULE_BOSCH_REST = 12,
+ KERNEL_MODULE_ATTENTION_CLOUD = 13
} KERNEL_MODULE_TYPE;
class kernelModule : public basicEventHandler, public basicEngine
diff --git a/lib/App/common/kernelModuleAttentionCloud.cpp b/lib/App/common/kernelModuleAttentionCloud.cpp
new file mode 100644
index 00000000..33082bd6
--- /dev/null
+++ b/lib/App/common/kernelModuleAttentionCloud.cpp
@@ -0,0 +1,275 @@
+#include "kernelModuleAttentionCloud.h"
+#include "deviceNodeFactory.h"
+#include "deviceNodeCamera.h"
+
+
+#define LOG(X) kernelModule::m_pLog->Log("TCLOUD", this, X)
+#define LOG_ERROR(X) kernelModule::m_pLog->Log("TCLOUD", this, _LOG_ERROR, X)
+
+kernelAttentionCloud::kernelAttentionCloud( uint32_t id ): kernelModule( id , KERNEL_MODULE_ATTENTION_CLOUD ){
+ m_pEvtHeap = basicEventHeap::getInstance();
+};
+
+kernelAttentionCloud::~kernelAttentionCloud(){
+ stopService( true );
+ waitThreadEnd( true );
+};
+
+bool kernelAttentionCloud::reloadSettings(){
+ DBC_ATC_MODULE_DATA *tData = m_pDBC->getAttentionModuleData( m_nDBAUXID );
+ if( tData ){
+ memcpy( &m_sModuleData, tData, sizeof( DBC_ATC_MODULE_DATA ));
+ free( tData );
+ return true;
+ };
+ return false;
+};
+
+bool kernelAttentionCloud::startService(){
+ LOG("Starting Service!");
+ DBC_ATC_MODULE_DATA *tData = m_pDBC->getAttentionModuleData( m_nDBAUXID );
+ if( tData ){
+ memcpy( &m_sModuleData, tData, sizeof( DBC_ATC_MODULE_DATA ));
+ free( tData );
+ } else {
+ m_sModuleData.rest_time = 1000; // 1 sec
+ m_sModuleData.persist_time = 3000; // 3 seconds
+ m_sModuleData.attention_zone_range = 3.0f; // 3 meters
+ };
+ loadCameras();
+ return init();
+};
+
+bool kernelAttentionCloud::stopService( bool force ){
+ LOG("Stoping Service!");
+ return uninit();
+};
+
+void kernelAttentionCloud::m_fThreadProc(void){
+ bool bNewSecondLoop = false;
+ uint32_t cTimeSeconds = 0;
+ uint32_t oTimeSeconds = 0;
+ m_bThreadStatus = TH_WORKING;
+ pthread_setname_np( pthread_self(), "AttentionCloud" );
+ while( m_bThreadStatus < TH_ENDED ){
+ uint64_t cts = getMilliseconds();
+ m_mCloudsProtector.lock();
+ if( m_vCloud.size() ){
+ for( AttentionCloud::iterator idx = m_vCloud.begin(); idx != m_vCloud.end(); idx++ ){
+ switch( (*idx)->status ) {
+ case ATTENTION_STATUS_NEW:{
+ if ( ( cts - (*idx)->ts ) > ( m_sModuleData.persist_time << 2 ) ){
+ // Kill Not Sutable Targets
+ (*idx)->status = ATTENTION_STATUS_ZOMBIE;
+ break;
+ };
+ if( m_vCameras.size() ){
+ //Try find sutable free camera for that
+ for( CamCtlAreas::iterator dx = m_vCameras.begin(); dx != m_vCameras.end(); dx++ )
+ if ( !(*dx)->busy ){
+#ifdef DEBUG_EXTRA
+ char tB[256];
+ sprintf( tB,"Cam# %ld is not buzy range is: %0.2f meters", (*dx)->cam_id, (*dx)->range );
+ LOG( tB );
+#endif
+ if( checkLocation( (*idx)->loc, (*dx)->loc, (*dx)->range ) ) {
+ TARGET_DATA *tData = (TARGET_DATA *) malloc( sizeof( TARGET_DATA ));
+ if ( tData ) {
+ memset(tData,0, sizeof(TARGET_DATA));
+ tData->system_target.x = (*idx)->loc.x;
+ tData->system_target.y = (*idx)->loc.y;
+ tData->system_target.z = (*idx)->loc.z;
+ EVENT_CONTAINER * tEvt = createBasicEvent( 0, EVT_CLASS_CAMERA_CTRL, EVT_CAMERA_MOVE_TO, NULL, NULL, tData );
+ if ( tEvt ) {
+ tEvt->m_db_id = 1; // to comply cam fusion engine
+ tEvt->m_nDestinationNodeID = (*dx)->cam_id;
+ m_pEvtHeap->broadcast( tEvt );
+ };
+ };
+ (*idx)->status = ATTENTION_STATUS_SHOWING;
+ (*idx)->ts = cts;
+ (*idx)->cam_ctl = (*dx);
+ (*idx)->cam_ctl->busy = true;
+ break;
+ };
+ };
+ };
+ break;
+ };
+ case ATTENTION_STATUS_SHOWING:{
+ if ( ( cts - (*idx)->ts ) > m_sModuleData.persist_time ) {
+ (*idx)->cam_ctl->busy = false;
+ (*idx)->cam_ctl = NULL;
+ (*idx)->status = ATTENTION_STATUS_RESTING;
+ };
+ break;
+ };
+ case ATTENTION_STATUS_RESTING:{
+ if ( ( cts - (*idx)->ts ) > m_sModuleData.rest_time ) (*idx)->status = ATTENTION_STATUS_ZOMBIE;
+ break;
+ };
+ };
+ };
+ };
+ m_mCloudsProtector.unlock();
+ SLEEP(DEFAULT_THREAD_SLEEP_TIME);
+ };
+};
+
+bool kernelAttentionCloud::validate(){
+ m_mCloudsProtector.lock();
+ if( uint32_t cnt = m_vCloud.size() ){
+ for( AttentionCloud::iterator idx = m_vCloud.begin(); idx != m_vCloud.end(); ){
+ if( (*idx)->status == ATTENTION_STATUS_ZOMBIE ){
+ m_vCloud.erase( idx );
+ } else idx++;
+ };
+ };
+ m_mCloudsProtector.unlock();
+ if ( m_vCameras.size() == 0 ) {
+ return loadCameras();
+ } else {
+ //Try To Load more Cameras ....
+ deviceNode ** tA = NULL;
+ size_t tCNT = deviceNodeFactory::getInstance()->fetchNodes( ARGUS_IP_PTZ_CAMERA, tA );
+ if ( tCNT != m_vCameras.size() ) {
+ free(tA);
+ return loadCameras();
+ };
+ free(tA);
+ };
+ //check settings
+ DBC_ATC_MODULE_DATA *tData = m_pDBC->getAttentionModuleData( m_nDBAUXID );
+ if( tData ){
+ if( memcmp( &m_sModuleData, tData, sizeof( DBC_ATC_MODULE_DATA ) ) != 0 ){
+ memcpy( &m_sModuleData, tData, sizeof( DBC_ATC_MODULE_DATA ));
+ };
+ free( tData );
+ return true;
+ };
+ return false;
+};
+
+bool kernelAttentionCloud::deleteCameras(){
+ if ( m_vCameras.size() ) {
+ for( CamCtlAreas::iterator idx = m_vCameras.begin(); idx != m_vCameras.end(); idx++ ) delete( *idx );
+ m_vCameras.clear();
+ };
+};
+
+bool kernelAttentionCloud::loadCameras(){
+ deleteCameras();
+ deviceNode ** tA = NULL;
+ size_t tCNT = deviceNodeFactory::getInstance()->fetchNodes( ARGUS_IP_PTZ_CAMERA, tA );
+ if( tA == NULL ) return false;
+ for ( size_t i = 0; i < tCNT; i++) {
+ CamCtlArea *tData = new CamCtlArea();
+ if ( tData ) {
+ deviceNodeCamera *tCam = (deviceNodeCamera *)tA[i];
+ tData->cam_id = tCam->getNodeID();
+ tData->loc.x = tCam->getSystemLocationX();
+ tData->loc.y = tCam->getSystemLocationY();
+ tData->loc.z = tCam->getSystemLocationZ();
+ tData->busy = false;
+ tData->range = tCam->getMaxRange();
+ m_vCameras.push_back( tData );
+ };
+ };
+ free(tA);
+ tA = NULL;
+ return true;
+};
+
+bool kernelAttentionCloud::checkLocation( C3D_DECART BASE, C3D_DECART N, float range ){
+#ifdef DEBUG_EXTRA
+ char tB[128];
+ sprintf( tB, " Comp: %0.2fx%0.2f %0.2fx%0.2f %0.2fx%0.2f",BASE.x,N.x,BASE.y,N.y,BASE.z, N.z );
+ LOG( tB );
+#endif
+ float A = (BASE.x - N.x)*(BASE.x - N.x);
+ float B = (BASE.y - N.y)*(BASE.y - N.y);
+ float C = (BASE.z - N.z)*(BASE.z - N.z);
+ float D = sqrtf( A+B+C );
+#ifdef DEBUG_EXTRA
+ sprintf( tB, " Final Comp: %0.2f %0.2f", D, range );
+ LOG( tB );
+#endif
+ return ( D < range );
+};
+
+AttentionZone *kernelAttentionCloud::getOldest(){
+ AttentionZone *RetVal = NULL;
+ m_mCloudsProtector.lock();
+ if( m_vCloud.size() ){
+ uint64_t max_ts = getMilliseconds();
+ for( AttentionCloud::iterator idx = m_vCloud.begin(); idx != m_vCloud.end(); idx++ )
+ if( (*idx)->ts < max_ts && (*idx)->status == ATTENTION_STATUS_NEW ) {
+ RetVal = *idx;
+ max_ts = (*idx)->ts;
+ break;
+ };
+ };
+ m_mCloudsProtector.unlock();
+ return RetVal;
+};
+
+bool kernelAttentionCloud::registerAttention( /*uint32_t TargetRefID,*/ C3D_DECART L ){
+ AttentionZone * cAZ = NULL;
+ m_mCloudsProtector.lock();
+ if( m_vCloud.size() ){
+ for( AttentionCloud::iterator idx = m_vCloud.begin(); idx != m_vCloud.end(); idx++ )
+ if ( checkLocation( (*idx)->loc, L, (*idx)->range ) ) {
+ cAZ = *idx;
+ break;
+ };
+ };
+ if ( cAZ ) {
+ //Found in collection -> update
+ cAZ->loc.x = L.x;
+ cAZ->loc.y = L.y;
+ cAZ->loc.z = L.z;
+ if( cAZ->status == ATTENTION_STATUS_ZOMBIE ){
+ cAZ->status = ATTENTION_STATUS_NEW;
+ cAZ->ts = getMilliseconds();
+ };
+ } else {
+ //Not Found in Current Active Zones
+ AttentionZone * tAZ = new AttentionZone();
+ if ( tAZ ) {
+ tAZ->loc.x = L.x;
+ tAZ->loc.y = L.y;
+ tAZ->loc.z = L.z;
+ tAZ->range = m_sModuleData.attention_zone_range;
+ tAZ->ts = getMilliseconds();
+ tAZ->status = ATTENTION_STATUS_NEW;
+ m_vCloud.push_back( tAZ );
+ };
+ };
+ m_mCloudsProtector.unlock();
+ return true;
+};
+
+bool kernelAttentionCloud::dispatchEvent(EVENT_CONTAINER * E){
+ if( E == NULL ) return false;
+ switch( E->m_eType ){
+ case EVT_ROI_ACTIVE:
+ case EVT_TARGET_1D:
+ case EVT_TARGET_2D_BLACK:
+ case EVT_TARGET_2D_WHITE:
+ case EVT_TARGET_3D_BLACK:
+ case EVT_TARGET_3D_WHITE:{
+ TARGET_DATA * tDATA;
+ tDATA = (TARGET_DATA *) E->m_pEvtData;
+ if( tDATA ) {
+ //LOG("Reg New Movement!");
+ registerAttention( tDATA->system_target );
+ }
+ break;
+ };
+ default: break;
+ };
+ return true;
+};
+
+#undef LOG_ERROR
+#undef LOG
\ No newline at end of file
diff --git a/lib/App/common/kernelModuleAttentionCloud.h b/lib/App/common/kernelModuleAttentionCloud.h
new file mode 100644
index 00000000..c1ec44be
--- /dev/null
+++ b/lib/App/common/kernelModuleAttentionCloud.h
@@ -0,0 +1,67 @@
+#ifndef __KERNEL_MODULE_ATTENTION_CLOUD__
+#define __KERNEL_MODULE_ATTENTION_CLOUD__
+
+#include "kernelModule.h"
+#include "../../components/base/basicThread.h"
+#include "../../components/base/basicMutex.h"
+#include "../../components/base/basicEventHeap.h"
+#include
+
+#define ATTENTION_STATUS_NEW 0
+#define ATTENTION_STATUS_SHOWING 1
+#define ATTENTION_STATUS_RESTING 2
+#define ATTENTION_STATUS_ZOMBIE 3
+
+typedef struct S_AttentionTarget{
+ float temperature;
+}AttentionTarget;
+
+typedef std::vector AttentionTargets;
+
+typedef struct S_CamCtlArea{
+ uint64_t cam_id;
+ uint64_t lts;
+ C3D_DECART loc;
+ float range;
+ basicMutex block;
+ bool busy;
+}CamCtlArea;
+
+typedef struct S_AttentionZone{
+ C3D_DECART loc;
+ float range;
+ uint64_t ts;
+ uint8_t status;
+ CamCtlArea * cam_ctl;
+}AttentionZone;
+
+typedef std::vector AttentionCloud;
+typedef std::vector CamCtlAreas;
+
+class kernelAttentionCloud : public kernelModule, public basicThread {
+ private:
+ basicEventHeap * m_pEvtHeap;
+ AttentionCloud m_vCloud;
+ CamCtlAreas m_vCameras;
+ DBC_ATC_MODULE_DATA m_sModuleData;
+ basicMutex m_mCloudsProtector;
+ bool isCamBusy( uint64_t cam_id );
+ bool registerAttention( /*uint32_t TargetRefID,*/ C3D_DECART L );
+ bool checkLocation( C3D_DECART BASE, C3D_DECART N, float range );
+ bool createMoveToEvt( uint32_t cam_id, C3D_DECART L );
+ AttentionZone * getOldest();
+ bool loadCameras();
+ bool deleteCameras();
+ protected:
+ void m_fThreadProc(void);
+ public:
+ explicit kernelAttentionCloud( uint32_t id );
+ ~kernelAttentionCloud();
+ virtual bool reloadSettings();
+ virtual bool startService();
+ virtual bool stopService(bool force = false);
+ virtual bool validate();
+ virtual bool dispatchEvent(EVENT_CONTAINER * Evt);
+};
+
+#endif
\ No newline at end of file
diff --git a/lib/App/common/kernelModuleBosch.cpp b/lib/App/common/kernelModuleBosch.cpp
index 68ea7ab4..eb040812 100644
--- a/lib/App/common/kernelModuleBosch.cpp
+++ b/lib/App/common/kernelModuleBosch.cpp
@@ -15,755 +15,279 @@
#endif
kernelModuleBosch::kernelModuleBosch(uint32_t ModuleID) :
- kernelModule(ModuleID, KERNEL_MODULE_BOSCH_REST)
-{
- m_pProtocol = NULL;
- m_bConsumerEnabled = false;
+ kernelModule(ModuleID, KERNEL_MODULE_BOSCH_REST){
+ m_pCURL = NULL;
+ m_pHttpAccessManager = NULL;
m_pEventHeap = basicEventHeap::getInstance();
-
- memset(m_sServerIP, 0, 48);
- CSTR TVAL = NULL; // m_pKernel->getServerIp();
- if (TVAL)
- {
- strncpy(m_sServerIP, TVAL, 48);
- free(TVAL);
- }
- else
- {
- LOG_ERROR("Error Get Argus Server IP!");
- strncpy(m_sServerIP, "192.168.0.127", 48);
- };
- memset(m_sServerName, 0, 48);
- TVAL = NULL; // m_pKernel->getServerName();
- if (TVAL)
- {
- strncpy(m_sServerName, TVAL, 48);
- free(TVAL);
- }
- else
- {
- LOG_ERROR("Error Get Argus Server Name!");
- strncpy(m_sServerName, "Argus Server", 48);
- };
-
- m_pEvtTemplates = (REST_TEMPLATE ***) calloc(EVT_CLASS_COUNT, sizeof(REST_TEMPLATE **));
- if (m_pEvtTemplates != NULL)
- {
- memset(m_pEvtTemplates, 0, EVT_CLASS_COUNT * sizeof(REST_TEMPLATE **));
- }
- else
- {
- LOG_ERROR("EVT Templates Memory Allocation Error!");
- }
- /*
- Do it in Kernel!!
- if ( m_pKernel!= NULL ) {
- argusHardwareManager *tHWM = m_pKernel->getHardwareManager();
- if( tHWM != NULL ) {
- DBC_INT_LIST *rIDS = tHWM->requestResourcesByType( ARGUS_HARDWARE_PROVIDER_NETWORK );
- if( rIDS != NULL ) {
- for( DBC_INT_LIST::iterator idx = rIDS->begin(); idx < rIDS->end(); idx++ ){
- argusHardwareResourceNetwork *tRES = (argusHardwareResourceNetwork *) tHWM->requestResource( ARGUS_HARDWARE_PROVIDER_NETWORK, *idx );
- if( tRES != NULL ) {
- m_pServerIP = tRES->getAddress();
- break;
- } else {
- LOG_ERROR("Cannot Get Resource!");
- };
- };
- delete( rIDS );
- } else {
- LOG("No Networks Detected!");
- m_bEnabled = false;
- };
- } else {
- LOG_ERROR("No HW Manager");
- };
- } else {
- LOG_ERROR("No Kernel");
- };
- */
-}
-
-kernelModuleBosch::~kernelModuleBosch()
-{
-
- m_bEnabled = false;
-
- waitThreadEnd(true);
-
- if (m_pProtocol != NULL)
- {
- delete(m_pProtocol);
- };
- if (m_pEvtTemplates != NULL)
- {
- for (int i = 0; i < EVT_CLASS_COUNT; i++)
- {
- if (m_pEvtTemplates[i] != NULL)
- {
- for (int j = 0; j < EVT_COUNT; j++)
- {
- if (m_pEvtTemplates[i][j] != NULL)
- {
- if (m_pEvtTemplates[i][j]->tpl)
- {
- free(m_pEvtTemplates[i][j]->tpl);
- }
- free(m_pEvtTemplates[i][j]);
- };
- };
- free(m_pEvtTemplates[i]);
- };
- };
- free(m_pEvtTemplates);
- };
}
-/* Periodical Job Handler */
-void kernelModuleBosch::m_fThreadProc(void)
-{
-#ifdef DEBUG
- LOG("Pereodical Jobs Started");
-#endif
- m_bThreadStatus = TH_WORKING;
- pthread_setname_np(pthread_self(), "moduleBVMS");
- if (! m_bEnabled)
- {
- m_bThreadStatus = TH_ENDED;
-#ifdef DEBUG
- LOG("Module is Disabled!");
-#endif
- };
- while (m_bThreadStatus < TH_ENDED)
- {
- m_llTicks++; //= getMilliseconds();
- if (m_llTicks % 20 == 0)
- { // each 2 seconds
-
- };
- if (m_bConsumerEnabled)
- {
- for (uint8_t idx = 0; idx < EVT_COUNT; idx++)
- {
- if (m_pEvtTemplates[EVT_CLASS_EXTERNAL_CMD][idx] != NULL)
- {
-/*
- char BUF[1024];
- int len;
- if (m_pProtocol->receivePost(m_pEvtTemplates[EVT_CLASS_EXTERNAL_CMD][idx]->topic, partition, start_offset, BUF, len))
- {
- if (len > 0)
- {
- start_offset++;
-#ifdef DEBUG
- char ttt[64];
- LOG(" HAVE MESSAGE ");
- sprintf(ttt, " MSG Len: %d", len);
- LOG(ttt);
-#endif
- if (len > 0)
- {
- LOG(BUF);
- try
- {
- Json::Value root;
-#ifdef OLD_WAY_JSON
- Json::Reader reader;
- if (! reader.parse(BUF, root))
- {
- LOG_ERROR("Error parsing the string");
- }
- else
- {
-#else
- JSONCPP_STRING err;
- Json::CharReaderBuilder builder;
- const std::unique_ptr reader(builder.newCharReader());
- if (! reader->parse(BUF, BUF + len, &root, &err))
- {
- LOG_ERROR("Error parsing the string");
- LOG_ERROR(err.c_str());
- }
- else
- {
-#endif
-
- if (root.size())
- {
- FH_CTRL_DATA * tData;
- basicEventTypeID evtID = EVT_NOINIT;
- Json::Value tVal;
- tData = (FH_CTRL_DATA *) malloc(sizeof(FH_CTRL_DATA));
- if (tData)
- {
- memset(tData, 0, sizeof(FH_CTRL_DATA));
- tVal = root["id"];
-
- if (! tVal.isNull())
- {
-#ifdef DEBUG
- LOG(tVal.asString().c_str());
-#endif
- sprintf(tData->cmdUUID, "%s", tVal.asString().c_str());
- };
- tVal = root["action"];
- if (! tVal.isNull())
- {
-#ifdef DEBUG
- LOG(tVal.asString().c_str());
-#endif
- if (strcasecmp(tVal.asString().c_str(), "intercept_target") == 0)
- {
- evtID = EVT_FH_MISSION_BEGIN;
- };
- if (strcasecmp(tVal.asString().c_str(), "jam_target") == 0)
- {
- tData->param = atoi(tVal.asString().c_str() + 10);
- if (tData->param == 0)
- {
- tData->param = FH_DEFAULT_JAMING_TIME;
- };
- evtID = EVT_FH_JAMING_BEGIN;
- };
- if (strcasecmp(tVal.asString().c_str(), "cancel") == 0)
- {
- evtID = EVT_FH_CANCEL_ACTION;
- };
- };
- tVal = root["event_id"];
- if (! tVal.isNull())
- {
-#ifdef DEBUG
- LOG(tVal.asString().c_str());
-#endif
- sprintf(tData->evtUUID, "%s", tVal.asString().c_str());
- };
- tVal = root["target_id"];
- if (! tVal.isNull())
- {
-#ifdef DEBUG
- LOG(tVal.asString().c_str());
-#endif
- sprintf(tData->targetUUID, "%s", tVal.asString().c_str());
- };
- if (evtID)
- {
- EVENT_CONTAINER * tEVT;
- tEVT = createBasicEvent(0, EVT_CLASS_EXTERNAL_CMD, evtID, NULL, NULL, tData);
- if (tEVT)
- {
- m_pEventHeap->broadcast(tEVT);
- }
- else
- {
- free(tData);
- };
- }
- else
- {
- free(tData);
- };
- };
- };
- };
- }
- catch (const std::exception & e )
- {
- LOG_ERROR("EXCEPTION");
- };
- };
- };
- */
- };
- };
- };
- SLEEP(100);
+kernelModuleBosch::~kernelModuleBosch(){
+ m_bEnabled = false;
+ if ( m_pCURL ){
+ curl_easy_cleanup(m_pCURL);
+ m_pCURL = NULL;
};
}
bool kernelModuleBosch::startService(){
- if (! m_bEnabled ) return false;
- if( reloadSettings() ){
- m_pProtocol = new protocolBVMS( m_sRestSettings.server_ip, m_sRestSettings.port );
- if (m_pProtocol->init()){
- return init();
- };
- };
+ m_pHttpAccessManager = curlRequestsManager::getInstance();
+ if( !m_bEnabled ) return false;
+ if ( m_pCURL ) return true;
+ if ( reloadSettings() ) return true;
return false;
}
-bool kernelModuleBosch::stopService(bool force)
-{
- if ( force ) {
- m_bEnabled = false;
- waitThreadEnd( force );
- } else {
- m_bEnabled = !uninit();
- };
+bool kernelModuleBosch::stopService(bool force){
+ m_bEnabled = false;
return true;
}
-bool kernelModuleBosch::reloadSettings()
-{
+bool kernelModuleBosch::reloadSettings(){
if (m_pDBC == NULL) return false;
if (! m_bEnabled) return false;
REST_SETTINGS * tData = m_pDBC->getBoschData( m_nDBAUXID );
if ( tData != NULL ){
-
+ memcpy( &m_sRestSettings, tData, sizeof(REST_SETTINGS));
free( tData );
-
- if (m_pEvtTemplates != NULL)
- {
- // Clear Templates
- for (int i = 0; i < EVT_CLASS_COUNT; i++)
- {
- for (int j = 0; j < EVT_COUNT; j++)
- {
- if (m_pEvtTemplates[i] != NULL)
- {
- if (m_pEvtTemplates[i][j] != NULL)
- {
- if (m_pEvtTemplates[i][j]->tpl)
- {
- free(m_pEvtTemplates[i][j]->tpl);
- }
- free(m_pEvtTemplates[i][j]);
- m_pEvtTemplates[i][j] = NULL;
- };
- };
- };
- free(m_pEvtTemplates[i]);
- m_pEvtTemplates[i] = NULL;
- };
- for (int i = 0; i < EVT_CLASS_COUNT; i++)
- {
- for (int j = 0; j < EVT_COUNT; j++)
- {
- REST_TEMPLATE * tT;
- tT = m_pDBC->getRESTTemplateForEvent(m_nDBAUXID, i, j);
- if (tT != NULL)
- {
- if (m_pEvtTemplates[i] == NULL)
- {
- m_pEvtTemplates[i] = (REST_TEMPLATE **) calloc(EVT_COUNT, sizeof(REST_TEMPLATE *));
- memset(m_pEvtTemplates[i], 0, EVT_COUNT * sizeof(REST_TEMPLATE *));
- if (i == EVT_CLASS_EXTERNAL_CMD)
- {
- m_bConsumerEnabled = true;
- };
- };
- m_pEvtTemplates[i][j] = tT;
- };
- };
- };
- };
return true;
};
return false;
}
-CSTR kernelModuleBosch::buildTemplate(CSTR tpl, uint32_t source_id, CSTR ts, CSTR uuid, CSTR az, CSTR range, CSTR width, CSTR el, CSTR lat, CSTR lon, CSTR alt, CSTR extID, CSTR src_Name, CSTR src_IP, CSTR src_lat, CSTR src_lon, CSTR src_alt,
- CSTR src_rot_x, CSTR src_rot_y, CSTR src_rot_z)
-{
- CSTR ct1, ct2;
- char sid[64];
- if (tpl)
+bool kernelModuleBosch::_send_request(CSTR url, CSTR post_string ){
+#ifdef CURL_MANAGER
+ bool RetVal = false;
+ if (m_pHttpAccessManager){
+ m_mResponseProtector.lock();
+ curlRequest * tRC;
+ tRC = new curlRequest( url, (CSTR) "Content-Type: application/json; charset=utf-8;");
+ if (tRC != NULL){
+ #ifdef DEBUG_BVMS_TRAFFIC
+ FILE * tf;
+ tf = fopen("Traffic_bvms.txt", "a+");
+ fprintf(tf, "--------------------\r\n");
+
+ if ( post_string != NULL ) {
+ fprintf( tf, "REQ: %s (%d)\n", url, strlen(post_string));
+ fprintf( tf, ">>>>> %s\n", post_string );
+ } else fprintf(tf, "REQ: %s\n", url );
+ fprintf(tf,"Creds: [%s]:[%s]\n", m_sRestSettings.access_user, m_sRestSettings.access_pass );
+ fprintf(tf, "--------------------\r\n");
+ fclose(tf);
+ //bool mustReturnData = true; // In Debug Allways Read Return
+ #endif
+ tRC->setCredentials( m_sRestSettings.access_user, m_sRestSettings.access_pass, m_sRestSettings.auth_mode );
+ if( post_string != NULL ){
+ tRC->setPOST(post_string, strlen(post_string));
+ };
+ RetVal = m_pHttpAccessManager->accomplish( tRC );
+ } else {
+ LOG_ERROR("Cannot Create curlRequest!");
+ };
+ m_mResponseProtector.unlock();
+ };
+ return RetVal;
+#else
+ char tBuffer[CTEXT];
+ if (m_pCURL == NULL)
{
- sprintf(sid, "%d", source_id);
- ct1 = strReplace(tpl, KAFKA_TPL_SUBST_ID, sid);
- if (ct1)
+ if (m_pLastResponse == NULL)
{
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_TS, ts);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- if (uuid)
- {
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_UUID, uuid);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- };
- if (az)
- {
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_AZ, az);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- };
- if (range)
- {
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_RANGE, range);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- };
- if (width)
- {
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_WIDTH, width);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- };
- if (el)
- {
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_EL, el);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- };
- if (lat)
- {
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_LAT, lat);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- };
- if (lon)
- {
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_LON, lon);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- };
- if (alt)
- {
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_ALT, alt);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- };
- if (extID)
- {
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_EXEVTD, extID);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- };
- if (src_Name)
- {
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRC_NAME, src_Name);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- };
- if (src_IP)
- {
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRC_IP, src_IP);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- };
- if (src_lat)
- {
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRC_LAT, src_lat);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- };
- if (src_lon)
- {
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRC_LON, src_lon);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- };
- if (src_alt)
- {
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRC_ALT, src_alt);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- };
- if (src_rot_x)
- {
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRC_ROT_X, src_rot_x);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- };
- if (src_rot_y)
- {
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRC_ROT_Y, src_rot_y);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- };
- if (src_rot_z)
- {
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRC_ROT_Z, src_rot_z);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- };
- // Finalaze Message by System Wide Data
- // UUID
- CSTR TVAL = getUniqID_UUID();
- if (TVAL != NULL)
- {
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_MSG_UUID, TVAL);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- free(TVAL);
- }
- else
- {
- LOG_ERROR("Error Generate Message UUID!");
- };
- // Server IP
-
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRV_IP, m_sServerIP);
- if (ct2)
- {
- free(ct1);
- ct1 = ct2;
- };
- // Server Name
- ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRV_NAME, m_sServerName);
- if (ct2)
+ m_pLastResponse = (CSTR) malloc(DEFAULT_BUFFER_SIZE);
+ };
+ m_pCURL = curl_easy_init();
+ if (m_pProxyHost != NULL && m_nProxyPort != 0)
+ {
+ curl_easy_setopt(m_pCURL, CURLOPT_PROXY, m_pProxyHost);
+ curl_easy_setopt(m_pCURL, CURLOPT_PROXYPORT, m_nProxyPort);
+ if (m_pProxyUsername != NULL && m_pProxyPassword != NULL)
{
- free(ct1);
- ct1 = ct2;
+ sprintf(tBuffer, "%s:%s", m_pProxyUsername, m_pProxyPassword);
+ curl_easy_setopt(m_pCURL, CURLOPT_PROXYUSERPWD, tBuffer);
};
- return ct1;
};
- }
- return NULL;
-}
-
-bool kernelModuleBosch::dispatchEvent(EVENT_CONTAINER * Evt)
-{
- if (Evt == NULL)
- {
- return false;
- }
- if (! m_bEnabled)
- {
- return true;
- }
-#ifdef DEBUG
- char tBuffer[256];
- sprintf(tBuffer, "Event Class %d Type %d ", Evt->m_eClass, Evt->m_eType);
- LOG(tBuffer);
-#endif
- if (m_pEvtTemplates[Evt->m_eClass] != NULL)
+ curl_easy_setopt(m_pCURL, CURLOPT_CONNECTTIMEOUT, 1);
+ curl_easy_setopt(m_pCURL, CURLOPT_TIMEOUT, 2);
+ curl_easy_setopt(m_pCURL, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_easy_setopt(m_pCURL, CURLOPT_SSL_VERIFYHOST, 0);
+ curl_easy_setopt(m_pCURL, CURLOPT_VERBOSE, 0);
+ curl_easy_setopt(m_pCURL, CURLOPT_POST, 1);
+ // curl_easy_setopt( m_pCURL, CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS, 0 );
+ // curl_easy_setopt( m_pCURL, CURLOPT_NOPROGRESS, 1 );
+ // curl_easy_setopt( m_pCURL, CURLOPT_NOSIGNAL, 1 );
+ curl_easy_setopt(m_pCURL, CURLOPT_TCP_FASTOPEN, 1);
+ curl_easy_setopt(m_pCURL, CURLOPT_TCP_NODELAY, 1);
+ // curl_easy_setopt( m_pCURL, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
+ curl_easy_setopt(m_pCURL, CURLOPT_WRITEFUNCTION, pOnvif::_writer);
+ curl_easy_setopt(m_pCURL, CURLOPT_WRITEDATA, this);
+ };
+ if (m_pCURL != NULL)
{
- // We have defined Channel for that class Events
- // Skip Event Handling by flags
- if (! m_bEvtFlags[Evt->m_eType])
+ curl_easy_setopt(m_pCURL, CURLOPT_URL, url);
+ struct curl_slist * sList = NULL;
+ // Content-Type: application/soap+xml; charset=utf-8; action="http://www.onvif.org/ver20/ptz/wsdl/ContinuousMove"
+ // Connection: Close
+ sList = curl_slist_append(sList, "Content-Type: text/xml; charset=utf-8");
+ sprintf(tBuffer, "Content-Length: %d", strlen(post_string));
+ sList = curl_slist_append(sList, tBuffer);
+ curl_easy_setopt(m_pCURL, CURLOPT_HTTPHEADER, sList);
+ curl_easy_setopt(m_pCURL, CURLOPT_POSTFIELDS, post_string);
+ sprintf(tBuffer, "%s:%s", m_pUsername, m_pPassword);
+ curl_easy_setopt(m_pCURL, CURLOPT_USERPWD, tBuffer);
+ switch (m_bAuthMode)
{
-#ifdef DEBUG
- // LOG("Disabled By FLAG!");
-#endif
- // return;
+ case 0: curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); break;
+ case 1: curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); break;
+ case 2: curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST_IE); break;
+ case 3: curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_BEARER); break;
+ case 4: curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_NEGOTIATE); break;
+ case 5: curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_NTLM); break;
+ case 6: curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_NTLM_WB); break;
+ case 7: curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_ANY); break;
+ case 8: curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_ANYSAFE); break;
+ case 9:
+ curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_ONLY);
+ break;
+ // case 10: curl_easy_setopt( m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_AWS_SIGV4 ); break;
+ };
+ #ifdef DEBUG
+ char tErrorBuffer[CURL_ERROR_SIZE];
+ curl_easy_setopt(m_pCURL, CURLOPT_ERRORBUFFER, tErrorBuffer);
+ #endif
+ m_pLastIndex = 0;
+ if (curl_easy_perform(m_pCURL))
+ {
+ LOG_ERROR("CURL Failure!");
+ #ifdef DEBUG
+ LOG_ERROR(tErrorBuffer);
+ #endif
}
- // Hadle Event
- CSTR tDATA = NULL;
- if (m_pEvtTemplates[Evt->m_eClass][Evt->m_eType] != NULL)
+ else
{
- switch (Evt->m_eType)
- {
- case EVT_TARGET_2D_BLACK:
- case EVT_TARGET_2D_WHITE:
- {
- TARGET_DATA * tTARGET = (TARGET_DATA *) Evt->m_pEvtData;
- if (tTARGET != NULL)
- {
- char AZ[10];
- char RA[10];
- char WID[10];
-
- char LAT[10];
- char LON[10];
- char ALT[10];
-
- char SLAT[10];
- char SLON[10];
- char SALT[10];
- char SROT_X[10];
- char SROT_Y[10];
- char SROT_Z[10];
- char SNAME[64];
- char TS[64];
-
- sprintf(AZ, "%0.3f", tTARGET->local_target.fi);
- sprintf(RA, "%0.3f", tTARGET->local_target.r);
- sprintf(WID, "%0.3f", tTARGET->area);
- sprintf(LAT, "%0.6f", tTARGET->global_target.lat);
- sprintf(LON, "%0.6f", tTARGET->global_target.lon);
- sprintf(ALT, "%0.6f", tTARGET->global_target.alt);
- sprintf(TS, "%04d-%02d-%02dT%02d:%02d:%02d.%03lldZ", Evt->sTS.tm_year + 1900, Evt->sTS.tm_mon + 1, Evt->sTS.tm_mday, Evt->sTS.tm_hour, Evt->sTS.tm_min, Evt->sTS.tm_sec, Evt->m_UMSTS % 1000);
- sprintf(SLAT, "%0.6f", tTARGET->source_position.lat);
- sprintf(SLON, "%0.6f", tTARGET->source_position.lon);
- sprintf(SALT, "%0.6f", tTARGET->source_position.alt);
-
- sprintf(SROT_X, "%0.6f", tTARGET->source_orient.rot_x);
- sprintf(SROT_Y, "%0.6f", tTARGET->source_orient.rot_y);
- sprintf(SROT_Z, "%0.6f", tTARGET->source_orient.rot_z);
- CSTR tN = m_pDBC->getNodeName(Evt->m_nSourceNodeID);
- if (tN)
- {
- strncpy(SNAME, tN, 64);
- free(tN);
- }
- else
- {
- strncpy(SNAME, "Noname-Laser-Detector", 64);
- };
- tDATA = buildTemplate(m_pEvtTemplates[Evt->m_eClass][Evt->m_eType]->tpl, Evt->m_nSourceNodeID, TS, Evt->m_UUID, AZ, RA, WID, NULL, LAT, LON, ALT, NULL, SNAME, m_sServerIP, SLAT, SLON, SALT, SROT_X, SROT_Y, SROT_Z);
- };
- break;
- };
- case EVT_TARGET_3D_BLACK:
- case EVT_TARGET_3D_WHITE:
- {
- TARGET_DATA * tTARGET = (TARGET_DATA *) Evt->m_pEvtData;
- if (tTARGET != NULL)
- {
- char AZ[10];
- char EL[10];
- char RA[10];
- char WID[10];
- char LAT[10];
- char LON[10];
- char ALT[10];
-
- char SLAT[10];
- char SLON[10];
- char SALT[10];
- char SROT_X[10];
- char SROT_Y[10];
- char SROT_Z[10];
+ m_pLastResponse[m_pLastIndex] = (char) 0;
+ return true;
+ };
+ m_pLastIndex = 0;
+ };
+ return false;
+#endif
+}
- char SIP[16];
- char SNAME[64];
+bool kernelModuleBosch::buildTargetEventMsg( CSTR Buffer, float az, float range, float lat, float lon, float alt, uint64_t extID, CSTR src_Name ){
+ if ( Buffer == NULL ) return false;
+ char tTS[64];
+ time_t LocalTime;
+ time(&LocalTime);
+ tm gmtt;
+ tm * gmt_time = &gmtt;
+ if( gmtime_r( &LocalTime, &gmtt ) == NULL) return false;
+
+ sprintf( tTS, "%04d-%02d-%02d %02d:%02d:%02d", 1900 + gmt_time->tm_year, 1 + gmt_time->tm_mon, gmt_time->tm_mday, gmt_time->tm_hour, gmt_time->tm_min, gmt_time->tm_sec );
+ sprintf( Buffer, "{\"externalAlarmId\":%d,\"data\":[%0.2f,%0.1f,%0.12f,%0.12f,%0.3f,10,\"%s\",\"\",\"%s\",\"Detection Event\"]}",
+ m_sRestSettings.detection_src,
+ az, range,
+ lat, lon, alt,
+ src_Name,
+ tTS
+ );
+ return true;
+}
- char TS[64];
- sprintf(AZ, "%0.3f", tTARGET->local_target.fi);
- sprintf(EL, "%0.3f", tTARGET->local_target.tetta);
- sprintf(RA, "%0.3f", tTARGET->local_target.r);
- sprintf(WID, "%0.3f", tTARGET->area);
- sprintf(LAT, "%0.6f", tTARGET->global_target.lat);
- sprintf(LON, "%0.6f", tTARGET->global_target.lon);
- sprintf(ALT, "%0.6f", tTARGET->global_target.alt);
- sprintf(TS, "%04d-%02d-%02dT%02d:%02d:%02d.%03lldZ", Evt->sTS.tm_year + 1900, Evt->sTS.tm_mon + 1, Evt->sTS.tm_mday, Evt->sTS.tm_hour, Evt->sTS.tm_min, Evt->sTS.tm_sec, Evt->m_UMSTS % 1000);
- sprintf(SLAT, "%0.6f", tTARGET->source_position.lat);
- sprintf(SLON, "%0.6f", tTARGET->source_position.lon);
- sprintf(SALT, "%0.6f", tTARGET->source_position.alt);
+bool kernelModuleBosch::buildCameraEventMsg( CSTR Buffer, CSTR CamName, uint8_t Status ){
+ if ( Buffer == NULL ) return false;
+ char tTS[64];
+ time_t LocalTime;
+ time(&LocalTime);
+ tm gmtt;
+ tm * gmt_time = &gmtt;
+ if( gmtime_r( &LocalTime, &gmtt ) == NULL) return false;
+
+ sprintf( tTS, "%04d-%02d-%02d %02d:%02d:%02d", 1900 + gmt_time->tm_year, 1 + gmt_time->tm_mon, gmt_time->tm_mday, gmt_time->tm_hour, gmt_time->tm_min, gmt_time->tm_sec );
+ sprintf( Buffer, "{\"externalAlarmId\":%d,\"data\":[\"%s\",%d,\"%s\",\"Camera Event\"]}",
+ m_sRestSettings.camera_src,
+ CamName,
+ Status,
+ tTS
+ );
+ return true;
+}
- sprintf(SROT_X, "%0.6f", tTARGET->source_orient.rot_x);
- sprintf(SROT_Y, "%0.6f", tTARGET->source_orient.rot_y);
- sprintf(SROT_Z, "%0.6f", tTARGET->source_orient.rot_z);
- CSTR tN = m_pDBC->getNodeName(Evt->m_nSourceNodeID);
- if (tN)
- {
- strncpy(SNAME, tN, 64);
- free(tN);
- }
- else
- {
- strncpy(SNAME, "Noname-Laser-Detector", 64);
- };
+bool kernelModuleBosch::dispatchEvent(EVENT_CONTAINER * Evt){
+ if( Evt == NULL ) return false;
+ if( !m_bEnabled ) return true;
- if (0)
- {
- strncpy(SIP, tN, 16);
- free(tN);
- }
- else
- {
- strncpy(SIP, "192.168.1.24", 16);
- };
+ char tBuffer[1024];
+ char tURL[256];
- tDATA = buildTemplate(m_pEvtTemplates[Evt->m_eClass][Evt->m_eType]->tpl, Evt->m_nSourceNodeID, TS, Evt->m_UUID, AZ, RA, WID, EL, LAT, LON, ALT, NULL, SNAME, SIP, SLAT, SLON, SALT, SROT_X, SROT_Y, SROT_Z);
- };
- break;
- };
- case EVT_FH_JAMER_ON:
- case EVT_FH_JAMER_OFF:
- case EVT_FH_FLY_TO:
- case EVT_FH_WAYPOINT:
- case EVT_FH_INTERCEPT_OK:
- case EVT_FH_INTERCEPT_NOK:
- case EVT_FH_BUSY:
- case EVT_FH_LANDED:
- {
- FH_MISSION_DATA * tPOINT = (FH_MISSION_DATA *) Evt->m_pEvtData;
- if (tPOINT)
- {
- char TS[64];
- char LAT[10];
- char LON[10];
- char ALT[10];
- sprintf(LAT, "%0.6f", tPOINT->location.lat);
- sprintf(LON, "%0.6f", tPOINT->location.lon);
- sprintf(ALT, "%0.6f", tPOINT->location.alt);
- sprintf(TS, "%04d-%02d-%02dT%02d:%02d:%02d.%03lldZ", Evt->sTS.tm_year + 1900, Evt->sTS.tm_mon + 1, Evt->sTS.tm_mday, Evt->sTS.tm_hour, Evt->sTS.tm_min, Evt->sTS.tm_sec, Evt->m_UMSTS % 1000);
- tDATA = buildTemplate(m_pEvtTemplates[Evt->m_eClass][Evt->m_eType]->tpl, Evt->m_nSourceNodeID, TS, Evt->m_UUID, NULL, NULL, NULL, NULL, LAT, LON, ALT, tPOINT->missionID);
- };
- break;
- };
- default:
- {
- break;
- };
- };
- if (tDATA != NULL)
- {
-#ifdef REST_DUMMY_SEND
- LOG(tDATA);
-#else
- int tLen = strlen(tDATA);
- m_pProtocol->issuePost(m_pEvtTemplates[Evt->m_eClass][Evt->m_eType]->endpoint, tDATA, tLen );
+#ifdef DEBUG_EXTRA
+ sprintf(tBuffer, "Event Class %d Type %d ", Evt->m_eClass, Evt->m_eType);
+ LOG(tBuffer);
#endif
- }
- else
- {
- LOG_ERROR("Cant Build Template!");
- };
- };
+ switch (Evt->m_eType){
+ case EVT_ROI_ACTIVE:
+ case EVT_TARGET_2D_BLACK:
+ case EVT_TARGET_2D_WHITE:{
+ if ( m_sRestSettings.detection_enabled ) {
+ TARGET_DATA * tTARGET = (TARGET_DATA *) Evt->m_pEvtData;
+ if (tTARGET != NULL){
+ CSTR tN = m_pDBC->getNodeName( Evt->m_nSourceNodeID );
+ if ( tN ) {
+ if ( buildTargetEventMsg(
+ tBuffer,
+ tTARGET->local_target.fi,
+ tTARGET->local_target.r,
+ tTARGET->global_target.lat,
+ tTARGET->global_target.lon,
+ tTARGET->global_target.alt,
+ Evt->m_nSourceNodeID,
+ tN
+ ) ) {
+ sprintf( tURL,"https://%s:%d%s", m_sRestSettings.server_ip, m_sRestSettings.port, m_sRestSettings.rest_api );
+ _send_request( tURL ,tBuffer );
+ };
+ free( tN );
+ };
+ };
+ };
+ break;
+ };
+ case EVT_CAMERA_MOVE_TO:{
+ // Evt->m_nSourceNodeID
+ //LOG("CAM MOVE!");
+ break;
+ };
+ case EVT_CAMERA_ON_POSITION:{
+ if ( m_sRestSettings.camera_enabled ){
+ DBC_SNAPSHOT_DATA * tData = (DBC_SNAPSHOT_DATA *) Evt->m_pEvtData;
+ if( tData ){
+ CSTR tN = m_pDBC->getNodeName( Evt->m_nSourceNodeID );
+ if ( tN ) {
+ if ( buildCameraEventMsg( tBuffer, tN, 1 ) ) {
+ sprintf( tURL,"https://%s:%d%s", m_sRestSettings.server_ip, m_sRestSettings.port, m_sRestSettings.rest_api );
+ _send_request( tURL ,tBuffer );
+ };
+ free( tN );
+ };
+ };
+ };
+ break;
+ };
+ default: return true;
+ };
+ return true; // Never return false -> to propogate event to next dispatcher.
+}
+
+bool kernelModuleBosch::validate(){
+ //check settings
+ REST_SETTINGS * tData = m_pDBC->getBoschData( m_nDBAUXID );
+ if( tData ){
+ if( memcmp( &m_sRestSettings, tData, sizeof(REST_SETTINGS) ) != 0 ){
+ memcpy( &m_sRestSettings, tData, sizeof(REST_SETTINGS) );
+ };
+ free( tData );
+ return true;
};
- return true;
+ return false;
}
#undef LOG
diff --git a/lib/App/common/kernelModuleBosch.h b/lib/App/common/kernelModuleBosch.h
index 1f21dfa7..3badb223 100644
--- a/lib/App/common/kernelModuleBosch.h
+++ b/lib/App/common/kernelModuleBosch.h
@@ -3,27 +3,27 @@
#include "../components/base/basicEventHeap.h"
#include "../components/base/basicThread.h"
-#include "../data/protocol/protocolBVMS.h"
+//#include "../data/protocol/protocolBVMS.h"
+#include "../../data/curl/curlRequestsManager.h"
#include "kernelModule.h"
-class kernelModuleBosch : public kernelModule, public basicThread
-{
- private:
- protocolBVMS * m_pProtocol;
- bool m_bConsumerEnabled;
- basicEventHeap * m_pEventHeap;
- REST_TEMPLATE ***m_pEvtTemplates;
- REST_SETTINGS m_sRestSettings;
- char m_sServerIP[48];
- char m_sServerName[48];
- unsigned long long m_llTicks;
- CSTR buildTemplate(CSTR tpl, uint32_t source_id, CSTR ts, CSTR uuid = NULL, CSTR az = NULL, CSTR range = NULL, CSTR width = NULL, CSTR el = NULL, CSTR lat = NULL, CSTR lon = NULL, CSTR alt = NULL, CSTR extID = NULL, CSTR src_Name = NULL,
- CSTR src_IP = NULL, CSTR src_lat = NULL, CSTR src_lon = NULL, CSTR src_alt = NULL, CSTR src_rot_x = NULL, CSTR src_rot_y = NULL, CSTR src_rot_z = NULL);
-
- protected:
+//#define DEBUG_BVMS_TRAFFIC
- virtual void m_fThreadProc(void);
+#ifndef CURL_MANAGER
+ #define CURL_MANAGER
+#endif
+class kernelModuleBosch : public kernelModule {
+ private:
+ CURL * m_pCURL;
+ curlRequestsManager * m_pHttpAccessManager;
+ basicMutex m_mResponseProtector;
+ basicEventHeap * m_pEventHeap;
+ REST_SETTINGS m_sRestSettings;
+
+ bool _send_request(CSTR url, CSTR post_string );
+ bool buildTargetEventMsg( CSTR Buffer, float az, float range, float lat, float lon, float alt, uint64_t extID, CSTR src_Name );
+ bool buildCameraEventMsg( CSTR Buffer, CSTR CamName, uint8_t Status );
public:
explicit kernelModuleBosch(uint32_t ModuleID);
@@ -33,6 +33,7 @@ class kernelModuleBosch : public kernelModule, public basicThread
virtual bool startService();
virtual bool stopService(bool force = false);
virtual bool dispatchEvent(EVENT_CONTAINER * Evt);
+ virtual bool validate();
};
#endif
diff --git a/lib/App/common/kernelModuleFactory.cpp b/lib/App/common/kernelModuleFactory.cpp
index 9124d2eb..29a64280 100644
--- a/lib/App/common/kernelModuleFactory.cpp
+++ b/lib/App/common/kernelModuleFactory.cpp
@@ -8,6 +8,7 @@
#include "kernelModuleSSDP.h"
#include "kernelModuleUSBRelay.h"
#include "kernelModuleBosch.h"
+#include "kernelModuleAttentionCloud.h"
#ifdef MEM_DEBUG
#include "../alg/generic/heapDebug.h"
@@ -83,6 +84,7 @@ void kernelModuleFactory::shutdownServices(bool force)
case KERNEL_MODULE_EMBED_VIDEO : sprintf(tB, "Stop Service of EmbedVideo Module"); break;
case KERNEL_MODULE_MODEM_MANAGER : sprintf(tB, "Stop Service of Modem Manager Module"); break;
case KERNEL_MODULE_BOSCH_REST : sprintf(tB, "Stop Service of Bosch REST Module"); break;
+ case KERNEL_MODULE_ATTENTION_CLOUD: sprintf(tB, "Stop Service of Attention Cloud Module"); break;
default : sprintf(tB, "Stop Service of UNKNOWN[%d] Module", (*index)->getType()); break;
};
LOG(tB);
@@ -227,6 +229,12 @@ kernelModule * kernelModuleFactory::createModule(int id)
#endif
tVal = new kernelModuleBosch(tData->module_id);
break;
+ case KERNEL_MODULE_ATTENTION_CLOUD:
+#ifdef DEBUG
+ LOG("Creating Attention Cloud Module");
+#endif
+ tVal = new kernelAttentionCloud(tData->module_id);
+ break;
};
free(tData);
}
@@ -269,6 +277,7 @@ kernelModule * kernelModuleFactory::createModule(int id)
break;
case KERNEL_MODULE_MODEM_MANAGER: delete((kernelModuleModemManager *) tVal); break;
case KERNEL_MODULE_BOSCH_REST: delete((kernelModuleBosch *) tVal); break;
+ case KERNEL_MODULE_ATTENTION_CLOUD: delete((kernelAttentionCloud *) tVal); break;
};
delete(tVal);
tVal = NULL;
@@ -293,6 +302,7 @@ void kernelModuleFactory::deleteModule(kernelModule * M)
case KERNEL_MODULE_EMBED_VIDEO : delete((kernelModuleEmbedVideo *) M); break;
case KERNEL_MODULE_MODEM_MANAGER : delete((kernelModuleModemManager *) M); break;
case KERNEL_MODULE_BOSCH_REST : delete((kernelModuleBosch *) M); break;
+ case KERNEL_MODULE_ATTENTION_CLOUD: delete((kernelAttentionCloud *) M); break;
default: LOG("Can not Delete Unknown Type Module!");
};
};
@@ -427,36 +437,28 @@ void kernelModuleFactory::m_fThreadProc(void)
#endif
pthread_setname_np( pthread_self(), "ModuleFactory" );
m_bThreadStatus = TH_WORKING;
- while (m_bThreadStatus < TH_ENDED)
- {
- if (m_bInitialLoadModulesDone)
- {
+ while (m_bThreadStatus < TH_ENDED){
+ if (m_bInitialLoadModulesDone){
#ifdef MEM_DEBUG
memStart = getCurrentRSS();
#endif
m_mModulesProtector.lock();
- if (m_vKernelModules.size())
- {
+ if (m_vKernelModules.size()){
DBC_INT_LIST tL;
- for ( size_t cm = 0; cm < m_vKernelModules.size(); cm++)
- {
+ for ( size_t cm = 0; cm < m_vKernelModules.size(); cm++){
tL.push_back(m_vKernelModules.at(cm)->getId());
}
tList = m_pDBC->listNewModules(&tL);
tL.clear();
- }
- else
- {
+ } else {
tList = m_pDBC->listNewModules(NULL);
};
m_mModulesProtector.unlock();
- if (tList != NULL)
- {
+ if (tList != NULL) {
#ifdef DEBUG
LOG("New Modules Exists!");
#endif
- for (size_t index = 0; index < tList->size(); index++)
- {
+ for (size_t index = 0; index < tList->size(); index++){
createModule(tList->at(index));
}
tList->clear();
@@ -474,8 +476,7 @@ void kernelModuleFactory::m_fThreadProc(void)
// Get Full List
// tList = NULL;
tList = m_pDBC->listModules();
- if (tList != NULL)
- {
+ if (tList != NULL){
size_t cm = 0;
while (cm < m_vKernelModules.size())
{
@@ -505,9 +506,7 @@ void kernelModuleFactory::m_fThreadProc(void)
};
tList->clear();
delete(tList);
- }
- else
- {
+ } else {
#ifdef DEBUG
LOG("All Modules Must be Deleted!");
#endif
diff --git a/lib/App/common/sequentalIOps.cpp b/lib/App/common/sequentalIOps.cpp
new file mode 100644
index 00000000..1110039c
--- /dev/null
+++ b/lib/App/common/sequentalIOps.cpp
@@ -0,0 +1,32 @@
+#include "sequentalIOps.h"
+
+sequentalSerial::sequentalSerial( uint32_t dbID ):hardwareResourceSerialProvider( dbID ){
+ m_pCurrentIO = NULL;
+};
+
+sequentalSerial::~sequentalSerial(){
+ m_pCurrentIO = NULL;
+};
+
+IO_Sequence *sequentalSerial::fetchIO(){
+ m_mCurrentIO.lock();
+ if( m_qIOQ.size ){
+ m_pCurrentIO = m_qIOQ.front();
+ m_qIOQ.pop();
+ } else m_pCurrentIO = NULL;
+ m_mCurrentIO.unlock();
+ retrun m_pCurrentIO;
+};
+
+bool sequentalSerial::sendData( uint8_t *Data, size_t DataSize ){
+ IO_Sequence *tData = new IO_Sequence();
+ if( tData ){
+ m_qIOQ.push( tData );
+ return true;
+ };
+ return false;
+};
+
+bool sequentalSerial::receiveData( IO_Sequence *ptr ){
+
+};
diff --git a/lib/App/common/sequentalIOps.h b/lib/App/common/sequentalIOps.h
new file mode 100644
index 00000000..bbde315c
--- /dev/null
+++ b/lib/App/common/sequentalIOps.h
@@ -0,0 +1,41 @@
+#ifndef __SEQUENTAL_IOPS_HEADER__
+#define __SEQUENTAL_IOPS_HEADER__
+
+#include "../../components/base/basicMutex.h"
+#include
+
+typedef struct S_IO_Sequence{
+ basicMutex block;
+ uint8_t * out_data;
+ size_t out_size;
+ bool sucess;
+ uint8_t * in_data;
+ size_t in_size;
+}IO_Sequence;
+
+typedef std::queue QIO_Sequence;
+
+class sequentalSerial: public hardwareResourceSerialProvider{
+ private:
+ basicMutex m_mCurrentIO;
+ QIO_Sequence m_qIOQ;
+ IO_Sequence * m_pCurrentIO;
+ protected:
+ IO_Sequence * fetchIO(){
+ m_mCurrentIO.lock();
+ if( m_qIOQ.size ){
+ m_pCurrentIO = m_qIOQ.front();
+ m_qIOQ.pop();
+ } else m_pCurrentIO = NULL;
+ m_mCurrentIO.unlock();
+ retrun m_pCurrentIO;
+ };
+ public:
+ explicit sequentalSerial( uint32_t dbID );
+ ~sequentalSerial();
+ bool sendData();
+ bool receiveData( IO_Sequence *ptr );
+};
+
+
+#endif
\ No newline at end of file
diff --git a/lib/App/common/streamHandler.h b/lib/App/common/streamHandler.h
index e0eeed71..96bca92e 100644
--- a/lib/App/common/streamHandler.h
+++ b/lib/App/common/streamHandler.h
@@ -1,6 +1,7 @@
#ifndef __STREAM_HANDLER_EMBED_VIDEO_HEADER__
#define __STREAM_HANDLER_EMBED_VIDEO_HEADER__
+#ifndef LRF_PROXY_ONLY
#include "../../components/base/basicDualThread.h"
#include "../../components/base/basicEventHeap.h"
@@ -363,4 +364,6 @@ class streamHandler :
typedef map mapSTREAMHANDLERS;
+#endif // !LRF_PROXY_ONLY
+
#endif
diff --git a/lib/App/mojo/mojoKernel.cpp b/lib/App/mojo/mojoKernel.cpp
index fec11834..1ad60d1e 100644
--- a/lib/App/mojo/mojoKernel.cpp
+++ b/lib/App/mojo/mojoKernel.cpp
@@ -334,7 +334,7 @@ bool mojoKernel::create()
LOG_ERROR("No Embed Video Processing Module!");
};
#else
- LOG_ERROR("DATA PROXY Processing Module!");
+ LOG("MOJO is DATA PROXY Processing Module!");
m_bMediaMode = 0;
#endif
diff --git a/lib/components/base/basicEvent.cpp b/lib/components/base/basicEvent.cpp
index 8bf488ba..76ab7cb4 100644
--- a/lib/components/base/basicEvent.cpp
+++ b/lib/components/base/basicEvent.cpp
@@ -44,9 +44,10 @@ void utilizeBasicEvent(EVENT_CONTAINER & Evt)
case EVT_TARGET_2D_WHITE:
case EVT_TARGET_2D_BLACK:
case EVT_TARGET_3D_WHITE:
- case EVT_TARGET_3D_BLACK:
+ case EVT_TARGET_3D_BLACK:
+ case EVT_CAMERA_MOVE_TO:
{
- delete((CLIENT_EVENT *) Evt.m_pEvtData);
+ delete((TARGET_DATA *) Evt.m_pEvtData);
break;
};
default: free(Evt.m_pEvtData);
@@ -87,9 +88,10 @@ void utilizeBasicEvent(EVENT_CONTAINER *& Evt)
case EVT_TARGET_2D_WHITE:
case EVT_TARGET_2D_BLACK:
case EVT_TARGET_3D_WHITE:
- case EVT_TARGET_3D_BLACK:
+ case EVT_TARGET_3D_BLACK:
+ case EVT_CAMERA_MOVE_TO:
{
- delete((CLIENT_EVENT *) Evt->m_pEvtData);
+ delete((TARGET_DATA *) Evt->m_pEvtData);
break;
};
default: free(Evt->m_pEvtData);
diff --git a/lib/components/base/basicMediaDestination.h b/lib/components/base/basicMediaDestination.h
index 734b14ee..ed3c3a7d 100644
--- a/lib/components/base/basicMediaDestination.h
+++ b/lib/components/base/basicMediaDestination.h
@@ -1,6 +1,7 @@
#ifndef __BASIC_MEDIA_DESTINATION_H_INCL__
#define __BASIC_MEDIA_DESTINATION_H_INCL__
+#ifndef LRF_PROXY_ONLY
#include "basicFunctionality.h"
#include "basicLIBAV.h"
#include "basicLogCollection.h"
@@ -73,4 +74,6 @@ inline basicMediaDestination::~basicMediaDestination() {}
typedef vector mediaDestinationsCollection;
+
+#endif // ! LRF_PROXY_ONLY
#endif // __BASICMEDIADESTINATION_H_INCL__
diff --git a/lib/components/base/basicMediaSource.h b/lib/components/base/basicMediaSource.h
index 1614c030..85754392 100644
--- a/lib/components/base/basicMediaSource.h
+++ b/lib/components/base/basicMediaSource.h
@@ -1,6 +1,7 @@
#ifndef __BASICMEDIASOURCE_H_INCL__
#define __BASICMEDIASOURCE_H_INCL__
+#ifndef LRF_PROXY_ONLY
#include "basicMediaDestination.h"
/**
@@ -85,4 +86,6 @@ inline basicMediaSource::~basicMediaSource() {}
typedef vector mediaSourceCollection;
+#endif // !LRF_PROXY_ONLY
+
#endif // __BASICMEDIASOURCE_H_INCL__
diff --git a/lib/components/base/basicTransport.h b/lib/components/base/basicTransport.h
index 57e7b4d9..5e3b5f80 100644
--- a/lib/components/base/basicTransport.h
+++ b/lib/components/base/basicTransport.h
@@ -7,6 +7,8 @@
#include
#include
+#define SERIAL_PING_PONG
+
#ifdef DEBUG
// #ifndef DUBUG_COMMUNICATION
// #define DUBUG_COMMUNICATION
@@ -35,8 +37,11 @@ class basicTransport
basicTransport();
~basicTransport();
-
- virtual bool sendData(unsigned char * Data, int DataSize)
+#ifdef SERIAL_PING_PONG
+ virtual bool sendData(unsigned char * Data, int DataSize, protocolParser *src = NULL )
+#else
+ virtual bool sendData(unsigned char * Data, int DataSize )
+#endif
{
if ( !Data ) return false;
if ( !DataSize ) return false;
diff --git a/lib/components/base/basicTypes.h b/lib/components/base/basicTypes.h
index d550071e..8e2cd199 100644
--- a/lib/components/base/basicTypes.h
+++ b/lib/components/base/basicTypes.h
@@ -664,7 +664,14 @@ typedef struct S_KAFKA_TEMPLATE
typedef struct S_REST_SETTINGS{
char server_ip[48];
- char server_name[48];
+ char rest_api[256];
+ uint8_t auth_mode;
+ char access_user[48];
+ char access_pass[48];
+ bool detection_enabled;
+ uint32_t detection_src;
+ bool camera_enabled;
+ uint32_t camera_src;
uint16_t port;
}REST_SETTINGS;
@@ -674,4 +681,28 @@ typedef struct S_REST_TEMPLATE
CSTR tpl;
} REST_TEMPLATE;
+typedef struct S_accessToken
+{
+ char USERNAME[CTEXT];
+ char PASSDIGEST[CTEXT]; // SHA_DIGEST_LENGTH];
+ char NONCE[CTEXT]; // SHA_DIGEST_LENGTH];
+ char TIMESTAMP[CTEXT];
+} accessToken;
+
+typedef struct S_ptzStatus
+{
+ float pan;
+ float tilt;
+ float zoom;
+ bool hasMoveStatus;
+ bool PanTiltIdle;
+ bool ZoomIdle;
+} ptzStatus;
+
+typedef struct S_DBC_ATC_MODULE_DATA{
+ uint16_t persist_time;
+ uint16_t rest_time;
+ float attention_zone_range;
+}DBC_ATC_MODULE_DATA;
+
#endif
diff --git a/lib/data/bosch_rcp/bosch_rcp.cpp b/lib/data/bosch_rcp/bosch_rcp.cpp
index def71430..68aaf4e8 100644
--- a/lib/data/bosch_rcp/bosch_rcp.cpp
+++ b/lib/data/bosch_rcp/bosch_rcp.cpp
@@ -31,53 +31,26 @@ const char *BRPC_TYPE_TAG[8]={
"P_UNICODE"
};
-const char *BRPC_OP_TAG[2]={
- "READ",
- "WRITE"
+const char *BRPC_OP_TAG[2]={
+ "WRITE",
+ "READ"
};
+#define F_FLAG 0
+#define T_OCTET 1
+#define T_WORD 2
+#define T_INT 3
+#define T_DWORD 4
+#define P_OCTET 5
+#define P_STRING 6
+#define P_UNICODE 7
-inline bool checkBool(const char * A)
-{
- if (A == NULL)
- {
- return false;
- }
- return (A[0] == 'T' || A[0] == 't' || A[0] == '1');
-}
-
-inline bool checkOnOff(const char * A)
-{
- if (A == NULL)
- {
- return false;
- }
- return (A[1] == 'N' || A[1] == 'n' || A[0] == '1');
-}
-
-inline onvifOnOffAuto checkOnOffAuto(const char * A)
-{
- if (A == NULL)
- {
- return AUTO;
- }
- if (A[1] == 'N' || A[1] == 'n' || A[0] == '1')
- {
- return ON;
- }
- return OFF;
-}
-
-boschRCP::boschRCP()
-{
+boschRCP::boschRCP(){
m_pLog = basicLogCollection::getInstance();
m_pIpAddress = NULL;
m_pUsername = NULL;
m_pPassword = NULL;
- m_pMediaURI = NULL;
- m_pSnapshotURI = NULL;
m_pDeviceURI = NULL;
- m_pPTZURI = NULL;
m_pBaseURI = NULL;
m_nDeltaTime = 0;
m_pCURL = NULL;
@@ -87,114 +60,24 @@ boschRCP::boschRCP()
m_pProxyPassword = NULL;
m_pLastResponse = NULL;
m_bIntransingent = true;
- m_nDiscoveryTimeout = 30;//PONVIF_DEFAULT_DISCOVERYTIMEOUT;
- m_pDiscoveryBindIP = NULL; // PONVIF_DEFAULT_DISCOVERYBINDIP;
- m_pDiscoveryMCastIP = NULL; // PONVIF_DEFAULT_DISCOVERYMCASTIP;
- m_nDiscoveryMCastPort = 30;//PONVIF_DEFAULT_DISCOVERYMCASTPORT;
- m_bDiscoveryHideDuplicates = true;
m_pHttpAccessManager = NULL;
- m_sCapabilities.Analytics = NULL;
- m_sCapabilities.Device = NULL;
- m_sCapabilities.Events = NULL;
- m_sCapabilities.Imaging = NULL;
- m_sCapabilities.Media = NULL;
- m_sCapabilities.PTZ = NULL;
- m_sCapabilities.Extension = NULL;
m_bAuthMode = 0;
LOG("Constructor Done!");
}
-boschRCP::~boschRCP()
-{
+boschRCP::~boschRCP(){
#ifdef DEBUG
LOG("Destructor begin");
#endif
- if (m_pIpAddress)
- {
- free(m_pIpAddress);
- }
- if (m_pUsername)
- {
- free(m_pUsername);
- }
- if (m_pPassword)
- {
- free(m_pPassword);
- }
- if (m_pMediaURI)
- {
- free(m_pMediaURI);
- }
- if (m_pSnapshotURI)
- {
- free(m_pSnapshotURI);
- }
- if (m_pDeviceURI)
- {
- free(m_pDeviceURI);
- }
- if (m_pPTZURI)
- {
- free(m_pPTZURI);
- }
- if (m_pBaseURI)
- {
- free(m_pBaseURI);
- }
- if (m_pProxyHost)
- {
- free(m_pProxyHost);
- }
- if (m_pProxyUsername)
- {
- free(m_pProxyUsername);
- }
- if (m_pProxyPassword)
- {
- free(m_pProxyPassword);
- }
- if (m_pLastResponse)
- {
- free(m_pLastResponse);
- }
- if (m_pDiscoveryBindIP)
- {
- free(m_pDiscoveryBindIP);
- }
- if (m_pDiscoveryMCastIP)
- {
- free(m_pDiscoveryMCastIP);
- }
- if (m_sCapabilities.Analytics)
- {
- free(m_sCapabilities.Analytics);
- }
- if (m_sCapabilities.Device)
- {
- free(m_sCapabilities.Device);
- }
- if (m_sCapabilities.Events)
- {
- free(m_sCapabilities.Events);
- }
- if (m_sCapabilities.Imaging)
- {
- free(m_sCapabilities.Imaging);
- }
- if (m_sCapabilities.Media)
- {
- free(m_sCapabilities.Media);
- }
- if (m_sCapabilities.PTZ)
- {
- free(m_sCapabilities.PTZ);
- }
- if (m_sCapabilities.Extension)
- {
- free(m_sCapabilities.Extension);
- }
- if (m_pCURL)
- {
+ if (m_pIpAddress) free(m_pIpAddress);
+ if (m_pUsername) free(m_pUsername);
+ if (m_pPassword) free(m_pPassword);
+ if (m_pDeviceURI) free(m_pDeviceURI);
+ if (m_pProxyHost) free(m_pProxyHost);
+ if (m_pProxyUsername) free(m_pProxyUsername);
+ if (m_pProxyPassword) free(m_pProxyPassword);
+ if (m_pLastResponse) free(m_pLastResponse);
+ if (m_pCURL){
#ifdef DEBUG
LOG("Try Cleanup CURL!");
#endif
@@ -368,20 +251,20 @@ bool boschRCP::setDeviceUri(CSTR deviceUri)
};
memcpy( m_pDeviceURI, deviceUri, strlen(deviceUri));
m_pDeviceURI[strlen(deviceUri)] = (char) 0;
-
+ LOG("Device URI set explicitly");
+ LOG( deviceUri );
// toDo: Must parsed Host/IP
char * tT = strstr(m_pDeviceURI, "/");
- if (tT)
- {
+ if (tT){
tT += 2;
char * tB = strstr(tT, "/");
int len = tB - tT + 1;
m_pIpAddress = (CSTR) malloc(len);
- if (m_pIpAddress)
- {
+ if (m_pIpAddress){
len--;
memcpy(m_pIpAddress, tT, len);
m_pIpAddress[len] = (char) 0;
+ LOG("Host/Ip");
LOG(m_pIpAddress);
};
};
@@ -393,46 +276,51 @@ CSTR boschRCP::getIPAddress(void)
return m_pIpAddress;
}
-bool boschRCP::setIPAddress(CSTR ipAddress)
-{
- if (ipAddress == NULL || strlen(ipAddress) == 0)
- {
- m_pIpAddress = NULL;
- return false;
- };
- if (m_pIpAddress != NULL)
- {
- free(m_pIpAddress);
- }
- m_pIpAddress = (CSTR) malloc(strlen(ipAddress) + 1);
- if (m_pIpAddress == NULL)
- {
- return false;
- }
- memcpy(m_pIpAddress, ipAddress, strlen(ipAddress));
- m_pIpAddress[strlen(ipAddress)] = (char) 0;
-
- int len = strlen(ipAddress) + 28;
- m_pDeviceURI = (CSTR) malloc(len + 1);
- if (m_pDeviceURI){
- sprintf( m_pDeviceURI, BRCP_DEFAULT_URI_TPL, m_pIpAddress);
- LOG(m_pDeviceURI);
+bool boschRCP::updateDevURI( void ){
+ if( m_pIpAddress == NULL ) return false;
+ if( m_pDeviceURI ) free( m_pDeviceURI );
+ char tBuffer[512];
+ //if ( m_pUsername ) {
+ // if ( m_pPassword ) {
+ // sprintf(tBuffer, BRCP_DEFAULT_URI_TPL, m_pUsername, m_pPassword, m_pIpAddress );
+ // } else {
+ // sprintf(tBuffer, BRCP_DEFAULT_URI_TPL, m_pUsername, "", m_pIpAddress );
+ // };
+ //} else {
+ sprintf( tBuffer, BRCP_DEFAULT_URI_TPL_NA, m_pIpAddress );
+ //};
+ size_t len = strlen( tBuffer );
+ m_pDeviceURI = (CSTR)malloc(len + 1);
+ if( m_pDeviceURI ){
+ strncpy( m_pDeviceURI, tBuffer, len );
+ m_pDeviceURI[len] = (char)0;
+ return true;
};
- return true;
+ return false;
}
-//bool boschRCP::setDiscoveryTimeout(int discoverytimeout)
-//{
-// m_nDiscoveryTimeout = discoverytimeout;
-// return true;
-//}
-
+bool boschRCP::setIPAddress( CSTR ipAddress ){
+ if( m_pIpAddress!= NULL) free(m_pIpAddress);
+ if( ipAddress == NULL || strlen(ipAddress) == 0) return false;
+ size_t len = strlen(ipAddress);
+ m_pIpAddress = (CSTR) malloc( len + 1);
+ if( m_pIpAddress == NULL ) return false;
+ strncpy( m_pIpAddress, ipAddress, len );
+ m_pIpAddress[len] = (char) 0;
+ return updateDevURI();
+}
size_t boschRCP::createRequestString( CSTR buffer, uint16_t CMD, bool RW, int8_t pl_type, void *pl ){
if ( buffer == NULL) return 0;
if (pl != NULL) {
- sprintf(buffer, "%s?command=0x%04x&type=%s&direction=%s", m_pDeviceURI, CMD, BRPC_TYPE_TAG[pl_type],(RW?"READ":"WRITE"));
+ sprintf(buffer, "%s?command=0x%04x&type=%s&direction=%s&payload=%s",
+ m_pDeviceURI,
+ CMD,
+ BRPC_TYPE_TAG[pl_type],
+ BRPC_OP_TAG[RW],
+ (CSTR)pl
+ );
} else {
sprintf(buffer, "%s?command=0x%04x&direction=READ", m_pDeviceURI, CMD );
};
@@ -441,8 +329,7 @@ size_t boschRCP::createRequestString( CSTR buffer, uint16_t CMD, bool RW, int8_t
}
-bool boschRCP::create(void)
-{
+bool boschRCP::create(void){
#ifdef DEBUG_EXTRA
LOG("Get Instance m_pHttpAccessManager");
#endif
@@ -477,7 +364,7 @@ bool boschRCP::create(void)
#endif
free(tTS);
} else {
- return false;
+ return true; //false;
};
} catch (const std::exception& e) {
LOG_ERROR("Catched Exception!");
@@ -576,8 +463,8 @@ struct tm * boschRCP::core_GetSystemDateAndTime(void)
}
else
{
- LOG_ERROR("Body is Not Found!");
- LOG(m_pLastResponse);
+ //LOG_ERROR("Body is Not Found!");
+ //LOG(m_pLastResponse);
};
};
return RetVal;
@@ -588,33 +475,22 @@ struct tm * boschRCP::core_GetSystemDateAndTime(void)
return NULL;
}
-bool boschRCP::ptz_GetStatus(CSTR profileToken, ptzStatus * tStatus)
-{
- /*if (m_pPTZURI == NULL)
- {
- return false;
- }
- if (tStatus == NULL)
- {
- return false;
- }
+bool boschRCP::ptz_GetStatus( ptzStatus * tStatus ){
+
+ if (tStatus == NULL) return false;
char tBuffer[DEFAULT_BUFFER_SIZE];
- accessToken tTOKEN;
- tTOKEN = _makeToken();
- memset(tStatus, 0, sizeof(ptzStatus));
- sprintf(tBuffer, PONVIF_PACK_GET_PTZ_STATUS, tTOKEN.USERNAME, tTOKEN.PASSDIGEST, tTOKEN.NONCE, tTOKEN.TIMESTAMP, profileToken);
- if (_send_request(m_pPTZURI, tBuffer, true))
- {
+ memset( tStatus, 0, sizeof(ptzStatus) );
+
+ //sprintf(tBuffer, PONVIF_PACK_GET_PTZ_STATUS, tTOKEN.USERNAME, tTOKEN.PASSDIGEST, tTOKEN.NONCE, tTOKEN.TIMESTAMP, profileToken);
+ /*
+ if (_send_request(m_pPTZURI, tBuffer, true )){
XMLResults tParseResults;
XMLNode response = XMLNode::parseString(m_pLastResponse, "root", &tParseResults);
- if (tParseResults.error)
- {
+ if (tParseResults.error){
char tBuf[CTEXT];
sprintf(tBuf, "XML Parse Error %d at %d:%d", tParseResults.error, tParseResults.nLine, tParseResults.nColumn);
LOG_ERROR(tBuf);
- }
- else
- {
+ } else {
XMLNode aNode = response.getChildNode("Body", 0);
if (aNode.isEmpty())
{
@@ -675,42 +551,13 @@ bool boschRCP::ptz_GetStatus(CSTR profileToken, ptzStatus * tStatus)
};
};
};
- };*/
+ };
+ */
return false;
}
/*
-bool boschRCP::core_GetDeviceInformation(){
-
- char tBuffer[DEFAULT_BUFFER_SIZE];
- accessToken tTOKEN;
- tTOKEN = _makeToken();
-
- if( createRequestString( tURL, BRCP_CMD_GET_DTS ) == 0 ){
- return NULL;
- };
- sprintf(tBuffer, PONVIF_PACK_GET_DEV_INFO, tTOKEN.USERNAME, tTOKEN.PASSDIGEST, tTOKEN.NONCE, tTOKEN.TIMESTAMP);
- if (_send_request(m_pMediaURI, tBuffer))
- {
- XMLResults tParseResults;
- XMLNode response = XMLNode::parseString(m_pLastResponse, "root", &tParseResults);
- LOG("RCPT:");
- printf(m_pLastResponse);
- if (tParseResults.error)
- {
- char tBuf[CTEXT];
- sprintf(tBuf, "XML Parse Error %d at %d:%d", tParseResults.error, tParseResults.nLine, tParseResults.nColumn);
- LOG_ERROR(tBuf);
- }
- else
- {
- // return $response['Envelope']['Body']['GetDeviceInformationResponse'];
- };
- };
- return false;
-}
-
bool boschRCP::ptz_GetPresets(CSTR profileToken)
{
if (m_pPTZURI == NULL)
@@ -745,236 +592,81 @@ bool boschRCP::ptz_GetPresets(CSTR profileToken)
};
return false;
}
-
-bool boschRCP::ptz_GetNode(CSTR ptzNodeToken)
-{
- if (m_pPTZURI == NULL)
- {
- return false;
- }
- char tBuffer[DEFAULT_BUFFER_SIZE];
- accessToken tTOKEN;
- tTOKEN = _makeToken();
- sprintf(tBuffer, PONVIF_PACK_GET_PTZ_NODE, tTOKEN.USERNAME, tTOKEN.PASSDIGEST, tTOKEN.NONCE, tTOKEN.TIMESTAMP, ptzNodeToken);
- if (_send_request(m_pPTZURI, tBuffer))
- {
- XMLResults tParseResults;
- XMLNode response = XMLNode::parseString(m_pLastResponse, "root", &tParseResults);
- LOG("RCPT:");
- printf(m_pLastResponse);
- if (tParseResults.error)
- {
- char tBuf[CTEXT];
- sprintf(tBuf, "XML Parse Error %d at %d:%d", tParseResults.error, tParseResults.nLine, tParseResults.nColumn);
- LOG_ERROR(tBuf);
- }
- else
- {
- // return $response['Envelope']['Body']['GetNodeResponse'];
- };
- };
- return false;
-}
-
-bool boschRCP::ptz_GotoPreset(CSTR profileToken, CSTR presetToken, float speed_pantilt_x, float speed_pantilt_y, float speed_zoom_x)
-{
- if (m_pPTZURI == NULL)
- {
- return false;
- }
+*/
+// here the IN coordinates are OnVIF -1 ... 0 ... 1 except zoom 0 .. 1
+bool boschRCP::ptz_AbsoluteMove( float position_pantilt_x, float position_pantilt_y, float zoom){
char tBuffer[DEFAULT_BUFFER_SIZE];
- accessToken tTOKEN;
- tTOKEN = _makeToken();
- sprintf(tBuffer, PONVIF_PACK_GOTO_PRESET, tTOKEN.USERNAME, tTOKEN.PASSDIGEST, tTOKEN.NONCE, tTOKEN.TIMESTAMP, profileToken, presetToken, speed_pantilt_x, speed_pantilt_y, speed_zoom_x);
- return _send_request(m_pPTZURI, tBuffer, true);
+ char ptzCOM[512];
+#ifdef DEBUG_EXTRA
+ sprintf( tBuffer, " Pan: %0.3f Tilt: %0.3f Zoom: %0.3f", position_pantilt_x, position_pantilt_y, zoom );
+ LOG( tBuffer );
+#endif
+ uint16_t pPos = ((uint16_t) ( 18000.0 + 18000.0 * position_pantilt_x)) % 36000;
+ uint16_t tPos = ((uint16_t) ( 9000.0 + 9000.0 * position_pantilt_y)) % 36000;
+ uint16_t zPos = ( uint16_t )( 16384 * zoom );
+#ifdef DEBUG_EXTRA
+ sprintf( tBuffer, " CPOS: %d Tilt: %d Zoom: %d", pPos, tPos, zPos );
+ LOG( tBuffer );
+#endif
+ sprintf( ptzCOM,"0x80000601D102%04X%04X%04X0000&num=1", pPos, tPos, zPos );
+ if( createRequestString( tBuffer, BRCP_CMD_PTZ_DRIVE, false, P_OCTET, ptzCOM ) == 0 ) return false;
+ return _send_request( tBuffer, NULL, false );
}
-bool boschRCP::ptz_RemovePreset(CSTR profileToken, CSTR presetToken)
-{
- if (m_pPTZURI == NULL)
- {
- return false;
- }
+bool boschRCP::ptz_ContinuousMove( float velocity_pantilt_x, float velocity_pantilt_y){
char tBuffer[DEFAULT_BUFFER_SIZE];
- accessToken tTOKEN;
- tTOKEN = _makeToken();
- sprintf(tBuffer, PONVIF_PACK_REMOVE_PRESET, tTOKEN.USERNAME, tTOKEN.PASSDIGEST, tTOKEN.NONCE, tTOKEN.TIMESTAMP, profileToken, presetToken);
- return _send_request(m_pPTZURI, tBuffer, true);
-}
-bool boschRCP::ptz_SetPreset(CSTR profileToken, CSTR presetName)
-{
- if (m_pPTZURI == NULL)
- {
- return false;
- }
- char tBuffer[DEFAULT_BUFFER_SIZE];
- accessToken tTOKEN;
- tTOKEN = _makeToken();
- sprintf(tBuffer, PONVIF_PACK_SET_PRESET, tTOKEN.USERNAME, tTOKEN.PASSDIGEST, tTOKEN.NONCE, tTOKEN.TIMESTAMP, profileToken, presetName);
- return _send_request(m_pPTZURI, tBuffer, true);
+ return _send_request( tBuffer, tBuffer, true);
}
-*/
-bool boschRCP::ptz_RelativeMove(CSTR profileToken, float translation_pantilt_x, float translation_pantilt_y, float speed_pantilt_x, float speed_pantilt_y)
-{
- if (m_pPTZURI == NULL)
- {
- return false;
- }
- char tBuffer[DEFAULT_BUFFER_SIZE];
- accessToken tTOKEN;
- tTOKEN = _makeToken();
- //sprintf(tBuffer, PONVIF_PACK_RELATIVE_MOVE, tTOKEN.USERNAME, tTOKEN.PASSDIGEST, tTOKEN.NONCE, tTOKEN.TIMESTAMP, profileToken, translation_pantilt_x, translation_pantilt_y, speed_pantilt_x, speed_pantilt_y);
- return _send_request( m_pPTZURI, tBuffer, true );
+bool boschRCP::ptz_ContinuousMoveZoom( float speedZoom ){
+ char tBuffer[DEFAULT_BUFFER_SIZE];
+ char ptzCOM[512];
+ uint8_t Speed;
+ // 1 - 15
+ if ( speedZoom < 0 ) {
+ Speed = 1 + (speedZoom * -14.0f);
+ sprintf( ptzCOM,"0x80000601108500000%01X&num=1", Speed );
+ } else {
+ Speed = 1 + (speedZoom * 14.0f);
+ sprintf( ptzCOM,"0x80000601108500008%01X&num=1", Speed );
+ };
+ if( createRequestString( tBuffer, BRCP_CMD_PTZ_DRIVE, false, P_OCTET, ptzCOM ) == 0 ) return false;
+ LOG( tBuffer );
+ return _send_request( tBuffer, NULL, false );
}
-bool boschRCP::ptz_RelativeMoveZoom(CSTR profileToken, float zoom, float speedZoom)
-{
- if (m_pPTZURI == NULL)
- {
- return false;
- }
+bool boschRCP::ptz_Stop( bool pantilt, bool zoom){
char tBuffer[DEFAULT_BUFFER_SIZE];
- accessToken tTOKEN;
- tTOKEN = _makeToken();
- //sprintf(tBuffer, PONVIF_PACK_RELATIVE_ZOOM, tTOKEN.USERNAME, tTOKEN.PASSDIGEST, tTOKEN.NONCE, tTOKEN.TIMESTAMP, profileToken, zoom, speedZoom);
- return _send_request(m_pPTZURI, tBuffer, true);
+ if( pantilt || zoom ){
+ char ptzCOM[512];
+ sprintf( ptzCOM,"0x800006011085000000&num=1" );
+ if( createRequestString( tBuffer, BRCP_CMD_PTZ_DRIVE, false, P_OCTET, ptzCOM ) == 0 ) return false;
+ return _send_request( tBuffer, NULL, false );
+ };
+ return false;
}
-bool boschRCP::ptz_AbsoluteMove(CSTR profileToken, float position_pantilt_x, float position_pantilt_y, float zoom)
-{
- if (m_pPTZURI == NULL)
- {
- return false;
- }
+bool boschRCP::ptz_GotoPreset( CSTR presetToken, float speed_pantilt_x, float speed_pantilt_y, float speed_zoom_x){
char tBuffer[DEFAULT_BUFFER_SIZE];
- accessToken tTOKEN;
- tTOKEN = _makeToken();
- //sprintf(tBuffer, PONVIF_PACK_ABSOLUTE_MOVE, tTOKEN.USERNAME, tTOKEN.PASSDIGEST, tTOKEN.NONCE, tTOKEN.TIMESTAMP, profileToken, position_pantilt_x, position_pantilt_y, zoom);
- return _send_request(m_pPTZURI, tBuffer, false);
+ return _send_request( tBuffer, NULL, false );
}
-bool boschRCP::ptz_ContinuousMove(CSTR profileToken, float velocity_pantilt_x, float velocity_pantilt_y)
-{
- if (m_pPTZURI == NULL)
- {
- return false;
- }
+bool boschRCP::ptz_RemovePreset( CSTR presetToken){
char tBuffer[DEFAULT_BUFFER_SIZE];
- accessToken tTOKEN;
- tTOKEN = _makeToken();
- //sprintf(tBuffer, PONVIF_PACK_CONTINUOUS_MOVE, tTOKEN.USERNAME, tTOKEN.PASSDIGEST, tTOKEN.NONCE, tTOKEN.TIMESTAMP, profileToken, velocity_pantilt_x, velocity_pantilt_y);
- return _send_request(m_pPTZURI, tBuffer, true);
+ return _send_request( tBuffer, NULL, false );
}
-bool boschRCP::ptz_ContinuousMoveZoom(CSTR profileToken, float zoom)
-{
- if (m_pPTZURI == NULL)
- {
- return false;
- }
+bool boschRCP::ptz_SetPreset( CSTR presetName){
char tBuffer[DEFAULT_BUFFER_SIZE];
- accessToken tTOKEN;
- tTOKEN = _makeToken();
- //sprintf(tBuffer, PONVIF_PACK_CONTINUOUS_ZOOM, tTOKEN.USERNAME, tTOKEN.PASSDIGEST, tTOKEN.NONCE, tTOKEN.TIMESTAMP, profileToken, zoom);
- return _send_request(m_pPTZURI, tBuffer, true);
+ return _send_request( tBuffer, NULL, false );
}
-bool boschRCP::ptz_Stop(CSTR profileToken, bool pantilt, bool zoom)
-{
- if ( pantilt || zoom ) profileToken = profileToken;
- if (m_pPTZURI == NULL)
- {
- return false;
- }
- char tBuffer[DEFAULT_BUFFER_SIZE];
- accessToken tTOKEN;
- tTOKEN = _makeToken();
- //sprintf(tBuffer, PONVIF_PACK_PTZ_STOP, tTOKEN.USERNAME, tTOKEN.PASSDIGEST, tTOKEN.NONCE, tTOKEN.TIMESTAMP, profileToken); //, pantilt, zoom );
- return _send_request(m_pPTZURI, tBuffer, true);
-}
/*
Internal functions
*/
-accessToken boschRCP::_makeToken(void)
-{
- time_t tTS = time(NULL) - m_nDeltaTime;
- return _passwordDigest(m_pUsername, m_pPassword, tTS);
-}
-/*
-void boschRCP::_getOnvifVersion(nodeCapability & caps)
-{
- if (caps.Device != NULL)
- {
- if (caps.Device->System != NULL)
- {
- if (caps.Device->System->SupportedVersions != NULL)
- {
- m_sOnvifVersion.Major = caps.Device->System->SupportedVersions->Major;
- m_sOnvifVersion.Minor = caps.Device->System->SupportedVersions->Minor;
- };
- };
- };
- if (caps.PTZ != NULL)
- {
- m_pPTZURI = caps.PTZ->XAddr;
- };
- if (caps.Media != NULL)
- {
- m_pMediaURI = caps.Media->XAddr;
- };
- if (caps.Device != NULL)
- {
- m_pDeviceURI = caps.Device->XAddr;
- };
-}
- protected function _getActiveSources($videoSources,$profiles) {
- $sources=array();
-
- if (isset($videoSources['@attributes'])) {
- // NVT is a camera
- $sources[0]['sourcetoken']=$videoSources['@attributes']['token'];
- $this->_getProfileData($sources,0,$profiles);
- }
- else {
- // NVT is an encoder
- for ($i=0;$i_getProfileData($sources,$i,$profiles);
- }
- } // for
- }
-
- return $sources;
- }
-
-void pOnvif::_getProfileData( sources,$i, XMLNode profiles ){
- //$inprofile=0;
- videoSourceProfile *tPtr;
- for( $y=0; $y < count($profiles); $y++ ){
- if ($profiles[$y]['VideoSourceConfiguration']['SourceToken']==$sources[$i]['sourcetoken']) {
- $sources[$i][$inprofile]['profilename']=$profiles[$y]['Name'];
- $sources[$i][$inprofile]['profiletoken']=$profiles[$y]['@attributes']['token'];
- if ( isset($profiles[$y]['VideoEncoderConfiguration'])) {
- $sources[$i][$inprofile]['encoding']=$profiles[$y]['VideoEncoderConfiguration']['Encoding'];
- $sources[$i][$inprofile]['width']=$profiles[$y]['VideoEncoderConfiguration']['Resolution']['Width'];
- $sources[$i][$inprofile]['height']=$profiles[$y]['VideoEncoderConfiguration']['Resolution']['Height'];
- $sources[$i][$inprofile]['fps']=$profiles[$y]['VideoEncoderConfiguration']['RateControl']['FrameRateLimit'];
- $sources[$i][$inprofile]['bitrate']=$profiles[$y]['VideoEncoderConfiguration']['RateControl']['BitrateLimit'];
- }
- if ( isset($profiles[$y]['PTZConfiguration'])) {
- $sources[$i][$inprofile]['ptz']['name']=$profiles[$y]['PTZConfiguration']['Name'];
- $sources[$i][$inprofile]['ptz']['nodetoken']=$profiles[$y]['PTZConfiguration']['NodeToken'];
- }
- $inprofile++;
- }
- }
-};
-*/
/*
protected function _xml2array($response) {
$sxe = new SimpleXMLElement($response);
@@ -1087,7 +779,7 @@ void * boschRCP::parser(void * obj, void * ptr)
{
memcpy(ME->m_pLastResponse, RQ->getBuffer(), RQ->getSize());
ME->m_pLastResponse[RQ->getSize()] = (char) 0;
-#ifdef DEBUG_ONVIF_TRAFFIC
+#ifdef DEBUG_BRCP_TRAFFIC
FILE * tf;
tf = fopen("Traffic.txt", "a+");
fprintf(tf, "~~~~~~~~~~~~~~~~~~~~\r\n");
@@ -1101,57 +793,48 @@ void * boschRCP::parser(void * obj, void * ptr)
return NULL;
}
-bool boschRCP::_send_request(CSTR url, CSTR post_string, bool mustReturnData)
-{
+bool boschRCP::_send_request(CSTR url, CSTR post_string, bool mustReturnData){
#ifdef CURL_MANAGER
bool RetVal = false;
- if (m_pHttpAccessManager)
- {
+ if (m_pHttpAccessManager){
m_mResponseProtector.lock();
curlRequest * tRC;
tRC = new curlRequest(url, (CSTR) "application/soap+xml; charset=utf-8;");
- if (tRC != NULL)
- {
+ if (tRC != NULL){
#ifdef DEBUG_BRCP_TRAFFIC
FILE * tf;
tf = fopen("Traffic.txt", "a+");
fprintf(tf, "--------------------\r\n");
if ( post_string != NULL ) {
- fprintf(tf, "REQ: %s (%d)\n", url, strlen(post_string));
- fprintf(tf, ">>>>> %s\n", post_string);
+ fprintf( tf, "REQ: %s (%d)\n", url, strlen(post_string));
+ fprintf( tf, ">>>>> %s\n", post_string );
} else fprintf(tf, "REQ: %s\n", url );
+ fprintf(tf,"Creds: [%s]:[%s]\n",m_pUsername, m_pPassword );
fprintf(tf, "--------------------\r\n");
fclose(tf);
mustReturnData = true; // In Debug Allways Read Return
#endif
tRC->setCredentials( m_pUsername, m_pPassword, m_bAuthMode );
- if ( post_string != NULL ) {
+ if( post_string != NULL ){
tRC->setPOST(post_string, strlen(post_string));
- }
- if (mustReturnData)
- {
+ };
+ if (mustReturnData){
tRC->setHandler((void *) this, boschRCP::parser, (void *) tRC );
- if (m_pHttpAccessManager->accomplish(tRC))
- {
+ if( m_pHttpAccessManager->accomplish(tRC) ){
parser_done = false;
uint8_t cnt = 200; // TO = 2 second
- while (! RetVal && cnt--)
- {
+ while (! RetVal && cnt--){
RetVal = parser_done;
SLEEP(10);
};
};
- }
- else
- {
+ } else {
RetVal = m_pHttpAccessManager->accomplish( tRC );
};
- }
- else
- {
+ } else {
LOG_ERROR("Cannot Create curlRequest!");
- }
+ };
m_mResponseProtector.unlock();
};
return RetVal;
diff --git a/lib/data/bosch_rcp/bosch_rcp.h b/lib/data/bosch_rcp/bosch_rcp.h
index 4034174b..4a68bbda 100644
--- a/lib/data/bosch_rcp/bosch_rcp.h
+++ b/lib/data/bosch_rcp/bosch_rcp.h
@@ -20,70 +20,15 @@
#include "../curl/curlRequestsManager.h"
#include "../protocol/xmlParser.h"
-#include "../ponvif/ponvif.h"
-
+#ifndef CURL_MANAGER
+ #define CURL_MANAGER
+#endif
-#define CURL_MANAGER
// #define DEBUG_BRCP_PRINTOUT_MESSAGES
// #define DEBUG_BRCP_TRAFFIC
-
-#define BRCP_PACK_GET_SYS_DTS \
- (CSTR)""
-#define BRCP_PACK_GET_CAPABILITIES \
- (CSTR)"%s%s%s%sAll"
-#define BRCP_PACK_GET_VIDEO_SOURCES \
- (CSTR)"%s%s%s%s"
-#define BRCP_PACK_GET_PROFILES \
- (CSTR)"%s%s%s%s"
-#define BRCP_PACK_GET_SERVICES \
- (CSTR)"%s%s%s%sfalse"
-#define BRCP_PACK_GET_DEV_INFO \
- (CSTR)"%s%s%s%s"
-#define BRCP_PACK_GET_STREAM_URI \
- (CSTR)"%s%s%s%s%s%s%s"
-#define BRCP_PACK_GET_PICTURE_URI \
- (CSTR)"%s%s%s%s%s"
-#define BRCP_PACK_GET_PRESETS \
- (CSTR)"%s%s%s%s%s"
-#define BRCP_PACK_GET_PTZ_NODE \
- (CSTR)"%s%s%s%s%s"
-#define BRCP_PACK_GET_PTZ_STATUS \
- (CSTR)"%s%s%s%s%s"
-#define BRCP_PACK_GOTO_PRESET \
- (CSTR)"%s%s%s%s%s%s"
-#define BRCP_PACK_REMOVE_PRESET \
- (CSTR)"%s%s%s%s%s%s"
-#define BRCP_PACK_SET_PRESET \
- (CSTR)"%s%s%s%s%s%s"
-#define BRCP_PACK_RELATIVE_MOVE \
- (CSTR)"%s%s%s%s%s"
-#define BRCP_PACK_RELATIVE_ZOOM \
- (CSTR)"%s%s%s%s%s"
-#define BRCP_PACK_ABSOLUTE_MOVE \
- (CSTR)"%s%s%s%s%s"
-#define BRCP_PACK_CONTINUOUS_MOVE \
- (CSTR)"%s%s%s%s%s"
-// #define BRCP_PACK_CONTINUOUS_MOVE_A (CSTR)"Profile_1"
-#define BRCP_PACK_CONTINUOUS_ZOOM \
- (CSTR)"%s%s%s%s%s"
-#define BRCP_PACK_PTZ_STOP \
- (CSTR)"%s%s%s%s%struetrue"
-
-#define BRCP_ENVELOPE_EXT \
- (CSTR)"%s%s"
-#define PONVIF_ENVELOPE_SIM (CSTR) "%s%s"
-#define PONVIF_BODY (CSTR) "%s"
-#define BRCP_HEADER_PROBE \
- (CSTR)"uuid:84ede3de-7dec-11d0-c360-f01234567890urn:schemas-xmlsoap-org:ws:2005:04:discoveryhttp://schemas.xmlsoap.org/ws/2005/04/discovery/Probe"
-#define BRCP_HEADER_SECUR \
- (CSTR)"%s%s%s%s"
-
-#define BRCP_PCK_GET_CAPABILITIES (CSTR) "All"
-
-#define BRCP_DEFAULT_URI_TPL (CSTR) "https://%s/rcp.xml"
+#define BRCP_DEFAULT_URI_TPL (CSTR) "http://%s:%s@%s/rcp.xml"
+#define BRCP_DEFAULT_URI_TPL_NA (CSTR) "http://%s/rcp.xml"
#define BRCP_CMD_GET_CAM_NAME 0x0019
#define BRCP_CMD_GET_UNIT_NAME 0x0024
@@ -94,53 +39,36 @@
#define BRCP_CMD_GET_DEV_MANUFAC 0x0d0b
#define BRCP_CMD_GET_DTS 0x0ba8
-
-class boschRCP;
-
-//typedef std::vector videoSourceProfiles;
-//typedef std::vector videoSources;
-//typedef std::vector discoveryResults;
+#define BRCP_CMD_PTZ_DRIVE 0x09A5
class boschRCP{
private:
- curlRequestsManager * m_pHttpAccessManager;
- basicMutex m_mResponseProtector;
- CURL * m_pCURL;
- basicLogCollection * m_pLog;
- CSTR m_pIpAddress;
- CSTR m_pUsername;
- CSTR m_pPassword;
- CSTR m_pDeviceURI;
- int m_pLastIndex;
- CSTR m_pMediaURI;
- CSTR m_pSnapshotURI;
-
- CSTR m_pPTZURI;
- CSTR m_pBaseURI;
-// onvifSupportedVersions m_sOnvifVersion;
+ curlRequestsManager * m_pHttpAccessManager;
+ basicMutex m_mResponseProtector;
+ CURL * m_pCURL;
+ basicLogCollection * m_pLog;
+ CSTR m_pIpAddress;
+ CSTR m_pUsername;
+ CSTR m_pPassword;
+ CSTR m_pDeviceURI;
+ int m_pLastIndex;
+ CSTR m_pBaseURI;
time_t m_nDeltaTime;
-// videoSources m_vVideoSources;
- //videoSourceProfiles m_vVideoProfiles;
- //videoSourceProfiles m_vActiveSources;
- nodeCapability m_sCapabilities;
+
CSTR m_pProxyHost;
int m_nProxyPort;
CSTR m_pProxyUsername;
CSTR m_pProxyPassword;
CSTR m_pLastResponse;
bool m_bIntransingent;
- time_t m_nDiscoveryTimeout;
- CSTR m_pDiscoveryBindIP;
- CSTR m_pDiscoveryMCastIP;
- int m_nDiscoveryMCastPort;
- bool m_bDiscoveryHideDuplicates;
volatile bool parser_done;
uint8_t m_bAuthMode;
#ifndef CURL_MANAGER
- static int _writer(char * data, size_t size, size_t nmemb, pOnvif * Ptr);
+ static int _writer(char * data, size_t size, size_t nmemb, pOnvif * Ptr);
#endif
- static void * parser(void * obj, void * ptr);
- size_t createRequestString( CSTR buffer, uint16_t CMD, bool RW, int8_t pl_type= -1, void *pl = NULL );
+ static void * parser(void * obj, void * ptr);
+ size_t createRequestString( CSTR buffer, uint16_t CMD, bool RW, int8_t pl_type= -1, void *pl = NULL );
+ bool updateDevURI(void);
public:
boschRCP();
@@ -162,58 +90,20 @@ class boschRCP{
bool setDeviceUri(CSTR deviceUri);
CSTR getIPAddress(void);
bool setIPAddress(CSTR ipAddress);
- /*videoSources * getSources(void);
- videoSourceProfiles * getProfiles(void);
- videoSourceProfiles * getActiveProfiles(void);
- CSTR getMediaUri(void);
- CSTR getPTZUri(void);
- CSTR getBaseUrl(void);
- void getSupportedVersion(void);
- nodeCapability * getCapabilities(void);
- bool setBreakOnError(bool intransingent);
- CSTR getLastResponse(void);
- bool setDiscoveryTimeout(int discoverytimeout);
- bool setDiscoveryBindIp(CSTR discoverybindip);
- bool setDiscoveryMcastIp(CSTR discoverymcastip);
- bool setDiscoveryMcastPort(int discoverymcastport);
- bool setDiscoveryHideDuplicates(bool discoveryhideduplicates);
- CSTR getSnapshotUri(void);
-
- discoveryResults discover(void);
- */
- bool create(void);
-
- struct tm * core_GetSystemDateAndTime(void);
- //bool core_GetCapabilities();
- //bool core_GetDeviceInformation();
-
- //bool media_GetVideoSources();
- //bool media_GetProfiles();
- //bool media_GetServices();
- //CSTR media_GetStreamUri(CSTR profileToken, CSTR stream = (CSTR) "RTP-Unicast", CSTR protocol = (CSTR) "RTSP");
- //CSTR media_GetSnapshotUri(CSTR profileToken);
-
- //bool ptz_GetPresets(CSTR profileToken);
- //bool ptz_GetNode(CSTR ptzNodeToken);
- bool ptz_GetStatus(CSTR profileToken, ptzStatus * tStatus);
- //bool ptz_GotoPreset(CSTR profileToken, CSTR presetToken, float speed_pantilt_x, float speed_pantilt_y, float speed_zoom_x);
- //bool ptz_RemovePreset(CSTR profileToken, CSTR presetToken);
- //bool ptz_SetPreset(CSTR profileToken, CSTR presetName);
- bool ptz_RelativeMove(CSTR profileToken, float translation_pantilt_x, float translation_pantilt_y, float speed_pantilt_x, float speed_pantilt_y);
- bool ptz_RelativeMoveZoom(CSTR profileToken, float zoom, float speedZoom);
- bool ptz_AbsoluteMove(CSTR profileToken, float position_pantilt_x, float position_pantilt_y, float zoom);
- bool ptz_ContinuousMove(CSTR profileToken, float velocity_pantilt_x, float velocity_pantilt_y);
- bool ptz_ContinuousMoveZoom(CSTR profileToken, float zoom);
- bool ptz_Stop(CSTR profileToken, bool pantilt, bool zoom);
- /*
- Internal functions
- */
+ bool create(void);
+
+ struct tm * core_GetSystemDateAndTime(void);
+
+ bool ptz_GetStatus( ptzStatus * tStatus );
+ bool ptz_GotoPreset( CSTR presetToken, float speed_pantilt_x, float speed_pantilt_y, float speed_zoom_x );
+ bool ptz_AbsoluteMove( float position_pantilt_x, float position_pantilt_y, float zoom );
+ bool ptz_ContinuousMove( float velocity_pantilt_x, float velocity_pantilt_y );
+ bool ptz_ContinuousMoveZoom( float zoom );
+ bool ptz_RemovePreset( CSTR presetToken );
+ bool ptz_Stop( bool pantilt, bool zoom );
+ bool ptz_SetPreset( CSTR presetName);
private:
- accessToken _makeToken(void);
- //void _getBRCPVersion(nodeCapability & capabilities);
- //void _getActiveSources(videoSourceProfiles & videoSources, videoSourceProfiles profiles);
- //void _getProfileData(videoSourceProfiles & videoSources, videoSourceProfiles profiles);
// protected function _xml2array($response);
accessToken _passwordDigest(CSTR username, CSTR password, time_t timestamp = 0, uint32_t nonce = 0);
bool _send_request(CSTR url, CSTR post_string = NULL, bool mr = true);
diff --git a/lib/data/curl/curlRequest.cpp b/lib/data/curl/curlRequest.cpp
index f5479adc..d6df600e 100644
--- a/lib/data/curl/curlRequest.cpp
+++ b/lib/data/curl/curlRequest.cpp
@@ -166,29 +166,25 @@ void curlRequest::init_CURL()
};
}
-void curlRequest::setCredentials(CSTR user, CSTR password, uint8_t AuthMode)
-{
- if (! strlen(user) || ! strlen(password))
- {
+void curlRequest::setCredentials(CSTR user, CSTR password, uint8_t AuthMode){
+ if (! strlen(user) || ! strlen(password)){
return;
}
- sprintf(m_cUserPassword, "%s:%s", user, password);
- curl_easy_setopt(m_pCURL, CURLOPT_USERPWD, m_cUserPassword);
- switch (AuthMode)
- {
- case 0: curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); break;
+ sprintf( m_cUserPassword, "%s:%s", user, password );
+ curl_easy_setopt( m_pCURL, CURLOPT_USERPWD, m_cUserPassword);
+ switch (AuthMode){
case 1: curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); break;
case 2: curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST_IE); break;
- // case 3: curl_easy_setopt( m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_BEARER ); break; //Does not works on 3D
+ case 3: curl_easy_setopt( m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_BEARER ); break; //Does not works on 3D
case 4: curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_NEGOTIATE); break;
case 5: curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_NTLM); break;
case 6: curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_NTLM_WB); break;
case 7: curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_ANY); break;
case 8: curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_ANYSAFE); break;
- case 9:
- curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_ONLY);
- break;
- // case 10: curl_easy_setopt( m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_AWS_SIGV4 ); break;
+ case 9: curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_ONLY); break;
+ //case 10:curl_easy_setopt( m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_AWS_SIGV4 ); break;
+ default:
+ curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
};
}
@@ -291,3 +287,4 @@ void curlRequest::issue(void)
#undef LOG_ERROR
#undef SLOG
#undef SLOG_ERROR
+
diff --git a/lib/data/ponvif/ponvif.cpp b/lib/data/ponvif/ponvif.cpp
index 773136dd..e546ead8 100644
--- a/lib/data/ponvif/ponvif.cpp
+++ b/lib/data/ponvif/ponvif.cpp
@@ -685,7 +685,7 @@ bool pOnvif::create(void){
return false;
};
// Are we need that all at beginning?
- /*
+
if (! core_GetCapabilities())
{
LOG_ERROR("Error Getting Caps!");
@@ -695,7 +695,6 @@ bool pOnvif::create(void){
// Update some Vars Online!
// preg_match("/^http(.*)onvif\//",$this->mediauri,$matches);
// m_pBaseURI = $matches[0];
-
if (media_GetVideoSources())
{
if (media_GetProfiles())
@@ -705,7 +704,6 @@ bool pOnvif::create(void){
};
};
LOG_ERROR("Error Profiles!");
- */
return true;
}
diff --git a/lib/data/ponvif/ponvif.h b/lib/data/ponvif/ponvif.h
index 2d6ed9ea..511c2eb6 100644
--- a/lib/data/ponvif/ponvif.h
+++ b/lib/data/ponvif/ponvif.h
@@ -22,8 +22,8 @@
#include "../protocol/xmlParser.h"
#define CURL_MANAGER
- #define DEBUG_ONVIF_PRINTOUT_MESSAGES
- #define DEBUG_ONVIF_TRAFFIC
+// #define DEBUG_ONVIF_PRINTOUT_MESSAGES
+// #define DEBUG_ONVIF_TRAFFIC
#define PONVIF_DEFAULT_DISCOVERYBINDIP (CSTR) "0.0.0.0"
#define PONVIF_DEFAULT_DISCOVERYMCASTIP (CSTR) "239.255.255.250"
@@ -87,13 +87,6 @@
#define PONVIF_PCK_GET_CAPABILITIES (CSTR) "All"
-typedef struct S_accessToken
-{
- char USERNAME[CTEXT];
- char PASSDIGEST[CTEXT]; // SHA_DIGEST_LENGTH];
- char NONCE[CTEXT]; // SHA_DIGEST_LENGTH];
- char TIMESTAMP[CTEXT];
-} accessToken;
typedef struct S_videoSourceProfile
{
@@ -476,16 +469,6 @@ typedef struct S_discoveryNodeInfo
char ip_addrs[32];
} discoveryNodeInfo;
-typedef struct S_ptzStatus
-{
- float pan;
- float tilt;
- float zoom;
- bool hasMoveStatus;
- bool PanTiltIdle;
- bool ZoomIdle;
-} ptzStatus;
-
class pOnvif;
typedef std::vector videoSourceProfiles;
diff --git a/lib/data/protocol/protocol.cpp b/lib/data/protocol/protocol.cpp
index c4095e58..67157305 100644
--- a/lib/data/protocol/protocol.cpp
+++ b/lib/data/protocol/protocol.cpp
@@ -198,11 +198,7 @@ bool protocolParser::parse(U8 * Buffer, size_t BufferSize)
// Note: RetVal is NEGATIVE!!??
m_nParserDataCount += RetVal;
memcpy(m_pParserBuffer, m_pParserBuffer - RetVal, m_nParserDataCount);
- // m_nParserDataCount--;
- // if( m_nParserDataCount ) memcpy( m_pParserBuffer, m_pParserBuffer+1, m_nParserDataCount );
- }
- else if (RetVal == 0)
- {
+ } else if (RetVal == 0) {
protocolPackage * tVal = NULL;
tVal = packetExtractor(m_pParserBuffer, m_nParserDataCount);
if (tVal != NULL)
diff --git a/lib/data/protocol/protocolBVMS.cpp b/lib/data/protocol/protocolBVMS.cpp
index 32147733..7a05be0e 100644
--- a/lib/data/protocol/protocolBVMS.cpp
+++ b/lib/data/protocol/protocolBVMS.cpp
@@ -8,27 +8,23 @@
CSTR systemStatusMode[] = {"Operational", "Degraded"};
CSTR systemFaultCode[] = {"Critical", "Warning", "Info"};
-CSTR getSHTimeStamp(void)
-{
+CSTR getSHTimeStamp(void){
CSTR RetVal;
#ifdef __linux__
RetVal = (CSTR) malloc(64);
- if (RetVal != NULL)
- {
+ if (RetVal != NULL){
sprintf(RetVal, "%llu", getTimeValue());
};
#else
RetVal = (CSTR) malloc(64);
- if (RetVal != NULL)
- {
+ if (RetVal != NULL){
sprintf(RetVal, "%I64d", getTimeValue());
};
#endif
return RetVal;
}
-CSTR protocolBVMS::buildURL(CSTR templ, int dim, CSTR devID)
-{
+CSTR protocolBVMS::buildURL(CSTR templ, int dim, CSTR devID){
CSTR RetVal;
char tpl[256];
RetVal = (CSTR) malloc(256);
@@ -37,8 +33,7 @@ CSTR protocolBVMS::buildURL(CSTR templ, int dim, CSTR devID)
return RetVal;
}
-CSTR protocolBVMS::buildUniqID(void)
-{
+CSTR protocolBVMS::buildUniqID(void){
CSTR RetVal;
RetVal = (CSTR) malloc(64);
sprintf(RetVal, "%s", MD5String(getSHTimeStamp()));
diff --git a/lib/data/protocol/protocolLGS2D.cpp b/lib/data/protocol/protocolLGS2D.cpp
index 2fe340ca..03329e49 100644
--- a/lib/data/protocol/protocolLGS2D.cpp
+++ b/lib/data/protocol/protocolLGS2D.cpp
@@ -201,7 +201,11 @@ bool protocolLGS_2D::getVoltage(void)
#ifdef DEBUG_EXTRA
LOG("getVoltage");
#endif
- return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID));
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData( Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID), this );
+#else
+ return m_oDataTransport->sendData( Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::doFullReset(void)
@@ -215,7 +219,11 @@ bool protocolLGS_2D::doFullReset(void)
#ifdef DEBUG_EXTRA
LOG("doFullReset");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::doReset(void)
@@ -229,7 +237,11 @@ bool protocolLGS_2D::doReset(void)
#ifdef DEBUG_EXTRA
LOG("doReset");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::getFullDraw(uint16_t Angle)
@@ -245,7 +257,11 @@ bool protocolLGS_2D::getFullDraw(uint16_t Angle)
#ifdef DEBUG_EXTRA
LOG("getFullDraw");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 6, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 6, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::getFastDraw(uint16_t Angle)
@@ -263,7 +279,11 @@ bool protocolLGS_2D::getFastDraw(uint16_t Angle)
#ifdef DEBUG_EXTRA
LOG("getFastDraw");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 8, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 8, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::getParameters(bool MASTER)
@@ -292,7 +312,11 @@ bool protocolLGS_2D::getParameters(bool MASTER)
LOG("getSlaveParameters");
};
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 5, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 5, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::getRelayParameters(void)
@@ -306,7 +330,11 @@ bool protocolLGS_2D::getRelayParameters(void)
#ifdef DEBUG_EXTRA
LOG("getRelayParameters");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::getShadowPoly(uint8_t sequence, uint16_t PolyID)
@@ -325,7 +353,11 @@ bool protocolLGS_2D::getShadowPoly(uint8_t sequence, uint16_t PolyID)
#ifdef DEBUG_EXTRA
LOG("getShadowPoly");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 9, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 9, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::getShadowPolyPoint(uint8_t sequence, uint16_t PolyID, uint16_t PointID)
@@ -346,7 +378,11 @@ bool protocolLGS_2D::getShadowPolyPoint(uint8_t sequence, uint16_t PolyID, uint1
#ifdef DEBUG_EXTRA
LOG("getShadowPolyPoint");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 11, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 11, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::getShadowStatus(uint8_t MaskID)
@@ -361,7 +397,11 @@ bool protocolLGS_2D::getShadowStatus(uint8_t MaskID)
#ifdef DEBUG_EXTRA
LOG("getShadowStatus"); // CMD_GET_HZ_ENABLE
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 5, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 5, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::getShadowInfo(uint8_t sequence)
@@ -378,7 +418,11 @@ bool protocolLGS_2D::getShadowInfo(uint8_t sequence)
#ifdef DEBUG_EXTRA
LOG("getShadowInfo");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 7, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 7, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::setShadowInfo(uint8_t sequence, SHADOW & SH)
@@ -403,7 +447,11 @@ bool protocolLGS_2D::setShadowInfo(uint8_t sequence, SHADOW & SH)
#ifdef DEBUG_EXTRA
LOG("setShadowInfo");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 15, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 15, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::setShadowPoly(uint8_t sequence, SHADOW & SH, uint16_t PolyID)
@@ -425,7 +473,11 @@ bool protocolLGS_2D::setShadowPoly(uint8_t sequence, SHADOW & SH, uint16_t PolyI
#ifdef DEBUG_EXTRA
LOG("sendShadowPoly");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 12, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 12, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::setShadowPolyPoint(uint8_t sequence, SHADOW & SH, uint16_t PolyID, uint16_t PointID)
@@ -450,7 +502,11 @@ bool protocolLGS_2D::setShadowPolyPoint(uint8_t sequence, SHADOW & SH, uint16_t
#ifdef DEBUG_EXTRA
LOG("sendShadowPolyPoint");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 15, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 15, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::setShadowRay(uint8_t sequence, SHADOW & SH, uint16_t RLID)
@@ -471,7 +527,11 @@ bool protocolLGS_2D::setShadowRay(uint8_t sequence, SHADOW & SH, uint16_t RLID)
#ifdef DEBUG_EXTRA
LOG("setShadowRayLine");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 11, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 11, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::setShadowRayLine(uint8_t sequence, SHADOW & SH, uint16_t RLID, uint16_t RayID)
@@ -500,7 +560,11 @@ bool protocolLGS_2D::setShadowRayLine(uint8_t sequence, SHADOW & SH, uint16_t RL
#ifdef DEBUG_EXTRA
LOG("setShadowRay");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 16, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 16, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::setShadowDone(uint8_t sequence)
@@ -517,7 +581,11 @@ bool protocolLGS_2D::setShadowDone(uint8_t sequence)
#ifdef DEBUG
LOG("setShadowDone");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 7, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 7, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::getState(void)
@@ -531,7 +599,11 @@ bool protocolLGS_2D::getState(void)
#ifdef DEBUG_EXTRA
LOG("getState");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::getState2(void)
@@ -550,7 +622,11 @@ bool protocolLGS_2D::getState2(void)
#ifdef DEBUG_EXTRA
LOG("getState2");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 5, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 5, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::getWidthTable()
@@ -564,7 +640,11 @@ bool protocolLGS_2D::getWidthTable()
#ifdef DEBUG_EXTRA
LOG("getWidthTable");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::setMode(U8 Mode)
@@ -579,7 +659,11 @@ bool protocolLGS_2D::setMode(U8 Mode)
#ifdef DEBUG_EXTRA
LOG("setMode");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 5, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 5, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::getMode(void)
@@ -594,7 +678,11 @@ bool protocolLGS_2D::getMode(void)
#ifdef DEBUG_EXTRA
LOG("getMode");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 5, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 5, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::setShadowStatus(uint8_t Mask)
@@ -612,7 +700,11 @@ bool protocolLGS_2D::setShadowStatus(uint8_t Mask)
#ifdef DEBUG_EXTRA
LOG("setShadowStatus");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 8, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 8, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::setWidthTable(PWIDTH_TABLE pWidthTable)
@@ -633,7 +725,11 @@ bool protocolLGS_2D::setWidthTable(PWIDTH_TABLE pWidthTable)
#ifdef DEBUG
LOG("setWidthTable");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, idx, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, idx, m_bDeviceID));
+#endif
}
/*
@@ -667,8 +763,12 @@ bool protocolLGS_2D::setShadowTrace( vectorZoneMask *VM ){
};
#ifdef DEBUG
LOG("setShadowTrace");
+#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, counter, m_bDeviceID ), this );
+#else
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, counter, m_bDeviceID ) );
#endif
- return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, counter, m_bDeviceID ) );
};
*/
bool protocolLGS_2D::setComSpeed(uint32_t spd)
@@ -686,7 +786,11 @@ bool protocolLGS_2D::setComSpeed(uint32_t spd)
#ifdef DEBUG_EXTRA
LOG("setComSpeed");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 8, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 8, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::setDeviceAddress(uint8_t DeviceID, CSTR Serial)
@@ -709,12 +813,20 @@ bool protocolLGS_2D::setDeviceAddress(uint8_t DeviceID, CSTR Serial)
{
Buffer[6 + i] = Serial[i];
};
+ #ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 6 + len, m_bDeviceID), this );
+ #else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 6 + len, m_bDeviceID));
+ #endif
}
else
{
Buffer[5] = 0;
+ #ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 6, m_bDeviceID), this );
+ #else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 6, m_bDeviceID));
+ #endif
};
}
@@ -730,7 +842,11 @@ bool protocolLGS_2D::setDetectionProfile(uint8_t profile)
#ifdef DEBUG_EXTRA
LOG("setDetectionProfile");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 5, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 5, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::setParameters(PLGS_2D_PARAMETERS ptr, bool MASTER, uint8_t profile)
@@ -766,7 +882,11 @@ bool protocolLGS_2D::setParameters(PLGS_2D_PARAMETERS ptr, bool MASTER, uint8_t
#ifdef DEBUG_EXTRA
LOG("setParameters");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 18, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 18, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::setRelayParameters(PRELAY_PARAMETERS ptr)
@@ -784,7 +904,11 @@ bool protocolLGS_2D::setRelayParameters(PRELAY_PARAMETERS ptr)
#ifdef DEBUG_EXTRA
LOG("setParameters");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 8, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 8, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::getSerialNumber(void)
@@ -798,7 +922,11 @@ bool protocolLGS_2D::getSerialNumber(void)
#ifdef DEBUG_EXTRA
LOG("getSerialNumber");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::getVersionString(void)
@@ -812,7 +940,11 @@ bool protocolLGS_2D::getVersionString(void)
#ifdef DEBUG_EXTRA
LOG("getVersionString");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::getDetectionProfile(void)
@@ -826,7 +958,11 @@ bool protocolLGS_2D::getDetectionProfile(void)
#ifdef DEBUG_EXTRA
LOG("getDetectionProfile");
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, 4, m_bDeviceID));
+#endif
}
bool protocolLGS_2D::sendFS_package(PFS_DATA pFSData)
@@ -886,7 +1022,12 @@ bool protocolLGS_2D::sendFS_package(PFS_DATA pFSData)
LOG(tT);
};
#endif
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, nCount, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, nCount, m_bDeviceID));
+#endif
+
}
bool protocolLGS_2D::sendGF_package(uint8_t CMD, uint8_t cnt, uint8_t * Data)
@@ -914,8 +1055,11 @@ bool protocolLGS_2D::sendGF_package(uint8_t CMD, uint8_t cnt, uint8_t * Data)
Buffer[DATA_BEGIN_IDX + 1 + i] = Data[i];
}
#endif
-
+#ifdef SERIAL_PING_PONG
+ return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, DATA_BEGIN_IDX + 1 + cnt, m_bDeviceID), this );
+#else
return m_oDataTransport->sendData(Buffer, FinishUpPackage(Buffer, DATA_BEGIN_IDX + 1 + cnt, m_bDeviceID));
+#endif
}
#undef SIZE_IDX
diff --git a/lib/data/protocol/protocolPTZ.h b/lib/data/protocol/protocolPTZ.h
index 41814999..677df7f6 100644
--- a/lib/data/protocol/protocolPTZ.h
+++ b/lib/data/protocol/protocolPTZ.h
@@ -37,7 +37,8 @@ typedef enum E_PTZ_CAMERA_PROTOCOL_TYPE
PTZ_PROTO_NONE = 0,
PTZ_PROTO_VISCA = 1,
PTZ_PROTO_PELCO = 2,
- PTZ_PROTO_ONVIF = 3
+ PTZ_PROTO_ONVIF = 3,
+ PTZ_PROTO_BRCP = 4
} PTZ_CAMERA_PROTOCOL_TYPE;
enum CAM_WB_MODE
diff --git a/lib/data/protocol/protocolPTZ_BRCP.cpp b/lib/data/protocol/protocolPTZ_BRCP.cpp
index bf957940..93240807 100644
--- a/lib/data/protocol/protocolPTZ_BRCP.cpp
+++ b/lib/data/protocol/protocolPTZ_BRCP.cpp
@@ -14,7 +14,6 @@ protocolPTZ_BRCP::protocolPTZ_BRCP(config_setting_t * Settings) :
m_pSettings = Settings;
m_bAuthMode = 0;
m_pBRCP = NULL;
- m_pProfile = NULL;
memset(m_pDeviceURI, 0, MAX_PATH_LEN);
memset(m_pUser, 0, MAX_CRED_LEN);
memset(m_pPassword, 0, MAX_CRED_LEN);
@@ -28,23 +27,21 @@ protocolPTZ_BRCP::protocolPTZ_BRCP(CSTR ip, uint16_t port, CSTR username, CSTR p
m_bLastCommandIssued = CMD_PTZ_NOOP;
m_pSettings = NULL;
m_pBRCP = NULL;
- m_pProfile = NULL;
LOG(ip);
LOG(username);
LOG(password);
m_bAuthMode = AuthMode;
- sprintf(m_pDeviceURI, "Auth Mode: [%d]", m_bAuthMode);
- LOG(m_pDeviceURI);
- if (port == 80)
- {
- sprintf(m_pDeviceURI, "http://%s/onvif/device_service", ip);
- }
- else
- {
- sprintf(m_pDeviceURI, "http://%s:%d/onvif/device_service", ip, port);
- }
- LOG(m_pDeviceURI);
+ sprintf(m_pDeviceURI, "M Auth Mode: [%d]", m_bAuthMode);
+ LOG( m_pDeviceURI );
+ if (port == 80){
+ sprintf(m_pDeviceURI, "%s", ip );
+ } else {
+ sprintf(m_pDeviceURI, "%s:%d", ip, port );
+ };
+ LOG( m_pDeviceURI );
+ memset( m_pUser, 0, MAX_CRED_LEN);
strncpy(m_pUser, username, MAX_CRED_LEN);
+ memset( m_pPassword, 0, MAX_CRED_LEN);
strncpy(m_pPassword, password, MAX_CRED_LEN);
}
@@ -56,16 +53,15 @@ protocolPTZ_BRCP::protocolPTZ_BRCP(CSTR ctl_url, CSTR username, CSTR password, u
m_bLastCommandIssued = CMD_PTZ_NOOP;
m_pSettings = NULL;
m_pBRCP = NULL;
- m_pProfile = NULL;
LOG(ctl_url);
LOG(username);
LOG(password);
m_bAuthMode = AuthMode;
- sprintf(m_pDeviceURI, "Auth Mode: [%d]", m_bAuthMode);
- LOG(m_pDeviceURI);
- strncpy(m_pDeviceURI, ctl_url, 250);
- strncpy(m_pUser, username, MAX_CRED_LEN);
- strncpy(m_pPassword, password, MAX_CRED_LEN);
+ sprintf(m_pDeviceURI, "Ex Auth Mode: [%d]", m_bAuthMode);
+ LOG( m_pDeviceURI );
+ strncpy( m_pDeviceURI, ctl_url, MAX_CRED_LEN );
+ strncpy( m_pUser, username, MAX_CRED_LEN);
+ strncpy( m_pPassword, password, MAX_CRED_LEN);
}
protocolPTZ_BRCP::~protocolPTZ_BRCP(){
@@ -74,94 +70,56 @@ protocolPTZ_BRCP::~protocolPTZ_BRCP(){
};
}
-bool protocolPTZ_BRCP::setIPAddress(CSTR ip)
-{
- if (ip == NULL)
- {
- return false;
- }
- if (strlen(ip) == 0)
- {
- return false;
- }
+bool protocolPTZ_BRCP::setIPAddress(CSTR ip){
+ if (ip == NULL) return false;
+ if (strlen(ip) == 0) return false;
sprintf(m_pDeviceURI, "http://%s/onvif/device_service", ip);
// strncpy( m_pDeviceURI, ip, MAX_PATH_LEN );
return true;
}
-bool protocolPTZ_BRCP::setUsername(CSTR username)
-{
- if (username == NULL)
- {
- return false;
- }
- if (strlen(username) == 0)
- {
- return false;
- }
+bool protocolPTZ_BRCP::setUsername(CSTR username){
+ if (username == NULL) return false;
+ if (strlen(username) == 0) return false;
strncpy(m_pUser, username, MAX_CRED_LEN);
return true;
}
-bool protocolPTZ_BRCP::setPassword(CSTR password)
-{
- if (password == NULL)
- {
- return false;
- }
- if (strlen(password) == 0)
- {
- return false;
- }
+bool protocolPTZ_BRCP::setPassword(CSTR password){
+ if (password == NULL) return false;
+ if (strlen(password) == 0) return false;
strncpy(m_pPassword, password, MAX_CRED_LEN);
return true;
}
-bool protocolPTZ_BRCP::setAuthMode(uint8_t Mode)
-{
+bool protocolPTZ_BRCP::setAuthMode(uint8_t Mode){
m_bAuthMode = Mode;
return true;
}
-bool protocolPTZ_BRCP::create(void)
-{
- if (! protocolPTZ::create())
- {
- return false;
- }
- if (m_pSettings != NULL)
- {
+bool protocolPTZ_BRCP::create(void){
+ if (! protocolPTZ::create()) return false;
+ if (m_pSettings != NULL){
config_setting_t * pSetting;
pSetting = config_setting_get_member(m_pSettings, PPTZ_TAG_ONVIF_USER);
- if (pSetting == NULL)
- {
- return false;
- }
+ if (pSetting == NULL) return false;
sprintf(m_pUser, "%s", config_setting_get_string(pSetting));
pSetting = config_setting_get_member(m_pSettings, PPTZ_TAG_ONVIF_PASS);
- if (pSetting == NULL)
- {
- return false;
- }
+ if (pSetting == NULL) return false;
sprintf(m_pPassword, "%s", config_setting_get_string(pSetting));
pSetting = config_setting_get_member(m_pSettings, PPTZ_TAG_ONVIF_DEV_URI);
- if (pSetting == NULL)
- {
- return false;
- }
+ if (pSetting == NULL) return false;
sprintf(m_pDeviceURI, "%s", config_setting_get_string(pSetting));
};
#ifdef DEBUG
LOG(m_pDeviceURI);
#endif
- if (strlen(m_pDeviceURI) < 4)
- {
+ if( strlen(m_pDeviceURI) < 4 ){
LOG_ERROR("No Device URI Is Set!");
return false;
};
m_pBRCP = new boschRCP();
- if (m_pBRCP == NULL)
- {
+ if( m_pBRCP == NULL ){
LOG_ERROR("boschRCP NEW FAILURE!");
m_bStatus = 0;
return false;
@@ -171,14 +129,12 @@ bool protocolPTZ_BRCP::create(void)
m_pBRCP->setPassword(m_pPassword);
m_pBRCP->setAuthMode(m_bAuthMode);
LOG("PROTOCREATE");
- if (m_pBRCP->create())
- {
- //m_pProfile = m_pBRCP->getProfiles()->at(0);
+ if( m_pBRCP->create() ){
LOG("DONE");
m_bStatus = 1;
return true;
} else {
- LOG_ERROR("boschRCP CREATE FAILURE!");
+ LOG_ERROR("bosch RCP+ CREATE FAILURE!");
delete(m_pBRCP);
m_pBRCP = NULL;
m_bStatus = 0;
@@ -189,10 +145,6 @@ bool protocolPTZ_BRCP::create(void)
bool protocolPTZ_BRCP::move(uint32_t MoveMatrix)
{
// if( m_bStatus == 0 ) return false;
- if (m_pProfile == NULL)
- {
- return false;
- }
// if (m_bReplyRequired) if (m_bLastCommandIssued != CMD_PTZ_NOOP) return false;
float Speed_x, Speed_y, Speed_z;
if (MoveMatrix > 0)
@@ -236,111 +188,77 @@ bool protocolPTZ_BRCP::move(uint32_t MoveMatrix)
bool res = true;
if ((MoveMatrix & (PTZ_DRIVE_PAN_MASK | PTZ_DRIVE_TILT_MASK)) != 0)
{
- res = m_pBRCP->ptz_ContinuousMove(m_pProfile->profiletoken, Speed_x, Speed_y);
+ res = m_pBRCP->ptz_ContinuousMove( Speed_x, Speed_y);
};
if (res)
{
if ((MoveMatrix & PTZ_DRIVE_ZOOM_MASK) != 0)
{
- res = m_pBRCP->ptz_ContinuousMoveZoom(m_pProfile->profiletoken, Speed_z);
+ res = m_pBRCP->ptz_ContinuousMoveZoom( Speed_z );
};
};
m_bStatus = (res) ? 1 : 0;
- }
- else
- {
+ } else {
- m_bStatus = (m_pBRCP->ptz_Stop(m_pProfile->profiletoken, true, true)) ? 1 : 0;
+ m_bStatus = (m_pBRCP->ptz_Stop( true, true )) ? 1 : 0;
};
return (m_bStatus > 0);
}
#include
-bool protocolPTZ_BRCP::waitMoveIsDone(void)
-{
+bool protocolPTZ_BRCP::waitMoveIsDone( void ){
ptzStatus tVal;
uint8_t TO = 12; // 3.6 second max
- while (m_pBRCP->ptz_GetStatus(m_pProfile->profiletoken, &tVal) && TO)
- {
- if (tVal.hasMoveStatus)
- {
- if (tVal.PanTiltIdle && tVal.ZoomIdle)
- {
+ while( m_pBRCP->ptz_GetStatus( &tVal ) && TO ){
+ if( tVal.hasMoveStatus ){
+ if( tVal.PanTiltIdle && tVal.ZoomIdle ){
break;
}
- }
- else
- {
- // if( ( fabs(tVal.pan - dPan) < 0.0005 ) && ( fabs( tVal.tilt - dTilt) < 0.0005 ) ) break;//&& ( fabs( tVal.zoom - dZoom ) < 0.05 ) ) break;
+ } else {
+ if( ( fabs(tVal.pan - m_dPan) < 0.0005 ) && ( fabs( tVal.tilt - m_dTilt) < 0.0005 ) ) break;
+ //&& ( fabs( tVal.zoom - m_dZoom ) < 0.05 ) ) break;
};
SLEEP(333);
TO--;
};
- if (TO)
- {
+ if( TO ){
#ifdef DEBUG_EXTRA
LOG("Finished Move!");
#endif
return true;
#ifdef DEBUG_EXTRA
- }
- else
- {
+ } else {
LOG_ERROR("Error Fetching PTZ Status!");
#endif
};
return false;
}
-bool protocolPTZ_BRCP::goAbsolute(float dPan, float dTilt, float dZoom)
-{
- // if (m_bStatus == 0) return false;
+bool protocolPTZ_BRCP::goAbsolute(float dPan, float dTilt, float dZoom){
#ifdef DEBUG_EXTRA
- LOG("ABS Move");
+ LOG("ABS Move");
#endif
- if (m_pProfile == NULL)
- {
- LOG_ERROR("No PTZ Profile!!");
- return false;
- };
- if (dZoom < 0.0f)
- {
- dZoom = 0.0f;
- }
-
- if (m_pBRCP->ptz_AbsoluteMove(m_pProfile->profiletoken, dPan, dTilt, dZoom))
- {
- };
- return true;
+ if (dZoom < 0.0f) dZoom = 0.0f;
+ return m_pBRCP->ptz_AbsoluteMove(dPan, dTilt, dZoom);
}
-bool protocolPTZ_BRCP::getCameraPresets(void)
-{
- LOG("GET PRESETS!");
- return false;//m_pBRCP->ptz_GetPresets(m_pProfile->profiletoken);
+bool protocolPTZ_BRCP::getCameraPresets(void){
+ return false;
}
-bool protocolPTZ_BRCP::goPreset(char * PresetToken)
-{
- // if (m_bStatus == 0) return false;
- #ifdef DEBUG_EXTRA
+bool protocolPTZ_BRCP::goPreset(char * PresetToken){
+
+#ifdef DEBUG_EXTRA
LOG("Preset Move");
- #endif
- if (m_pProfile == NULL)
- {
- LOG_ERROR("No PTZ Profile!!");
- return false;
- };
- //if (! m_pBRCP->ptz_GotoPreset(m_pProfile->profiletoken, PresetToken, 1.0f, 1.0f, 1.0f))
- //{
- // m_bStatus = 0;
- //}
+#endif
+ if( !m_pBRCP->ptz_GotoPreset( PresetToken, 1.0f, 1.0f, 1.0f )){
+ m_bStatus = 0;
+ }
return (m_bStatus > 0);
}
-bool protocolPTZ_BRCP::validate()
-{
+bool protocolPTZ_BRCP::validate(){
return (m_bStatus > 0);
}
diff --git a/lib/data/protocol/protocolPTZ_BRCP.h b/lib/data/protocol/protocolPTZ_BRCP.h
index 1ff919ba..adc9109c 100644
--- a/lib/data/protocol/protocolPTZ_BRCP.h
+++ b/lib/data/protocol/protocolPTZ_BRCP.h
@@ -12,11 +12,12 @@ class protocolPTZ_BRCP : public protocolPTZ
basicLogCollection * m_pLog;
char m_pUser[MAX_CRED_LEN];
+ char m_pIP[MAX_CRED_LEN];
char m_pPassword[MAX_CRED_LEN];
char m_pDeviceURI[MAX_PATH_LEN];
+ uint16_t m_nPort;
uint8_t m_bAuthMode;
boschRCP * m_pBRCP;
- videoSourceProfile * m_pProfile;
config_setting_t * m_pSettings;
basicMutex m_mInquiryMutex;