.NET Application For Activity Upload
dee4life2005
Posts: 773
Hopefully someone here can help with this (apologies if this is the wrong forum section).
I'm trying to extend my knowledge of the C# language, and decided I'd try to write myself a windows application that takes my Garmin 500 .FIT files ... parses the data and then uploads the ride data to Runkeeper / Strava / Garmin Connect - mainly because I'm lazy and can't be bothered to manually do it for every ride.
Anyway, I've managed the FIT file parsing, displaying google route map and charts, as well as uploading the data to runkeeper (that was actually quite easy). As for Strava, I came across the STRAVAN .net library (https://github.com/KristopherGBaker/Stravan) but am having a little difficulty working out how to perform the authentication of the user details. This library only uses V1 and V2 of their API, which I can't find documentation for - perhaps I'd be better waiting for V3 of their API with the full OAUTH/REST stuff ?
Anyone used this library ? Any pointers ?
Ta.
I'm trying to extend my knowledge of the C# language, and decided I'd try to write myself a windows application that takes my Garmin 500 .FIT files ... parses the data and then uploads the ride data to Runkeeper / Strava / Garmin Connect - mainly because I'm lazy and can't be bothered to manually do it for every ride.
Anyway, I've managed the FIT file parsing, displaying google route map and charts, as well as uploading the data to runkeeper (that was actually quite easy). As for Strava, I came across the STRAVAN .net library (https://github.com/KristopherGBaker/Stravan) but am having a little difficulty working out how to perform the authentication of the user details. This library only uses V1 and V2 of their API, which I can't find documentation for - perhaps I'd be better waiting for V3 of their API with the full OAUTH/REST stuff ?
Anyone used this library ? Any pointers ?
Ta.
0
Comments
-
- I was looking at some json parsing and came across some sample code
this was a link I followed
https://www.strava.com/api/v2/authentication/login
but it seems to have been discontinued.The dissenter is every human being at those moments of his life when he resigns
momentarily from the herd and thinks for himself.0 -
A quick butchers at the developers section on Strava seems to imply they're working on a new public API and would rather everyone just buggered off in the meantime. Personally, I'd leave it until Strava have actually published whatever it is they're working on, otherwise you'll just end up redoing it all when they do.Mangeur0
-
Thanks. I've managed to get it to work. Seems I was missing a couple of settings in the app.config file (doh!), causing it to throw some exceptions. It's now successfully retrieving ride/segment details etc.
I had seen strava were working on V3 of their API (and that V1 and V2 were deprecated). V3 does sound like it'll be good, once they get around to releasing it0 -
Excellent stuff Sounds like a rather fun\handy personal project, does that.Mangeur0
-
Thanks, I'm really enjoying working on it in my spare time :-)
I've now got it parsing .FIT / .TCX / .GPX files, displaying a google map of the route with mile markers, and charts of the altitude / heart rate / cadence / speed information. It'll also allow you to connect the application with Runkeeper / Strava / Endomondo / Garmin Connect and RideWithGPS and upload to them all with the press of one button (except Endomondo, can't get it to work for them yet). I've also built in a basic profile viewer for each provider that shows your ride history, and in some cases will give stats and ability to click-through to view the ride selected.
It's still got a few bugs - mostly things like HTTP timeout handling etc., and there are a few features I'd still like to add - like a batch upload for when folks are migrating to a new provider, metric / statute measurements (fixed as miles/feet at the moment). I've given it to a few colleagues for beta testing, as I've noticed some differences within .TCX and .GPX files and I want to try and cater for all the subtle differences within these files produced by different devices. At the moment it should work for Gamin (tested only with an edge 500), Bryton and Mio Cyclo. If I can get my hands on sample files from other devices I'd be able to check if they're support and, if not then see if I can make the necessary adjustments.
If no show-stopper bugs are found I`ll consider sticking it up on t'internet for anyone that's interested.0 -
Sounds like bloody good progress there. It's always rather cool when a personal spare time project actually turns into something useful. The GPS and TCX stuff sounds potentially unpleasant, although that statement's probably more down to my personal fear of XML*.
* XML clearly isn't inherently scary. Used sensibly, it's quite nice, in fact. However, extension without the absolute need to document can end up, in my experience anyway, with far to much "and WTF is that, exactly?" data in there over time. If something can be freely used as a dumping ground, it inevitably is.Mangeur0 -
The processing of .FIT files was the easiest, although this was because it's a binary file format and someone had kindly already written a library for doing it - and made it open source. I like XML myself, other than the bloat it adds, but agree that people adding extensions without documenting ... grrrr.
The .TCX / .GPX files were indeed a little more problematic, although this wasn't help with there being multiple versions of the specs (e.g. TCX v1, TCX v2) and different providers having a slightly different take on how to store the data within them.
e.g. For Cadence,
Mio Cycle GPX has it wrapped in "<Extensions><Cadence>123</Cadence></Extensions>"
whereas everyone seems to use "<extensions><{namespace_prefix}:TrackPointExtensions><{namespace_prefix}:cad>123</{namespace_prefix}:cad></{namespace_prefix}:TrackPointExtensions>"
Similarly for .TCX files, but it only seems to be .TCX files generated by TrainerRoad that are slightly different.0 -
At least it's structurally fairly similar, so not to special-casey to get round. Is there any versioning info at the start of said files, or is it a case of sniffing?Mangeur0
-
There is various namespace and extension schema urls defined in one of the root tags. With a bit of sniffing of the content of said tag it's possible to determine which schema version the .TCX file is based on (and possibly .GPX too). This means we know what tags the file should contain, which makes parsing it much much easier.
e.g. from a Garmin .TCX (from Garmin Training Centre)
<TrainingCenterDatabase xmlns="http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.garmin.com/xmlschemas/ActivityExtension/v2 http://www.garmin.com/xmlschemas/Activi ... sionv2.xsd http://www.garmin.com/xmlschemas/FatCalories/v1 http://www.garmin.com/xmlschemas/fatcal ... sionv1.xsd http://www.garmin.com/xmlschemas/Traini ... atabase/v2 http://www.garmin.com/xmlschemas/Traini ... basev2.xsd">0 -
Sounds really useful actually - would you like a sample GPX file from Cyclemeter on the iPhone to look at? Garmin Connect doesn't always like those for some reason.0
-
Step_7 wrote:Sounds really useful actually - would you like a sample GPX file from Cyclemeter on the iPhone to look at? Garmin Connect doesn't always like those for some reason.
PM Sent.0 -
This sounds exactly like something I want to do, have you got the source code available?
It you can share the code would be greatly appreciated0