setSamplingRate method
Set the sampling rate for sensor sampling in Hz (min: 1 - max: 100) Default sampling rate is 10 Hz.
Returns true
if the request was successfully made, false
otherwise.
Sampling rate must be set before listening is started.
Note that the sampling rate is only a hint to the system. Sensor events may be received faster or slower than the specified rate, depending on the Bluetooth communication status and parameter values.
Implementation
Future<bool> setSamplingRate(int rate) async {
assert(rate > 0 && rate <= 100,
'Must provide a sampling rate between 1 and 100 Hz.');
_samplingRate = rate;
// for some strange reason, iOS does not accept an int as argument
// hence, [rate] is converted to a string
return await _eSenseManagerMethodChannel.invokeMethod<bool?>(
'setSamplingRate', <String, dynamic>{'rate': '$rate'}) ??
false;
}