Closed zenbooster closed 1 year ago
Does this seem to be the reason?
This is only a hint to the system. Events may be received faster or slower than the specified rate.
Meanwhile, it could be a useful option. Which is better, to modify the server, or the client? =)
The data delay (or sampling rate) controls the interval at which sensor events are sent to your application via the onSensorChanged() callback method. The default data delay is suitable for monitoring typical screen orientation changes and uses a delay of 200,000 microseconds. You can specify other data delays, such as SENSOR_DELAY_GAME (20,000 microsecond delay), SENSOR_DELAY_UI (60,000 microsecond delay), or SENSOR_DELAY_FASTEST (0 microsecond delay). As of Android 3.0 (API Level 11) you can also specify the delay as an absolute value (in microseconds).
The delay that you specify is only a suggested delay. The Android system and other applications can alter this delay. As a best practice, you should specify the largest delay that you can because the system typically uses a smaller delay than the one you specify (that is, you should choose the slowest sampling rate that still meets the needs of your application). Using a larger delay imposes a lower load on the processor and therefore uses less power.
There is no public method for determining the rate at which the sensor framework is sending sensor events to your application; however, you can use the timestamps that are associated with each sensor event to calculate the sampling rate over several events. You should not have to change the sampling rate (delay) once you set it. If for some reason you do need to change the delay, you will have to unregister and reregister the sensor listener.
source https://developer.android.com/guide/topics/sensors/sensors_overview
For fastest sampling, set rate to 0 (before starting a server)
Why, when I set the sample rate to 500000 microseconds, does the data come in much more often than twice per second?
websocat.x86_64-pc-windows-gnu.exe ws://192.168.4.44:8080/sensor/connect?type=android.sensor.accelerometer