diff -r 988a898974f3 -r 417ee898fb02 thermferm/devices.c --- a/thermferm/devices.c Mon Aug 04 19:31:03 2014 +0200 +++ b/thermferm/devices.c Mon Aug 04 23:34:22 2014 +0200 @@ -20,8 +20,9 @@ * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *****************************************************************************/ +#include "thermferm.h" #include "devices.h" -#include "thermferm.h" +#include "rc-switch.h" #include "xutil.h" @@ -31,6 +32,57 @@ + +int device_out(char *uuid, int value) +{ + devices_list *device; + char buf[40]; + int i, rc; + + if (uuid == NULL) + return 0; + + for (device = Config.devices; device; device = device->next) { + if (strcmp(uuid, device->uuid) == 0) { + if (value != device->value) { + +#ifdef HAVE_WIRINGPI_H + rc = 0; + if ((device->type == DEVTYPE_RC433) && (device->gpiopin != -1) && (device->present == DEVPRESENT_YES)) { + enableTransmit(device->gpiopin); + usleep(10000); + snprintf(buf, 39, "%s,%d", device->address, value ? 1:0); + for (i = 0; i < strlen(buf); i++) + if (buf[i] == '-') + buf[i] = ','; + rc = toggleSwitch(buf); + syslog(LOG_NOTICE, "RC433 command %s rc=%d", buf, rc); + if (debug) + fprintf(stdout, "RC433 command %s rc=%d\n", buf, rc); + usleep(50000); + disableTransmit(); + } + device->value = value; + device->timestamp = time(NULL); + return rc; + + if ((device->type == DEVTYPE_GPIO) && (device->gpiopin != -1) && (device->present == DEVPRESENT_YES)) { + + } +#endif + if ((device->type == DEVTYPE_W1) && (device->direction == DEVDIR_OUT_BIN) && (device->present == DEVPRESENT_YES)) { + + } + } else { + return 0; + } + } + } + return 0; +} + + + /* * Auto detect hotplugged or known to be present devices */