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,
@@ -60,6 +55,17 @@ void GEMALTO_CINTERION_CellularStack::urc_sis()
60
55
sock->_cb (sock->_data );
61
56
}
62
57
}
58
+ if (urc_code == 0 ) {
59
+ int urc_info_id = _at.read_int ();
60
+ if (urc_info_id == 48 ) {
61
+ tr_info (" Socket closed %d" , sock_id);
62
+ sock->closed = true ;
63
+ if (sock->_cb ) {
64
+ sock->_cb (sock->_data );
65
+ }
66
+
67
+ }
68
+ }
63
69
}
64
70
}
65
71
@@ -109,8 +115,7 @@ void GEMALTO_CINTERION_CellularStack::sisr_urc_handler(int sock_id, int urc_code
109
115
nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_stack_init ()
110
116
{
111
117
_at.lock ();
112
- int connection_profile_id = CONNECTION_PROFILE_ID;
113
- nsapi_error_t err = create_connection_profile (connection_profile_id);
118
+ nsapi_error_t err = create_connection_profile (_cid);
114
119
if (!err) {
115
120
_at.set_urc_handler (" ^SIS:" , mbed::Callback<void ()>(this , &GEMALTO_CINTERION_CellularStack::urc_sis));
116
121
_at.set_urc_handler (" ^SISW:" , mbed::Callback<void ()>(this , &GEMALTO_CINTERION_CellularStack::urc_sisw));
@@ -122,7 +127,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_stack_init()
122
127
socket_close_impl (i);
123
128
}
124
129
_at.clear_error ();
125
- close_connection_profile (connection_profile_id );
130
+ close_connection_profile (_cid );
126
131
}
127
132
_at.unlock ();
128
133
return err;
@@ -157,8 +162,6 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_close_impl(int sock_id)
157
162
158
163
nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer (CellularSocket *socket, const SocketAddress *address)
159
164
{
160
- int connection_profile_id = CONNECTION_PROFILE_ID;
161
-
162
165
int retry_open = 1 ;
163
166
retry_open:
164
167
// setup internet session profile
@@ -193,7 +196,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer(CellularSocket
193
196
}
194
197
if (strcmp (paramTag, " conId" ) == 0 ) {
195
198
char buf[10 ];
196
- std::sprintf (buf, " %d" , connection_profile_id );
199
+ std::sprintf (buf, " %d" , _cid );
197
200
if (strcmp (paramValue, buf) == 0 ) {
198
201
foundConIdType = true ;
199
202
}
@@ -209,7 +212,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer(CellularSocket
209
212
}
210
213
211
214
if (!foundConIdType) {
212
- _at.at_cmd_discard (" ^SISS" , " =" , " %d%s%d" , internet_service_id, " conId" , connection_profile_id );
215
+ _at.at_cmd_discard (" ^SISS" , " =" , " %d%s%d" , internet_service_id, " conId" , _cid );
213
216
}
214
217
215
218
// host address (IPv4) and local+remote port is needed only for BGS2 which does not support UDP server socket
@@ -238,7 +241,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer(CellularSocket
238
241
_at.at_cmd_discard (" ^SISO" , " =" , " %d" , internet_service_id);
239
242
240
243
if (_at.get_last_error ()) {
241
- tr_error (" Socket %d open failed!" , socket-> id );
244
+ tr_error (" Socket %d open failed!" , internet_service_id );
242
245
_at.clear_error ();
243
246
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
247
if (retry_open--) {
@@ -390,7 +393,7 @@ nsapi_size_or_error_t GEMALTO_CINTERION_CellularStack::socket_recvfrom_impl(Cell
390
393
if (!socket->pending_bytes ) {
391
394
_at.process_oob (); // check for ^SISR URC
392
395
if (!socket->pending_bytes ) {
393
- tr_debug (" Socekt %d recv would block" , socket->id );
396
+ tr_debug (" Socket %d recv would block" , socket->id );
394
397
return NSAPI_ERROR_WOULD_BLOCK;
395
398
}
396
399
}
0 commit comments