The delay function had a bug where the true delay was a factor 10 higher than the delay passed as the argument. The cause of this is that the microapp is not called every bluenet tick. Instead, in the MicroappController::tickMicroapp() function (https://github.com/crownstone/bluenet/blob/master/source/src/microapp/cs_MicroappController.cpp#L302) the microapp is only called every MICROAPP_LOOP_FREQUENCY ticks (default value for MICROAPP_LOOP_FREQUENCY is 10, as defined in the shared cs_MicroappStructs.h)
The solution is simple: delay_ms argument is divided by MICROAPP_LOOP_FREQUENCY in the delay() function on the microapp side.
The delay function had a bug where the true delay was a factor 10 higher than the delay passed as the argument. The cause of this is that the microapp is not called every bluenet tick. Instead, in the
MicroappController::tickMicroapp()
function (https://github.com/crownstone/bluenet/blob/master/source/src/microapp/cs_MicroappController.cpp#L302) the microapp is only called everyMICROAPP_LOOP_FREQUENCY
ticks (default value forMICROAPP_LOOP_FREQUENCY
is 10, as defined in the sharedcs_MicroappStructs.h
)The solution is simple:
delay_ms
argument is divided byMICROAPP_LOOP_FREQUENCY
in thedelay()
function on the microapp side.