-
Notifications
You must be signed in to change notification settings - Fork 82
Add new examples #55
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
Add new examples #55
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
3af2e77
add new CloudBlink example
umbynos 032a024
remove some comments
umbynos 2f10025
Merge branch 'master' of github.com:arduino-libraries/ArduinoIoTCloud…
umbynos 5f7ef98
Merge branch 'master' of github.com:arduino-libraries/ArduinoIoTCloud…
umbynos 0095a53
fix errors and improvements
umbynos 4e02f2c
move example sketch in proper folder
umbynos f0cfd21
add new CloudBlink example
umbynos 0c3369a
remove some comments
umbynos c51fccc
fix errors and improvements
umbynos 70c9324
move example sketch in proper folder
umbynos e156a2c
Merge branch 'add-new-examples' of github.com:arduino-libraries/Ardui…
umbynos 2112403
apply code formatting according to examples_formatter.conf
umbynos a4388b4
Update examples/MKRWIFI1010_Cloud_Blink/MKRWIFI1010_Cloud_Blink.ino
aentinger 3f3a848
Update examples/MKRWIFI1010_Cloud_Blink/MKRWIFI1010_Cloud_Blink.ino
per1234 5eb39ab
Build 'MKRWIFI1010_Cloud_Blink.ino' with Travis
aentinger ec30765
MKRWIFI1010_Cloud_Blink is now compilable for both WIFI and GSM enabl…
aentinger 318fb5f
Defining arduino secrets blank in case they are undefined and issue a…
aentinger c029e46
split Cloud_Blink sketch, one for GSM and the other one for WiFi enab…
umbynos 9197919
Update .travis.yml
umbynos 3c087da
Update .travis.yml
per1234 833522f
Update .travis.yml
per1234 bc39f7f
fix a problem with CloudSerial not being initialized
umbynos fc08f1b
add code fortmatting for GSM_Cloud_Blink
umbynos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#include <ArduinoIoTCloud.h> | ||
#include <ConnectionManager.h> | ||
#include <GSMConnectionManager.h> | ||
|
||
#ifndef SECRET_PIN | ||
#define SECRET_PIN "" | ||
#warning "You need to define SECRET_PIN in tab/arduino_secrets.h" | ||
#endif | ||
|
||
#ifndef SECRET_APN | ||
#define SECRET_APN "" | ||
#warning "You need to define SECRET_PIN in tab/arduino_secrets.h" | ||
#endif | ||
|
||
#ifndef SECRET_LOGIN | ||
#define SECRET_LOGIN "" | ||
#warning "You need to define SECRET_LOGIN in tab/arduino_secrets.h" | ||
#endif | ||
|
||
#ifndef SECRET_PASS | ||
#define SECRET_PASS "" | ||
#warning "You need to define SECRET_PASS in tab/arduino_secrets.h" | ||
#endif | ||
|
||
String cloudSerialBuffer = ""; // the string used to compose network messages from the received characters | ||
// handles connection to the network | ||
ConnectionManager * ArduinoIoTPreferredConnection = new GSMConnectionManager(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS); | ||
|
||
void setup() { | ||
setDebugMessageLevel(3); // used to set a level of granularity in information output [0...4] | ||
Serial.begin(9600); | ||
while (!Serial); // waits for the serial to become available | ||
ArduinoCloud.begin(ArduinoIoTPreferredConnection); // initialize a connection to the Arduino IoT Cloud | ||
while (ArduinoCloud.connected()); // needed to wait for the initialization of CloudSerial | ||
CloudSerial.print("I'm ready for blinking!\n"); | ||
pinMode(LED_BUILTIN, OUTPUT); | ||
} | ||
|
||
void loop() { | ||
ArduinoCloud.update(); | ||
// check if there is something waiting to be read | ||
if (CloudSerial.available()) { | ||
char character = CloudSerial.read(); | ||
cloudSerialBuffer += character; | ||
// if a \n character has been received, there should be a complete command inside cloudSerialBuffer | ||
if (character == '\n') { | ||
handleString(); | ||
} | ||
} else { // if there is nothing to read, it could be that the last command didn't end with a '\n'. Check. | ||
handleString(); | ||
} | ||
// Just to be able to simulate the board responses through the serial monitor | ||
if (Serial.available()) { | ||
CloudSerial.write(Serial.read()); | ||
} | ||
} | ||
void handleString() { | ||
// Don't proceed if the string is empty | ||
if (cloudSerialBuffer.equals("")) { | ||
return; | ||
} | ||
// Remove leading and trailing whitespaces | ||
cloudSerialBuffer.trim(); | ||
// Make it uppercase; | ||
cloudSerialBuffer.toUpperCase(); | ||
if (cloudSerialBuffer.equals("ON")) { | ||
digitalWrite(LED_BUILTIN, HIGH); | ||
} else if (cloudSerialBuffer.equals("OFF")) { | ||
digitalWrite(LED_BUILTIN, LOW); | ||
} | ||
sendString(cloudSerialBuffer); | ||
// Reset cloudSerialBuffer | ||
cloudSerialBuffer = ""; | ||
} | ||
// sendString sends a string to the Arduino Cloud. | ||
void sendString(String stringToSend) { | ||
// send the characters one at a time | ||
char lastSentChar = 0; | ||
for (int i = 0; i < stringToSend.length(); i++) { | ||
lastSentChar = stringToSend.charAt(i); | ||
CloudSerial.write(lastSentChar); | ||
} | ||
// if the last sent character wasn't a '\n' add it | ||
if (lastSentChar != '\n') { | ||
CloudSerial.write('\n'); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#include <ArduinoIoTCloud.h> | ||
#include <ConnectionManager.h> | ||
#include <WiFiConnectionManager.h> | ||
|
||
#ifndef SECRET_WIFI_NAME | ||
#define SECRET_WIFI_NAME "" | ||
#warning "You need to define SECRET_WIFI_NAME in tab/arduino_secrets.h" | ||
#endif | ||
|
||
#ifndef SECRET_PASSWORD | ||
#define SECRET_PASSWORD "" | ||
#warning "You need to define SECRET_PASSWORD in tab/arduino_secrets.h" | ||
#endif | ||
|
||
String cloudSerialBuffer = ""; // the string used to compose network messages from the received characters | ||
// handles connection to the network | ||
ConnectionManager * ArduinoIoTPreferredConnection = new WiFiConnectionManager(SECRET_WIFI_NAME, SECRET_PASSWORD); | ||
|
||
void setup() { | ||
setDebugMessageLevel(3); // used to set a level of granularity in information output [0...4] | ||
Serial.begin(9600); | ||
while (!Serial); // waits for the serial to become available | ||
ArduinoCloud.begin(ArduinoIoTPreferredConnection); // initialize a connection to the Arduino IoT Cloud | ||
while (ArduinoCloud.connected()); // needed to wait for the initialization of CloudSerial | ||
CloudSerial.print("I'm ready for blinking!\n"); | ||
pinMode(LED_BUILTIN, OUTPUT); | ||
} | ||
|
||
void loop() { | ||
ArduinoCloud.update(); | ||
// check if there is something waiting to be read | ||
if (CloudSerial.available()) { | ||
char character = CloudSerial.read(); | ||
cloudSerialBuffer += character; | ||
// if a \n character has been received, there should be a complete command inside cloudSerialBuffer | ||
if (character == '\n') { | ||
handleString(); | ||
} | ||
} else { // if there is nothing to read, it could be that the last command didn't end with a '\n'. Check. | ||
handleString(); | ||
} | ||
// Just to be able to simulate the board responses through the serial monitor | ||
if (Serial.available()) { | ||
CloudSerial.write(Serial.read()); | ||
} | ||
} | ||
void handleString() { | ||
// Don't proceed if the string is empty | ||
if (cloudSerialBuffer.equals("")) { | ||
return; | ||
} | ||
// Remove leading and trailing whitespaces | ||
cloudSerialBuffer.trim(); | ||
// Make it uppercase; | ||
cloudSerialBuffer.toUpperCase(); | ||
if (cloudSerialBuffer.equals("ON")) { | ||
digitalWrite(LED_BUILTIN, HIGH); | ||
} else if (cloudSerialBuffer.equals("OFF")) { | ||
digitalWrite(LED_BUILTIN, LOW); | ||
} | ||
sendString(cloudSerialBuffer); | ||
// Reset cloudSerialBuffer | ||
cloudSerialBuffer = ""; | ||
} | ||
// sendString sends a string to the Arduino Cloud. | ||
void sendString(String stringToSend) { | ||
// send the characters one at a time | ||
char lastSentChar = 0; | ||
for (int i = 0; i < stringToSend.length(); i++) { | ||
lastSentChar = stringToSend.charAt(i); | ||
CloudSerial.write(lastSentChar); | ||
} | ||
// if the last sent character wasn't a '\n' add it | ||
if (lastSentChar != '\n') { | ||
CloudSerial.write('\n'); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.