java.util.concurrent.TimeoutException: Did not received timer id within 1000ms
Hello!
Board: MetaMotion C
Firmware: 1.3.6
Android Compile SDK: 23
SDK: 3.2.2
I'm attempting to use the Timer to record the temperature and battery settings every 100 ms. I'm receiving a java.util.concurrent.TimeoutException with the message "Creating timer timed out".
Interestingly enough, the scheduleAsync call seems to succeed since the subscribers for both streams receive data. However, I don't have access to the Timer.ScheduledTask object (or its id) which I need to stop the task properly.
My code for invoking scheduleAsync is:
board.getModule(Timer.class)
.scheduleAsync(period, true, callback)
.continueWithTask(timerTask -> {
Timer.ScheduledTask scheduledTask = timerTask.getResult();
if (scheduledTask == null) {
if (timerTask.getError() != null) {
Log.w(sensorStreamName, "Error in timer task result: " + timerTask.getError());
...
The callback passed for Temperature is:
Temperature temperature = board.getModule(Temperature.class);
Temperature.Sensor[] sensors = temperature.findSensors(Temperature.SensorType.BOSCH_ENV);
if (sensors.length != 1 || sensors[0] == null) {
Log.w("UploadActivity", "Unable to find Bosch temperature sensor!!!");
return;
}
this.temperatureSensor = sensors[0];
...
callback = () -> this.temperatureSensor.read();
The callback passed for battery is:
Settings settings = board.getModule(Settings.class);
...
callback = () -> settings.battery().read();
Any thoughts on how to proceed? I can do something hacky like invoke Timer.lookupScheduledTask for all 256 possible values of a byte to find my scheduled tasks.
Also, do the timer tasks stop by default when we call disconnectAsync on the board?
Thanks for any help!
This discussion has been closed.
Comments
ScheduledTask
interface has anid
methodlookupScheduledTask
unless you need to access the object from another activity or if you need to rebuild your app state.