Skip to content

Commit

Permalink
Merge branch 'release/v1.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
valeros committed Dec 27, 2023
2 parents 9ccefca + 5cced3c commit 8205822
Show file tree
Hide file tree
Showing 15 changed files with 290 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
- "examples/arduino-internal-libs"
- "examples/arduino-uno-r4-led-animation"
- "examples/arduino-wifiscan"
- "examples/arduino-iot-cloud-basic"
- "examples/cmsis-blink"
- "examples/fsp-blink"
- "examples/fsp-button-isr"
Expand Down
2 changes: 1 addition & 1 deletion boards/portenta_c33.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"variant": "PORTENTA_C33"
},
"debug": {
"jlink_device": "R7FA6M5",
"jlink_device": "R7FA6M5BH",
"svd_path": "R7FA6M5BH.svd"
},
"frameworks": [
Expand Down
2 changes: 1 addition & 1 deletion boards/uno_r4_minima.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"variant": "MINIMA"
},
"debug": {
"jlink_device": "ra4m1",
"jlink_device": "R7FA4M1AB",
"svd_path": "R7FA4M1AB.svd"
},
"frameworks": [
Expand Down
2 changes: 1 addition & 1 deletion boards/uno_r4_wifi.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"onboard_tools": [
"cmsis-dap"
],
"jlink_device": "ra4m1",
"jlink_device": "R7FA4M1AB",
"openocd_config": "openocd.cfg",
"svd_path": "R7FA4M1AB.svd"
},
Expand Down
9 changes: 7 additions & 2 deletions builder/frameworks/arduino.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ def load_flags(filename):
"-mcpu=%s" % board.get("build.cpu"),
"-mthumb",
"-Wl,--gc-sections",
"--specs=nano.specs",
"--specs=nosys.specs",
"-nostdlib",
'-Wl,-Map="%s"' % os.path.join("${BUILD_DIR}", "${PROGNAME}.map")
],

Expand Down Expand Up @@ -149,6 +147,13 @@ def load_flags(filename):
]
)

if board.id != "portenta_c33":
env.Append(
LINKFLAGS=[
"--specs=nano.specs",
]
)

#
# Add Linker scripts
#
Expand Down
1 change: 1 addition & 0 deletions examples/arduino-iot-cloud-basic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.pio
21 changes: 21 additions & 0 deletions examples/arduino-iot-cloud-basic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
How to build PlatformIO based project
=====================================

1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html)
2. Download [development platform with examples](https://github.com/platformio/platform-renesas-ra/archive/develop.zip)
3. Extract ZIP archive
4. Run these commands:

```shell
# Change directory to example
$ cd platform-renesas-ra/examples/arduino-iot-cloud-basic

# Build project
$ pio run

# Upload firmware
$ pio run --target upload

# Clean build files
$ pio run --target clean
```
39 changes: 39 additions & 0 deletions examples/arduino-iot-cloud-basic/include/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

This directory is intended for project header files.

A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.

```src/main.c

#include "header.h"

int main (void)
{
...
}
```

Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.

In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.

Read more about using header files in official GCC documentation:

* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes

https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
46 changes: 46 additions & 0 deletions examples/arduino-iot-cloud-basic/lib/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.

The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").

For example, see a structure of the following two libraries `Foo` and `Bar`:

|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c

and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>

int main (void)
{
...
}

```

PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.

More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
21 changes: 21 additions & 0 deletions examples/arduino-iot-cloud-basic/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter, extra scripting
; Upload options: custom port, speed and extra flags
; Library options: dependencies, extra library storages
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env]
platform = renesas-ra
framework = arduino
lib_ldf_mode = deep+
lib_deps =
arduino-libraries/ArduinoIoTCloud@^1.13.0

[env:portenta_c33]
board = portenta_c33

[env:uno_r4_wifi]
board = uno_r4_wifi
55 changes: 55 additions & 0 deletions examples/arduino-iot-cloud-basic/src/ArduinoIoTCloud-Basic.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
This sketch demonstrates how to exchange data between your board and the Arduino IoT Cloud.
* Connect a potentiometer (or other analog sensor) to A0.
* When the potentiometer (or sensor) value changes the data is sent to the Cloud.
* When you flip the switch in the Cloud dashboard the onboard LED lights gets turned ON or OFF.
IMPORTANT:
This sketch works with WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
On a LoRa board, if it is configured as a class A device (default and preferred option), values from Cloud dashboard are received
only after a value is sent to Cloud.
The full list of compatible boards can be found here:
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
*/

#include "arduino_secrets.h"
#include "thingProperties.h"

#if !defined(LED_BUILTIN) && !defined(ARDUINO_NANO_ESP32)
static int const LED_BUILTIN = 2;
#endif

void setup() {
/* Initialize serial and wait up to 5 seconds for port to open */
Serial.begin(9600);
for(unsigned long const serialBeginTime = millis(); !Serial && (millis() - serialBeginTime > 5000); ) { }

/* Configure LED pin as an output */
pinMode(LED_BUILTIN, OUTPUT);

/* This function takes care of connecting your sketch variables to the ArduinoIoTCloud object */
initProperties();

/* Initialize Arduino IoT Cloud library */
ArduinoCloud.begin(ArduinoIoTPreferredConnection);

setDebugMessageLevel(DBG_INFO);
ArduinoCloud.printDebugInfo();
}

void loop() {
ArduinoCloud.update();
potentiometer = analogRead(A0);
seconds = millis() / 1000;
}

/*
* 'onLedChange' is called when the "led" property of your Thing changes
*/
void onLedChange() {
Serial.print("LED set to ");
Serial.println(led);
digitalWrite(LED_BUILTIN, led);
}
37 changes: 37 additions & 0 deletions examples/arduino-iot-cloud-basic/src/arduino_secrets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>

/* A complete list of supported boards with WiFi is available here:
* https://github.com/arduino-libraries/ArduinoIoTCloud/#what
*/
#if defined(BOARD_HAS_WIFI)
#define SECRET_SSID "YOUR_WIFI_NETWORK_NAME"
#define SECRET_PASS "YOUR_WIFI_PASSWORD"
#endif

/* ESP8266 ESP32*/
#if defined(BOARD_HAS_SECRET_KEY)
#define SECRET_DEVICE_KEY "my-device-password"
#endif

/* MKR GSM 1400 */ /* MKR NB 1500 */ /* Portenta CAT.M1/NB IoT GNSS Shield */
#if defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_CATM1_NBIOT)
#define SECRET_PIN ""
#define SECRET_APN ""
#define SECRET_LOGIN ""
#define SECRET_PASS ""
#endif

/* MKR WAN 1300/1310 */
#if defined(BOARD_HAS_LORA)
#define SECRET_APP_EUI ""
#define SECRET_APP_KEY ""
#endif

/* Portenta H7 + Ethernet shield */
#if defined(BOARD_HAS_ETHERNET)
#define SECRET_OPTIONAL_IP ""
#define SECRET_OPTIONAL_DNS ""
#define SECRET_OPTIONAL_GATEWAY ""
#define SECRET_OPTIONAL_NETMASK ""
#endif
47 changes: 47 additions & 0 deletions examples/arduino-iot-cloud-basic/src/thingProperties.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#if !(defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_LORA) || \
defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT))
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif

#if defined(BOARD_HAS_SECRET_KEY)
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#endif

void onLedChange();

bool led;
int potentiometer;
int seconds;

void initProperties() {
#if defined(BOARD_HAS_SECRET_KEY)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT)
ArduinoCloud.addProperty(led, Permission::Write).onUpdate(onLedChange);
ArduinoCloud.addProperty(potentiometer, Permission::Read).publishOnChange(10);
ArduinoCloud.addProperty(seconds, Permission::Read).publishOnChange(1);
#elif defined(BOARD_HAS_LORA)
ArduinoCloud.addProperty(led, 1, READWRITE, ON_CHANGE, onLedChange);
ArduinoCloud.addProperty(potentiometer, 2, READ, ON_CHANGE);
ArduinoCloud.addProperty(seconds, 3, READ, 5 * MINUTES);
#endif
}

#if defined(BOARD_HAS_ETHERNET)
/* DHCP mode */
//EthernetConnectionHandler ArduinoIoTPreferredConnection;
/* Manual mode. It will fallback in DHCP mode if SECRET_OPTIONAL_IP is invalid or equal to "0.0.0.0" */
EthernetConnectionHandler ArduinoIoTPreferredConnection(SECRET_OPTIONAL_IP, SECRET_OPTIONAL_DNS, SECRET_OPTIONAL_GATEWAY, SECRET_OPTIONAL_NETMASK);
#elif defined(BOARD_HAS_WIFI)
WiFiConnectionHandler ArduinoIoTPreferredConnection(SECRET_SSID, SECRET_PASS);
#elif defined(BOARD_HAS_GSM)
GSMConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
#elif defined(BOARD_HAS_LORA)
LoRaConnectionHandler ArduinoIoTPreferredConnection(SECRET_APP_EUI, SECRET_APP_KEY, _lora_band::EU868, NULL, _lora_class::CLASS_A);
#elif defined(BOARD_HAS_NB)
NBConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
#elif defined(BOARD_HAS_CATM1_NBIOT)
CatM1ConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
#endif
11 changes: 11 additions & 0 deletions examples/arduino-iot-cloud-basic/test/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

This directory is intended for PIO Unit Testing and project tests.

Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.

More information about PIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html
2 changes: 1 addition & 1 deletion platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"type": "git",
"url": "https://github.com/platformio/platform-renesas-ra.git"
},
"version": "1.3.0",
"version": "1.3.1",
"frameworks": {
"arduino": {
"package": "framework-arduinorenesas-uno",
Expand Down

0 comments on commit 8205822

Please sign in to comment.