Skip to content

Commit

Permalink
Merge pull request #438 from zfields/zak-await-serial
Browse files Browse the repository at this point in the history
fix: Await Serial
  • Loading branch information
pennam authored Apr 2, 2024
2 parents 7c682b5 + 50ade91 commit 46ebf04
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
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); ) { }
for(unsigned long const serialBeginTime = millis(); !Serial && (millis() - serialBeginTime <= 5000); ) { }

/* This function takes care of connecting your sketch variables to the ArduinoIoTCloud object */
initProperties();
Expand Down
2 changes: 1 addition & 1 deletion examples/ArduinoIoTCloud-Basic/ArduinoIoTCloud-Basic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static int const LED_BUILTIN = 2;
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); ) { }
for(unsigned long const serialBeginTime = millis(); !Serial && (millis() - serialBeginTime <= 5000); ) { }

/* Configure LED pin as an output */
pinMode(LED_BUILTIN, OUTPUT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
You don't need any specific Properties to be created in order to demonstrate these functionalities.
Simply create a new Thing and give it 1 arbitrary Property.
Remember that the Thing ID needs to be configured in thingProperties.h
Remember that the Thing ID needs to be configured in thingProperties.h
These events can be very useful in particular cases, for instance to disable a peripheral
or a connected sensor/actuator when no data connection is available, as well as to perform
specific operations on connection or right after properties values are synchronised.
Expand All @@ -31,7 +31,7 @@
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); ) { }
for(unsigned long const serialBeginTime = millis(); !Serial && (millis() - serialBeginTime <= 5000); ) { }

/* This function takes care of connecting your sketch variables to the ArduinoIoTCloud object */
initProperties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bool onOTARequestCallback()
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); ) { }
for(unsigned long const serialBeginTime = millis(); !Serial && (millis() - serialBeginTime <= 5000); ) { }

/* Configure LED pin as an output */
pinMode(LED_BUILTIN, OUTPUT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static int const LED_BUILTIN = 2;
void setup() {
/* Initialize the serial port and wait up to 5 seconds for a connection */
Serial.begin(9600);
for(unsigned long const serialBeginTime = millis(); !Serial && (millis() - serialBeginTime > 5000); ) { }
for(unsigned long const serialBeginTime = millis(); !Serial && (millis() - serialBeginTime <= 5000); ) { }

/* Configure LED pin as an output */
pinMode(LED_BUILTIN, OUTPUT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void setup() {

Serial.begin(9600);
unsigned long serialBeginTime = millis();
while (!Serial && (millis() - serialBeginTime > 5000));
while (!Serial && (millis() - serialBeginTime <= 5000));

Serial.println("Starting Arduino IoT Cloud Example");

Expand Down

0 comments on commit 46ebf04

Please sign in to comment.