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

Add TLS support to Portenta CAT.M1/NB IoT GNSS Shield#759

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
facchinm merged 20 commits intoarduino:mainfrompennam:thales_edge
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
20 commits
Select commitHold shift + click to select a range
d8add39
GSMUdp: fix file header
pennamNov 7, 2023
984b4fd
GSM: add isConnected() method
pennamNov 7, 2023
03be367
Add GSMSSLClient class
pennamNov 7, 2023
69e563e
MbedClient add possibility to set socket timeout in constructor
pennamNov 7, 2023
4cedb61
MbedClient::connectSSL set timeout before TLS handshake starts
pennamNov 7, 2023
389a2c9
MbedSSLClient add possibility to set socket timeout in constructor
pennamNov 7, 2023
89cec9f
GSMClient: set default socket timeout
pennamNov 7, 2023
703289d
GSM: Add GSMSSLClient example
pennamNov 7, 2023
ef79b5b
GSM: fix file headers
pennamNov 9, 2023
66b026a
GSM: remove unused function
pennamNov 9, 2023
bed5201
GSM: rename debug() method into trace()
pennamNov 9, 2023
2cb24df
GSM: fix identation and spacing
pennamNov 9, 2023
5131eef
GSM: use define for RESET and power ON pin
pennamNov 10, 2023
afb706d
edge_control: enable cellular connectivity
facchinmOct 10, 2023
d7ae070
edge_control: reduce rtos.main-thread-stack-size to 4K
pennamNov 10, 2023
dc22e05
edge_control: TLS enable SHA1
pennamNov 10, 2023
f0e429a
GSM: edge_control add pins definitions
pennamNov 10, 2023
a4d9a38
MbedSSLClient: load certificates from filesystem only if supported
pennamNov 13, 2023
74d0c52
Add Gemalto Cinterion mbed-os patches
pennamNov 13, 2023
149883b
CI: remove GSM library from target GIGA
pennamNov 13, 2023
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
1 change: 0 additions & 1 deletion.github/workflows/compile-examples.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -156,7 +156,6 @@ jobs:
- libraries/USBHOST
- libraries/USBMSD/examples/AccessFlashAsUSBDisk
- libraries/WiFi
- libraries/GSM
- ~/Arduino/libraries/ArduinoBLE
- board:
fqbn: arduino:mbed:nicla_voice
Expand Down
66 changes: 66 additions & 0 deletionslibraries/GSM/examples/GSMSSLClient/GSMSSLClient.ino
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
/*
GSMSSLlient

This sketch connects to a website (https://ifconfig.me)
using the Portenta CAT.M1/NB IoT GNSS Shield and TLS.

*/

#include <GSM.h>

#include "arduino_secrets.h"
char pin[] = SECRET_PIN;
char apn[] = SECRET_APN;
char username[] = SECRET_USERNAME;
char pass[] = SECRET_PASSWORD;

const char server[] = "ifconfig.me";
const char* ip_address;
int port = 443;
GSMSSLClient client;

void setup() {
Serial.begin(115200);
while(!Serial) {}
Serial.println("Starting Carrier Network registration");
if(!GSM.begin(pin, apn, username, pass, CATM1, BAND_3 | BAND_20 | BAND_19)){
Serial.println("The board was not able to register to the network...");
// do nothing forevermore:
while(1);
}
Serial.println("\nStarting connection to server...");
// if you get a connection, report back via serial:
if (client.connect(server, port)) {
Serial.println("connected to server");
// Make a HTTP request:
client.println("GET /ip HTTP/1.1");
client.print("Host: ");
client.println(server);
client.println("Connection: close");
client.println();
} else {
Serial.println("unable to connect to server");
}

}

void loop() {

// if there are incoming bytes available
// from the server, read them and print them:
while (client.available()) {
char c = client.read();
Serial.write(c);
}

// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting from server.");
client.stop();

// do nothing forevermore:
while (true);
}

}
4 changes: 4 additions & 0 deletionslibraries/GSM/examples/GSMSSLClient/arduino_secrets.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
#define SECRET_PIN ""
#define SECRET_APN ""
#define SECRET_USERNAME ""
#define SECRET_PASSWORD ""
98 changes: 40 additions & 58 deletionslibraries/GSM/src/GSM.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,34 @@
/*
GSM.cpp - Library for GSM on mbed platforms.
Copyright (c) 2011-2023 Arduino LLC. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "GSM.h"

#include "mbed.h"
#include "CellularLog.h"
#include "CellularDevice.h"
#include "CellularContext.h"
#include "CellularInterface.h"
#include "GEMALTO_CINTERION_CellularStack.h"

#define MAXRETRY 3

bool _cmuxEnable = false;
arduino::CMUXClass * arduino::CMUXClass::get_default_instance()
arduino::CMUXClass *arduino::CMUXClass::get_default_instance()
{
static mbed::UnbufferedSerial serial(MBED_CONF_GEMALTO_CINTERION_TX, MBED_CONF_GEMALTO_CINTERION_RX, 115200);
serial.set_flow_control(mbed::SerialBase::RTSCTS_SW, MBED_CONF_GEMALTO_CINTERION_CTS, NC);
Expand All@@ -19,24 +38,24 @@ arduino::CMUXClass * arduino::CMUXClass::get_default_instance()

mbed::CellularDevice *mbed::CellularDevice::get_default_instance()
{
static auto cmux = arduino::CMUXClass::get_default_instance();
static mbed::GEMALTO_CINTERION device(cmux->get_serial(0));
nextSerialPort++;
device.enableCMUXChannel = mbed::callback(cmux, &arduino::CMUXClass::enableCMUXChannel);
return &device;
static auto cmux = arduino::CMUXClass::get_default_instance();
static mbed::GEMALTO_CINTERION device(cmux->get_serial(0));
nextSerialPort++;
device.enableCMUXChannel = mbed::callback(cmux, &arduino::CMUXClass::enableCMUXChannel);
return &device;
}

int arduino::GSMClass::begin(const char* pin, const char* apn, const char* username, const char* password, RadioAccessTechnologyType rat, uint32_t band, bool restart) {

if(restart || isCmuxEnable()) {
pinMode(PJ_10, OUTPUT);
digitalWrite(PJ_10, HIGH);
pinMode(MBED_CONF_GEMALTO_CINTERION_RST, OUTPUT);
digitalWrite(MBED_CONF_GEMALTO_CINTERION_RST, HIGH);
delay(800);
digitalWrite(PJ_10, LOW);
pinMode(PJ_7, OUTPUT);
digitalWrite(PJ_7, LOW);
digitalWrite(MBED_CONF_GEMALTO_CINTERION_RST, LOW);
pinMode(MBED_CONF_GEMALTO_CINTERION_ON, OUTPUT);
digitalWrite(MBED_CONF_GEMALTO_CINTERION_ON, LOW);
delay(1);
digitalWrite(PJ_7, HIGH);
digitalWrite(MBED_CONF_GEMALTO_CINTERION_ON, HIGH);
delay(1);
// this timer is to make sure that at boottime and when the CMUX is used,
// ^SYSTART is received in time to avoid stranger behaviour
Expand All@@ -50,7 +69,7 @@ int arduino::GSMClass::begin(const char* pin, const char* apn, const char* usern
printf("Invalid context\n");
return 0;
}
pinMode(PJ_7, INPUT_PULLDOWN);
pinMode(MBED_CONF_GEMALTO_CINTERION_ON, INPUT_PULLDOWN);

static mbed::DigitalOut rts(MBED_CONF_GEMALTO_CINTERION_RTS, 0);

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

void arduino::GSMClass::enableCmux(){
void arduino::GSMClass::enableCmux(){
_cmuxGSMenable = true;
}

bool arduino::GSMClass::isCmuxEnable(){
bool arduino::GSMClass::isCmuxEnable(){
return _cmuxGSMenable;
}

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

static PlatformMutex trace_mutex;

static void trace_wait()
bool arduino::GSMClass::isConnected()
{
trace_mutex.lock();
}

static void trace_release()
{
trace_mutex.unlock();
}

static char* trace_time(size_t ss)
{
static char time_st[50];
auto ms = std::chrono::time_point_cast<std::chrono::milliseconds>(rtos::Kernel::Clock::now()).time_since_epoch().count();
//snprintf(time_st, 49, "[%08llums]", ms);
snprintf(time_st, 1, "\n");
return time_st;
}

static Stream* trace_stream = nullptr;
static void arduino_print(const char* c) {
if (trace_stream) {
trace_stream->println(c);
if (_context) {
return _context->is_connected();
} else {
return false;
}
}

void arduino::GSMClass::debug(Stream& stream) {

#if MBED_CONF_MBED_TRACE_ENABLE

mbed_trace_init();

trace_stream = &stream;
mbed_trace_print_function_set(arduino_print);
mbed_trace_prefix_function_set( &trace_time );

mbed_trace_mutex_wait_function_set(trace_wait);
mbed_trace_mutex_release_function_set(trace_release);

mbed_cellular_trace::mutex_wait_function_set(trace_wait);
mbed_cellular_trace::mutex_release_function_set(trace_release);

#endif

}

NetworkInterface* arduino::GSMClass::getNetwork() {
return _context;
Expand Down
36 changes: 30 additions & 6 deletionslibraries/GSM/src/GSM.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
/*
GSM.h - Library for GSM on mbed platforms.
Copyright (c) 2011-2021 Arduino LLC. All right reserved.
Copyright (c) 2011-2023 Arduino LLC. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Expand All@@ -30,10 +33,28 @@
#include "CMUXClass.h"
#include "PTYSerial.h"

#define MBED_CONF_GEMALTO_CINTERION_TX PA_0
#define MBED_CONF_GEMALTO_CINTERION_RX PI_9
#define MBED_CONF_GEMALTO_CINTERION_RTS PI_10
#define MBED_CONF_GEMALTO_CINTERION_CTS PI_13
#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
#define MBED_CONF_GEMALTO_CINTERION_TX PA_0
#define MBED_CONF_GEMALTO_CINTERION_RX PI_9
#define MBED_CONF_GEMALTO_CINTERION_RTS PI_10
#define MBED_CONF_GEMALTO_CINTERION_CTS PI_13
#define MBED_CONF_GEMALTO_CINTERION_RST PJ_10
#define MBED_CONF_GEMALTO_CINTERION_ON PJ_7
#elif defined (ARDUINO_EDGE_CONTROL)
/* IMPORTANT: turn on the module's 5V on demand by calling
pinMode(ON_MKR2, OUTPUT);
digitalWrite(ON_MKR2, HIGH);
*/
#define MBED_CONF_GEMALTO_CINTERION_TX p24
#define MBED_CONF_GEMALTO_CINTERION_RX p25
#define MBED_CONF_GEMALTO_CINTERION_RTS NC
#define MBED_CONF_GEMALTO_CINTERION_CTS NC
#define MBED_CONF_GEMALTO_CINTERION_RST p31
#define MBED_CONF_GEMALTO_CINTERION_ON p2
#else
#error Gemalto Cinterion cellular connectivity not supported
#endif

#define MBED_CONF_APP_SOCK_TYPE 1

#if defined __has_include
Expand DownExpand Up@@ -87,10 +108,12 @@ class GSMClass : public MbedSocketClass {
bool setTime(unsigned long const epoch, int const timezone = 0);
void enableCmux();
bool isCmuxEnable();
void debug(Stream& stream);
void trace(Stream& stream);
void setTraceLevel(int trace_level, bool timestamp = false);
int ping(const char* hostname, uint8_t ttl = 128);
int ping(const String& hostname, uint8_t ttl = 128);
int ping(IPAddress host, uint8_t ttl = 128);
bool isConnected();

friend class GSMClient;
friend class GSMUDP;
Expand All@@ -115,6 +138,7 @@ class GSMClass : public MbedSocketClass {
extern GSMClass GSM;

#include "GSMClient.h"
#include "GSMSSLClient.h"
#include "GSMUdp.h"

#endif
24 changes: 24 additions & 0 deletionslibraries/GSM/src/GSMClient.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
/*
GSMClient.cpp
Copyright (c) 2023 Arduino SA. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "GSMClient.h"

arduino::GSMClient::GSMClient(): MbedClient(100) {

}
4 changes: 4 additions & 0 deletionslibraries/GSM/src/GSMClient.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,6 +26,10 @@
namespace arduino {

class GSMClient : public MbedClient {
public:
GSMClient();

private:
NetworkInterface *getNetwork() {
return GSM.getNetwork();
}
Expand Down
24 changes: 24 additions & 0 deletionslibraries/GSM/src/GSMSSLClient.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
/*
GSMSSLClient.cpp
Copyright (c) 2023 Arduino SA. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "GSMSSLClient.h"

arduino::GSMSSLClient::GSMSSLClient(): MbedSSLClient(100) {

}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp