summaryrefslogtreecommitdiff
path: root/src/thing_toggler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/thing_toggler.c')
-rw-r--r--src/thing_toggler.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/thing_toggler.c b/src/thing_toggler.c
index d77141e..f80b73a 100644
--- a/src/thing_toggler.c
+++ b/src/thing_toggler.c
@@ -62,10 +62,10 @@ static void service_app_low_memory(app_event_info_h event_info, void *user_data)
/*APP_EVENT_LOW_MEMORY*/
}
-static void _control_led(peripheral_gpio_context_h dev, int power_on)
+static void _control_led(peripheral_gpio_h gpio, int power_on)
{
dlog_print(DLOG_INFO, LOG_TAG, "Write [%d] into GPIO.");
- peripheral_gpio_write(dev, power_on);
+ peripheral_gpio_write(gpio, power_on);
}
static gboolean _toggle_led(gpointer user_data)
@@ -85,7 +85,7 @@ int main(int argc, char* argv[])
char ad[50] = {0,};
service_app_lifecycle_callback_s event_callback;
app_event_handler_h handlers[5] = {NULL, };
- peripheral_gpio_context_h dev = NULL;
+ peripheral_gpio_h gpio = NULL;
guint timer_id = 0;
int ret = 0;
@@ -98,20 +98,20 @@ int main(int argc, char* argv[])
service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, service_app_lang_changed, &ad);
service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, service_app_region_changed, &ad);
- dev = peripheral_gpio_open(GPIO_NUM);
- if (!dev) {
+ peripheral_gpio_open(GPIO_NUM, &gpio);
+ if (!gpio) {
dlog_print(DLOG_INFO, LOG_TAG, "The return value of peripheral_gpio_open is null.");
return 1;
}
- ret = peripheral_gpio_set_direction(dev, PERIPHERAL_GPIO_DIRECTION_OUT);
+ ret = peripheral_gpio_set_direction(gpio, PERIPHERAL_GPIO_DIRECTION_OUT);
if (ret != 0) {
dlog_print(DLOG_INFO, LOG_TAG, "Cannot set direction error.");
return 1;
}
// Return value : the ID (greater than 0) of the event source.
- timer_id = g_timeout_add_seconds(1, _toggle_led, dev);
+ timer_id = g_timeout_add_seconds(1, _toggle_led, gpio);
if (timer_id <= 0) {
dlog_print(DLOG_INFO, LOG_TAG, "Timer id : %d", timer_id);
return 1;
@@ -120,7 +120,7 @@ int main(int argc, char* argv[])
ret = service_app_main(argc, argv, &event_callback, ad);
g_source_remove(timer_id);
- peripheral_gpio_close(dev);
+ peripheral_gpio_close(gpio);
return ret;
}