From c94929b0857fbba9ccdf7791b8bd59a2db699898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Thu, 13 Feb 2025 16:40:47 +0100 Subject: [PATCH 1/3] Added information about sync options --- .../arduino-cloud/03.cloud-interface/00.sketches/sketches.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/content/arduino-cloud/03.cloud-interface/00.sketches/sketches.md b/content/arduino-cloud/03.cloud-interface/00.sketches/sketches.md index 25ac653d71..e75a3fa6b6 100644 --- a/content/arduino-cloud/03.cloud-interface/00.sketches/sketches.md +++ b/content/arduino-cloud/03.cloud-interface/00.sketches/sketches.md @@ -70,6 +70,11 @@ The sketch file is generated with a set of additional Cloud-specific methods inc - `ArduinoCloud.begin()` starts the library with the preferred connection (e.g. Wi-Fi® or LoRaWAN®). - `ArduinoCloud.update()` - synchronizes all data between the board and the Arduino Cloud. +There are a few different options when it comes to synchronization of your cloud sketch: +- `MOST_RECENT_WINS` - Best for real-time applications where the latest data should always be used, regardless of source. +- `CLOUD_WINS` - Useful when the cloud holds critical configurations or settings that should always be enforced on the device. +- `DEVICE_WINS` - Used when the device generates important real-time data (sensor readings) that should always be preserved over cloud updates. + In addition, any variable created with a read/write permission will also generate a callback function that executes whenever the variable's value changes. - If you create a variable called `test`, the function will render as `void onTestChange(){}` From 38fedcff7f67956c5fedd9613209ba78560dd6dd Mon Sep 17 00:00:00 2001 From: BenjaminDannegard Date: Wed, 26 Feb 2025 13:43:17 +0100 Subject: [PATCH 2/3] Changed place for text --- .../03.cloud-interface/00.sketches/sketches.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/content/arduino-cloud/03.cloud-interface/00.sketches/sketches.md b/content/arduino-cloud/03.cloud-interface/00.sketches/sketches.md index e75a3fa6b6..00fb6a3a3b 100644 --- a/content/arduino-cloud/03.cloud-interface/00.sketches/sketches.md +++ b/content/arduino-cloud/03.cloud-interface/00.sketches/sketches.md @@ -70,11 +70,6 @@ The sketch file is generated with a set of additional Cloud-specific methods inc - `ArduinoCloud.begin()` starts the library with the preferred connection (e.g. Wi-Fi® or LoRaWAN®). - `ArduinoCloud.update()` - synchronizes all data between the board and the Arduino Cloud. -There are a few different options when it comes to synchronization of your cloud sketch: -- `MOST_RECENT_WINS` - Best for real-time applications where the latest data should always be used, regardless of source. -- `CLOUD_WINS` - Useful when the cloud holds critical configurations or settings that should always be enforced on the device. -- `DEVICE_WINS` - Used when the device generates important real-time data (sensor readings) that should always be preserved over cloud updates. - In addition, any variable created with a read/write permission will also generate a callback function that executes whenever the variable's value changes. - If you create a variable called `test`, the function will render as `void onTestChange(){}` @@ -108,6 +103,17 @@ void onTestChange(){ } ``` +There are a few different options when it comes to synchronization of your cloud sketch: +- `MOST_RECENT_WINS` - The latest update whether from the device or the cloud is used. Best for real-time applications where the latest data should always be used, regardless of source. +- `CLOUD_WINS` - The cloud value always overwrites the device value. Useful when the cloud holds critical configurations or settings that should always be enforced on the device. +- `DEVICE_WINS` - The device value always overwrites the cloud value. Used when the device generates important real-time data (sensor readings) that should always be preserved over cloud updates. + +It can be set in your sketch with: + +```arduino +setSyncPolicy(MOST_RECENT_WINS); // or CLOUD_WINS, DEVICE_WINS +``` + ### Configuration Header File The `thingProperties.h` file is a non-editable file that updates based on changes made in your Thing. For example: From c9e3d1fc203ba803bed2ab98599241b170af72e2 Mon Sep 17 00:00:00 2001 From: BenjaminDannegard Date: Wed, 26 Feb 2025 19:30:20 +0100 Subject: [PATCH 3/3] Update content/arduino-cloud/03.cloud-interface/00.sketches/sketches.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Karl Söderby <35461661+karlsoderby@users.noreply.github.com> --- .../arduino-cloud/03.cloud-interface/00.sketches/sketches.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/arduino-cloud/03.cloud-interface/00.sketches/sketches.md b/content/arduino-cloud/03.cloud-interface/00.sketches/sketches.md index 00fb6a3a3b..1ac4e0398f 100644 --- a/content/arduino-cloud/03.cloud-interface/00.sketches/sketches.md +++ b/content/arduino-cloud/03.cloud-interface/00.sketches/sketches.md @@ -103,7 +103,7 @@ void onTestChange(){ } ``` -There are a few different options when it comes to synchronization of your cloud sketch: +There are a few different options available for synchronizing your sketch with the Arduino Cloud: - `MOST_RECENT_WINS` - The latest update whether from the device or the cloud is used. Best for real-time applications where the latest data should always be used, regardless of source. - `CLOUD_WINS` - The cloud value always overwrites the device value. Useful when the cloud holds critical configurations or settings that should always be enforced on the device. - `DEVICE_WINS` - The device value always overwrites the cloud value. Used when the device generates important real-time data (sensor readings) that should always be preserved over cloud updates.