Developing a CIQ BLE Client for Treadmill and Fitness Equipment

I want to run on my smart treadmill and get EXACT speed and grade information via BLE.  Previously, I created an Arduino ESP-32 solution running as a BLE server that runs on the treadmill.  This server works well with Zwift etc, so I know it works.  Now the plan is to create a CLIENT on my fenix-5.  Eventually, I want to save and thereafter load my treadmill runs into Strava.  In the far away future, I would like to control my treadmill from the fenix-5 (using watch buttons to speed-up, tilt up etc) .  In the far,far,far away future, I would like to automatically adjust treadmill speed and grade based on complicated pre-planned-workouts (intervals, hill repeat etc).

REFERENCE INFO

GATT SERVICES

Plan to read data from:

  • Fitness Machine Service UUID: 0x1826
    • Fitness Machine Feature Characteristic 0x2acc 
    • Treadmill Data Characteristic 0x2acd
      • 2902 Enable Notify Descriptor 0x2902
        • This is required so client gets more than one data point.
    • Supported Speed Range Characteristic 0x2ad4
    • Supported Incline Range Characteristic 0x2ad5
  • Keep Alive UUID

Long Form "standard" UUIDs take the form of 

xxxxxxxx-0000-1000-8000-00805F9B34FB
where xxxxxxxx is the zero-padded short-form uuid (see above)
E.G. Fitness Machine Service long UUID would be 00001826-0000-1000-8000-00805F9B34FB

  • if you do a recording device app, you have access to a whole bunch of info - cadence and HR are just a couple.  See Activity.Info

    As far as a workout, you need to find a way to define it yourself (maybe by way of menus in your app or having your app download it from some place in your own format)

  • My goal is to do this with the fenix 5 (not the plus model).

    I notice that there is a beta firmware for fenix 5 which shows sdk v3.1 support.

    https://www8.garmin.com/support/download_details.jsp?id=11663

    The current SDK 3.1.6 will not build for the fenix 5 with sdk v3.1 indicating it is not supported.

    If they finalize the firmware release, and release a new SDK supporting this combination, is there any other reason like a hardware limitation that would prevent using fenix 5 with Toybox,BluetoothLowEnergy?

    I am presuming that this might occur fairly soon as new SDK have been coming fairly rapidly.

  • Not all devices with CIQ 3.1.x will support BLE from CIQ,

    See this blog post for the list of devices that will have BLE support.

    https://forums.garmin.com/developer/connect-iq/b/news-announcements/posts/connect-iq-3-1-connects-you-to-the-world

    There are some devices with BLE not on that list, like the fenix 6, but the blog post if from before they were announced.

    There is some reason that the fenix 5 won't get this functionality, but not sure what that reason is.

  • The App is completed!  It works really well-- I'll post some screen shots when I get back to the "lab".  I added a Fartlek screen, that automatically adjusts the treadmill's speed and incline to different combinations of speed and grade.  One combination-- for a hard interval and the second combination, for a rest interval.  When the user presses the "back" button, the treadmill automatically adjusts both speed and grade.  This saves a lot of treadmill button-presses,---- especially when running high-intensity intervals.  The settings persist with SetValue / GetValue.  I used this app last evening.  Now, I wish my running worked as well as the app did. I'll post the code on Github this evening.

    Of note, I combined View/Delegate class-pairs into common files for easier debugging.  I also combined all the BLE stuff into a single file, for portability / readability.

  • Great!

    Did you find the dongle helped with getting the app working? I know for me, it really helped to speed up development and debugging.

  •  Oh yea!  It was awesome.  Thanks for the advice!!  Now, configuring the dongle on the MAC was a little more different  than selecting COM1, COM2 etc like on a PC...  But once it was configured, it worked very, very well.  I had my ESP32 attached via a second serial-USB cable so I could debug BLE read/write/notify events in real-time using the same system.  This improved cycle-time by several orders of magnitude.  I could thereby improve what, would have been a proof-of-concept app, and make it user friendly(ish).  If anybody has a commercial treadmill that can accept GATT BLE control point characteristic read-write-events (E.G.  Control the thing remotely), let me know.  I would love to see if this app works on something besides mine.  The picture is the watch configured in FARTLEK mode.  This allows a rapid speed/Incline switch by pressing the back button.  It's good for Tabata intervals when you don't wanna get carpal tunnel from pressing the treadmill buttons.

  • The App works well and can now upload data to Garmin Connect.  The problem is that speed, grade, elevation and distance are represented as custom fields and not "real speed", for example  Do you know how to "overwrite" the device's speed (it think it's zero) field with the speed coming-in from the Treadmill (or other device)?  I have tried copying field names and units but, sadly, no luck.

  • Sorry, there's no way to do that for Garmin Connect.  It's been an issue since adding user data to a .fit became possible.