Skip to content

Commit 26c3bcf

Browse files
author
Daniel Lee
committed
Add a check step of IPv6 network to BG96
Need to check IPv6 address when use IPv6 network via BG96. Signed-off-by: Daniel Lee <[email protected]>
1 parent 46603f8 commit 26c3bcf

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
@@ -189,7 +189,11 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
189189
_at.write_int(_cid);
190190
_at.write_int(request_connect_id);
191191
_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+
}
193197
_at.write_int(remote_port);
194198
_at.write_int(socket->localAddress.get_port());
195199
_at.write_int(0);
@@ -202,15 +206,18 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
202206
socket->created = false;
203207
return NSAPI_ERROR_PARAMETER;
204208
}
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);
208210

209211
_at.cmd_start("AT+QIOPEN=");
210212
_at.write_int(_cid);
211213
_at.write_int(request_connect_id);
212214
_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+
}
214221
_at.write_int(remote_port);
215222
_at.write_int(socket->localAddress.get_port());
216223
_at.write_int(0);
@@ -234,9 +241,7 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
234241
socket->created = false;
235242
return NSAPI_ERROR_PARAMETER;
236243
}
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);
240245

241246
_at.cmd_start("AT+QIOPEN=");
242247
_at.write_int(_cid);
@@ -252,9 +257,7 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
252257

253258
// If opened successfully BUT not requested one, close it
254259
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);
258261
}
259262

260263
nsapi_error_t ret_val = _at.get_last_error();

0 commit comments

Comments
 (0)