aboutsummaryrefslogtreecommitdiffstats
path: root/attrib/example.c
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2010-09-20 11:11:54 -0300
committerAnderson Lizardo <anderson.lizardo@openbossa.org>2010-09-22 16:00:04 -0400
commitd74b6fd61f4cf3b7d5953d3d1fc08fa2f663874c (patch)
tree3422571cffd685d2dbeca6f49ae05d9eaf9e35b2 /attrib/example.c
parenta66ccf347bb1c319436c25e21fa17381c590aa3c (diff)
downloadbluez-d74b6fd61f4cf3b7d5953d3d1fc08fa2f663874c.tar.gz
bluez-d74b6fd61f4cf3b7d5953d3d1fc08fa2f663874c.tar.xz
bluez-d74b6fd61f4cf3b7d5953d3d1fc08fa2f663874c.zip
Remove the timeout source function when the example server exits
Diffstat (limited to 'attrib/example.c')
-rw-r--r--attrib/example.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/attrib/example.c b/attrib/example.c
index 21799892..76afce9b 100644
--- a/attrib/example.c
+++ b/attrib/example.c
@@ -59,6 +59,8 @@
#define FMT_KILOGRAM_UUID 0xA010
#define FMT_HANGING_UUID 0xA011
+static guint timeout_id = 0;
+
static gboolean change_battery_state(gpointer user_data)
{
static uint8_t state = 0x05;
@@ -163,7 +165,7 @@ static int register_attributes(void)
atval[0] = 0x04;
attrib_db_add(0x0110, &uuid, atval, 1);
- g_timeout_add_seconds(10, change_battery_state, NULL);
+ timeout_id = g_timeout_add_seconds(10, change_battery_state, NULL);
/* Thermometer: primary service definition */
sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
@@ -426,3 +428,8 @@ int server_example_init(void)
{
return register_attributes();
}
+
+void server_example_exit(void)
+{
+ g_source_remove(timeout_id);
+}