MSOM 5.8.2 Sleep Help

Hello,

I can't get sleep mode to work on my msom on device os version 5.8.2. It does not enter sleep mode and the code just flows to result.wakeReason() instantly.

My code for this is:

SystemSleepConfiguration config;
config.mode(SystemSleepMode::STOP)
    .network(NETWORK_INTERFACE_CELLULAR, SystemSleepNetworkFlag::INACTIVE_STANDBY)
    .duration(10s);

SystemSleepResult result = System.sleep(config);

waitFor(Serial.isConnected, 5000);
Log.info("Wakeup reason %d", result.wakeupReason());

I flashed the same code to a b402 and it works no problem.

When is this code run? Is the device already online and breathing cyan when you run this code, or is it still in the process of connecting?

Does it make a difference if you leave off the .network command?

10 seconds to sleep is very short, it may take that long to disconnect from the cloud and go to sleep.

What is the wakeup reason that is reported?

With SerialLogHandler logHandler(LOG_LEVEL_TRACE) what are the debug statements shown prior to sleep?

The code runs in loop() and is triggered via a flag set by a cloud function, so the device is connected to the cloud and breathing cyan.

10s is used just for testing. What's strange is that the code does not stop when I call sleep, it immediately runs the next line as if it had ignored the sleep command.

The wake up reason is 0 - UNKNOWN, when network settings are left in.

When I remove network from the config, it enters sleep properly, wake up reason is 4 - BY_RTC

Here are the logs for when I leave network in:

0000134280 [comm.coap] TRACE: Received CoAP message
0000134308 [comm.coap] TRACE: CON POST /f/Sleep?10 size=16 token=02 id=23780
0000134349 [comm.coap] TRACE: Sending CoAP message
0000134374 [comm.coap] TRACE: ACK 0.00  size=4 token= id=23780
0000134408 [app] INFO: Sleep arg 10
0000134417 [app] INFO: Sleep
0000134423 [system.sleep] TRACE: Entering system_sleep_ext()
0000134417 [comm.coap] TRACE: Sending CoAP message
0000134450 [comm.coap] TRACE: CON 2.04  size=10 token=02 id=27
0000134465 [app] INFO: Wakeup reason 0
0000134538 [comm.coap] TRACE: Received CoAP message
0000134566 [comm.coap] TRACE: ACK 0.00  size=4 token= id=27

Try adding:

.flag(SystemSleepFlag::WAIT_CLOUD)

From the log it looks like the cloud disconnect caused by SystemSleepNetworkFlag::INACTIVE_STANDBY might be causing the device to wake up immediately.

I added .flag(SystemSleepFlag::WAIT_CLOUD) and left network in, this did not have any effect. The logs are also the same as before.

That doesn't seem right. @support may need to create an engineering ticket for further investigation.

One last thing to check is .network(NETWORK_INTERFACE_CELLULAR) without inactive standby. This is just to determine the bounds of the problem.

No effect with

        config.mode(SystemSleepMode::STOP)
            .network(NETWORK_INTERFACE_CELLULAR)
            .flag(SystemSleepFlag::WAIT_CLOUD)
            .duration(10s);

Thank you for all the testing!

I think I know why it's not working: network wake is not supported on Gen 4 (RTL872x) including the M-SoM.

It's not supported on Wi-Fi only devices (P2 and Photon 2) because the Wi-Fi hardware is off during sleep, which would make it impossible to wake by Wi-Fi or keep the stack active.

However, it appears that the M-SoM may not have the feature either. It would only work for cellular, not when connected by Wi-Fi, which would be a strange behavior, so it's likely that it's never available.

It's possible that the code is in a completely different location, but it's certainly not in the RTL872x sleep_hal.cpp like it is for nRF52.

2 Likes

Makes sense, I was using sleep here to check wake by AB1805 fout to see if the chip was fine in newly manufactured devices, I have other ways of testing the chip.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.