Skip to contentSkip to conversation

gobex: Add proper message to transfer errors

PATCH In review Luiz Augusto von Dentz 2 participants 5 messages Aug 8, 2013 – Aug 17, 2013 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/3 gobex: Add proper message to transfer errors

From: Luiz Augusto von Dentz <[email protected]>

This improve the error message when a transfer fails by using g_obex_strerror to decode the response code to a human readable string.

---
 gobex/gobex-transfer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
gobex/gobex-transfer.c +2 -2
index ac8836c..4203fec 100644
@@ -207,8 +207,8 @@ static void transfer_response(GObex *obex, GError *err, GObexPacket *rsp,
 
 	rspcode = g_obex_packet_get_operation(rsp, &final);
 	if (rspcode != G_OBEX_RSP_SUCCESS && rspcode != G_OBEX_RSP_CONTINUE) {
-		err = g_error_new(G_OBEX_ERROR, rspcode,
-					"Transfer failed (0x%02x)", rspcode);
+		err = g_error_new(G_OBEX_ERROR, rspcode, "%s",
+						g_obex_strerror(rspcode));
 		goto failed;
 	}
 
Signature · 1 line
1.8.3.1
author maintainer
#1 lore raw

PATCH 2/3 gobex: Make PUT request with just filler byte to set the final bit

From: Luiz Augusto von Dentz <[email protected]>

This make PUT request with just filler byte 0x30 to be treated as there is no data and thus avoid an extra packet to be sent.

Some profiles such as MAP use this to workaround PUT being interpreted as a delete request:

"5.7.5 Body/EndOfBody
To avoid PUT with empty Body leading to a 'delete' of the related message these headers shall contain a filler byte. The value of this byte shall be set to 0x30 (="0")."

Future PIM related specs in development also seems to be following the use of filler byte.

---
 gobex/gobex-packet.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
gobex/gobex-packet.c +10 -4
index 4c14cf7..96f8c76 100644
@@ -387,9 +387,15 @@ static gssize get_body(GObexPacket *pkt, guint8 *buf, gsize len)
 	if (ret < 0)
 		return ret;
 
-	if (ret > 0)
-		buf[0] = G_OBEX_HDR_BODY;
-	else
+	if (ret > 0) {
+		/* To avoid PUT with empty Body leading to a 'delete' some
+		 * transfer may use a filler byte of 0x30 (="0").
+		 */
+		if (ret == 2 && strcmp((char *) buf + 3, "0") == 0)
+			buf[0] = G_OBEX_HDR_BODY_END;
+		else
+			buf[0] = G_OBEX_HDR_BODY;
+	} else
 		buf[0] = G_OBEX_HDR_BODY_END;
 
 	u16 = g_htons(ret + 3);
@@ -440,7 +446,7 @@ gssize g_obex_packet_encode(GObexPacket *pkt, guint8 *buf, gsize len)
 		ret = get_body(pkt, buf + count, len - count);
 		if (ret < 0)
 			return ret;
-		if (ret == 0) {
+		if (ret == 0 || buf[count] == G_OBEX_HDR_BODY_END) {
 			if (pkt->opcode == G_OBEX_RSP_CONTINUE)
 				buf[0] = G_OBEX_RSP_SUCCESS;
 			buf[0] |= FINAL_BIT;
Signature · 1 line
1.8.3.1
author maintainer
#2 lore raw

PATCH 3/3 client/transfer: Add proper message to errors

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This improve the error message when a transfer fails by using g_obex_strerror to decode the response code to a human readable string.

---
 obexd/client/transfer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
obexd/client/transfer.c +2 -2
index 4b1def3..2e8f7c7 100644
@@ -596,8 +596,8 @@ static void get_xfer_progress_first(GObex *obex, GError *err, GObexPacket *rsp,
 
 	rspcode = g_obex_packet_get_operation(rsp, &final);
 	if (rspcode != G_OBEX_RSP_SUCCESS && rspcode != G_OBEX_RSP_CONTINUE) {
-		err = g_error_new(OBC_TRANSFER_ERROR, rspcode,
-					"Transfer failed (0x%02x)", rspcode);
+		err = g_error_new(OBC_TRANSFER_ERROR, rspcode, "%s",
+						g_obex_strerror(rspcode));
 		xfer_complete(obex, err, transfer);
 		g_error_free(err);
 		return;
Signature · 1 line
1.8.3.1
author maintainer
#3 lore raw
In reply to Luiz Augusto von Dentz

Hi,

Quoted 24 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This improve the error message when a transfer fails by using g_obex_strerror to decode the response code to a human readable string.

---
 gobex/gobex-transfer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
gobex/gobex-transfer.c +2 -3
index ac8836c..4203fec 100644
@@ -207,8 +207,8 @@ static void transfer_response(GObex *obex, GError *err, GObexPacket *rsp,
 
        rspcode = g_obex_packet_get_operation(rsp, &final);
        if (rspcode != G_OBEX_RSP_SUCCESS && rspcode != G_OBEX_RSP_CONTINUE) {
-               err = g_error_new(G_OBEX_ERROR, rspcode,
-                                       "Transfer failed (0x%02x)", rspcode);
+               err = g_error_new(G_OBEX_ERROR, rspcode, "%s",
+                                               g_obex_strerror(rspcode));
                goto failed;
        }
 
--
Quoted 1 line

1.8.3.1

I went ahead and applied patches 1 and 3, for patch 2 I will wait for feedback as the filler byte is something Bluetooth specific it can be controversial.

Signature · 1 line
Luiz Augusto von Dentz
#4 lore raw

Rfcomm connection error while connecting from android app

In reply to Luiz Augusto von Dentz

Hello all,

This is my first post to this mailing list. I am new to Bluetooth, I am trying to develop an embedded application with bluetooth using bluez 4.96 stack which would be controled by an adroid application.

My embedded platfrom is IMX28 running linux with Bluex4.96. On this platfrom I have a BCM2070 bluetooth usb dongle. I am running a simple rfcomm server example from this link "http://people.csail.mit.edu/albert/bluez-intro/x502.html". I ran a rfcomm client on ubuntu pc with BCM2070 bluetooth usb dongle and I could talk between the server and client.

Now I am developing an app on android but i am unable to connect to rfcomm server. I even tried running the rfcomm server on ubuntu machine but same result. I have attached the log of hcidump.

Quoted 1 line

HCI Event: Connect Request (0x04) plen 10

    bdaddr D0:E7:82:4A:26:BA class 0x5a011c type ACL < HCI Command: Accept Connection Request (0x01|0x0009) plen 7 bdaddr D0:E7:82:4A:26:BA role 0x00
    Role: Master

Quoted 1 line

HCI Event: Command Status (0x0f) plen 4

    Accept Connection Request (0x01|0x0009) status 0x00 ncmd 1

Quoted 1 line

HCI Event: Role Change (0x12) plen 8

    status 0x00 bdaddr D0:E7:82:4A:26:BA role 0x00
    Role: Master

Quoted 1 line

HCI Event: Connect Complete (0x03) plen 11

    status 0x00 handle 12 bdaddr D0:E7:82:4A:26:BA type ACL encrypt 0x00 < HCI Command: Read Remote Supported Features (0x01|0x001b) plen 2 handle 12

Quoted 1 line

HCI Event: Command Status (0x0f) plen 4

    Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 1

Quoted 1 line

HCI Event: Read Remote Supported Features (0x0b) plen 11

    status 0x00 handle 12
    Features: 0xbf 0x3e 0x8d 0xfe 0xdb 0xff 0x5b 0x87
< HCI Command: Read Remote Extended Features (0x01|0x001c) plen 3 handle 12 page 1

Quoted 1 line

HCI Event: Command Status (0x0f) plen 4

    Read Remote Extended Features (0x01|0x001c) status 0x00 ncmd 1

Quoted 1 line

ACL data: handle 12 flags 0x02 dlen 12

    L2CAP(s): Connect req: psm 1 scid 0x0040
< ACL data: handle 12 flags 0x00 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0040 result 1 status 0 Connection pending - No futher information available < ACL data: handle 12 flags 0x00 dlen 10
    L2CAP(s): Info req: type 2

Quoted 1 line

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

    handle 12 packets 2

Quoted 1 line

ACL data: handle 12 flags 0x02 dlen 16

    L2CAP(s): Info rsp: type 2 result 0
      Extended feature mask 0x02fb
        Flow control mode
        Retransmission mode
        Enhanced Retransmission mode
        Streaming mode
        FCS Option
        Extended Flow Specification
        Fixed Channels
        Unicast Connectless Data Reception
< ACL data: handle 12 flags 0x00 dlen 10
    L2CAP(s): Info req: type 3

Quoted 1 line

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

    handle 12 slots 5

Quoted 1 line

ACL data: handle 12 flags 0x02 dlen 20

    L2CAP(s): Info rsp: type 3 result 0
      Fixed channel list 0x00000006
        L2CAP Signalling Channel
        L2CAP Connless
< ACL data: handle 12 flags 0x00 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0040 result 0 status 0 Connection successful
< ACL data: handle 12 flags 0x00 dlen 23
    L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 11 RFC 0x00 (Basic)

Quoted 1 line

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

    handle 12 packets 2

Quoted 1 line

ACL data: handle 12 flags 0x02 dlen 16

    L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 4 MTU 1691
< ACL data: handle 12 flags 0x00 dlen 18
    L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 4 MTU 1691

Quoted 1 line

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

    handle 12 packets 2

Quoted 1 line

ACL data: handle 12 flags 0x02 dlen 14

    L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 0 Success

Quoted 1 line

ACL data: handle 12 flags 0x02 dlen 31

    L2CAP(d): cid 0x0040 len 27 [psm 1]
        SDP SS Req: tid 0x26 len 0x16
          pat uuid-128 00001101-0000-1000-8000-00805f9b34fb max 16
          cont 00
< ACL data: handle 12 flags 0x00 dlen 14
    L2CAP(d): cid 0x0040 len 10 [psm 1]
        SDP SS Rsp: tid 0x26 len 0x5
          count 0
          cont 00

Quoted 1 line

HCI Event: Read Remote Extended Features (0x23) plen 13

    status 0x00 handle 12 page 1 max 2
    Features: 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00 < HCI Command: Remote Name Request (0x01|0x0019) plen 10 bdaddr D0:E7:82:4A:26:BA mode 2 clkoffset 0x0000

Quoted 1 line

ACL data: handle 12 flags 0x02 dlen 12

    L2CAP(s): Disconn req: dcid 0x0040 scid 0x0040 < ACL data: handle 12 flags 0x00 dlen 12 L2CAP(s): Disconn rsp: dcid 0x0040 scid 0x0040

Quoted 1 line

HCI Event: Command Status (0x0f) plen 4

    Remote Name Request (0x01|0x0019) status 0x00 ncmd 1

Quoted 1 line

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

    handle 12 packets 2

Quoted 1 line

HCI Event: Remote Name Req Complete (0x07) plen 255

    status 0x00 bdaddr D0:E7:82:4A:26:BA name 'A1-810'

Quoted 1 line

HCI Event: Disconn Complete (0x05) plen 4

    status 0x00 handle 12 reason 0x13
    Reason: Remote User Terminated Connection

What could be the reason for termination of a connection. On my host machine i just have rfcomm server running nothing else. Does my rfcomm server needs to have anything else in it.

Can some one please help me to understand what could be causing this issue.

Thanks
Tama