Skip to content

GSM: allow retry if connection fails #975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
patches: GEMALTO CINTERION fixes for connection retries
  • Loading branch information
pennam committed Nov 14, 2024
commit f9561efec1c4a99410a90f75a43ac8f9fd5719ad
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
From f40d4a9d65ee9163921271697d316c1061aca946 Mon Sep 17 00:00:00 2001
From: pennam <m.pennasilico@arduino.cc>
Date: Thu, 31 Oct 2024 11:05:18 +0100
Subject: [PATCH 244/247] GEMALTO CINTERION: cleanup stack before connection

Allows to re-connect after a disconnection
---
.../GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp
index 78955c599e..76c788cdaf 100644
--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp
+++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp
@@ -35,6 +35,11 @@ nsapi_error_t GEMALTO_CINTERION_CellularContext::connect(const char *sim_pin, co
{
nsapi_error_t error = NSAPI_ERROR_OK;

+ if (_stack) {
+ delete _stack;
+ _stack = NULL;
+ }
+
set_sim_pin(sim_pin);
set_credentials(apn, uname, pwd);

--
2.45.2

25 changes: 25 additions & 0 deletions patches/0245-GEMALTO-CINTERION-close-socket-on-timeout.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 4b6c6ad0554c88c369fc4e2e5ed543d52117aa3f Mon Sep 17 00:00:00 2001
From: pennam <m.pennasilico@arduino.cc>
Date: Thu, 31 Oct 2024 12:00:51 +0100
Subject: [PATCH 245/247] GEMALTO CINTERION: close socket on timeout

---
.../GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp
index ac2a54282a..41a01859e7 100644
--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp
+++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp
@@ -59,7 +59,7 @@ void GEMALTO_CINTERION_CellularStack::urc_sis()
}
if (urc_code == 0) {
int urc_info_id = _at.read_int();
- if (urc_info_id == 48) {
+ if (urc_info_id == 48 || urc_info_id == 20) {
tr_info("Socket closed %d", sock_id);
sock->closed = true;
if (sock->_cb) {
--
2.45.2

33 changes: 33 additions & 0 deletions patches/0246-GEMALTO-CINTERION-add-debug-for-urc_sis.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From 84e682a7f4c0c05dded7f12817f78c1cc9a66cfe Mon Sep 17 00:00:00 2001
From: pennam <m.pennasilico@arduino.cc>
Date: Thu, 31 Oct 2024 12:01:47 +0100
Subject: [PATCH 246/247] GEMALTO CINTERION: add debug for urc_sis

---
.../GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp | 3 +++
1 file changed, 3 insertions(+)

diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp
index 41a01859e7..9a3f22dc3c 100644
--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp
+++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp
@@ -47,6 +47,8 @@ void GEMALTO_CINTERION_CellularStack::urc_sis()
int sock_id = _at.read_int();
int urc_code = _at.read_int();
CellularSocket *sock = find_socket(sock_id);
+
+ tr_info("urc_sis socket id %d urc code %d\n\r", sock_id, urc_code);
if (sock) {
// Currently only UDP is supported so there is need to handle only some error codes here,
// and others are detected on sendto/recvfrom responses.
@@ -59,6 +61,7 @@ void GEMALTO_CINTERION_CellularStack::urc_sis()
}
if (urc_code == 0) {
int urc_info_id = _at.read_int();
+ tr_info("urcInfoId %d\n\r", urc_info_id);
if (urc_info_id == 48 || urc_info_id == 20) {
tr_info("Socket closed %d", sock_id);
sock->closed = true;
--
2.45.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From 5cc2a1998d37bad69a0b4e75b7d6f7b92e95935c Mon Sep 17 00:00:00 2001
From: pennam <m.pennasilico@arduino.cc>
Date: Thu, 31 Oct 2024 12:03:00 +0100
Subject: [PATCH 247/247] GEMALTO CINTERION: add configuration for urcs during
read

---
.../CINTERION/GEMALTO_CINTERION_CellularStack.cpp | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp
index 9a3f22dc3c..a96cb2b360 100644
--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp
+++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp
@@ -527,8 +527,13 @@ sisw_retry:
return (_at.get_last_error() == NSAPI_ERROR_OK) ? accept_len : NSAPI_ERROR_DEVICE_ERROR;
}

-#define DISABLE_URCs _at.at_cmd_discard("^SCFG", "=", "%s%s","Tcp/WithURCs","off")
-#define RESTORE_URCs_AND_RETURN(ret) do { _at.at_cmd_discard("^SCFG", "=", "%s%s","Tcp/WithURCs","on"); return ret; } while(0)
+#if defined GEMALTO_CINTERION_DISABLE_URC_READING
+ #define DISABLE_URCs _at.at_cmd_discard("^SCFG", "=", "%s%s","Tcp/WithURCs","off")
+ #define RESTORE_URCs_AND_RETURN(ret) do { _at.at_cmd_discard("^SCFG", "=", "%s%s","Tcp/WithURCs","on"); return ret; } while(0)
+#else
+ #define DISABLE_URCs
+ #define RESTORE_URCs_AND_RETURN(ret) do { return ret; } while(0)
+#endif

nsapi_size_or_error_t GEMALTO_CINTERION_CellularStack::socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address,
void *buffer, nsapi_size_t size)
--
2.45.2