#include <glib.h>
#include <sensor.h>
-const sensor_type_e sensor_type[] =
+static const sensor_type_e sensor_type[] =
{
SENSOR_ACCELEROMETER,
SENSOR_GRAVITY,
SENSOR_HUMAN_SLEEP_DETECTOR
};
-const char *sensor_name[] = {
+static const char *sensor_name[] = {
"Accelerometer",
"Gravity sensor",
"Linear acceleration sensor",
};
// the number of value to be verified of the sensor
-const int value_num[] = {3, 3, 3, 3, 4, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 6, 4, 4, 1, 1, 1, 3, 1};
-
-GMainLoop *loop;
-bool turned_on[SENSOR_NUM];
-int min_range[SENSOR_NUM];
-int max_range[SENSOR_NUM];
-int called_num[SENSOR_NUM];
-int miss[SENSOR_NUM];
-int callback_count;
-bool running;
-
-void sensor_callback(sensor_h sensor, sensor_event_s events[], int events_count, void *user_data)
+static const int value_num[] = {3, 3, 3, 3, 4, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 6, 4, 4, 1, 1, 1, 3, 1};
+
+static GMainLoop *loop;
+static bool turned_on[SENSOR_NUM];
+static int min_range[SENSOR_NUM];
+static int max_range[SENSOR_NUM];
+static int called_num[SENSOR_NUM];
+static int miss[SENSOR_NUM];
+static int callback_count;
+static bool running;
+
+static void sensor_callback(sensor_h sensor, sensor_event_s events[], int events_count, void *user_data)
{
const char *name;
sensor_type_e type;
}
}
-int create_sensor_listener(int num, sensor_h *sensor, sensor_listener_h *listener)
+static int create_sensor_listener(int num, sensor_h *sensor, sensor_listener_h *listener)
{
bool supported;
int ret;
sensor_h sensor[29];
sensor_listener_h listener[29];
+ int usable = 0;
for (int i = 0; i < SENSOR_NUM; ++i) {
called_num[i] = 0;
miss[i] = 0;
- if (create_sensor_listener(i, &sensor[i], &listener[i]))
+ if (create_sensor_listener(i, &sensor[i], &listener[i])) {
turned_on[i] = false;
- else
+ }
+ else {
turned_on[i] = true;
+ ++usable;
+ }
}
+ if (usable == 0) {
+ g_print("There is no supported sensor.\n");
+ return -1;
+ }
g_print("testing... ");