Skip to contentSkip to conversation

rfcomm receive problem and success

Bluez-devel franz keuner 2 participants 3 messages Mar 24, 2004 – Mar 25, 2004 1 message not in the archive Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

hello,

with your help i had quite a success in sending data from my mobile phone to bluez.
but there's something i don't understand.
i registered a SP service: sdptool add --channel=10 SP

./rctest -d
rctest[2482]: Waiting for connection on channel 10 ... rctest[2483]: Connect from 00:00:00:00:00:00 rctest[2483]: Receiving ...
rctest[2483]: Recevied 51 bytes
rctest[2483]: Disconnect

and the programm doesn't exit, i have to use ctr-c to stop it. is this normal or is something going wrong although the receiving was successful?

and something else:
if i try to receive with the 'r' option there's an error:

./rctest -r
rctest[2458]: Waiting for connection on channel 10 ... rctest[2459]: Connect from 00:00:00:00:00:00 rctest[2459]: Receiving ...
rctest[2459]: Read failed. Connection reset by peer(104) rctest[2459]: Disconnect

has anybody an idea what's my fault?

i think somehow it's possible to use the read socket function but not the recv function...

regards,

franz

hcidump shows the following messages using the -r option:

device: hci0 snap_len: 1028 filter: 0xffffffff

Quoted 1 line

HCI Event: Connect Request(0x04) plen 10

AD 1C E8 D9 0A 00 00 00 00 01
< HCI Command: Accept Connection Request(0x01|0x0009) plen 7
AD 1C E8 D9 0A 00 01

Quoted 1 line

HCI Event: Command Status(0x0f) plen 4

00 01 09 04

Quoted 1 line

HCI Event: Connect Complete(0x03) plen 11

00 28 00 AD 1C E8 D9 0A 00 01 00
< HCI Command: Write Link Policy Settings(0x02|0x000d) plen 4
28 00 0E 00

Quoted 1 line

HCI Event: Page Scan Repetition Mode Change(0x20) plen 7

AD 1C E8 D9 0A 00 01

Quoted 1 line

HCI Event: Command Complete(0x0e) plen 6

01 0D 08 00 28 00
< HCI Command: Change Connection Packet Type(0x01|0x000f) plen 4
28 00 18 CC

Quoted 1 line

HCI Event: Command Status(0x0f) plen 4

00 01 0F 04

Quoted 1 line

HCI Event: Connection Packet Type Changed(0x1d) plen 5

00 28 00 18 CC

Quoted 1 line

ACL data: handle 0x0028 flags 0x02 dlen 12

    L2CAP(s): Connect req: psm 3 scid 0x0046
< ACL data: handle 0x0028 flags 0x02 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0046 result 0 status 0
Quoted 1 line

HCI Event: Number of Completed Packets(0x13) plen 5

01 28 00 01 00

Quoted 1 line

HCI Event: Max Slots Change(0x1b) plen 3

28 00 05

Quoted 1 line

ACL data: handle 0x0028 flags 0x02 dlen 12

    L2CAP(s): Config req: dcid 0x0040 flags 0x0000 clen 0
< ACL data: handle 0x0028 flags 0x02 dlen 14
    L2CAP(s): Config rsp: scid 0x0046 flags 0x0000 result 0 clen 0
< ACL data: handle 0x0028 flags 0x02 dlen 16
    L2CAP(s): Config req: dcid 0x0046 flags 0x0000 clen 4
    MTU 1024
Quoted 1 line

HCI Event: Number of Completed Packets(0x13) plen 5

01 28 00 01 00

Quoted 1 line

HCI Event: Number of Completed Packets(0x13) plen 5

01 28 00 01 00

Quoted 1 line

ACL data: handle 0x0028 flags 0x02 dlen 18

    L2CAP(s): Config rsp: scid 0x0040 flags 0x0000 result 0 clen 4
    MTU 672
Quoted 1 line

ACL data: handle 0x0028 flags 0x02 dlen 8

    L2CAP(d): cid 0x40 len 4 [psm 3]
      RFCOMM(s): SABM: cr 1 dlci 0 pf 1 ilen 0 fcs 0x1c
< ACL data: handle 0x0028 flags 0x02 dlen 8
    L2CAP(d): cid 0x46 len 4 [psm 3]
      RFCOMM(s): UA: cr 1 dlci 0 pf 1 ilen 0 fcs 0xd7
Quoted 1 line

HCI Event: Number of Completed Packets(0x13) plen 5

01 28 00 01 00

Quoted 1 line

ACL data: handle 0x0028 flags 0x02 dlen 18

    L2CAP(d): cid 0x40 len 14 [psm 3]
      RFCOMM(s): PN CMD: cr 1 dlci 0 pf 0 ilen 10 fcs 0x70 mcc_len 8
      dlci 20 frame_type 0 credit_flow 15 pri 0 ack_timer 0 frame_size 667
max_retrans 0 credits 3
< ACL data: handle 0x0028 flags 0x02 dlen 18
    L2CAP(d): cid 0x46 len 14 [psm 3]
      RFCOMM(s): PN RSP: cr 0 dlci 0 pf 0 ilen 10 fcs 0xaa mcc_len 8
      dlci 20 frame_type 0 credit_flow 14 pri 0 ack_timer 0 frame_size 667

max_retrans 0 credits 7

Quoted 1 line

HCI Event: Number of Completed Packets(0x13) plen 5

01 28 00 01 00

Quoted 1 line

ACL data: handle 0x0028 flags 0x02 dlen 8

    L2CAP(d): cid 0x40 len 4 [psm 3]
      RFCOMM(s): SABM: cr 1 dlci 20 pf 1 ilen 0 fcs 0xfd
< ACL data: handle 0x0028 flags 0x02 dlen 8
    L2CAP(d): cid 0x46 len 4 [psm 3]
      RFCOMM(s): UA: cr 1 dlci 20 pf 1 ilen 0 fcs 0x36
< ACL data: handle 0x0028 flags 0x02 dlen 12
    L2CAP(d): cid 0x46 len 8 [psm 3]
      RFCOMM(s): MSC CMD: cr 0 dlci 0 pf 0 ilen 4 fcs 0xaa mcc_len 2
      dlci 20 fc 0 rtc 1 rtr 1 ic 0 dv 1 b1 1 b2 1 b3 0 len 0
Quoted 1 line

HCI Event: Number of Completed Packets(0x13) plen 5

01 28 00 01 00

Quoted 1 line

HCI Event: Number of Completed Packets(0x13) plen 5

01 28 00 01 00

Quoted 1 line

ACL data: handle 0x0028 flags 0x02 dlen 12

    L2CAP(d): cid 0x40 len 8 [psm 3]
      RFCOMM(s): MSC CMD: cr 1 dlci 0 pf 0 ilen 4 fcs 0x70 mcc_len 2
      dlci 20 fc 0 rtc 1 rtr 1 ic 0 dv 1 b1 1 b2 1 b3 0 len 0
< ACL data: handle 0x0028 flags 0x02 dlen 12
    L2CAP(d): cid 0x46 len 8 [psm 3]
      RFCOMM(s): MSC RSP: cr 0 dlci 0 pf 0 ilen 4 fcs 0xaa mcc_len 2
      dlci 20 fc 0 rtc 1 rtr 1 ic 0 dv 1 b1 1 b2 1 b3 0 len 0
Quoted 1 line

ACL data: handle 0x0028 flags 0x02 dlen 12

    L2CAP(d): cid 0x40 len 8 [psm 3]
      RFCOMM(s): MSC RSP: cr 1 dlci 0 pf 0 ilen 4 fcs 0x70 mcc_len 2
      dlci 20 fc 0 rtc 1 rtr 1 ic 0 dv 1 b1 1 b2 1 b3 0 len 0
< ACL data: handle 0x0028 flags 0x02 dlen 9
    L2CAP(d): cid 0x46 len 5 [psm 3]
      RFCOMM(d): UIH: cr 0 dlci 20 pf 1 ilen 0 fcs 0xf7
      21
Quoted 1 line

HCI Event: Number of Completed Packets(0x13) plen 5

01 28 00 01 00

Quoted 1 line

HCI Event: Number of Completed Packets(0x13) plen 5

01 28 00 01 00

Quoted 1 line

ACL data: handle 0x0028 flags 0x02 dlen 60

    L2CAP(d): cid 0x40 len 56 [psm 3]
      RFCOMM(d): UIH: cr 1 dlci 20 pf 1 ilen 51 fcs 0x2d
      04 30 30 3A 30 41 3A 44 39 3A 45 38 3A 31 43 3A 41 44 20 45
      73 6B 50 39 30 30 20 54 75 65 20 4D 61 72 20 32 33 20 31 35
      3A 34 33 3A 35 32 20 32 30 30 34 0A
Quoted 1 line

ACL data: handle 0x0028 flags 0x02 dlen 8

    L2CAP(d): cid 0x40 len 4 [psm 3]
      RFCOMM(s): DISC: cr 1 dlci 20 pf 1 ilen 0 fcs 0x1c
< ACL data: handle 0x0028 flags 0x02 dlen 8
    L2CAP(d): cid 0x46 len 4 [psm 3]
      RFCOMM(s): UA: cr 1 dlci 20 pf 1 ilen 0 fcs 0x36
Quoted 1 line

HCI Event: Number of Completed Packets(0x13) plen 5

01 28 00 01 00

Quoted 1 line

ACL data: handle 0x0028 flags 0x02 dlen 12

    L2CAP(s): Disconn req: dcid 0x0040 scid 0x0046
< ACL data: handle 0x0028 flags 0x02 dlen 12
    L2CAP(s): Disconn rsp: dcid 0x0040 scid 0x0046
Quoted 1 line

HCI Event: Number of Completed Packets(0x13) plen 5

01 28 00 01 00

Quoted 1 line

HCI Event: Disconn Complete(0x05) plen 4

00 28 00 13

Signature · 14 lines
+++ NEU bei GMX und erstmalig in Deutschland: TÜV-geprüfter Virenschutz +++
100% Virenerkennung nach Wildlist. Infos: http://www.gmx.net/virenschutz



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
maintainer
#1 lore raw

Hi Franz,

Quoted 12 lines

with your help i had quite a success in sending data from my mobile phone to bluez.
but there's something i don't understand.
i registered a SP service: sdptool add --channel=10 SP

./rctest -d
rctest[2482]: Waiting for connection on channel 10 ... rctest[2483]: Connect from 00:00:00:00:00:00 rctest[2483]: Receiving ...
rctest[2483]: Recevied 51 bytes
rctest[2483]: Disconnect

Quoted 2 lines

and the programm doesn't exit, i have to use ctr-c to stop it. is this normal or is something going wrong although the receiving was successful?

this is normal, because you can connect another time.

Quoted 11 lines

and something else:
if i try to receive with the 'r' option there's an error:

./rctest -r
rctest[2458]: Waiting for connection on channel 10 ... rctest[2459]: Connect from 00:00:00:00:00:00 rctest[2459]: Receiving ...
rctest[2459]: Read failed. Connection reset by peer(104) rctest[2459]: Disconnect

has anybody an idea what's my fault?

You received data (one UIH frame) and then the phone disconnects you. Actually they are the same 51 bytes as above, but you only see an extra error message.

Regards

Marcel

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

maintainer
#3 lore raw

Hi Franz,

Quoted 2 lines

that's maybe a stupid question:
but why is there a error message if the bytes are received?

actually these is a test program and not for normal use. Maybe the code is simply wrong. I never checked it and I don't really care. If you fixed it, send me a patch.

Quoted 8 lines

when i use the dump function i can work in my program with the data sended by the phone and no error.

when i try to use the receive function there's this error.

is the fault on the phone side and what can i do about it? does the receive function needs any additional information compared to the dump(read) function?

Compare the code of the recv and the dump functions and check what happens. Look at it with hcidump to see if it is really an error.

Regards

Marcel

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel