Files
ArduinoCore-mbed/patches/0220-GEMALTO_CINTERION_CellularContext-connect-check-retu.patch
2023-11-13 17:56:02 +01:00

65 lines
2.2 KiB
Diff

From b5d44a4f3be3938045c185d5f1753cbade22a6f9 Mon Sep 17 00:00:00 2001
From: pennam <m.pennasilico@arduino.cc>
Date: Fri, 10 Nov 2023 17:06:53 +0100
Subject: [PATCH 220/221] GEMALTO_CINTERION_CellularContext::connect check
return codes and print errors
---
.../GEMALTO_CINTERION_CellularContext.cpp | 29 +++++++++++++++----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp
index bbd5c4c4b5..0af08a786d 100644
--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp
+++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp
@@ -33,22 +33,41 @@ GEMALTO_CINTERION_CellularContext::~GEMALTO_CINTERION_CellularContext()
nsapi_error_t GEMALTO_CINTERION_CellularContext::connect(const char *sim_pin, const char *apn, const char *uname,
const char *pwd)
{
+ nsapi_error_t error = NSAPI_ERROR_OK;
+
set_sim_pin(sim_pin);
set_credentials(apn, uname, pwd);
- set_device_ready();
+ error = set_device_ready();
+ if ((error != NSAPI_ERROR_OK) && (error != NSAPI_ERROR_ALREADY)) {
+ tr_error("Failure connecting to GEMALTO CINTERION modem");
+ return error;
+ }
_at.lock();
bool valid_context = get_context();
_at.unlock();
- if(!valid_context) {
- set_new_context(_cid);
+ if (!valid_context) {
+ valid_context = set_new_context(_cid);
+ }
+
+ if (!valid_context) {
+ tr_error("Invalid AT cellular context %d", _cid);
+ return NSAPI_ERROR_DEVICE_ERROR;
}
- do_user_authentication();
+ error = do_user_authentication();
+ if (error != NSAPI_ERROR_OK) {
+ tr_error("Failure during user authentication");
+ return error;
+ }
- enable_access_technology();
+ error = enable_access_technology();
+ if (error != NSAPI_ERROR_OK) {
+ tr_error("Failure enabling access technology");
+ return error;
+ }
return AT_CellularContext::connect();
}
--
2.42.0