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

RE: [bluetooth-dev] BT_CTRL_TTY & /dev/ttyBTx ..!



Hello,

The control TTY (ttyBTC) is only used to send IOCTL:s to the driver, it
can be opened several times. 
The ttyBTx-devices are used to send/receive data from the driver and can
only be open by one process 
at the same time. Typically the control tty is used by a daemon to check
for incoming connections and
then it uses the ttyBTx-devices to send and receive data.

Line is the identifier for the ttyBT, so ttyBT0 = line 0. 

I'm not sure why you need to parse the procfile, have a look at the
function discover_connection
in btdm.c. An example how you open the device and send data can be found
in btsend.c. I haven't
analyzed the parsing code below but if you manage to get the correct tty
which is connected you
shall be able to send data with the method you are using below.

Best Regards,
Anders

> -----Original Message-----
> From: owner-bluetooth-dev On Behalf Of axis
> Sent: den 9 januari 2004 10:42
> To: Bluetooth-dev
> Subject: [bluetooth-dev] BT_CTRL_TTY & /dev/ttyBTx ..!
> 
> Sir,
>      Could anyone please tell me the difference between 
> BT_CTRL_TTY and /dev/ttyBTx.Do we need to use both at the same time?
>      And is "line" the "x" in /dev/ttyBTx ? If so is the 
> following code correct for opening the tty and sending the 
> data to my device from access point.
>      Please have a look at lines marked ****** and your help 
> in this regard will be very helpful for my Masters Thesis.
> Thank you
> 
>   while(1){
> 
> ****** if((bt_cfd = bt_openctrl()) < 0)
>        {
>         perror("Could not open BT Control device");
>         exit(1);
>        }
> 
>     if(!bt_isinitiated(bt_cfd))
>       {
>         printf("Stack not initianted ,exit\n");
>         exit(1);
>       }
>         printf("Reading proc file\n");
> ******  pFile = fopen("/proc/bt_channel_con","r");
>         if(pFile == 0)
>                 perror("fopen");
> ******  temp = fread(buffer, 5, 1, pFile);
>         printf("Connect on bt_cfd %d,temp %d buffer %s line 
> %c\n", bt_cfd,temp,buffer,buffer[0]);
>         fclose(pFile);
>         t1 = (char *)malloc(sizeof(char));
>         t2 = (char *)malloc(sizeof(char));
>         sprintf(t1,"%c",buffer[0]);
>         sprintf(t2,"%c",buffer[2]);
> *****   line = atoi(t1);
> *****   srv_ch = atoi(t2);
> *****   if(bt_isconnected(bt_cfd,line))
>         {
>      *(int*)bd_addr = line;
>      if(ioctl(bt_cfd, BTREADREMOTEBDADDR, bd_addr) <
> 0)
>                 {
>                         perror("BTREADREMOTEBDADDR");
>                 }
> 
>         tty[10] = buffer[0];
>         printf("The tty is %s\n",tty);
> *****   fd = open_device(tty,O_RDWR,0);
>         printf("Device file descriptor %d\n",fd);
> 
>         for(i=0;i<20000;i++)
>         {
> *****         if(write(fd,buffer,5) != 5)
>                         perror("write");
>         }
>                 close_device(fd);
>      }
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes 
> http://hotjobs.sweepstakes.yahoo.com/signingbonus
> -
> To unsubscribe from this list: send the line "unsubscribe 
> bluetooth-dev" in the body of a message to majordomo@xxxxxxx.com
> 

-
To unsubscribe from this list: send the line "unsubscribe bluetooth-dev" in
the body of a message to majordomo@xxxxxxx.com