Skip to content

Commit 89b6646

Browse files
author
Ari Parkkila
committed
Cellular: Fix Gemalto/Cinterion driver
1 parent b1b0673 commit 89b6646

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-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: 6 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,
@@ -109,8 +104,7 @@ void GEMALTO_CINTERION_CellularStack::sisr_urc_handler(int sock_id, int urc_code
109104
nsapi_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

158152
nsapi_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;
163155
retry_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

Comments
 (0)