Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdd74c5b

Browse files
authored
Merge pull request#759 from pennam/thales_edge
Add TLS support to Portenta CAT.M1/NB IoT GNSS Shield
2 parents52a91c4 +149883b commitdd74c5b

File tree

24 files changed

+857
-69
lines changed

24 files changed

+857
-69
lines changed

‎.github/workflows/compile-examples.yml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ jobs:
156156
- libraries/USBHOST
157157
- libraries/USBMSD/examples/AccessFlashAsUSBDisk
158158
- libraries/WiFi
159-
- libraries/GSM
160159
- ~/Arduino/libraries/ArduinoBLE
161160
-board:
162161
fqbn:arduino:mbed:nicla_voice
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
GSMSSLlient
3+
4+
This sketch connects to a website (https://ifconfig.me)
5+
using the Portenta CAT.M1/NB IoT GNSS Shield and TLS.
6+
7+
*/
8+
9+
#include<GSM.h>
10+
11+
#include"arduino_secrets.h"
12+
char pin[] = SECRET_PIN;
13+
char apn[] = SECRET_APN;
14+
char username[] = SECRET_USERNAME;
15+
char pass[] = SECRET_PASSWORD;
16+
17+
constchar server[] ="ifconfig.me";
18+
constchar* ip_address;
19+
int port =443;
20+
GSMSSLClient client;
21+
22+
voidsetup() {
23+
Serial.begin(115200);
24+
while(!Serial) {}
25+
Serial.println("Starting Carrier Network registration");
26+
if(!GSM.begin(pin, apn, username, pass, CATM1, BAND_3 | BAND_20 | BAND_19)){
27+
Serial.println("The board was not able to register to the network...");
28+
// do nothing forevermore:
29+
while(1);
30+
}
31+
Serial.println("\nStarting connection to server...");
32+
// if you get a connection, report back via serial:
33+
if (client.connect(server, port)) {
34+
Serial.println("connected to server");
35+
// Make a HTTP request:
36+
client.println("GET /ip HTTP/1.1");
37+
client.print("Host:");
38+
client.println(server);
39+
client.println("Connection: close");
40+
client.println();
41+
}else {
42+
Serial.println("unable to connect to server");
43+
}
44+
45+
}
46+
47+
voidloop() {
48+
49+
// if there are incoming bytes available
50+
// from the server, read them and print them:
51+
while (client.available()) {
52+
char c = client.read();
53+
Serial.write(c);
54+
}
55+
56+
// if the server's disconnected, stop the client:
57+
if (!client.connected()) {
58+
Serial.println();
59+
Serial.println("disconnecting from server.");
60+
client.stop();
61+
62+
// do nothing forevermore:
63+
while (true);
64+
}
65+
66+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#defineSECRET_PIN ""
2+
#defineSECRET_APN ""
3+
#defineSECRET_USERNAME ""
4+
#defineSECRET_PASSWORD ""

‎libraries/GSM/src/GSM.cpp‎

Lines changed: 40 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,34 @@
1+
/*
2+
GSM.cpp - Library for GSM on mbed platforms.
3+
Copyright (c) 2011-2023 Arduino LLC. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
120
#include"GSM.h"
221

322
#include"mbed.h"
423
#include"CellularLog.h"
24+
#include"CellularDevice.h"
525
#include"CellularContext.h"
626
#include"CellularInterface.h"
727
#include"GEMALTO_CINTERION_CellularStack.h"
828

929
#defineMAXRETRY3
1030

11-
bool _cmuxEnable =false;
12-
arduino::CMUXClass *arduino::CMUXClass::get_default_instance()
31+
arduino::CMUXClass *arduino::CMUXClass::get_default_instance()
1332
{
1433
static mbed::UnbufferedSerialserial(MBED_CONF_GEMALTO_CINTERION_TX, MBED_CONF_GEMALTO_CINTERION_RX,115200);
1534
serial.set_flow_control(mbed::SerialBase::RTSCTS_SW, MBED_CONF_GEMALTO_CINTERION_CTS, NC);
@@ -19,24 +38,24 @@ arduino::CMUXClass * arduino::CMUXClass::get_default_instance()
1938

2039
mbed::CellularDevice *mbed::CellularDevice::get_default_instance()
2140
{
22-
staticauto cmux =arduino::CMUXClass::get_default_instance();
23-
static mbed::GEMALTO_CINTERIONdevice(cmux->get_serial(0));
24-
nextSerialPort++;
25-
device.enableCMUXChannel =mbed::callback(cmux, &arduino::CMUXClass::enableCMUXChannel);
26-
return &device;
41+
staticauto cmux =arduino::CMUXClass::get_default_instance();
42+
static mbed::GEMALTO_CINTERIONdevice(cmux->get_serial(0));
43+
nextSerialPort++;
44+
device.enableCMUXChannel =mbed::callback(cmux, &arduino::CMUXClass::enableCMUXChannel);
45+
return &device;
2746
}
2847

2948
intarduino::GSMClass::begin(constchar* pin,constchar* apn,constchar* username,constchar* password, RadioAccessTechnologyType rat,uint32_t band,bool restart) {
3049

3150
if(restart ||isCmuxEnable()) {
32-
pinMode(PJ_10, OUTPUT);
33-
digitalWrite(PJ_10, HIGH);
51+
pinMode(MBED_CONF_GEMALTO_CINTERION_RST, OUTPUT);
52+
digitalWrite(MBED_CONF_GEMALTO_CINTERION_RST, HIGH);
3453
delay(800);
35-
digitalWrite(PJ_10, LOW);
36-
pinMode(PJ_7, OUTPUT);
37-
digitalWrite(PJ_7, LOW);
54+
digitalWrite(MBED_CONF_GEMALTO_CINTERION_RST, LOW);
55+
pinMode(MBED_CONF_GEMALTO_CINTERION_ON, OUTPUT);
56+
digitalWrite(MBED_CONF_GEMALTO_CINTERION_ON, LOW);
3857
delay(1);
39-
digitalWrite(PJ_7, HIGH);
58+
digitalWrite(MBED_CONF_GEMALTO_CINTERION_ON, HIGH);
4059
delay(1);
4160
// this timer is to make sure that at boottime and when the CMUX is used,
4261
// ^SYSTART is received in time to avoid stranger behaviour
@@ -50,7 +69,7 @@ int arduino::GSMClass::begin(const char* pin, const char* apn, const char* usern
5069
printf("Invalid context\n");
5170
return0;
5271
}
53-
pinMode(PJ_7, INPUT_PULLDOWN);
72+
pinMode(MBED_CONF_GEMALTO_CINTERION_ON, INPUT_PULLDOWN);
5473

5574
static mbed::DigitalOutrts(MBED_CONF_GEMALTO_CINTERION_RTS,0);
5675

@@ -99,11 +118,11 @@ int arduino::GSMClass::begin(const char* pin, const char* apn, const char* usern
99118
return connect_status == NSAPI_ERROR_OK ?1 :0;
100119
}
101120

102-
voidarduino::GSMClass::enableCmux(){
121+
voidarduino::GSMClass::enableCmux(){
103122
_cmuxGSMenable =true;
104123
}
105124

106-
boolarduino::GSMClass::isCmuxEnable(){
125+
boolarduino::GSMClass::isCmuxEnable(){
107126
return _cmuxGSMenable;
108127
}
109128

@@ -130,53 +149,16 @@ bool arduino::GSMClass::setTime(unsigned long const epoch, int const timezone)
130149
return _device->set_time(epoch, timezone);
131150
}
132151

133-
static PlatformMutex trace_mutex;
134-
135-
staticvoidtrace_wait()
152+
boolarduino::GSMClass::isConnected()
136153
{
137-
trace_mutex.lock();
138-
}
139-
140-
staticvoidtrace_release()
141-
{
142-
trace_mutex.unlock();
143-
}
144-
145-
staticchar*trace_time(size_t ss)
146-
{
147-
staticchar time_st[50];
148-
auto ms = std::chrono::time_point_cast<std::chrono::milliseconds>(rtos::Kernel::Clock::now()).time_since_epoch().count();
149-
//snprintf(time_st, 49, "[%08llums]", ms);
150-
snprintf(time_st,1,"\n");
151-
return time_st;
152-
}
153-
154-
static Stream* trace_stream =nullptr;
155-
staticvoidarduino_print(constchar* c) {
156-
if (trace_stream) {
157-
trace_stream->println(c);
154+
if (_context) {
155+
return _context->is_connected();
156+
}else {
157+
returnfalse;
158158
}
159159
}
160160

161-
voidarduino::GSMClass::debug(Stream& stream) {
162-
163-
#if MBED_CONF_MBED_TRACE_ENABLE
164-
165-
mbed_trace_init();
166161

167-
trace_stream = &stream;
168-
mbed_trace_print_function_set(arduino_print);
169-
mbed_trace_prefix_function_set( &trace_time );
170-
171-
mbed_trace_mutex_wait_function_set(trace_wait);
172-
mbed_trace_mutex_release_function_set(trace_release);
173-
174-
mbed_cellular_trace::mutex_wait_function_set(trace_wait);
175-
mbed_cellular_trace::mutex_release_function_set(trace_release);
176-
177-
#endif
178-
179-
}
180162

181163
NetworkInterface*arduino::GSMClass::getNetwork() {
182164
return _context;

‎libraries/GSM/src/GSM.h‎

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
/*
22
GSM.h - Library for GSM on mbed platforms.
3-
Copyright (c) 2011-2021 Arduino LLC. All right reserved.
3+
Copyright (c) 2011-2023 Arduino LLC. All right reserved.
4+
45
This library is free software; you can redistribute it and/or
56
modify it under the terms of the GNU Lesser General Public
67
License as published by the Free Software Foundation; either
78
version 2.1 of the License, or (at your option) any later version.
9+
810
This library is distributed in the hope that it will be useful,
911
but WITHOUT ANY WARRANTY; without even the implied warranty of
1012
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1113
Lesser General Public License for more details.
14+
1215
You should have received a copy of the GNU Lesser General Public
1316
License along with this library; if not, write to the Free Software
1417
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
@@ -30,10 +33,28 @@
3033
#include"CMUXClass.h"
3134
#include"PTYSerial.h"
3235

33-
#defineMBED_CONF_GEMALTO_CINTERION_TX PA_0
34-
#defineMBED_CONF_GEMALTO_CINTERION_RX PI_9
35-
#defineMBED_CONF_GEMALTO_CINTERION_RTS PI_10
36-
#defineMBED_CONF_GEMALTO_CINTERION_CTS PI_13
36+
#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
37+
#defineMBED_CONF_GEMALTO_CINTERION_TX PA_0
38+
#defineMBED_CONF_GEMALTO_CINTERION_RX PI_9
39+
#defineMBED_CONF_GEMALTO_CINTERION_RTS PI_10
40+
#defineMBED_CONF_GEMALTO_CINTERION_CTS PI_13
41+
#defineMBED_CONF_GEMALTO_CINTERION_RST PJ_10
42+
#defineMBED_CONF_GEMALTO_CINTERION_ON PJ_7
43+
#elif defined (ARDUINO_EDGE_CONTROL)
44+
/* IMPORTANT: turn on the module's 5V on demand by calling
45+
pinMode(ON_MKR2, OUTPUT);
46+
digitalWrite(ON_MKR2, HIGH);
47+
*/
48+
#defineMBED_CONF_GEMALTO_CINTERION_TX p24
49+
#defineMBED_CONF_GEMALTO_CINTERION_RX p25
50+
#defineMBED_CONF_GEMALTO_CINTERION_RTS NC
51+
#defineMBED_CONF_GEMALTO_CINTERION_CTS NC
52+
#defineMBED_CONF_GEMALTO_CINTERION_RST p31
53+
#defineMBED_CONF_GEMALTO_CINTERION_ON p2
54+
#else
55+
#error Gemalto Cinterion cellular connectivity not supported
56+
#endif
57+
3758
#defineMBED_CONF_APP_SOCK_TYPE1
3859

3960
#if defined __has_include
@@ -87,10 +108,12 @@ class GSMClass : public MbedSocketClass {
87108
boolsetTime(unsignedlongconst epoch,intconst timezone =0);
88109
voidenableCmux();
89110
boolisCmuxEnable();
90-
voiddebug(Stream& stream);
111+
voidtrace(Stream& stream);
112+
voidsetTraceLevel(int trace_level,bool timestamp =false);
91113
intping(constchar* hostname,uint8_t ttl =128);
92114
intping(const String& hostname,uint8_t ttl =128);
93115
intping(IPAddress host,uint8_t ttl =128);
116+
boolisConnected();
94117

95118
friendclassGSMClient;
96119
friendclassGSMUDP;
@@ -115,6 +138,7 @@ class GSMClass : public MbedSocketClass {
115138
extern GSMClass GSM;
116139

117140
#include"GSMClient.h"
141+
#include"GSMSSLClient.h"
118142
#include"GSMUdp.h"
119143

120144
#endif

‎libraries/GSM/src/GSMClient.cpp‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
GSMClient.cpp
3+
Copyright (c) 2023 Arduino SA. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#include"GSMClient.h"
21+
22+
arduino::GSMClient::GSMClient(): MbedClient(100) {
23+
24+
}

‎libraries/GSM/src/GSMClient.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
namespacearduino {
2727

2828
classGSMClient :publicMbedClient {
29+
public:
30+
GSMClient();
31+
32+
private:
2933
NetworkInterface *getNetwork() {
3034
return GSM.getNetwork();
3135
}

‎libraries/GSM/src/GSMSSLClient.cpp‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
GSMSSLClient.cpp
3+
Copyright (c) 2023 Arduino SA. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#include"GSMSSLClient.h"
21+
22+
arduino::GSMSSLClient::GSMSSLClient(): MbedSSLClient(100) {
23+
24+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp