From f6ed27b863b974f1b6acc2df8d9287ecedcefb2f Mon Sep 17 00:00:00 2001 From: bernard Date: Sun, 4 Jan 2015 20:01:52 +0800 Subject: [PATCH] [DeviceDrivers] Fix sensor_poll issue. --- components/drivers/sensors/sensor.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/components/drivers/sensors/sensor.cpp b/components/drivers/sensors/sensor.cpp index 34bf5a5890..18eb8eee18 100644 --- a/components/drivers/sensors/sensor.cpp +++ b/components/drivers/sensors/sensor.cpp @@ -189,21 +189,27 @@ int SensorManager::pollSensor(SensorBase *sensor, sensors_event_t *events, int n return index; } -int rt_sensor_subscribe(int type, SensorEventHandler_t *handler, void *user_data) -{ - return SensorManager::subscribe(type, handler, user_data); -} - rt_sensor_t rt_sensor_get_default(int type) { return (rt_sensor_t)SensorManager::getDefaultSensor(type); } +int rt_sensor_subscribe(rt_sensor_t sensor, SensorEventHandler_t *handler, void *user_data) +{ + SensorBase *sensor_base; + if (sensor == NULL) return -1; + + sensor_base = (SensorBase*)sensor; + + return sensor_base->subscribe(handler, user_data); +} + int rt_sensor_poll(rt_sensor_t sensor, sensors_event_t *event) { SensorBase *sensor_base; if (sensor == NULL || event == NULL) return -1; + sensor_base = (SensorBase*)sensor; return sensor_base->poll(event); } @@ -224,4 +230,3 @@ int rt_sensor_activate(rt_sensor_t sensor, int enable) sensor_base = (SensorBase*)sensor; return sensor_base->activate(enable); } -