Decoding message packet send via RFCOMM

164 views
Skip to first unread message

Nikolai Onken

unread,
Dec 4, 2009, 1:36:45 PM12/4/09
to btstack-dev
HI all,

I finally got the iPhone app to receive data from the Arduino and
everything is falling into place.
Already thanks so much for the input I have gotten so far.

The last issue I am stuck with and I am not sure whether I just don't
understand packaging or whether this is not yet implemented is the
fact how I "decode" the message I have sent via bluetooth using
RFCOMM.

In Arduino BT I simply do a

Serial.println("Hi, this is my message");

and in my iPhone app I an trying to log the packages using:

NSLog(@"RX: address %02x, control %02x %02x %02x %02x %02x %02x %02x
%02x", packet[0], packet[1], packet[2], packet[3], packet[4], packet
[5], packet[6], packet[7], packet[8]);

I get something like this:

Fri Dec 4 19:35:11 unknown Test[3950] <Warning>: RX: address 09,
control ef 09 61 6f 0d 0a 40 0a

Is there a simple way to decode my message "Hi, this is a message" and
log it to the iPhone logger?

Thanks again and I already started writing a detailed blogpost about
how to get this stuff running,

Nikolai

Matthias Ringwald

unread,
Dec 5, 2009, 10:36:04 AM12/5/09
to btstack-dev
hi

there is nothing to decode. can you show me the output from the original rfcomm.c?


On Dec 4, 2009, at 7:36 PM, Nikolai Onken wrote:

> HI all,
>
> I finally got the iPhone app to receive data from the Arduino and
> everything is falling into place.
> Already thanks so much for the input I have gotten so far.
>
> The last issue I am stuck with and I am not sure whether I just don't
> understand packaging or whether this is not yet implemented is the
> fact how I "decode" the message I have sent via bluetooth using
> RFCOMM.
>
> In Arduino BT I simply do a
>
> Serial.println("Hi, this is my message");
>
> and in my iPhone app I an trying to log the packages using:
>
> NSLog(@"RX: address %02x, control %02x %02x %02x %02x %02x %02x %02x
> %02x", packet[0], packet[1], packet[2], packet[3], packet[4], packet
> [5], packet[6], packet[7], packet[8]);
>
> I get something like this:
>
> Fri Dec 4 19:35:11 unknown Test[3950] <Warning>: RX: address 09,
> control ef 09 61 6f 0d 0a 40 0a
..

Nikolai Onken

unread,
Dec 6, 2009, 2:16:03 PM12/6/09
to btstack-dev
Hi Matthias,

I am now sending "Hi friends" to the iPhone using a Serial.println("Hi
friends");
This is a whole bunch of logs I am getting running the plain rfcomm (./
rfcomm)

Turn on the Arduino BT
Please enter PIN 12345 on remote device
Channel successfully opened: 00-07-80-90-50-C8, handle 0x25, psm 0x03,
source cid 0x40, dest cid 0x41
Sending SABM #0
Received RFCOMM unnumbered acknowledgement for channel 0 - multiplexer
working
Sending UIH Parameter Negotiation Command
UIH Parameter Negotiation Response
Sending SABM #1
Received RFCOMM unnumbered acknowledgement for channel 1 - channel
opened
Sending MSC 'I'm ready'
Received BT_RFCOMM_MSC_CMD
Responding to 'I'm ready'
RFCOMM up and running!
Got 1 credits, can send!
RX: address 09, control ff:
Received BT_RFCOMM_MSC_CMD
Responding to 'I'm ready'
RFCOMM up and running!
RX: address 09, control ef: 48
RX: address 09, control ef: 69 20 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48 69 20 66 72 69 65 6E
RX: address 09, control ef: 64 73 0D 0A
RX: address 09, control ef: 48 69 20 66 72 69 65 6E
RX: address 09, control ef: 64 73 0D 0A
RX: address 09, control ef: 48
RX: address 09, control ef: 69 20 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48
RX: address 09, control ef: 69 20 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48
RX: address 09, control ef: 69 20 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48 69 20
RX: address 09, control ef: 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48
RX: address 09, control ef: 69 20 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48 69 20
RX: address 09, control ef: 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48
RX: address 09, control ef: 69 20 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48
RX: address 09, control ef: 69 20 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48
RX: address 09, control ef: 69 20 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48 69 20 66 72
RX: address 09, control ef: 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48 69 20 66 72 69 65 6E
RX: address 09, control ef: 64 73 0D 0A
RX: address 09, control ef: 48
RX: address 09, control ef: 69 20 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48
RX: address 09, control ef: 69 20 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48
RX: address 09, control ef: 69 20 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48 69
RX: address 09, control ef: 20 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48 69
RX: address 09, control ef: 20 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48 69
RX: address 09, control ef: 20 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48 69 20 66 72
RX: address 09, control ef: 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48
RX: address 09, control ef: 69 20 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48 69 20 66
RX: address 09, control ef: 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48
RX: address 09, control ef: 69 20 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48
RX: address 09, control ef: 69 20 66 72 69 65 6E 64 73 0D 0A
RX: address 09, control ef: 48 69
RX: address 09, control ef: 20 66 72 69 65 6E 64 73 0D 0A

There are a few hexadecimal values repeating such as

69 20 66 72 69 65 6E 64 73 0D 0A

but I am not sure how to make heads out of this.
Thanks already so much for your help so far!!
Regards,

Nikolai

On Dec 5, 4:36 pm, Matthias Ringwald <matthias.ringw...@gmail.com>
wrote:

Nikolai Onken

unread,
Dec 6, 2009, 2:17:51 PM12/6/09
to btstack-dev
Btw, really I want to send a JSON String, e.g. {"foo": "bar"} or
{"items": ["ffdsm", "fgds", "fsa"]} but that should not make a
difference

Matthias Ringwald

unread,
Dec 6, 2009, 3:39:19 PM12/6/09
to btsta...@googlegroups.com
Hi Nikolai,

you really should learn to read text in ASCII...

On Dec 6, 2009, at 8:16 PM, Nikolai Onken wrote:

Hi Matthias,

I am now sending "Hi friends" to the iPhone using a Serial.println("Hi
friends");
This is a whole bunch of logs I am getting running the plain rfcomm (./
rfcomm)
..There are a few hexadecimal values repeating such as


69 20 66 72 69 65 6E 64 73 0D 0A

let me help a bit:
0x69 = 105 = 'i'
0x20 =   32 = ' '
0x66 = 102 = 'f'
0x72 =  ...    = 'r'
...

i guess you get the picture. you can also change %02x in hexdump() of src/utils.c to %c and you'll get the text output.

please not that there is no framing, which means you'll never know when your message is completely received. that's a general deficit with using a serial connection: detecting packet borders is up to you, e.g. by first sending a length indicator. at least you have newlines (0d 0a).

best
matthias

Nikolai Onken

unread,
Dec 6, 2009, 3:42:44 PM12/6/09
to btstack-dev
HI Matthias,

> you really should learn to read text in ASCII...

absolutely, you just gave me enough hints so I can dive in, thanks for
that!!
And yes, when I specify a packet length this should be pretty straight
forward.

Thanks again for pointing me into the right direction!!

Regards,

Nikolai
Reply all
Reply to author
Forward
0 new messages