Skip to content

Commit 589f8ab

Browse files
committed
Add Thales patches
1 parent cd7acd7 commit 589f8ab

19 files changed

+2017
-0
lines changed

patches/0090-Thales-mbed-library-porting.patch

+568
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
From 083b7057da81658a6f89607409e494d6043e7a50 Mon Sep 17 00:00:00 2001
2+
From: giulcioffi <g.cioffi@arduino.cc>
3+
Date: Tue, 13 Jul 2021 13:16:06 +0200
4+
Subject: [PATCH 091/106] Implement connect() and get_context() functions
5+
inside GEMALTO stack
6+
7+
---
8+
.../framework/AT/AT_CellularContext.cpp | 33 --------
9+
.../GEMALTO_CINTERION_CellularContext.cpp | 82 +++++++++++++++++++
10+
.../GEMALTO_CINTERION_CellularContext.h | 3 +
11+
3 files changed, 85 insertions(+), 33 deletions(-)
12+
13+
diff --git a/connectivity/cellular/source/framework/AT/AT_CellularContext.cpp b/connectivity/cellular/source/framework/AT/AT_CellularContext.cpp
14+
index b4678ff081..620af5ac76 100644
15+
--- a/connectivity/cellular/source/framework/AT/AT_CellularContext.cpp
16+
+++ b/connectivity/cellular/source/framework/AT/AT_CellularContext.cpp
17+
@@ -269,26 +269,6 @@ nsapi_error_t AT_CellularContext::connect(const char *sim_pin, const char *apn,
18+
set_sim_pin(sim_pin);
19+
set_credentials(apn, uname, pwd);
20+
21+
-#if defined __has_include
22+
-# if __has_include (<GEMALTO_CINTERION.h>)
23+
- set_device_ready();
24+
-
25+
- _at.lock();
26+
- bool valid_context = get_context();
27+
- _at.unlock();
28+
-
29+
- if(!valid_context) {
30+
- set_new_context(_cid);
31+
- }
32+
-
33+
- do_user_authentication();
34+
-
35+
- enable_access_technology();
36+
-
37+
- do_connect();
38+
-# endif
39+
-#endif
40+
-
41+
return connect();
42+
}
43+
44+
@@ -378,13 +358,7 @@ bool AT_CellularContext::get_context()
45+
int pdp_type_len = _at.read_string(pdp_type_from_context, sizeof(pdp_type_from_context));
46+
if (pdp_type_len > 0) {
47+
apn_len = _at.read_string(apn, sizeof(apn));
48+
-#if defined __has_include
49+
-# if __has_include (<GEMALTO_CINTERION.h>)
50+
- if (apn_len > 0) {
51+
-# else
52+
if (apn_len >= 0) {
53+
-# endif
54+
-#endif
55+
if (_apn && (strcmp(apn, _apn) != 0)) {
56+
tr_debug("CID %d APN \"%s\"", cid, apn);
57+
continue;
58+
@@ -402,13 +376,6 @@ bool AT_CellularContext::get_context()
59+
set_cid(cid);
60+
}
61+
}
62+
-#if defined __has_include
63+
-# if __has_include (<GEMALTO_CINTERION.h>)
64+
- else {
65+
- cid_max = 0;
66+
- }
67+
-# endif
68+
-#endif
69+
}
70+
}
71+
72+
diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp
73+
index ee0a56e57a..8f04e1274a 100644
74+
--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp
75+
+++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp
76+
@@ -30,6 +30,88 @@ GEMALTO_CINTERION_CellularContext::~GEMALTO_CINTERION_CellularContext()
77+
{
78+
}
79+
80+
+nsapi_error_t GEMALTO_CINTERION_CellularContext::connect(const char *sim_pin, const char *apn, const char *uname,
81+
+ const char *pwd)
82+
+{
83+
+ set_sim_pin(sim_pin);
84+
+ set_credentials(apn, uname, pwd);
85+
+
86+
+ set_device_ready();
87+
+
88+
+ _at.lock();
89+
+ bool valid_context = get_context();
90+
+ _at.unlock();
91+
+
92+
+ if(!valid_context) {
93+
+ set_new_context(_cid);
94+
+ }
95+
+
96+
+ do_user_authentication();
97+
+
98+
+ enable_access_technology();
99+
+
100+
+ return AT_CellularContext::connect();
101+
+}
102+
+
103+
+bool GEMALTO_CINTERION_CellularContext::get_context()
104+
+{
105+
+ _at.cmd_start_stop("+CGDCONT", "?");
106+
+ _at.resp_start("+CGDCONT:");
107+
+ set_cid(-1);
108+
+ int cid_max = 0; // needed when creating new context
109+
+ char apn[MAX_ACCESSPOINT_NAME_LENGTH];
110+
+ int apn_len = 0;
111+
+
112+
+ while (_at.info_resp()) {
113+
+ int cid = _at.read_int();
114+
+ if (cid > cid_max) {
115+
+ cid_max = cid;
116+
+ }
117+
+ char pdp_type_from_context[10];
118+
+ int pdp_type_len = _at.read_string(pdp_type_from_context, sizeof(pdp_type_from_context));
119+
+ if (pdp_type_len > 0) {
120+
+ apn_len = _at.read_string(apn, sizeof(apn));
121+
+ if (apn_len > 0) {
122+
+ if (_apn && (strcmp(apn, _apn) != 0)) {
123+
+ tr_debug("CID %d APN \"%s\"", cid, apn);
124+
+ continue;
125+
+ }
126+
+
127+
+ // APN matched -> Check PDP type
128+
+ pdp_type_t pdp_type = string_to_pdp_type(pdp_type_from_context);
129+
+ tr_debug("CID %d APN \"%s\" pdp_type %u", cid, apn, pdp_type);
130+
+
131+
+ // Accept exact matching PDP context type or dual PDP context for modems that support both IPv4 and IPv6 stacks
132+
+ if (get_device()->get_property(pdp_type_t_to_cellular_property(pdp_type)) ||
133+
+ ((pdp_type == IPV4V6_PDP_TYPE && (get_device()->get_property(AT_CellularDevice::PROPERTY_IPV4_PDP_TYPE) &&
134+
+ get_device()->get_property(AT_CellularDevice::PROPERTY_IPV6_PDP_TYPE))) && !_nonip_req)) {
135+
+ _pdp_type = pdp_type;
136+
+ set_cid(cid);
137+
+ }
138+
+ }
139+
+ else {
140+
+ cid_max = 0;
141+
+ }
142+
+ }
143+
+ }
144+
+
145+
+ _at.resp_stop();
146+
+ if (_cid == -1) { // no suitable context was found so create a new one
147+
+ if (!set_new_context(cid_max + 1)) {
148+
+ return false;
149+
+ }
150+
+ }
151+
+
152+
+ // save the apn
153+
+ if (apn_len > 0 && !_apn) {
154+
+ memcpy(_found_apn, apn, apn_len + 1);
155+
+ }
156+
+
157+
+ tr_info("Found PDP context %d", _cid);
158+
+
159+
+ return true;
160+
+}
161+
+
162+
163+
nsapi_error_t GEMALTO_CINTERION_CellularContext::do_user_authentication()
164+
{
165+
diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.h b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.h
166+
index da6e7676d6..0645b2b87c 100644
167+
--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.h
168+
+++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.h
169+
@@ -25,6 +25,9 @@ class GEMALTO_CINTERION_CellularContext: public AT_CellularContext {
170+
public:
171+
GEMALTO_CINTERION_CellularContext(ATHandler &at, CellularDevice *device, const char *apn, bool cp_req = false, bool nonip_req = false);
172+
virtual ~GEMALTO_CINTERION_CellularContext();
173+
+ virtual nsapi_error_t connect(const char *sim_pin, const char *apn = 0, const char *uname = 0,
174+
+ const char *pwd = 0);
175+
+ virtual bool get_context();
176+
177+
protected:
178+
#if !NSAPI_PPP_AVAILABLE
179+
--
180+
2.33.1
181+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
From 7ad3530cab80994fe2c8edfe2e8444b169772b5d Mon Sep 17 00:00:00 2001
2+
From: giulcioffi <g.cioffi@arduino.cc>
3+
Date: Tue, 13 Jul 2021 13:16:49 +0200
4+
Subject: [PATCH 092/106] Make set_cid() protected to call it from GEMALTO
5+
stack
6+
7+
---
8+
.../cellular/include/cellular/framework/AT/AT_CellularContext.h | 2 +-
9+
1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+
diff --git a/connectivity/cellular/include/cellular/framework/AT/AT_CellularContext.h b/connectivity/cellular/include/cellular/framework/AT/AT_CellularContext.h
12+
index 19099c0e08..0eb83531b0 100644
13+
--- a/connectivity/cellular/include/cellular/framework/AT/AT_CellularContext.h
14+
+++ b/connectivity/cellular/include/cellular/framework/AT/AT_CellularContext.h
15+
@@ -109,6 +109,7 @@ protected:
16+
*/
17+
virtual const char *get_nonip_context_type_str();
18+
virtual void enable_access_technology();
19+
+ virtual void set_cid(int cid);
20+
21+
private:
22+
#if NSAPI_PPP_AVAILABLE
23+
@@ -125,7 +126,6 @@ private:
24+
nsapi_error_t check_operation(nsapi_error_t err, ContextOperation op);
25+
void ciot_opt_cb(mbed::CellularNetwork::CIoT_Supported_Opt ciot_opt);
26+
virtual void do_connect_with_retry();
27+
- void set_cid(int cid);
28+
29+
private:
30+
ContextOperation _current_op;
31+
--
32+
2.33.1
33+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
From a18d5e8c226fa748e62b6cc56661518fd7923ac3 Mon Sep 17 00:00:00 2001
2+
From: giulcioffi <g.cioffi@arduino.cc>
3+
Date: Tue, 13 Jul 2021 18:17:13 +0200
4+
Subject: [PATCH 093/106] Implement GEMALTO subclass of CellularNetwork
5+
6+
---
7+
.../framework/device/CellularStateMachine.cpp | 6 ----
8+
.../GEMALTO/CINTERION/GEMALTO_CINTERION.cpp | 6 ++++
9+
.../GEMALTO/CINTERION/GEMALTO_CINTERION.h | 1 +
10+
.../GEMALTO_CINTERION_CellularNetwork.cpp | 34 ++++++++++++++++++
11+
.../GEMALTO_CINTERION_CellularNetwork.h | 35 +++++++++++++++++++
12+
5 files changed, 76 insertions(+), 6 deletions(-)
13+
create mode 100644 connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularNetwork.cpp
14+
create mode 100644 connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularNetwork.h
15+
16+
diff --git a/connectivity/cellular/source/framework/device/CellularStateMachine.cpp b/connectivity/cellular/source/framework/device/CellularStateMachine.cpp
17+
index 35b16839d3..0a452eacb3 100644
18+
--- a/connectivity/cellular/source/framework/device/CellularStateMachine.cpp
19+
+++ b/connectivity/cellular/source/framework/device/CellularStateMachine.cpp
20+
@@ -471,13 +471,7 @@ void CellularStateMachine::state_registering()
21+
_cb_data.error = NSAPI_ERROR_OK;
22+
send_event_cb(_current_event);
23+
// we are already registered, go to attach
24+
-#if defined __has_include
25+
-# if __has_include (<GEMALTO_CINTERION.h>)
26+
-# else
27+
- //This state is not needed for Gemalto TX62-W module
28+
enter_to_state(STATE_ATTACHING_NETWORK);
29+
-# endif
30+
-#endif
31+
} else {
32+
tr_info("Network registration (timeout %d ms)", _state_timeout_registration.count());
33+
change_timeout(_state_timeout_registration);
34+
diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp
35+
index 6e062039d4..f8f892fccd 100644
36+
--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp
37+
+++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp
38+
@@ -17,6 +17,7 @@
39+
40+
#include "GEMALTO_CINTERION_CellularContext.h"
41+
#include "GEMALTO_CINTERION_CellularInformation.h"
42+
+#include "GEMALTO_CINTERION_CellularNetwork.h"
43+
#include "GEMALTO_CINTERION.h"
44+
#include "AT_CellularNetwork.h"
45+
#include "CellularLog.h"
46+
@@ -43,6 +44,11 @@ AT_CellularInformation *GEMALTO_CINTERION::open_information_impl(ATHandler &at)
47+
return AT_CellularDevice::open_information_impl(at);
48+
}
49+
50+
+AT_CellularNetwork *GEMALTO_CINTERION::open_network_impl(ATHandler &at)
51+
+{
52+
+ return new GEMALTO_CINTERION_CellularNetwork(at, *this);
53+
+}
54+
+
55+
nsapi_error_t GEMALTO_CINTERION::init()
56+
{
57+
nsapi_error_t err = AT_CellularDevice::init();
58+
diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.h b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.h
59+
index 73cb7dc67c..21d5888383 100644
60+
--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.h
61+
+++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.h
62+
@@ -51,6 +51,7 @@ public:
63+
protected: // AT_CellularDevice
64+
virtual AT_CellularContext *create_context_impl(ATHandler &at, const char *apn, bool cp_req = false, bool nonip_req = false);
65+
virtual AT_CellularInformation *open_information_impl(ATHandler &at);
66+
+ virtual AT_CellularNetwork *open_network_impl(ATHandler &at);
67+
68+
protected:
69+
virtual nsapi_error_t init();
70+
diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularNetwork.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularNetwork.cpp
71+
new file mode 100644
72+
index 0000000000..37ca733b6e
73+
--- /dev/null
74+
+++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularNetwork.cpp
75+
@@ -0,0 +1,34 @@
76+
+/*
77+
+ * Copyright (c) 2018, Arm Limited and affiliates.
78+
+ * SPDX-License-Identifier: Apache-2.0
79+
+ *
80+
+ * Licensed under the Apache License, Version 2.0 (the "License");
81+
+ * you may not use this file except in compliance with the License.
82+
+ * You may obtain a copy of the License at
83+
+ *
84+
+ * http://www.apache.org/licenses/LICENSE-2.0
85+
+ *
86+
+ * Unless required by applicable law or agreed to in writing, software
87+
+ * distributed under the License is distributed on an "AS IS" BASIS,
88+
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
89+
+ * See the License for the specific language governing permissions and
90+
+ * limitations under the License.
91+
+ */
92+
+#include "GEMALTO_CINTERION_CellularNetwork.h"
93+
+
94+
+using namespace mbed;
95+
+
96+
+GEMALTO_CINTERION_CellularNetwork::GEMALTO_CINTERION_CellularNetwork(ATHandler &at, AT_CellularDevice &device) : AT_CellularNetwork(at, device)
97+
+{
98+
+}
99+
+
100+
+GEMALTO_CINTERION_CellularNetwork::~GEMALTO_CINTERION_CellularNetwork()
101+
+{
102+
+}
103+
+
104+
+nsapi_error_t GEMALTO_CINTERION_CellularNetwork::set_attach()
105+
+{
106+
+ return NSAPI_ERROR_OK;
107+
+}
108+
+
109+
+ /* namespace mbed */
110+
diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularNetwork.h b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularNetwork.h
111+
new file mode 100644
112+
index 0000000000..8d5f49cf5a
113+
--- /dev/null
114+
+++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularNetwork.h
115+
@@ -0,0 +1,35 @@
116+
+/*
117+
+ * Copyright (c) 2018, Arm Limited and affiliates.
118+
+ * SPDX-License-Identifier: Apache-2.0
119+
+ *
120+
+ * Licensed under the Apache License, Version 2.0 (the "License");
121+
+ * you may not use this file except in compliance with the License.
122+
+ * You may obtain a copy of the License at
123+
+ *
124+
+ * http://www.apache.org/licenses/LICENSE-2.0
125+
+ *
126+
+ * Unless required by applicable law or agreed to in writing, software
127+
+ * distributed under the License is distributed on an "AS IS" BASIS,
128+
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
129+
+ * See the License for the specific language governing permissions and
130+
+ * limitations under the License.
131+
+ */
132+
+#ifndef GEMALTO_CINTERION_CELLULARNETWORK_H_
133+
+#define GEMALTO_CINTERION_CELLULARNETWORK_H_
134+
+
135+
+#include "AT_CellularNetwork.h"
136+
+
137+
+namespace mbed {
138+
+
139+
+class GEMALTO_CINTERION_CellularNetwork: public AT_CellularNetwork {
140+
+public:
141+
+ GEMALTO_CINTERION_CellularNetwork(ATHandler &at, AT_CellularDevice &device);
142+
+ virtual ~GEMALTO_CINTERION_CellularNetwork();
143+
+ virtual nsapi_error_t set_attach();
144+
+
145+
+protected:
146+
+};
147+
+
148+
+} /* namespace mbed */
149+
+
150+
+#endif // GEMALTO_CINTERION_CELLULARNETWORK_H_
151+
--
152+
2.33.1
153+

0 commit comments

Comments
 (0)