@@ -89,8 +89,7 @@ nsapi_error_t UBLOX_AT_CellularContext::open_data_channel()
89
89
_at.cmd_start (" AT+UPSND=" PROFILE " ,8" );
90
90
_at.cmd_stop ();
91
91
_at.resp_start (" +UPSND:" );
92
- _at.read_int ();
93
- _at.read_int ();
92
+ _at.skip_param (2 );
94
93
active = _at.read_int ();
95
94
_at.resp_stop ();
96
95
@@ -133,7 +132,7 @@ bool UBLOX_AT_CellularContext::activate_profile(const char *apn,
133
132
// Set up the APN
134
133
if (apn) {
135
134
success = false ;
136
- _at.cmd_start (" AT+UPSD=0 ,1," );
135
+ _at.cmd_start (" AT+UPSD=" PROFILE " ,1," );
137
136
_at.write_string (apn);
138
137
_at.cmd_stop ();
139
138
_at.resp_start ();
@@ -183,7 +182,7 @@ bool UBLOX_AT_CellularContext::activate_profile(const char *apn,
183
182
for (int protocol = nsapi_security_to_modem_security (NSAPI_SECURITY_NONE);
184
183
success && (protocol <= nsapi_security_to_modem_security (NSAPI_SECURITY_CHAP)); protocol++) {
185
184
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," );
187
186
_at.write_int (protocol);
188
187
_at.cmd_stop ();
189
188
_at.resp_start ();
@@ -192,14 +191,29 @@ bool UBLOX_AT_CellularContext::activate_profile(const char *apn,
192
191
if (_at.get_last_error () == NSAPI_ERROR_OK) {
193
192
// Activate, wait upto 30 seconds for the connection to be made
194
193
_at.set_at_timeout (30000 );
195
- _at.cmd_start (" AT+UPSDA=0 ,3" );
194
+ _at.cmd_start (" AT+UPSDA=" PROFILE " ,3" );
196
195
_at.cmd_stop ();
197
196
_at.resp_start ();
198
197
_at.resp_stop ();
199
198
_at.restore_at_timeout ();
200
199
201
200
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 ();
203
217
}
204
218
}
205
219
}
0 commit comments