1 parent
6c795aa802
commit
afe9af8904
2 files changed
+10
-8
No files matched your search
+3
-3
@@ -71,14 +71,14 @@ boolean reconnect() {
|
|||||||
while (!client.connected()) {
|
while (!client.connected()) {
|
||||||
trc(F("Attempting MQTT connection...")); //F function enable to decrease sram usage
|
trc(F("Attempting MQTT connection...")); //F function enable to decrease sram usage
|
||||||
#ifdef mqtt_user
|
#ifdef mqtt_user
|
||||||
if (client.connect(GatewayName, mqtt_user, mqtt_password)) { // if an mqtt user is defined we connect to the broker with authentication
|
if (client.connect(Gateway_Name, mqtt_user, mqtt_password, will_Topic, will_QoS, will_Retain, will_Message)) { // if an mqtt user is defined we connect to the broker with authentication
|
||||||
trc(F("connected with authentication"));
|
trc(F("connected with authentication"));
|
||||||
#else
|
#else
|
||||||
if (client.connect(GatewayName)) {
|
if (client.connect(Gateway_Name, will_Topic, will_QoS, will_Retain, will_Message)) {
|
||||||
trc(F("connected without authentication"));
|
trc(F("connected without authentication"));
|
||||||
#endif
|
#endif
|
||||||
// Once connected, publish an announcement...
|
// Once connected, publish an announcement...
|
||||||
client.publish(GatewayAnnouncementTopic,GatewayAnnouncementMsg);
|
client.publish(will_Topic,Gateway_AnnouncementMsg);
|
||||||
//Subscribing to topic
|
//Subscribing to topic
|
||||||
if (client.subscribe(subjectMQTTtoX)) {
|
if (client.subscribe(subjectMQTTtoX)) {
|
||||||
trc(F("subscription OK to"));
|
trc(F("subscription OK to"));
|
||||||
|
|||||||
+7
-5
@@ -35,6 +35,12 @@ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT
|
|||||||
#define mqtt_user "your_username" // not compulsory only if your broker needs authentication
|
#define mqtt_user "your_username" // not compulsory only if your broker needs authentication
|
||||||
#define mqtt_password "your_password" // not compulsory only if your broker needs authentication
|
#define mqtt_password "your_password" // not compulsory only if your broker needs authentication
|
||||||
#define mqtt_port 1883
|
#define mqtt_port 1883
|
||||||
|
#define Gateway_Name "OpenMQTTGateway"
|
||||||
|
#define will_Topic "home/OpenMQTTGateway/LWT"
|
||||||
|
#define will_QoS 0
|
||||||
|
#define will_Retain true
|
||||||
|
#define will_Message "Offline"
|
||||||
|
#define Gateway_AnnouncementMsg "Online"
|
||||||
|
|
||||||
// Update these with values suitable for your network.
|
// Update these with values suitable for your network.
|
||||||
#ifdef ESP8266 // for nodemcu, weemos and esp8266
|
#ifdef ESP8266 // for nodemcu, weemos and esp8266
|
||||||
@@ -54,10 +60,6 @@ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT
|
|||||||
#define time_avoid_duplicate 3000 // if you want to avoid duplicate mqtt message received set this to > 0, the value is the time in milliseconds during which we don't publish duplicates
|
#define time_avoid_duplicate 3000 // if you want to avoid duplicate mqtt message received set this to > 0, the value is the time in milliseconds during which we don't publish duplicates
|
||||||
|
|
||||||
//MQTT definitions
|
//MQTT definitions
|
||||||
//RF MQTT Subjects
|
|
||||||
#define GatewayName "OpenMQTTGateway"
|
|
||||||
#define GatewayAnnouncementTopic "OpenMQTTGateway connected"
|
|
||||||
#define GatewayAnnouncementMsg "hello broker!"
|
|
||||||
// global MQTT subject listened by the gateway to execute commands (send RF, IR or others)
|
// global MQTT subject listened by the gateway to execute commands (send RF, IR or others)
|
||||||
#define subjectMQTTtoX "home/commands/#"
|
#define subjectMQTTtoX "home/commands/#"
|
||||||
|
|
||||||
@@ -69,8 +71,8 @@ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT
|
|||||||
#define RFprotocolKey "433_" // protocol will be defined if a subject contains RFprotocolKey followed by a value of 1 digit
|
#define RFprotocolKey "433_" // protocol will be defined if a subject contains RFprotocolKey followed by a value of 1 digit
|
||||||
#define RFpulselengthKey "PLSL_" // pulselength will be defined if a subject contains RFprotocolKey followed by a value of 3 digits
|
#define RFpulselengthKey "PLSL_" // pulselength will be defined if a subject contains RFprotocolKey followed by a value of 3 digits
|
||||||
//IR MQTT Subjects
|
//IR MQTT Subjects
|
||||||
#define subjectIRtoMQTT "home/sensors/ir"
|
|
||||||
#define subjectGTWIRtoMQTT "home/sensors/ir"
|
#define subjectGTWIRtoMQTT "home/sensors/ir"
|
||||||
|
#define subjectIRtoMQTT "home/sensors/ir"
|
||||||
#define subjectMQTTtoIR "home/commands/MQTTtoIR"
|
#define subjectMQTTtoIR "home/commands/MQTTtoIR"
|
||||||
/*
|
/*
|
||||||
RF supported protocols
|
RF supported protocols
|
||||||
|
|||||||
Reference in new issue
Block a user