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

  • ...Really sorry.. I had previously found the link to the .hex firmware file in a different thread.  And that part is awesome.  But do you have insights on how to flash that .hex file through the usb and onto the NRF 52840 dongle?  I can't find anything on the programmers guide other than older BLE connection stuff.  I am really struggling to find any useful link in the Garmin universe (other than your stuff).  Sorry (Again) and Thanks!

  • Look in the CIQ programmer's guide.  You do it using RF Connect for the desktop.  After you do the flash, if I recall, you want to unplug it and plug it back in to restart the dongle. 

  • Thanks!  Found it.   Downloaded it.  Uploaded the .hex file.  Still no love.  I'll keep plugging.  

  • You use the programmer in nRF Connect Desktop.  Once you do that, do not try to load anything else like the general tool for BLE, as that will wipe out what's needed for CIQ.  Check the comm port after you flashed the dongle and unplugged it and plugged it back in.  What happens when you try to set the comm port for BLE in settings?

  • ITS WORKING!!!  Thanks!

    The following workflow worked for my Macbook pro 64-bit Catalina USB-C:

    • place fresh dongle in USB adapter.  
    • press reset (It's not the big button-- it's a little button on the side)
    • wait for light to flash.
    • Upload connectivity_1.0.0_usb_with_s132_5.1.0.hex using the nRF downloaded from Nordic
    • Unplug dongle
    • Replug dongle.
    • Make sure light is not flashing.
    • From Settings-> BLE Settings, Connect to /dev/tty.usbmodemF4D9B5EF08912.
      • the port is enumerated from terminal using: ls /dev/{tty,cu}.*
    • Watch the magic!
  • This is handy..  Converts a two byte UUID to long form

    private function wordToUuid(uuid)
    	{
    		
    		return Ble.longToUuid(0x0000000000001000l + ((uuid & 0xffff).toLong() << 32), 0x800000805f9b34fbl);
    	}
        
        
    	public const FITNESS_MACHINE_SERVICE 	   = wordToUuid(0x1826);
    	public const TREADMILL_DATA_CHARACTERISTIC = wordToUuid(0x2acd);

  • It works well.  I still want to simplify BLE implementation from the high-level user side.  And having the simulator (finally) working will speed up cycle-time.  In the meantime, I'm going running.  WHOOT!!    

    CIQ Simulator

    Mets and KCAL are close, and only exist as placeholders now.   I need to confirm that they are getting sent correctly from the Server.

  • The treadmill can now be controlled from the watch using the fitness equipment control-point characteristic.  Whoot!!!!  But, other than a proof of concept, it's not really all that useful.  (The treadmill buttons are a lot easier to get to and thereby control...). 

    What if I coupled the watch's accelerometer to treadmill speed.  E.G.  When the watch detects a faster cadence, it speeds up.  And a slower cadence slows down.   Hmmmmmmm???!!!???

    So...  Is it possible to access fitness fields like cadence (or HR) from an app?

    Also... is it possible to parse a planned-workout and set the treadmill accordingly?  Then, things will suddenly get super cool.  What resources exist to read-in planned workout files?

    Thanks As Always