Check whether a sensor is supported
Here is how you can check whether a sensor of a specific type is supported on a device. In this example we check for an accelerometer.
#include <sensor.h>
bool supported = false;
sensor_type_e type = SENSOR_ACCELEROMETER;
if (sensor_is_supported(type, &supported) == SENSOR_ERROR_NONE)
{
if (supported == true)
{
//Sensor is supported, you can do what you want
}
}