mirror of https://github.com/ARMmbed/mbed-os.git
Merge branch 'ublox-cellular-api' of ssh://github.com/u-blox/mbed-os into u-blox-ublox-cellular-api
commit
aaead00218
|
@ -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)
|
nsapi_error_t UBLOX_AT_CellularStack::create_socket_impl(CellularSocket *socket)
|
||||||
{
|
{
|
||||||
int sock_id = 0;
|
int sock_id = 0;
|
||||||
bool socketOpenWorking = false;
|
|
||||||
|
|
||||||
_at.lock();
|
_at.lock();
|
||||||
if (socket->proto == NSAPI_UDP) {
|
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();
|
sock_id = _at.read_int();
|
||||||
_at.resp_stop();
|
_at.resp_stop();
|
||||||
} // Unsupported protocol is checked in "is_protocol_supported" function
|
} // Unsupported protocol is checked in "is_protocol_supported" function
|
||||||
_at.unlock();
|
|
||||||
|
|
||||||
socketOpenWorking = (_at.get_last_error() == NSAPI_ERROR_OK);
|
if ((_at.get_last_error() != NSAPI_ERROR_OK) || (sock_id == -1)) {
|
||||||
if (!socketOpenWorking) {
|
_at.unlock();
|
||||||
return NSAPI_ERROR_NO_SOCKET;
|
return NSAPI_ERROR_NO_SOCKET;
|
||||||
}
|
}
|
||||||
|
_at.unlock();
|
||||||
|
|
||||||
// Check for duplicate socket id delivered by modem
|
// Check for duplicate socket id delivered by modem
|
||||||
for (int i = 0; i < UBLOX_MAX_SOCKET; i++) {
|
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;
|
CellularSocket *socket = (CellularSocket *)handle;
|
||||||
|
|
||||||
if (!socket->created) {
|
if (socket) {
|
||||||
create_socket_impl(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();
|
_at.lock();
|
||||||
|
|
Loading…
Reference in New Issue