182 /* |
183 /* |
183 * Execute command if different then the old value. But also |
184 * Execute command if different then the old value. But also |
184 * every 2 minutes because commands can have temporary |
185 * every 2 minutes because commands can have temporary |
185 * disconnects, or have radio problems. |
186 * disconnects, or have radio problems. |
186 */ |
187 */ |
187 if ((value != device->value) || (((int)now - (int)device->timestamp) > 120)) { |
188 #ifdef HAVE_WIRINGPI_H |
|
189 piLock(LOCK_DEVICES); |
|
190 #endif |
|
191 my_timestamp = device->timestamp; |
|
192 my_value = device->value; |
|
193 #ifdef HAVE_WIRINGPI_H |
|
194 piUnlock(LOCK_DEVICES); |
|
195 #endif |
|
196 if ((value != my_value) || (((int)now - (int)my_timestamp) > 120)) { |
188 |
197 |
189 #ifdef HAVE_WIRINGPI_H |
198 #ifdef HAVE_WIRINGPI_H |
190 rc = 0; |
199 rc = 0; |
191 if ((device->type == DEVTYPE_RC433) && (device->gpiopin != -1) && (device->present == DEVPRESENT_YES)) { |
200 if ((device->type == DEVTYPE_RC433) && (device->gpiopin != -1) && (device->present == DEVPRESENT_YES)) { |
192 snprintf(buf, 39, "%s,%d", device->address, value ? 1:0); |
201 snprintf(buf, 39, "%s,%d", device->address, value ? 1:0); |