Skip to content

Commit 4567626

Browse files
authored
Merge pull request #10636 from u-blox/activation_status
+UPSND sent to poll activation status
2 parents 86bd7f0 + 255e2e5 commit 4567626

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ nsapi_error_t UBLOX_AT_CellularContext::open_data_channel()
8989
_at.cmd_start("AT+UPSND=" PROFILE ",8");
9090
_at.cmd_stop();
9191
_at.resp_start("+UPSND:");
92-
_at.read_int();
93-
_at.read_int();
92+
_at.skip_param(2);
9493
active = _at.read_int();
9594
_at.resp_stop();
9695

@@ -133,7 +132,7 @@ bool UBLOX_AT_CellularContext::activate_profile(const char *apn,
133132
// Set up the APN
134133
if (apn) {
135134
success = false;
136-
_at.cmd_start("AT+UPSD=0,1,");
135+
_at.cmd_start("AT+UPSD=" PROFILE ",1,");
137136
_at.write_string(apn);
138137
_at.cmd_stop();
139138
_at.resp_start();
@@ -183,7 +182,7 @@ bool UBLOX_AT_CellularContext::activate_profile(const char *apn,
183182
for (int protocol = nsapi_security_to_modem_security(NSAPI_SECURITY_NONE);
184183
success && (protocol <= nsapi_security_to_modem_security(NSAPI_SECURITY_CHAP)); protocol++) {
185184
if ((_auth == NSAPI_SECURITY_UNKNOWN) || (nsapi_security_to_modem_security(_auth) == protocol)) {
186-
_at.cmd_start("AT+UPSD=0,6,");
185+
_at.cmd_start("AT+UPSD=" PROFILE ",6,");
187186
_at.write_int(protocol);
188187
_at.cmd_stop();
189188
_at.resp_start();
@@ -192,14 +191,29 @@ bool UBLOX_AT_CellularContext::activate_profile(const char *apn,
192191
if (_at.get_last_error() == NSAPI_ERROR_OK) {
193192
// Activate, wait upto 30 seconds for the connection to be made
194193
_at.set_at_timeout(30000);
195-
_at.cmd_start("AT+UPSDA=0,3");
194+
_at.cmd_start("AT+UPSDA=" PROFILE ",3");
196195
_at.cmd_stop();
197196
_at.resp_start();
198197
_at.resp_stop();
199198
_at.restore_at_timeout();
200199

201200
if (_at.get_last_error() == NSAPI_ERROR_OK) {
202-
activated = true;
201+
Timer t1;
202+
t1.start();
203+
while (!(t1.read() >= 180)) {
204+
_at.cmd_start("AT+UPSND=" PROFILE ",8");
205+
_at.cmd_stop();
206+
_at.resp_start("+UPSND:");
207+
_at.skip_param(2);
208+
_at.read_int() ? activated = true : activated = false;
209+
_at.resp_stop();
210+
211+
if (activated) { //If context is activated, exit while loop and return status
212+
break;
213+
}
214+
wait_ms(5000); //Wait for 5 seconds and then try again
215+
}
216+
t1.stop();
203217
}
204218
}
205219
}

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/TARGET_UBLOX_C030/ONBOARD_UBLOX.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ CellularDevice *CellularDevice::get_target_default_instance()
3131
#elif defined(TARGET_UBLOX_C030_N211)
3232
static UARTSerial serial(MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
3333
static ONBOARD_UBLOX_N2XX device(&serial);
34-
#else
34+
#elif defined(TARGET_UBLOX_C030_U201)
35+
#if (NSAPI_PPP_AVAILABLE)
36+
static UARTSerial serial(MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
37+
static ONBOARD_UBLOX_PPP device(&serial);
38+
#else
39+
static UARTSerial serial(MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
40+
static ONBOARD_UBLOX_AT device(&serial);
41+
#endif
42+
#else //UBLOX_C027
3543
static UARTSerial serial(MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
3644
static ONBOARD_UBLOX_PPP device(&serial);
3745
#endif

0 commit comments

Comments
 (0)