System.Stats.batteryInDays is null

I try to test System.Stats.batteryInDays in the sim with vivoactive 4 device - although the sim is set to have a value of 5 it returns null - is the sim not working yet with the new Connect IQ System 5? Docs are not saying anything about a possible null value either...

SIM, devices are up to date...

  • It's actually quite different.  In this case, "batteryInDays" exists (passes the 'has' test), but has a null value on some deices.

    While you're not passing the has test with a 245.  System 5 APIS work for me with a fr245 target.  When you get new devices or a new SDK, be sure to close the sim, and to be safe, restart VS Code or eclipse.

  • Yes, as you say it, the has: test is passed and the sim device got a CIQ5 update but it returns null... Does this mean its a sim bug? Or is it a CIQ5 problem and will be the same on a real device as well?

    Btw, I already tried restarting the SIM and VSCode but this did not change anything in this case. Simulating data (I'm always unsure what all is influenced by it like e.g. pressure) does not have any effect either

  • If you try the venu2, it works and returns a non-null value in the sim.  I'd suspect this is an issue with specific device config,  (the stuff in the devices folder) and but maybe the sim.

    You can build a sideload and see if it works on a real device

  • Ok, I tried sideloads on a couple of devices.  I see days on an Instinct2, and null on a fr245.

    What I'm starting to think is this may be a documentation issue vs devices or sim.

    On the I2, you can see battery in days in the native fw, but on the 245. you can't.

    So what I've thinking is the null value means battery in days isn't available, and the doc should mention this.

    The has check works on both devices, it's just that on the fr245 a value isn't available, while it is on the Instinct 2.

  • It's hard to test real devices as I only own one device... But thanks for testing and for your feedback, that's good to know. I will test with the venu2 for now.

  • The batteryInDays field should only be available to devices with 3.3.0 or later SDK support that also have the battery in days feature enabled. I'm trying to avoid saying exactly which devices will support it since they may not have released compatible firmware.

    There was a typographical error that resulted in it being null in some cases where support is not currently enabled. I know this affected the simulated vivoactive4/s devices, but it may have affected more. I do not believe that this issue ever made it into public device firmware, but I could be wrong.

    I believe we will be pushing out simulated device updates soon. Hopefully that will fix the issue there.

    The value should either not be present (a has check returns false), or should be a Float, but it is not a bad idea to add a null check just in case.

  • On a real fr245, with CIQ 3.3.x, the "has" check is true, but I see null for batteryInDays.  It's not just the sim. 

  • Ugh. Well, to be safe you're going to have to write a lengthy check

    if (stats has :batteryInDays) {
        // probably supported
    
        // this check is necessary to work around WERETECH-12398 which caused
        // some devices that don't have support to pass the has check and give
        // a null
        if (stats.batteryInDays != null) {
            // really supported
        }
    }

  • I have similar code in my test app already.  A few posts back I indicated it was null on the fr245 and a float on the instinct 2.