@@ -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