-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[gen2, threading] Fixes Cellular taking up to 10 minutes to shutoff modem with Cellular.off() / System.sleep(config) if there is no cell connection [ch73242] #2284
Conversation
3a88180
to
c7b7413
Compare
@technobly I know the original issue was about Do we want to do something about that? |
@avtolstoy I didn't see that specific reproduced case in the CH story, but yes of course we should fix that. Let me add a test to reproduce it first (CELLULAR_NO_ANTENNA_03_device_will_sleep_quickly_when_modem_cannot_connect). Any suggestions for a fix are welcome. |
@technobly Ideally we'd refactor the modem code to not block the system loop while registering, but that requires quite a bit of acrobatics to achieve as there are things like AT command timeouts to consider (e.g. COPS taking 5 mins etc). As a quick workaround I would perhaps add a fix specifically for Electron to check for |
…odem with Cellular.off() if there is no cell connection [ch73242]
…shutoff modem with System.sleep(config) if there is no cell connection [ch73242]
60ec25b
to
d6d1d4b
Compare
Problem
On Gen 2, with Threading enabled, Cellular.off() can take up to 10 minutes when there is no cellular reception and the device is actively trying to connect to cellular. This is due to the registration timeout of 10 minutes and the cellular_cancel() request not being processed.
The Sleep 2.0 API also has a similar issue and can cause the device to take a long time to enter sleep or other powered down states.
Gen 3 devices are not affected.
Solution
A flag in
system_network_cellular.h
calledconnect_cancelled
was not being reset tofalse
whencellular_cancel()
was being calledfalse
to unconditionally resume the AT interface. This has been fixed.Sleep 2.0 calls (i.e.
System.sleep(config);
) have been prepended with anetwork_connect_cancel
ifnetwork_connecting
istrue
.Sleep 2.0 tests were also updated for better reliability running in threaded mode.
Workaround
As a workaround, a user may call
cellular_cancel(true, false, NULL)
beforeCellular.off() / System.sleep(config)
Workaround for Cellular.off()
Workaround for System.sleep(config);
Steps to Test
TEST=wiring/cellular_no_antenna
TEST=wiring/sleep20
Tested on Electron G350/ E Series LTE/3G / Boron LTE
References
ch73242
Completeness