Search code examples
androidapibluetooth-lowenergysonygoogle-fit

Unable to retrieve STEP_COUNT via my app from Sony Smartband2


This is not a repeated question as all other questions either refer to the REST Api or retrieve step count from the device (usually the phone) on which the app is running. It is also different from android wear questions, as no separate app can be built for the Smartband2.

I want to retrieve the heart rate and the step count. I am successfully able to get the heart-rate via the BLE Api

However, for the step-count I've been having a lot of trouble. I understand that the best way to get the step-count is through Google Fit APIs. I tried using the Sensor Api, but only my phone on which the app is running gets listed as a Data Source. On using the Google fit BLE Api ,the band gets detected only when I search for TYPE_HEART_RATE_BPM, but not when TYPE_STEP_COUNT_CUMULATIVE or TYPE_STEP_COUNT_DELTA

From the comment by noogui here, I understand I'll have to use the Recording and History Api.

On the other hand, there's an option to create Additional Sensorfrom similar questions posted earlier.

I'm utterly confused as how to go about this now.

TLDR: Could someone please list out the steps and the APIs I will need to get step-count data from Smartband2? An example would be very helpful.


Solution

  • I was able to get the heart-rate and step-count data using the following method:

    1. Pair the Smartband2 with the official Sony Smartband2 app.
    2. In the app: settings -> Google fit -> Turn on
    3. Write an app that uses the History api from Google Fit. Example: https://github.com/googlesamples/android-fit/tree/master/BasicHistoryApi
    4. Fetch data for every minute for last ten minutes for Heart-rate and step-count

    No Ble api or other additional raw sensor creation was required.