BTStack for Polar Wearlink®+ Heart Rate Transmitter

1,239 views
Skip to first unread message

Robert Lange

unread,
May 20, 2011, 8:31:54 AM5/20/11
to btstack-dev
hi folks,
does anyone has a clue how to get the Polar Wearlink®+ Heart Rate
Transmitter used with iPhone (4 in my case)?
So far I can tell the Polar Wearlink®+ Heart Rate Transmitter doesn't
work with the build-in BTStack.
If someone could get it working or has a clue how to use it would very
very nice.

Thanks a lot
Rob from Germany

Robert Lange

unread,
May 20, 2011, 10:51:45 AM5/20/11
to btstack-dev
ps. the Polar Wearlink+ Heart Rate Transmitter uses the SPP protocol
so far I can tell.
I'm not a programmer so I appreciate any kind of help on this
problem ;)
Thanks guys
/rob

mungewell

unread,
May 20, 2011, 10:52:28 AM5/20/11
to btstack-dev
The first thing would be trying to understand how the device
advertises it's links and what protocol if uses over them.

You can get a SDP 'dump' of them that would help a lot. For example
from a Linux command line you could do 'sdptool --browse --tree --raw
<BT Devices MAC>'.
Simon.

Matthias Ringwald

unread,
May 20, 2011, 11:00:18 AM5/20/11
to btsta...@googlegroups.com

on the Mac, make sure you have Xcode installed, start the PacketLogger utility and then just try to set it up with your Mac. Then post the packet log somewhere, so we can have a quick look.

the other thing is that usually you would need to somehow bring your device into a "discoverable" mode.

and yes, thanks for pointing to this device, I've seen it before and wondered about if it could be used with iOS, but then forgot it again (I didn't buy one at that time :))

Best
Matthias

> --
> You received this message because you are subscribed to the Google Groups "btstack-dev" group.
> To post to this group, send email to btsta...@googlegroups.com.
> To unsubscribe from this group, send email to btstack-dev...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/btstack-dev?hl=en.
>

Robert Lange

unread,
May 20, 2011, 11:05:13 AM5/20/11
to btstack-dev
Thanks Simon,
Thanks Matthais,
I will get one asap and do whatever u guys want to figure out how to
get it working ;)
Get back to you asap.
/rob

On May 20, 5:00 pm, Matthias Ringwald <matthias.ringw...@gmail.com>
wrote:

Robert Lange

unread,
May 25, 2011, 6:30:53 AM5/25/11
to btstack-dev
Hi Guys,
I get one in the next days for testing and also have the setup done to
get all the informations you may need.
I get back to you asap.
Thanks again.
/rob

Robert Lange

unread,
Jun 13, 2011, 3:23:11 PM6/13/11
to btstack-dev
Hi Guys,
I need your help.
I got my mates mac. XCode is installed and I can connect the Wearlink+
to the Mac by using BT.

I also installed CocoaPacketAnalyzer to collect the data you need.
But I dont get anything.

Can you give me a hint on it?

Cheers
/rob

ps. Sorry Guys. I'm just an MCSE :(
no clue about mac at all :(

Robert Lange

unread,
Jun 14, 2011, 3:57:16 AM6/14/11
to btstack-dev
Hi Matthias,
got the log you need.
You can download the pdf file here:
http://mobile-parts-discount.net/formulare/polar-wearlink-bt-log.pdf

Pls let me know if u need anything else.
Have a lot of guys looking forward to use the wearlink+ with runtastic
or such an app :)

/rob

On May 20, 5:00 pm, Matthias Ringwald <matthias.ringw...@gmail.com>
wrote:

Matthias Ringwald

unread,
Jun 14, 2011, 4:11:09 AM6/14/11
to btsta...@googlegroups.com
Hi Robert

I prefer the original .pklg format but the pdf was a good start. If you look at the service requests, you can see that the only one with a response (5-6 bytes == don't support) is the Serial Port Profile - which isn't too surprising for custom stuff.

Now, by pairing, you should have got a new serial port on your mac - or a new COM port if you're on Windows. Try opening that one and log to a file. On mac just "cat /dev/tty.NEW-SERIAL-PORT-FOR-POLAR > logfile. Let it running for a while until you've got some data in there. now, the tricky part starts: what do does bytes mean?

If you can figure that out, we can talk to it from Mac/Win/Linux/BTstack,... and please don't forget to post it publicly. :)

Good luck
Matthias

Robert Lange

unread,
Jun 14, 2011, 7:37:43 AM6/14/11
to btstack-dev
Hi Matthias,
here a new log as pklg file.
http://mobile-parts-discount.net/formulare/polar-wearlink-bt-log.pklg

I will try to work out how I get the serial log you want on the mac
today.
But I reckon its gonna be a lot easier for me to do it on my Windows
System.
Need to give back the Mac tonite.
So if you need anything else based on the Mac system pls let me know
asap :)

Cheers
/rob

ps. what did you mean with "post it publicly"? isnt the link to the
file public?
how should i do it?

On Jun 14, 10:11 am, Matthias Ringwald <matthias.ringw...@gmail.com>
wrote:

Matthias Ringwald

unread,
Jun 14, 2011, 8:22:23 AM6/14/11
to btsta...@googlegroups.com
Hi Robert

On 14.06.2011, at 13:37, Robert Lange wrote:

> Hi Matthias,

Thanks.

>
> I will try to work out how I get the serial log you want on the mac
> today.
> But I reckon its gonna be a lot easier for me to do it on my Windows
> System.

As it is SPP, you can do on any OS where you're able to record a serial data stream.

> Need to give back the Mac tonite.
> So if you need anything else based on the Mac system pls let me know
> asap :)

Nope.

>
> ps. what did you mean with "post it publicly"? isnt the link to the
> file public?

Sorry, "publicly" was redundant in that sentence. I meant that you, after you figure out what the data means, write a little text that explains how to interpret the data.

Best
Matthias

Robert Lange

unread,
Jun 15, 2011, 2:28:46 AM6/15/11
to btstack-dev
Hi Matthias,
I tried to collect some datas from the polar wearlink+

Please check the following two files:
http://mobile-parts-discount.net/formulare/polar.csv
http://mobile-parts-discount.net/formulare/polar2.txt

I guess the polar.csv file is more promising as the second one.

From my point of view I must say that I got a bit lost.
As you can see in the csv file there are not much details you get from
the wearlink.
And this makes sense as only information you should get is your
current heart beat.
So far I can tell the IRP_MJ_READ must be the bit we need.
But. every second collect the HEX value is "fe".
For the record. As I recorded the data my heart beat was between 70
and 75 beats per min.

Hope this information tells you more as I can figure out :(

Let me know if you wanna get anything else or you have a better idea
to record the data.
I used my Windows 7 system and the Eltima Serial Port Monitor 4.0

Dont have a working Linux system :(

Thanks for helping.
/rob

On Jun 14, 2:22 pm, Matthias Ringwald <matthias.ringw...@gmail.com>
wrote:

Matthias Ringwald

unread,
Jun 15, 2011, 3:19:10 AM6/15/11
to Robert Lange, btstack-dev
Hi Robert

The first one is very verbose and I don't know how to read that format. The second looks fine but uses some funny symbols.
Can your tool just dump the received data with a time stamp and as hex data (11:23:00 0x01 0x02 0x03 ...)
If that's not possible, you should be able to just save the binary data and e.g. open it with a hex viewer.

> So far I can tell the IRP_MJ_READ must be the bit we need.
> But. every second collect the HEX value is "fe".

At the end, there are some other lines with actual data in there.

Did you browse the web if someone already wondered about that data? usually it's nice linux people who figure out stuff. :)

Best
Matthias

Matthias Ringwald

unread,
Jun 17, 2011, 8:52:34 AM6/17/11
to Robert Lange, btstack-dev

On 16.06.2011, at 10:01, Robert Lange wrote:

> Quick question.
> With the details we have so far, could we connect the Wearlink with the iPhone already?

yes. you can run the rfomm-cat example to receive the data with the iPhone

Best
Matthais

Robert Lange

unread,
Jun 22, 2011, 5:14:55 AM6/22/11
to btstack-dev
Hi Matthias,
Sorry for late reply.
Here another file
http://mobile-parts-discount.net/formulare/polar3.txt

I tried to get any information of the guys behind runtastic.
Unfortunately, the doc to the Wearlink+ seems to be under NDA and
as we need a Jailbreak to be able to use the Wearlink+ BT with the
iPhone they dont care
anymore :(

Hope you can figure out anything and may set up a tiny app to show the
heart beat on the iPhone.
I would like to give you a hand on it but I'm very bad in coding :(

I will tried to get hold of the guys from Polar directly as they
should be very interest to get the product
used as much as possible => more sales...

Please let me know what you reckon and how I can help.

Thanks
/rob

On Jun 17, 2:52 pm, Matthias Ringwald <matthias.ringw...@gmail.com>
wrote:

Matthias Ringwald

unread,
Jun 22, 2011, 7:48:20 AM6/22/11
to btsta...@googlegroups.com
Hallo Robert

On 22.06.2011, at 11:14, Robert Lange wrote:
>
> I tried to get any information of the guys behind runtastic.
> Unfortunately, the doc to the Wearlink+ seems to be under NDA and
> as we need a Jailbreak to be able to use the Wearlink+ BT with the
> iPhone they dont care
> anymore :(

Well, I seriously would have been surprised if you would have gotten any useful information. Even if those guys would be very nice, they would have to ask a lawyer, who, as it is his job, has to say "No WAY!". There's zero benefit for them to hand out information, but a very high risk of getting sued if they would do.

> I will tried to get hold of the guys from Polar directly as they
> should be very interest to get the product
> used as much as possible => more sales...

Again, please try, but I don't expect a more positive result . At least they will learn that more people are interested. Polar will also have a lawyer and they didn't put the guy from runtastic under an NDA just to provide you with information. If they wanted to have an iPhone app, they would try to join the Made for iPhone program, which they might actually do, but won't tell anybody.

> Hope you can figure out anything and may set up a tiny app to show the
> heart beat on the iPhone.
> I would like to give you a hand on it but I'm very bad in coding :(

So, now we're in the game of reverse engineering of data formats. And it looks like we will have a public exercise right away. And by the way, reverse engineering data formats only requires logic and maths skills, programming skills are not needed.

So... you have this file here, which is cluttered with useless status information.

> Please let me know what you reckon and how I can help.

> ..http://mobile-parts-discount.net/formulare/polar3.txt

Trying to clean this up, I used the grep tool:

$ grep -A 2 IRP_MJ_READ Desktop/polar3.txt | grep -v IRP | grep -v STA | grep " "

to get data like this:

08 f7 01 d1 00 06 0c .˜.—...
fe ˛
08 f7 02 d1 00 06 0c .˜.—...
fe ˛
08 f7 03 d1 00 06 0c .˜.—...
fe ˛
08 f7 04 d1 00 06 0c .˜.—...
fe ˛
08 f7 05 d1 00 06 0c .˜.—...
fe ˛
08 f7 06 d1 00 06 0c .˜.—...
fe ˛
08 f7 07 d1 00 06 0c .˜.—...
fe ˛
08 f7 08 d1 00 06 0c .˜.—...
fe ˛
0a f5 09 d1 4c 02 cf 03 34 .ı.—L.œ.4
fe ˛
08 f7 0a d1 4a 03 4b .˜.—J.K
fe ˛
0a f5 0b d1 4a 03 5c 03 0d .ı.—J.\..
fe ˛
08 f7 0c d1 4d 02 e5 .˜.—M.Â
fe ˛
0a f5 0d d1 4f 02 b5 02 aa .ı.—O.µ.™
fe ˛
0a f5 0e d1 4f 02 c3 03 29 .ı.—O.√.)
fe ˛
08 f7 0f d1 4f 03 aa .˜.—O.™
fe ˛
0a f5 00 d1 4f 03 88 03 25 .ı.—O.à.%
fe ˛


Now, we have to look carefully. Do you see any patterns?

The first byte of the longer packet is either 8 or 10.
The second byte is either 0xf7 or 0xf5. Note that 8 in the first byte always has 0xf7 in the second and vice versa.
Some random idea tells me that this is a way to detect the start of the transmission and that the second byte is the inverse for the first, or... second byte = 255 - first byte.

Then, I can see that the 3. byte looks like a counter, which only counts until 15 and then resets.

The fourth byte is always 0xd1 - no idea what it's good for.

Now, it's getting interesting. The fifth byte changes and has values in the range of 0x4a - 0x50. These are 74-90, which look like perfectly legit heart rate measurements.
After that, I have no idea what the rest of the data is. Hm.. I would expect the battery value to be in there, too. Can you check if the 0xd1 goes down over time?

Finally, we have two different packet lengths, and a single 0xfe in every second line. The 8 and the 10 as the first byte look like a packet length, and together with the 0xfe, it sums up. But I cannot explain why the 0xfe is send in-between. I bet it's an artifact of using a serial port emulation to send packets, but cannot put my finger down on the logic for this.

Anyway, that's enough for a first prototype. The algorithm would look like this: read data and try to find two bytes, where the first is 8 or 10 and the second is 255-the first. The fifth then gives the heart rate in beats/minute. I may write a quick command line test over the weekend, if nobody beats me.

Best
Matthias


Robert Lange

unread,
Jun 22, 2011, 8:58:06 AM6/22/11
to btstack-dev
Hi Matthias,
Thanks for getting back so quickly.

Here a dump file the way you may like it :)
http://mobile-parts-discount.net/formulare/polar-dump.txt

I will use the Wearlink+ all day and see if the battery value drops
down til tomorrow.

On some websites I found the information that the Wearlink+ send the
battery value as well together with the heart rate.
May I get a second battery and drain one to about 50% so we can see
the change and will be able to figure out what the
sent value means.

/rob

On Jun 22, 1:48 pm, Matthias Ringwald <matthias.ringw...@gmail.com>
wrote:

Jérôme Hamm

unread,
Jun 23, 2011, 7:07:37 AM6/23/11
to btsta...@googlegroups.com
Hi Robert,

Do you actually have a Nike+ or a Bluetooth transmitter?

Jérôme.

Robert Lange

unread,
Jun 23, 2011, 7:25:59 AM6/23/11
to btsta...@googlegroups.com
the bluetooth one

/rob

kmk

unread,
Jul 24, 2011, 3:59:02 AM7/24/11
to btsta...@googlegroups.com
Hi Robert, Matthias,
Did you get any final results and would like to share them?

I was looking for some manual or other formal information from polar about this protocol with no good results yet. It's kind of strange that they do not publish the communication schem for everyone to implement... 

Please let me know if you were able to get some more data extracted from the logs. 
Thanks in advance.

br
kmk

Robert Lange

unread,
Jul 24, 2011, 10:13:06 AM7/24/11
to btsta...@googlegroups.com
Hi,
I didn't make any process so far.
My hope was Mathias could come up with something but to be honest I don't it makes any sense to put energy in this project as apps like runtastic or so wouldn't be able to handle the data we could get from the belt.

I had a talk to the guys from Suunto about the latest products (dive computer, heart rate belt).
We say with the next iPhone and BT Version 5?! they have the opportunity to come up with something.
Not sure about it at all.

--
You received this message because you are subscribed to the Google Groups "btstack-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/btstack-dev/-/d1uymz425ZQJ.

Matthias Ringwald

unread,
Jul 26, 2011, 4:34:59 AM7/26/11
to btsta...@googlegroups.com
HI KMK

I guess you found my analysis, and I'm pretty confident that I've identified the right byte as heart rate. Aside from some new companies, most companies won't tell you anything because a) lawyers or b) nobody is responsible or c) nobody wants to accept the "risk" of publishing those formats. Sometimes it is even something else, who knows?

Anyway, the heart rate value is there, and maybe also the battery level, what else are you looking for?

Best
Matthias

Szucs Mark

unread,
Feb 15, 2012, 11:43:50 AM2/15/12
to btsta...@googlegroups.com
Hi
Sorry for bothering.
I would like to connect the Polar Wearlink to an android phone. And develope an application on it.
Could you tell me your experience in this topic?
If i would know the protocol which it using for communicate on bluetooth.
Thanks,
Szűcs Márk

alfriz

unread,
Feb 25, 2012, 1:53:54 PM2/25/12
to btsta...@googlegroups.com

I tried to develop an application for iPhone. I connected Polar device and i logged data, but after 50-55 secs the communication drop down. 
Before dropping btstack returns L2CAP_EVENT_TIMEOUT_CHECK message.
I am running  iPhone 3 with 4.1 os and i need some help.

Thanks in advance.

alfriz

unread,
Feb 27, 2012, 7:42:58 AM2/27/12
to btsta...@googlegroups.com

I made some more analysis on issue. I logged data using iPhone and BTstack and using Mac. On iPhone connection drop down after about 50 sec, on Mac communication was stable. In my opinion there should be something wrong in credits management, but i think that Matthias could better analyze problem.

http://dl.dropbox.com/u/22055472/hci_dump_HRM_btstack_iphone.pklg

http://dl.dropbox.com/u/22055472/hci_dump_HRM_MACosx.pklg

I made my tests using my test app that retries connection after drop, but i also used rfcomm-cat app with same results. On Mac i used cool-term program.

Thanks,

Alfredo

Matthias Ringwald

unread,
Feb 27, 2012, 7:58:26 AM2/27/12
to btsta...@googlegroups.com
Hi Alfredo

thanks for the logs. What program did you use to connect to the Polar on the iPhone? Was it using the POSIX run loop or the Cocoa/CoreFoundation one?

Best
Matthias

> --
> You received this message because you are subscribed to the Google Groups "btstack-dev" group.

> To view this discussion on the web visit https://groups.google.com/d/msg/btstack-dev/-/Ws7MDSkA1G4J.

alfriz

unread,
Feb 27, 2012, 8:41:26 AM2/27/12
to btsta...@googlegroups.com
Many thanks for prompt reply Matthias!

I wrote a test app, anyway you could use rfcomm-cat, i had same results.
On that app i was using Cocoa run loop approach.

If you need more logs using rfcomm-cat i could capture it promptly.

Regars,

Alfredo 

alfriz

unread,
Mar 8, 2012, 4:06:56 AM3/8/12
to btstack-dev
No news about it?

Matthias Ringwald

unread,
Mar 13, 2012, 2:32:32 AM3/13/12
to btsta...@googlegroups.com
Hi Alfredo

Could you capture a log with rfcomm-cat please? 

Best 
Matthias

--
You received this message because you are subscribed to the Google Groups "btstack-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/btstack-dev/-/L7cxqLEKpzcJ.

Matthias Ringwald

unread,
Feb 21, 2013, 1:06:09 PM2/21/13
to btsta...@googlegroups.com
Hi David

you can enable Packet Logging in the Settings and the have a look at /tmp/hci_dump.pklg - you should see all your sensor readings and then, what happens the moment it stops. One possibility is that the watch doesn't have enough credits. I assume BTstack doesn't make a mistake in counting credits, but I never really "proofed" that. We had no problems with RFCOMM in Celeste, which is/was used to send multi megabyte files.

best
matthias


On Feb 16, 2013, at 2:20 PM, David O. <david...@gmail.com> wrote:

> Hi everybody,
> sorry for posting to this old thread.
> I have exactly the same problem with the Polar Wearlink Bluetooth Sensor. I can connect with rfcomm-cat, and it keeps reporting measurements about a minute. Then the rfcomm-connection is closed.
>
> Does somebody has an idea whats the reason for this?
>
> Am Dienstag, 13. März 2012 07:32:32 UTC+1 schrieb Matthias Ringwald:
> Hi Alfredo
>
> Could you capture a log with rfcomm-cat please?
>
> Best
> Matthias
>
> Here are the respective logs:
> https://www.dropbox.com/s/szrd99vpyck7du3/hci_dump.pklg
> https://www.dropbox.com/s/rfnfpg2byplu30k/rfcomm-out.txt
>
> Best regards,
> David
>
> --
> You received this message because you are subscribed to the Google Groups "btstack-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to btstack-dev...@googlegroups.com.
> To post to this group, send email to btsta...@googlegroups.com.
> Visit this group at http://groups.google.com/group/btstack-dev?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

David O.

unread,
Feb 23, 2013, 12:31:07 PM2/23/13
to btsta...@googlegroups.com
Hi Matthias,
thanks for the hints.
It seems like i have found the reason. To use this sensor you need to
enable sniff mode. You can even use MaxInterval to configure the frequency
of the measurements.

After this, the connection is really stable. There might be still some
problem when iOS suspends the app (or btdaemon?), but i need to investigate
this further.

Best regards
David
Reply all
Reply to author
Forward
0 new messages