summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunmi Ha <yunmi.ha@samsung.com>2021-04-13 15:49:19 +0900
committerYunmi Ha <yunmi.ha@samsung.com>2021-04-13 19:35:10 +0900
commit471dbdce40f1eed3a8d7f1679580829607b26c74 (patch)
treef4b983527a0e6d38f0593c4bf06d6ff6a044c73f
parentd861a3c572a2c80645f552895481ac9fdb58e989 (diff)
downloadsensor-tw3-471dbdce40f1eed3a8d7f1679580829607b26c74.tar.gz
sensor-tw3-471dbdce40f1eed3a8d7f1679580829607b26c74.tar.bz2
sensor-tw3-471dbdce40f1eed3a8d7f1679580829607b26c74.zip
Use sensor_error_e of hal API
Change-Id: I8d7a268c31343cee3e5bc969ba0ea5083ac62ac5 Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
-rw-r--r--src/hal-backend-sensor.cpp16
-rwxr-xr-xsrc/sensor_common.h21
-rw-r--r--src/sensorhub/sensorhub.cpp3
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<accel_device>("Accelerometer");
- create_sensor<gyro_device>("Gyroscope");
- create_sensor<pressure_device>("Pressure");
- create_sensor<light_device>("Light");
- create_sensor<hrm_raw_device>("HRM Raw");
- create_sensor<hrm_device>("HRM");
- create_sensor<sensorhub_device>("Sensorhub");
+ if (devs.empty()) {
+ create_sensor<accel_device>("Accelerometer");
+ create_sensor<gyro_device>("Gyroscope");
+ create_sensor<pressure_device>("Pressure");
+ create_sensor<light_device>("Light");
+ create_sensor<hrm_raw_device>("HRM Raw");
+ create_sensor<hrm_device>("HRM");
+ create_sensor<sensorhub_device>("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 <tizen.h>
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;