Skip to content

Commit daafb95

Browse files
authored
Merge pull request #11538 from mirelachirica/ipv6_to_wise_1570
Cellular: Enable IPV6 for WISE_1570
2 parents 1f5a124 + 090ce03 commit daafb95

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
4040
1, // AT_CMGF
4141
1, // AT_CSDH
4242
1, // PROPERTY_IPV4_STACK
43-
0, // PROPERTY_IPV6_STACK
43+
1, // PROPERTY_IPV6_STACK
4444
0, // PROPERTY_IPV4V6_STACK
4545
0, // PROPERTY_NON_IP_PDP_TYPE
4646
0, // PROPERTY_AT_CGEREP

features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ nsapi_error_t QUECTEL_BC95_CellularStack::create_socket_impl(CellularSocket *soc
142142
bool socketOpenWorking = false;
143143

144144
if (socket->proto == NSAPI_UDP) {
145-
_at.cmd_start_stop("+NSOCR", "=DGRAM,", "%d%d%d", 17, socket->localAddress.get_port(), 1);
145+
_at.cmd_start_stop("+NSOCR", "=DGRAM,", "%d%d%d%s", 17, socket->localAddress.get_port(), 1, ((_ip_ver_sendto == NSAPI_IPv4) ? "AF_INET" : "AF_INET6"));
146146
} else if (socket->proto == NSAPI_TCP) {
147-
_at.cmd_start_stop("+NSOCR", "=STREAM,", "%d%d%d", 6, socket->localAddress.get_port(), 1);
147+
_at.cmd_start_stop("+NSOCR", "=STREAM,", "%d%d%d%s", 6, socket->localAddress.get_port(), 1, ((_ip_ver_sendto == NSAPI_IPv4) ? "AF_INET" : "AF_INET6"));
148148
} else {
149149
return NSAPI_ERROR_PARAMETER;
150150
}
@@ -173,6 +173,12 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_sendto_impl(CellularSoc
173173
// open already.
174174
MBED_ASSERT(socket->id != -1);
175175

176+
if (_ip_ver_sendto != address.get_ip_version()) {
177+
_ip_ver_sendto = address.get_ip_version();
178+
socket_close_impl(socket->id);
179+
create_socket_impl(socket);
180+
}
181+
176182
int sent_len = 0;
177183

178184
if (size > PACKET_SIZE_MAX) {

0 commit comments

Comments
 (0)