How to put the Tracker one to sleep immediately? and what is the right way to handle wakeup properly?

Is there a way to put the tracker one to sleep immediately?

This is what I am doing right now and is this the right way to command the tracker one to sleep as early as possible?

TrackerSleep::instance().resumeSleep();
TrackerSleep::instance().extendExecutionFromNow(1, true);

https://docs.particle.io/reference/asset-tracking/tracker-edge-firmware/#trackersleep

I works at times, but there are times it takes some time before it goes to sleep

my second question is what is the best way to handle the wakeup?

This is my code on the wakup callback

TrackerSleep::instance().extendExecutionFromNow(180, true);
TrackerSleep::instance().pauseSleep(); // dont sleep. we will call the function above for the device to sleep

// need to be fully awake and connected to the internet asap
if (!TrackerSleep::instance().isFullWakeCycle()) {
    TrackerSleep::instance().forceFullWakeCycle();
  }

Are these the right way of handling the sleep and wakeup?

Thanks!

The sleep settings are also configured in the cloud settings in the console. The most important setting for your purposes is post publish execution time, which you probably want to set to 1 instead of the default 10.

You should not use extend execution from now because that will only make the sleep period longer, not shorter, than the post-publish execution time.
Also pauseSleep() will override the timed execution sleep, so you usually don’t need both on wake.

Is there a reason you’re forcing a full wake cycle? This will override maximum location update frequency. This can cause excessive data and power consumption, and also cause your SIM to be banned from the cellular network for aggressive reconnection if you have additional wake sources.