diff --git a/.gitignore b/.gitignore
old mode 100644
new mode 100755
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
old mode 100644
new mode 100755
diff --git a/.travis.yml b/.travis.yml
old mode 100644
new mode 100755
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
old mode 100644
new mode 100755
diff --git a/.vscode/ipch/5621cedcfe4a1a0f/mmap_address.bin b/.vscode/ipch/5621cedcfe4a1a0f/mmap_address.bin
new file mode 100644
index 0000000..a3dd973
Binary files /dev/null and b/.vscode/ipch/5621cedcfe4a1a0f/mmap_address.bin differ
diff --git a/.vscode/ipch/96c62a1ecada60cd/main.ipch b/.vscode/ipch/96c62a1ecada60cd/main.ipch
new file mode 100644
index 0000000..2942547
Binary files /dev/null and b/.vscode/ipch/96c62a1ecada60cd/main.ipch differ
diff --git a/.vscode/ipch/96c62a1ecada60cd/mmap_address.bin b/.vscode/ipch/96c62a1ecada60cd/mmap_address.bin
new file mode 100644
index 0000000..5147fbb
Binary files /dev/null and b/.vscode/ipch/96c62a1ecada60cd/mmap_address.bin differ
diff --git a/.vscode/ipch/ac952b37c792bcdd/main.ipch b/.vscode/ipch/ac952b37c792bcdd/main.ipch
new file mode 100644
index 0000000..0add761
Binary files /dev/null and b/.vscode/ipch/ac952b37c792bcdd/main.ipch differ
diff --git a/.vscode/ipch/ac952b37c792bcdd/mmap_address.bin b/.vscode/ipch/ac952b37c792bcdd/mmap_address.bin
new file mode 100644
index 0000000..92c6c45
Binary files /dev/null and b/.vscode/ipch/ac952b37c792bcdd/mmap_address.bin differ
diff --git a/.vscode/ipch/b83158c58eaf72d2/mmap_address.bin b/.vscode/ipch/b83158c58eaf72d2/mmap_address.bin
new file mode 100644
index 0000000..2f8ee88
Binary files /dev/null and b/.vscode/ipch/b83158c58eaf72d2/mmap_address.bin differ
diff --git a/.vscode/ipch/cedfd36b17bccdfe/MqttPlugin.ipch b/.vscode/ipch/cedfd36b17bccdfe/MqttPlugin.ipch
new file mode 100644
index 0000000..c55a3d7
Binary files /dev/null and b/.vscode/ipch/cedfd36b17bccdfe/MqttPlugin.ipch differ
diff --git a/.vscode/ipch/cedfd36b17bccdfe/mmap_address.bin b/.vscode/ipch/cedfd36b17bccdfe/mmap_address.bin
new file mode 100644
index 0000000..e79a71e
Binary files /dev/null and b/.vscode/ipch/cedfd36b17bccdfe/mmap_address.bin differ
diff --git a/.vscode/settings.json b/.vscode/settings.json
old mode 100644
new mode 100755
index 13f18c7..7c99b34
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,6 +1,6 @@
{
"terminal.integrated.env.linux": {
- "PATH": "/home/master/.platformio/penv/bin:/home/master/.platformio/penv:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl",
+ "PATH": "/home/master/.platformio/penv/bin:/home/master/.platformio/penv:/home/master/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/sbin:/usr/sbin",
"PLATFORMIO_CALLER": "vscode"
}
}
\ No newline at end of file
diff --git a/data/config.json b/data/config.json
old mode 100644
new mode 100755
index 82c9e85..7c31fae
--- a/data/config.json
+++ b/data/config.json
@@ -4,7 +4,7 @@
"apSSID": "sprocket",
"apPassword": "th3r31sn0Sp00n",
"connectTimeout": 20000,
- "stationSSID": "MyAP",
+ "stationSSID": "th1ngs4p",
"stationPassword": "th3r31sn0Sp00n",
"meshSSID": "whateverYouLike",
"meshPassword": "somethingSneaky",
diff --git a/data/mqttConfig.json b/data/mqttConfig.json
old mode 100644
new mode 100755
index fac46fe..142589f
--- a/data/mqttConfig.json
+++ b/data/mqttConfig.json
@@ -2,5 +2,7 @@
"mqttClientName" : "sprocket",
"mqttBrokerHost" : "192.168.1.2",
"mqttBrokerPort" : 1883,
- "mqttRootTopic" : "wirelos/sprocket"
+ "mqttRootTopic" : "wirelos/sprocket",
+ "mqttUser": "",
+ "mqttPass": ""
}
\ No newline at end of file
diff --git a/lib/readme.txt b/lib/readme.txt
old mode 100644
new mode 100755
diff --git a/library.json b/library.json
old mode 100644
new mode 100755
diff --git a/platformio.ini b/platformio.ini
old mode 100644
new mode 100755
index 9def105..67c3eb3
--- a/platformio.ini
+++ b/platformio.ini
@@ -12,7 +12,6 @@ lib_deps =
TaskScheduler
SPIFFS
ArduinoJson
- ArduinoOTA
https://gitlab.com/wirelos/sprocket-lib.git#develop
https://gitlab.com/wirelos/sprocket-network-wifi.git
@@ -33,5 +32,15 @@ board = ${common.board}
upload_speed = ${common.upload_speed}
monitor_baud = ${common.monitor_baud}
framework = ${common.framework}
+lib_deps = ${common.lib_deps}
+ PubSubClient
+
+[env:chat-esp01]
+src_filter = +<*> - +
+platform = ${common.platform}
+board = esp01
+upload_speed = ${common.upload_speed}
+monitor_baud = ${common.monitor_baud}
+framework = ${common.framework}
lib_deps = ${common.lib_deps}
PubSubClient
\ No newline at end of file
diff --git a/src/MqttConfig.h b/src/MqttConfig.h
old mode 100644
new mode 100755
index 6fd27b2..e430c3f
--- a/src/MqttConfig.h
+++ b/src/MqttConfig.h
@@ -7,6 +7,8 @@
#define JSON_MQTT_BROKER_HOST "mqttBrokerHost"
#define JSON_MQTT_BROKER_PORT "mqttBrokerPort"
#define JSON_MQTT_TOPIC_ROOT "mqttRootTopic"
+#define JSON_MQTT_USER "mqttUser"
+#define JSON_MQTT_PASS "mqttPass"
struct MqttConfig
{
@@ -14,6 +16,8 @@ struct MqttConfig
const char *brokerHost;
int brokerPort;
const char *topicRoot;
+ const char *user;
+ const char *pass;
};
struct MqttConfigJson : public MqttConfig, public JsonStruct
@@ -24,6 +28,8 @@ struct MqttConfigJson : public MqttConfig, public JsonStruct
root[JSON_MQTT_BROKER_HOST] = brokerHost;
root[JSON_MQTT_BROKER_PORT] = brokerPort;
root[JSON_MQTT_TOPIC_ROOT] = topicRoot;
+ root[JSON_MQTT_USER] = user;
+ root[JSON_MQTT_PASS] = pass;
}
void fromJsonObject(JsonObject &json)
{
@@ -37,6 +43,8 @@ struct MqttConfigJson : public MqttConfig, public JsonStruct
brokerHost = getAttr(json, JSON_MQTT_BROKER_HOST);
brokerPort = getIntAttrFromJson(json, JSON_MQTT_BROKER_PORT);
topicRoot = getAttr(json, JSON_MQTT_TOPIC_ROOT);
+ user = getAttr(json, JSON_MQTT_USER);
+ pass = getAttr(json, JSON_MQTT_PASS);
valid = 1;
};
};
diff --git a/src/MqttPlugin.cpp b/src/MqttPlugin.cpp
old mode 100644
new mode 100755
index 936288a..6e5eb06
--- a/src/MqttPlugin.cpp
+++ b/src/MqttPlugin.cpp
@@ -12,6 +12,8 @@ void MqttPlugin::applyConfig(MqttConfig cfg) {
brokerPort = cfg.brokerPort;
clientName = String(cfg.clientName);
topicRoot = String(cfg.topicRoot);
+ user = String(cfg.user);
+ pass = String(cfg.pass);
}
void MqttPlugin::applyConfigFromFile(const char* fileName) {
@@ -51,7 +53,13 @@ void MqttPlugin::connect()
if (!client->connected())
{
PRINT_MSG(Serial, "MQTT", "try connect");
- if (client->connect(clientName.c_str()))
+ int connected = 0;
+ if(user.length() > 0 && pass.length() > 0){
+ connected = client->connect(clientName.c_str(), user.c_str(), pass.c_str());
+ } else {
+ client->connect(clientName.c_str());
+ }
+ if (connected)
{
// bind handlers to all local subscriptions
if (!subscribed)
diff --git a/src/MqttPlugin.h b/src/MqttPlugin.h
old mode 100644
new mode 100755
index 4299977..59deb5f
--- a/src/MqttPlugin.h
+++ b/src/MqttPlugin.h
@@ -37,6 +37,8 @@ private:
int brokerPort;
String clientName;
String topicRoot;
+ String user;
+ String pass;
int connectTries = 0;
int maxConnectTries = 5; // TODO add to config
diff --git a/src/examples/basic/config.h b/src/examples/basic/config.h
old mode 100644
new mode 100755
diff --git a/src/examples/basic/main.cpp b/src/examples/basic/main.cpp
old mode 100644
new mode 100755
index 6e62fd4..b4166e7
--- a/src/examples/basic/main.cpp
+++ b/src/examples/basic/main.cpp
@@ -26,7 +26,7 @@ void setup()
});
sprocket->addTask(publishHeap);
sprocket->addPlugin(
- new MqttPlugin({"mqttSprocket", "192.168.1.2", 1883, "wirelos/mqttSprocket/"}));
+ new MqttPlugin({"clientId", "192.168.1.2", 1883, "some/topic", "myuser", "mypass"}));
network = new WiFiNet(
SPROCKET_MODE,
diff --git a/src/examples/chat/config.h b/src/examples/chat/config.h
old mode 100644
new mode 100755
diff --git a/src/examples/chat/main.cpp b/src/examples/chat/main.cpp
old mode 100644
new mode 100755