Skip to content

Commit

Permalink
added note about deadlock to all examples
Browse files Browse the repository at this point in the history
  • Loading branch information
256dpi committed Feb 3, 2020
1 parent 5d6d29e commit 6946a0e
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 26 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,19 @@ void connect() {

void messageReceived(String &topic, String &payload) {
Serial.println("incoming: " + topic + " - " + payload);

// Note: Do not use the client in the callback to publish, subscribe or
// unsubscribe as it may cause deadlocks when other things arrive while
// sending and receiving acknowledgments. Instead, change a global variable,
// or push to a queue and handle it in the loop after calling `client.loop()`.
}

void setup() {
Serial.begin(115200);
WiFi.begin(ssid, pass);

// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported by Arduino.
// You need to set the IP address directly.
// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported
// by Arduino. You need to set the IP address directly.
client.begin("broker.shiftr.io", net);
client.onMessage(messageReceived);

Expand Down
9 changes: 7 additions & 2 deletions examples/AdafruitHuzzahESP8266/AdafruitHuzzahESP8266.ino
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ void connect() {

void messageReceived(String &topic, String &payload) {
Serial.println("incoming: " + topic + " - " + payload);

// Note: Do not use the client in the callback to publish, subscribe or
// unsubscribe as it may cause deadlocks when other things arrive while
// sending and receiving acknowledgments. Instead, change a global variable,
// or push to a queue and handle it in the loop after calling `client.loop()`.
}

void setup() {
Serial.begin(115200);
WiFi.begin(ssid, pass);

// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported by Arduino.
// You need to set the IP address directly.
// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported
// by Arduino. You need to set the IP address directly.
client.begin("broker.shiftr.io", net);
client.onMessage(messageReceived);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,19 @@ void connect() {

void messageReceived(String &topic, String &payload) {
Serial.println("incoming: " + topic + " - " + payload);

// Note: Do not use the client in the callback to publish, subscribe or
// unsubscribe as it may cause deadlocks when other things arrive while
// sending and receiving acknowledgments. Instead, change a global variable,
// or push to a queue and handle it in the loop after calling `client.loop()`.
}

void setup() {
Serial.begin(115200);
WiFi.begin(ssid, pass);

// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported by Arduino.
// You need to set the IP address directly.
// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported
// by Arduino. You need to set the IP address directly.
//
// MQTT brokers usually use port 8883 for secure connections.
client.begin("broker.shiftr.io", 8883, net);
Expand Down
9 changes: 7 additions & 2 deletions examples/ArduinoEthernetShield/ArduinoEthernetShield.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,19 @@ void connect() {

void messageReceived(String &topic, String &payload) {
Serial.println("incoming: " + topic + " - " + payload);

// Note: Do not use the client in the callback to publish, subscribe or
// unsubscribe as it may cause deadlocks when other things arrive while
// sending and receiving acknowledgments. Instead, change a global variable,
// or push to a queue and handle it in the loop after calling `client.loop()`.
}

void setup() {
Serial.begin(115200);
Ethernet.begin(mac, ip);

// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported by Arduino.
// You need to set the IP address directly.
// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported
// by Arduino. You need to set the IP address directly.
client.begin("broker.shiftr.io", net);
client.onMessage(messageReceived);

Expand Down
9 changes: 7 additions & 2 deletions examples/ArduinoMKRGSM1400/ArduinoMKRGSM1400.ino
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,18 @@ void connect() {

void messageReceived(String &topic, String &payload) {
Serial.println("incoming: " + topic + " - " + payload);

// Note: Do not use the client in the callback to publish, subscribe or
// unsubscribe as it may cause deadlocks when other things arrive while
// sending and receiving acknowledgments. Instead, change a global variable,
// or push to a queue and handle it in the loop after calling `client.loop()`.
}

void setup() {
Serial.begin(115200);

// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported by Arduino.
// You need to set the IP address directly.
// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported
// by Arduino. You need to set the IP address directly.
client.begin("broker.shiftr.io", net);
client.onMessage(messageReceived);

Expand Down
9 changes: 7 additions & 2 deletions examples/ArduinoMKRGSM1400Secure/ArduinoMKRGSM1400Secure.ino
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,18 @@ void connect() {

void messageReceived(String &topic, String &payload) {
Serial.println("incoming: " + topic + " - " + payload);

// Note: Do not use the client in the callback to publish, subscribe or
// unsubscribe as it may cause deadlocks when other things arrive while
// sending and receiving acknowledgments. Instead, change a global variable,
// or push to a queue and handle it in the loop after calling `client.loop()`.
}

void setup() {
Serial.begin(115200);

// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported by Arduino.
// You need to set the IP address directly.
// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported
// by Arduino. You need to set the IP address directly.
//
// MQTT brokers usually use port 8883 for secure connections.
client.begin("broker.shiftr.io", 8883, net);
Expand Down
9 changes: 7 additions & 2 deletions examples/ArduinoWiFi101/ArduinoWiFi101.ino
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,19 @@ void connect() {

void messageReceived(String &topic, String &payload) {
Serial.println("incoming: " + topic + " - " + payload);

// Note: Do not use the client in the callback to publish, subscribe or
// unsubscribe as it may cause deadlocks when other things arrive while
// sending and receiving acknowledgments. Instead, change a global variable,
// or push to a queue and handle it in the loop after calling `client.loop()`.
}

void setup() {
Serial.begin(115200);
WiFi.begin(ssid, pass);

// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported by Arduino.
// You need to set the IP address directly.
// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported
// by Arduino. You need to set the IP address directly.
client.begin("broker.shiftr.io", net);
client.onMessage(messageReceived);

Expand Down
9 changes: 7 additions & 2 deletions examples/ArduinoWiFi101Secure/ArduinoWiFi101Secure.ino
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,19 @@ void connect() {

void messageReceived(String &topic, String &payload) {
Serial.println("incoming: " + topic + " - " + payload);

// Note: Do not use the client in the callback to publish, subscribe or
// unsubscribe as it may cause deadlocks when other things arrive while
// sending and receiving acknowledgments. Instead, change a global variable,
// or push to a queue and handle it in the loop after calling `client.loop()`.
}

void setup() {
Serial.begin(115200);
WiFi.begin(ssid, pass);

// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported by Arduino.
// You need to set the IP address directly.
// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported
// by Arduino. You need to set the IP address directly.
//
// MQTT brokers usually use port 8883 for secure connections.
client.begin("broker.shiftr.io", 8883, net);
Expand Down
9 changes: 7 additions & 2 deletions examples/ArduinoWiFiShield/ArduinoWiFiShield.ino
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ void connect() {

void messageReceived(String &topic, String &payload) {
Serial.println("incoming: " + topic + " - " + payload);

// Note: Do not use the client in the callback to publish, subscribe or
// unsubscribe as it may cause deadlocks when other things arrive while
// sending and receiving acknowledgments. Instead, change a global variable,
// or push to a queue and handle it in the loop after calling `client.loop()`.
}

void setup() {
Serial.begin(115200);
WiFi.begin(ssid, pass);

// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported by Arduino.
// You need to set the IP address directly.
// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported
// by Arduino. You need to set the IP address directly.
client.begin("broker.shiftr.io", net);
client.onMessage(messageReceived);

Expand Down
9 changes: 7 additions & 2 deletions examples/ArduinoYun/ArduinoYun.ino
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,19 @@ void connect() {

void messageReceived(String &topic, String &payload) {
Serial.println("incoming: " + topic + " - " + payload);

// Note: Do not use the client in the callback to publish, subscribe or
// unsubscribe as it may cause deadlocks when other things arrive while
// sending and receiving acknowledgments. Instead, change a global variable,
// or push to a queue and handle it in the loop after calling `client.loop()`.
}

void setup() {
Bridge.begin();
Serial.begin(115200);

// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported by Arduino.
// You need to set the IP address directly.
// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported
// by Arduino. You need to set the IP address directly.
client.begin("broker.shiftr.io", net);
client.onMessage(messageReceived);

Expand Down
9 changes: 7 additions & 2 deletions examples/ArduinoYunSecure/ArduinoYunSecure.ino
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,19 @@ void connect() {

void messageReceived(String &topic, String &payload) {
Serial.println("incoming: " + topic + " - " + payload);

// Note: Do not use the client in the callback to publish, subscribe or
// unsubscribe as it may cause deadlocks when other things arrive while
// sending and receiving acknowledgments. Instead, change a global variable,
// or push to a queue and handle it in the loop after calling `client.loop()`.
}

void setup() {
Bridge.begin();
Serial.begin(115200);

// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported by Arduino.
// You need to set the IP address directly.
// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported
// by Arduino. You need to set the IP address directly.
//
// MQTT brokers usually use port 8883 for secure connections.
client.begin("broker.shiftr.io", 8883, net);
Expand Down
9 changes: 7 additions & 2 deletions examples/ESP32DevelopmentBoard/ESP32DevelopmentBoard.ino
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ void connect() {

void messageReceived(String &topic, String &payload) {
Serial.println("incoming: " + topic + " - " + payload);

// Note: Do not use the client in the callback to publish, subscribe or
// unsubscribe as it may cause deadlocks when other things arrive while
// sending and receiving acknowledgments. Instead, change a global variable,
// or push to a queue and handle it in the loop after calling `client.loop()`.
}

void setup() {
Serial.begin(115200);
WiFi.begin(ssid, pass);

// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported by Arduino.
// You need to set the IP address directly.
// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported
// by Arduino. You need to set the IP address directly.
client.begin("broker.shiftr.io", net);
client.onMessage(messageReceived);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ void connect() {

void messageReceived(String &topic, String &payload) {
Serial.println("incoming: " + topic + " - " + payload);

// Note: Do not use the client in the callback to publish, subscribe or
// unsubscribe as it may cause deadlocks when other things arrive while
// sending and receiving acknowledgments. Instead, change a global variable,
// or push to a queue and handle it in the loop after calling `client.loop()`.
}

void setup() {
Serial.begin(115200);
WiFi.begin(ssid, pass);

// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported by Arduino.
// You need to set the IP address directly.
// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported
// by Arduino. You need to set the IP address directly.
//
// MQTT brokers usually use port 8883 for secure connections.
client.begin("broker.shiftr.io", 8883, net);
Expand Down

0 comments on commit 6946a0e

Please sign in to comment.