Draft: drivers: Poll driver synchronously when claiming sensor the first time
When claiming a sensor via DBus, there are two possible options:
-
The sensor is not active, and the client is the first one to claim the sensor. In that case iio-sensor-proxy will initialize the sensor and notify the property on dbus once a first measurement has been done.
-
The sensor already is active, the client is not the first one to claim the sensor. In that case iio-sensor-proxy will not really do anything.
In case 2), the client can read the sensor property (so eg. ProximityNear) over DBus immediately and the result will be correct.
Meanwhile in case 1), the client will read an outdated result (potentially from the last time the sensor was active, or just the default).
Clients have no way of knowing whether they're the first ones to claim a sensor though, so they can only trust iio-sensor-proxy that the DBus properties are always up-to-date. In case 1), this requirement is not met.
To deliver on that promise given how the API of iio-sensor-proxy looks, there seems to be no other option than waiting and blocking the DBus call on the first claim of a sensor until we receive a measurement from the sensor.
To implement that, we'll make the set_polling() function block and wait until the first measurement has come in, and only then return the DBus Claim*() invocation.