summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoyeon <boyeon.son@samsung.com>2019-08-13 20:19:39 +0900
committerBoyeon <boyeon.son@samsung.com>2019-08-13 20:21:55 +0900
commitbe10d13b9edcf00e9ff5ab347de34063d86491d8 (patch)
tree1aa461777541a7c83a176d8a9a76a265f6da387d
parent19cc6f0a2e32b77506aaf102b7412d68bef01cec (diff)
downloadst-things-light-be10d13b9edcf00e9ff5ab347de34063d86491d8.tar.gz
st-things-light-be10d13b9edcf00e9ff5ab347de34063d86491d8.tar.bz2
st-things-light-be10d13b9edcf00e9ff5ab347de34063d86491d8.zip
Add some comments and clarify function names / Change the name of the project
Change-Id: Iaaa6672b3c708ad535f9df41d0dff01fdd05a2c1
-rw-r--r--.project2
-rw-r--r--.tproject2
-rw-r--r--shared/res/icon.png (renamed from shared/res/motion.png)bin57662 -> 57662 bytes
-rwxr-xr-xsrc/controller.c20
-rw-r--r--tizen-manifest.xml4
5 files changed, 18 insertions, 10 deletions
diff --git a/.project b/.project
index af28b71..dd48221 100644
--- a/.project
+++ b/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>smart-light</name>
+ <name>smart-light-basic</name>
<comment></comment>
<projects>
</projects>
diff --git a/.tproject b/.tproject
index 903a965..7bd616a 100644
--- a/.tproject
+++ b/.tproject
@@ -2,7 +2,7 @@
<tproject xmlns="http://www.tizen.org/tproject">
<platforms>
<platform>
- <name>iot-headed-5.0</name>
+ <name>iot-headless-5.0</name>
</platform>
</platforms>
<package>
diff --git a/shared/res/motion.png b/shared/res/icon.png
index 9765b1b..9765b1b 100644
--- a/shared/res/motion.png
+++ b/shared/res/icon.png
Binary files differ
diff --git a/src/controller.c b/src/controller.c
index ba706bf..bbb2110 100755
--- a/src/controller.c
+++ b/src/controller.c
@@ -38,9 +38,10 @@ typedef struct app_data_s {
Ecore_Timer *getter_timer;
} app_data;
-static int _set_led_data(app_data *ad, int state) {
+static int _change_led_state(int state) {
int ret = 0;
+ // Write state to LED light
ret = resource_write_led(SENSOR_LED_GPIO_NUMBER, state);
if (ret != 0) {
_E("cannot write led data");
@@ -51,17 +52,17 @@ static int _set_led_data(app_data *ad, int state) {
return 0;
}
-static Eina_Bool _get_motion_sensor_data(void *user_data)
+static Eina_Bool _get_motion_set_led()
{
int ret = 0;
uint32_t value = 0;
- app_data *ad = user_data;
if (!ad) {
_E("failed to get app_data");
return ECORE_CALLBACK_CANCEL;
}
+ // Get value from motion sensor
ret = resource_read_infrared_motion_sensor(SENSOR_MOTION_GPIO_NUMBER, &value);
if (ret != 0) {
_E("cannot read data from the infrared motion sensor");
@@ -70,7 +71,8 @@ static Eina_Bool _get_motion_sensor_data(void *user_data)
_D("Detected motion value is: %u", value);
- _set_led_data(ad, value);
+ // Set LED light with value
+ _change_led_state(value);
return ECORE_CALLBACK_RENEW;
}
@@ -84,10 +86,12 @@ static void service_app_control(app_control_h app_control, void *user_data)
{
app_data *ad = user_data;
+ // Delete old timer if there is one
if (ad->getter_timer)
ecore_timer_del(ad->getter_timer);
- ad->getter_timer = ecore_timer_add(TIMER_GATHER_INTERVAL, _get_motion_sensor_data, ad);
+ // Create a timer to call the given function in given period of time
+ ad->getter_timer = ecore_timer_add(TIMER_GATHER_INTERVAL, _get_motion_set_led, ad);
if (!ad->getter_timer) {
_E("Failed to add getter timer");
return;
@@ -98,8 +102,12 @@ static void service_app_terminate(void *user_data)
{
app_data *ad = user_data;
+ // Delete timer
+ if (ad->getter_timer)
+ ecore_timer_del(ad->getter_timer);
+
// Turn off LED light with __set_led()
- _set_led_data(ad, 0);
+ _change_led_state(0);
// Close Motion and LED resources
resource_close_infrared_motion_sensor();
diff --git a/tizen-manifest.xml b/tizen-manifest.xml
index 83d5397..26e3a1e 100644
--- a/tizen-manifest.xml
+++ b/tizen-manifest.xml
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<manifest xmlns="http://tizen.org/ns/packages" api-version="5.0" package="org.example.smart-light" version="1.0.0">
- <profile name="iot-headed"/>
+ <profile name="iot-headless"/>
<service-application appid="org.example.smart-light" exec="smart-light" multiple="false" nodisplay="true" on-boot="true" taskmanage="false" type="capp">
<label>smart-light</label>
- <icon>smart-light.png</icon>
+ <icon>icon.png</icon>
<metadata key="http://tizen.org/iot/metadata/master" value="shared/res/master.json"/>
<metadata key="http://tizen.org/iot/metadata/resource" value="shared/res/resource.json"/>
<background-category value="background-network"/>