Return-Path: Message-ID: From: "Albert Huang" To: bluez-devel@lists.sourceforge.net Subject: Re: [Bluez-devel] Selection of Local module.... In-Reply-To: <049f01c65cb0$0d478bf0$0300a8c0@akira> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_3380_11677985.1144690677709" References: <049f01c65cb0$0d478bf0$0300a8c0@akira> Sender: bluez-devel-admin@lists.sourceforge.net Errors-To: bluez-devel-admin@lists.sourceforge.net Reply-To: bluez-devel@lists.sourceforge.net List-Unsubscribe: , List-Id: BlueZ development List-Post: List-Help: List-Subscribe: , List-Archive: Date: Mon, 10 Apr 2006 13:37:57 -0400 ------=_Part_3380_11677985.1144690677709 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline bind() to the address and channel of the local adapter you want to use before the call to connect() -albert On 4/10/06, Sir Graham (Terra) wrote: > > *Hi,* > ** > *I need to use two bluetooth devices in the same computer with BlueZ.* > ** > *How can I select (with socket) the device local that I like make a > conexion?* > > > *If I make a simple conexion... Can I select what of my local modules > (HCI0 or HCI1) makes this conexion?* > > > #include > #include > #include > #include > #include > > int main(int argc, char **argv) > { > struct sockaddr_rc addr =3D { 0 }; > int s, status; > char dest[18] =3D "01:23:45:67:89:AB"; > > // allocate a socket > s =3D socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM); > > // set the connection parameters (who to connect to) > addr.rc_family =3D AF_BLUETOOTH; > addr.rc_channel =3D (uint8_t) 1; > str2ba( dest, &addr.rc_bdaddr ); > > // connect to server > status =3D connect(s, (struct sockaddr *)&addr, sizeof(addr)); > > // send a message > if( status =3D=3D 0 ) { > status =3D write(s, "hello!", 6); > } > > if( status < 0 ) perror("uh oh"); > > close(s); > return 0; > } > > *Can I select what of my local modules (HCI0 or HCI1) makes this > conexion? * > > *Where can I select (in the example) what local module use? =BF=BF=BF???= * > ** > *Regards,* > *Sir Graham.* > ** > > > > ------=_Part_3380_11677985.1144690677709 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline bind() to the address and channel of the local adapter you want to use befo= re the call to connect()

-albert

On 4/10/06, Sir Graham (Terra) <<= a href=3D"mailto:sir__graham@terra.es"> sir__graham@terra.es> wrote:
Hi,
 
I need to use two bluetooth de= vices in the=20 same computer with BlueZ.
 
How  can I select (with s= ocket) the=20 device local that I like make a conexion?
 
 
If I make a simple conexion...= Can I select=20 what of my local modules (HCI0 or HCI1) makes this=20 conexion?
 
 
#include <stdio.h>
#inc= lude=20 <unistd.h>
#include <sys/socket.h>
#include=20 <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
int=20 main(int argc, char **argv)
{
    struct sockaddr_rc a= ddr =3D=20 { 0 };
    int s, status;
    char dest= [18]=20 =3D "01:23:45:67:89:AB";

    // allocate a= =20 socket
    s =3D socket(AF_BLUETOOTH, SOCK_STREAM,=20 BTPROTO_RFCOMM);

    // set the connection parameters= (who=20 to connect to)
    addr.rc_family =3D=20 AF_BLUETOOTH;
    addr.rc_channel =3D (uint8_t)=20 1;
    str2ba( dest, &addr.rc_bdaddr=20 );

    // connect to server
    sta= tus =3D=20 connect(s, (struct sockaddr *)&addr,=20 sizeof(addr));

    // send a message
  &= nbsp;=20 if( status =3D=3D 0 ) {
        statu= s =3D=20 write(s, "hello!", 6);
    }

  = ;  if(=20 status < 0 ) perror("uh oh");

   =20 close(s);
    return 0;
}
 
Can I select what of my local = modules (HCI0=20 or HCI1) makes this conexion? 
 
Where can I select (in t= he example)=20 what local module use?  =BF=BF=BF???
&= nbsp;
Regards,=
Sir=20 Graham.
 

 
 

------=_Part_3380_11677985.1144690677709-- ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel