Skip to content

Cellular: add detach from the network #6570

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

Merged
merged 2 commits into from
Apr 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions features/cellular/framework/API/CellularNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,11 @@ class CellularNetwork : public NetworkInterface

/** Request attach to network.
*
* @deprecated Parameter timeout will be deprecated. Use mbed-os/features/cellular/framework/API/CellularDevice.h set_timeout instead.
* @param timeout milliseconds to wait for attach response
* @return zero on success
*/
MBED_DEPRECATED_SINCE("mbed-os-5.9", "Parameter timeout will be deprecated. Use mbed-os/features/cellular/framework/API/CellularDevice.h set_timeout instead.")
virtual nsapi_error_t set_attach(int timeout = 10*1000) = 0;

/** Request attach status from network.
Expand All @@ -284,6 +286,12 @@ class CellularNetwork : public NetworkInterface
*/
virtual nsapi_error_t get_attach(AttachStatus &status) = 0;

/** Request detach from a network.
*
* @return zero on success
*/
virtual nsapi_error_t detach() = 0;

/** Get APN rate control.
*
* @remark optional params are not updated if not received from network, so use good defaults
Expand Down
15 changes: 14 additions & 1 deletion features/cellular/framework/AT/AT_CellularNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ bool AT_CellularNetwork::has_registration(RegistrationType reg_type)
return true;
}

nsapi_error_t AT_CellularNetwork::set_attach(int timeout)
nsapi_error_t AT_CellularNetwork::set_attach(int /*timeout*/)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that "timeout" is and will not be used, so could add deprecated notice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, added deprecation

{
_at.lock();

Expand Down Expand Up @@ -770,6 +770,19 @@ nsapi_error_t AT_CellularNetwork::get_attach(AttachStatus &status)
return _at.unlock_return_error();
}

nsapi_error_t AT_CellularNetwork::detach()
{
_at.lock();

tr_debug("Network detach");
_at.cmd_start("AT+CGATT=0");
_at.cmd_stop();
_at.resp_start();
_at.resp_stop();

return _at.unlock_return_error();
}

nsapi_error_t AT_CellularNetwork::get_apn_backoff_timer(int &backoff_timer)
{
// If apn is set
Expand Down
2 changes: 2 additions & 0 deletions features/cellular/framework/AT/AT_CellularNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class AT_CellularNetwork : public CellularNetwork, public AT_CellularBase

virtual nsapi_error_t get_attach(AttachStatus &status);

virtual nsapi_error_t detach();

virtual nsapi_error_t get_rate_control(CellularNetwork::RateControlExceptionReports &reports,
CellularNetwork::RateControlUplinkTimeUnit &time_unit, int &uplink_rate);

Expand Down