Skip to content

Lora support #83

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jan 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*~
.vscode
*.orig
.vs
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ matrix:
- BOARD="arduino:samd:mkrwifi1010"
- env:
- BOARD="arduino:samd:mkrgsm1400"
- env:
- BOARD="arduino:samd:mkrwan1300"
- env:
- BOARD="esp8266:esp8266:huzzah"
- env:
Expand Down Expand Up @@ -69,6 +71,7 @@ before_install:
- installLibrary arduino-libraries/ArduinoBearSSL
- installLibrary arduino-libraries/ArduinoMqttClient
- installLibrary arduino-libraries/MKRGSM
- installLibrary arduino-libraries/MKRWAN
- installLibrary arduino-libraries/RTCZero
- installLibrary arduino-libraries/WiFi101
- installLibrary arduino-libraries/WiFiNINA
Expand All @@ -87,6 +90,11 @@ script:
buildExampleSketch ArduinoIoTCloud_Travis_CI;
buildExampleUtilitySketch Provisioning;
fi
- |
if [ "$BOARD" == "arduino:samd:mkrwan1300" ]; then
buildExampleSketch ArduinoIoTCloud_LED_switch;
buildExampleSketch ArduinoIoTCloud_Travis_CI;
fi
- |
if [ "$BOARD" == "arduino:samd:mkr1000" ] || [ "$BOARD" == "arduino:samd:mkrwifi1010" ]; then
buildExampleSketch WiFi_Cloud_Blink;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
When you flip the switch in the Cloud dashboard the onboard LED lights gets turned ON or OFF.

IMPORTANT:
This sketch will work with both WiFi and GSM enabled boards supported by Arduino IoT Cloud.
By default, settings for WiFi are chosen. If you prefer to use a GSM board take a look at thingProperties.h arduino_secrets.h,
to make sure you uncomment what's needed and comment incompatible instructions.
This sketch will work with WiFi, GSM and Lora enabled boards supported by Arduino IoT Cloud.
On a LoRa board, if it is configuered as a class A device (default and preferred option), values from Cloud dashboard are received
only after a value is sent to Cloud.

This sketch is compatible with:
- MKR 1000
- MKR WIFI 1010
- MKR GSM 1400
- MKR WAN 1300/1310
*/
#include "arduino_secrets.h"
#include "thingProperties.h"
Expand All @@ -30,7 +31,7 @@ void setup() {

// initProperties takes care of connecting your sketch variables to the ArduinoIoTCloud object
initProperties();
// tell ArduinoIoTCloud to use our WiFi connection
// tell ArduinoIoTCloud to use right connection handler
ArduinoCloud.begin(ArduinoIoTPreferredConnection);

/*
Expand Down
6 changes: 6 additions & 0 deletions examples/ArduinoIoTCloud_LED_switch/arduino_secrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@
#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
9 changes: 9 additions & 0 deletions examples/ArduinoIoTCloud_LED_switch/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#if defined(BOARD_HAS_WIFI)
#elif defined(BOARD_HAS_GSM)
#elif defined(BOARD_HAS_LORA)
#else
#error "Arduino IoT Cloud currently only supports MKR1000, MKR WiFi 1010 and MKR GSM 1400"
#endif
Expand All @@ -18,12 +19,20 @@ int potentiometer;

void initProperties() {
ArduinoCloud.setThingId(THING_ID);
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM)
ArduinoCloud.addProperty(led, READWRITE, ON_CHANGE, onLedChange);
ArduinoCloud.addProperty(potentiometer, READ, ON_CHANGE);
#elif defined(BOARD_HAS_LORA)
ArduinoCloud.addProperty(led, 1, READWRITE, ON_CHANGE, onLedChange);
ArduinoCloud.addProperty(potentiometer, 2, READ, ON_CHANGE);
#endif

}

#if 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, _lora_class::CLASS_A);
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- MKR 1000
- MKR WIFI 1010
- MKR GSM 1400
- MKR WAN 1300/1310
*/

#include "arduino_secrets.h"
Expand Down
7 changes: 7 additions & 0 deletions examples/ArduinoIoTCloud_Travis_CI/arduino_secrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@
#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

39 changes: 37 additions & 2 deletions examples/ArduinoIoTCloud_Travis_CI/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

#if defined(BOARD_HAS_WIFI)
#elif defined(BOARD_HAS_GSM)
#elif defined(BOARD_HAS_LORA)
#else
#error "Arduino IoT Cloud currently only supports MKR1000, MKR WiFi 1010 and MKR GSM 1400"
#error "Arduino IoT Cloud currently only supports MKR1000, MKR WiFi 1010, MKR GSM 1400 and MKR WAN 1300/1310"
#endif

/******************************************************************************
Expand Down Expand Up @@ -57,6 +58,8 @@ String str_property_8;
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, EU868);
#endif

/******************************************************************************
Expand All @@ -71,7 +74,7 @@ void onStringPropertyChange();
/******************************************************************************
FUNCTIONS
******************************************************************************/

#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM)
void initProperties() {
ArduinoCloud.setThingId(THING_ID);

Expand Down Expand Up @@ -101,3 +104,35 @@ void initProperties() {
ArduinoCloud.addProperty(str_property_7, Permission::ReadWrite).publishEvery(1 * SECONDS).onSync(CLOUD_WINS);
ArduinoCloud.addProperty(str_property_8, Permission::ReadWrite).publishEvery(1 * SECONDS).onSync(DEVICE_WINS);
}

#elif defined(BOARD_HAS_LORA)
void initProperties() {
ArduinoCloud.setThingId(THING_ID);

ArduinoCloud.addProperty(bool_property_1, 1, READWRITE, 1 * SECONDS);
ArduinoCloud.addProperty(int_property_1, 2, READ, 2 * MINUTES);
ArduinoCloud.addProperty(float_property_1, 3, WRITE, 3 * HOURS);
ArduinoCloud.addProperty(str_property_1, 4, READWRITE, 4 * DAYS);

ArduinoCloud.addProperty(bool_property_2, 5, Permission::ReadWrite).publishEvery(1 * SECONDS);
ArduinoCloud.addProperty(int_property_2, 6, Permission::Read).publishEvery(1 * MINUTES);
ArduinoCloud.addProperty(float_property_2, 7, Permission::Write).publishEvery(3 * HOURS);
ArduinoCloud.addProperty(str_property_2, 8, Permission::ReadWrite).publishEvery(4 * DAYS);

ArduinoCloud.addProperty(int_property_3, 9, READWRITE, ON_CHANGE); /* Default 'minDelta' = 0 */
ArduinoCloud.addProperty(int_property_4, 10, READWRITE, ON_CHANGE, onIntPropertyChange); /* Default 'minDelta' = 0 */
ArduinoCloud.addProperty(int_property_5, 11, READWRITE, ON_CHANGE, 0 /* onIntPropertyChange */, MIN_DELTA_INT_PROPERTY);
ArduinoCloud.addProperty(int_property_6, 12, READWRITE, ON_CHANGE, onIntPropertyChange, MIN_DELTA_INT_PROPERTY);

ArduinoCloud.addProperty(float_property_3, 13, Permission::ReadWrite).publishOnChange(MIN_DELTA_FLOAT_PROPERTY);
ArduinoCloud.addProperty(float_property_4, 14, Permission::ReadWrite).publishOnChange(MIN_DELTA_FLOAT_PROPERTY).onUpdate(onFloatPropertyChange);

ArduinoCloud.addProperty(str_property_3, 15, READWRITE, 1 * SECONDS, 0 /* onStringPropertyChange */, 0.0 /* 'minDelta' */, MOST_RECENT_WINS);
ArduinoCloud.addProperty(str_property_4, 16, READWRITE, 1 * SECONDS, 0 /* onStringPropertyChange */, 0.0 /* 'minDelta' */, CLOUD_WINS);
ArduinoCloud.addProperty(str_property_5, 17, READWRITE, 1 * SECONDS, 0 /* onStringPropertyChange */, 0.0 /* 'minDelta' */, DEVICE_WINS);

ArduinoCloud.addProperty(str_property_6, 18, Permission::ReadWrite).publishEvery(1 * SECONDS).onSync(MOST_RECENT_WINS);
ArduinoCloud.addProperty(str_property_7, 19, Permission::ReadWrite).publishEvery(1 * SECONDS).onSync(CLOUD_WINS);
ArduinoCloud.addProperty(str_property_8, 20, Permission::ReadWrite).publishEvery(1 * SECONDS).onSync(DEVICE_WINS);
}
#endif
1 change: 1 addition & 0 deletions extras/codespell-ignore-words-list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
wan
Loading