Encapsulate pre-defined functions into controller_internal.c
authorJin Yoon <jinny.yoon@samsung.com>
Mon, 24 Jul 2017 02:43:09 +0000 (11:43 +0900)
committerJin Yoon <jinny.yoon@samsung.com>
Mon, 24 Jul 2017 02:45:26 +0000 (11:45 +0900)
Change-Id: I5801569003f9331fd8e7a7bd4fb9c96e237ae9f0

CMakeLists.txt
inc/controller.h
inc/controller_internal.h [new file with mode: 0644]
src/controller.c
src/controller_internal.c [new file with mode: 0644]

index 7d4f9c9..91e1717 100644 (file)
@@ -34,6 +34,7 @@ INCLUDE_DIRECTORIES(${PROJECT_ROOT_DIR}/inc)
 
 ADD_EXECUTABLE(${PROJECT_NAME}
        ${PROJECT_ROOT_DIR}/src/controller.c
+       ${PROJECT_ROOT_DIR}/src/controller_internal.c
        ${PROJECT_ROOT_DIR}/src/connectivity.c
        ${PROJECT_ROOT_DIR}/src/resource.c
        ${PROJECT_ROOT_DIR}/src/resource/resource_illuminance_sensor.c
index 8920022..154bb76 100644 (file)
@@ -22,4 +22,6 @@
 #ifndef __POSITION_FINDER_CONTROLLER_H__
 #define __POSITION_FINDER_CONTROLLER_H__
 
+#include "controller_internal.h"
+
 #endif /* __POSITION_FINDER_CONTROLLER_H__ */
diff --git a/inc/controller_internal.h b/inc/controller_internal.h
new file mode 100644 (file)
index 0000000..73c6a23
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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_CONTROLLER_INTERNAL_H__
+#define __POSITION_FINDER_CONTROLLER_INTERNAL_H__
+
+extern void controller_init_internal_functions(void);
+extern void controller_fini_internal_functions(void);
+
+#endif /* __POSITION_FINDER_CONTROLLER_INTERNAL_H__ */
index cee20d9..06cb7b7 100644 (file)
@@ -42,9 +42,6 @@
 #define USE_MULTIPLE_SENSOR 0
 #define MULTIPLE_SENSOR_NUMBER 5
 
-static void _start_internal_function(void);
-static void _stop_internal_function(void);
-
 typedef struct app_data_s {
        Ecore_Timer *getter_timer[PIN_MAX];
        connectivity_resource_s *resource_info;
@@ -111,7 +108,7 @@ static bool service_app_create(void *data)
        app_data *ad = data;
        int ret = -1;
 
-       _start_internal_function();
+       controller_init_internal_functions();
 
        ret = connectivity_set_resource("/door/1", "org.tizen.door", &ad->resource_info);
        if (ret == -1) _E("Cannot broadcast resource");
@@ -159,7 +156,7 @@ static void service_app_terminate(void *data)
        }
 
        connectivity_unset_resource(ad->resource_info);
-       _stop_internal_function();
+       controller_fini_internal_functions();
 
        free(ad);
 }
@@ -211,16 +208,3 @@ int main(int argc, char* argv[])
 
        return ret;
 }
-
-/* Do not modify codes under this comment */
-static void _start_internal_function(void)
-{
-       connectivity_init();
-}
-
-static void _stop_internal_function(void)
-{
-       _I("Terminating...");
-       resource_close_all();
-       connectivity_fini();
-}
diff --git a/src/controller_internal.c b/src/controller_internal.c
new file mode 100644 (file)
index 0000000..9deb732
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <iotcon.h>
+
+#include "log.h"
+#include "connectivity.h"
+#include "resource.h"
+
+void controller_init_internal_functions(void)
+{
+       connectivity_init();
+}
+
+void controller_fini_internal_functions(void)
+{
+       _I("Terminating...");
+       resource_close_all();
+       connectivity_fini();
+}