public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] HCI forwarding
@ 2005-01-02  4:29 radeX
  2005-01-02 11:39 ` Marcel Holtmann
  0 siblings, 1 reply; 10+ messages in thread
From: radeX @ 2005-01-02  4:29 UTC (permalink / raw)
  To: bluez-devel

[-- Attachment #1: Type: text/plain, Size: 1488 bytes --]

Hi everybody:

 

I've been months reading the bluez source and learning about the bluetooth
specification, plus other documents (the correct coding style, Wireless
Technologies Congress 2003 and other documents by Marcel holtmann)

 

I'm developing an application to connect two Bluetooth-enabled phones via
internet using two Bluetooth-enabled PCs both connected to internet. I mean
that I can transmit files and play Bluetooth multiplayer games to my friend
that is 25 miles away like if it were in my device's Bluetooth radio range.
(I know that ping times would be very ugly!).

I use a raw socket as hcidump does, then I send the data trough TCP to the
other peer, when received is sent over Bluetooth hoping that the other
device receives it, this is more complex than it seems since bluez handles
and answers all HCI requests, i.e (when a device performs a SDP request to
find a service UUID bluez handles and answers the request) but this is not
correct for my application, hci responses and data acks may be received via
TCP from the other peer, in other words: no bluez support, only HCI frames
sniffing, sending, receiving and transmitting. Now my questions are:

 

-          Can I send HCI frames with a raw socket ?

-          How can I tell the bluez stack not to answer HCI requests
(receiving only, leave the sends to me).

 

-     Is there a better way to make this application?

 

Any help would be greatly appreciated.

 

Thanks in advance and happy new year.


[-- Attachment #2: Type: text/html, Size: 6474 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: [Bluez-devel] Several bluetooth dongles at time
@ 2005-02-10 12:41 Marcel Holtmann
  2005-02-10 13:10 ` [Bluez-devel] HCI Forwarding radeX
  0 siblings, 1 reply; 10+ messages in thread
From: Marcel Holtmann @ 2005-02-10 12:41 UTC (permalink / raw)
  To: BlueZ Mailing List

Hi Matthias,

> I am runnning a rfcomm server on a linux pc and want mobile phones to
> connect to it.
> I need some clearence about the following questions:
> 
> 1) As the phone is connecting to the pc and not the other way around, the
> pc is the slave at first. As far as I know a slave cannot connect to more
> than one device at time. So I force a role switch to master after
> connection. What happend when another phone will connect? The PC will be
> master from the beginning and no role switch is needed? (I don't have a
> second mobile to test, at the moment)

there will be transient state and therefor you need at least a dongle
that can do scatternet. Not all mobile phones support role switch. This
is a hardware limitation, because some of them contain an old chip.

> 2) Can i have multiple connections on the same rfcomm channel? So more
> than one mobile can connect to my server at time or only one device per
> channel and i have to open more than one channel?

One connection per RFCOMM channel. On the RFCOMM level there is no
further multiplexing.

> 3) If I have more than one bluetooth dongle how can I say which dongle to
> use for the connections? At the moment I am setting the field rc_bdaddr to
> the address of the bluetooth dongle I am willing to use. Is that about
> right? What happens if I am using BDADDR_ANY, BDADDR_ALL or BDADDR_LOCAL
> instead? Is there any convinient way that bluez automatically chooses
> another dongle if all connections on one dongle are full?

When writing a RFCOMM server you can bind it to a specific local address
or to all local addresses (ANY). The ALL and LOCAL addreses are not
useful for this and they also won't work.

After the connection you can use getsockname() to get the address of the
local device.

There is no load-balancing for connections. It is point-to-point and the
mobile phone in your case decides what dongle to connect to.

> This is the code I am using:
> 
>   int sock, client, alen;
>   int dev;
> 
>   struct sockaddr_rc addr;
>   if( (sock = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)) < 0)
>     {
>       perror("socket");
>       exit(1);
>     }
> 
>   addr.rc_family = AF_BLUETOOTH;
>   bdaddr_t local;
>   str2ba("00:10:60:A4:03:01", &local);
>   bacpy(&addr.rc_bdaddr, &local);
>   addr.rc_channel = htobs(channel);
>   alen = sizeof(addr);

I don't know where you guys copy your examples from. The htobs() for the
channel is wrong. This value is only uint8_t and so it won't on big
endian platforms.

And for what is this crazy str->local->rc_bdaddr thing needed?

>   if(bind(sock, (struct sockaddr *)&addr, alen) < 0)
>     {
>       perror("bind");
>       exit(1);
>     }
> 
>   listen(sock,10);
>   printf("%d Waiting for connections...\n\n",channel);
> 
>   if(client = accept(sock, (struct sockaddr *)&addr, &alen))
>     {
>       printf("%d Got a connection attempt!\n",channel);
>     }
> 
>   dev=hci_open_dev(0);
>   if (dev<0) {
>     printf("Error opening hci dev");
>     exit(1);
> 
>     }

This thing here is wrong and will only work as long as only one dongle
is attached. You need to find the correct one, see getsockname() etc.

>   if (hci_switch_role(dev, &addr.rc_bdaddr, 0, 10000) <0) {
>     printf("Role switch failed!");
>     }
>   close(dev);

This reminds me that the RFCOMM_MASTER link mode support is missing.
Feel free to send me a patch for that instead of hacking around it.

Regards

Marcel




-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

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

end of thread, other threads:[~2005-02-10 14:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-02  4:29 [Bluez-devel] HCI forwarding radeX
2005-01-02 11:39 ` Marcel Holtmann
2005-01-02 16:58   ` radeX
2005-01-02 17:32     ` Marcel Holtmann
2005-01-02 19:02       ` radeX
2005-01-02 19:21         ` Marcel Holtmann
2005-01-02 20:26           ` radeX
2005-01-02 20:45             ` Marcel Holtmann
  -- strict thread matches above, loose matches on Subject: below --
2005-02-10 12:41 [Bluez-devel] Several bluetooth dongles at time Marcel Holtmann
2005-02-10 13:10 ` [Bluez-devel] HCI Forwarding radeX
2005-02-10 14:47   ` Marcel Holtmann

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