@@ -142,9 +142,9 @@ nsapi_error_t QUECTEL_BC95_CellularStack::create_socket_impl(CellularSocket *soc
142
142
bool socketOpenWorking = false ;
143
143
144
144
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 " ) );
146
146
} 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 " ) );
148
148
} else {
149
149
return NSAPI_ERROR_PARAMETER;
150
150
}
@@ -173,6 +173,12 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_sendto_impl(CellularSoc
173
173
// open already.
174
174
MBED_ASSERT (socket->id != -1 );
175
175
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
+
176
182
int sent_len = 0 ;
177
183
178
184
if (size > PACKET_SIZE_MAX) {
0 commit comments