Skip to content

Commit 51b835b

Browse files
authored
Merge pull request #10473 from DanielDmlee/BG96_IPV6_only
Add exception case for IPV6 only mode of BG96.
2 parents 3801d4a + 26c3bcf commit 51b835b

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,11 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
195195
_at.write_int(_cid);
196196
_at.write_int(request_connect_id);
197197
_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+
}
199203
_at.write_int(remote_port);
200204
_at.write_int(socket->localAddress.get_port());
201205
_at.write_int(0);
@@ -208,15 +212,18 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
208212
socket->id = -1;
209213
return NSAPI_ERROR_PARAMETER;
210214
}
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);
214216

215217
_at.cmd_start("AT+QIOPEN=");
216218
_at.write_int(_cid);
217219
_at.write_int(request_connect_id);
218220
_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+
}
220227
_at.write_int(remote_port);
221228
_at.write_int(socket->localAddress.get_port());
222229
_at.write_int(0);
@@ -240,9 +247,7 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
240247
socket->id = -1;
241248
return NSAPI_ERROR_PARAMETER;
242249
}
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);
246251

247252
_at.cmd_start("AT+QIOPEN=");
248253
_at.write_int(_cid);
@@ -258,9 +263,7 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
258263

259264
// If opened successfully BUT not requested one, close it
260265
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);
264267
}
265268

266269
nsapi_error_t ret_val = _at.get_last_error();

0 commit comments

Comments
 (0)