Hi @cyrille.mdc,
I think the best place to call the GPS sleep code is inside the goToSleep() function, you can do it in line 1284 after the code that stops the PM sensor.
...
// Stop PM sensor
if (urban.sck_pm.started) urban.sck_pm.stop();
// Sleep GPS (ADDED FOR THIS EXAMPLE)
if (sensors[SENSOR_GPS_FIX_QUALITY].enabled) auxBoards.stop(SENSOR_GPS_FIX_QUALITY);
if (sckOFF) { ...
In this example first we check if the SENSOR_GPS_FIX_QUALITY is enabled (we can use any of the GPS SensorType defined in Sensors.h) and then called the auxboards.stop() function that will call the stop function for GPS, you can check that in line 194 of SckAux.cpp file.
To wake up the GPS at the end of the goToSleep() function add the same code but calling auxboards.start(). Be aware that you need to pass this (SckBase object pointer) to the start method.
... // Recover Noise sensor timer
REG_GCLK_GENCTRL = GCLK_GENCTRL_ID(4); // Select GCLK4
while (GCLK->STATUS.bit.SYNCBUSY);
// Wake up GPS (ADDED FOR THIS EXAMPLE)
if (sensors[SENSOR_GPS_FIX_QUALITY].enabled) auxBoards.start(this, SENSOR_GPS_FIX_QUALITY);
}
On the other side if you need to call specific code for sleep/wake on the GPS side, maybe using the stop() and start() methods isn’t the best idea. If that’s the case, the option I can think off, is to create new methods for that eg: gps.sleep() and gps.wake() and call them through the auxboards.control() method. where you can pass a specific command to the sensor in String format.
String control(SensorType wichSensor, String command);
So you can end up with something like this:
auxBoards.control(SENSOR_GPS_FIX_QUALITY, "sleep");
auxBoards.control(SENSOR_GPS_FIX_QUALITY, "wakeup");
and inside the AuxBoards::control() function you can act depending on the received command and call your new functions gps.sleep() and gps.wake().
Hope this helps!
Cheers
Victor