typedef struct
{
const char *tag; /* Prefix such as "accel", "gyro", "temp"... */
+ const char *shorthand;
const int type; /* Sensor type ; ex: SENSOR_TYPE_ACCELEROMETER */
const int num_channels; /* Expected iio channels for this sensor */
const int is_virtual; /* Is the sensor virtual or not */
int i = sensor[s].catalog_index;
const char *prefix = sensor_catalog[i].tag;
+ const char *shorthand = sensor_catalog[i].shorthand;
/* First try most specialized form, like ro.iio.anglvel.bmg160.name */
return 0;
}
+ if (shorthand[0] != '\0') {
+ /* Try with shorthand instead of prefix */
+ snprintf(prop_name, PROP_NAME_MAX, PROP_BASE, shorthand, extended_sel);
+
+ if (property_get(prop_name, prop_val, "")) {
+ strncpy(val, prop_val, MAX_NAME_SIZE-1);
+ val[MAX_NAME_SIZE-1] = '\0';
+ return 0;
+ }
+ }
/* Fall back to simple form, like ro.iio.anglvel.name */
snprintf(prop_name, PROP_NAME_MAX, PROP_BASE, prefix, sel);
sensor_catalog_entry_t sensor_catalog[] = {
{
.tag = "accel",
+ .shorthand = "",
.type = SENSOR_TYPE_ACCELEROMETER,
.num_channels = 3,
.is_virtual = 0,
},
{
.tag = "anglvel",
+ .shorthand = "",
.type = SENSOR_TYPE_GYROSCOPE,
.num_channels = 3,
.is_virtual = 0,
},
{
.tag = "magn",
+ .shorthand = "",
.type = SENSOR_TYPE_MAGNETIC_FIELD,
.num_channels = 3,
.is_virtual = 0,
},
{
.tag = "intensity",
+ .shorthand = "",
.type = SENSOR_TYPE_INTERNAL_INTENSITY,
.num_channels = 1,
.is_virtual = 0,
},
{
.tag = "illuminance",
+ .shorthand = "",
.type = SENSOR_TYPE_INTERNAL_ILLUMINANCE,
.num_channels = 1,
.is_virtual = 0,
},
{
.tag = "incli",
+ .shorthand = "",
.type = SENSOR_TYPE_ORIENTATION,
.num_channels = 3,
.is_virtual = 0,
},
{
.tag = "rot",
+ .shorthand = "",
.type = SENSOR_TYPE_ROTATION_VECTOR,
.num_channels = 4,
.is_virtual = 0,
},
{
.tag = "temp",
+ .shorthand = "",
.type = SENSOR_TYPE_AMBIENT_TEMPERATURE,
.num_channels = 1,
.is_virtual = 0,
},
{
.tag = "proximity",
+ .shorthand = "prox",
.type = SENSOR_TYPE_PROXIMITY,
.num_channels = 1,
.is_virtual = 0,
},
{
.tag = "",
+ .shorthand = "",
.type = SENSOR_TYPE_GYROSCOPE_UNCALIBRATED,
.num_channels = 0,
.is_virtual = 1,
},
{
.tag = "",
+ .shorthand = "",
.type = SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED,
.num_channels = 0,
.is_virtual = 1,
},
{
.tag = "steps",
+ .shorthand = "",
.type = SENSOR_TYPE_STEP_COUNTER,
.num_channels = 1,
.is_virtual = 0,
},
{
.tag = "steps",
+ .shorthand = "",
.type = SENSOR_TYPE_STEP_DETECTOR,
.num_channels = 1,
.is_virtual = 0,
},
{
.tag = "proximity",
+ .shorthand = "prox",
.type = SENSOR_TYPE_PROXIMITY,
.num_channels = 4,
.is_virtual = 0,