Web Requests without Mobile Connect

Former Member
Former Member
Hello,

I am looking to develop a widget for the tactix Bravo and was researching requests to various API's, and I had questions related to the communications in the API.
If a watch is connected to the WiFi but not to a phone via Garmin Connect Mobile, can it still utilize communications with the web with HTTP requests? This seems like a given, however all of the documentation references using the communications class AND having a connection to a phone through bluetooth, never seperately. I would like to know before I continue, this is not a scenario in which a phone will be easily accessible.

Thanks!
  • Former Member
    Former Member over 8 years ago
    No, the Connect IQ Communications module requires a connection to a phone. Garmin Connect Mobile does a significant amount of "heavy lifting" for the device to enable web communication. It is not possible to do Connect IQ communication directly via WiFi.
  • At the risk of being accused of torturing Brian's metaphor, I would add that in doing the "heavy lifting" GCM does a) sometimes damage the load and b) work to some very strict rules.

    "Damaging the load:"
    Unless everything is perfect, the transfer fails and the values in response code are not documented and, as I have discovered, are not HTTP response codes.

    I did some investigation into the range of response codes with the iOS phone. ( Unfortunately my Android broke so I don't have its results, but I expect they will be different.)
    In each case I monitored the response to System.getDeviceSettings().phoneConnected ("Phone Connected" column) and monitored the response code from Comm.makeWebRequest from my web site with the phone in various states.
    Here are my results


    [table="width: 500"]
    [tr]
    [td]Operation[/td]
    [td]Phone connected?[/td]
    [td]Response code[/td]
    [/tr]
    [tr]
    [td]GCM "Remove device"[/td]
    [td]TRUE [/td]
    [td]-101/ -2[/td]
    [/tr]
    [tr]
    [td]GCM Close[/td]
    [td] FALSE[/td]
    [td]-104[/td]
    [/tr]
    [tr]
    [td]Restart phone (GCM not running)[/td]
    [td]FALSE[/td]
    [td]-101[/td]
    [/tr]
    [tr]
    [td]Disable phone Bluetooth[/td]
    [td]FALSE [/td]
    [td] -101[/td]
    [/tr]
    [tr]
    [td]Disable Wifi/Data on phone[/td]
    [td]TRUE [/td]
    [td]-300[/td]
    [/tr]
    [/table]


    "Very strict rules"

    Here are a few restrictions on makeWebRequest that I have found inconvenient:

    • it will only retrieve JSON, FIT or GPX data - it won't retrieve text.
    • It does not honor cookies, so it's not possible to use cookies to save state data
    • Because of the cookies restriction above, it can not not maintain a SESSION with the host, so credentials have to be passed each time
    • Numbers in a JSON response have to be quoted. "myNumber": 1.23 causes havoc, it requires "myNumber": "1.23"


    I just thought I would share my results with the Forum.
  • Former Member
    Former Member over 8 years ago
    the values in response code are not documented


    The negative return codes you have listed are documented.

    https://developer.garmin.com/downloads/connect-iq/monkey-c/doc/Toybox/Communications.html
  • As a note, Brian posted the online doc for 2.2.x, and the doc in the 2.3.0.beta1 includes a new one. (-1001 is "SECURE_CONNECTION_REQUIRED"), as you need to use https instead of http (thanks to Apple...)

    I'm not sure if it's generated by the VM or phone, but many of the 2.x devices now have the 2.3.1 VM.
  • The negative return codes you have listed are documented.


    D'OH. Head slap!:mad:
  • Hi Brian, I've a question.

    What happens with the request if you're so far from your phone? Does it send when it's available or just fails?



    Thanks in advance,

  • If there's no phone connected, you get BLE_CONNECTION_UNAVAILABLE (-104) right away.

  • understood!

    thanks, Jim