Skip to content

Commit 122e771

Browse files
socket_open function removed
1 parent ffb4f92 commit 122e771

File tree

2 files changed

+2
-53
lines changed

2 files changed

+2
-53
lines changed

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

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -117,55 +117,6 @@ bool UBLOX_AT_CellularStack::is_protocol_supported(nsapi_protocol_t protocol)
117117
return (protocol == NSAPI_UDP || protocol == NSAPI_TCP);
118118
}
119119

120-
nsapi_error_t UBLOX_AT_CellularStack::socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto)
121-
{
122-
if (!is_protocol_supported(proto) || !handle) {
123-
return NSAPI_ERROR_UNSUPPORTED;
124-
}
125-
126-
int max_socket_count = get_max_socket_count();
127-
128-
if (!_socket) {
129-
_socket = new CellularSocket*[max_socket_count];
130-
if (!_socket) {
131-
return NSAPI_ERROR_NO_SOCKET;
132-
}
133-
_socket_count = max_socket_count;
134-
for (int i = 0; i < max_socket_count; i++) {
135-
_socket[i] = 0;
136-
}
137-
}
138-
139-
int index = -1;
140-
for (int i = 0; i < max_socket_count; i++) {
141-
if (!_socket[i]) {
142-
index = i;
143-
break;
144-
}
145-
}
146-
147-
if (index == -1) {
148-
return NSAPI_ERROR_NO_SOCKET;
149-
}
150-
151-
// create local socket structure, socket on modem is created when app calls sendto/recvfrom
152-
_socket[index] = new CellularSocket;
153-
CellularSocket *psock;
154-
psock = _socket[index];
155-
memset(psock, 0, sizeof(CellularSocket));
156-
SocketAddress addr(0, get_dynamic_ip_port());
157-
psock->id = index;
158-
psock->localAddress = addr;
159-
psock->proto = proto;
160-
nsapi_error_t err = create_socket_impl(psock);
161-
162-
if (err == NSAPI_ERROR_OK) {
163-
*handle = psock;
164-
}
165-
166-
return err;
167-
}
168-
169120
nsapi_error_t UBLOX_AT_CellularStack::create_socket_impl(CellularSocket *socket)
170121
{
171122
int sock_id = 0;
@@ -212,8 +163,8 @@ nsapi_error_t UBLOX_AT_CellularStack::socket_connect(nsapi_socket_t handle, cons
212163
{
213164
CellularSocket *socket = (CellularSocket *)handle;
214165

215-
if (!socket) {
216-
return NSAPI_ERROR_DEVICE_ERROR;
166+
if (!socket->created) {
167+
create_socket_impl(socket);
217168
}
218169

219170
_at.lock();

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ class UBLOX_AT_CellularStack : public AT_CellularStack
7373

7474
virtual bool is_protocol_supported(nsapi_protocol_t protocol);
7575

76-
virtual nsapi_error_t socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto);
77-
7876
virtual nsapi_error_t create_socket_impl(CellularSocket *socket);
7977

8078
virtual nsapi_error_t socket_connect(nsapi_socket_t handle, const SocketAddress &address);

0 commit comments

Comments
 (0)