From 471dbdce40f1eed3a8d7f1679580829607b26c74 Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Tue, 13 Apr 2021 15:49:19 +0900 Subject: Use sensor_error_e of hal API Change-Id: I8d7a268c31343cee3e5bc969ba0ea5083ac62ac5 Signed-off-by: Yunmi Ha --- src/hal-backend-sensor.cpp | 16 +++++++++------- src/sensor_common.h | 21 --------------------- src/sensorhub/sensorhub.cpp | 3 +++ 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/hal-backend-sensor.cpp b/src/hal-backend-sensor.cpp index ad0a238..b166c58 100644 --- a/src/hal-backend-sensor.cpp +++ b/src/hal-backend-sensor.cpp @@ -48,13 +48,15 @@ void create_sensor(const char *name) { } static int sensor_tw3_create(sensor_device_t **devices) { - create_sensor("Accelerometer"); - create_sensor("Gyroscope"); - create_sensor("Pressure"); - create_sensor("Light"); - create_sensor("HRM Raw"); - create_sensor("HRM"); - create_sensor("Sensorhub"); + if (devs.empty()) { + create_sensor("Accelerometer"); + create_sensor("Gyroscope"); + create_sensor("Pressure"); + create_sensor("Light"); + create_sensor("HRM Raw"); + create_sensor("HRM"); + create_sensor("Sensorhub"); + } *devices = &devs[0]; return devs.size(); diff --git a/src/sensor_common.h b/src/sensor_common.h index 56cf5d4..9c56c2f 100755 --- a/src/sensor_common.h +++ b/src/sensor_common.h @@ -30,7 +30,6 @@ #define NS_TO_US(x) ((x) / 1000) #define UNKNOWN_NAME "UNKNOWN" -#include enum sensorhub_enable_bit { @@ -64,24 +63,4 @@ enum sensorhub_enable_bit { }; -/** - * @brief Enumeration for errors. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - */ -typedef enum { - SENSOR_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - SENSOR_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */ - SENSOR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - SENSOR_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */ - SENSOR_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ - SENSOR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ - SENSOR_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data available - @if MOBILE (Since 3.0) @elseif WEARABLE (Since 2.3.2) @endif */ - SENSOR_ERROR_NOT_NEED_CALIBRATION = TIZEN_ERROR_SENSOR | 0x03, /**< Sensor doesn't need calibration */ - SENSOR_ERROR_OPERATION_FAILED = TIZEN_ERROR_SENSOR | 0x06, /**< Operation failed */ - SENSOR_ERROR_NOT_AVAILABLE = TIZEN_ERROR_SENSOR | 0x07, /**< The sensor is supported, but currently not available - @if MOBILE (Since 3.0) @elseif WEARABLE (Since 2.3.2) @endif */ -} sensor_error_e; - - #endif /* __SENSOR_COMMON_H__ */ diff --git a/src/sensorhub/sensorhub.cpp b/src/sensorhub/sensorhub.cpp index 409ca03..511de82 100644 --- a/src/sensorhub/sensorhub.cpp +++ b/src/sensorhub/sensorhub.cpp @@ -56,6 +56,9 @@ int sensorhub_device::get_poll_fd(void) int sensorhub_device::get_sensors(const sensor_info_t **sensors) { int size; + + retvm_if(sensors == NULL || sensors == nullptr, SENSOR_ERROR_INVALID_PARAMETER, "sensorhub_device:NULL interface"); + size = manager->get_sensor_infos(sensors); return size; -- cgit v1.2.3