2525#define UDP_PACKET_SIZE 1460
2626#define FAILURE_TIMEOUT (30 *1000 ) // failure timeout in milliseconds on modem side
2727
28- /*
29- * Use connection profile 0 and Internet service profiles starting from 0 for sockets.
30- */
31- #define CONNECTION_PROFILE_ID 0
32-
3328using namespace mbed ;
3429
3530GEMALTO_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
109104nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_stack_init ()
110105{
111106 _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);
114108 if (!err) {
115109 _at.set_urc_handler (" ^SIS:" , mbed::Callback<void ()>(this , &GEMALTO_CINTERION_CellularStack::urc_sis));
116110 _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()
122116 socket_close_impl (i);
123117 }
124118 _at.clear_error ();
125- close_connection_profile (connection_profile_id );
119+ close_connection_profile (_cid );
126120 }
127121 _at.unlock ();
128122 return err;
@@ -157,8 +151,6 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_close_impl(int sock_id)
157151
158152nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer (CellularSocket *socket, const SocketAddress *address)
159153{
160- int connection_profile_id = CONNECTION_PROFILE_ID;
161-
162154 int retry_open = 1 ;
163155retry_open:
164156 // setup internet session profile
@@ -193,7 +185,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer(CellularSocket
193185 }
194186 if (strcmp (paramTag, " conId" ) == 0 ) {
195187 char buf[10 ];
196- std::sprintf (buf, " %d" , connection_profile_id );
188+ std::sprintf (buf, " %d" , _cid );
197189 if (strcmp (paramValue, buf) == 0 ) {
198190 foundConIdType = true ;
199191 }
@@ -209,7 +201,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer(CellularSocket
209201 }
210202
211203 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 );
213205 }
214206
215207 // 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
238230 _at.at_cmd_discard (" ^SISO" , " =" , " %d" , internet_service_id);
239231
240232 if (_at.get_last_error ()) {
241- tr_error (" Socket %d open failed!" , socket-> id );
233+ tr_error (" Socket %d open failed!" , internet_service_id );
242234 _at.clear_error ();
243235 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
244236 if (retry_open--) {
@@ -390,7 +382,7 @@ nsapi_size_or_error_t GEMALTO_CINTERION_CellularStack::socket_recvfrom_impl(Cell
390382 if (!socket->pending_bytes ) {
391383 _at.process_oob (); // check for ^SISR URC
392384 if (!socket->pending_bytes ) {
393- tr_debug (" Socekt %d recv would block" , socket->id );
385+ tr_debug (" Socket %d recv would block" , socket->id );
394386 return NSAPI_ERROR_WOULD_BLOCK;
395387 }
396388 }
0 commit comments