Browse Source

Fix MQTT publishing when mqtt is not configured

gpiosensors
Mathieu Maret 5 years ago
parent
commit
76c06690a2
  1. 2
      Esp8266-Arduino-Makefile
  2. 17
      WifiControlSensor/MQTT.ino

2
Esp8266-Arduino-Makefile

@ -1 +1 @@
Subproject commit 8030bb24a8f37d4b6efc4a5ac2751856ee70506b
Subproject commit 6ffd79de30164e67f6c059b7a1792bdc3860e973

17
WifiControlSensor/MQTT.ino

@ -174,21 +174,22 @@ int getGpioFromSubscription(Adafruit_MQTT_Subscribe *subscription, const char *p
return -1;
}
void MqttChangeGpioValue(int gpio, int value) {
pinMode(gpio, OUTPUT);
digitalWrite(gpio, value);
void MqttNofity(int gpio, int value){
int watchIdx = findIndex(gpio, gpioWatched);
if (watchIdx >= 0 ) {
if (watchIdx >= 0 && isMqttConfigured) {
mqttGpio[watchIdx]->publish(value);
}
}
void MqttChangeGpioValue(int gpio, int value) {
pinMode(gpio, OUTPUT);
digitalWrite(gpio, value);
MqttNofity(gpio, value);
}
void MqttChangePWMValue(int gpio, int value) {
analogWrite(gpio, value);
int watchIdx = findIndex(gpio, gpioWatched);
if (watchIdx >= 0 ) {
mqttGpio[watchIdx]->publish(value);
}
MqttNofity(gpio, value);
}
void MqttCheckSubscription() {

Loading…
Cancel
Save