Skip to content

Commit 90fe9de

Browse files
author
Ari Parkkila
committed
Cellular: Fixed network registration on Gemalto AT drivers
1 parent 9d0e3d8 commit 90fe9de

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,28 @@ NetworkStack *GEMALTO_CINTERION_CellularNetwork::get_stack()
4141

4242
bool GEMALTO_CINTERION_CellularNetwork::get_modem_stack_type(nsapi_ip_stack_t requested_stack)
4343
{
44+
#if NSAPI_PPP_AVAILABLE
45+
return (requested_stack == IPV4_STACK || requested_stack == IPV6_STACK);
46+
#else
4447
if (GEMALTO_CINTERION_Module::get_model() == GEMALTO_CINTERION_Module::ModelBGS2) {
4548
return (requested_stack == IPV4_STACK);
4649
}
4750
return (requested_stack == IPV4_STACK || requested_stack == IPV6_STACK);
51+
#endif
4852
}
4953

50-
bool GEMALTO_CINTERION_CellularNetwork::has_registration(RegistrationType reg_type)
54+
AT_CellularNetwork::RegistrationMode GEMALTO_CINTERION_CellularNetwork::has_registration(RegistrationType reg_type)
5155
{
5256
if (GEMALTO_CINTERION_Module::get_model() == GEMALTO_CINTERION_Module::ModelEMS31) {
53-
return (reg_type == C_EREG);
57+
return (reg_type == C_EREG) ? RegistrationModeLAC : RegistrationModeDisable;
5458
}
5559
if (GEMALTO_CINTERION_Module::get_model() == GEMALTO_CINTERION_Module::ModelBGS2) {
56-
return (reg_type == C_REG || reg_type == C_GREG);
60+
if (reg_type == C_GREG) {
61+
return RegistrationModeEnable;
62+
}
63+
return (reg_type == C_REG) ? RegistrationModeLAC : RegistrationModeDisable;
5764
}
58-
return (reg_type == C_REG || reg_type == C_GREG || reg_type == C_EREG);
65+
return (reg_type == C_REG || reg_type == C_GREG || reg_type == C_EREG) ? RegistrationModeLAC : RegistrationModeDisable;
5966
}
6067

6168
nsapi_error_t GEMALTO_CINTERION_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opsAct)

features/cellular/framework/targets/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularNetwork.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class GEMALTO_CINTERION_CellularNetwork : public AT_CellularNetwork {
3232
virtual NetworkStack *get_stack();
3333
#endif // NSAPI_PPP_AVAILABLE
3434

35-
virtual bool has_registration(RegistrationType reg_type);
35+
virtual RegistrationMode has_registration(RegistrationType reg_type);
3636

3737
virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack);
3838

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ void GEMALTO_CINTERION_CellularStack::urc_sis()
6060
{
6161
int sock_id = _at.read_int();
6262
int urc_code = _at.read_int();
63-
//tr_debug("Socket ready: id=%d, urc=%d", sock_id, urc_code);
6463
CellularSocket *sock = find_socket(sock_id);
6564
if (sock) {
6665
if (urc_code == 5) { // data available
@@ -79,7 +78,6 @@ void GEMALTO_CINTERION_CellularStack::urc_sisw()
7978
{
8079
int sock_id = _at.read_int();
8180
int urc_code = _at.read_int();
82-
//tr_debug("TX event: socket=%d, urc=%d", sock_id, urc_code);
8381
CellularSocket *sock = find_socket(sock_id);
8482
if (sock) {
8583
if (urc_code == 1) { // ready
@@ -100,7 +98,6 @@ void GEMALTO_CINTERION_CellularStack::urc_sisr()
10098
{
10199
int sock_id = _at.read_int();
102100
int urc_code = _at.read_int();
103-
//tr_debug("RX event: socket=%d, urc=%d", sock_id, urc_code);
104101
CellularSocket *sock = find_socket(sock_id);
105102
if (sock) {
106103
if (urc_code == 1) { // data available
@@ -221,11 +218,9 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::create_socket_impl(CellularSocket
221218
char paramTag[16];
222219
int paramTagLen = _at.read_string(paramTag, sizeof(paramTag));
223220
if (paramTagLen > 0) {
224-
//tr_debug("paramTag %s", paramTag);
225221
char paramValue[100 + 1]; // APN may be up to 100 chars
226222
int paramValueLen = _at.read_string(paramValue, sizeof(paramValue));
227223
if (paramValueLen >= 0) {
228-
//tr_debug("paramValue %s", paramValue);
229224
if (strcmp(paramTag, "srvType") == 0) {
230225
if (strcmp(paramValue, "Socket") == 0) {
231226
tr_debug("srvType %s", paramValue);
@@ -298,13 +293,12 @@ nsapi_size_or_error_t GEMALTO_CINTERION_CellularStack::socket_sendto_impl(Cellul
298293
socket_close_impl(socket->id);
299294
_at.clear_error();
300295
}
301-
// socket->started = false;
296+
302297
if (socket_open_defer(socket, &address) != NSAPI_ERROR_OK) {
303298
tr_error("Failed to open socket %d", socket->id);
304299
return NSAPI_ERROR_NO_SOCKET;
305300
}
306301
socket->remoteAddress = address;
307-
// return NSAPI_ERROR_WOULD_BLOCK;
308302
_at.resp_start("^SISW:");
309303
int sock_id = _at.read_int();
310304
int urc_code = _at.read_int();

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,21 @@ class GEMALTO_CINTERION_CellularStack : public AT_CellularStack {
4646
void *buffer, nsapi_size_t size);
4747

4848
private:
49+
// find the socket handle based on socket identifier
4950
CellularSocket *find_socket(int sock_id);
51+
52+
// socket URC handlers as per Cinterion AT manuals
5053
void urc_sis();
5154
void urc_sisw();
5255
void urc_sisr();
56+
57+
// sockets need a connection profile, one profile is enough to support single stack sockets
5358
bool create_connection_profile();
59+
60+
// socket open need to be deferred until sendto due to BGS2 does not support UDP server endpoint
5461
nsapi_error_t socket_open_defer(CellularSocket *socket, const SocketAddress *address = NULL);
5562

63+
// connection profile configuration needs Access Point Name
5664
const char *_apn;
5765
};
5866

0 commit comments

Comments
 (0)