Health Tracking additions

Posted on
  • As part of the Bangle.js 2 launch I intend to make health tracking more of a first-class part of Bangle.js.

    We'll have a health app which will store health data every 10 minutes, all day, every day for the last year - it'll also draw graphs and stuff.

    I'm planning on storing: steps, heart rate (if enabled) and movement (for sleep tracking). Is there anything else? GPS traces/etc can be stored separately.

    I'm adding movement tracking inside the firmware, but it does raise a question about how to do it in the most friendly way. We've had a longstanding issue that the step counter is 'steps since Bangle.js started' and apps like pedometers have to do their own work to calculate steps per day.

    While I can add Bangle.setSteps/etc functions so steps can be reset at the beginning of the day, when you're also measuring steps for the logging and maybe also an exercise session you don't want the step count randomly reset in the middle. You also don't want to lose health info if you change apps.

    So I'm thinking of adding a health event once per minute, that updates with health stats (eg steps, movement) over that minute (and the ability to query health stats for what has happened during the minute). That way apps can hook onto that event and nothing is treading on anything else's toes.

    Any thoughts? Does that sound sensible?

  • This is great news and I m looking forward to see how it goes next! do you think of developing this health with the collaboration of gadgetbridge?

  • Maybe too different, but just came up when reading this, so what about

    • Emergency Contact
    • Important Medication
    • Allergies
  • If the watch is going to be used to track health stats then it sounds very sensible to do this in the firmware rather than with separate apps.

  • This is great news and I m looking forward to see how it goes next! do you think of developing this health with the collaboration of gadgetbridge?

    Would make more sense to do this with the Bangle.js app that we're getting very close to becoming a reality (at this rate the KS campaign should hit 80k within a day or two).

  • do you think of developing this health with the collaboration of gadgetbridge?

    The idea of storing the data is it'll connect pretty well with what Gadgetbridge is currently able to record. Gadgetbridge has a way of requesting data from when the watch has been 'offline' so it should fit in well.

    Thinking about Gadgetbridge, maybe we should store 'activity type'. As I understand it, this is mostly something users input manually, but then you can at least see it in Gadgetbridge graphs. It always seemed a bit pointless to me though - does anyone use it?

    Emergency Contact, Important Medication, Allergies

    I think these can just be a separate app? It's a good idea though.

    Really my question is about how we expose the data so it can be used easily by other apps on the watch.

    Would make more sense to do this with the Bangle.js app that we're getting very close to becoming a reality

    Yes, that's the plan really - but seeing how Gadgetbridge does it is a good start I guess

  • Thinking about Gadgetbridge, maybe we should store 'activity type'. As I understand it, this is mostly something users input manually, but then you can at least see it in Gadgetbridge graphs. It always seemed a bit pointless to me though - does anyone use it?

    From my experience, for the moment, the activity data retrieved by GadgetBridge from the Bangle is false (recordings of several thousand kilometers in a few minutes without moving from my chair or bed, unrecognized sleep, unrecorded heart activity , ...)
    I do know, however, that it works quite well with the list of watches supported by GadgetBridge.

  • So I'm thinking of adding a health event once per minute

    Sounds a good idea.

    Bangle.setSteps/etc

    Not so keen on that. It means an App could reset the step count for the day.

    We've had a longstanding issue that the step counter is 'steps since Bangle.js started' and
    apps like pedometers have to do their own work to calculate steps per day.

    Could the firmware not manage the reset at midnight as per current locale setting ?

    Apps would be much simpler if we could just do Bangle.getSteps() rather than have to manage a listenner.

  • So I'm thinking of adding a health event once per minute, that updates with health stats (eg steps, movement) over that minute (and the ability to query health stats for what has happened during the minute). That way apps can hook onto that event and nothing is treading on anything else's toes.

    Won't this drain a lot of battery?

    Could the firmware not manage the reset at midnight as per current locale setting ?
    Apps would be much simpler if we could just do Bangle.getSteps() rather than have to manage a >listenner.

    This seems like a complex problem. And this is my first time thinking about it, but maybe this could work:

    From my understanding the midnight reset becomes an issue only when some app is counting steps during a reset. What if apps that rely on step counting had a way to tell the firmware they are still counting? Specifically, if an app is counting steps, it would have to write "1" (or a timestamp, or even just the equivalent of GNU touch) to a .keepalive file. At midnight, the firmware only resets steps if the .keepalive file was modified more than 1 minute ago, otherwise, delay the reset for 5 minutes. Unless there is a better way to determine whether any app is accessing the step count?

    Another alternative would be to have the firmware write the step count to 2 files/variables at the same time. These files/vars would be named with the date (ddmmyyyy or similar, just something that changes every day in a predictable manner), and steps always get added to both "today" and "yesterday". Apps that read steps define on startup from which variable they are reading the step counts. Firmware step reset only deletes the file/variable "2 days ago".

    I would think both these approaches are less resource intensive than polling every minute (which will not only make apps more complicated, but also report the step information with a 1min delay).

    I have never done embedded development before, so these ideas might just be dumb/naive, but I thought they could maybe be helpful. Don't be afraid to tell me how dumb they are, if that is the case. =-)

  • Won't this drain a lot of battery?

    Not really - once a second it would have an impact for sure, but adding maybe 1ms worth of extra power draw every 60 seconds should be pretty minor.

    Could the firmware not manage the reset at midnight as per current locale setting ?

    It could do, but what if you're doing exercise over midnight? The app would have to be aware that the step count will reset to 0 mid-exercise. Although I guess in that case it should just be using the step event and counting itself...

    I'm thinking that the best option for steps is to have a health library provided by the health application that provides the step count for the day, and the goal, and also has some functionality for grabbing historical data too

  • Sometimes the step count is lost (after a reboot/upgrade). Would it be possible to reset the step count manually using the Custom Boot Code app? Maybe using Bangle.setSteps?

  • Sometimes the step count is lost (after a reboot/upgrade)

    There is a Bangle.setStepCount function but nobody uses getSteps - they generally use Bangle.getHealthStatus("day") and I'm afraid there is no way to set that at the moment.

    Potentially this could be added and then the health app could try and figure out what the current day's step count was at boot time.

    ... but hopefully full reboots are so rare this isn't a big issue.

    And even when it does happen, then step counter may show the wrong step count, but if you go into the health app you'll see that all the steps are still recorded for the day

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Health Tracking additions

Posted by Avatar for Gordon @Gordon

Actions