Skip to content

Commit

Permalink
PR review fix:
Browse files Browse the repository at this point in the history
- bind behaviour to not change existing port or address if the requested ones are 0
- removed temporary array setting to zero
  • Loading branch information
Mirela Chirica committed Feb 15, 2018
1 parent 3c33251 commit 5e04288
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion features/cellular/framework/AT/ATHandler.cpp
Expand Up @@ -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(...)
Expand Down
9 changes: 6 additions & 3 deletions features/cellular/framework/AT/AT_CellularStack.cpp
Expand Up @@ -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();
Expand Down
Expand Up @@ -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);
Expand Down

0 comments on commit 5e04288

Please sign in to comment.