summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJin Yoon <jinny.yoon@samsung.com>2017-07-12 19:26:03 +0900
committerJin Yoon <jinny.yoon@samsung.com>2017-07-12 19:26:03 +0900
commitfe280c315017adbb5994ff99971dce680205d1f3 (patch)
tree311a4bb6c097ba4882583d0599ab9a54c39fd41f
parent198144c15c26b02c60fb8b1268170b59535d41c1 (diff)
downloadposition-finder-server-fe280c315017adbb5994ff99971dce680205d1f3.tar.gz
position-finder-server-fe280c315017adbb5994ff99971dce680205d1f3.tar.bz2
position-finder-server-fe280c315017adbb5994ff99971dce680205d1f3.zip
Rename Model as Resource
Change-Id: Ie671b3e2bf00fdc45f230c1335b1edc40510bdd0
-rw-r--r--CMakeLists.txt12
-rw-r--r--inc/resource.h (renamed from inc/model.h)18
-rw-r--r--inc/resource/resource_illuminance_sensor.h (renamed from inc/model/model_illuminance_sensor.h)10
-rw-r--r--inc/resource/resource_infrared_motion_sensor.h (renamed from inc/model/model_infrared_motion_sensor.h)10
-rw-r--r--inc/resource/resource_infrared_obstacle_avoidance_sensor.h (renamed from inc/model/model_infrared_obstacle_avoidance_sensor.h)10
-rw-r--r--inc/resource/resource_touch_sensor.h (renamed from inc/model/model_touch_sensor.h)10
-rw-r--r--inc/resource/resource_ultrasonic_sensor.h (renamed from inc/model/model_ultrasonic_sensor.h)10
-rw-r--r--inc/resource_internal.h (renamed from inc/model_internal.h)12
-rw-r--r--[-rwxr-xr-x]org.tizen.position-finder-server.manifest0
-rw-r--r--src/controller.c14
-rw-r--r--src/main.c120
-rw-r--r--src/resource.c (renamed from src/model.c)8
-rw-r--r--src/resource/resource_illuminance_sensor.c (renamed from src/model/model_illuminance_sensor.c)26
-rw-r--r--src/resource/resource_infrared_motion_sensor.c (renamed from src/model/model_infrared_motion_sensor.c)22
-rw-r--r--src/resource/resource_infrared_obstacle_avoidance_sensor.c (renamed from src/model/model_infrared_obstacle_avoidance_sensor.c)24
-rw-r--r--src/resource/resource_touch_sensor.c (renamed from src/model/model_touch_sensor.c)24
-rw-r--r--src/resource/resource_ultrasonic_sensor.c (renamed from src/model/model_ultrasonic_sensor.c)46
17 files changed, 128 insertions, 248 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9953f4a..b1952ce 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,12 +33,12 @@ INCLUDE_DIRECTORIES(${PROJECT_ROOT_DIR}/inc)
ADD_EXECUTABLE(${PROJECT_NAME}
${PROJECT_ROOT_DIR}/src/controller.c
${PROJECT_ROOT_DIR}/src/connectivity.c
- ${PROJECT_ROOT_DIR}/src/model.c
- ${PROJECT_ROOT_DIR}/src/model/model_illuminance_sensor.c
- ${PROJECT_ROOT_DIR}/src/model/model_infrared_motion_sensor.c
- ${PROJECT_ROOT_DIR}/src/model/model_infrared_obstacle_avoidance_sensor.c
- ${PROJECT_ROOT_DIR}/src/model/model_touch_sensor.c
- ${PROJECT_ROOT_DIR}/src/model/model_ultrasonic_sensor.c
+ ${PROJECT_ROOT_DIR}/src/resource.c
+ ${PROJECT_ROOT_DIR}/src/resource/resource_illuminance_sensor.c
+ ${PROJECT_ROOT_DIR}/src/resource/resource_infrared_motion_sensor.c
+ ${PROJECT_ROOT_DIR}/src/resource/resource_infrared_obstacle_avoidance_sensor.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
diff --git a/inc/model.h b/inc/resource.h
index 6cf1869..89fc1c8 100644
--- a/inc/model.h
+++ b/inc/resource.h
@@ -19,16 +19,16 @@
* limitations under the License.
*/
-#ifndef __POSITION_FINDER_MODEL_H__
-#define __POSITION_FINDER_MODEL_H__
+#ifndef __POSITION_FINDER_RESOURCE_H__
+#define __POSITION_FINDER_RESOURCE_H__
#include <peripheral_io.h>
-#include "model_internal.h"
-#include "model/model_illuminance_sensor.h"
-#include "model/model_infrared_motion_sensor.h"
-#include "model/model_infrared_obstacle_avoidance_sensor.h"
-#include "model/model_touch_sensor.h"
-#include "model/model_ultrasonic_sensor.h"
+#include "resource_internal.h"
+#include "resource/resource_illuminance_sensor.h"
+#include "resource/resource_infrared_motion_sensor.h"
+#include "resource/resource_infrared_obstacle_avoidance_sensor.h"
+#include "resource/resource_touch_sensor.h"
+#include "resource/resource_ultrasonic_sensor.h"
-#endif /* __POSITION_FINDER_MODEL_H__ */
+#endif /* __POSITION_FINDER_RESOURCE_H__ */
diff --git a/inc/model/model_illuminance_sensor.h b/inc/resource/resource_illuminance_sensor.h
index 19eef2d..e95198b 100644
--- a/inc/model/model_illuminance_sensor.h
+++ b/inc/resource/resource_illuminance_sensor.h
@@ -19,12 +19,12 @@
* limitations under the License.
*/
-#ifndef __POSITION_FINDER_MODEL_ILLUMINANCE_SENSOR_H__
-#define __POSITION_FINDER_MODEL_ILLUMINANCE_SENSOR_H__
+#ifndef __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_H__
/* You have to use this illuminance sensor ONLY ONE in the pi board */
-extern int model_read_illuminance_sensor(int i2c_bus, int *out_value);
-extern void model_close_illuminance_sensor(void);
+extern int resource_read_illuminance_sensor(int i2c_bus, int *out_value);
+extern void resource_close_illuminance_sensor(void);
-#endif /* __POSITION_FINDER_MODEL_ILLUMINANCE_SENSOR_H__ */
+#endif /* __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_H__ */
diff --git a/inc/model/model_infrared_motion_sensor.h b/inc/resource/resource_infrared_motion_sensor.h
index fabd14b..fa99633 100644
--- a/inc/model/model_infrared_motion_sensor.h
+++ b/inc/resource/resource_infrared_motion_sensor.h
@@ -19,10 +19,10 @@
* limitations under the License.
*/
-#ifndef __POSITION_FINDER_MODEL_INFRARED_MOTION_SENSOR_H__
-#define __POSITION_FINDER_MODEL_INFRARED_MOTION_SENSOR_H__
+#ifndef __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__
-extern void model_close_infrared_motion_sensor(int sensor_index);
-extern int model_read_infrared_motion_sensor(int pin_num, int *out_value);
+extern void resource_close_infrared_motion_sensor(int sensor_index);
+extern int resource_read_infrared_motion_sensor(int pin_num, int *out_value);
-#endif /* __POSITION_FINDER_MODEL_INFRARED_MOTION_SENSOR_H__ */
+#endif /* __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__ */
diff --git a/inc/model/model_infrared_obstacle_avoidance_sensor.h b/inc/resource/resource_infrared_obstacle_avoidance_sensor.h
index 348ca90..3e6f420 100644
--- a/inc/model/model_infrared_obstacle_avoidance_sensor.h
+++ b/inc/resource/resource_infrared_obstacle_avoidance_sensor.h
@@ -19,10 +19,10 @@
* limitations under the License.
*/
-#ifndef __POSITION_FINDER_MODEL_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__
-#define __POSITION_FINDER_MODEL_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__
+#ifndef __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__
-extern void model_close_infrared_obstacle_avoidance_sensor(int pin_num);
-extern int model_read_infrared_obstacle_avoidance_sensor(int pin_num, int *out_value);
+extern void resource_close_infrared_obstacle_avoidance_sensor(int pin_num);
+extern int resource_read_infrared_obstacle_avoidance_sensor(int pin_num, int *out_value);
-#endif /* __POSITION_FINDER_MODEL_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__ */
+#endif /* __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__ */
diff --git a/inc/model/model_touch_sensor.h b/inc/resource/resource_touch_sensor.h
index d3f9f53..e209a80 100644
--- a/inc/model/model_touch_sensor.h
+++ b/inc/resource/resource_touch_sensor.h
@@ -19,10 +19,10 @@
* limitations under the License.
*/
-#ifndef __POSITION_FINDER_MODEL_TOUCH_SENSOR_H__
-#define __POSITION_FINDER_MODEL_TOUCH_SENSOR_H__
+#ifndef __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_H__
-extern void model_close_touch_sensor(int pin_num);
-extern int model_read_touch_sensor(int pin_num, int *out_value);
+extern void resource_close_touch_sensor(int pin_num);
+extern int resource_read_touch_sensor(int pin_num, int *out_value);
-#endif /* __POSITION_FINDER_MODEL_TOUCH_SENSOR_H__ */
+#endif /* __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_H__ */
diff --git a/inc/model/model_ultrasonic_sensor.h b/inc/resource/resource_ultrasonic_sensor.h
index 401f37c..29fdd00 100644
--- a/inc/model/model_ultrasonic_sensor.h
+++ b/inc/resource/resource_ultrasonic_sensor.h
@@ -19,10 +19,10 @@
* limitations under the License.
*/
-#ifndef __POSITION_FINDER_MODEL_ULTRASONIC_SENSOR_H__
-#define __POSITION_FINDER_MODEL_ULTRASONIC_SENSOR_H__
+#ifndef __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_H__
-extern void model_close_ultrasonic_sensor(int echo_pin_num, int trig_pin_num);
-extern int model_read_ultrasonic_sensor(int echo_pin_num, int trig_pin_num, double *out_value);
+extern void resource_close_ultrasonic_sensor(int echo_pin_num, int trig_pin_num);
+extern int resource_read_ultrasonic_sensor(int echo_pin_num, int trig_pin_num, double *out_value);
-#endif /* __POSITION_FINDER_MODEL_ULTRASONIC_SENSOR_H__ */
+#endif /* __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_H__ */
diff --git a/inc/model_internal.h b/inc/resource_internal.h
index ea73236..1844db6 100644
--- a/inc/model_internal.h
+++ b/inc/resource_internal.h
@@ -19,19 +19,19 @@
* limitations under the License.
*/
-#ifndef __POSITION_FINDER_MODEL_INTERNAL_H__
-#define __POSITION_FINDER_MODEL_INTERNAL_H__
+#ifndef __POSITION_FINDER_RESOURCE_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_INTERNAL_H__
#include <peripheral_io.h>
#define PIN_MAX 40
-struct _model_s {
+struct _resource_s {
int opened;
peripheral_gpio_h sensor_h;
};
-typedef struct _model_s model_s;
+typedef struct _resource_s resource_s;
-extern model_s *model_get_info(int pin_num);
+extern resource_s *resource_get_info(int pin_num);
-#endif /* __POSITION_FINDER_MODEL_INTERNAL_H__ */
+#endif /* __POSITION_FINDER_RESOURCE_INTERNAL_H__ */
diff --git a/org.tizen.position-finder-server.manifest b/org.tizen.position-finder-server.manifest
index af9b883..af9b883 100755..100644
--- a/org.tizen.position-finder-server.manifest
+++ b/org.tizen.position-finder-server.manifest
diff --git a/src/controller.c b/src/controller.c
index 27c3015..69a040e 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -28,7 +28,7 @@
#include "log.h"
#include "controller.h"
-#include "model.h"
+#include "resource.h"
#define I2C_BUS_1 0x1
#define GPIO_NOT_USED -1
@@ -45,7 +45,7 @@ static Eina_Bool _infrared_motion_getter_timer(void *data)
{
int value = 0;
- retv_if(model_read_infrared_motion_sensor(GPIO_INFRARED_MOTION_NUM_1, &value) == -1, ECORE_CALLBACK_CANCEL);
+ retv_if(resource_read_infrared_motion_sensor(GPIO_INFRARED_MOTION_NUM_1, &value) == -1, ECORE_CALLBACK_CANCEL);
_I("Infrared Motion Value is [%d]", value);
return ECORE_CALLBACK_RENEW;
@@ -55,7 +55,7 @@ static Eina_Bool _ultrasonic_getter_timer(void *data)
{
double value = 0;
- retv_if(model_read_ultrasonic_sensor(GPIO_ULTRASONIC_TRIG_NUM_1, GPIO_ULTRASONIC_ECHO_NUM_1, &value) == -1, ECORE_CALLBACK_CANCEL);
+ retv_if(resource_read_ultrasonic_sensor(GPIO_ULTRASONIC_TRIG_NUM_1, GPIO_ULTRASONIC_ECHO_NUM_1, &value) == -1, ECORE_CALLBACK_CANCEL);
_I("Ultra Sonic Distance is [%d cm]", value);
return ECORE_CALLBACK_RENEW;
@@ -65,7 +65,7 @@ static Eina_Bool _illuminance_getter_timer(void *data)
{
int value = 0;
- retv_if(model_read_illuminance_sensor(I2C_BUS_1, &value) == -1, ECORE_CALLBACK_CANCEL);
+ retv_if(resource_read_illuminance_sensor(I2C_BUS_1, &value) == -1, ECORE_CALLBACK_CANCEL);
_I("Ultra Sonic Distance is [%d lux]", value);
return ECORE_CALLBACK_RENEW;
@@ -108,9 +108,9 @@ static void service_app_terminate(void *data)
ecore_timer_del(ad->getter_timer[i]);
}
}
- model_close_infrared_motion_sensor(GPIO_INFRARED_MOTION_NUM_1);
- model_close_ultrasonic_sensor(GPIO_ULTRASONIC_TRIG_NUM_1, GPIO_ULTRASONIC_ECHO_NUM_1);
- model_close_illuminance_sensor();
+ resource_close_infrared_motion_sensor(GPIO_INFRARED_MOTION_NUM_1);
+ resource_close_ultrasonic_sensor(GPIO_ULTRASONIC_TRIG_NUM_1, GPIO_ULTRASONIC_ECHO_NUM_1);
+ resource_close_illuminance_sensor();
free(ad);
}
diff --git a/src/main.c b/src/main.c
deleted file mode 100644
index 1da7c7d..0000000
--- a/src/main.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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 <tizen.h>
-#include <Ecore.h>
-#include <service_app.h>
-#include <unistd.h>
-#include <glib.h>
-
-#include "log.h"
-#include "model.h"
-
-typedef struct app_data_s {
- Ecore_Timer *getter_timer;
- void *event;
-} app_data;
-
-static Eina_Bool _getter_timer(void *data)
-{
-#if 0
- int value = 0;
- retv_if(model_read_int_value(&value) == -1, ECORE_CALLBACK_CANCEL);
- _I("Value is [%d]", value);
-#else
- double value = 0.0;
- retv_if(model_read_double_value(&value) == -1, ECORE_CALLBACK_RENEW);
- _I("Value is [%f]", value);
-#endif
-
- return ECORE_CALLBACK_RENEW;
-}
-
-static bool service_app_create(void *data)
-{
- app_data *ad = (app_data *)data;
-
- retv_if(model_init(SENSOR_TYPE_ULTRASONIC) == -1, false);
-
- ad->getter_timer = ecore_timer_add(3.0, _getter_timer, NULL);
- if (!ad->getter_timer) {
- _D("Failed to add getter timer");
- return false;
- }
-
- return true;
-}
-
-static void service_app_terminate(void *data)
-{
- app_data *ad = (app_data *)data;
- ecore_timer_del(ad->getter_timer);
- model_fini();
- free(ad);
-}
-
-static void service_app_control(app_control_h app_control, void *data)
-{
- // Todo: add your code here.
-}
-
-static void service_app_lang_changed(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_LANGUAGE_CHANGED*/
-}
-
-static void service_app_region_changed(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_REGION_FORMAT_CHANGED*/
-}
-
-static void service_app_low_battery(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_LOW_BATTERY*/
-}
-
-static void service_app_low_memory(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_LOW_MEMORY*/
-}
-
-int main(int argc, char* argv[])
-{
- app_data *ad = NULL;
- int ret = 0;
- service_app_lifecycle_callback_s event_callback;
- app_event_handler_h handlers[5] = {NULL, };
-
- ad = (app_data *)calloc(1, sizeof(app_data));
-
- event_callback.create = service_app_create;
- event_callback.terminate = service_app_terminate;
- event_callback.app_control = service_app_control;
-
- service_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, service_app_low_battery, &ad);
- service_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, service_app_low_memory, &ad);
- service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, service_app_lang_changed, &ad);
- service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, service_app_region_changed, &ad);
-
- ret = service_app_main(argc, argv, &event_callback, ad);
-
- return ret;
-}
diff --git a/src/model.c b/src/resource.c
index f9298a7..7d49961 100644
--- a/src/model.c
+++ b/src/resource.c
@@ -20,11 +20,11 @@
*/
#include <peripheral_io.h>
-#include "model.h"
+#include "resource.h"
-static model_s model_info[PIN_MAX] = { 0, };
+static resource_s resource_info[PIN_MAX] = { 0, };
-model_s *model_get_info(int pin_num)
+resource_s *resource_get_info(int pin_num)
{
- return &model_info[pin_num];
+ return &resource_info[pin_num];
}
diff --git a/src/model/model_illuminance_sensor.c b/src/resource/resource_illuminance_sensor.c
index 9a0f381..e5b5dda 100644
--- a/src/model/model_illuminance_sensor.c
+++ b/src/resource/resource_illuminance_sensor.c
@@ -25,7 +25,7 @@
#include <sys/time.h>
#include "log.h"
-#include "model_internal.h"
+#include "resource_internal.h"
#define I2C_PIN_MAX 28
/* I2C */
@@ -36,33 +36,33 @@
static struct {
int opened;
peripheral_i2c_h sensor_h;
-} model_sensor_s;
+} resource_sensor_s;
-void model_close_illuminance_sensor(void)
+void resource_close_illuminance_sensor(void)
{
- ret_if(!model_sensor_s.opened);
+ ret_if(!resource_sensor_s.opened);
_I("Infrared Motion Sensor is finishing...");
- peripheral_i2c_close(model_sensor_s.sensor_h);
- model_sensor_s.opened = 0;
+ peripheral_i2c_close(resource_sensor_s.sensor_h);
+ resource_sensor_s.opened = 0;
}
/* You have to use this illuminance sensor ONLY ONE in the pi board */
-int model_read_illuminance_sensor(int i2c_bus, int *out_value)
+int resource_read_illuminance_sensor(int i2c_bus, int *out_value)
{
int ret = PERIPHERAL_ERROR_NONE;
unsigned char buf[10] = { 0, };
- if (!model_sensor_s.opened) {
- ret = peripheral_i2c_open(i2c_bus, GY30_ADDR, &model_sensor_s.sensor_h);
- retv_if(!model_sensor_s.sensor_h, -1);
- model_sensor_s.opened = 1;
+ if (!resource_sensor_s.opened) {
+ ret = peripheral_i2c_open(i2c_bus, GY30_ADDR, &resource_sensor_s.sensor_h);
+ retv_if(!resource_sensor_s.sensor_h, -1);
+ resource_sensor_s.opened = 1;
}
- ret = peripheral_i2c_write_byte(model_sensor_s.sensor_h, GY30_CONT_HIGH_RES_MODE);
+ ret = peripheral_i2c_write_byte(resource_sensor_s.sensor_h, GY30_CONT_HIGH_RES_MODE);
retv_if(ret < 0, -1);
- ret = peripheral_i2c_read(model_sensor_s.sensor_h, buf, 2);
+ ret = peripheral_i2c_read(resource_sensor_s.sensor_h, buf, 2);
retv_if(ret < 0, -1);
*out_value = (buf[0] << 8 | buf[1]) / GY30_CONSTANT_NUM; // Just Sum High 8bit and Low 8bit
diff --git a/src/model/model_infrared_motion_sensor.c b/src/resource/resource_infrared_motion_sensor.c
index f606b8a..d8e86e3 100644
--- a/src/model/model_infrared_motion_sensor.c
+++ b/src/resource/resource_infrared_motion_sensor.c
@@ -25,31 +25,31 @@
#include <sys/time.h>
#include "log.h"
-#include "model_internal.h"
+#include "resource_internal.h"
-void model_close_infrared_motion_sensor(int pin_num)
+void resource_close_infrared_motion_sensor(int pin_num)
{
- ret_if(!model_get_info(pin_num)->opened);
+ ret_if(!resource_get_info(pin_num)->opened);
_I("Infrared Motion Sensor is finishing...");
- model_get_info(pin_num)->opened = 0;
+ resource_get_info(pin_num)->opened = 0;
}
-int model_read_infrared_motion_sensor(int pin_num, int *out_value)
+int resource_read_infrared_motion_sensor(int pin_num, int *out_value)
{
int ret = PERIPHERAL_ERROR_NONE;
- if (!model_get_info(pin_num)->opened) {
- ret = peripheral_gpio_open(pin_num, &model_get_info(pin_num)->sensor_h);
- retv_if(!model_get_info(pin_num)->sensor_h, -1);
+ if (!resource_get_info(pin_num)->opened) {
+ ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+ retv_if(!resource_get_info(pin_num)->sensor_h, -1);
- ret = peripheral_gpio_set_direction(model_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+ ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
retv_if(ret != 0, -1);
- model_get_info(pin_num)->opened = 1;
+ resource_get_info(pin_num)->opened = 1;
}
- ret = peripheral_gpio_read(model_get_info(pin_num)->sensor_h, 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);
diff --git a/src/model/model_infrared_obstacle_avoidance_sensor.c b/src/resource/resource_infrared_obstacle_avoidance_sensor.c
index a63ab6a..f95d4ed 100644
--- a/src/model/model_infrared_obstacle_avoidance_sensor.c
+++ b/src/resource/resource_infrared_obstacle_avoidance_sensor.c
@@ -25,32 +25,32 @@
#include <sys/time.h>
#include "log.h"
-#include "model_internal.h"
+#include "resource_internal.h"
-void model_close_infrared_obstacle_avoidance_sensor(int pin_num)
+void resource_close_infrared_obstacle_avoidance_sensor(int pin_num)
{
- ret_if(!model_get_info(pin_num)->opened);
+ ret_if(!resource_get_info(pin_num)->opened);
_I("Infrared Obstacle Avoidance Sensor is finishing...");
- peripheral_gpio_close(model_get_info(pin_num)->sensor_h);
- model_get_info(pin_num)->opened = 0;
+ peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
+ resource_get_info(pin_num)->opened = 0;
}
-int model_read_infrared_obstacle_avoidance_sensor(int pin_num, int *out_value)
+int resource_read_infrared_obstacle_avoidance_sensor(int pin_num, int *out_value)
{
int ret = PERIPHERAL_ERROR_NONE;
- if (!model_get_info(pin_num)->opened) {
- ret = peripheral_gpio_open(pin_num, &model_get_info(pin_num)->sensor_h);
- retv_if(!model_get_info(pin_num)->sensor_h, -1);
+ if (!resource_get_info(pin_num)->opened) {
+ ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+ retv_if(!resource_get_info(pin_num)->sensor_h, -1);
- ret = peripheral_gpio_set_direction(model_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+ ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
retv_if(ret != 0, -1);
- model_get_info(pin_num)->opened = 1;
+ resource_get_info(pin_num)->opened = 1;
}
- ret = peripheral_gpio_read(model_get_info(pin_num)->sensor_h, out_value);
+ ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
retv_if(ret < 0, -1);
_I("Infrared Obstacle Avoidance Sensor Value : %d", *out_value);
diff --git a/src/model/model_touch_sensor.c b/src/resource/resource_touch_sensor.c
index ba472c5..a8ba4ba 100644
--- a/src/model/model_touch_sensor.c
+++ b/src/resource/resource_touch_sensor.c
@@ -25,34 +25,34 @@
#include <sys/time.h>
#include "log.h"
-#include "model_internal.h"
+#include "resource_internal.h"
-void model_close_touch_sensor(int pin_num)
+void resource_close_touch_sensor(int pin_num)
{
- ret_if(!model_get_info(pin_num)->opened);
+ ret_if(!resource_get_info(pin_num)->opened);
_I("Touch Sensor is finishing...");
- peripheral_gpio_close(model_get_info(pin_num)->sensor_h);
- model_get_info(pin_num)->opened = 0;
+ peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
+ resource_get_info(pin_num)->opened = 0;
}
-int model_read_touch_sensor(int pin_num, int *out_value)
+int resource_read_touch_sensor(int pin_num, int *out_value)
{
int ret = PERIPHERAL_ERROR_NONE;
- if (!model_get_info(pin_num)->opened) {
+ if (!resource_get_info(pin_num)->opened) {
_I("Touch sensor is initializing...");
- ret = peripheral_gpio_open(pin_num, &model_get_info(pin_num)->sensor_h);
- retv_if(!model_get_info(pin_num)->sensor_h, -1);
+ ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+ retv_if(!resource_get_info(pin_num)->sensor_h, -1);
- ret = peripheral_gpio_set_direction(model_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+ ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
retv_if(ret != 0, -1);
- model_get_info(pin_num)->opened = 1;
+ resource_get_info(pin_num)->opened = 1;
}
- ret = peripheral_gpio_read(model_get_info(pin_num)->sensor_h, out_value);
+ ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
retv_if(ret < 0, -1);
_I("Touch Sensor Value : %d", *out_value);
diff --git a/src/model/model_ultrasonic_sensor.c b/src/resource/resource_ultrasonic_sensor.c
index 0d2ae75..c397920 100644
--- a/src/model/model_ultrasonic_sensor.c
+++ b/src/resource/resource_ultrasonic_sensor.c
@@ -25,20 +25,20 @@
#include <sys/time.h>
#include "log.h"
-#include "model_internal.h"
+#include "resource_internal.h"
-void model_close_ultrasonic_sensor(int echo_pin_num, int trig_pin_num)
+void resource_close_ultrasonic_sensor(int echo_pin_num, int trig_pin_num)
{
- ret_if(!model_get_info(echo_pin_num)->opened);
- ret_if(!model_get_info(trig_pin_num)->opened);
+ ret_if(!resource_get_info(echo_pin_num)->opened);
+ ret_if(!resource_get_info(trig_pin_num)->opened);
_I("Ultrasonic sensor is finishing...");
- peripheral_gpio_close(model_get_info(echo_pin_num)->sensor_h);
- peripheral_gpio_close(model_get_info(trig_pin_num)->sensor_h);
+ peripheral_gpio_close(resource_get_info(echo_pin_num)->sensor_h);
+ peripheral_gpio_close(resource_get_info(trig_pin_num)->sensor_h);
- model_get_info(echo_pin_num)->opened = 0;
- model_get_info(trig_pin_num)->opened = 0;
+ resource_get_info(echo_pin_num)->opened = 0;
+ resource_get_info(trig_pin_num)->opened = 0;
}
static int _get_echo_value(int echo_pin_num)
@@ -46,53 +46,53 @@ static int _get_echo_value(int echo_pin_num)
int ret = 0;
int value = 0;
- ret = peripheral_gpio_read(model_get_info(echo_pin_num)->sensor_h, &value);
+ ret = peripheral_gpio_read(resource_get_info(echo_pin_num)->sensor_h, &value);
retv_if(ret < 0, -1);
return value;
}
-int model_read_ultrasonic_sensor(int echo_pin_num, int trig_pin_num, double *out_value)
+int resource_read_ultrasonic_sensor(int echo_pin_num, int trig_pin_num, double *out_value)
{
int ret = 0;
double duration = 0.0;
struct timeval start_time, end_time, temp_start_time, temp_end_time;
- if (!model_get_info(echo_pin_num)->opened) {
+ if (!resource_get_info(echo_pin_num)->opened) {
_I("Ultrasonic sensor is initializing...");
- ret = peripheral_gpio_open(echo_pin_num, &model_get_info(echo_pin_num)->sensor_h);
- retv_if(!model_get_info(echo_pin_num)->sensor_h, -1);
+ ret = peripheral_gpio_open(echo_pin_num, &resource_get_info(echo_pin_num)->sensor_h);
+ retv_if(!resource_get_info(echo_pin_num)->sensor_h, -1);
- ret = peripheral_gpio_set_direction(model_get_info(echo_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+ ret = peripheral_gpio_set_direction(resource_get_info(echo_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
retv_if(ret != 0, -1);
- model_get_info(echo_pin_num)->opened = 1;
+ resource_get_info(echo_pin_num)->opened = 1;
}
- if (!model_get_info(trig_pin_num)->opened) {
+ if (!resource_get_info(trig_pin_num)->opened) {
_I("Ultrasonic sensor is initializing...");
- ret = peripheral_gpio_open(trig_pin_num, &model_get_info(trig_pin_num)->sensor_h);
- retv_if(!model_get_info(trig_pin_num)->sensor_h, -1);
+ ret = peripheral_gpio_open(trig_pin_num, &resource_get_info(trig_pin_num)->sensor_h);
+ retv_if(!resource_get_info(trig_pin_num)->sensor_h, -1);
- ret = peripheral_gpio_set_direction(model_get_info(trig_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+ ret = peripheral_gpio_set_direction(resource_get_info(trig_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
retv_if(ret != 0, -1);
- model_get_info(trig_pin_num)->opened = 1;
+ resource_get_info(trig_pin_num)->opened = 1;
}
- ret = peripheral_gpio_write(model_get_info(trig_pin_num)->sensor_h, 0);
+ ret = peripheral_gpio_write(resource_get_info(trig_pin_num)->sensor_h, 0);
retv_if(ret < 0, -1);
sleep(1);
- ret = peripheral_gpio_write(model_get_info(trig_pin_num)->sensor_h, 1);
+ ret = peripheral_gpio_write(resource_get_info(trig_pin_num)->sensor_h, 1);
retv_if(ret < 0, -1);
usleep(10);
- ret = peripheral_gpio_write(model_get_info(trig_pin_num)->sensor_h, 0);
+ ret = peripheral_gpio_write(resource_get_info(trig_pin_num)->sensor_h, 0);
retv_if(ret < 0, -1);
_D("Count the distance");