From d15801d8936eb95437b1ff768c217654652f0c93 Mon Sep 17 00:00:00 2001 From: Mirela Chirica Date: Thu, 15 Feb 2018 15:51:32 +0200 Subject: [PATCH] PR review fix: - bind behaviour to not change existing port or address if the requested ones are 0 - removed temporary array setting to zero --- features/cellular/framework/AT/ATHandler.cpp | 2 +- features/cellular/framework/AT/AT_CellularStack.cpp | 9 ++++++--- .../targets/QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/features/cellular/framework/AT/ATHandler.cpp b/features/cellular/framework/AT/ATHandler.cpp index b82176f229..dbd9672e1b 100644 --- a/features/cellular/framework/AT/ATHandler.cpp +++ b/features/cellular/framework/AT/ATHandler.cpp @@ -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(...) diff --git a/features/cellular/framework/AT/AT_CellularStack.cpp b/features/cellular/framework/AT/AT_CellularStack.cpp index 0a03528600..6fd0f123e4 100644 --- a/features/cellular/framework/AT/AT_CellularStack.cpp +++ b/features/cellular/framework/AT/AT_CellularStack.cpp @@ -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(); diff --git a/features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp b/features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp index c9e63c8331..bf4d208e4c 100644 --- a/features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp +++ b/features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp @@ -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);