Pebble: Support "Pebble Health" #188

Closed
opened 6 years ago by ashimokawa · 26 comments
Owner

It seems like firmware 3.8 for Pebble Time has native activity tracking.

https://blog.getpebble.com/2015/12/15/health

We need to support it
(That excludes me, since I do not own a Pebble Time)

  • Find out how to activate Health
  • Find out how to de-activate Health
  • Find out how to set the correct parameters for Health
    (probably, including SI distance units for fw >= 3.9)
  • Find out how to retrieve the steps data from the watch (probably)
  • Find out how to retrieve the sleep data from the watch (missing deep sleep data)
It seems like firmware 3.8 for Pebble Time has native activity tracking. https://blog.getpebble.com/2015/12/15/health We need to support it (That excludes me, since I do not own a Pebble Time) - [x] Find out how to activate Health - [x] Find out how to de-activate Health - [x] Find out how to set the correct parameters for Health (probably, including SI distance units for fw >= 3.9) - [x] Find out how to retrieve the steps data from the watch (probably) - [x] Find out how to retrieve the sleep data from the watch (missing deep sleep data)
wngr commented 6 years ago (Migrated from github.com)
Poster
Owner

There is no API released yet.

Early next year.
There is no API released yet. ``` Early next year. ```
Owner

if anyone who is using the original app could send us bluetooth logs when the health app is being enabled, that would help a lot!

if anyone who is using the original app could send us bluetooth logs when the health app is being enabled, that would help a lot!
wngr commented 6 years ago (Migrated from github.com)
Poster
Owner

I'm happy to help and provide the logs.

Which logs do you need and where can I get them (maybe we can add a wiki page for that?)

I'm happy to help and provide the logs. Which logs do you need and where can I get them (maybe we can add a wiki page for that?)
Poster
Owner

In Android developer settings, enable "Bluetooth HCI snoop log", after that enable pebble health (I dont know if you have to factory reset the pebble IF you already enabled pebble health). Then you should immediately disable HCI snoop again and send us the file /sdcard/btsnoop_hci.log.

Before sending please look at the file with an hex editor to check if it contains personal information, if you are running a real operating system and not windows, you can type "strings btsnoop_hci.log | less" which should give you a good overview.

I think the official Pebble app sometimes (always?) syncs calendar events on connect so if you have some secret appointments which are in the btsnoop_hci.log you should not send that to anyone.
Just saying.

In Android developer settings, enable "Bluetooth HCI snoop log", after that enable pebble health (I dont know if you have to factory reset the pebble IF you already enabled pebble health). Then you should immediately disable HCI snoop again and send us the file /sdcard/btsnoop_hci.log. Before sending please look at the file with an hex editor to check if it contains personal information, if you are running a real operating system and not windows, you can type "strings btsnoop_hci.log | less" which should give you a good overview. I think the official Pebble app sometimes (always?) syncs calendar events on connect so if you have some secret appointments which are in the btsnoop_hci.log you should not send that to anyone. Just saying.
Owner

to complement what @ashimokawa said:

The first step is to bring the watch in a situation like the pristine status, where the watch health app shows a message "This app requires pebble health. You have to enable health in the pebble app on your phone..."

I guess that disabling the health app on the phone is enough, but I have seen only screenshots :)

Then follow the directions above: enable bt logging and afterwards enable health in the official app. I would say starting the health app on the watch wouldn't hurt before stopping the bluetooth logging.

Thanks for your help!

to complement what @ashimokawa said: The first step is to bring the watch in a situation like the pristine status, where the watch health app shows a message "This app requires pebble health. You have to enable health in the pebble app on your phone..." I guess that disabling the health app on the phone is enough, but I have seen only screenshots :) Then follow the directions above: enable bt logging and afterwards enable health in the official app. I would say starting the health app on the watch wouldn't hurt before stopping the bluetooth logging. Thanks for your help!
Owner

The Health API documentation has been published, however it doesn't help us because it documents how external apps might use Health data. The core health functionality is not documented.

The [Health API](https://developer.getpebble.com/docs/c/preview/Foundation/Event_Service/HealthService/) documentation has been published, however it doesn't help us because it documents how external apps might use Health data. The core health functionality is not documented.
wngr commented 6 years ago (Migrated from github.com)
Poster
Owner

I hope that helps.

Activated the Pebble Health app.

hexdump btsnoop_hci.log 
0000000 7462 6e73 6f6f 0070 0000 0100 0000 ea03
0000010 0000 0600 0000 0600 0000 0200 0000 0000
0000020 e200 e107 5c22 7782 0401 0208 0004 0000
0000030 3500 0000 3500 0000 0000 0000 0000 e200
0000040 e107 5c22 3b87 0402 3020 2c00 7600 0b01
0000050 4fff 0001 b123 01db 4813 1307 6361 6974
0000060 6976 7974 7250 6665 7265 6e65 6563 0973
0000070 0000 0000 0100 0000 0200 0086 0000 0007
0000080 0000 0007 0000 0003 0000 0000 07e2 22e1
0000090 a15c 04ef 040f 0100 0804 0000 0800 0000
00000a0 0800 0000 0300 0000 0000 e200 e107 6222
00000b0 9abd 1304 0105 0004 0001 0000 0900 0000
00000c0 0900 0000 0300 0000 0000 e200 e107 6222
00000d0 fec4 1404 0006 0004 0000 0000 0000 0015
00000e0 0000 0015 0000 0001 0000 0000 07e2 22e1
00000f0 4863 02d7 2004 0010 000c 0045 ff09 010f
0000100 0300 dbb1 4813 5c01 0000 0e00 0000 0e00
0000110 0000 0200 0000 0000 e200 e107 af22 9a22
0000120 0301 0a08 0004 0320 0190 0004 0001 0000
0000130 0700 0000 0700 0000 0300 0000 0000 e200
0000140 e107 af22 d225 0f04 0004 0301 0008 0000
0000150 0009 0000 0009 0000 0003 0000 0000 07e2
0000160 22e1 4aaf 044c 0614 0400 0200 0320 0000
0000170 0e00 0000 0e00 0000 0300 0000 0000 e200
0000180 e107 b622 5ba7 2e04 000b 0004 0320 0320
0000190 0002 0002 0000 2200 0000 2200 0000 0100
00001a0 0000 0000 e200 e107 dc22 dbc7 0402 1d20
00001b0 1900 4500 0900 2bef 1100 3400 8f02 863c
00001c0 3186 4fa1 915f 01f5 0c60 dc9b 4059 0000
00001d0 2200 0000 2200 0000 0100 0000 0000 e200
00001e0 e107 dc22 62cc 0402 1d20 1900 4500 0900
00001f0 2bef 1100 3400 de01 42c0 064c 4825 b178
0000200 14f2 577e 36e8 4088 0000 0600 0000 0600
0000210 0000 0200 0000 0000 e200 e107 dc22 16d5
0000220 0401 0208 0004 0000 0700 0000 0700 0000
0000230 0300 0000 0000 e200 e107 dc22 fed6 0f04
0000240 0004 0401 0008 0000 0009 0000 0009 0000
0000250 0003 0000 0000 07e2 22e1 72e4 04c1 0614
0000260 0400 0000 0000 0000 2200 0000 2200 0000
0000270 0100 0000 0000 e200 e107 f222 741f 0402
0000280 1d20 1900 4500 0900 2bef 1100 3400 de02
0000290 42c0 064c 4825 b178 14f2 577e 36e8 4088
00002a0 0000 2200 0000 2200 0000 0100 0000 0000
00002b0 e200 e107 f222 5929 0402 1d20 1900 4500
00002c0 0900 2bef 1100 3400 3601 c6d8 4ced 4f83
00002d0 a9a1 8fe2 dc12 1f94 408c 0000 0900 0000
00002e0 0900 0000 0300 0000 0000 e200 e107 3123
00002f0 4aa2 1404 0006 0004 0802 0007 0000 0006
0000300 0000 0006 0000 0002 0000 0000 07e2 23e1
0000310 a931 0190 0804 0402 0000 0000 0007 0000
0000320 0007 0000 0003 0000 0000 07e2 23e1 ac31
0000330 04e6 040f 0100 0804 0000 0900 0000 0900
0000340 0000 0300 0000 0000 e200 e107 3423 6de6
0000350 1404 0006 0004 0000 0000               
0000359
I hope that helps. Activated the Pebble Health app. ``` hexdump btsnoop_hci.log 0000000 7462 6e73 6f6f 0070 0000 0100 0000 ea03 0000010 0000 0600 0000 0600 0000 0200 0000 0000 0000020 e200 e107 5c22 7782 0401 0208 0004 0000 0000030 3500 0000 3500 0000 0000 0000 0000 e200 0000040 e107 5c22 3b87 0402 3020 2c00 7600 0b01 0000050 4fff 0001 b123 01db 4813 1307 6361 6974 0000060 6976 7974 7250 6665 7265 6e65 6563 0973 0000070 0000 0000 0100 0000 0200 0086 0000 0007 0000080 0000 0007 0000 0003 0000 0000 07e2 22e1 0000090 a15c 04ef 040f 0100 0804 0000 0800 0000 00000a0 0800 0000 0300 0000 0000 e200 e107 6222 00000b0 9abd 1304 0105 0004 0001 0000 0900 0000 00000c0 0900 0000 0300 0000 0000 e200 e107 6222 00000d0 fec4 1404 0006 0004 0000 0000 0000 0015 00000e0 0000 0015 0000 0001 0000 0000 07e2 22e1 00000f0 4863 02d7 2004 0010 000c 0045 ff09 010f 0000100 0300 dbb1 4813 5c01 0000 0e00 0000 0e00 0000110 0000 0200 0000 0000 e200 e107 af22 9a22 0000120 0301 0a08 0004 0320 0190 0004 0001 0000 0000130 0700 0000 0700 0000 0300 0000 0000 e200 0000140 e107 af22 d225 0f04 0004 0301 0008 0000 0000150 0009 0000 0009 0000 0003 0000 0000 07e2 0000160 22e1 4aaf 044c 0614 0400 0200 0320 0000 0000170 0e00 0000 0e00 0000 0300 0000 0000 e200 0000180 e107 b622 5ba7 2e04 000b 0004 0320 0320 0000190 0002 0002 0000 2200 0000 2200 0000 0100 00001a0 0000 0000 e200 e107 dc22 dbc7 0402 1d20 00001b0 1900 4500 0900 2bef 1100 3400 8f02 863c 00001c0 3186 4fa1 915f 01f5 0c60 dc9b 4059 0000 00001d0 2200 0000 2200 0000 0100 0000 0000 e200 00001e0 e107 dc22 62cc 0402 1d20 1900 4500 0900 00001f0 2bef 1100 3400 de01 42c0 064c 4825 b178 0000200 14f2 577e 36e8 4088 0000 0600 0000 0600 0000210 0000 0200 0000 0000 e200 e107 dc22 16d5 0000220 0401 0208 0004 0000 0700 0000 0700 0000 0000230 0300 0000 0000 e200 e107 dc22 fed6 0f04 0000240 0004 0401 0008 0000 0009 0000 0009 0000 0000250 0003 0000 0000 07e2 22e1 72e4 04c1 0614 0000260 0400 0000 0000 0000 2200 0000 2200 0000 0000270 0100 0000 0000 e200 e107 f222 741f 0402 0000280 1d20 1900 4500 0900 2bef 1100 3400 de02 0000290 42c0 064c 4825 b178 14f2 577e 36e8 4088 00002a0 0000 2200 0000 2200 0000 0100 0000 0000 00002b0 e200 e107 f222 5929 0402 1d20 1900 4500 00002c0 0900 2bef 1100 3400 3601 c6d8 4ced 4f83 00002d0 a9a1 8fe2 dc12 1f94 408c 0000 0900 0000 00002e0 0900 0000 0300 0000 0000 e200 e107 3123 00002f0 4aa2 1404 0006 0004 0802 0007 0000 0006 0000300 0000 0006 0000 0002 0000 0000 07e2 23e1 0000310 a931 0190 0804 0402 0000 0000 0007 0000 0000320 0007 0000 0003 0000 0000 07e2 23e1 ac31 0000330 04e6 040f 0100 0804 0000 0900 0000 0900 0000340 0000 0300 0000 0000 e200 e107 3423 6de6 0000350 1404 0006 0004 0000 0000 0000359 ```
Poster
Owner

Looks good. And contains we were looking for
Thanks!

Looks good. And contains we were looking for Thanks!
Owner

Thanks a lot @wngr for the dump (and @ashimokawa for the directions): I can confirm that I enabled health on my pebble time. Now I'll try to figure out how to get the data in GB.

@wngr when activating health, did you have to enter some details about you? Things like the wrist you are wearing the pebble (left/right), your gender, height, weight? We would like to understand the meaning of these bytes, and if they are related to something you entered or "standard".
Please note that if you want to test by yourself, you can easily look for the byte sequence "activityPreferences" in the dumps after changing the settings in pebble app, and see how the bytes that follow it change, and relate the changes to what you entered. You don't have to tell us what you entered :)

Thanks a lot @wngr for the dump (and @ashimokawa for the directions): I can confirm that I enabled health on my pebble time. Now I'll try to figure out how to get the data in GB. @wngr when activating health, did you have to enter some details about you? Things like the wrist you are wearing the pebble (left/right), your gender, height, weight? We would like to understand the meaning of [these bytes](https://github.com/Freeyourgadget/Gadgetbridge/commit/7ba3a874a2ca44fbb44f3124ec792ce447e583e5#diff-7b41eee18b20874f13531500f8e97ad4R659), and if they are related to something you entered or "standard". Please note that if you want to test by yourself, you can easily look for the byte sequence "activityPreferences" in the dumps after changing the settings in pebble app, and see how the bytes that follow it change, and relate the changes to what you entered. You don't have to tell us what you entered :)
Owner

Quick update: we managed (current master) to activate and deactivate Health properly.

With "properly" I mean that when Health is deactivated, no steps are recorded and the watch app shows the warning "You have to enable pebble health on your phone...". The collected data, however, is not deleted from the watch, as the pins that Health already put on the timeline.

So far I was unsuccessful in retrieving recorded data from the watch (possibly this and the deletion are related?).

Further, the activation is done using the @wngr dump but in order to get more accurate data, we would need to map the different options of the health app (sex, age, height, weight, if you want to be more active or sleep more, $more_fields_I_am_not_aware_of...) to the nine bytes that are sent to the pebble by the phone app, and for that we need more logs.

Quick update: we managed (current master) to activate and deactivate Health properly. With "properly" I mean that when Health is deactivated, no steps are recorded and the watch app shows the warning "You have to enable pebble health on your phone...". The collected data, however, is not deleted from the watch, as the pins that Health already put on the timeline. So far I was unsuccessful in retrieving recorded data from the watch (possibly this and the deletion are related?). Further, the activation is done using the @wngr dump but in order to get more accurate data, we would need to map the different options of the health app (sex, age, height, weight, if you want to be more active or sleep more, $more_fields_I_am_not_aware_of...) to the nine bytes that are sent to the pebble by the phone app, and for that we need more logs.
wngr commented 6 years ago (Migrated from github.com)
Poster
Owner

I will provide you with the requested data. Could take a couple of days for me, though.

On January 28, 2016 5:26:51 PM GMT+01:00, Daniele Gobbetti notifications@github.com wrote:

Quick update: we managed (current master) to activate and deactivate
Health properly.

With "properly" I mean that when Health is deactivated, no steps are
recorded and the watch app shows the warning "You have to enable pebble
health on your phone...". The collected data, however, is not deleted
from the watch, as the pins that Health already put on the timeline.

So far I was unsuccessful in retrieving recorded data from the watch
(possibly this and the deletion are related?).

Further, the activation is done using the @wngr dump but in order to
get more accurate data, we would need to map the different options of
the health app (sex, age, height, weight, if you want to be more active
or sleep more, $more_fields_I_am_not_aware_of...) to the nine bytes
that are sent to the pebble by the phone app, and for that we need more
logs.


Reply to this email directly or view it on GitHub:
https://github.com/Freeyourgadget/Gadgetbridge/issues/188#issuecomment-176262901

Sent from my Android device with K-9 Mail. Please excuse my brevity.

I will provide you with the requested data. Could take a couple of days for me, though. On January 28, 2016 5:26:51 PM GMT+01:00, Daniele Gobbetti notifications@github.com wrote: > Quick update: we managed (current master) to activate and deactivate > Health properly. > > With "properly" I mean that when Health is deactivated, no steps are > recorded and the watch app shows the warning "You have to enable pebble > health on your phone...". The collected data, however, is not deleted > from the watch, as the pins that Health already put on the timeline. > > So far I was unsuccessful in retrieving recorded data from the watch > (possibly this and the deletion are related?). > > Further, the activation is done using the @wngr dump but in order to > get more accurate data, we would need to map the different options of > the health app (sex, age, height, weight, if you want to be more active > or sleep more, $more_fields_I_am_not_aware_of...) to the nine bytes > that are sent to the pebble by the phone app, and for that we need more > logs. > > --- > > Reply to this email directly or view it on GitHub: > https://github.com/Freeyourgadget/Gadgetbridge/issues/188#issuecomment-176262901 ## Sent from my Android device with K-9 Mail. Please excuse my brevity.
Owner

Thanks @wngr!!! If we figure the details out somehow in some different way I'll update this issue.

Thanks @wngr!!! If we figure the details out somehow in some different way I'll update this issue.
Owner

@wngr I may be have found some details, can you confirm that when you saved your log you had set in the app:
height: 0, weigth: 0, tracking: 1, insights for activity: 0, insights for sleep: 0, age: 0, gender: other
?

@wngr I may be have found some details, can you confirm that when you saved your log you had set in the app: height: 0, weigth: 0, tracking: 1, insights for activity: 0, insights for sleep: 0, age: 0, gender: other ?
wngr commented 6 years ago (Migrated from github.com)
Poster
Owner

Yes, that seems correct as I didnt set anything except enabling Health.

On January 29, 2016 9:48:10 AM GMT+01:00, Daniele Gobbetti notifications@github.com wrote:

@wngr I may be have found some details, can you confirm that when you
saved your log you had set in the app:
height: 0, weigth: 0, tracking: 1, insights for activity: 0, insights
for sleep: 0, age: 0, gender: other
?


Reply to this email directly or view it on GitHub:
https://github.com/Freeyourgadget/Gadgetbridge/issues/188#issuecomment-176646868

Yes, that seems correct as I didnt set anything except enabling Health. On January 29, 2016 9:48:10 AM GMT+01:00, Daniele Gobbetti notifications@github.com wrote: > @wngr I may be have found some details, can you confirm that when you > saved your log you had set in the app: > height: 0, weigth: 0, tracking: 1, insights for activity: 0, insights > for sleep: 0, age: 0, gender: other > ? > > --- > > Reply to this email directly or view it on GitHub: > https://github.com/Freeyourgadget/Gadgetbridge/issues/188#issuecomment-176646868
Owner

@wngr thank! One more question: do you have to enter data in SI (metric) units or imperial? I ask because I'd like to give you some round numbers to enter and check if my hypothesis is correct. Internally, it looks like SI units are used.

@wngr thank! One more question: do you have to enter data in SI (metric) units or imperial? I ask because I'd like to give you some round numbers to enter and check if my hypothesis is correct. Internally, it looks like SI units are used.
Owner

Little progress report: It seems the data format I am using is correct, at least I have successfully activated the insights for sleep and activity. They are really really annoying BTW :)

Little progress report: It seems the data format I am using is correct, at least I have successfully activated the insights for sleep and activity. They are really really annoying BTW :)
Poster
Owner

Just another progress report: Health seems to make use of datalogging, we could isolite the used "tags" which seems to be at least 81 and 83. They only appear on Health supported Pebbles not on original ones.
The next step is to make sense of the data we get.

Just another progress report: Health seems to make use of datalogging, we could isolite the used "tags" which seems to be at least 81 and 83. They only appear on Health supported Pebbles not on original ones. The next step is to make sense of the data we get.
Owner

Current master is able to parse the steps data sent from the watch.
I am fairly confident also other data (intensity) is correct but there's a "hole" every 15 minutes, the steps data is complete, though.

If someone could test and report back I'd appreciate it very much.

P.S. The pebble sends data at bunches of ~15 minutes, and the watch decide when to send them, so it is likely that during the day the steps count in GB and on Pebble Health will be different.

Current master is able to parse the steps data sent from the watch. I am fairly confident also other data (intensity) is correct but there's a "hole" every 15 minutes, the steps data is complete, though. If someone could test and report back I'd appreciate it very much. P.S. The pebble sends data at bunches of ~15 minutes, and the watch decide when to send them, so it is likely that during the day the steps count in GB and on Pebble Health will be different.
wngr commented 6 years ago (Migrated from github.com)
Poster
Owner

I just checked in the Pebble Time app (firmware v3.9.1 was installed).
You can set the units on the respective dialogues for Height and Weight.

Should I check some values/unit combinations for you?

I installed the newest master and will get back to you with feedback.

I just checked in the Pebble Time app (firmware v3.9.1 was installed). You can set the units on the respective dialogues for Height and Weight. Should I check some values/unit combinations for you? ## I installed the newest master and will get back to you with feedback.
Poster
Owner

I assume that the APP will convert units before sending it to the watch for height and weight.

For distance it is needed since the watch actually displays it.
We have an idea how to send this preference to the watch, however I cannot test since I do not have the pebble time.

I assume that the APP will convert units before sending it to the watch for height and weight. For distance it is needed since the watch actually displays it. We have an idea how to send this preference to the watch, however I cannot test since I do not have the pebble time.
Owner

@wngr a double check is always welcome.

one option is that you for instance set 100kg, 100cm and gender female, and send us the packet. Another option is that you set the same values in gb and in pebble time, then compare the packets and see if they match, this way you don't have to send data around.

Consider that we are forcing insights for sleep and for activity off, because I find them annoying :)

@wngr a double check is always welcome. one option is that you for instance set 100kg, 100cm and gender female, and send us the packet. Another option is that you set the same values in gb and in pebble time, then compare the packets and see if they match, this way you don't have to send data around. Consider that we are forcing insights for sleep and for activity off, because I find them annoying :)
Owner

current master now sets the watch to show distances in kilometers (hopefully this doesn't break anything on fw < 3.9)

current master now sets the watch to show distances in kilometers (hopefully this doesn't break anything on fw < 3.9)
Poster
Owner

I think we will just get a blobdb error response in logcat on previous firmwares. Just as I get on aplite for the activityPreferences blobdb insert.

I think we will just get a blobdb error response in logcat on previous firmwares. Just as I get on aplite for the activityPreferences blobdb insert.
Owner

Progress report: I believe I'm starting to make sense of the sleep data, but there are no minutes data, we just get the beginning and end timestamps of "bed time", and a counter (I guess the deep sleep amount). So mapping these data to our model will not be trivial.

Progress report: I believe I'm starting to make sense of the sleep data, but there are no minutes data, we just get the beginning and end timestamps of "bed time", and a counter (I guess the deep sleep amount). So mapping these data to our model will not be trivial.
Owner

Progress report: current master is receiving sleep data as some of you may have noticed already. Unfortunately sometimes they may not be saved. I believe I fixed this issue locally and will push the fix tomorrow if everything works tomorrow morning.

The deep sleep data will unfortunately be trashed, because we don't get enough information to store them. I see no way around this but I am open to suggestions.

Progress report: current master is receiving sleep data as some of you may have noticed already. Unfortunately sometimes they may not be saved. I believe I fixed this issue locally and will push the fix tomorrow if everything works tomorrow morning. The deep sleep data will unfortunately be trashed, because we don't get enough information to store them. I see no way around this but I am open to suggestions.
Owner

The workaround works :) I'll push it later today and then I guess we can close this issue. The only thing that is still missing is deep sleep data, but I don't see how that could be fixed.

The workaround works :) I'll push it later today and then I guess we can close this issue. The only thing that is still missing is deep sleep data, but I don't see how that could be fixed.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.