From: mike <mikelee@avantwave.com>
To: bluez-users@lists.sourceforge.net
Subject: Re: [Bluez-users] Re: [Bluez-devel] About rfcomm socket
Date: Wed, 01 Dec 2004 16:53:17 +0800 [thread overview]
Message-ID: <41AD867D.2060609@avantwave.com> (raw)
In-Reply-To: <1101882506.18840.18.camel@pegasus>
Dear Marcel
Thanks for helping.
Here is code fragment. I use usual fork practise to run these two
func do_connect and do_listen. I hard code the bluetooth device to be
connected just because code is under testing.
And these two func are using different channel, it can be connected
when do_connect retry more than 3 times.
So i do not why it can not be connected when it is trying to connect
another device.
int *do_connect*(TPVSerial_State_t *stateData)
{
struct sockaddr_rc sa;
int sk,retry;
// Create RFCOMM socket
sk = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
sa.rc_family = AF_BLUETOOTH;
sa.rc_channel = 3;
str2ba("00:e0:07:cb:15:68",&sa.rc_bdaddr);
retry = 3;
while(retry--)
{
int ret, alen = sizeof(sa);
DEBPRINT("Conecting...\n");
ret = connect(sk, (struct sockaddr *) &sa, alen);
DEBPRINT("Connected\n");
ba2str(&sa.rc_bdaddr, ba);
syslog(LOG_INFO, "New connection from %s", ba);
// to handle the SPP connection
sp_open_connection(sk, stateData);
close(sk);
}
return 0;
}
int *do_listen*(TPVSerial_State_t *stateData)
{
struct sockaddr_rc sa;
int sk;
fd_set netfd;
// Create RFCOMM socket
sk = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
sa.rc_family = AF_BLUETOOTH;
sa.rc_channel = 2
sa.rc_bdaddr = src_addr;
if (bind(sk, (struct sockaddr *) &sa, sizeof(sa)))
{
syslog(LOG_ERR, "Bind failed. %s(%d)", strerror(errno), errno);
return -1;
}
listen(sk, 10);
FD_ZERO(&netfd);
terminate = 0;
while(!terminate)
{
int alen = sizeof(sa), nsk;
FD_SET(sk,&netfd);
syslog(LOG_INFO, "Waiting for connection...");
DEBPRINT("wait Accept\n");
select(sk+1,&netfd,NULL,NULL,NULL)
if(FD_ISSET(sk,&netfd)){
nsk = accept(sk, (struct sockaddr *) &sa, &alen);
DEBPRINT("Accepted\n");
ba2str(&sa.rc_bdaddr, ba);
syslog(LOG_INFO, "New connection from %s", ba);
// to handle the SPP connection
sp_open_connection(nsk, stateData);
close(nsk);
}
}
return 0;
}
Marcel Holtmann wrote:
>Hi Mike,
>
>
>
>> I have tried to fork two process, One use socket system call -
>>accept at rfcomm channel 2, and another try to connect to a bluetooth
>>device thought channel 3. But i found that i can not use a 3rd device to
>>connect to the listen channel 2 at the same time.
>>
>>
>
>show us the source code for that.
>
>
>
>> I am using bluez-lib-2.6, utils-2.6. ,hci-uart and linux-2.4.18
>>patched with patch-2.4.18-mh15.
>>
>>
>
>The bluez-libs and bluez-utils are at version 2.11 and you should update
>both of them.
>
>
>
>> My question is simple, Could bluez be multi-tasking?
>>
>>
>
>You may not be able to do some crazy things, but in general yes.
>
>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://productguide.itmanagersjournal.com/
>_______________________________________________
>Bluez-users mailing list
>Bluez-users@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/bluez-users
>
>
>
-------------------------------------------------------
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://productguide.itmanagersjournal.com/
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users
next prev parent reply other threads:[~2004-12-01 8:53 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-01 2:25 [Bluez-devel] About rfcomm socket mike
2004-12-01 6:28 ` Marcel Holtmann
2004-12-01 8:53 ` mike [this message]
2004-12-01 9:48 ` Marcel Holtmann
2004-12-02 4:26 ` mike
2004-12-02 7:44 ` Marcel Holtmann
2004-12-03 3:16 ` mike
2004-12-03 3:15 ` Marcel Holtmann
2004-12-06 7:37 ` mike
2004-12-06 7:38 ` Marcel Holtmann
2004-12-06 11:29 ` mike
2004-12-06 11:27 ` Marcel Holtmann
2004-12-06 13:17 ` Mike Lee
2004-12-06 13:27 ` Marcel Holtmann
2004-12-06 14:04 ` Mike Lee
2004-12-06 14:20 ` Marcel Holtmann
2004-12-06 14:47 ` Mike Lee
2004-12-06 15:41 ` Marcel Holtmann
2004-12-07 9:13 ` mike
2004-12-07 9:10 ` [Bluez-devel] " Sebastian Roth
2004-12-07 9:18 ` [Bluez-devel] " Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=41AD867D.2060609@avantwave.com \
--to=mikelee@avantwave.com \
--cc=bluez-users@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.