Implement multiple sensor logic
authorGeunsun, Lee <gs86.lee@samsung.com>
Mon, 10 Jul 2017 07:45:53 +0000 (16:45 +0900)
committerGeunSun Lee <gs86.lee@samsung.com>
Fri, 14 Jul 2017 01:00:46 +0000 (01:00 +0000)
Change-Id: I9f33f9c9336c32f7ab798d50a10cd0a3ef1a3c33

src/controller.c

index b84b259..ae6ba1a 100644 (file)
 #define GPIO_INFRARED_MOTION_NUM_1 4
 #define I2C_ILLUMINANCE_FIRST_PIN_1 3
 
+#define USE_MULTIPLE_SENSOR 1
+
 typedef struct app_data_s {
        Ecore_Timer *getter_timer[PIN_MAX];
 } app_data;
 
 static Eina_Bool _infrared_motion_getter_timer(void *data)
 {
+#if USE_MULTIPLE_SENSOR
+       int gpio_num[3] = { 16, 23, 26 };
+       int i = 0;
+       int value[3] = { 0, };
+
+       for (i = 0; i < 3; i++) {
+               if (model_read_infrared_motion_sensor(gpio_num[i], &value[i]) == -1) {
+                       _E("Failed to get Infrared Motion value [GPIO:%d]", gpio_num[i]);
+                       continue;
+               }
+               _I("[GPIO:%d] Infrared Motion Value is [%d]", gpio_num[i], value[i]);
+       }
+
+
+       //@TODO: Send the data to Analyzer using connectivity APIs
+
+#else
        int value = 0;
 
        retv_if(resource_read_infrared_motion_sensor(GPIO_INFRARED_MOTION_NUM_1, &value) == -1, ECORE_CALLBACK_CANCEL);
        _I("Infrared Motion Value is [%d]", value);
+#endif
 
        return ECORE_CALLBACK_RENEW;
 }
@@ -75,6 +95,13 @@ static bool service_app_create(void *data)
 {
        app_data *ad = data;
 
+#if USE_MULTIPLE_SENSOR
+       ad->getter_timer[GPIO_INFRARED_MOTION_NUM_1] = ecore_timer_add(3.0, _infrared_motion_getter_timer, ad);
+       if (!ad->getter_timer[GPIO_INFRARED_MOTION_NUM_1]) {
+               _E("Failed to add infrared motion getter timer");
+               return false;
+       }
+#else
        /* One Pin Sensor */
        ad->getter_timer[GPIO_INFRARED_MOTION_NUM_1] = ecore_timer_add(3.0, _infrared_motion_getter_timer, ad);
        if (!ad->getter_timer[GPIO_INFRARED_MOTION_NUM_1]) {
@@ -95,6 +122,7 @@ static bool service_app_create(void *data)
                _D("Failed to add ultra sonic getter timer");
                return false;
        }
+#endif
 
     return true;
 }