25
25
#define UDP_PACKET_SIZE 1460
26
26
#define FAILURE_TIMEOUT (30 *1000 ) // failure timeout in milliseconds on modem side
27
27
28
- /*
29
- * Use connection profile 0 and Internet service profiles starting from 0 for sockets.
30
- */
31
- #define CONNECTION_PROFILE_ID 0
32
-
33
28
using namespace mbed ;
34
29
35
30
GEMALTO_CINTERION_CellularStack::GEMALTO_CINTERION_CellularStack (ATHandler &atHandler, const char *apn, const char *user, const char *password,
@@ -109,8 +104,7 @@ void GEMALTO_CINTERION_CellularStack::sisr_urc_handler(int sock_id, int urc_code
109
104
nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_stack_init ()
110
105
{
111
106
_at.lock ();
112
- int connection_profile_id = CONNECTION_PROFILE_ID;
113
- nsapi_error_t err = create_connection_profile (connection_profile_id);
107
+ nsapi_error_t err = create_connection_profile (_cid);
114
108
if (!err) {
115
109
_at.set_urc_handler (" ^SIS:" , mbed::Callback<void ()>(this , &GEMALTO_CINTERION_CellularStack::urc_sis));
116
110
_at.set_urc_handler (" ^SISW:" , mbed::Callback<void ()>(this , &GEMALTO_CINTERION_CellularStack::urc_sisw));
@@ -122,7 +116,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_stack_init()
122
116
socket_close_impl (i);
123
117
}
124
118
_at.clear_error ();
125
- close_connection_profile (connection_profile_id );
119
+ close_connection_profile (_cid );
126
120
}
127
121
_at.unlock ();
128
122
return err;
@@ -157,8 +151,6 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_close_impl(int sock_id)
157
151
158
152
nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer (CellularSocket *socket, const SocketAddress *address)
159
153
{
160
- int connection_profile_id = CONNECTION_PROFILE_ID;
161
-
162
154
int retry_open = 1 ;
163
155
retry_open:
164
156
// setup internet session profile
@@ -193,7 +185,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer(CellularSocket
193
185
}
194
186
if (strcmp (paramTag, " conId" ) == 0 ) {
195
187
char buf[10 ];
196
- std::sprintf (buf, " %d" , connection_profile_id );
188
+ std::sprintf (buf, " %d" , _cid );
197
189
if (strcmp (paramValue, buf) == 0 ) {
198
190
foundConIdType = true ;
199
191
}
@@ -209,7 +201,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer(CellularSocket
209
201
}
210
202
211
203
if (!foundConIdType) {
212
- _at.at_cmd_discard (" ^SISS" , " =" , " %d%s%d" , internet_service_id, " conId" , connection_profile_id );
204
+ _at.at_cmd_discard (" ^SISS" , " =" , " %d%s%d" , internet_service_id, " conId" , _cid );
213
205
}
214
206
215
207
// host address (IPv4) and local+remote port is needed only for BGS2 which does not support UDP server socket
@@ -238,7 +230,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer(CellularSocket
238
230
_at.at_cmd_discard (" ^SISO" , " =" , " %d" , internet_service_id);
239
231
240
232
if (_at.get_last_error ()) {
241
- tr_error (" Socket %d open failed!" , socket-> id );
233
+ tr_error (" Socket %d open failed!" , internet_service_id );
242
234
_at.clear_error ();
243
235
socket_close_impl (internet_service_id); // socket may already be open on modem if app and modem are not in sync, as a recovery, try to close the socket so open succeeds the next time
244
236
if (retry_open--) {
@@ -390,7 +382,7 @@ nsapi_size_or_error_t GEMALTO_CINTERION_CellularStack::socket_recvfrom_impl(Cell
390
382
if (!socket->pending_bytes ) {
391
383
_at.process_oob (); // check for ^SISR URC
392
384
if (!socket->pending_bytes ) {
393
- tr_debug (" Socekt %d recv would block" , socket->id );
385
+ tr_debug (" Socket %d recv would block" , socket->id );
394
386
return NSAPI_ERROR_WOULD_BLOCK;
395
387
}
396
388
}
0 commit comments