diff --git a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp old mode 100644 new mode 100755 index 719ed5e249..7ad3892e22 --- a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp +++ b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp @@ -50,9 +50,13 @@ nsapi_error_t QUECTEL_BG96_CellularStack::socket_connect(nsapi_socket_t handle, CellularSocket *socket = (CellularSocket *)handle; int modem_connect_id = -1; - int request_connect_id = socket->id; int err = -1; + int request_connect_id = find_socket_index(socket); + // assert here as its a programming error if the socket container doesn't contain + // specified handle + MBED_ASSERT(request_connect_id != -1); + _at.lock(); if (socket->proto == NSAPI_TCP) { _at.cmd_start("AT+QIOPEN="); diff --git a/features/cellular/framework/targets/QUECTEL/M26/QUECTEL_M26_CellularStack.cpp b/features/cellular/framework/targets/QUECTEL/M26/QUECTEL_M26_CellularStack.cpp old mode 100644 new mode 100755 index d6b65fd115..2bd7434ab0 --- a/features/cellular/framework/targets/QUECTEL/M26/QUECTEL_M26_CellularStack.cpp +++ b/features/cellular/framework/targets/QUECTEL/M26/QUECTEL_M26_CellularStack.cpp @@ -302,12 +302,14 @@ nsapi_error_t QUECTEL_M26_CellularStack::socket_connect(nsapi_socket_t handle, c { CellularSocket *socket = (CellularSocket *)handle; - MBED_ASSERT(socket->id != -1); - int modem_connect_id = -1; - int request_connect_id = socket->id; int err = -1; + int request_connect_id = find_socket_index(socket); + // assert here as its a programming error if the socket container doesn't contain + // specified handle + MBED_ASSERT(request_connect_id != -1); + _at.lock(); if (socket->proto == NSAPI_TCP) { _at.cmd_start("AT+QIOPEN=");