registerForPhoneAppMessages

Hi all,

out of frustration from the missing documentation, I'm posting here what I found about the usage of the new CIQ BLE communication method.

The example usage is:

function onStart(state) {
Comm.registerForPhoneAppMessages(method(:onMsg));
}

function onMsg(message) { // the object received should be a PhoneAppMessage, which is undocumented, but inherits from Message
handleData(message.data.toString());
}


You can set up both the old Mailbox listener and this callback, in that case only registerForPhoneAppMessages will be used.
  • Is this method is usable with every latest devices firmware ?

    I'm using an application build upon latest SDK and my Vivoactive HR, running v3.30 doesnt start the app because of this method :

    ERROR: Symbol Not Found Error
    DETAILS: Could not find symbol registerForPhoneAppMessages.
    STORE_ID: 00000000000000000000000000000000
    CALLSTACK:
    source/SleepApp.mc (onStart:110)
  • While registerForPhoneAppMessages() isn't documented, the Comm example that ships with the 2.2.2 and later SDK shows exactly how to use it, and how to use it with setMailboxListener() in a single application.

    As for why you can't access it on the vivoactive_hr right now, it appears (by looking at ${SDKROOT}/bin/api.debug.xml) that registerForPhoneAppMessages() was is available to devices that have ConnectIQ 1.4 (for version 1 devices) or 2.2 support (for version 2 devices). The latest version of the vivoactive_hr firmware (version 3.30) supports ConnectIQ 2.1.

    Travis
  • Thanks guys,

    didn't know about the Comm example being changed.
    jim_m_58 is exactly right -- for the VAHR, the 1.4/2.2 SDK is currently supported only in the beta FW, scheduled to ship stable next week (I've been told).

    Jiri
  • Former Member
    Former Member over 8 years ago
    According to this announcement, the vivoactive HR should now support ConnectIQ 2.2.

    https://forums.garmin.com/showthread.php?368648-vivoactive-HR-firmware-version-3-40-is-available!

    Unfortunately, I can't find a way to take advantage of it yet using the 2.2.3 SDK (installed via the SDK manager). When I select 2.2 as the minimum SDK version for my project, it greys out the vivoactive HR option under the Target Platforms.

    This is pretty frustrating, since my device is on v3.40 and the deprecated mailbox functionality causes "System Error" for Comm.emptyMailbox() and "Out of Memory" for iterator.next(). Due to the above issue I can no longer send messages to my watch-app from my phone app. :(

    Is there a way to enable the vivoactive HR as a target platform for 2.2?
  • SDK and VM versions aren't always in sync. And there are times where some users may have a device with a 2.1.x VM while others with the same devices, could have a 2.2.x VM (it depends on if the FW upgrade was installed in some cases)

    To handle that, you can use "has" so at runtime on the device, it can see if something is available or not, and once a user gets the new FW, the app still runs but can use the new feature.

    I for one, have nothing where I modify the minimum FW for any project or device, and just use "has" to see if there's something I can't use.

    This is also the case where you want to use something like ActMon.getHeartrateHistory() - it's available on devices with WHR, but not on those that don't. With "has", the same code will run on both types, but only show HR on devices with WHR, for example.

    "has" is a nice thing with multiple devices and multiple versions of FW for a given device. You want to use it a bit sparingly, as it's not a really cheap operation (there is a bit of checking for things that occurs). So when an app starts, you may want to do all your "has" checks and set a boolean vs doing the "has" in each onUpdate() for example.
  • Former Member
    Former Member over 8 years ago
    Thanks jim_m_58 for the insights on the usage of "has". I'll definitely take that into account in my development moving forward.

    Unfortunately, it wouldn't do anything to address my current predicament. Neither messaging APIs work. The SDK doesn't allow me to build an app targetting the 2.2.x version for the device. If I do try to make that call anyway, I get this in CIQ_LOG.TXT:
    ERROR: Symbol Not Found Error
    DETAILS: Could not find symbol registerForPhoneAppMessages.
    STORE_ID: 00000000000000000000000000000000
    CALLSTACK:
    <snip>\source\MyApp.mc (initialize:22)


    If I try to use the Mailbox API, say by calling Communications.emptyMailbox(), I get the following:
    ERROR: System Error
    DETAILS: Failed invoking <symbol>
    STORE_ID: 00000000000000000000000000000000
    CALLSTACK:
    <snip>\source\MyApp.mc (initialize:22)


    So I'm in kind of a pickle at the moment. I'm not sure how any vivoactive HR apps that depend on the direct messaging support are expected to work once they upgrade to the 3.40 firmware, or even be updated to adapt to the new API since the SDK actively prevents building to that API for this device. Perhaps the System Error above is due to something other than the Mailbox deprecation, but I have no idea what it would be.
  • The code shown a few post backs assumes you have

    using Toybox.Communications as Comm;

    in your code. If you don't, you will get the symbol not found error. Could that be it?