Skip to content

Commit

Permalink
[PATCH 1/2] [PATCH] Add a check step of IPv6 network to BG96
Browse files Browse the repository at this point in the history
Need to check IPv6 address when use IPv6 network via BG96.

Signed-off-by: Daniel Lee <daniel.lee2@arm.com>
  • Loading branch information
Daniel Lee committed Jun 4, 2019
1 parent 51d5550 commit 6c43e63
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
_at.write_int(_cid);
_at.write_int(request_connect_id);
_at.write_string("UDP SERVICE");
_at.write_string("127.0.0.1");
if (_stack_type == IPV4_STACK) {
_at.write_string("127.0.0.1");
} else if (_stack_type == IPV6_STACK || _stack_type == IPV4V6_STACK) {
_at.write_string("0:0:0:0:0:0:0:1");
}
_at.write_int(remote_port);
_at.write_int(socket->localAddress.get_port());
_at.write_int(0);
Expand All @@ -186,15 +190,18 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
socket->created = false;
return NSAPI_ERROR_PARAMETER;
}
_at.cmd_start("AT+QICLOSE=");
_at.write_int(modem_connect_id);
_at.cmd_stop_read_resp();
socket_close_impl(modem_connect_id);

_at.cmd_start("AT+QIOPEN=");
_at.write_int(_cid);
_at.write_int(request_connect_id);
_at.write_string("UDP SERVICE");
_at.write_string("127.0.0.1");

if (_stack_type == IPV4_STACK) {
_at.write_string("127.0.0.1");
} else if (_stack_type == IPV6_STACK || _stack_type == IPV4V6_STACK) {
_at.write_string("0:0:0:0:0:0:0:1");
}
_at.write_int(remote_port);
_at.write_int(socket->localAddress.get_port());
_at.write_int(0);
Expand All @@ -218,9 +225,7 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
socket->created = false;
return NSAPI_ERROR_PARAMETER;
}
_at.cmd_start("AT+QICLOSE=");
_at.write_int(modem_connect_id);
_at.cmd_stop_read_resp();
socket_close_impl(modem_connect_id);

_at.cmd_start("AT+QIOPEN=");
_at.write_int(_cid);
Expand All @@ -236,9 +241,7 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc

// If opened successfully BUT not requested one, close it
if (!err && (modem_connect_id != request_connect_id)) {
_at.cmd_start("AT+QICLOSE=");
_at.write_int(modem_connect_id);
_at.cmd_stop_read_resp();
socket_close_impl(modem_connect_id);
}

nsapi_error_t ret_val = _at.get_last_error();
Expand Down

0 comments on commit 6c43e63

Please sign in to comment.