- Flashed SoftDevice, bootloader, and DeviceOS image through USB+CLI (still on v2.3.0);
- Moved the
sleep
call from setup
into loop
(actually I tested both; it made no difference);
- Replaced
SerialLogHandler
(USB) with Serial1LogHandler
(USART) so I can see the log when USB is unplugged;
- Added a few Log prints, including
wakeupReason
.
Code:
#include "particle.h"
SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);
Serial1LogHandler logHandler2(115200,
LOG_LEVEL_ALL, {
{ "app", LOG_LEVEL_ALL }
});
void setup() {
Log.info("checkpoint 1");
Particle.connect();
waitUntil(Particle.connected);
Log.info("checkpoint 2");
Particle.process();
delay(1s);
Particle.process();
delay(1s);
Particle.process();
delay(1s);
Log.info("checkpoint 3");
Particle.disconnect(CloudDisconnectOptions().graceful(true).timeout(5000));
waitUntil(Particle.disconnected);
Cellular.disconnect();
waitUntilNot(Cellular.ready);
Cellular.off();
waitUntil(Cellular.isOff);
Log.info("checkpoint 4");
}
void loop() {
Log.info("entering sleep...");
SystemSleepConfiguration c;
c.mode(SystemSleepMode::ULTRA_LOW_POWER);
SystemSleepResult result = System.sleep(c);
Log.error("this ain't right (%u)", (uint16_t)result.wakeupReason());
delay(1s);
}
Log:
0000000248 [system.nm] INFO: State changed: NONE -> DISABLED
0000000249 [system.nm] TRACE: Interface 4 power state: 2
0000000259 [app] INFO: checkpoint 1
0000000362 [system.nm] INFO: State changed: DISABLED -> IFACE_DOWN
0000000364 [system.nm] INFO: State changed: IFACE_DOWN -> IFACE_REQUEST_UP
0000000368 [net.pppncp] TRACE: PPP netif event from queue: 1
0000000371 [ncp.client] TRACE: Powering modem on, ncpId: 0x44
0000000380 [ncp.client] TRACE: Modem already on
0000000380 [ncp.client] TRACE: Setting UART voltage translator state 1
0000000393 [system.nm] INFO: State changed: IFACE_REQUEST_UP -> IFACE_UP
0000000492 [ncp.client] TRACE: Setting UART voltage translator state 0
0000000592 [ncp.client] TRACE: Setting UART voltage translator state 1
0000000592 [ncp.client] TRACE: Muxer is not currently running
0000000594 [ncp.client] TRACE: Initialized muxer @ 460800 baudrate
0000000599 [gsm0710muxer] INFO: Starting GSM07.10 muxer
0000000605 [gsm0710muxer] INFO: GSM07.10 muxer thread started
0000000904 [gsm0710muxer] INFO: Stopping GSM07.10 muxer
0000000904 [gsm0710muxer] INFO: Gracefully stopping GSM07.10 muxer
0000000905 [gsm0710muxer] INFO: Closing all muxed channels
0000000912 [gsm0710muxer] INFO: Muxed channel 1 already closed
0000000916 [gsm0710muxer] INFO: Muxed channel 2 already closed
0000000923 [gsm0710muxer] INFO: Muxed channel 3 already closed
0000000927 [gsm0710muxer] INFO: Muxed channel 4 already closed
0000001584 [gsm0710muxer] INFO: Sending CLD (multiplexer close down)
0000002485 [gsm0710muxer] INFO: Received response to CLD or timed out, exiting multiplexed mode
0000002535 [gsm0710muxer] INFO: GSM07.10 muxer thread exiting
0000002535 [gsm0710muxer] INFO: GSM07.10 muxer stopped
0000002536 [ncp.client] TRACE: Initialized muxer @ 115200 baudrate
0000002547 [gsm0710muxer] INFO: Starting GSM07.10 muxer
0000002548 [gsm0710muxer] INFO: GSM07.10 muxer thread started
0000002848 [gsm0710muxer] INFO: Stopping GSM07.10 muxer
0000002848 [gsm0710muxer] INFO: Gracefully stopping GSM07.10 muxer
0000002849 [gsm0710muxer] INFO: Closing all muxed channels
0000002858 [gsm0710muxer] INFO: Muxed channel 1 already closed
0000002860 [gsm0710muxer] INFO: Muxed channel 2 already closed
0000002870 [gsm0710muxer] INFO: Muxed channel 3 already closed
0000002872 [gsm0710muxer] INFO: Muxed channel 4 already closed
0000003531 [gsm0710muxer] INFO: Sending CLD (multiplexer close down)
0000004432 [gsm0710muxer] INFO: Received response to CLD or timed out, exiting multiplexed mode
0000004482 [gsm0710muxer] INFO: GSM07.10 muxer thread exiting
0000004482 [gsm0710muxer] INFO: GSM07.10 muxer stopped
0000004484 [ncp.at] TRACE: > AT
0000005495 [ncp.at] TRACE: > AT
0000006495 [ncp.client] TRACE: Modem is not responsive @ 460800 baudrate
0000006496 [ncp.at] TRACE: > AT
0000006501 [ncp.at] TRACE: < OK
0000006502 [ncp.client] TRACE: NCP ready to accept AT commands
0000006503 [ncp.at] TRACE: > AT
0000006507 [ncp.at] TRACE: < OK
0000006514 [ncp.at] TRACE: > ATI9
0000006522 [ncp.at] TRACE: < L0.0.00.00.05.06,A.02.00
0000006523 [ncp.at] TRACE: < OK
0000006523 [ncp.client] TRACE: App firmware: 200
0000006524 [ncp.at] TRACE: > AT+UGPIOC?
0000006535 [ncp.at] TRACE: < +UGPIOC:
0000006535 [ncp.at] TRACE: < 16,255
0000006535 [ncp.at] TRACE: < 19,255
0000006537 [ncp.at] TRACE: < 23,0
0000006546 [ncp.at] TRACE: < 24,255
0000006546 [ncp.at] TRACE: < 25,255
0000006548 [ncp.at] TRACE: < 42,255
0000006557 [ncp.at] TRACE: < OK
0000006557 [ncp.at] TRACE: > AT+UGPIOR=23
0000006566 [ncp.at] TRACE: < +UGPIOR: 23,1
0000006567 [ncp.at] TRACE: < OK
0000006567 [ncp.client] INFO: Using internal SIM card
0000006571 [ncp.at] TRACE: > AT+CPIN?
0000006578 [ncp.at] TRACE: < +CPIN: READY
0000006579 [ncp.at] TRACE: < OK
0000006579 [ncp.at] TRACE: > AT+CCID
0000006588 [ncp.at] TRACE: < +CCID: 89014103271226500732
0000006590 [ncp.at] TRACE: < OK
0000006590 [ncp.at] TRACE: > AT+IFC=2,2
0000006597 [ncp.at] TRACE: < OK
0000006601 [ncp.at] TRACE: > AT
0000006604 [ncp.at] TRACE: < OK
0000007604 [ncp.at] TRACE: > AT
0000007609 [ncp.at] TRACE: < OK
0000007610 [ncp.at] TRACE: > AT+CCID
0000007620 [ncp.at] TRACE: < +CCID: 89014103271226500732
0000007620 [ncp.at] TRACE: < OK
0000007621 [ncp.at] TRACE: > AT+CIMI
0000007628 [ncp.at] TRACE: < 310410122650073
0000007629 [ncp.at] TRACE: < OK
0000007631 [ncp.at] TRACE: > AT+UMNOPROF?
0000007641 [ncp.at] TRACE: < +UMNOPROF: 2
0000007642 [ncp.at] TRACE: < OK
0000007642 [ncp.at] TRACE: > AT+COPS=3,2
0000007647 [ncp.at] TRACE: < OK
0000007647 [ncp.at] TRACE: > AT+CGEREP=1,0
0000007657 [ncp.at] TRACE: < OK
0000007657 [ncp.at] TRACE: > AT+URAT?
0000007662 [ncp.at] TRACE: < +URAT: 7
0000007662 [ncp.at] TRACE: < OK
0000007665 [ncp.at] TRACE: > AT+CPSMS?
0000007676 [ncp.at] TRACE: < +CPSMS:0,,,"01100000","00000000"
0000007676 [ncp.at] TRACE: < OK
0000007676 [ncp.at] TRACE: > AT+CEDRXS?
0000007681 [ncp.at] TRACE: < +CEDRXS:
0000007682 [ncp.at] TRACE: < OK
0000007688 [ncp.at] TRACE: > AT+CMUX=0,0,,1509,,,,,
0000007697 [ncp.at] TRACE: < OK
0000007698 [gsm0710muxer] INFO: Starting GSM07.10 muxer
0000007699 [gsm0710muxer] INFO: Openning mux channel 0
0000007699 [gsm0710muxer] INFO: GSM07.10 muxer thread started
0000007713 [gsm0710muxer] INFO: Openning mux channel 1
0000007719 [ncp.at] TRACE: > AT
0000007729 [ncp.at] TRACE: < OK
0000007729 [ncp.client] TRACE: NCP state changed: 1
0000007730 [net.pppncp] TRACE: NCP event 1
0000007731 [net.ppp.client] TRACE: PPP thread event ADM_UP
0000007740 [net.ppp.client] TRACE: State NONE -> READY
0000007735 [ncp.at] TRACE: > AT+CFUN?
0000007751 [ncp.at] TRACE: < +CFUN: 1
0000007752 [ncp.at] TRACE: < OK
0000007753 [ncp.at] TRACE: > AT+CCID
0000007765 [ncp.at] TRACE: < +CCID: 89014103271226500732
0000007765 [ncp.at] TRACE: < OK
0000007766 [ncp.at] TRACE: > AT+CIMI
0000007777 [ncp.at] TRACE: < 310410122650073
0000007778 [ncp.at] TRACE: < OK
0000007778 [ncp.at] TRACE: > AT+CGDCONT?
0000007793 [ncp.at] TRACE: < +CGDCONT: 1,"IP","10569.mcs","10.207.191.71",0,0,0,0
0000007794 [ncp.at] TRACE: < OK
0000007795 [ncp.at] TRACE: > AT+CFUN?
0000007806 [ncp.at] TRACE: < +CFUN: 1
0000007806 [ncp.at] TRACE: < OK
0000007807 [ncp.at] TRACE: > AT+CEREG=2
0000007817 [ncp.at] TRACE: < OK
0000007817 [ncp.client] TRACE: NCP connection state changed: 1
0000007818 [net.pppncp] TRACE: NCP event 2
0000007823 [net.pppncp] TRACE: State changed event: 1
0000007829 [net.ppp.client] TRACE: PPP thread event LOWER_DOWN
0000007830 [ncp.at] TRACE: > AT+COPS?
0000007841 [ncp.at] TRACE: < +COPS: 0,2,"310410",8
0000007841 [ncp.at] TRACE: < OK
0000007842 [ncp.at] TRACE: > AT+CEREG?
0000007855 [ncp.at] TRACE: < +CEREG: 2,1,"8504","7A19B10",8
0000007856 [ncp.at] TRACE: < OK
0000007856 [ncp.client] TRACE: NCP connection state changed: 2
0000007863 [gsm0710muxer] INFO: Openning mux channel 2
0000009125 [net.pppncp] TRACE: NCP event 100
0000009125 [net.pppncp] TRACE: New auth info
0000009127 [net.pppncp] TRACE: NCP event 2
0000009127 [net.pppncp] TRACE: State changed event: 2
0000009137 [net.ppp.client] TRACE: PPP thread event LOWER_UP
0000009137 [net.ppp.client] TRACE: State READY -> CONNECT
0000009148 [net.ppp.client] TRACE: State CONNECT -> CONNECTING
0000009138 [ncp.at] TRACE: > AT+CIMI
0000009151 [ncp.at] TRACE: < 310410122650073
0000009159 [ncp.at] TRACE: < OK
0000009160 [ncp.at] TRACE: > AT
0000009168 [ncp.at] TRACE: < OK
0000010170 [ncp.at] TRACE: > AT
0000010179 [ncp.at] TRACE: < OK
0000010179 [ncp.at] TRACE: > ATD*99***1#
0000010193 [ncp.at] TRACE: < CONNECT 150000000
0000010193 [net.ppp.client] TRACE: PPP phase -> 3
0000010194 [net.ppp.client] TRACE: PPP phase -> 6
0000010224 [net.ppp.client] TRACE: PPP phase -> 7
0000010251 [net.ppp.client] TRACE: PPP phase -> 9
0000010281 [system.nm] INFO: State changed: IFACE_UP -> IFACE_LINK_UP
0000010283 [system.nm] INFO: State changed: IFACE_LINK_UP -> IP_CONFIGURED
0000010288 [net.ppp.client] TRACE: PPP phase -> 10
0000010283 [net.ppp.client] TRACE: PPP thread event UP
0000010299 [net.ppp.client] TRACE: State CONNECTING -> CONNECTED
0000010299 [net.pppncp] TRACE: Negotiated MTU: 1500
0000010310 [net.pppncp] TRACE: Updating MTU to: 990
0000010310 [system] INFO: Cloud: connecting
0000010317 [system] INFO: Cloud socket connected
0000010322 [comm.protocol.handshake] INFO: Establish secure connection
0000010701 [ncp.at] TRACE: > AT+CFUN?
0000010713 [ncp.at] TRACE: < +CFUN: 1
0000010713 [ncp.at] TRACE: < OK
0000010715 [ncp.at] TRACE: > AT+CCID
0000010727 [ncp.at] TRACE: < +CCID: 89014103271226500732
0000010727 [ncp.at] TRACE: < OK
0000010729 [ncp.at] TRACE: > AT+CGSN
0000010740 [ncp.at] TRACE: < 352753090294479
0000010741 [ncp.at] TRACE: < OK
0000010742 [ncp.at] TRACE: > ATI9
0000010754 [ncp.at] TRACE: < L0.0.00.00.05.06,A.02.00
0000010754 [ncp.at] TRACE: < OK
0000010755 [comm.protocol.handshake] INFO: Skipping HELLO message
0000010868 [comm.protocol] INFO: Checksum has not changed; not sending application DESCRIBE
0000010870 [comm.protocol] INFO: Checksum has not changed; not sending subscriptions
0000011390 [comm.protocol] TRACE: Reply recieved: type=2, code=0
0000011390 [comm.protocol] TRACE: message id 38 complete with code 0.00
0000011411 [comm.protocol] TRACE: rcv'd message type=13
0000011413 [comm.protocol] TRACE: Reply recieved: type=2, code=69
0000011413 [comm.protocol] TRACE: message id 41 complete with code 2.05
0000011424 [comm.protocol] INFO: Received TIME response: 1650593019
0000011425 [comm.protocol] TRACE: rcv'd message type=12
0000011535 [comm.protocol] TRACE: Reply recieved: type=2, code=0
0000011536 [comm.protocol] TRACE: message id 39 complete with code 0.00
0000011537 [comm.protocol] TRACE: rcv'd message type=13
0000011647 [comm.protocol] TRACE: Reply recieved: type=2, code=0
0000011648 [comm.protocol] TRACE: message id 40 complete with code 0.00
0000011649 [comm.protocol] TRACE: rcv'd message type=13
0000011761 [system] INFO: Cloud connected
0000011761 [app] INFO: checkpoint 2
0000012461 [comm.protocol] TRACE: rcv'd message type=8
0000014762 [app] INFO: checkpoint 3
0000014861 [system] INFO: Cloud: disconnecting
0000015068 [comm.protocol] TRACE: Reply recieved: type=2, code=0
0000015070 [comm.protocol] TRACE: message id 42 complete with code 0.00
0000015071 [comm.protocol] TRACE: rcv'd message type=13
0000015864 [system] INFO: Cloud: disconnected
0000015865 [net.pppncp] TRACE: PPP netif event from queue: 2
0000015866 [net.ppp.client] TRACE: PPP thread event LOWER_DOWN
0000015868 [net.ppp.client] TRACE: State CONNECTED -> DISCONNECT
0000015879 [net.ppp.client] TRACE: State DISCONNECT -> DISCONNECTING
0000015867 [ncp.at] TRACE: > AT+CFUN=0
0000015883 [system.nm] INFO: State changed: IP_CONFIGURED -> IFACE_UP
0000015891 [net.ppp.client] TRACE: PPP phase -> 9
0000015901 [net.ppp.client] TRACE: PPP phase -> 6
0000015902 [net.ppp.client] TRACE: PPP phase -> 12
0000015904 [net.ppp.client] TRACE: PPP phase -> 0
0000015913 [net.ppp.client] TRACE: PPP thread event ADM_DOWN
0000015913 [net.ppp.client] TRACE: PPP thread event DOWN
0000015924 [net.ppp.client] TRACE: State DISCONNECTING -> DISCONNECTED
0000015927 [net.ppp.client] TRACE: State DISCONNECTED -> NONE
0000015936 [system.nm] INFO: State changed: IFACE_UP -> IFACE_REQUEST_DOWN
0000015938 [system.nm] INFO: State changed: IFACE_REQUEST_DOWN -> IFACE_DOWN
0000015946 [system.nm] TRACE: Request to power off the interface
0000015950 [system.nm] TRACE: Interface 4 power state: 2
0000015959 [system.nm] INFO: State changed: IFACE_DOWN -> DISABLED
0000016019 [ncp.at] TRACE: < OK
0000016020 [ncp.client] TRACE: NCP connection state changed: 0
0000016020 [net.pppncp] TRACE: NCP event 2
0000016025 [net.pppncp] TRACE: State changed event: 0
0000016031 [ncp.at] TRACE: < +CEREG: 0
0000016032 [net.pppncp] TRACE: PPP netif event from queue: 4
0000016036 [net.pppncp] TRACE: NCP event 3
0000016042 [net.pppncp] TRACE: NCP power state changed: IF_POWER_STATE_POWERING_DOWN
0000016047 [system.nm] TRACE: Interface 4 power state changed: 3
0000016054 [ncp.client] TRACE: Try powering modem off using AT command
0000016032 [net.ppp.client] TRACE: PPP thread event LOWER_DOWN
0000016060 [ncp.at] TRACE: > AT+CPWROFF
0000016070 [ncp.at] TRACE: < OK
0000016070 [ncp.client] TRACE: Waiting the modem to be turned off...
0000016096 [net.pppncp] TRACE: NCP event 3
0000016096 [net.pppncp] TRACE: NCP power state changed: IF_POWER_STATE_DOWN
0000016097 [system.nm] TRACE: Interface 4 power state changed: 1
0000016108 [ncp.client] TRACE: It takes 37 ms to power off the modem.
0000016108 [gsm0710muxer] INFO: Stopping GSM07.10 muxer
0000016119 [gsm0710muxer] INFO: Gracefully stopping GSM07.10 muxer
0000016119 [gsm0710muxer] INFO: Closing all muxed channels
0000016130 [gsm0710muxer] INFO: Closing mux channel 1
0000016130 [gsm0710muxer] INFO: Closing mux channel 2
0000016141 [gsm0710muxer] INFO: Muxed channel 3 already closed
0000016141 [gsm0710muxer] INFO: Muxed channel 4 already closed
0000016152 [gsm0710muxer] INFO: GSM07.10 muxer thread exiting
0000016153 [gsm0710muxer] INFO: GSM07.10 muxer stopped
0000016163 [ncp.client] TRACE: Setting UART voltage translator state 0
0000016164 [ncp.client] TRACE: Soft power off modem successfully
0000016174 [ncp.client] TRACE: Deinit modem serial.
0000016175 [app] INFO: checkpoint 4
0000016176 [app] INFO: entering sleep...
0000016185 [system.sleep] TRACE: Entering system_sleep_ext()
0000016186 [app] ERROR: this ain't right (0)
0000016275 [ncp.client] TRACE: Modem already off
0000016275 [ncp.client] TRACE: Setting UART voltage translator state 0
0000016276 [ncp.client] TRACE: Soft power off modem successfully
0000016284 [ncp.client] TRACE: Deinit modem serial.
0000016287 [ncp.client] TRACE: NCP state changed: 0
0000016295 [net.pppncp] TRACE: NCP event 1
0000017196 [app] INFO: entering sleep...
0000017197 [system.sleep] TRACE: Entering system_sleep_ext()
0000017197 [app] ERROR: this ain't right (0)
0000018199 [app] INFO: entering sleep...
0000018199 [system.sleep] TRACE: Entering system_sleep_ext()
0000018200 [app] ERROR: this ain't right (0)
0000019209 [app] INFO: entering sleep...
0000019210 [system.sleep] TRACE: Entering system_sleep_ext()
0000019210 [app] ERROR: this ain't right (0)
0000020219 [app] INFO: entering sleep...
0000020219 [system.sleep] TRACE: Entering system_sleep_ext()
0000020220 [app] ERROR: this ain't right (0)
0000021226 [app] INFO: entering sleep...
0000021227 [system.sleep] TRACE: Entering system_sleep_ext()
0000021227 [app] ERROR: this ain't right (0)
0000022232 [app] INFO: entering sleep...
0000022232 [system.sleep] TRACE: Entering system_sleep_ext()
0000022233 [app] ERROR: this ain't right (0)
0000023236 [app] INFO: entering sleep...
0000023236 [system.sleep] TRACE: Entering system_sleep_ext()
0000023237 [app] ERROR: this ain't right (0)
0000024248 [app] INFO: entering sleep...
0000024248 [system.sleep] TRACE: Entering system_sleep_ext()
It just repeats the same thing from this point on; still drawing 4 mA. Wake up reason is 0
, which from the definition of the struct it’s likely the first one, i.e. UNKNOWN
.