Skip to content
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

Cellular: disconnect does not deactivate context (for some cases) #13490

Closed
boraozgen opened this issue Aug 25, 2020 · 1 comment · Fixed by #13610
Closed

Cellular: disconnect does not deactivate context (for some cases) #13490

boraozgen opened this issue Aug 25, 2020 · 1 comment · Fixed by #13610

Comments

@boraozgen
Copy link
Contributor

boraozgen commented Aug 25, 2020

Description of defect

I use a Quectel BG95 modem (similar to BG96) to connect and disconnect to the cellular network in my application. I noticed that during disconnection, the PDP context is not deactivated. I looked into the code and found some curious logic. There are two parts I believe are buggy or I do not understand.

In AT_CellularContext::do_disconnect(), the value of _is_context_activated is checked in order to deactivate the context.

However, this variable is not set in case an active context is found in AT_CellularContext::find_and_activate_context(). There, only _is_context_active is set.

This leads to the issue that the context is not deactivated if it is found active. Is this desired? I think disconnect should deactivate the context in both cases.

Also, what is the difference between _is_context_active and _is_context_activated? Are they redundant?

When I changed this, it went one step further but the context was still not getting deactivated. Looking further, I found that the only deactivate_context() call is inside this check:

if (_is_context_active && (rat < CellularNetwork::RAT_E_UTRAN || active_contexts_count > 1)) {
_at.clear_error();
deactivate_context();
}

which checks for something really unclear (3G and older RAT?) or active_contexts_count > 1, which I again do not understand. For my case, I am connected using NB-IoT and I have only 1 active context, so this check was failing and my context was not deactivated. Maybe only the _at.clear_error() should be in the if block and deactivate_context() should be after the block. When I changed it in that way, it finally worked for me.

I can open a PR with my changes if needed.

Target(s) affected by this defect ?

Not target specific.

Toolchain(s) (name and version) displaying this defect ?

Not relevant.

What version of Mbed-os are you using (tag or sha) ?

mbed-os-6.2.0
mbed-os-99.99.99

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

Not relevant.

How is this defect reproduced ?

Disconnect from cellular network using without activating (connect with a modem which has an active PDP context).
For the second issue, disconnect from a NB-IoT network with one active context.

boraozgen added a commit to Nantis-GmbH/mbed-os that referenced this issue Sep 10, 2020
@0xc0170
Copy link
Contributor

0xc0170 commented Sep 14, 2020

@boraozgen Could you send a pull request proposing a fix? I can see a reference from the fix above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants