File tree 6 files changed +49
-6
lines changed
WiFiSimpleReceiveCallback
6 files changed +49
-6
lines changed Original file line number Diff line number Diff line change 23
23
char ssid[] = SECRET_SSID; // your network SSID (name)
24
24
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
25
25
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
+
26
32
WiFiClient wifiClient;
27
33
MqttClient mqttClient (wifiClient);
28
34
29
35
const char broker[] = " test.mosquitto.org" ;
36
+ int port = 1883 ;
30
37
const char willTopic[] = " arduino/will" ;
31
38
const char inTopic[] = " arduino/in" ;
32
39
const char outTopic[] = " arduino/out" ;
@@ -75,7 +82,7 @@ void setup() {
75
82
Serial.print (" Attempting to connect to the MQTT broker: " );
76
83
Serial.println (broker);
77
84
78
- if (!mqttClient.connect (broker, 1883 )) {
85
+ if (!mqttClient.connect (broker, port )) {
79
86
Serial.print (" MQTT connection failed! Error code = " );
80
87
Serial.println (mqttClient.connectError ());
81
88
Original file line number Diff line number Diff line change 19
19
char ssid[] = SECRET_SSID; // your network SSID (name)
20
20
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
21
21
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
+
22
28
WiFiClient wifiClient;
23
29
MqttClient mqttClient (wifiClient);
24
30
25
31
const char broker[] = " test.mosquitto.org" ;
32
+ int port = 1883 ;
33
+
26
34
const char topic[] = " arduino/echo" ;
27
35
28
36
const long interval = 1000 ;
@@ -59,7 +67,7 @@ void setup() {
59
67
Serial.print (" Attempting to connect to the MQTT broker: " );
60
68
Serial.println (broker);
61
69
62
- if (!mqttClient.connect (broker, 1883 )) {
70
+ if (!mqttClient.connect (broker, port )) {
63
71
Serial.print (" MQTT connection failed! Error code = " );
64
72
Serial.println (mqttClient.connectError ());
65
73
Original file line number Diff line number Diff line change 20
20
char ssid[] = SECRET_SSID; // your network SSID (name)
21
21
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
22
22
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
+
23
29
WiFiClient wifiClient;
24
30
MqttClient mqttClient (wifiClient);
25
31
26
32
const char broker[] = " test.mosquitto.org" ;
33
+ int port = 1883 ;
27
34
const char topic[] = " arduino/echo" ;
28
35
29
36
const long interval = 1000 ;
@@ -60,7 +67,7 @@ void setup() {
60
67
Serial.print (" Attempting to connect to the MQTT broker: " );
61
68
Serial.println (broker);
62
69
63
- if (!mqttClient.connect (broker, 1883 )) {
70
+ if (!mqttClient.connect (broker, port )) {
64
71
Serial.print (" MQTT connection failed! Error code = " );
65
72
Serial.println (mqttClient.connectError ());
66
73
Original file line number Diff line number Diff line change 18
18
char ssid[] = SECRET_SSID; // your network SSID (name)
19
19
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
20
20
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
+
21
27
WiFiClient wifiClient;
22
28
MqttClient mqttClient (wifiClient);
23
29
24
30
const char broker[] = " test.mosquitto.org" ;
31
+ int port = 1883 ;
25
32
const char topic[] = " arduino/simple" ;
26
33
27
34
void setup () {
@@ -53,7 +60,7 @@ void setup() {
53
60
Serial.print (" Attempting to connect to the MQTT broker: " );
54
61
Serial.println (broker);
55
62
56
- if (!mqttClient.connect (broker, 1883 )) {
63
+ if (!mqttClient.connect (broker, port )) {
57
64
Serial.print (" MQTT connection failed! Error code = " );
58
65
Serial.println (mqttClient.connectError ());
59
66
Original file line number Diff line number Diff line change 19
19
char ssid[] = SECRET_SSID; // your network SSID (name)
20
20
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
21
21
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
+
22
28
WiFiClient wifiClient;
23
29
MqttClient mqttClient (wifiClient);
24
30
25
31
const char broker[] = " test.mosquitto.org" ;
32
+ int port = 1883 ;
26
33
const char topic[] = " arduino/simple" ;
27
34
28
35
void setup () {
@@ -54,7 +61,7 @@ void setup() {
54
61
Serial.print (" Attempting to connect to the MQTT broker: " );
55
62
Serial.println (broker);
56
63
57
- if (!mqttClient.connect (broker, 1883 )) {
64
+ if (!mqttClient.connect (broker, port )) {
58
65
Serial.print (" MQTT connection failed! Error code = " );
59
66
Serial.println (mqttClient.connectError ());
60
67
Original file line number Diff line number Diff line change 18
18
char ssid[] = SECRET_SSID; // your network SSID (name)
19
19
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
20
20
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
+
21
27
WiFiClient wifiClient;
22
28
MqttClient mqttClient (wifiClient);
23
29
24
30
const char broker[] = " test.mosquitto.org" ;
31
+ int port = 1883 ;
25
32
const char topic[] = " arduino/simple" ;
26
33
27
34
const long interval = 1000 ;
@@ -58,7 +65,7 @@ void setup() {
58
65
Serial.print (" Attempting to connect to the MQTT broker: " );
59
66
Serial.println (broker);
60
67
61
- if (!mqttClient.connect (broker, 1883 )) {
68
+ if (!mqttClient.connect (broker, port )) {
62
69
Serial.print (" MQTT connection failed! Error code = " );
63
70
Serial.println (mqttClient.connectError ());
64
71
You can’t perform that action at this time.
0 commit comments