2005-08-24 19:21:02

by Rui Silva

[permalink] [raw]
Subject: [Bluez-devel] help needed with rfcomm

hello ppl,=20

i tried to post these doubts under the bluez-users mailing list, but i
did'nt have any response, and since it has a programing doubt, i'll
try to explain my problem.

i want to buil an aplication that listen on rfcomm bluetooth sockets
and the same aplication receives information thru that socket. i kinda
have a squeleton of the program as folows:


// cria o socket
if( (sock =3D socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM))
< 0){
perror("socket");
return(-1);
}

// op=E7=F5es do socket
addr.rc_family =3D AF_BLUETOOTH;
str2ba(argv[1],&addr.rc_bdaddr);
addr.rc_channel =3D htobs(CHANNEL);
alen =3D sizeof(addr);

//regista o socket no SO
if(bind(sock, (struct sockaddr *)&addr, alen) < 0){
perror("bind");
return(-1);
}
//poe o socket =E0 escuta
listen(sock,QUEUE);

printf("Waiting for connections...\n\n");

while (1){
while((client =3D accept(sock, (struct sockaddr *)&addr,
&alen)) !=3D -1){
printf("Got a connection attempt!\n");

memset(buffer, 0, TAM_BUFFER);

if ( (r =3D read(client, buffer, TAM_BUFFER)) < 0
){
perror("Read no server");
}

but i can't get the connections to this computer to work. a i don't know wh=
y.

another problem that i had was that the SPP profile has not
advertized, and i solved that problem by performing a "sdptool add
SP".

anyway, with or without my program, i can't get the computer to accept
the connection attemps from other computers. these connections are
made using rfcomm on channel 1, and i can't change that.
my kernel was all the bluez stuff compiled in, not as modules.=20

any sugestions will be apreciated

so any ideia on how to solve this problem. I lacking time to
accomplish this program so i would really aprecciate all the hep that
you can give me..

thank you all very much

--=20
Rui Silva
Powered by Gentoo Linux under :
CELERON 1000 - Stage1 install with nptl
Pentium M 1800GHz - Stage1 install with NPTL

http://rukinhas.no-ip.org


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel


2005-08-27 12:55:09

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-devel] help needed with rfcomm

Hi Rui,

> now it works with SOCK_STREAM, and i havent changed anythig to the
> program. i realy don't understand how this could be. I'm using kernel
> 2.6.12-CK and the bluez libs version 2.19?

this is how it should be. I fixed the kernel code to prevent creating
connections with the SOCK_RAW interface.

Regards

Marcel




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2005-08-26 21:02:31

by Albert Huang

[permalink] [raw]
Subject: Re: [Bluez-devel] help needed with rfcomm

use select() or poll()

See here for an introduction:=20
http://www.ecst.csuchico.edu/~beej/guide/net/html/

-albert

On 8/26/05, Rui Silva <[email protected]> wrote:
> is there as way to set a timetout to a socket??
> what i mean is, if the socket does not read anything for certain time, th=
e read
> operation would unlock and the execution of the program continues. is
> there a way to
> accomplish this??
>=20
> --
> Rui Silva
> Powered by Gentoo Linux under :
> CELERON 1000 - Stage1 install with nptl
> Pentium M 1800GHz - Stage1 install with NPTL
>=20
> http://rukinhas.no-ip.org
>=20
>=20
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practic=
es
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & Q=
A
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> Bluez-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/bluez-devel
>


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2005-08-26 20:56:46

by Rui Silva

[permalink] [raw]
Subject: Re: [Bluez-devel] help needed with rfcomm

is there as way to set a timetout to a socket??=20
what i mean is, if the socket does not read anything for certain time, the =
read=20
operation would unlock and the execution of the program continues. is
there a way to
accomplish this??

--=20
Rui Silva
Powered by Gentoo Linux under :
CELERON 1000 - Stage1 install with nptl
Pentium M 1800GHz - Stage1 install with NPTL

http://rukinhas.no-ip.org


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2005-08-26 13:35:39

by Rui Silva

[permalink] [raw]
Subject: Re: [Bluez-devel] help needed with rfcomm

this is the output with SOCK_RAW of hcidump

> HCI Event: Connect Request (0x04) plen 10
bdaddr 00:80:5A:20:1B:E9 class 0x3e0100 type ACL
< HCI Command: Accept Connection Request (0x01|0x0009) plen 7
bdaddr 00:80:5A:20:1B:E9 role 0x01
Role: Slave
> HCI Event: Command Status (0x0f) plen 4
Accept Connection Request (0x01|0x0009) status 0x00 ncmd 1
> HCI Event: Connect Complete (0x03) plen 11
status 0x00 handle 41 bdaddr 00:80:5A:20:1B:E9 type ACL encrypt 0x00
< HCI Command: Write Link Policy Settings (0x02|0x000d) plen 4
handle 41 policy 0x0f
Link policy: RSWITCH HOLD SNIFF PARK
> HCI Event: Page Scan Repetition Mode Change (0x20) plen 7
bdaddr 00:80:5A:20:1B:E9 mode 1
> HCI Event: Command Complete (0x0e) plen 6
Write Link Policy Settings (0x02|0x000d) ncmd 1
status 0x00 handle 41
< HCI Command: Change Connection Packet Type (0x01|0x000f) plen 4
handle 41 ptype 0xcc18
Packet type: DM1 DM3 DM5 DH1 DH3 DH5
> HCI Event: Max Slots Change (0x1b) plen 3
handle 41 slots 5
> HCI Event: Command Status (0x0f) plen 4
Change Connection Packet Type (0x01|0x000f) status 0x00 ncmd 1
> HCI Event: Connection Packet Type Changed (0x1d) plen 5
status 0x00 handle 41 ptype 0xcc18
Packet type: DM1 DM3 DM5 DH1 DH3 DH5
> ACL data: handle 41 flags 0x02 dlen 12
L2CAP(s): Connect req: psm 3 scid 0x0040
< ACL data: handle 41 flags 0x02 dlen 16
L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0040 result 0 status 0
Connection successful
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 41
> ACL data: handle 41 flags 0x02 dlen 16
L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 4
MTU 1024
< ACL data: handle 41 flags 0x02 dlen 14
L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 0
Success
< ACL data: handle 41 flags 0x02 dlen 16
L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 4
MTU 1024
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 41
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 41
> ACL data: handle 41 flags 0x02 dlen 14
L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 0
Success
> ACL data: handle 41 flags 0x02 dlen 8
L2CAP(d): cid 0x0040 len 4 [psm 3]
RFCOMM(s): SABM: cr 1 dlci 0 pf 1 ilen 0 fcs 0x1c
< ACL data: handle 41 flags 0x02 dlen 8
L2CAP(d): cid 0x0040 len 4 [psm 3]
RFCOMM(s): UA: cr 1 dlci 0 pf 1 ilen 0 fcs 0xd7
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 41
> ACL data: handle 41 flags 0x02 dlen 18
L2CAP(d): cid 0x0040 len 14 [psm 3]
RFCOMM(s): PN CMD: cr 1 dlci 0 pf 0 ilen 10 fcs 0x70 mcc_len 8
dlci 2 frame_type 0 credit_flow 15 pri 7 ack_timer 0
frame_size 1019 max_retrans 0 credits 7
< ACL data: handle 41 flags 0x02 dlen 18
L2CAP(d): cid 0x0040 len 14 [psm 3]
RFCOMM(s): PN RSP: cr 0 dlci 0 pf 0 ilen 10 fcs 0xaa mcc_len 8
dlci 2 frame_type 0 credit_flow 14 pri 7 ack_timer 0
frame_size 1019 max_retrans 0 credits 7
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 41
> ACL data: handle 41 flags 0x02 dlen 8
L2CAP(d): cid 0x0040 len 4 [psm 3]
RFCOMM(s): SABM: cr 1 dlci 2 pf 1 ilen 0 fcs 0x59
< ACL data: handle 41 flags 0x02 dlen 8
L2CAP(d): cid 0x0040 len 4 [psm 3]
RFCOMM(s): UA: cr 1 dlci 2 pf 1 ilen 0 fcs 0x92
< ACL data: handle 41 flags 0x02 dlen 12
L2CAP(d): cid 0x0040 len 8 [psm 3]
RFCOMM(s): MSC CMD: cr 0 dlci 0 pf 0 ilen 4 fcs 0xaa mcc_len 2
dlci 2 fc 0 rtc 1 rtr 1 ic 0 dv 1 b1 1 b2 1 b3 0 len 0
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 41
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 41
> ACL data: handle 41 flags 0x02 dlen 12
L2CAP(d): cid 0x0040 len 8 [psm 3]
RFCOMM(s): MSC CMD: cr 1 dlci 0 pf 0 ilen 4 fcs 0x70 mcc_len 2
dlci 2 fc 0 rtc 1 rtr 1 ic 0 dv 1 b1 1 b2 1 b3 0 len 0
< ACL data: handle 41 flags 0x02 dlen 12
L2CAP(d): cid 0x0040 len 8 [psm 3]
RFCOMM(s): MSC RSP: cr 0 dlci 0 pf 0 ilen 4 fcs 0xaa mcc_len 2
dlci 2 fc 0 rtc 1 rtr 1 ic 0 dv 1 b1 1 b2 1 b3 0 len 0
> ACL data: handle 41 flags 0x02 dlen 12
L2CAP(d): cid 0x0040 len 8 [psm 3]
RFCOMM(s): MSC RSP: cr 1 dlci 0 pf 0 ilen 4 fcs 0x70 mcc_len 2
dlci 2 fc 0 rtc 1 rtr 1 ic 0 dv 1 b1 1 b2 1 b3 0 len 0
< ACL data: handle 41 flags 0x02 dlen 9
L2CAP(d): cid 0x0040 len 5 [psm 3]
RFCOMM(d): UIH: cr 0 dlci 2 pf 1 ilen 0 fcs 0x5c credits 33
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 41
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 41
> ACL data: handle 41 flags 0x02 dlen 9
L2CAP(d): cid 0x0040 len 5 [psm 3]
RFCOMM(d): UIH: cr 1 dlci 2 pf 1 ilen 0 fcs 0x86 credits 33


this is the output wiht SOCK_STREAM

> HCI Event: Connect Request (0x04) plen 10
bdaddr 00:80:5A:20:1B:E9 class 0x3e0100 type ACL
< HCI Command: Accept Connection Request (0x01|0x0009) plen 7
bdaddr 00:80:5A:20:1B:E9 role 0x01
Role: Slave
> HCI Event: Command Status (0x0f) plen 4
Accept Connection Request (0x01|0x0009) status 0x00 ncmd 1
> HCI Event: Connect Complete (0x03) plen 11
status 0x00 handle 41 bdaddr 00:80:5A:20:1B:E9 type ACL encrypt 0x00
< HCI Command: Write Link Policy Settings (0x02|0x000d) plen 4
handle 41 policy 0x0f
Link policy: RSWITCH HOLD SNIFF PARK
> HCI Event: Page Scan Repetition Mode Change (0x20) plen 7
bdaddr 00:80:5A:20:1B:E9 mode 1
> HCI Event: Command Complete (0x0e) plen 6
Write Link Policy Settings (0x02|0x000d) ncmd 1
status 0x00 handle 41
< HCI Command: Change Connection Packet Type (0x01|0x000f) plen 4
handle 41 ptype 0xcc18
Packet type: DM1 DM3 DM5 DH1 DH3 DH5
> HCI Event: Max Slots Change (0x1b) plen 3
handle 41 slots 5
> HCI Event: Command Status (0x0f) plen 4
Change Connection Packet Type (0x01|0x000f) status 0x00 ncmd 1
> HCI Event: Connection Packet Type Changed (0x1d) plen 5
status 0x00 handle 41 ptype 0xcc18
Packet type: DM1 DM3 DM5 DH1 DH3 DH5
> ACL data: handle 41 flags 0x02 dlen 12
L2CAP(s): Connect req: psm 3 scid 0x0040
< ACL data: handle 41 flags 0x02 dlen 16
L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0040 result 0 status 0
Connection successful
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 41
> ACL data: handle 41 flags 0x02 dlen 16
L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 4
MTU 1024
< ACL data: handle 41 flags 0x02 dlen 14
L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 0
Success
< ACL data: handle 41 flags 0x02 dlen 16
L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 4
MTU 1024
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 41
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 41
> ACL data: handle 41 flags 0x02 dlen 14
L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 0
Success
> ACL data: handle 41 flags 0x02 dlen 8
L2CAP(d): cid 0x0040 len 4 [psm 3]
RFCOMM(s): SABM: cr 1 dlci 0 pf 1 ilen 0 fcs 0x1c
< ACL data: handle 41 flags 0x02 dlen 8
L2CAP(d): cid 0x0040 len 4 [psm 3]
RFCOMM(s): UA: cr 1 dlci 0 pf 1 ilen 0 fcs 0xd7
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 41
> ACL data: handle 41 flags 0x02 dlen 18
L2CAP(d): cid 0x0040 len 14 [psm 3]
RFCOMM(s): PN CMD: cr 1 dlci 0 pf 0 ilen 10 fcs 0x70 mcc_len 8
dlci 2 frame_type 0 credit_flow 15 pri 7 ack_timer 0
frame_size 1019 max_retrans 0 credits 7
< ACL data: handle 41 flags 0x02 dlen 18
L2CAP(d): cid 0x0040 len 14 [psm 3]
RFCOMM(s): PN RSP: cr 0 dlci 0 pf 0 ilen 10 fcs 0xaa mcc_len 8
dlci 2 frame_type 0 credit_flow 14 pri 7 ack_timer 0
frame_size 1019 max_retrans 0 credits 7
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 41
> ACL data: handle 41 flags 0x02 dlen 8
L2CAP(d): cid 0x0040 len 4 [psm 3]
RFCOMM(s): SABM: cr 1 dlci 2 pf 1 ilen 0 fcs 0x59
< ACL data: handle 41 flags 0x02 dlen 8
L2CAP(d): cid 0x0040 len 4 [psm 3]
RFCOMM(s): UA: cr 1 dlci 2 pf 1 ilen 0 fcs 0x92
< ACL data: handle 41 flags 0x02 dlen 12
L2CAP(d): cid 0x0040 len 8 [psm 3]
RFCOMM(s): MSC CMD: cr 0 dlci 0 pf 0 ilen 4 fcs 0xaa mcc_len 2
dlci 2 fc 0 rtc 1 rtr 1 ic 0 dv 1 b1 1 b2 1 b3 0 len 0
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 41
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 41
> ACL data: handle 41 flags 0x02 dlen 12
L2CAP(d): cid 0x0040 len 8 [psm 3]
RFCOMM(s): MSC CMD: cr 1 dlci 0 pf 0 ilen 4 fcs 0x70 mcc_len 2
dlci 2 fc 0 rtc 1 rtr 1 ic 0 dv 1 b1 1 b2 1 b3 0 len 0
< ACL data: handle 41 flags 0x02 dlen 12
L2CAP(d): cid 0x0040 len 8 [psm 3]
RFCOMM(s): MSC RSP: cr 0 dlci 0 pf 0 ilen 4 fcs 0xaa mcc_len 2
dlci 2 fc 0 rtc 1 rtr 1 ic 0 dv 1 b1 1 b2 1 b3 0 len 0
> ACL data: handle 41 flags 0x02 dlen 12
L2CAP(d): cid 0x0040 len 8 [psm 3]
RFCOMM(s): MSC RSP: cr 1 dlci 0 pf 0 ilen 4 fcs 0x70 mcc_len 2
dlci 2 fc 0 rtc 1 rtr 1 ic 0 dv 1 b1 1 b2 1 b3 0 len 0
< ACL data: handle 41 flags 0x02 dlen 9
L2CAP(d): cid 0x0040 len 5 [psm 3]
RFCOMM(d): UIH: cr 0 dlci 2 pf 1 ilen 0 fcs 0x5c credits 33
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 41
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 41
> ACL data: handle 41 flags 0x02 dlen 9
L2CAP(d): cid 0x0040 len 5 [psm 3]
RFCOMM(d): UIH: cr 1 dlci 2 pf 1 ilen 0 fcs 0x86 credits 33


now it works with SOCK_STREAM, and i havent changed anythig to the
program. i realy don't understand how this could be. I'm using kernel
2.6.12-CK and the bluez libs version 2.19?



On 8/25/05, Marcel Holtmann <[email protected]> wrote:
> Hi Rui,
>=20
> > i tried your changes but it didn't help. i thank anyway for your help
> > i solved my problem at least for now. I've changed SOCK_STREAM to
> > SOCK_RAW and the connections were accepted.
>=20
> this is wrong and if this works it is a bug inside the kernel. Why don't
> you run "hcidump -X -V" as I told you?
>=20
> Regards
>=20
> Marcel
>=20
>=20
>=20
>=20
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practic=
es
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & Q=
A
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> Bluez-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/bluez-devel
>=20


--=20
Rui Silva
Powered by Gentoo Linux under :
CELERON 1000 - Stage1 install with nptl
Pentium M 1800GHz - Stage1 install with NPTL

http://rukinhas.no-ip.org


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2005-08-25 14:29:28

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-devel] help needed with rfcomm

Hi Rui,

> i tried your changes but it didn't help. i thank anyway for your help
> i solved my problem at least for now. I've changed SOCK_STREAM to
> SOCK_RAW and the connections were accepted.

this is wrong and if this works it is a bug inside the kernel. Why don't
you run "hcidump -X -V" as I told you?

Regards

Marcel




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2005-08-25 13:43:37

by Rui Silva

[permalink] [raw]
Subject: Re: [Bluez-devel] help needed with rfcomm

On 8/24/05, Marcel Holtmann <[email protected]> wrote:
> Hi Rui,
>=20
> > i tried to post these doubts under the bluez-users mailing list, but i
> > did'nt have any response, and since it has a programing doubt, i'll
> > try to explain my problem.
> >
> > i want to buil an aplication that listen on rfcomm bluetooth sockets
> > and the same aplication receives information thru that socket. i kinda
> > have a squeleton of the program as folows:
> >
> >
> > // cria o socket
> > if( (sock =3D socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)=
)
> > < 0){
> > perror("socket");
> > return(-1);
> > }
> >
> > // op=E7=F5es do socket
> > addr.rc_family =3D AF_BLUETOOTH;
> > str2ba(argv[1],&addr.rc_bdaddr);
> > addr.rc_channel =3D htobs(CHANNEL);
>=20
> the htobs() is wrong here. The channel is uint8 value and thus a endian
> change is not needed.
>=20
> > alen =3D sizeof(addr);
> >
> > //regista o socket no SO
> > if(bind(sock, (struct sockaddr *)&addr, alen) < 0){
> > perror("bind");
> > return(-1);
> > }
> > //poe o socket =E0 escuta
> > listen(sock,QUEUE);
> >
> > printf("Waiting for connections...\n\n");
> >
> > while (1){
> > while((client =3D accept(sock, (struct sockaddr *)&addr=
,
> > &alen)) !=3D -1){
> > printf("Got a connection attempt!\n");
> >
> > memset(buffer, 0, TAM_BUFFER);
> >
> > if ( (r =3D read(client, buffer, TAM_BUFFER)) <=
0
> > ){
> > perror("Read no server");
> > }
> >
> > but i can't get the connections to this computer to work. a i don't kno=
w why.
> >
> > another problem that i had was that the SPP profile has not
> > advertized, and i solved that problem by performing a "sdptool add
> > SP".
> >
> > anyway, with or without my program, i can't get the computer to accept
> > the connection attemps from other computers. these connections are
> > made using rfcomm on channel 1, and i can't change that.
> > my kernel was all the bluez stuff compiled in, not as modules.
> >
> > any sugestions will be apreciated
> >
> > so any ideia on how to solve this problem. I lacking time to
> > accomplish this program so i would really aprecciate all the hep that
> > you can give me..
>=20
> Run "hcidump -X -V" to see what happens. Run "sdptool browse local" to
> see what channel is advertised for your serial port service.
>=20
> Regards
>=20
> Marcel

i tried your changes but it didn't help. i thank anyway for your help
i solved my problem at least for now. I've changed SOCK_STREAM to
SOCK_RAW and the connections were accepted.

--=20
Rui Silva
Powered by Gentoo Linux under :
CELERON 1000 - Stage1 install with nptl
Pentium M 1800GHz - Stage1 install with NPTL

http://rukinhas.no-ip.org


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2005-08-24 20:56:18

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-devel] Re: help needed with rfcomm

Hi Rui,

> I also notice now, that I don't have any /dev/rfcomm* or
> /dev/bluetooth/rfcomm* devices under /dev. I'm using udev as a device
> manager. anyone?? please

the rfcommX devices are optional. They must be created with a special
ioctl() after you established the connection. However most applications
don't need a TTY. They work perfect through a socket.

Regards

Marcel




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2005-08-24 20:55:16

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-devel] help needed with rfcomm

Hi Rui,

> i tried to post these doubts under the bluez-users mailing list, but i
> did'nt have any response, and since it has a programing doubt, i'll
> try to explain my problem.
>=20
> i want to buil an aplication that listen on rfcomm bluetooth sockets
> and the same aplication receives information thru that socket. i kinda
> have a squeleton of the program as folows:
>=20
>=20
> // cria o socket
> if( (sock =3D socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)=
)
> < 0){
> perror("socket");
> return(-1);
> }
>=20
> // op=E7=F5es do socket
> addr.rc_family =3D AF_BLUETOOTH;
> str2ba(argv[1],&addr.rc_bdaddr);
> addr.rc_channel =3D htobs(CHANNEL);

the htobs() is wrong here. The channel is uint8 value and thus a endian
change is not needed.

> alen =3D sizeof(addr);
>=20
> //regista o socket no SO
> if(bind(sock, (struct sockaddr *)&addr, alen) < 0){
> perror("bind");
> return(-1);
> }
> //poe o socket =E0 escuta
> listen(sock,QUEUE);
>=20
> printf("Waiting for connections...\n\n");
>=20
> while (1){
> while((client =3D accept(sock, (struct sockaddr *)&addr=
,
> &alen)) !=3D -1){
> printf("Got a connection attempt!\n");
>=20
> memset(buffer, 0, TAM_BUFFER);
>=20
> if ( (r =3D read(client, buffer, TAM_BUFFER)) <=
0
> ){
> perror("Read no server");
> }
>=20
> but i can't get the connections to this computer to work. a i don't kno=
w why.
>=20
> another problem that i had was that the SPP profile has not
> advertized, and i solved that problem by performing a "sdptool add
> SP".
>=20
> anyway, with or without my program, i can't get the computer to accept
> the connection attemps from other computers. these connections are
> made using rfcomm on channel 1, and i can't change that.
> my kernel was all the bluez stuff compiled in, not as modules.=20
>=20
> any sugestions will be apreciated
>=20
> so any ideia on how to solve this problem. I lacking time to
> accomplish this program so i would really aprecciate all the hep that
> you can give me..

Run "hcidump -X -V" to see what happens. Run "sdptool browse local" to
see what channel is advertised for your serial port service.

Regards

Marcel




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2005-08-24 20:43:50

by Rui Silva

[permalink] [raw]
Subject: [Bluez-devel] Re: help needed with rfcomm

I also notice now, that I don't have any /dev/rfcomm* or
/dev/bluetooth/rfcomm* devices under /dev. I'm using udev as a device
manager. anyone?? please

On 8/24/05, Rui Silva <[email protected]> wrote:
> hello ppl,
>=20
> i tried to post these doubts under the bluez-users mailing list, but i
> did'nt have any response, and since it has a programing doubt, i'll
> try to explain my problem.
>=20
> i want to buil an aplication that listen on rfcomm bluetooth sockets
> and the same aplication receives information thru that socket. i kinda
> have a squeleton of the program as folows:
>=20
>=20
> // cria o socket
> if( (sock =3D socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM))
> < 0){
> perror("socket");
> return(-1);
> }
>=20
> // op=E7=F5es do socket
> addr.rc_family =3D AF_BLUETOOTH;
> str2ba(argv[1],&addr.rc_bdaddr);
> addr.rc_channel =3D htobs(CHANNEL);
> alen =3D sizeof(addr);
>=20
> //regista o socket no SO
> if(bind(sock, (struct sockaddr *)&addr, alen) < 0){
> perror("bind");
> return(-1);
> }
> //poe o socket =E0 escuta
> listen(sock,QUEUE);
>=20
> printf("Waiting for connections...\n\n");
>=20
> while (1){
> while((client =3D accept(sock, (struct sockaddr *)&addr,
> &alen)) !=3D -1){
> printf("Got a connection attempt!\n");
>=20
> memset(buffer, 0, TAM_BUFFER);
>=20
> if ( (r =3D read(client, buffer, TAM_BUFFER)) < 0
> ){
> perror("Read no server");
> }
>=20
> but i can't get the connections to this computer to work. a i don't know =
why.
>=20
> another problem that i had was that the SPP profile has not
> advertized, and i solved that problem by performing a "sdptool add
> SP".
>=20
> anyway, with or without my program, i can't get the computer to accept
> the connection attemps from other computers. these connections are
> made using rfcomm on channel 1, and i can't change that.
> my kernel was all the bluez stuff compiled in, not as modules.
>=20
> any sugestions will be apreciated
>=20
> so any ideia on how to solve this problem. I lacking time to
> accomplish this program so i would really aprecciate all the hep that
> you can give me..
>=20
> thank you all very much
>=20
> --
> Rui Silva
> Powered by Gentoo Linux under :
> CELERON 1000 - Stage1 install with nptl
> Pentium M 1800GHz - Stage1 install with NPTL
>=20
> http://rukinhas.no-ip.org
>=20


--=20
Rui Silva
Powered by Gentoo Linux under :
CELERON 1000 - Stage1 install with nptl
Pentium M 1800GHz - Stage1 install with NPTL

http://rukinhas.no-ip.org


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel