public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ] gatttool: Update interactive prompt if connection is lost
@ 2012-03-23 15:22 Jefferson Delfes
  2012-03-27 11:50 ` Johan Hedberg
  2012-03-27 13:21 ` [PATCHv2 " Jefferson Delfes
  0 siblings, 2 replies; 5+ messages in thread
From: Jefferson Delfes @ 2012-03-23 15:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

In interactive mode, when connection is lost, the prompt used to remain
in "connected" state. This patch fixes that case, by always showing the
actual connection state.
---
 attrib/interactive.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/attrib/interactive.c b/attrib/interactive.c
index be81424..47ddcf6 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -56,6 +56,7 @@ struct characteristic_data {
 };
 
 static void cmd_help(int argcp, char **argvp);
+static void cmd_disconnect(int argcp, char **argvp);
 
 enum state {
 	STATE_DISCONNECTED,
@@ -327,6 +328,14 @@ static void cmd_exit(int argcp, char **argvp)
 	g_main_loop_quit(event_loop);
 }
 
+static gboolean channel_watcher(GIOChannel *chan, GIOCondition cond,
+				gpointer user_data)
+{
+	cmd_disconnect(0, NULL);
+
+	return TRUE;
+}
+
 static void cmd_connect(int argcp, char **argvp)
 {
 	if (conn_state != STATE_DISCONNECTED)
@@ -347,6 +356,8 @@ static void cmd_connect(int argcp, char **argvp)
 						opt_mtu, connect_cb);
 	if (iochannel == NULL)
 		set_state(STATE_DISCONNECTED);
+	else
+		g_io_add_watch(iochannel, G_IO_HUP, channel_watcher, NULL);
 }
 
 static void cmd_disconnect(int argcp, char **argvp)
-- 
1.7.9.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-03-28  9:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-23 15:22 [PATCH BlueZ] gatttool: Update interactive prompt if connection is lost Jefferson Delfes
2012-03-27 11:50 ` Johan Hedberg
2012-03-27 12:52   ` Jefferson Delfes
2012-03-27 13:21 ` [PATCHv2 " Jefferson Delfes
2012-03-28  9:41   ` Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox