Skip to content

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

@boraozgen

Description

@boraozgen

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions