summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt5
-rw-r--r--packaging/org.tizen.position-finder-server.spec8
-rw-r--r--src/connectivity.c45
-rw-r--r--src/controller.c6
-rw-r--r--src/resource/resource_infrared_motion_sensor.c2
5 files changed, 55 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 91e1717..b70de1b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,7 +3,7 @@ PROJECT(position-finder-server C)
SET(INSTALL_EXEC_PREFIX "${INSTALL_PREFIX}/bin")
SET(INSTALL_RESDIR "${INSTALL_PREFIX}/res")
-SET(INSTALL_DATADIR "/home/owner/apps_rw/org.tizen.position-finder-server/data")
+SET(INSTALL_RESDIR "/home/owner/apps_rw/org.tizen.position-finder-server/res")
SET(CMAKE_VERBOSE_MAKEFILE 0)
SET(PROJECT_ROOT_DIR "${CMAKE_SOURCE_DIR}")
@@ -43,7 +43,6 @@ ADD_EXECUTABLE(${PROJECT_NAME}
${PROJECT_ROOT_DIR}/src/resource/resource_touch_sensor.c
${PROJECT_ROOT_DIR}/src/resource/resource_ultrasonic_sensor.c
)
-#${PROJECT_ROOT_DIR}/src/connectivity.c
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -lm)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${APP_PKGS_LDFLAGS})
@@ -54,6 +53,6 @@ INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${INSTALL_EXEC_PREFIX})
INSTALL(FILES ${PROJECT_ROOT_DIR}/tizen-manifest.xml DESTINATION ${SYS_PACKAGES_DIR} RENAME org.tizen.position-finder-server.xml)
INSTALL(DIRECTORY DESTINATION ${PREFIX}/data)
INSTALL(FILES ${PROJECT_ROOT_DIR}/shared/res/position_finder_server.png DESTINATION ${SYS_ICONS_DIR})
-INSTALL(FILES ${PROJECT_ROOT_DIR}/res/iotcon-test-svr-db-server.dat DESTINATION ${INSTALL_DATADIR})
+INSTALL(FILES ${PROJECT_ROOT_DIR}/res/iotcon-test-svr-db-server.dat DESTINATION ${INSTALL_RESDIR})
# End of a file
diff --git a/packaging/org.tizen.position-finder-server.spec b/packaging/org.tizen.position-finder-server.spec
index 12e6acd..1bb7a67 100644
--- a/packaging/org.tizen.position-finder-server.spec
+++ b/packaging/org.tizen.position-finder-server.spec
@@ -31,6 +31,7 @@ Server for Position Finder
%define _pkg_dir %{TZ_SYS_RO_APP}/%{alias}
%define _pkg_shared_dir %{_pkg_dir}/shared
%define _pkg_data_dir %{_pkg_dir}/data
+%define _pkg_rw_res_dir /home/owner/apps_rw/org.tizen.position-finder-server/res
%define _pkg_rw_data_dir /home/owner/apps_rw/org.tizen.position-finder-server/data
%define _sys_icons_dir %{_pkg_shared_dir}/res
%define _sys_packages_dir %{TZ_SYS_RO_PACKAGES}
@@ -63,6 +64,10 @@ make %{?jobs:-j%jobs}
%post
/sbin/ldconfig
+chsmack -a "User::Pkg::org.tizen.position-finder-server" %{_pkg_rw_res_dir}/*.dat
+chmod 666 %{_pkg_rw_res_dir}/*.dat
+
+touch %{_pkg_rw_data_dir}/*.dat
chsmack -a "User::Pkg::org.tizen.position-finder-server" %{_pkg_rw_data_dir}/*.dat
chmod 666 %{_pkg_rw_data_dir}/*.dat
@@ -70,8 +75,7 @@ chmod 666 %{_pkg_rw_data_dir}/*.dat
%files
%manifest org.tizen.position-finder-server.manifest
-%{_pkg_rw_data_dir}/*.dat
-/home/owner/apps_rw/org.tizen.position-finder-server/data/iotcon-test-svr-db-server.dat
+%{_pkg_rw_res_dir}/*.dat
%defattr(-,root,root,-)
%{_pkg_dir}/bin/position-finder-server
%{_sys_packages_dir}/org.tizen.position-finder-server.xml
diff --git a/src/connectivity.c b/src/connectivity.c
index eb281f1..9165cb9 100644
--- a/src/connectivity.c
+++ b/src/connectivity.c
@@ -19,6 +19,7 @@
* limitations under the License.
*/
+#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <glib.h>
@@ -32,6 +33,9 @@
#define ULTRASONIC_RESOURCE_1_URI "/door/1"
#define ULTRASONIC_RESOURCE_2_URI "/door/2"
#define ULTRASONIC_RESOURCE_TYPE "org.tizen.door"
+#define BUFSIZE 1024
+#define CBOR_FILE_IN_RES "/home/owner/apps_rw/org.tizen.position-finder-server/res/iotcon-test-svr-db-server.dat"
+#define CBOR_FILE_IN_DATA "/home/owner/apps_rw/org.tizen.position-finder-server/data/iotcon-test-svr-db-server.dat"
static void _request_resource_handler(iotcon_resource_h resource, iotcon_request_h request, void *user_data);
@@ -302,12 +306,16 @@ static int _handle_observer(iotcon_request_h request, iotcon_observers_h observe
ret = iotcon_request_get_observe_id(request, &observe_id);
retv_if(IOTCON_ERROR_NONE != ret, -1);
+ _I("Add an observer : %d", observe_id);
+
ret = iotcon_observers_add(observers, observe_id);
retv_if(IOTCON_ERROR_NONE != ret, -1);
} else if (IOTCON_OBSERVE_DEREGISTER == observe_type) {
ret = iotcon_request_get_observe_id(request, &observe_id);
retv_if(IOTCON_ERROR_NONE != ret, -1);
+ _I("Remove an observer : %d", observe_id);
+
ret = iotcon_observers_remove(observers, observe_id);
retv_if(IOTCON_ERROR_NONE != ret, -1);
}
@@ -343,11 +351,46 @@ error:
_send_response(request, NULL, IOTCON_RESPONSE_ERROR);
}
+static void _copy_file(const char *in_filename, const char *out_filename)
+{
+ char buf[BUFSIZE] = { 0, };
+ size_t nread = 0;
+ FILE *in = NULL;
+ FILE *out = NULL;
+
+ ret_if(!in_filename);
+ ret_if(!out_filename);
+
+ in = fopen(in_filename, "r");
+ ret_if(!in);
+
+ out = fopen(out_filename, "w");
+ goto_if(!out, error);
+
+ rewind(in);
+ while ((nread = fread(buf, 1, sizeof(buf), in)) > 0) {
+ if (fwrite (buf, 1, nread, out) < nread) {
+ _E("critical error to copy a file");
+ break;
+ }
+ }
+
+ fclose(in);
+ fclose(out);
+
+ return;
+
+error:
+ fclose(out);
+}
+
int connectivity_init(void)
{
int ret = -1;
- ret = iotcon_initialize("/home/owner/apps_rw/org.tizen.position-finder-server/data/iotcon-test-svr-db-server.dat");
+ _copy_file(CBOR_FILE_IN_RES, CBOR_FILE_IN_DATA);
+
+ ret = iotcon_initialize(CBOR_FILE_IN_DATA);
retv_if(IOTCON_ERROR_NONE != ret, -1);
ret = iotcon_set_device_name(ULTRASONIC_RESOURCE_TYPE);
diff --git a/src/controller.c b/src/controller.c
index 20388a7..e662a99 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -19,11 +19,11 @@
* limitations under the License.
*/
-#include <tizen.h>
-#include <Ecore.h>
-#include <service_app.h>
#include <unistd.h>
#include <glib.h>
+#include <Ecore.h>
+#include <tizen.h>
+#include <service_app.h>
#include <iotcon.h> // Please remove this after test
diff --git a/src/resource/resource_infrared_motion_sensor.c b/src/resource/resource_infrared_motion_sensor.c
index d20664f..40308a3 100644
--- a/src/resource/resource_infrared_motion_sensor.c
+++ b/src/resource/resource_infrared_motion_sensor.c
@@ -53,7 +53,5 @@ int resource_read_infrared_motion_sensor(int pin_num, int *out_value)
ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
retv_if(ret < 0, -1);
- _I("Infrared Motion Sensor Value : %d", *out_value);
-
return 0;
}