application fully rewritten 64/207564/2
authorJeonghoon Park <jh1979.park@samsung.com>
Fri, 7 Jun 2019 08:06:56 +0000 (17:06 +0900)
committerJeonghoon Park <jh1979.park@samsung.com>
Fri, 7 Jun 2019 10:45:49 +0000 (19:45 +0900)
Change-Id: I26ebdbe79ecf38a839b529582f550d4e107e9642

19 files changed:
LICENSE.APLv2
inc/controller.h [deleted file]
inc/controller_internal.h [deleted file]
inc/controller_util.h [deleted file]
inc/log.h
inc/resource.h
inc/resource/resource_led.h
inc/resource/resource_led_internal.h
inc/resource/resource_lidar.h [deleted file]
inc/resource/resource_lidar_internal.h [deleted file]
inc/resource_internal.h
inc/sensor-data.h
src/controller.c
src/controller_internal.c [deleted file]
src/controller_util.c [deleted file]
src/resource.c
src/resource/resource_led.c
src/resource/resource_lidar.c [deleted file]
src/sensor-data.c

index d645695..2a42015 100644 (file)
       same "printed page" as the copyright notice for easier
       identification within third-party archives.
 
-   Copyright [yyyy] [name of copyright owner]
+   Copyright 2019 Samsung Electronics Co., Ltd
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
diff --git a/inc/controller.h b/inc/controller.h
deleted file mode 100644 (file)
index 5fe0e6c..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2019 G.camp,
- *
- * Contact: Jin Seog Bang <seog814@gmail.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 __CONTROLLER_H__
-#define __CONTROLLER_H__
-
-#include "controller_internal.h"
-
-#endif /* __CONTROLLER_H__ */
diff --git a/inc/controller_internal.h b/inc/controller_internal.h
deleted file mode 100644 (file)
index a99d398..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2019 G.camp,
- *
- * Contact: Jin Seog Bang <seog814@gmail.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 __CONTROLLER_INTERNAL_H__
-#define __CONTROLLER_INTERNAL_H__
-
-extern void controller_init_internal_functions(void);
-extern void controller_fini_internal_functions(void);
-
-#endif /* __CONTROLLER_INTERNAL_H__ */
diff --git a/inc/controller_util.h b/inc/controller_util.h
deleted file mode 100644 (file)
index 906b3b0..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2019 G.camp,
- *
- * Contact: Jin Seog Bang <seog814@gmail.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 __CONTROLLER_UTIL_H__
-#define __CONTROLLER_UTIL_H__
-
-int controller_util_get_path(const char **path);
-int controller_util_get_address(const char **address);
-int controller_util_get_image_address(const char **image_upload);
-void controller_util_free(void);
-
-#endif /* __CONTROLLER_UTIL_H__ */
index 3fa0b67..85f8ef9 100644 (file)
--- a/inc/log.h
+++ b/inc/log.h
@@ -1,7 +1,5 @@
 /*
- * Copyright (c) 2019 G.camp,
- *
- * Contact: Jin Seog Bang <seog814@gmail.com>
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef __POSITION_FINDER_SERVER_H__
-#define __POSITION_FINDER_SERVER_H__
+#ifndef __SMART_RULER_LOG_H__
+#define __SMART_RULER_LOG_H__
 
 #include <dlog.h>
 
@@ -93,4 +91,4 @@
        } \
 }
 
-#endif /* __POSITION_FINDER_SERVER_H__ */
+#endif /* __SMART_RULER_LOG_H__ */
index 41624fc..8ad77d0 100644 (file)
 #ifndef __RESOURCE_H__
 #define __RESOURCE_H__
 
-#include <peripheral_io.h>
-
 #include "resource/resource_lidar_v3.h"
-#include "resource/resource_lidar.h"
 #include "resource/resource_led.h"
 
 extern void resource_close_all(void);
index 0d406ed..4a52130 100644 (file)
@@ -1,7 +1,5 @@
 /*
- * Copyright (c) 2019 G.camp,
- *
- * Contact: Jin Seog Bang <seog814@gmail.com>
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index f9dd9b3..b814927 100644 (file)
@@ -1,7 +1,5 @@
 /*
- * Copyright (c) 2019 G.camp,
- *
- * Contact: Jin Seog Bang <seog814@gmail.com>
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/inc/resource/resource_lidar.h b/inc/resource/resource_lidar.h
deleted file mode 100644 (file)
index 2a6b836..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2019 G.camp,
- *
- * Contact: Jin Seog Bang <seog814@gmail.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 __RESOURCE_LIDAR_SENSOR_H__
-#define __RESOURCE_LIDAR_SENSOR_H__
-
-/**
- * @brief Reads the value of i2c bus connected lidar sensor.
- * @param[in] i2c_bus The i2c bus number that the slave device is connected
- * @param[out] out_value The value read by the lidar sensor
- * @return 0 on success, otherwise a negative error value
- * @see If the i2c bus is not open, creates i2c handle before reading data from the i2c slave device.
- */
-
-extern int resource_initial_lidar_sensor(int i2c_bus);
-
-extern int resource_two_read_set_lidar_sensor(int i2c_bus);
-
-extern int resource_read_lidar_sensor(int i2c_bus, uint32_t *out_value);
-
-#endif /* __RESOURCE_LIDAR_SENSOR_H__ */
-
diff --git a/inc/resource/resource_lidar_internal.h b/inc/resource/resource_lidar_internal.h
deleted file mode 100644 (file)
index c8f8516..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2019 G.camp,
- *
- * Contact: Jin Seog Bang <seog814@gmail.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 __RESOURCE_LIDAR_SENSOR_INTERNAL_H__
-#define __RESOURCE_LIDAR_SENSOR_INTERNAL_H__
-
-/**
- * @brief Destory the i2c handle and changes the gpio pin state to the close(0).
- */
-extern void resource_close_lidar_sensor(void);
-
-#endif /* __RESOURCE_LIDAR_SENSOR_INTERNAL_H__ */
-
index 0ac9f33..2e0e2d6 100644 (file)
 #include <peripheral_io.h>
 
 #include "resource/resource_led_internal.h"
-#include "resource/resource_lidar_internal.h"
 #include "resource/resource_lidar_v3_internal.h"
 
-#define PIN_MAX 40
-
-struct _resource_s {
+typedef struct _resource_s {
        int opened;
        peripheral_gpio_h sensor_h;
        void (*close) (int);
-};
-typedef struct _resource_s resource_s;
-
-typedef void (*resource_read_cb)(double value, void *data);
-
-struct _resource_read_cb_s {
-       resource_read_cb cb;
-       void *data;
-       int pin_num;
-};
-typedef struct _resource_read_cb_s resource_read_s;
+} resource_s;
 
 extern resource_s *resource_get_info(int pin_num);
 
index a3649c9..9522d7a 100644 (file)
@@ -1,7 +1,5 @@
 /*
- * Copyright (c) 2019 G.camp,
- *
- * Contact: Jin Seog Bang <seog814@gmail.com>
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 55585fa..134e632 100644 (file)
@@ -1,7 +1,5 @@
 /*
- * Copyright (c) 2019 G.camp,
- *
- * Contact: Jin Seog Bang <seog814@gmail.com>
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,8 +14,6 @@
  * limitations under the License.
  */
 
-#include <unistd.h>
-#include <glib.h>
 #include <Ecore.h>
 #include <tizen.h>
 #include <service_app.h>
 #include "log.h"
 #include "sensor-data.h"
 #include "resource.h"
-#include "controller.h"
-#include "controller_util.h"
 
-#define I2C_BUS_NUMBER (1)
-#define SENSORING_TIME_INTERVAL 1.0f
+#define SENSORING_TIME_INTERVAL (0.5)
 
 typedef struct app_data_s {
        Ecore_Timer *getter_timer;
        sensor_data *lidar_data;
 } app_data;
 
-
-static inline int __get_lidar_data(void *data, unsigned int *lidar_value)
-{
-       int ret = 0;
-       unsigned int delay_usec = 20000; // 20mS delay
-       app_data *ad = data;
-
-       retv_if(!ad, -1);
-       retv_if(!ad->lidar_data, -1);
-
-       ret = resource_initial_lidar_sensor(I2C_BUS_NUMBER);
-       retv_if(ret != 0, -1);
-       ret = resource_two_read_set_lidar_sensor(I2C_BUS_NUMBER);
-       retv_if(ret != 0, -1);
-
-       usleep(delay_usec);
-
-       ret = resource_read_lidar_sensor(I2C_BUS_NUMBER, lidar_value);
-       retv_if(ret != 0, -1);
-
-       sensor_data_set_uint(ad->lidar_data, *lidar_value);
-       _D("Distance value : %u", *lidar_value);
-
-       return 0;
-}
-
-static Eina_Bool control_sensors_cb(void *data)
+static Eina_Bool _lidar_value_read_cb(void *data)
 {
        app_data *ad = data;
-       int value = 1;
        int ret = 0;
        unsigned int lidar_value = 0;
-       resource_write_led(26, value);
+
        if (!ad) {
-               _E("failed to get app_data");
+               _E("app_data is NULL");
                service_app_exit();
        }
 
        if (!ad->lidar_data) {
-               _E("failed to get lidar_data");
+               _E("lidar_data is NULL");
                service_app_exit();
        }
 
-       ret = __get_lidar_data(ad, &lidar_value);
+       resource_write_led(5, 1);
+       ret = resource_read_lidar_v3(&lidar_value);
        retv_if(ret != 0, ECORE_CALLBACK_RENEW);
+       resource_write_led(5, 0);
+       _D("distance : %u cm", lidar_value);
+       sensor_data_set_uint(ad->lidar_data, lidar_value);
 
        return ECORE_CALLBACK_RENEW;
 }
 
-static bool service_app_create(void *data)
+static void service_app_control(app_control_h app_control, void *user_data)
 {
-       app_data *ad = data;
-
-       controller_init_internal_functions();
+       app_data *ad = user_data;
+       if (ad->getter_timer)
+               ecore_timer_del(ad->getter_timer);
 
+       ad->getter_timer = ecore_timer_add(SENSORING_TIME_INTERVAL, _lidar_value_read_cb, ad);
+       if (!ad->getter_timer) {
+               _E("Failed to add getter timer");
+               return;
+       }
+}
 
+static bool service_app_create(void *data)
+{
+       app_data *ad = data;
        ad->lidar_data = sensor_data_new(SENSOR_DATA_TYPE_UINT);
        if (!ad->lidar_data)
                return false;
 
-       /**
-        * Creates a timer to call the given function in the given period of time.
-        * In the control_sensors_cb(), each sensor reads the measured value or writes a specific value to the sensor.
-        */
-       ad->getter_timer = ecore_timer_add(SENSORING_TIME_INTERVAL, control_sensors_cb, ad);
-       if (!ad->getter_timer) {
-               _E("Failed to add infrared motion getter timer");
-               return false;
-       }
-
-       resource_write_led(5, 1);
-
        return true;
 }
 
@@ -118,57 +85,26 @@ static void service_app_terminate(void *data)
        if (ad->getter_timer)
                ecore_timer_del(ad->getter_timer);
 
-       controller_fini_internal_functions();
+       resource_close_all();
 
        sensor_data_free(ad->lidar_data);
        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;
+       app_data ad;
        int ret = 0;
        service_app_lifecycle_callback_s event_callback;
-       app_event_handler_h handlers[5] = {NULL, };
 
-       ad = calloc(1, sizeof(app_data));
-       retv_if(!ad, -1);
+       ad.getter_timer = NULL;
+       ad.lidar_data = NULL;
 
        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);
+       ret = service_app_main(argc, argv, &event_callback, &ad);
 
        return ret;
 }
diff --git a/src/controller_internal.c b/src/controller_internal.c
deleted file mode 100644 (file)
index 8acb939..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2019 G.camp,
- *
- * Contact: Jin Seog Bang <seog814@gmail.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 "resource.h"
-#include "controller_util.h"
-
-void controller_init_internal_functions(void)
-{
-       return;
-}
-
-void controller_fini_internal_functions(void)
-{
-       _I("Terminating...");
-       resource_close_all();
-       controller_util_free();
-
-       return;
-}
diff --git a/src/controller_util.c b/src/controller_util.c
deleted file mode 100644 (file)
index 47b1d86..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2019 G.camp,
- *
- * Contact: Jin Seog Bang <seog814@gmail.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 <stdlib.h>
-#include <glib.h>
-#include <stdio.h>
-#include <app_common.h>
-#include "log.h"
-
-#define CONF_GROUP_DEFAULT_NAME "default"
-#define CONF_KEY_PATH_NAME "path"
-#define CONF_KEY_ADDRESS_NAME "address"
-#define CONF_KEY_IMAGE_UPLOAD_NAME "image_address"
-#define CONF_FILE_NAME "pi.conf"
-
-struct controller_util_s {
-       char *path;
-       char *address;
-       char *image_upload;
-};
-
-struct controller_util_s controller_util = { 0, };
-
-static int _read_conf_file(void)
-{
-       GKeyFile *gkf = NULL;
-       char conf_path[PATH_MAX] = {0,};
-       char *prefix = NULL;
-
-       gkf = g_key_file_new();
-       retv_if(!gkf, -1);
-
-       prefix = app_get_resource_path();
-       retv_if(!prefix, -1);
-       snprintf(conf_path, sizeof(conf_path)-1, "%s%s", prefix, CONF_FILE_NAME);
-       free(prefix);
-       prefix = NULL;
-
-       if (!g_key_file_load_from_file(gkf, conf_path, G_KEY_FILE_NONE, NULL)) {
-               _E("could not read config file %s", conf_path);
-               return -1;
-       }
-
-       controller_util.path = g_key_file_get_string(gkf,
-                       CONF_GROUP_DEFAULT_NAME,
-                       CONF_KEY_PATH_NAME,
-                       NULL);
-       if (!controller_util.path)
-               _E("could not get the key string");
-
-       controller_util.address = g_key_file_get_string(gkf,
-                       CONF_GROUP_DEFAULT_NAME,
-                       CONF_KEY_ADDRESS_NAME,
-                       NULL);
-       if (!controller_util.address)
-               _E("could not get the key string");
-
-       controller_util.image_upload = g_key_file_get_string(gkf,
-                       CONF_GROUP_DEFAULT_NAME,
-                       CONF_KEY_IMAGE_UPLOAD_NAME,
-                       NULL);
-       if (!controller_util.image_upload)
-               _E("could not get the key string");
-
-       g_key_file_free(gkf);
-
-       return 0;
-}
-
-int controller_util_get_path(const char **path)
-{
-       retv_if(!path, -1);
-
-       if (!controller_util.path) {
-               int ret = -1;
-               ret = _read_conf_file();
-               retv_if(-1 == ret, -1);
-       }
-
-       *path = controller_util.path;
-
-       return 0;
-}
-
-int controller_util_get_address(const char **address)
-{
-       retv_if(!address, -1);
-
-       if (!controller_util.address) {
-               int ret = -1;
-               ret = _read_conf_file();
-               retv_if(-1 == ret, -1);
-       }
-
-       *address = controller_util.address;
-
-       return 0;
-}
-
-int controller_util_get_image_address(const char **image_upload)
-{
-       retv_if(!image_upload, -1);
-
-       if (!controller_util.image_upload) {
-               int ret = -1;
-               ret = _read_conf_file();
-               retv_if(-1 == ret, -1);
-       }
-
-       *image_upload = controller_util.image_upload;
-
-       return 0;
-}
-
-void controller_util_free(void)
-{
-       if (controller_util.path) {
-               free(controller_util.path);
-               controller_util.path = NULL;
-       }
-
-       if (controller_util.address) {
-               free(controller_util.address);
-               controller_util.address = NULL;
-       }
-}
index 77bbdbc..a36f969 100644 (file)
  * limitations under the License.
  */
 
-#include <peripheral_io.h>
-
 #include "log.h"
 #include "resource_internal.h"
 
+#define PIN_MAX 40
+
 static resource_s resource_info[PIN_MAX] = { {0, NULL, NULL}, };
 
 resource_s *resource_get_info(int pin_num)
@@ -37,6 +37,5 @@ void resource_close_all(void)
                        resource_info[i].close(i);
        }
 
-       resource_close_lidar_sensor();
        resource_close_lidar_v3();
 }
index 1f0dd2c..8f8768b 100644 (file)
@@ -1,7 +1,5 @@
 /*
- * Copyright (c) 2019 G.camp,
- *
- * Contact: Jin Seog Bang <seog814@gmail.com>
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/src/resource/resource_lidar.c b/src/resource/resource_lidar.c
deleted file mode 100644 (file)
index 434641c..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2019 G.camp,
- *
- * Contact: Jin Seog Bang <seog814@gmail.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 <stdlib.h>
-#include <unistd.h>
-#include <peripheral_io.h>
-#include <sys/time.h>
-
-#include "log.h"
-#include "resource_internal.h"
-#include "resource.h"
-
-#define I2C_PIN_MAX 28
-
-/* I2C */
-#define LIDAR_V1_ADDRW 0x62
-#define LIDAR_V1_ADDRR 0x63
-#define LIDAR_CONSTANT_NUM (1.00)
-
-static struct {
-       int opened;
-       peripheral_i2c_h sensor_h;
-} resource_sensor_s;
-
-
-void resource_close_lidar_sensor(void)
-{
-       if (!resource_sensor_s.opened)
-               return;
-
-       _I("initial_LIDAR_Sensor is finishing...");
-       peripheral_i2c_close(resource_sensor_s.sensor_h);
-       resource_sensor_s.opened = 0;
-}
-
-int resource_initial_lidar_sensor(int i2c_bus)
-{
-       int ret = PERIPHERAL_ERROR_NONE;
-       static int write = 0;
-       unsigned char buf[10] = { 0, };
-       resource_write_led(5, 1); // debug led on
-       if (!resource_sensor_s.opened) {
-
-               ret = peripheral_i2c_open(i2c_bus, LIDAR_V1_ADDRW, &resource_sensor_s.sensor_h);
-
-               if (ret != PERIPHERAL_ERROR_NONE) {
-                       _E("i2c open error : %s", get_error_message(ret));
-
-                       return -1;
-               }
-               resource_sensor_s.opened = 1;
-               write = 0;
-       }
-
-       buf[0] = 0x00;
-       buf[1] = 0x04;
-
-       if (!write) {
-               ret = peripheral_i2c_write(resource_sensor_s.sensor_h, buf, 2);
-               if (ret != PERIPHERAL_ERROR_NONE) {
-                       _E("i2c write error : %s", get_error_message(ret));
-                       return -1;
-               }
-               write = 0;
-       }
-       _I("iic lidar control reset ... step ");
-
-       buf[0] = 0x00;
-       buf[1] = 0x03;
-
-       if (!write) {
-               ret = peripheral_i2c_write(resource_sensor_s.sensor_h, buf, 2);
-               if (ret != PERIPHERAL_ERROR_NONE) {
-                       _E("i2c write error : %s", get_error_message(ret));
-                       return -1;
-               }
-               write = 0;
-       }
-       _I("iic lidar control reset ... step ");
-
-       return 0;
-}
-
-int resource_two_read_set_lidar_sensor(int i2c_bus)
-{
-       int ret = PERIPHERAL_ERROR_NONE;
-       static int write = 0;
-       unsigned char buf[10] = { 0, };
-
-       if (!resource_sensor_s.opened) {
-
-               ret = peripheral_i2c_open(i2c_bus, LIDAR_V1_ADDRW, &resource_sensor_s.sensor_h);
-               if (ret != PERIPHERAL_ERROR_NONE) {
-                       _E("i2c open error : %s", get_error_message(ret));
-
-                       return -1;
-               }
-               resource_sensor_s.opened = 1;
-               write = 0;
-       }       
-
-       buf[0] = 0x8f;  
-
-       if (!write) {
-               ret = peripheral_i2c_write(resource_sensor_s.sensor_h, buf, 1);
-               if (ret != PERIPHERAL_ERROR_NONE) {
-                       _E("i2c write error : %s", get_error_message(ret));
-                       return -1;
-               }
-               write = 0;
-       }
-
-       _I("iic lidar control 2byte read set .. step ");
-
-       return 0;
-}
-
-int resource_read_lidar_sensor(int i2c_bus, uint32_t *out_value)
-{
-       int ret = PERIPHERAL_ERROR_NONE;
-
-       unsigned char buf[10] = { 0, };
-
-       if (!resource_sensor_s.opened) {
-
-               ret = peripheral_i2c_open(i2c_bus, LIDAR_V1_ADDRR, &resource_sensor_s.sensor_h);
-               if (ret != PERIPHERAL_ERROR_NONE) {
-                       _E("i2c open error : %s", get_error_message(ret));
-                       return -1;
-               }
-               resource_sensor_s.opened = 1;
-       }
-
-       ret = peripheral_i2c_read(resource_sensor_s.sensor_h, buf, 2);
-
-       if (ret != PERIPHERAL_ERROR_NONE) {
-               _E("i2c read error : %s", get_error_message(ret));
-
-               return -1;
-       }
-
-       *out_value = (buf[0] << 8 | buf[1]) / LIDAR_CONSTANT_NUM;
-
-
-       resource_write_led(5, 0); // debug led off
-
-       return 0;
-}
index fb29ac5..47d487f 100644 (file)
@@ -1,7 +1,5 @@
 /*
- * Copyright (c) 2019 G.camp,
- *
- * Contact: Jin Seog Bang <seog814@gmail.com>
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.