User Activity

Is it possible to set start a timer (e.g in a function), then enable the StopMode in the whileloop, and when the timer has expired wake up agian?
I am using the I-Cube-lrwan driver on the B-L072z-lrwan1 disco kit and I would like to implement the sensors without the NUCLEO board. where do I have to implement this code?