Sensors and Recording (Expected or Bug)

Hi,

Can anybody confirm what happens (on all or some devices) when you are listening to Sensor's and Start and Stop Recording?

Using the latest Simulator, it appears to work fine, in the current app keeps getting Sensor events once recording is started. However on my physical device (Vivoactive), it stops getting Sensor events and the Recording never starts?

Any ideas?

Cheers
Chris
  • 1) DataField or App?
    2) Are you calling session start on it?
    3) What sensors are you requesting for access? HR? or something else?

    typically, when you request for the sensor, it will get enabled and you will get the data output (without user invervention)

    More details of your predicament would help
  • Sorry, maybe I didn't provide enough detail.

    I have an App, which provides data on your Heart Rate. This currently uses the Sensor implementation and works fine (with Sensor.setEnabledSensors and Sensor.enableSensorEvents). I now want to allow the user to record sections of this (with ActivityRecording.createSession and ActivityRecording.save).

    In the simulator: The user can monitor HR, and then press Record. The session is 'recorded' and the App works normally during and after.
    On a Vivoactive:: The App works fine while monitoring heart rate, but when recording is started, it never does and the Sensor stops sending HR data, so the previous monitoring stops with no new HR readings.

    Thanks
    Chris
  • I've not seen this myself. I have a couple apps that user the HRM, Tempe, and footpod that enable before I start recording (I wait for GPS and/or a user action to do that), and do lots of testing on a vivoactive.
  • Thanks Jim. I have no trouble until the Recording is started.

    Is there any way of getting more information, when ActivityRecording.createSession returns null?
  • If you're getting null, there's something wrong with your call to create the session

    here's how I do the create/start

    session = Record.createSession({:name=>"Hike", :sport=>recordTypes[recordType][0]});
    session.start();

    (recordTypes is something like "Record.SPORT_HIKING" )

    What does your createSession look like?
  • If you're getting null, there's something wrong with your call to create the session

    here's how I do the create/start

    session = Record.createSession({:name=>"Hike", :sport=>recordTypes[recordType][0]});
    session.start();

    (recordTypes is something like "Record.SPORT_HIKING" )

    What does your createSession look like?


    Thanks again Jim. My code is:
    Sensor.setEnabledSensors([Sensor.SENSOR_HEARTRATE]);
    Sensor.enableSensorEvents(method(:onSensorHR));


    And

    _recordingSession = Recording.createSession({ :name => "hRecovery 01 Jan 2016", :sport => Recording.SPORT_TRAINING , :subsport => Recording.SUB_SPORT_EXERCISE });


    As originally highlighted, I don't get null in the simulator
  • Nothing jumps out at me, but what happens if you remove the subsport, and then maybe trying SPORT_RUNNING? If that works, see what breaks it when you add/change it.
  • Ok, I've come back to this and solved the problem. Hopefully helpful for those reading later.

    It was a mistake on my behalf and a bug/improvement required on Connect IQ (in my view).

    My mistake:
    - My name is longer than 15 characters, and I missed this point highlighted in the documentation. Also I cut the code down above (which I've now amended) for brevity, which is probably why also nobody spotted it as I was adding the date taking it over 15 characters.

    Problem:
    - On the Vivoactive Simulator this is never picked up and all works ok.
    - On the Vivoactive Device it acts really odd (thus throwing me off the scent) but causing the Sensors to stop and the function (starting the recording) to exit early with no crash.

    Improvement:
    - Can the createSesson just return null when this happens?

    Thanks
    Chris
  • Former Member
    Former Member over 9 years ago
    We'll look into it.

    To clarify, on vivoactive, you are seeing the createSession API crash the app when you provide a name longer than 15 characters? I am pretty sure it should just truncate the name and work normally, so we should get that fixed.
  • We'll look into it.

    To clarify, on vivoactive, you are seeing the createSession API crash the app when you provide a name longer than 15 characters? I am pretty sure it should just truncate the name and work normally, so we should get that fixed.


    Thanks Brian. It's definitely not working over 15 characters, as I've done loads of testing. Looks like (from my old C/C++ days!) the memory is getting overwritten from the extra length, causing the bizarre behavior.

    My application doesn't crash, it keeps running; the Heart Rate sensor (the only sensor I am using) stops sending/receiving data (the event doesn't fire) and code below the createSession isn't getting called. Below 15 characters, works a treat.

    Also unrelated/related, I noticed the activity in Garmin Connect is label 'untitled' even below the 15 characters, and I can't see my title in the activity data anywhere. So I am not sure that the purpose of the name is anyway!

    Thanks
    Chris