Compile error when using software timers?

I’m trying to use software timers using an example very similar to this:

and getting the compilation error below. I’m using Particle Dev. Should I somehow configure Particle Dev to target a particular firmware version ? When using Particle Build (on the web), my device does say 0.4.7.

/tmp/cccIxLwD.ltrans20.ltrans.o: In function Timer::invoke_timer(void*) [clone .local.178]': /mnt/compile-service-shared-workspace/0_core__20_1/firmware/main/../wiring/inc/spark_wiring_timer.h:91: undefined reference toos_timer_get_id’
/tmp/cccIxLwD.ltrans20.ltrans.o: In function Timer::dispose() [clone .isra.2]': /mnt/compile-service-shared-workspace/0_core__20_1/firmware/main/../wiring/inc/spark_wiring_timer.h:68: undefined reference toos_timer_destroy’
/tmp/cccIxLwD.ltrans5.ltrans.o: In function Timer::stop(bool) [clone .isra.3]': /mnt/compile-service-shared-workspace/0_core__20_1/firmware/main/../wiring/inc/spark_wiring_timer.h:56: undefined reference toos_timer_change’
/tmp/cccIxLwD.ltrans5.ltrans.o: In function start': /mnt/compile-service-shared-workspace/0_core__20_1/firmware/main/../wiring/inc/spark_wiring_timer.h:50: undefined reference toos_timer_change’
/tmp/cccIxLwD.ltrans21.ltrans.o: In function __base_ctor ': /mnt/compile-service-shared-workspace/0_core__20_1/firmware/main/../wiring/inc/spark_wiring_timer.h:35: undefined reference toos_timer_create’
/mnt/compile-service-shared-workspace/0_core__20_1/firmware/main/…/wiring/inc/spark_wiring_timer.h:35: undefined reference to `os_timer_create’
collect2: error: ld returned 1 exit status

It looks that you are targeting a Core but I think the timers are only available out the box for the Photon/P1 (at least for now).

The docs do state

1 Like

I am writing this on a Photon. I think it was a transient error, because a subsequent compile went through.

1 Like

I’m just now getting the same error from the web builder. I’m using a Photon with 0.4.7 firmware.

What version of firmware is selected in the web IDE?

1 Like

I have “Latest (0.4.7)”.

And you have that device selected? (A little star to the left of the device?)

The device works quite well, I can compile and flash from the web IDE as long as I don’t use the Timer class. I’m currently using a library instead, but I’d just as soon prefer not to.

I mean, are you sure the device is selected in the WebIDE? The device has to be selected, and the correct firmware versions selected. Then the compiler will use the 0.4.7 branch which includes the timer support.

Yes. As I’m updating the device in question from the web IDE, I’m fairly certain that I’ve selected the correct device, and it does say “Latest (0.4.7)”. As long as I’m not including any Timer objects (I’m currently using a library called “SparcCorePolledTimer” instead), it compiles just fine.

Or am I misunderstanding your questions somehow?

Well, scratch that. I just tried again and it works now. Guess I was drunk or something. Thanks for your time. :confused:

Same problem here, only that I am compiling for Core. I have included the freertos library.

Do you feel like selecting the device first makes the compilation work more reliably ? Since the IDE needs to decide between compiling for a spark core or a photon. Maybe choosing your device before even starting the cloud compilation correctly selects the build environment.