File tree Expand file tree Collapse file tree 6 files changed +49
-6
lines changed
WiFiSimpleReceiveCallback Expand file tree Collapse file tree 6 files changed +49
-6
lines changed Original file line number Diff line number Diff line change 2323char ssid[] = SECRET_SSID; // your network SSID (name)
2424char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
2525
26+ // To connect with SSL/TLS:
27+ // 1) Change WiFiClient to WiFiSSLClient.
28+ // 2) Change port value from 1883 to 8883.
29+ // 3) Change broker value to a server with a known SSL/TLS root certificate
30+ // flashed in the WiFi module.
31+
2632WiFiClient wifiClient;
2733MqttClient mqttClient (wifiClient);
2834
2935const char broker[] = " test.mosquitto.org" ;
36+ int port = 1883 ;
3037const char willTopic[] = " arduino/will" ;
3138const char inTopic[] = " arduino/in" ;
3239const char outTopic[] = " arduino/out" ;
@@ -75,7 +82,7 @@ void setup() {
7582 Serial.print (" Attempting to connect to the MQTT broker: " );
7683 Serial.println (broker);
7784
78- if (!mqttClient.connect (broker, 1883 )) {
85+ if (!mqttClient.connect (broker, port )) {
7986 Serial.print (" MQTT connection failed! Error code = " );
8087 Serial.println (mqttClient.connectError ());
8188
Original file line number Diff line number Diff line change 1919char ssid[] = SECRET_SSID; // your network SSID (name)
2020char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
2121
22+ // To connect with SSL/TLS:
23+ // 1) Change WiFiClient to WiFiSSLClient.
24+ // 2) Change port value from 1883 to 8883.
25+ // 3) Change broker value to a server with a known SSL/TLS root certificate
26+ // flashed in the WiFi module.
27+
2228WiFiClient wifiClient;
2329MqttClient mqttClient (wifiClient);
2430
2531const char broker[] = " test.mosquitto.org" ;
32+ int port = 1883 ;
33+
2634const char topic[] = " arduino/echo" ;
2735
2836const long interval = 1000 ;
@@ -59,7 +67,7 @@ void setup() {
5967 Serial.print (" Attempting to connect to the MQTT broker: " );
6068 Serial.println (broker);
6169
62- if (!mqttClient.connect (broker, 1883 )) {
70+ if (!mqttClient.connect (broker, port )) {
6371 Serial.print (" MQTT connection failed! Error code = " );
6472 Serial.println (mqttClient.connectError ());
6573
Original file line number Diff line number Diff line change 2020char ssid[] = SECRET_SSID; // your network SSID (name)
2121char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
2222
23+ // To connect with SSL/TLS:
24+ // 1) Change WiFiClient to WiFiSSLClient.
25+ // 2) Change port value from 1883 to 8883.
26+ // 3) Change broker value to a server with a known SSL/TLS root certificate
27+ // flashed in the WiFi module.
28+
2329WiFiClient wifiClient;
2430MqttClient mqttClient (wifiClient);
2531
2632const char broker[] = " test.mosquitto.org" ;
33+ int port = 1883 ;
2734const char topic[] = " arduino/echo" ;
2835
2936const long interval = 1000 ;
@@ -60,7 +67,7 @@ void setup() {
6067 Serial.print (" Attempting to connect to the MQTT broker: " );
6168 Serial.println (broker);
6269
63- if (!mqttClient.connect (broker, 1883 )) {
70+ if (!mqttClient.connect (broker, port )) {
6471 Serial.print (" MQTT connection failed! Error code = " );
6572 Serial.println (mqttClient.connectError ());
6673
Original file line number Diff line number Diff line change 1818char ssid[] = SECRET_SSID; // your network SSID (name)
1919char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
2020
21+ // To connect with SSL/TLS:
22+ // 1) Change WiFiClient to WiFiSSLClient.
23+ // 2) Change port value from 1883 to 8883.
24+ // 3) Change broker value to a server with a known SSL/TLS root certificate
25+ // flashed in the WiFi module.
26+
2127WiFiClient wifiClient;
2228MqttClient mqttClient (wifiClient);
2329
2430const char broker[] = " test.mosquitto.org" ;
31+ int port = 1883 ;
2532const char topic[] = " arduino/simple" ;
2633
2734void setup () {
@@ -53,7 +60,7 @@ void setup() {
5360 Serial.print (" Attempting to connect to the MQTT broker: " );
5461 Serial.println (broker);
5562
56- if (!mqttClient.connect (broker, 1883 )) {
63+ if (!mqttClient.connect (broker, port )) {
5764 Serial.print (" MQTT connection failed! Error code = " );
5865 Serial.println (mqttClient.connectError ());
5966
Original file line number Diff line number Diff line change 1919char ssid[] = SECRET_SSID; // your network SSID (name)
2020char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
2121
22+ // To connect with SSL/TLS:
23+ // 1) Change WiFiClient to WiFiSSLClient.
24+ // 2) Change port value from 1883 to 8883.
25+ // 3) Change broker value to a server with a known SSL/TLS root certificate
26+ // flashed in the WiFi module.
27+
2228WiFiClient wifiClient;
2329MqttClient mqttClient (wifiClient);
2430
2531const char broker[] = " test.mosquitto.org" ;
32+ int port = 1883 ;
2633const char topic[] = " arduino/simple" ;
2734
2835void setup () {
@@ -54,7 +61,7 @@ void setup() {
5461 Serial.print (" Attempting to connect to the MQTT broker: " );
5562 Serial.println (broker);
5663
57- if (!mqttClient.connect (broker, 1883 )) {
64+ if (!mqttClient.connect (broker, port )) {
5865 Serial.print (" MQTT connection failed! Error code = " );
5966 Serial.println (mqttClient.connectError ());
6067
Original file line number Diff line number Diff line change 1818char ssid[] = SECRET_SSID; // your network SSID (name)
1919char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
2020
21+ // To connect with SSL/TLS:
22+ // 1) Change WiFiClient to WiFiSSLClient.
23+ // 2) Change port value from 1883 to 8883.
24+ // 3) Change broker value to a server with a known SSL/TLS root certificate
25+ // flashed in the WiFi module.
26+
2127WiFiClient wifiClient;
2228MqttClient mqttClient (wifiClient);
2329
2430const char broker[] = " test.mosquitto.org" ;
31+ int port = 1883 ;
2532const char topic[] = " arduino/simple" ;
2633
2734const long interval = 1000 ;
@@ -58,7 +65,7 @@ void setup() {
5865 Serial.print (" Attempting to connect to the MQTT broker: " );
5966 Serial.println (broker);
6067
61- if (!mqttClient.connect (broker, 1883 )) {
68+ if (!mqttClient.connect (broker, port )) {
6269 Serial.print (" MQTT connection failed! Error code = " );
6370 Serial.println (mqttClient.connectError ());
6471
You can’t perform that action at this time.
0 commit comments