From 9b0b92bb1ccccd9c40e5ba838f408f8489be9e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teppo=20J=C3=A4rvelin?= Date: Mon, 9 Apr 2018 12:50:46 +0300 Subject: [PATCH 1/2] Cellular: added detach from the network. --- features/cellular/framework/API/CellularNetwork.h | 6 ++++++ .../cellular/framework/AT/AT_CellularNetwork.cpp | 15 ++++++++++++++- .../cellular/framework/AT/AT_CellularNetwork.h | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/features/cellular/framework/API/CellularNetwork.h b/features/cellular/framework/API/CellularNetwork.h index a3f7f010b5..4094a07838 100644 --- a/features/cellular/framework/API/CellularNetwork.h +++ b/features/cellular/framework/API/CellularNetwork.h @@ -284,6 +284,12 @@ public: */ 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 diff --git a/features/cellular/framework/AT/AT_CellularNetwork.cpp b/features/cellular/framework/AT/AT_CellularNetwork.cpp index 59bddab888..3d8d7c55d8 100644 --- a/features/cellular/framework/AT/AT_CellularNetwork.cpp +++ b/features/cellular/framework/AT/AT_CellularNetwork.cpp @@ -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*/) { _at.lock(); @@ -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 diff --git a/features/cellular/framework/AT/AT_CellularNetwork.h b/features/cellular/framework/AT/AT_CellularNetwork.h index 3b6eef2b55..7c07efe0e3 100644 --- a/features/cellular/framework/AT/AT_CellularNetwork.h +++ b/features/cellular/framework/AT/AT_CellularNetwork.h @@ -74,6 +74,8 @@ public: // CellularNetwork 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); From 0b5fae367035a318ec769e3d968eca765828c031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teppo=20J=C3=A4rvelin?= Date: Mon, 9 Apr 2018 13:32:16 +0300 Subject: [PATCH 2/2] Cellular: added deprecation note for parameter timeout in set_attach. --- features/cellular/framework/API/CellularNetwork.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/features/cellular/framework/API/CellularNetwork.h b/features/cellular/framework/API/CellularNetwork.h index 4094a07838..0b9fc19e5e 100644 --- a/features/cellular/framework/API/CellularNetwork.h +++ b/features/cellular/framework/API/CellularNetwork.h @@ -272,9 +272,11 @@ public: /** 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.