get sensor type

Former Member
Former Member

Hello, I am making my very first steps with the Connect IQ SDK and have taken the example sensor as a starting point.

Instead of the Heartrate I wanted to get the Sensor-Type or the Sensor-Technology, but here I get the error:

"
Error: Symbol Not Found Error
Details: Could not find symbol 'type'
Stack:
- onSnsr() at I:\GarminSDK\projects\Sensor\source\Sensor.mc:40 0x1000012b
"

Code:

" public function onSnsr(sensorInfo as Info) as Void {
var heartRate = sensorInfo.heartRate;
var technology = sensorInfo.type ;
"

I'm on the fence right now, what am I doing wrong?

  • It appears that you are confusing Sensor.Info with SensorInfo.

    Your onSnsr callback is registered with the Sensor module via Sensor.enableSensorEvents(). The sensorInfo parameter to this callback is a Sensor.Info. That type has a heartRate field, but does not have a type field.

    The SensorInfo type is used to provide information about a sensor and is provided when iterating over sensors with Sensor.getRegisteredSensors().

    Note that if you compile your application with type checking enabled, it should give you a compile error on that line. It's usually a lot easier to deal with compile errors than runtime errors.

  • Former Member
    Former Member in reply to Travis.ConnectIQ

    Thank you very much, that makes sense. Unfortunately, since I don't have the programming skills, I still can't get it to work. I tried for a while with
    Sensor.getRegisteredSensors() .

    I asked garmin to provide a data field that shows which HR sensor is in use, so that you know when the external HR is disconnected, battery empty, etc. But nothing happens.

    Now I had the idea to try it myself, but I am not a programmer and do not understand all the logic.

    Thanks anyway