@@ -189,7 +189,11 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
189
189
_at.write_int (_cid);
190
190
_at.write_int (request_connect_id);
191
191
_at.write_string (" UDP SERVICE" );
192
- _at.write_string (" 127.0.0.1" );
192
+ if (_stack_type == IPV4_STACK) {
193
+ _at.write_string (" 127.0.0.1" );
194
+ } else if (_stack_type == IPV6_STACK || _stack_type == IPV4V6_STACK) {
195
+ _at.write_string (" 0:0:0:0:0:0:0:1" );
196
+ }
193
197
_at.write_int (remote_port);
194
198
_at.write_int (socket->localAddress .get_port ());
195
199
_at.write_int (0 );
@@ -202,15 +206,18 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
202
206
socket->created = false ;
203
207
return NSAPI_ERROR_PARAMETER;
204
208
}
205
- _at.cmd_start (" AT+QICLOSE=" );
206
- _at.write_int (modem_connect_id);
207
- _at.cmd_stop_read_resp ();
209
+ socket_close_impl (modem_connect_id);
208
210
209
211
_at.cmd_start (" AT+QIOPEN=" );
210
212
_at.write_int (_cid);
211
213
_at.write_int (request_connect_id);
212
214
_at.write_string (" UDP SERVICE" );
213
- _at.write_string (" 127.0.0.1" );
215
+
216
+ if (_stack_type == IPV4_STACK) {
217
+ _at.write_string (" 127.0.0.1" );
218
+ } else if (_stack_type == IPV6_STACK || _stack_type == IPV4V6_STACK) {
219
+ _at.write_string (" 0:0:0:0:0:0:0:1" );
220
+ }
214
221
_at.write_int (remote_port);
215
222
_at.write_int (socket->localAddress .get_port ());
216
223
_at.write_int (0 );
@@ -234,9 +241,7 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
234
241
socket->created = false ;
235
242
return NSAPI_ERROR_PARAMETER;
236
243
}
237
- _at.cmd_start (" AT+QICLOSE=" );
238
- _at.write_int (modem_connect_id);
239
- _at.cmd_stop_read_resp ();
244
+ socket_close_impl (modem_connect_id);
240
245
241
246
_at.cmd_start (" AT+QIOPEN=" );
242
247
_at.write_int (_cid);
@@ -252,9 +257,7 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
252
257
253
258
// If opened successfully BUT not requested one, close it
254
259
if (!err && (modem_connect_id != request_connect_id)) {
255
- _at.cmd_start (" AT+QICLOSE=" );
256
- _at.write_int (modem_connect_id);
257
- _at.cmd_stop_read_resp ();
260
+ socket_close_impl (modem_connect_id);
258
261
}
259
262
260
263
nsapi_error_t ret_val = _at.get_last_error ();
0 commit comments