thermferm/server.c

changeset 276
a19cc3770f09
parent 274
111b0e9663dc
child 278
76c8a6f18e4d
--- a/thermferm/server.c	Mon Sep 01 22:06:39 2014 +0200
+++ b/thermferm/server.c	Tue Sep 02 14:10:37 2014 +0200
@@ -381,6 +381,8 @@
 			    if (strcmp(kwd, (char *)"TYPE") == 0) {
 				for (i = 0; i < 8; i++) {
 				    if (strcmp(val, DEVTYPE[i]) == 0) {
+					if (device->type != i)
+					    syslog(LOG_NOTICE, "Device %s changed type %s to %s", device->uuid, DEVTYPE[device->type], DEVTYPE[i]);
 					device->type = i;
 					break;
 				    }
@@ -389,48 +391,73 @@
 			    } else if (strcmp(kwd, (char *)"DIRECTION") == 0) {
 				for (i = 0; i < 7; i++) {
 				    if (strcmp(val, DEVDIR[i]) == 0) {
+					if (device->direction != i)
+					    syslog(LOG_NOTICE, "Device %s changed direction %s to %s", device->uuid, DEVDIR[device->type], DEVDIR[i]);
 					device->direction = i;
 					break;
 				    }
 				}
 
 			    } else if (strcmp(kwd, (char *)"VALUE") == 0) {
-				if (sscanf(val, "%d", &ival) == 1)
+				if (sscanf(val, "%d", &ival) == 1) {
+				    if (device->value != ival)
+					syslog(LOG_NOTICE, "Device %s changed value %d to %d", device->uuid, device->value, ival);
 				    device->value = ival;
+				}
 
 			    } else if (strcmp(kwd, (char *)"OFFSET") == 0) {
-				if (sscanf(val, "%d", &ival) == 1)
+				if (sscanf(val, "%d", &ival) == 1) {
+				    if (device->offset != ival)
+					syslog(LOG_NOTICE, "Device %s changed offset %d to %d", device->uuid, device->offset, ival);
 				    device->offset = ival;
+				}
 
 			    } else if (strcmp(kwd, (char *)"PRESENT") == 0) {
 				for (i = 0; i < 4; i++) {
 				    if (strcmp(val, DEVPRESENT[i]) == 0) {
+					if (device->present != i)
+					    syslog(LOG_NOTICE, "Device %s changed present %s to %s", device->uuid, DEVPRESENT[device->present], DEVPRESENT[i]);
 					device->present = i;
 				        break;
 				    }
 				}
 
 			    } else if (strcmp(kwd, (char *)"ADDRESS") == 0) {
-				if (device->address)
+				if (device->address) {
+				    if (strcmp(device->address, val))
+					syslog(LOG_NOTICE, "Device %s changed address %s to %s", device->uuid, device->address, val);
 				    free(device->address);
+				}
 				device->address = xstrcpy(val);
 
 			    } else if (strcmp(kwd, (char *)"SUBDEVICE") == 0) {
-				if (sscanf(val, "%d", &ival) == 1)
+				if (sscanf(val, "%d", &ival) == 1) {
+				    if (device->subdevice != ival)
+					syslog(LOG_NOTICE, "Device %s changed subdevice %d to %d", device->uuid, device->subdevice, ival);
 				    device->subdevice = ival;
+				}
 
 			    } else if (strcmp(kwd, (char *)"GPIOPIN") == 0) {
-				if (sscanf(val, "%d", &ival) == 1)
+				if (sscanf(val, "%d", &ival) == 1) {
+				    if (device->gpiopin != ival)
+					syslog(LOG_NOTICE, "Device %s changed gpiopin %d to %d", device->uuid, device->gpiopin, ival);
 				    device->gpiopin = ival;
+				}
 
 			    } else if (strcmp(kwd, (char *)"DESCRIPTION") == 0) {
-				if (device->description)
+				if (device->description) {
+				    if (strcmp(device->description, val))
+					syslog(LOG_NOTICE, "Device %s changed description %s to %s", device->uuid, device->description, val);
 				    free(device->description);
+				}
 				device->description = xstrcpy(val);
 
 			    } else if (strcmp(kwd, (char *)"COMMENT") == 0) {
-				if (device->comment)
+				if (device->comment) {
+				    if (strcmp(device->comment, val))
+					syslog(LOG_NOTICE, "Device %s changed comment %s to %s", device->uuid, device->comment, val);
 				    free(device->comment);
+				}
 				device->comment = xstrcpy(val);
 
 			    }

mercurial