This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

post a FIT file

Former Member
Former Member
The goal I have is to send the FIT data of dismissed hospital patients from their Garmin to the department server for analysis
Could you please provide a hint about a makeWebRequest (or other useful API) for sending a FIT file from the Garmin device to the server's site, please?
I'm new to Garmin and in the doc/Toybox/Communications.html I see only the REQUEST_CONTENT_TYPE_URL_ENCODED and the REQUEST_CONTENT_TYPE_JSON options, which I presume won't fit the .FIT file which is binary if I'm not wrong.
Thanks
  • Former Member
    0 Former Member
    Garmin Connect API is needed for this, isn't it? We can't send the data from device to server by ourselves, or can we?
    I've found https://forums.garmin.com/forum/developers/connect-iq/101606-how-to-access-fit-data-or-activity-detail saying an app has to store its own data by itself in order to use them, it can't access FIT files.
  • I'm confused as to whether you want to retrieve FIT files from a Garmin device and upload them to the device owner's Garmin Connect account (and why would you want to do that, when it is usually already done automatically upon syncing the device?), or to a third-party server somewhere.

    When you connect the Garmin device by USB cable, (with the correct device settings) the device will present to the connected PC or Mac as a mass storage device, from which FIT files can then be retrieved and copied to the computer. The PC or Mac can then do whatever with its copies of the FIT files, including send them over the network to “the department server” by whichever protocol. I don't see why the Garmin Connect API would be required just to achieve that much.

    Full automation of such a process would of course be a bit more complicated, but in the simplest case, the dismissed hospital patients can be trained to follow a reasonably easy (but relatively labour-intensive and possibly error-prone) procedure for physically connecting the device, copying the FIT files, then uploading them somehow. If the exercise is valuable to their health, I'm sure they'll learn and manage such a task just fine.
  • Former Member
    0 Former Member
    Thank you very much ASmugDill for answering

    I meant to a third-party server at the hospital

    Patients will have to follow the easiest possible procedure to have their data sent to the hospital server

    So I've understood that our app will have to both record the data and then later send them to the server

    I've found https://developer.garmin.com/connect-iq/programmers-guide/resource-compiler/#datastorage
    provides advice.
    I think I will use the Toybox::Application::Storage to keep the data during the day, as documentation says that storage persists after the application is closed, doesn't it?
    As for memory limits documentation says: "Keys and values are limited to 8 KB each, and a total of 128 KB of storage is available."
    Then at evening the patients will launch the app again for uploading data: it will getValue each data and send it as jSON to the server, with a makeWebRequest call.

    Does this make sense? To use the Application::Storage to keep the data in place of the FIT file?

    The alternative that came to my mind, for instance in case storage limits could arise or any kind of difficulty or further necessities, was to ask for either the Health API or the Garmin Connect API, simply instruct the patients to sync their device, and let the hospital server ask the data to Garmin center itself.