examples/notification: Exit cleanly notification example

pull/91/head
Olivier Martin 2019-03-05 16:35:48 +01:00 committed by Olivier Martin
parent 62022bdab9
commit cbeca9d6c0
1 changed files with 6 additions and 2 deletions

View File

@ -66,14 +66,18 @@ int main(int argc, char *argv[]) {
ret = gattlib_notification_start(connection, &g_battery_level_uuid);
if (ret) {
fprintf(stderr, "Fail to start notification\n.");
return 1;
goto DISCONNECT;
}
GMainLoop *loop = g_main_loop_new(NULL, 0);
g_main_loop_run(loop);
// In case we quit the main loop, clean the connection
gattlib_notification_stop(connection, &g_battery_level_uuid);
g_main_loop_unref(loop);
DISCONNECT:
gattlib_disconnect(connection);
puts("Done");
return 0;
return ret;
}