[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SPAM] Re: [bluetooth-dev] How to get connection state of ttyBTx



Hi Anders,

of course it is no problem to add the mentioned ioctl.
Here is the patch. Can you apply it to the repository ?

Matthias

Anders Torbjörn Johansson wrote:

> Hello,
> 
> In the current code I can only find BTISLOWERCONNECTED and it will
> return false when the state is BT_ACTIVE. It seems like the 
> IOCTL you are looking for is missing. There should however
> not be any problem to add it :). Add an IOCTL called, as
> example, BTISACTIVE with the same code as the previous one
> except the comparation which should be
> 
> SESSIONSTATE(line) == BT_ACTIVE
> 
> It will probably be better to add a general one which return
> the current state of the line instead of true or false.
> 
> Best Regards
> Anders Johansson
> 
> 
>>-----Original Message-----
>>From: Matthias Fuchs [mailto:matthias.fuchs@xxxxxxx.com]
>>Sent: Monday, April 15, 2002 1:48 PM
>>To: Bluetooth-dev
>>Subject: [bluetooth-dev] [SPAM] How to get connection state of ttyBTx
>>
>>
>>Hi,
>>
>>is there any way to get the connection state 
>>(upper_connected, lower_connected, active, not_connected ..)
>>of a ttyBTx device ? The BT_ISCONNECTED ioctl only returns 
>>information if the lower stack is connected.
>>If upper and lower stack are connected (line is active), this 
>>ioctl returns a "disconnected" (meaning: active, not_connected and
>>active). I need to find out if a line is complete active 
>>(upper and lower connected). Did I miss the right ioctl ?
>>Or is there no way to get this info right now ?
>>
>>Matthias
>>
>>
>>-
>>To unsubscribe from this list: send the line "unsubscribe 
>>bluetooth-dev" in
>>the body of a message to majordomo@xxxxxxx.com
>>
>>
> 
> 


-- 
-------------------------------------------------------------------------

                             _/_/_/_/   Matthias Fuchs
                            _/_/_/_/   Dipl.-Ing.
                           _/_/_/_/   matthias.fuchs@xxxxxxx.com

       _/_/_/   _/_/_/_/_/_/_/      esd electronic system design gmbh
     _/   _/  _/             _/    Vahrenwalder Str. 207
    _/   _/    _/_/_/   _/   _/   D-30165 Hannover
    _/             _/  _/   _/   Phone: +49-511-37298-0
     _/_/_/_/_/_/_/   _/_/_/    Fax:   +49-511-37298-68

-------------------------------------------------------------------------
diff -Nru axis_cvs/apps/bluetooth/experimental/bt_if.c axis_cvs_copy/apps/bluetooth/experimental/bt_if.c
--- axis_cvs/apps/bluetooth/experimental/bt_if.c	Thu Apr 11 19:01:44 2002
+++ axis_cvs_copy/apps/bluetooth/experimental/bt_if.c	Mon Apr 15 14:56:55 2002
@@ -349,6 +349,28 @@
   return ret;
 }
 
+/* Get state of line (rfcomm ready and application running) */
+int bt_getlinestate(int bt_cfd, int line)
+{
+  int fd = (bt_cfd < 0 ? bt_openctrl() : bt_cfd);
+  int ret;
+#ifndef BT_USERSTACK
+  if (fd < 0 || (ret = ioctl(fd, BTGETLINESTATE, &line)) < 0)
+  {
+    perror(__FUNCTION__);
+    exit(1);
+  }
+#else
+  fprintf(stderr, __FUNCTION__ ": not yet implemented...\n");
+  ret = -1;
+#endif
+  if (bt_cfd < 0)
+  {
+    close(fd);
+  }
+  return ret;
+}
+
 void bt_showstatus(void)
 {
 #ifdef BT_USERSTACK
diff -Nru axis_cvs/apps/bluetooth/experimental/bt_if.h axis_cvs_copy/apps/bluetooth/experimental/bt_if.h
--- axis_cvs/apps/bluetooth/experimental/bt_if.h	Thu Apr 11 19:01:45 2002
+++ axis_cvs_copy/apps/bluetooth/experimental/bt_if.h	Mon Apr 15 15:33:29 2002
@@ -136,6 +136,7 @@
 
 //#define BT_SDP_REQUEST _IOW(BT_IOC_MAGIC, 0x0F, bt_sdp_request)
 #define BT_GETCACHEDLINKKEY _IOWR(BT_IOC_MAGIC, 0x10, unsigned char[22])
+#define BTGETLINESTATE _IOW(BT_IOC_MAGIC, 0x11, int)
 
 /* ============================================================== */
 /* Ioctls for executing HCI commands */
@@ -336,6 +337,10 @@
 void bt_showstatus(void);
 int bt_force_msswitch_as_server(int bt_cfd, int enable);
 int bt_set_max_conections(int bt_cfd, int connections);
+int bt_getlinestate(int bt_cfd, int line);
+
+enum bt_session_states { BT_INACTIVE, BT_LOWERCONNECTED, 
+			 BT_UPPERCONNECTED, BT_ACTIVE };
 
 /*  
  * HCI command functions 
diff -Nru axis_cvs/linux/drivers/char/bluetooth/bluetooth.c axis_cvs_copy/linux/drivers/char/bluetooth/bluetooth.c
--- axis_cvs/linux/drivers/char/bluetooth/bluetooth.c	Thu Apr 11 19:01:46 2002
+++ axis_cvs_copy/linux/drivers/char/bluetooth/bluetooth.c	Mon Apr 15 15:34:01 2002
@@ -631,6 +631,15 @@
 		copy_from_user(&line, (s32*)arg, size);
 		return SESSIONSTATE(line) == BT_LOWERCONNECTED;
 	}
+
+	case BTGETLINESTATE:
+	{
+		s32 line;	  
+
+		copy_from_user(&line, (s32*)arg, size);
+	        /* ioctl() returns line state */
+		return SESSIONSTATE(line);
+	}
 	
 	case BTINITSTACK:
 		return bt_init_stack();
diff -Nru axis_cvs/linux/include/linux/bluetooth/btcommon.h axis_cvs_copy/linux/include/linux/bluetooth/btcommon.h
--- axis_cvs/linux/include/linux/bluetooth/btcommon.h	Thu Apr 11 19:01:48 2002
+++ axis_cvs_copy/linux/include/linux/bluetooth/btcommon.h	Mon Apr 15 15:08:59 2002
@@ -148,6 +148,7 @@
 #define BTISLOWERCONNECTED _IOW(BT_IOC_MAGIC, 0x0E, s32)
 #define BT_SDP_REQUEST _IOW(BT_IOC_MAGIC, 0x0F, bt_sdp_request)
 #define BT_GETCACHEDLINKKEY _IOWR(BT_IOC_MAGIC, 0x10, u8[22])
+#define BTGETLINESTATE _IOW(BT_IOC_MAGIC, 0x11, s32)
 
 /* Ioctls executing HCI commands */