Avoid some mqtt server connection
Do not check subscription when we do not subscribe
This commit is contained in:
parent
73d6e17dc1
commit
7b1d9ae63e
@ -197,14 +197,17 @@ void MqttCheckIRQ() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MqttCheckSubscription() {
|
void MqttCheckSubscription()
|
||||||
|
{
|
||||||
|
if (mqtt->getSubscriptionCount() == 0)
|
||||||
|
return;
|
||||||
if (MqttConnect() == 0) {
|
if (MqttConnect() == 0) {
|
||||||
Adafruit_MQTT_Subscribe *subscription;
|
Adafruit_MQTT_Subscribe *subscription;
|
||||||
while ((subscription = mqtt->readSubscription(0))) {
|
while ((subscription = mqtt->readSubscription(0))) {
|
||||||
int gpio = getGpioFromSubscription(subscription, "/gpio/");
|
int gpio = getGpioFromSubscription(subscription, "/gpio/");
|
||||||
if (gpio > 0 && findIndex(gpio, gpioControlled) >= 0) {
|
if (gpio > 0 && findIndex(gpio, gpioControlled) >= 0) {
|
||||||
SKETCH_DEBUG_PRINTF("Got Subscription for GPIO %d\n", gpio);
|
SKETCH_DEBUG_PRINTF("Got Subscription for GPIO %d\n", gpio);
|
||||||
char *value = (char *) subscription->lastread;
|
char *value = (char *)subscription->lastread;
|
||||||
SKETCH_DEBUG_PRINTF("Receive data: %s\n", value);
|
SKETCH_DEBUG_PRINTF("Receive data: %s\n", value);
|
||||||
MqttChangeGpioValue(gpio, atoi(value));
|
MqttChangeGpioValue(gpio, atoi(value));
|
||||||
}
|
}
|
||||||
@ -212,7 +215,7 @@ void MqttCheckSubscription() {
|
|||||||
gpio = getGpioFromSubscription(subscription, "/pwm/");
|
gpio = getGpioFromSubscription(subscription, "/pwm/");
|
||||||
if (gpio > 0 && findIndex(gpio, pwmControlled) >= 0) {
|
if (gpio > 0 && findIndex(gpio, pwmControlled) >= 0) {
|
||||||
SKETCH_DEBUG_PRINTF("Got Subscription for PWM %d\n", gpio);
|
SKETCH_DEBUG_PRINTF("Got Subscription for PWM %d\n", gpio);
|
||||||
char *value = (char *) subscription->lastread;
|
char *value = (char *)subscription->lastread;
|
||||||
SKETCH_DEBUG_PRINTF("Receive data: %s\n", value);
|
SKETCH_DEBUG_PRINTF("Receive data: %s\n", value);
|
||||||
MqttChangePWMValue(gpio, atoi(value));
|
MqttChangePWMValue(gpio, atoi(value));
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ int TeleinfoSetup() {
|
|||||||
inline int TeleinfoProcess(std::vector<struct mqttInfo> &){
|
inline int TeleinfoProcess(std::vector<struct mqttInfo> &){
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
int TeleinfoProcess(float &iinst, float &papp, float &base){
|
int TeleinfoProcess(float &, float &, float &){
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user