Skip to content

Commit 9b0b92b

Browse files
author
Teppo Järvelin
committed
Cellular: added detach from the network.
1 parent a463b07 commit 9b0b92b

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

features/cellular/framework/API/CellularNetwork.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ class CellularNetwork : public NetworkInterface
284284
*/
285285
virtual nsapi_error_t get_attach(AttachStatus &status) = 0;
286286

287+
/** Request detach from a network.
288+
*
289+
* @return zero on success
290+
*/
291+
virtual nsapi_error_t detach() = 0;
292+
287293
/** Get APN rate control.
288294
*
289295
* @remark optional params are not updated if not received from network, so use good defaults

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ bool AT_CellularNetwork::has_registration(RegistrationType reg_type)
733733
return true;
734734
}
735735

736-
nsapi_error_t AT_CellularNetwork::set_attach(int timeout)
736+
nsapi_error_t AT_CellularNetwork::set_attach(int /*timeout*/)
737737
{
738738
_at.lock();
739739

@@ -770,6 +770,19 @@ nsapi_error_t AT_CellularNetwork::get_attach(AttachStatus &status)
770770
return _at.unlock_return_error();
771771
}
772772

773+
nsapi_error_t AT_CellularNetwork::detach()
774+
{
775+
_at.lock();
776+
777+
tr_debug("Network detach");
778+
_at.cmd_start("AT+CGATT=0");
779+
_at.cmd_stop();
780+
_at.resp_start();
781+
_at.resp_stop();
782+
783+
return _at.unlock_return_error();
784+
}
785+
773786
nsapi_error_t AT_CellularNetwork::get_apn_backoff_timer(int &backoff_timer)
774787
{
775788
// If apn is set

features/cellular/framework/AT/AT_CellularNetwork.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class AT_CellularNetwork : public CellularNetwork, public AT_CellularBase
7474

7575
virtual nsapi_error_t get_attach(AttachStatus &status);
7676

77+
virtual nsapi_error_t detach();
78+
7779
virtual nsapi_error_t get_rate_control(CellularNetwork::RateControlExceptionReports &reports,
7880
CellularNetwork::RateControlUplinkTimeUnit &time_unit, int &uplink_rate);
7981

0 commit comments

Comments
 (0)