Skip to content

Commit

Permalink
Merge pull request #762 from arduino/edge_gsm_fixes
Browse files Browse the repository at this point in the history
Edge control build fixes and CI
  • Loading branch information
facchinm authored Nov 16, 2023
2 parents 7800f10 + e2e2c64 commit e2cff95
Show file tree
Hide file tree
Showing 18 changed files with 164 additions and 27 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
- fqbn: arduino:mbed:opta
- fqbn: arduino:mbed:giga
- fqbn: arduino:mbed:nicla_voice
- fqbn: arduino:mbed:edge_control

# compile only the examples compatible with each board
include:
Expand Down Expand Up @@ -170,6 +171,15 @@ jobs:
version: v0.9.6
- name: arduino-libg722
source-url: https://github.com/pschatzmann/arduino-libg722.git
- board:
fqbn: arduino:mbed:edge_control
additional-libraries: |
- name: MicroNMEA
additional-sketch-paths: |
- libraries/GSM
- libraries/USBHID
- libraries/USBMSD/examples/Nano33BLE_FlashMassStorage
- libraries/ThreadDebug
steps:
- name: Checkout repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class AT_CellularContext : public CellularContext {
* @return NIDD context text, e.g. Non-IP or NONIP
*/
virtual const char *get_nonip_context_type_str();
virtual void enable_access_technology();
virtual nsapi_error_t enable_access_technology();
virtual void set_cid(int cid);

private:
Expand All @@ -135,15 +135,15 @@ class AT_CellularContext : public CellularContext {

PinName _dcd_pin;
bool _active_high;
RadioAccessTechnologyType _rat;
FrequencyBand _band;

protected:
char _found_apn[MAX_APN_LENGTH];
// flag indicating if CP was requested to be setup
bool _cp_req;
bool _is_connected;
ATHandler &_at;
RadioAccessTechnologyType _rat;
FrequencyBand _band;
};

} // namespace mbed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class GEMALTO_CINTERION_CellularContext: public AT_CellularContext {
virtual NetworkStack *get_stack();
#endif // NSAPI_PPP_AVAILABLE
virtual nsapi_error_t do_user_authentication();
virtual nsapi_error_t enable_access_technology();
};

} /* namespace mbed */
Expand Down
11 changes: 1 addition & 10 deletions cores/arduino/mbed/platform/include/platform/Callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@
#include <mstd_type_traits>
#include <mstd_functional>

#pragma GCC push_options
// This prevents the GCC compiler from applying optimizations that assume the code follows strict aliasing rules.
// In order to prevent bugs arising from undefined behavior that is tricky to find in the Callback implementation,
// or simply from compiler bugs in GCC.
#pragma GCC optimize("-fno-strict-aliasing")
// This prevents the GCC compiler from generating incorrect inline code for the Callback constructor.
#pragma GCC optimize("-fno-inline")

// Controlling switches from config:
// MBED_CONF_PLATFORM_CALLBACK_NONTRIVIAL - support storing non-trivial function objects
// MBED_CONF_PLATFORM_CALLBACK_COMPARABLE - support memcmp comparing stored objects (requires zero padding)
Expand All @@ -44,6 +36,7 @@
#define MBED_CONF_PLATFORM_CALLBACK_NONTRIVIAL 1
#endif


namespace mbed {
/** \addtogroup platform-public-api */
/** @{*/
Expand Down Expand Up @@ -842,6 +835,4 @@ Callback(R(*func)(const volatile T *, ArgTs...), const volatile U *arg) -> Callb

} // namespace mbed

#pragma GCC pop_options

#endif
2 changes: 1 addition & 1 deletion edge.variables
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export FLAVOUR="edge"
export VARIANTS=("EDGE_CONTROL")
export FQBNS=("edge_control")
export LIBRARIES=("PDM SPI Wire MRI USBHID USBMSD ThreadDebug Scheduler")
export LIBRARIES=("SocketWrapper GSM GPS SPI Wire MRI USBHID USBMSD ThreadDebug Scheduler")
export BOOTLOADERS=("EDGE_CONTROL")
2 changes: 1 addition & 1 deletion libraries/GPS/library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ sentence=GPS Support Library
paragraph=
category=Other
url=http://www.arduino.cc/en/Reference/GSM
architectures=mbed,ArduinoCore-mbed,mbed_portenta
architectures=mbed,ArduinoCore-mbed,mbed_portenta,mbed_edge
11 changes: 11 additions & 0 deletions libraries/GSM/examples/GNSSClient/GNSSClient.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,20 @@ char username[] = SECRET_USERNAME;
char pass[] = SECRET_PASSWORD;

void setup() {

#if defined(ARDUINO_EDGE_CONTROL)
// Power ON MKR2
pinMode(ON_MKR2, OUTPUT);
digitalWrite(ON_MKR2, HIGH);
#endif

Serial.begin(115200);
while (!Serial) {}

// To enable AT Trace debug uncomment the following lines
//GSM.trace(Serial);
//GSM.setTraceLevel(4);

Serial.println("Starting Carrier Network registration");
if(!GSM.begin(pin, apn, username, pass, CATNB)){
Serial.println("The board was not able to register to the network...");
Expand Down
14 changes: 12 additions & 2 deletions libraries/GSM/examples/GSMClient/GSMClient.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include <GSM.h>

REDIRECT_STDOUT_TO(Serial);

#include "arduino_secrets.h"
char pin[] = SECRET_PIN;
char apn[] = SECRET_APN;
Expand All @@ -14,8 +12,20 @@ int port = 80;
GSMClient client;

void setup() {

#if defined(ARDUINO_EDGE_CONTROL)
// Power ON MKR2
pinMode(ON_MKR2, OUTPUT);
digitalWrite(ON_MKR2, HIGH);
#endif

Serial.begin(115200);
while(!Serial) {}

// To enable AT Trace debug uncomment the following lines
//GSM.trace(Serial);
//GSM.setTraceLevel(4);

Serial.println("Starting Carrier Network registration");
if(!GSM.begin(pin, apn, username, pass, CATNB, BAND_20 | BAND_19)){
Serial.println("The board was not able to register to the network...");
Expand Down
27 changes: 23 additions & 4 deletions libraries/GSM/examples/GSMSSLClient/GSMSSLClient.ino
Original file line number Diff line number Diff line change
@@ -1,27 +1,46 @@
/*
GSMSSLlient
This sketch connects to a website (https://ifconfig.me)
This sketch connects to a website (https://example.com)
using the Portenta CAT.M1/NB IoT GNSS Shield and TLS.
*/

#include <GSM.h>

#include "arduino_secrets.h"

#if defined(ARDUINO_EDGE_CONTROL)
#include "root_ca.h"
#endif

char pin[] = SECRET_PIN;
char apn[] = SECRET_APN;
char username[] = SECRET_USERNAME;
char pass[] = SECRET_PASSWORD;

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

void setup() {

#if defined(ARDUINO_EDGE_CONTROL)
// Power ON MKR2
pinMode(ON_MKR2, OUTPUT);
digitalWrite(ON_MKR2, HIGH);

// Configure root certificate
client.appendCustomCACert(root_ca);
#endif

Serial.begin(115200);
while(!Serial) {}

// To enable AT Trace debug uncomment the following lines
//GSM.trace(Serial);
//GSM.setTraceLevel(4);

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...");
Expand All @@ -33,7 +52,7 @@ void setup() {
if (client.connect(server, port)) {
Serial.println("connected to server");
// Make a HTTP request:
client.println("GET /ip HTTP/1.1");
client.println("GET / HTTP/1.1");
client.print("Host: ");
client.println(server);
client.println("Connection: close");
Expand Down
23 changes: 23 additions & 0 deletions libraries/GSM/examples/GSMSSLClient/root_ca.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
static const char root_ca[] =
"-----BEGIN CERTIFICATE-----\n"
"MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh\n"
"MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n"
"d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD\n"
"QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT\n"
"MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n"
"b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG\n"
"9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB\n"
"CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97\n"
"nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt\n"
"43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P\n"
"T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4\n"
"gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO\n"
"BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR\n"
"TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw\n"
"DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr\n"
"hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg\n"
"06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF\n"
"PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls\n"
"YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk\n"
"CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=\n"
"-----END CERTIFICATE-----\n";
2 changes: 1 addition & 1 deletion libraries/GSM/library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ sentence=GSM wrapper
paragraph=
category=Other
url=http://www.arduino.cc/en/Reference/GSM
architectures=mbed,ArduinoCore-mbed,mbed_portenta
architectures=mbed,ArduinoCore-mbed,mbed_portenta,mbed_edge
2 changes: 2 additions & 0 deletions libraries/GSM/src/GSM.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ class GSMClass : public MbedSocketClass {
bool setTime(unsigned long const epoch, int const timezone = 0);
void enableCmux();
bool isCmuxEnable();
#if MBED_CONF_MBED_TRACE_ENABLE
void trace(Stream& stream);
void setTraceLevel(int trace_level, bool timestamp = false);
#endif
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
#define led2 LEDG
#define led3 LEDB

// On Edge Control there are no leds so we use GPIO and Serial
#elif defined(ARDUINO_EDGE_CONTROL)

#define led1 CMD_TRIAC_3
#define led2 CMD_TRIAC_4
#define led3 NOT_A_PIN

#else

int led1 = LEDR;
Expand Down
2 changes: 1 addition & 1 deletion libraries/SocketWrapper/library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ sentence=Wrapper for mbed Socket classes
paragraph=
category=Other
url=http://www.arduino.cc/en/Reference/WiFi
architectures=mbed,ArduinoCore-mbed,mbed_portenta,mbed_nicla,mbed_opta,mbed_giga
architectures=mbed,ArduinoCore-mbed,mbed_portenta,mbed_nicla,mbed_opta,mbed_giga,mbed_edge
2 changes: 1 addition & 1 deletion variants/EDGE_CONTROL/defines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
-DFEATURE_STORAGE=1
-D__FPU_PRESENT=1
-D__MBED__=1
-DMBED_BUILD_TIMESTAMP=1690447154.5646534
-DMBED_BUILD_TIMESTAMP=1700127377.3953335
-D__MBED_CMSIS_RTOS_CM
-DMBED_MPU_CUSTOM
-DMBED_TICKLESS
Expand Down
27 changes: 27 additions & 0 deletions variants/EDGE_CONTROL/includes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,33 @@
-iwithprefixbefore/mbed/connectivity/drivers/802.15.4_RF/stm-s2lp-rf-driver/source
-iwithprefixbefore/mbed/connectivity/drivers/802.15.4_RF/stm-s2lp-rf-driver/stm-s2lp-rf-driver
-iwithprefixbefore/mbed/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x
-iwithprefixbefore/mbed/connectivity/drivers/cellular
-iwithprefixbefore/mbed/connectivity/drivers/cellular/Altair
-iwithprefixbefore/mbed/connectivity/drivers/cellular/Altair/ALT1250
-iwithprefixbefore/mbed/connectivity/drivers/cellular/Altair/ALT1250/PPP
-iwithprefixbefore/mbed/connectivity/drivers/cellular/GEMALTO
-iwithprefixbefore/mbed/connectivity/drivers/cellular/GEMALTO/CINTERION
-iwithprefixbefore/mbed/connectivity/drivers/cellular/GENERIC
-iwithprefixbefore/mbed/connectivity/drivers/cellular/GENERIC/GENERIC_AT3GPP
-iwithprefixbefore/mbed/connectivity/drivers/cellular/MultiTech
-iwithprefixbefore/mbed/connectivity/drivers/cellular/MultiTech/DragonflyNano
-iwithprefixbefore/mbed/connectivity/drivers/cellular/MultiTech/DragonflyNano/PPP
-iwithprefixbefore/mbed/connectivity/drivers/cellular/QUECTEL
-iwithprefixbefore/mbed/connectivity/drivers/cellular/QUECTEL/BC95
-iwithprefixbefore/mbed/connectivity/drivers/cellular/QUECTEL/BG96
-iwithprefixbefore/mbed/connectivity/drivers/cellular/QUECTEL/EC2X
-iwithprefixbefore/mbed/connectivity/drivers/cellular/QUECTEL/M26
-iwithprefixbefore/mbed/connectivity/drivers/cellular/QUECTEL/UG96
-iwithprefixbefore/mbed/connectivity/drivers/cellular/RiotMicro
-iwithprefixbefore/mbed/connectivity/drivers/cellular/RiotMicro/AT
-iwithprefixbefore/mbed/connectivity/drivers/cellular/TELIT
-iwithprefixbefore/mbed/connectivity/drivers/cellular/TELIT/HE910
-iwithprefixbefore/mbed/connectivity/drivers/cellular/TELIT/ME310
-iwithprefixbefore/mbed/connectivity/drivers/cellular/TELIT/ME910
-iwithprefixbefore/mbed/connectivity/drivers/cellular/UBLOX
-iwithprefixbefore/mbed/connectivity/drivers/cellular/UBLOX/AT
-iwithprefixbefore/mbed/connectivity/drivers/cellular/UBLOX/N2XX
-iwithprefixbefore/mbed/connectivity/drivers/cellular/UBLOX/PPP
-iwithprefixbefore/mbed/connectivity/drivers/mbedtls/FEATURE_CRYPTOCELL310
-iwithprefixbefore/mbed/connectivity/drivers/mbedtls/FEATURE_CRYPTOCELL310/TARGET_MCU_NRF52840
-iwithprefixbefore/mbed/connectivity/drivers/mbedtls/FEATURE_CRYPTOCELL310/include
Expand Down
Binary file modified variants/EDGE_CONTROL/libs/libmbed.a
Binary file not shown.
Loading

0 comments on commit e2cff95

Please sign in to comment.