PR review fix:

- bind behaviour to not change existing port or address if the requested ones are 0
- removed temporary array setting to zero
pull/6082/head
Mirela Chirica 2018-02-15 15:51:32 +02:00 committed by Ari Parkkila
parent 71f54bc2d4
commit d15801d893
3 changed files with 8 additions and 5 deletions

View File

@ -32,7 +32,7 @@ using namespace events;
#include "CellularLog.h"
// this is intentionally TRACE_LEVEL_INFO
#if MBED_TRACE_MAX_LEVEL <= TRACE_LEVEL_INFO
#if MBED_TRACE_MAX_LEVEL >= TRACE_LEVEL_INFO
#define at_debug(format, ...) do { if (_debug_on) debug(format, ## __VA_ARGS__); } while (0)
#else
#define at_debug(...)

View File

@ -169,10 +169,13 @@ nsapi_error_t AT_CellularStack::socket_bind(nsapi_socket_t handle, const SocketA
if (!socket) {
return NSAPI_ERROR_DEVICE_ERROR;
}
socket->localAddress = addr;
if (socket->localAddress.get_port() == 0) {
socket->localAddress.set_port(get_dynamic_ip_port());
if (addr) {
socket->localAddress.set_addr(addr.get_addr());
}
if (addr.get_port()) {
socket->localAddress.set_port(addr.get_port());
}
_at.lock();

View File

@ -167,7 +167,7 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_recvfrom_impl(CellularS
nsapi_size_or_error_t recv_len=0;
int port;
char ip_address[NSAPI_IP_SIZE];
char hexstr[BC95_MAX_PACKET_SIZE*2 + 1] = {0};
char hexstr[BC95_MAX_PACKET_SIZE*2 + 1];
_at.cmd_start("AT+NSORF=");
_at.write_int(socket->id);