clampSensorHz function
Clamps a motion subscribe rate to the 1..60 Hz the bridge supports.
Implementation
int clampSensorHz(double? hz) {
// A missing, non-finite or non-positive rate takes the default (iOS rule).
if (hz == null || !hz.isFinite || hz <= 0) return 30;
if (hz < 1.0) return 1;
if (hz > 60.0) return 60;
return hz.toInt();
}