Skip to content

Commit 7520896

Browse files
committed
Replacing defines with constants and adding default broker addr/port information for user/pass authentification
1 parent 1a6d4f6 commit 7520896

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/ArduinoIoTCloud.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@
3838

3939
#include "CloudSerial.h"
4040

41-
#define DEFAULT_BROKER_ADDRESS "mqtts-sa.iot.arduino.cc"
42-
#define DEFAULT_BROKER_PORT 8883
41+
static char const DEFAULT_BROKER_ADDRESS_SECURE_AUTH[] = "mqtts-sa.iot.arduino.cc";
42+
static uint16_t const DEFAULT_BROKER_PORT_SECURE_AUTH = 8883;
43+
static char const DEFAULT_BROKER_ADDRESS_USER_PASS_AUTH[] = "mqtts-up.iot.arduino.cc";
44+
static uint16_t const DEFAULT_BROKER_PORT_USER_PASS_AUTH = 8884;
45+
4346
typedef enum {
4447
READ = 0x01,
4548
WRITE = 0x02,
@@ -81,9 +84,9 @@ class ArduinoIoTCloudClass {
8184
ArduinoIoTCloudClass();
8285
~ArduinoIoTCloudClass();
8386

84-
int begin(ConnectionHandler &connection, String device_id, String password, String brokerAddress = DEFAULT_BROKER_ADDRESS, uint16_t brokerPort = DEFAULT_BROKER_PORT);
85-
int begin(ConnectionHandler &connection, String brokerAddress = DEFAULT_BROKER_ADDRESS, uint16_t brokerPort = DEFAULT_BROKER_PORT);
86-
int begin(Client &net, String brokerAddress = DEFAULT_BROKER_ADDRESS, uint16_t brokerPort = DEFAULT_BROKER_PORT);
87+
int begin(ConnectionHandler &connection, String device_id, String password, String brokerAddress = DEFAULT_BROKER_ADDRESS_USER_PASS_AUTH, uint16_t brokerPort = DEFAULT_BROKER_PORT_USER_PASS_AUTH);
88+
int begin(ConnectionHandler &connection, String brokerAddress = DEFAULT_BROKER_ADDRESS_SECURE_AUTH, uint16_t brokerPort = DEFAULT_BROKER_PORT_SECURE_AUTH);
89+
int begin(Client &net, String brokerAddress = DEFAULT_BROKER_ADDRESS_SECURE_AUTH, uint16_t brokerPort = DEFAULT_BROKER_PORT_SECURE_AUTH);
8790
// Class constant declaration
8891
static const int MQTT_TRANSMIT_BUFFER_SIZE = 256;
8992
static const int TIMEOUT_FOR_LASTVALUES_SYNC = 10000;

0 commit comments

Comments
 (0)