All of lore.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] Selection of Local module....
@ 2006-04-10 15:03 Sir Graham (Terra)
  2006-04-10 17:37 ` Albert Huang
  0 siblings, 1 reply; 6+ messages in thread
From: Sir Graham (Terra) @ 2006-04-10 15:03 UTC (permalink / raw)
  To: bluez-devel

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

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 <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>

int main(int argc, char **argv)
{
    struct sockaddr_rc addr = { 0 };
    int s, status;
    char dest[18] = "01:23:45:67:89:AB";

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

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

    // connect to server
    status = connect(s, (struct sockaddr *)&addr, sizeof(addr));

    // send a message
    if( status == 0 ) {
        status = 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?  ¿¿¿???

Regards,
Sir Graham.





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

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

* Re: [Bluez-devel] Selection of Local module....
  2006-04-10 15:03 [Bluez-devel] Selection of Local module Sir Graham (Terra)
@ 2006-04-10 17:37 ` Albert Huang
  2006-04-10 18:51   ` Sir Graham (Terra)
  0 siblings, 1 reply; 6+ messages in thread
From: Albert Huang @ 2006-04-10 17:37 UTC (permalink / raw)
  To: bluez-devel

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

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) <sir__graham@terra.es> 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 <stdio.h>
> #include <unistd.h>
> #include <sys/socket.h>
> #include <bluetooth/bluetooth.h>
> #include <bluetooth/rfcomm.h>
>
> int main(int argc, char **argv)
> {
>     struct sockaddr_rc addr = { 0 };
>     int s, status;
>     char dest[18] = "01:23:45:67:89:AB";
>
>     // allocate a socket
>     s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
>
>     // set the connection parameters (who to connect to)
>     addr.rc_family = AF_BLUETOOTH;
>     addr.rc_channel = (uint8_t) 1;
>     str2ba( dest, &addr.rc_bdaddr );
>
>     // connect to server
>     status = connect(s, (struct sockaddr *)&addr, sizeof(addr));
>
>     // send a message
>     if( status == 0 ) {
>         status = 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?  ¿¿¿???*
> **
> *Regards,*
> *Sir Graham.*
> **
>
>
>
>

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

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

* Re: [Bluez-devel] Selection of Local module....
  2006-04-10 17:37 ` Albert Huang
@ 2006-04-10 18:51   ` Sir Graham (Terra)
  2006-04-11 19:29     ` Albert Huang
  0 siblings, 1 reply; 6+ messages in thread
From: Sir Graham (Terra) @ 2006-04-10 18:51 UTC (permalink / raw)
  To: bluez-devel

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

Hi,

Thanks for you answer....

This works when you make a server conexion.... but... When you create a client function works also the bind function? 

you see the function attachment to my first message. If I put a bind call in this function (client connect funcion) can i select the local bluetooth device? 

Regards,
Sir Graham.


  ----- Original Message ----- 
  From: Albert Huang 
  To: bluez-devel@lists.sourceforge.net 
  Sent: Monday, April 10, 2006 7:37 PM
  Subject: Re: [Bluez-devel] Selection of Local module....


  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) < sir__graham@terra.es> 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 <stdio.h>
    #include <unistd.h>
    #include <sys/socket.h>
    #include <bluetooth/bluetooth.h>
    #include <bluetooth/rfcomm.h>

    int main(int argc, char **argv)
    {
        struct sockaddr_rc addr = { 0 };
        int s, status;
        char dest[18] = "01:23:45:67:89:AB";

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

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

        // connect to server
        status = connect(s, (struct sockaddr *)&addr, sizeof(addr));

        // send a message
        if( status == 0 ) {
            status = 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?  ¿¿¿???

    Regards,
    Sir Graham.







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

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

* Re: [Bluez-devel] Selection of Local module....
  2006-04-10 18:51   ` Sir Graham (Terra)
@ 2006-04-11 19:29     ` Albert Huang
  2006-04-11 20:21       ` Sir Graham (Terra)
  0 siblings, 1 reply; 6+ messages in thread
From: Albert Huang @ 2006-04-11 19:29 UTC (permalink / raw)
  To: bluez-devel

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

Hi Sir Graham,

This works when you make a server conexion.... but... When you create
aclient function works also the bind function?
>

Feel free to try it out before you believe me.

Regards,
Albert

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

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

* Re: [Bluez-devel] Selection of Local module....
  2006-04-11 19:29     ` Albert Huang
@ 2006-04-11 20:21       ` Sir Graham (Terra)
  2006-04-11 22:10         ` Albert Huang
  0 siblings, 1 reply; 6+ messages in thread
From: Sir Graham (Terra) @ 2006-04-11 20:21 UTC (permalink / raw)
  To: bluez-devel

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

Hi Albert.

WORKS!

However... In the Local address.... the port variable I think is not important... can be to 0?    Or     must I make put special port?

Best Regards,
Sir Graham.
  ----- Original Message ----- 
  From: Albert Huang 
  To: bluez-devel@lists.sourceforge.net 
  Sent: Tuesday, April 11, 2006 9:29 PM
  Subject: Re: [Bluez-devel] Selection of Local module....


  Hi Sir Graham,


    This works when you make a server conexion.... but... When you create a client function works also the bind function?

  Feel free to try it out before you believe me.

  Regards,
  Albert

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

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

* Re: [Bluez-devel] Selection of Local module....
  2006-04-11 20:21       ` Sir Graham (Terra)
@ 2006-04-11 22:10         ` Albert Huang
  0 siblings, 0 replies; 6+ messages in thread
From: Albert Huang @ 2006-04-11 22:10 UTC (permalink / raw)
  To: bluez-devel

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

Hi Sir Graham,

Good to hear.  yes, it can be 0.

-albert

On 4/11/06, Sir Graham (Terra) <sir__graham@terra.es> wrote:
>
> Hi Albert.
>
> WORKS!
>
> However... In the Local address.... the port variable I think is not
> important... can be to 0?    Or     must I make put special port?
>
> Best Regards,
> Sir Graham.
>
> ----- Original Message -----
> *From:* Albert Huang <albert@csail.mit.edu>
> *To:* bluez-devel@lists.sourceforge.net
> *Sent:* Tuesday, April 11, 2006 9:29 PM
> *Subject:* Re: [Bluez-devel] Selection of Local module....
>
> Hi Sir Graham,
>
>   This works when you make a server conexion.... but... When you create aclient function works also the bind function?
> >
>
> Feel free to try it out before you believe me.
>
> Regards,
> Albert
>

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

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

end of thread, other threads:[~2006-04-11 22:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-10 15:03 [Bluez-devel] Selection of Local module Sir Graham (Terra)
2006-04-10 17:37 ` Albert Huang
2006-04-10 18:51   ` Sir Graham (Terra)
2006-04-11 19:29     ` Albert Huang
2006-04-11 20:21       ` Sir Graham (Terra)
2006-04-11 22:10         ` Albert Huang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.