SET(PROJECT_ROOT_DIR "${CMAKE_SOURCE_DIR}")
SET(PROJECT_RESOURCES_DIR "${PROJECT_ROOT_DIR}/res")
-INCLUDE(FindPkgConfig)
-pkg_check_modules(APP_PKGS REQUIRED
+#disable web notify
+#SET(PF_TYPE "Zarie-web")
+
+MESSAGE("position-finder-server type: ${PF_TYPE}")
+
+SET(CHECK_MODULES
dlog
- aul
capi-appfw-application
capi-appfw-service-application
capi-system-peripheral-io
ecore
- eina
iotcon
- gio-2.0
)
+IF("${PF_TYPE}" STREQUAL "Zarie-web")
+ SET(CHECK_MODULES ${CHECK_MODULES}
+ libcurl
+ glib-2.0
+ )
+ADD_DEFINITIONS (-DENABLE_WEBNOTIFY
+ -DTEST_RES_URI=\"http://10.113.63.43:8080\"
+)
+ENDIF("${PF_TYPE}" STREQUAL "Zarie-web")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(APP_PKGS REQUIRED ${CHECK_MODULES})
+
FOREACH (flag ${APP_PKGS_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
INCLUDE_DIRECTORIES(${PROJECT_ROOT_DIR}/inc)
-ADD_EXECUTABLE(${PROJECT_NAME}
+SET(SRCS
${PROJECT_ROOT_DIR}/src/controller.c
${PROJECT_ROOT_DIR}/src/controller_internal.c
${PROJECT_ROOT_DIR}/src/connectivity.c
${PROJECT_ROOT_DIR}/src/resource/resource_touch_sensor.c
${PROJECT_ROOT_DIR}/src/resource/resource_ultrasonic_sensor.c
)
-#${PROJECT_ROOT_DIR}/src/connectivity.c
+
+IF("${PF_TYPE}" STREQUAL "Zarie-web")
+ SET(SRCS ${SRCS} ${PROJECT_ROOT_DIR}/src/webnotify.c)
+ENDIF("${PF_TYPE}" STREQUAL "Zarie-web")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS} )
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -lm)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${APP_PKGS_LDFLAGS})
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ * Jeonghoon Park <jh1979.park@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __POSITION_FINDER_WEBNOTIFY_H__
+#define __POSITION_FINDER_WEBNOTIFY_H__
+
+int web_notify_init(void);
+void web_notify_fini(void);
+int web_notify_data(const char *resource, const char *data);
+int web_notify_bool(const char *resource, bool value);
+int web_notify_int(const char *resource, int value);
+int web_notify_double(const char *resource, double value);
+
+#endif /* __POSITION_FINDER_WEBNOTIFY_H__ */
+
BuildRequires: hash-signer
BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(capi-appfw-service-application)
BuildRequires: pkgconfig(capi-system-peripheral-io)
BuildRequires: pkgconfig(ecore)
-BuildRequires: pkgconfig(eina)
BuildRequires: pkgconfig(iotcon)
-BuildRequires: pkgconfig(gio-2.0)
+BuildRequires: pkgconfig(libcurl)
+BuildRequires: pkgconfig(glib-2.0)
%description
Server for Position Finder
* Geunsun Lee <gs86.lee@samsung.com>
* Eunyoung Lee <ey928.lee@samsung.com>
* Junkyu Han <junkyu.han@samsung.com>
+ * Jeonghoon Park <jh1979.park@samsung.com>
*
* Licensed under the Flora License, Version 1.1 (the License);
* you may not use this file except in compliance with the License.
#include "connectivity.h"
#include "controller.h"
+#ifdef ENABLE_WEBNOTIFY
+#include "webnotify.h"
+#ifndef RESOURCE_URI
+#define RESOURCE_URI TEST_RES_URI
+#endif /* RESOURCE_URI */
+#endif /* ENABLE_WEBNOTIFY */
+
#define GPIO_ULTRASONIC_TRIG_NUM_1 20
#define GPIO_ULTRASONIC_ECHO_NUM_1 21
#define MULTIPLE_SENSOR_NUMBER 5
if (connectivity_notify_bool(ad->resource_info, CONNECTIVITY_KEY, total) == -1)
_E("Cannot notify message");
+#ifdef ENABLE_WEBNOTIFY
+ if (web_notify_bool(RESOURCE_URI, total) == -1)
+ _E("Cannot notify web message");
+#endif /* ENABLE_WEBNOTIFY */
+
return ECORE_CALLBACK_RENEW;
}
* Geunsun Lee <gs86.lee@samsung.com>
* Eunyoung Lee <ey928.lee@samsung.com>
* Junkyu Han <junkyu.han@samsung.com>
+ * Jeonghoon Park <jh1979.park@samsung.com>
*
* Licensed under the Flora License, Version 1.1 (the License);
* you may not use this file except in compliance with the License.
#include "log.h"
#include "connectivity.h"
#include "resource.h"
+#ifdef ENABLE_WEBNOTIFY
+#include "webnotify.h"
+#endif /* ENABLE_WEBNOTIFY */
+
void controller_init_internal_functions(void)
{
connectivity_init();
+#ifdef ENABLE_WEBNOTIFY
+ web_notify_init();
+#endif /* ENABLE_WEBNOTIFY */
}
void controller_fini_internal_functions(void)
_I("Terminating...");
resource_close_all();
connectivity_fini();
+#ifdef ENABLE_WEBNOTIFY
+ web_notify_fini();
+#endif /* ENABLE_WEBNOTIFY */
}
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ * Jeonghoon Park <jh1979.park@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdbool.h>
+#include <glib.h>
+#include <curl/curl.h>
+#include "log.h"
+
+static int _web_notify(const char *resource, const char *data)
+{
+ CURL *curl;
+ CURLcode response;
+ curl = curl_easy_init();
+ int ret = 0;
+
+ if(!curl) {
+ _E("fail to init curl");
+ return -1;
+ }
+
+ curl_easy_setopt(curl, CURLOPT_URL, resource);
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
+
+ response = curl_easy_perform(curl);
+
+ if(response != CURLE_OK) {
+ _E("curl_easy_perform() failed: %s",
+ curl_easy_strerror(response));
+ ret = -1;
+ }
+
+ curl_easy_cleanup(curl);
+
+ return ret;
+}
+
+int web_notify_init(void)
+{
+ int ret = 0;
+ CURLcode result;
+ result = curl_global_init(CURL_GLOBAL_DEFAULT);
+ if(result != CURLE_OK) {
+ _E("curl_global_init() failed: %s",
+ curl_easy_strerror(result));
+ ret = -1;
+ }
+ return ret;
+}
+
+void web_notify_fini(void)
+{
+ curl_global_cleanup();
+ return;
+}
+
+int web_notify_data(const char *resource, const char *data)
+{
+ return _web_notify(resource, data);
+}
+
+int web_notify_bool(const char *resource, bool value)
+{
+ int ret = 0;
+
+ _D("Notify to %s - value[%d]", resource, value);
+
+ if(value)
+ ret = _web_notify(resource, "TRUE");
+ else
+ ret = _web_notify(resource, "FALSE");
+
+ return ret;
+}
+
+int web_notify_int(const char *resource, int value)
+{
+ int ret = 0;
+ char *data = NULL;
+
+ data = g_strdup_printf("%d", value);
+ retv_if(NULL == data, -1);
+
+ ret = _web_notify(resource, data);
+ g_free(data);
+
+ return ret;
+}
+
+int web_notify_double(const char *resource, double value)
+{
+ int ret = 0;
+ char *data = NULL;
+
+ data = g_strdup_printf("%lf", value);
+ retv_if(NULL == data, -1);
+
+ ret = _web_notify(resource, data);
+ g_free(data);
+
+ return ret;
+}