@@ -195,7 +195,11 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
195
195
_at.write_int (_cid);
196
196
_at.write_int (request_connect_id);
197
197
_at.write_string (" UDP SERVICE" );
198
- _at.write_string (" 127.0.0.1" );
198
+ if (_stack_type == IPV4_STACK) {
199
+ _at.write_string (" 127.0.0.1" );
200
+ } else if (_stack_type == IPV6_STACK || _stack_type == IPV4V6_STACK) {
201
+ _at.write_string (" 0:0:0:0:0:0:0:1" );
202
+ }
199
203
_at.write_int (remote_port);
200
204
_at.write_int (socket->localAddress .get_port ());
201
205
_at.write_int (0 );
@@ -208,15 +212,18 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
208
212
socket->id = -1 ;
209
213
return NSAPI_ERROR_PARAMETER;
210
214
}
211
- _at.cmd_start (" AT+QICLOSE=" );
212
- _at.write_int (modem_connect_id);
213
- _at.cmd_stop_read_resp ();
215
+ socket_close_impl (modem_connect_id);
214
216
215
217
_at.cmd_start (" AT+QIOPEN=" );
216
218
_at.write_int (_cid);
217
219
_at.write_int (request_connect_id);
218
220
_at.write_string (" UDP SERVICE" );
219
- _at.write_string (" 127.0.0.1" );
221
+
222
+ if (_stack_type == IPV4_STACK) {
223
+ _at.write_string (" 127.0.0.1" );
224
+ } else if (_stack_type == IPV6_STACK || _stack_type == IPV4V6_STACK) {
225
+ _at.write_string (" 0:0:0:0:0:0:0:1" );
226
+ }
220
227
_at.write_int (remote_port);
221
228
_at.write_int (socket->localAddress .get_port ());
222
229
_at.write_int (0 );
@@ -240,9 +247,7 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
240
247
socket->id = -1 ;
241
248
return NSAPI_ERROR_PARAMETER;
242
249
}
243
- _at.cmd_start (" AT+QICLOSE=" );
244
- _at.write_int (modem_connect_id);
245
- _at.cmd_stop_read_resp ();
250
+ socket_close_impl (modem_connect_id);
246
251
247
252
_at.cmd_start (" AT+QIOPEN=" );
248
253
_at.write_int (_cid);
@@ -258,9 +263,7 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
258
263
259
264
// If opened successfully BUT not requested one, close it
260
265
if (!err && (modem_connect_id != request_connect_id)) {
261
- _at.cmd_start (" AT+QICLOSE=" );
262
- _at.write_int (modem_connect_id);
263
- _at.cmd_stop_read_resp ();
266
+ socket_close_impl (modem_connect_id);
264
267
}
265
268
266
269
nsapi_error_t ret_val = _at.get_last_error ();
0 commit comments