Connectivity APIs, First version
authorJin Yoon <jinny.yoon@samsung.com>
Fri, 14 Jul 2017 03:15:30 +0000 (12:15 +0900)
committerGeunSun Lee <gs86.lee@samsung.com>
Fri, 14 Jul 2017 04:24:50 +0000 (04:24 +0000)
Change-Id: I9d3df7e6b5bd6b02f8fa351223d43ff996699493

inc/connectivity.h
inc/connectivity_internal.h [new file with mode: 0644]
src/connectivity.c

index 58dd87f..18479c6 100644 (file)
 #ifndef __POSITION_FINDER_CONNECTIVITY_H__
 #define __POSITION_FINDER_CONNECTIVITY_H__
 
+#include "connectivity_internal.h"
+
+struct connectivity_resource {
+       iotcon_resource_h res;
+       iotcon_observers_h observers;
+};
+
 typedef struct connectivity_resource connectivity_resource_s;
-extern int connectivity_notify(connectivity_resource_s *user_data, int value);
 
-extern int connectivity_init(const char *device_name);
-extern int connectivity_fini(void);
+extern int connectivity_set_resource(const char *uri_path, const char *type, connectivity_resource_s **out_resource_info);
+extern void connectivity_unset_resource(connectivity_resource_s *resource);
 
-extern void connectivity_destroy_resource(connectivity_resource_s *resource);
-extern int connectivity_create_resource(const char *uri_path, const char *type, connectivity_resource_s **out_resource);
+extern int connectivity_notify(connectivity_resource_s *resource_info, int value);
 
 #endif /* __POSITION_FINDER_CONNECTIVITY_H__ */
diff --git a/inc/connectivity_internal.h b/inc/connectivity_internal.h
new file mode 100644 (file)
index 0000000..1f1ff14
--- /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_CONNECTIVITY_INTERNAL_H__
+#define __POSITION_FINDER_CONNECTIVITY_INTERNAL_H__
+
+extern int connectivity_init(const char *device_name);
+extern int connectivity_fini(void);
+
+#endif /* __POSITION_FINDER_CONNECTIVITY_INTERNAL_H__ */
index b772625..c27234e 100644 (file)
 #define ULTRASONIC_RESOURCE_2_URI "/door/2"
 #define ULTRASONIC_RESOURCE_TYPE "org.tizen.door"
 
-struct connectivity_resource {
-       iotcon_resource_h res;
-       iotcon_observers_h observers;
-};
 static bool _resource_created;
 static void _request_resource_handler(iotcon_resource_h resource, iotcon_request_h request, void *user_data);
 
@@ -184,10 +180,9 @@ error:
        return -1;
 }
 
-int connectivity_notify(connectivity_resource_s *user_data, int value)
+int connectivity_notify(connectivity_resource_s *resource_info, int value)
 {
        iotcon_representation_h representation;
-       connectivity_resource_s *resource_info = user_data;
        int ret = -1;
 
        retv_if(!resource_info, -1);
@@ -223,7 +218,7 @@ static int _handle_post_request(connectivity_resource_s *resource_info, iotcon_r
        new_resource_info = calloc(1, sizeof(connectivity_resource_s));
        retv_if(!new_resource_info, -1);
 
-       ret = connectivity_create_resource(ULTRASONIC_RESOURCE_2_URI, ULTRASONIC_RESOURCE_TYPE, &new_resource_info);
+       ret = connectivity_set_resource(ULTRASONIC_RESOURCE_2_URI, ULTRASONIC_RESOURCE_TYPE, &new_resource_info);
        retv_if(0 != ret, -1);
 
        _resource_created = true;
@@ -380,7 +375,7 @@ int connectivity_init(const char *device_name)
 {
        int ret = -1;
 
-       ret = iotcon_initialize("../res/iotcon-test-svr-db-server.dat");
+       ret = iotcon_initialize("/usr/apps/org.tizen.position-finder-server/res/iotcon-test-svr-db-server.dat");
        retv_if(IOTCON_ERROR_NONE != ret, -1);
 
        ret = iotcon_set_device_name(device_name);
@@ -402,7 +397,7 @@ int connectivity_fini(void)
        return 0;
 }
 
-void connectivity_destroy_resource(connectivity_resource_s *resource_info)
+void connectivity_unset_resource(connectivity_resource_s *resource_info)
 {
        ret_if(!resource_info);
        if (resource_info->observers) iotcon_observers_destroy(resource_info->observers);
@@ -410,7 +405,7 @@ void connectivity_destroy_resource(connectivity_resource_s *resource_info)
        free(resource_info);
 }
 
-int connectivity_create_resource(const char *uri_path, const char *type, connectivity_resource_s **out_resource_info)
+int connectivity_set_resource(const char *uri_path, const char *type, connectivity_resource_s **out_resource_info)
 {
        iotcon_resource_types_h resource_types = NULL;
        iotcon_resource_interfaces_h ifaces = NULL;