From defc244db2445f232d03b5c46c5cb5af7cabb252 Mon Sep 17 00:00:00 2001 From: Bilal Qamar Date: Wed, 22 May 2019 16:52:03 +0500 Subject: [PATCH 1/4] +UPSND sent to poll activation status --- .../UBLOX/AT/UBLOX_AT_CellularContext.cpp | 22 ++++++++++++++----- .../TARGET_UBLOX_C030/ONBOARD_UBLOX.cpp | 10 ++++++++- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp index 214b9ebe72a..6089092c782 100644 --- a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp +++ b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp @@ -89,8 +89,7 @@ nsapi_error_t UBLOX_AT_CellularContext::open_data_channel() _at.cmd_start("AT+UPSND=" PROFILE ",8"); _at.cmd_stop(); _at.resp_start("+UPSND:"); - _at.read_int(); - _at.read_int(); + _at.skip_param(2); active = _at.read_int(); _at.resp_stop(); @@ -133,7 +132,7 @@ bool UBLOX_AT_CellularContext::activate_profile(const char *apn, // Set up the APN if (apn) { success = false; - _at.cmd_start("AT+UPSD=0,1,"); + _at.cmd_start("AT+UPSD=" PROFILE ",1,"); _at.write_string(apn); _at.cmd_stop(); _at.resp_start(); @@ -192,14 +191,27 @@ bool UBLOX_AT_CellularContext::activate_profile(const char *apn, if (_at.get_last_error() == NSAPI_ERROR_OK) { // Activate, wait upto 30 seconds for the connection to be made _at.set_at_timeout(30000); - _at.cmd_start("AT+UPSDA=0,3"); + _at.cmd_start("AT+UPSD=" PROFILE ",6,"); _at.cmd_stop(); _at.resp_start(); _at.resp_stop(); _at.restore_at_timeout(); if (_at.get_last_error() == NSAPI_ERROR_OK) { - activated = true; + Timer t1; + t1.start(); + while (!(t1.read() >= 180)){ + _at.cmd_start("AT+UPSND=" PROFILE ",8"); + _at.cmd_stop(); + _at.resp_start("+UPSND:"); + _at.skip_param(2); + _at.read_int() ? activated = true : activated = false; + _at.resp_stop(); + + if (activated) //If context is activated, exit while loop and return status + break; + wait_ms(5000); //Wait for 5 seconds and then try again + } } } } diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/TARGET_UBLOX_C030/ONBOARD_UBLOX.cpp b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/TARGET_UBLOX_C030/ONBOARD_UBLOX.cpp index d213b298802..8f00c979ea8 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/TARGET_UBLOX_C030/ONBOARD_UBLOX.cpp +++ b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/TARGET_UBLOX_C030/ONBOARD_UBLOX.cpp @@ -31,7 +31,15 @@ CellularDevice *CellularDevice::get_target_default_instance() #elif defined(TARGET_UBLOX_C030_N211) static UARTSerial serial(MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE); static ONBOARD_UBLOX_N2XX device(&serial); -#else +#elif defined(TARGET_UBLOX_C030_U201) + #if (NSAPI_PPP_AVAILABLE) + static UARTSerial serial(MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE); + static ONBOARD_UBLOX_PPP device(&serial); + #else + static UARTSerial serial(MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE); + static ONBOARD_UBLOX_AT device(&serial); + #endif +#else //UBLOX_C027 static UARTSerial serial(MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE); static ONBOARD_UBLOX_PPP device(&serial); #endif From fb51501234f5f605cc60295663ce2d72603ab871 Mon Sep 17 00:00:00 2001 From: Bilal Qamar Date: Thu, 23 May 2019 11:09:43 +0500 Subject: [PATCH 2/4] Timer stopped after exiting while loop --- .../framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp index 6089092c782..72ce9584e0c 100644 --- a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp +++ b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp @@ -212,6 +212,7 @@ bool UBLOX_AT_CellularContext::activate_profile(const char *apn, break; wait_ms(5000); //Wait for 5 seconds and then try again } + t1.stop(); } } } From 4a37b13bd0bfb08f577eb3eb8502dfb329786507 Mon Sep 17 00:00:00 2001 From: Bilal Qamar Date: Thu, 23 May 2019 14:26:38 +0500 Subject: [PATCH 3/4] Coding style corrected --- .../framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp index 72ce9584e0c..d540f01e0ee 100644 --- a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp +++ b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp @@ -200,7 +200,7 @@ bool UBLOX_AT_CellularContext::activate_profile(const char *apn, if (_at.get_last_error() == NSAPI_ERROR_OK) { Timer t1; t1.start(); - while (!(t1.read() >= 180)){ + while (!(t1.read() >= 180)) { _at.cmd_start("AT+UPSND=" PROFILE ",8"); _at.cmd_stop(); _at.resp_start("+UPSND:"); @@ -208,8 +208,9 @@ bool UBLOX_AT_CellularContext::activate_profile(const char *apn, _at.read_int() ? activated = true : activated = false; _at.resp_stop(); - if (activated) //If context is activated, exit while loop and return status + if (activated) { //If context is activated, exit while loop and return status break; + } wait_ms(5000); //Wait for 5 seconds and then try again } t1.stop(); From 255e2e56233639f6d31509442853c347294dd019 Mon Sep 17 00:00:00 2001 From: Bilal Qamar Date: Thu, 23 May 2019 16:15:10 +0500 Subject: [PATCH 4/4] Correction in AT Command --- .../framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp index d540f01e0ee..32448fcf706 100644 --- a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp +++ b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp @@ -182,7 +182,7 @@ bool UBLOX_AT_CellularContext::activate_profile(const char *apn, for (int protocol = nsapi_security_to_modem_security(NSAPI_SECURITY_NONE); success && (protocol <= nsapi_security_to_modem_security(NSAPI_SECURITY_CHAP)); protocol++) { if ((_auth == NSAPI_SECURITY_UNKNOWN) || (nsapi_security_to_modem_security(_auth) == protocol)) { - _at.cmd_start("AT+UPSD=0,6,"); + _at.cmd_start("AT+UPSD=" PROFILE ",6,"); _at.write_int(protocol); _at.cmd_stop(); _at.resp_start(); @@ -191,7 +191,7 @@ bool UBLOX_AT_CellularContext::activate_profile(const char *apn, if (_at.get_last_error() == NSAPI_ERROR_OK) { // Activate, wait upto 30 seconds for the connection to be made _at.set_at_timeout(30000); - _at.cmd_start("AT+UPSD=" PROFILE ",6,"); + _at.cmd_start("AT+UPSDA=" PROFILE ",3"); _at.cmd_stop(); _at.resp_start(); _at.resp_stop();