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

[bluetooth-dev] One more patch !



Hi,

attached to this email is a small patch that brings these (new)
features. Perhaps someone can
have a look and check it in :-)

1) Added more cross compilation stuff to Rules.elinux. You can now do a 
	make CROSSCOMPILE=powerpc-linux- INCLUDEDIR=usr/src/ppclinuc

2) Added a usleep(10000) in the old btd application after setting the
uart baudrate.
   This was removed sometime and has been added to the experiment stuff
in the last days, therfore
   it should be in the old btd.c again. Am I right ? Well, at least I
need it :-)

3) Minor change to experimental/btd.c. ipa_fd is only added to the
FD_SET if an ip_assign server is used.
   Well, since something like a ipassign server is useful (I am working
on a web browser configurable        device, but without ethernet), I
wrote my own one using the IPA API.

4) Up to now the command line option -m was useless. Modememulator was
always enabled and this could not    be touched at the command line.
modem_emul now overrides the hard default.

5) New ioctl to get the RFCOMM server channel number of a currently
connected line.
   I added the ioctl an a API call in bt_if.c. Also some defines in the
headers were needed.
   This call is very useful. For example btdm: In discover_connection
you can decide on the rf_comm          channel number what to do (see
below). Take a look at the switch() statement.

/* Checks for new connections and starts pppd/modememulator */
static void discover_connections(int bt_cfd)
{
  int line;
  unsigned char srvchan;

  D(syslog(LOG_INFO, "discover_connections"));
  for (line = 0; line < BT_NBR_DATAPORTS; line++)
  {
    if ((STATE(line) == NOCONNECTION) && 
        bt_isconnected(bt_cfd, line))
    {
      syslog(LOG_INFO, "Found connection on line : %d !\n", line);
      STATE(line) = CONNECTED;
      
      read_remote_bd(bt_cfd, PEER(line).remote_bd);
      print_bd_addr("remote bd ", PEER(line).remote_bd);

      /* get rfcomm server channel - mfuchs */
      bt_getrfcommchannel(bt_cfd,line,&srvchan);  
      syslog(LOG_INFO, "rfcomm channel is %d !\n",srvchan);

      /* decide on rfcomm server channel number what is to do - mfuchs
*/
      switch(srvchan) 
	{
	case 2:
#ifdef USE_IPASSIGN
	  D(syslog(LOG_INFO, "Sending IPA request\n"));
	  
	  PEER(line).ipset = &IPSET(line);
	  
	  STATE(line) = WAITING_PPPCONF;
	  if (ipa_sendrequest(line, (unsigned char *)&PEER(line).remote_bd, 
			      IPAREQ_GETIPSET) < 0)
	    {
	      syslog(LOG_INFO, "IPA request failed or no IPA server");
	      
	      /* Build without IPA anyway */
	      STATE(line) = PPPCONF_DONE;
	      build_pppdopts(line, (char**)pppd_options);      
	      start_pppd(line, speedstr, (char**)pppd_options);     
	    }
	  else
	    D(syslog(LOG_INFO, "IPA request sent"));
#else
	  STATE(line) = PPPCONF_DONE;
	  build_pppdopts(line, (char**)pppd_options);      
	  start_pppd(line, speedstr, (char**)pppd_options);     
#endif  
	  break;

	case 4:
	  /* example: put code for an other server application here */
	  /* e.g. LAN access using PPP without modem emulator       */

	  syslog(LOG_INFO, "Starting other server application\n");
	  STATE(line) = PPPCONF_DONE;
	  build_pppdopts(line, (char**)pppd_options);      
	  start_other_server(line, speedstr, (char**)pppd_options);     
	  syslog(LOG_INFO, "... started other server application\n");
	  break;

	default:
	  /* this should never be the case, because this server channel is not
published by SDP */
	  syslog(LOG_INFO, "unsupported rfcomm server channel -
disconnect",srvchan);
	  break;
	}
    }
  }
}

Ok, that's it for now. Hope some of my changes will find the way into
the CVS.

Matthias
-- 
-------------------------------------------------
\ Matthias Fuchs                                 \
 \ esd electronic system design Gmbh              \
  \ Vahrenwalder Straße 205                        \
   \ D-30165 Hannover                               \
    \ email: matthias.fuchs@xxxxxxx.com      \
     \ phone: +49-511-37298-0                         \
      \ fax:   +49-511-37298-68                        \
       --------------------------------------------------
diff -r -u --exclude CVS cvs/apps/Rules.elinux current/apps/Rules.elinux
--- cvs/apps/Rules.elinux	Thu Mar  1 00:42:08 2001
+++ current/apps/Rules.elinux	Mon Mar 19 16:41:05 2001
@@ -67,7 +67,12 @@
 
 # This is for building for the local host
 
-RANLIB = ranlib
+RANLIB  = $(CROSSCOMPILE)ranlib
+OBJCOPY = $(CROSSCOMPILE)objcopy
+LD      = $(CROSSCOMPILE)ld
+AR      = $(CROSSCOMPILE)ar
+RANLIB  = $(CROSSCOMPILE)ranlib
+CC      = $(CROSSCOMPILE)gcc
 
 TARGET_TYPE = host
 TARGET_ENV = "\$$HROOT"
diff -r -u --exclude CVS cvs/apps/bluetooth/btd/btd.c current/apps/bluetooth/btd/btd.c
--- cvs/apps/bluetooth/btd/btd.c	Fri Mar 30 14:49:06 2001
+++ current/apps/bluetooth/btd/btd.c	Mon Apr  2 11:09:04 2001
@@ -3185,6 +3185,8 @@
 
   printf("Setting baudrate in Ericsson module!\n");  
   hci_set_baudrate(spd);  
+
+  usleep(10000);
 #endif
 }
 
diff -r -u --exclude CVS cvs/apps/bluetooth/experimental/bt_if.c current/apps/bluetooth/experimental/bt_if.c
--- cvs/apps/bluetooth/experimental/bt_if.c	Fri Mar 30 14:31:46 2001
+++ current/apps/bluetooth/experimental/bt_if.c	Fri Mar 30 17:03:56 2001
@@ -396,6 +396,26 @@
 #endif
 }
 
+
+void
+bt_getrfcommchannel(int bt_fd, int line, unsigned char *srvchan)  /* mfuchs */
+{
+  int dlci;
+#ifndef BT_USERSTACK
+    if ((dlci=ioctl(bt_fd, BTGETRFCOMMCHAN, &line)) < 0)
+    {
+      perror("bt_getrfcommchannel");
+      exit(1);
+    }
+    //printf("bt_getrfcommchannel : line %d uses rfcomm channel %d !\n",line,dlci);
+    *srvchan = (unsigned char)(dlci >> 1);
+#else
+    /* fixme<1> */
+    printf("bt_getrfcommchannel : not impl in usermode stack\n");
+#endif
+}
+
+
 int bt_send_raw_hci(int bt_cfd, unsigned char *data, char len)
 {
   unsigned char buf[261];
diff -r -u --exclude CVS cvs/apps/bluetooth/experimental/bt_if.h current/apps/bluetooth/experimental/bt_if.h
--- cvs/apps/bluetooth/experimental/bt_if.h	Fri Mar 30 14:32:47 2001
+++ current/apps/bluetooth/experimental/bt_if.h	Fri Mar 30 17:26:13 2001
@@ -139,6 +139,8 @@
 #define BTWAITFORCONNECTION _IOW(BT_IOC_MAGIC, 0x0a, int)
 #define BTWAITNEWCONNECTIONS _IO(BT_IOC_MAGIC, 0x0b)
 #define BTISLOWERCONNECTED _IOW(BT_IOC_MAGIC, 0x0c, int)
+#define BT_SDP_REQUEST _IOW(BT_IOC_MAGIC, 0x0d, bt_sdp_request)
+#define BTGETRFCOMMCHAN _IOW(BT_IOC_MAGIC, 0x0e, int) /* mfuchs */
 
 #define BTSETSPEED _IOW(BT_IOC_MAGIC, 0x02, int)
 #define BTINITSTACK _IO(BT_IOC_MAGIC, 0x03)
@@ -290,6 +292,7 @@
 int bt_send(int fd, int len, int repeat);
 void bt_showstatus(void);
 int bt_force_msswitch_as_server(int bt_cfd, int enable);
+void bt_getrfcommchannel(int bt_fd, int line, unsigned char *srvchan); /* mfuchs */
 
 /*  
  * HCI command functions 
diff -r -u --exclude CVS cvs/apps/bluetooth/experimental/btd.c current/apps/bluetooth/experimental/btd.c
--- cvs/apps/bluetooth/experimental/btd.c	Mon Mar 26 17:30:36 2001
+++ current/apps/bluetooth/experimental/btd.c	Mon Apr  2 11:24:50 2001
@@ -317,7 +318,9 @@
     tv.tv_usec = 0;
 
     FD_ZERO(&rfd);  
+#ifdef USE_IPASSIGN
     FD_SET(ipa_fd, &rfd);
+#endif
     FD_SET(0, &rfd);
 
     result = select(FD_SETSIZE, &rfd, (fd_set*)0, 
@@ -620,6 +688,8 @@
       
       _exit(0);
     } 
+    else
+      D(syslog(LOG_INFO, "Started pppd on %s [pid : %d]", dev, PEER(line).pppd_pid)); 
   }
   
   return 0; 
@@ -744,7 +814,7 @@
   {
     PEER(i).state = NOCONNECTION;
     PEER(i).pppd_pid = -1;
-    PEER(i).do_modememul = 1; /* all enabled per default */
+    PEER(i).do_modememul = modem_emul; /* all enabled per default, but "-m 1" option overwrites default - mfuchs */
     PEER(i).ipset = NULL;
   }  
   
diff -r -u --exclude CVS cvs/linux/drivers/char/bluetooth/bluetooth.c current/linux/drivers/char/bluetooth/bluetooth.c
--- cvs/linux/drivers/char/bluetooth/bluetooth.c	Sun Apr  1 17:50:12 2001
+++ current/linux/drivers/char/bluetooth/bluetooth.c	Mon Apr  2 11:20:38 2001
@@ -251,6 +251,7 @@
 #define BTCTRL bt_ctrl /* the name of the struct that holds all data */
 #define GET_UPPERTTY(line) (BTCTRL.session[line].upper_tty)
 #define SESSIONSTATE(line) (BTCTRL.session[line].state)
+#define SESSIONDLCI(line) (BTCTRL.session[line].dlci) /* mfuchs */
 #define NBR_ACTIVE BTCTRL.nbr_active
 #define NBR_UPPER BTCTRL.nbr_upper
 #define NBR_CTRL_FDS BTCTRL.ctrl_tty_count
@@ -581,6 +582,13 @@
 		s32 line;	  
 		copy_from_user(&line, (s32*)arg, size);
 		return (SESSIONSTATE(line) == BT_LOWERCONNECTED);
+	}
+
+	case BTGETRFCOMMCHAN : /* mfuchs */
+	{
+		s32 line;	  
+		copy_from_user(&line, (s32*)arg, size);
+		return (int)SESSIONDLCI(line);
 	}
 	
 	case BTSETSPEED:
diff -r -u --exclude CVS cvs/linux/include/linux/bluetooth/btcommon.h current/linux/include/linux/bluetooth/btcommon.h
--- cvs/linux/include/linux/bluetooth/btcommon.h	Fri Mar 30 11:40:53 2001
+++ current/linux/include/linux/bluetooth/btcommon.h	Fri Mar 30 17:27:59 2001
@@ -131,7 +131,7 @@
 #define BTWAITNEWCONNECTIONS _IO(BT_IOC_MAGIC, 0x0b)
 #define BTISLOWERCONNECTED _IOW(BT_IOC_MAGIC, 0x0c, s32)
 #define BT_SDP_REQUEST _IOW(BT_IOC_MAGIC, 0x0d, bt_sdp_request)
-
+#define BTGETRFCOMMCHAN _IOW(BT_IOC_MAGIC, 0x0e, s32) /* mfuchs */
 
 /* ioctls executing HCI commands */