@@ -35,6 +35,7 @@ class MyStack : public AT_CellularStack {
35
35
bool max_sock_value;
36
36
nsapi_error_t create_error;
37
37
int max_packet_size;
38
+ CellularSocket socket;
38
39
39
40
MyStack (ATHandler &atr, int cid, nsapi_ip_stack_t typ) : AT_CellularStack(atr, cid, typ)
40
41
{
@@ -143,14 +144,14 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_open()
143
144
144
145
st.bool_value = true ;
145
146
st.max_sock_value = 0 ;
146
- nsapi_socket_t sock;
147
+ nsapi_socket_t sock = &st. socket ;
147
148
CHECK (NSAPI_ERROR_NO_SOCKET == st.socket_open (&sock, NSAPI_TCP));
148
149
149
150
MyStack st2 (at, 0 , IPV6_STACK);
150
151
st2.bool_value = true ;
151
152
st2.max_sock_value = 1 ;
152
- nsapi_socket_t sock2 ;
153
- CHECK (NSAPI_ERROR_OK == st2.socket_open (&sock2 , NSAPI_TCP));
153
+ sock = &st2. socket ;
154
+ CHECK (NSAPI_ERROR_OK == st2.socket_open (&sock , NSAPI_TCP));
154
155
}
155
156
156
157
void Test_AT_CellularStack::test_AT_CellularStack_socket_close ()
@@ -160,22 +161,21 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_close()
160
161
ATHandler at (&fh1, que, 0 , " ," );
161
162
162
163
MyStack st (at, 0 , IPV6_STACK);
163
- nsapi_socket_t soc = NULL ;
164
- CHECK (NSAPI_ERROR_DEVICE_ERROR == st.socket_close (soc));
164
+ CHECK (NSAPI_ERROR_DEVICE_ERROR == st.socket_close (&st.socket ));
165
165
166
+ nsapi_socket_t sock = &st.socket ;
166
167
st.bool_value = true ;
167
168
st.max_sock_value = 1 ;
168
- nsapi_socket_t sock;
169
169
CHECK (NSAPI_ERROR_OK == st.socket_open (&sock, NSAPI_TCP));
170
170
st.max_sock_value = 0 ;
171
171
CHECK (NSAPI_ERROR_DEVICE_ERROR == st.socket_close (sock));
172
172
173
173
MyStack st2 (at, 0 , IPV6_STACK);
174
174
st2.max_sock_value = 1 ;
175
175
st2.bool_value = true ;
176
- nsapi_socket_t sock2 ;
177
- CHECK (NSAPI_ERROR_OK == st2.socket_open (&sock2 , NSAPI_TCP));
178
- CHECK (NSAPI_ERROR_OK == st2.socket_close (sock2 ));
176
+ sock = &st2. socket ;
177
+ CHECK (NSAPI_ERROR_OK == st2.socket_open (&sock , NSAPI_TCP));
178
+ CHECK (NSAPI_ERROR_OK == st2.socket_close (sock ));
179
179
}
180
180
181
181
void Test_AT_CellularStack::test_AT_CellularStack_socket_bind ()
@@ -185,12 +185,11 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_bind()
185
185
ATHandler at (&fh1, que, 0 , " ," );
186
186
187
187
MyStack st (at, 0 , IPV6_STACK);
188
- nsapi_socket_t sock;
189
188
SocketAddress addr;
190
189
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_ALREADY;
191
190
CHECK (NSAPI_ERROR_DEVICE_ERROR == st.socket_bind (NULL , addr));
192
191
193
- CHECK (NSAPI_ERROR_ALREADY == st.socket_bind (sock , addr));
192
+ CHECK (NSAPI_ERROR_ALREADY == st.socket_bind (&st. socket , addr));
194
193
}
195
194
196
195
void Test_AT_CellularStack::test_AT_CellularStack_socket_listen ()
@@ -200,8 +199,7 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_listen()
200
199
ATHandler at (&fh1, que, 0 , " ," );
201
200
202
201
MyStack st (at, 0 , IPV6_STACK);
203
- nsapi_socket_t sock;
204
- CHECK (0 == st.socket_listen (sock, 4 ));
202
+ CHECK (NSAPI_ERROR_UNSUPPORTED == st.socket_listen (&st.socket , 4 ));
205
203
}
206
204
207
205
void Test_AT_CellularStack::test_AT_CellularStack_socket_connect ()
@@ -214,8 +212,7 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_connect()
214
212
SocketAddress addr;
215
213
CHECK (NSAPI_ERROR_DEVICE_ERROR == st.socket_connect (NULL , addr));
216
214
217
- nsapi_socket_t sock;
218
- CHECK (NSAPI_ERROR_OK == st.socket_connect (sock, addr));
215
+ CHECK (NSAPI_ERROR_OK == st.socket_connect (&st.socket , addr));
219
216
}
220
217
221
218
void Test_AT_CellularStack::test_AT_CellularStack_socket_accept ()
@@ -225,8 +222,8 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_accept()
225
222
ATHandler at (&fh1, que, 0 , " ," );
226
223
227
224
MyStack st (at, 0 , IPV6_STACK);
228
- nsapi_socket_t sock;
229
- CHECK (0 == st.socket_accept (NULL , &sock));
225
+ nsapi_socket_t sock = &st. socket ;
226
+ CHECK (NSAPI_ERROR_UNSUPPORTED == st.socket_accept (NULL , &sock));
230
227
}
231
228
232
229
void Test_AT_CellularStack::test_AT_CellularStack_socket_send ()
@@ -238,12 +235,12 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_send()
238
235
MyStack st (at, 0 , IPV6_STACK);
239
236
CHECK (NSAPI_ERROR_DEVICE_ERROR == st.socket_send (NULL , " addr" , 4 ));
240
237
241
- nsapi_socket_t sock;
242
- CHECK (NSAPI_ERROR_DEVICE_ERROR == st.socket_send (sock, " addr" , 4 ));
238
+ CHECK (NSAPI_ERROR_DEVICE_ERROR == st.socket_send (&st.socket , " addr" , 4 ));
243
239
244
240
SocketAddress addr;
245
241
st.max_sock_value = 1 ;
246
242
st.bool_value = true ;
243
+ nsapi_socket_t sock = &st.socket ;
247
244
st.socket_open (&sock, NSAPI_TCP);
248
245
st.socket_connect (sock, addr);
249
246
CHECK (NSAPI_ERROR_DEVICE_ERROR == st.socket_send (sock, " addr" , 4 ));
@@ -257,12 +254,12 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_sendto()
257
254
258
255
MyStack st (at, 0 , IPV6_STACK);
259
256
260
- nsapi_socket_t sock;
261
257
SocketAddress addr;
262
258
CHECK (NSAPI_ERROR_DEVICE_ERROR == st.socket_sendto (NULL , addr, " addr" , 4 ));
263
259
264
260
st.max_sock_value = 1 ;
265
261
st.bool_value = true ;
262
+ nsapi_socket_t sock = &st.socket ;
266
263
st.socket_open (&sock, NSAPI_TCP);
267
264
st.socket_connect (sock, addr);
268
265
st.create_error = NSAPI_ERROR_CONNECTION_LOST;
@@ -294,10 +291,10 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_recvfrom()
294
291
char table[4 ];
295
292
CHECK (NSAPI_ERROR_DEVICE_ERROR == st.socket_recvfrom (NULL , NULL , table, 4 ));
296
293
297
- nsapi_socket_t sock;
298
294
SocketAddress addr;
299
295
st.max_sock_value = 1 ;
300
296
st.bool_value = true ;
297
+ nsapi_socket_t sock = &st.socket ;
301
298
st.socket_open (&sock, NSAPI_TCP);
302
299
st.socket_connect (sock, addr);
303
300
st.create_error = NSAPI_ERROR_CONNECTION_LOST;
@@ -317,9 +314,9 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_attach()
317
314
MyStack st (at, 0 , IPV6_STACK);
318
315
319
316
st.socket_attach (NULL , NULL , NULL );
320
- nsapi_socket_t sock;
321
317
st.max_sock_value = 1 ;
322
318
st.bool_value = true ;
319
+ nsapi_socket_t sock = &st.socket ;
323
320
st.socket_open (&sock, NSAPI_TCP);
324
321
st.socket_attach (sock, NULL , NULL );
325
322
}
0 commit comments