Merge branch 'u-blox-ublox-cellular-api' into rollup2

pull/8423/head
Cruz Monrreal II 2018-10-12 21:46:39 -05:00
commit 304059d039
1 changed files with 12 additions and 6 deletions

View File

@ -119,7 +119,6 @@ bool UBLOX_AT_CellularStack::is_protocol_supported(nsapi_protocol_t protocol)
nsapi_error_t UBLOX_AT_CellularStack::create_socket_impl(CellularSocket *socket)
{
int sock_id = 0;
bool socketOpenWorking = false;
_at.lock();
if (socket->proto == NSAPI_UDP) {
@ -137,12 +136,12 @@ nsapi_error_t UBLOX_AT_CellularStack::create_socket_impl(CellularSocket *socket)
sock_id = _at.read_int();
_at.resp_stop();
} // Unsupported protocol is checked in "is_protocol_supported" function
_at.unlock();
socketOpenWorking = (_at.get_last_error() == NSAPI_ERROR_OK);
if (!socketOpenWorking) {
if ((_at.get_last_error() != NSAPI_ERROR_OK) || (sock_id == -1)) {
_at.unlock();
return NSAPI_ERROR_NO_SOCKET;
}
_at.unlock();
// Check for duplicate socket id delivered by modem
for (int i = 0; i < UBLOX_MAX_SOCKET; i++) {
@ -162,8 +161,15 @@ nsapi_error_t UBLOX_AT_CellularStack::socket_connect(nsapi_socket_t handle, cons
{
CellularSocket *socket = (CellularSocket *)handle;
if (!socket->created) {
create_socket_impl(socket);
if (socket) {
if (!socket->created) {
nsapi_error_t err = create_socket_impl(socket);
if(err != NSAPI_ERROR_OK) {
return err;
}
}
} else {
return NSAPI_ERROR_DEVICE_ERROR;
}
_at.lock();