From 4698cd268d31a2dfe104b671c2f61a464e1c7abf Mon Sep 17 00:00:00 2001 From: Ari Parkkila Date: Thu, 13 Sep 2018 03:11:17 -0700 Subject: [PATCH] Cellular: Implement APN authentication for BG96 --- .../BG96/QUECTEL_BG96_CellularNetwork.cpp | 21 +++++++++++++++++++ .../BG96/QUECTEL_BG96_CellularNetwork.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularNetwork.cpp b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularNetwork.cpp index 5a5140725b..6ed0bbd9e8 100644 --- a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularNetwork.cpp +++ b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularNetwork.cpp @@ -111,3 +111,24 @@ nsapi_error_t QUECTEL_BG96_CellularNetwork::set_access_technology_impl(RadioAcce return _at.unlock_return_error(); } + +nsapi_error_t QUECTEL_BG96_CellularNetwork::do_user_authentication() +{ + if (_pwd && _uname) { + _at.cmd_start("AT+QICSGP="); + _at.write_int(_cid); + _at.write_int(1); // IPv4 + _at.write_string(_apn); + _at.write_string(_uname); + _at.write_string(_pwd); + _at.write_int(_authentication_type); + _at.cmd_stop(); + _at.resp_start(); + _at.resp_stop(); + if (_at.get_last_error() != NSAPI_ERROR_OK) { + return NSAPI_ERROR_AUTH_FAILURE; + } + } + + return NSAPI_ERROR_OK; +} diff --git a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularNetwork.h b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularNetwork.h index 1504b9d1c5..292bcaf193 100644 --- a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularNetwork.h +++ b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularNetwork.h @@ -33,6 +33,8 @@ protected: virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology opRat); virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack); + + virtual nsapi_error_t do_user_authentication(); }; } // namespace mbed