Skip to content

Commit 304059d

Browse files
Cruz Monrreal IICruz Monrreal II
authored andcommitted
Merge branch 'u-blox-ublox-cellular-api' into rollup2
2 parents 6ea0da2 + aaead00 commit 304059d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularStack.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ bool UBLOX_AT_CellularStack::is_protocol_supported(nsapi_protocol_t protocol)
119119
nsapi_error_t UBLOX_AT_CellularStack::create_socket_impl(CellularSocket *socket)
120120
{
121121
int sock_id = 0;
122-
bool socketOpenWorking = false;
123122

124123
_at.lock();
125124
if (socket->proto == NSAPI_UDP) {
@@ -137,12 +136,12 @@ nsapi_error_t UBLOX_AT_CellularStack::create_socket_impl(CellularSocket *socket)
137136
sock_id = _at.read_int();
138137
_at.resp_stop();
139138
} // Unsupported protocol is checked in "is_protocol_supported" function
140-
_at.unlock();
141139

142-
socketOpenWorking = (_at.get_last_error() == NSAPI_ERROR_OK);
143-
if (!socketOpenWorking) {
140+
if ((_at.get_last_error() != NSAPI_ERROR_OK) || (sock_id == -1)) {
141+
_at.unlock();
144142
return NSAPI_ERROR_NO_SOCKET;
145143
}
144+
_at.unlock();
146145

147146
// Check for duplicate socket id delivered by modem
148147
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
162161
{
163162
CellularSocket *socket = (CellularSocket *)handle;
164163

165-
if (!socket->created) {
166-
create_socket_impl(socket);
164+
if (socket) {
165+
if (!socket->created) {
166+
nsapi_error_t err = create_socket_impl(socket);
167+
if(err != NSAPI_ERROR_OK) {
168+
return err;
169+
}
170+
}
171+
} else {
172+
return NSAPI_ERROR_DEVICE_ERROR;
167173
}
168174

169175
_at.lock();

0 commit comments

Comments
 (0)