Skip to content

Commit d518f5c

Browse files
authored
Merge pull request #12131 from AriParkkila/cell-gemalto-cid
Cellular: Fix Gemalto/Cinterion driver
2 parents bad7baf + 31bd1a7 commit d518f5c

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

features/cellular/framework/targets/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ void GEMALTO_CINTERION::init_module_els61()
127127
0, // AT_CGSN_WITH_TYPE
128128
1, // AT_CGDATA
129129
1, // AT_CGAUTH
130+
1, // AT_CNMI
131+
1, // AT_CSMP
132+
1, // AT_CMGF
133+
1, // AT_CSDH
130134
1, // PROPERTY_IPV4_STACK
131135
1, // PROPERTY_IPV6_STACK
132136
0, // PROPERTY_IPV4V6_STACK
@@ -147,6 +151,10 @@ void GEMALTO_CINTERION::init_module_ems31()
147151
1, // AT_CGSN_WITH_TYPE
148152
1, // AT_CGDATA
149153
1, // AT_CGAUTH
154+
1, // AT_CNMI
155+
1, // AT_CSMP
156+
1, // AT_CMGF
157+
1, // AT_CSDH
150158
1, // PROPERTY_IPV4_STACK
151159
1, // PROPERTY_IPV6_STACK
152160
1, // PROPERTY_IPV4V6_STACK

features/cellular/framework/targets/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@
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-
3328
using namespace mbed;
3429

3530
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()
6055
sock->_cb(sock->_data);
6156
}
6257
}
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+
}
6369
}
6470
}
6571

@@ -109,8 +115,7 @@ void GEMALTO_CINTERION_CellularStack::sisr_urc_handler(int sock_id, int urc_code
109115
nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_stack_init()
110116
{
111117
_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);
114119
if (!err) {
115120
_at.set_urc_handler("^SIS:", mbed::Callback<void()>(this, &GEMALTO_CINTERION_CellularStack::urc_sis));
116121
_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()
122127
socket_close_impl(i);
123128
}
124129
_at.clear_error();
125-
close_connection_profile(connection_profile_id);
130+
close_connection_profile(_cid);
126131
}
127132
_at.unlock();
128133
return err;
@@ -157,8 +162,6 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_close_impl(int sock_id)
157162

158163
nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer(CellularSocket *socket, const SocketAddress *address)
159164
{
160-
int connection_profile_id = CONNECTION_PROFILE_ID;
161-
162165
int retry_open = 1;
163166
retry_open:
164167
// setup internet session profile
@@ -193,7 +196,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer(CellularSocket
193196
}
194197
if (strcmp(paramTag, "conId") == 0) {
195198
char buf[10];
196-
std::sprintf(buf, "%d", connection_profile_id);
199+
std::sprintf(buf, "%d", _cid);
197200
if (strcmp(paramValue, buf) == 0) {
198201
foundConIdType = true;
199202
}
@@ -209,7 +212,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer(CellularSocket
209212
}
210213

211214
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);
213216
}
214217

215218
// 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
238241
_at.at_cmd_discard("^SISO", "=", "%d", internet_service_id);
239242

240243
if (_at.get_last_error()) {
241-
tr_error("Socket %d open failed!", socket->id);
244+
tr_error("Socket %d open failed!", internet_service_id);
242245
_at.clear_error();
243246
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
244247
if (retry_open--) {
@@ -390,7 +393,7 @@ nsapi_size_or_error_t GEMALTO_CINTERION_CellularStack::socket_recvfrom_impl(Cell
390393
if (!socket->pending_bytes) {
391394
_at.process_oob(); // check for ^SISR URC
392395
if (!socket->pending_bytes) {
393-
tr_debug("Socekt %d recv would block", socket->id);
396+
tr_debug("Socket %d recv would block", socket->id);
394397
return NSAPI_ERROR_WOULD_BLOCK;
395398
}
396399
}

0 commit comments

Comments
 (0)