thermferm/server.c

changeset 276
a19cc3770f09
parent 274
111b0e9663dc
child 278
76c8a6f18e4d
equal deleted inserted replaced
275:a86c702c2e4f 276:a19cc3770f09
379 val = strtok(NULL, "\0"); 379 val = strtok(NULL, "\0");
380 if (kwd && val) { 380 if (kwd && val) {
381 if (strcmp(kwd, (char *)"TYPE") == 0) { 381 if (strcmp(kwd, (char *)"TYPE") == 0) {
382 for (i = 0; i < 8; i++) { 382 for (i = 0; i < 8; i++) {
383 if (strcmp(val, DEVTYPE[i]) == 0) { 383 if (strcmp(val, DEVTYPE[i]) == 0) {
384 if (device->type != i)
385 syslog(LOG_NOTICE, "Device %s changed type %s to %s", device->uuid, DEVTYPE[device->type], DEVTYPE[i]);
384 device->type = i; 386 device->type = i;
385 break; 387 break;
386 } 388 }
387 } 389 }
388 390
389 } else if (strcmp(kwd, (char *)"DIRECTION") == 0) { 391 } else if (strcmp(kwd, (char *)"DIRECTION") == 0) {
390 for (i = 0; i < 7; i++) { 392 for (i = 0; i < 7; i++) {
391 if (strcmp(val, DEVDIR[i]) == 0) { 393 if (strcmp(val, DEVDIR[i]) == 0) {
394 if (device->direction != i)
395 syslog(LOG_NOTICE, "Device %s changed direction %s to %s", device->uuid, DEVDIR[device->type], DEVDIR[i]);
392 device->direction = i; 396 device->direction = i;
393 break; 397 break;
394 } 398 }
395 } 399 }
396 400
397 } else if (strcmp(kwd, (char *)"VALUE") == 0) { 401 } else if (strcmp(kwd, (char *)"VALUE") == 0) {
398 if (sscanf(val, "%d", &ival) == 1) 402 if (sscanf(val, "%d", &ival) == 1) {
403 if (device->value != ival)
404 syslog(LOG_NOTICE, "Device %s changed value %d to %d", device->uuid, device->value, ival);
399 device->value = ival; 405 device->value = ival;
406 }
400 407
401 } else if (strcmp(kwd, (char *)"OFFSET") == 0) { 408 } else if (strcmp(kwd, (char *)"OFFSET") == 0) {
402 if (sscanf(val, "%d", &ival) == 1) 409 if (sscanf(val, "%d", &ival) == 1) {
410 if (device->offset != ival)
411 syslog(LOG_NOTICE, "Device %s changed offset %d to %d", device->uuid, device->offset, ival);
403 device->offset = ival; 412 device->offset = ival;
413 }
404 414
405 } else if (strcmp(kwd, (char *)"PRESENT") == 0) { 415 } else if (strcmp(kwd, (char *)"PRESENT") == 0) {
406 for (i = 0; i < 4; i++) { 416 for (i = 0; i < 4; i++) {
407 if (strcmp(val, DEVPRESENT[i]) == 0) { 417 if (strcmp(val, DEVPRESENT[i]) == 0) {
418 if (device->present != i)
419 syslog(LOG_NOTICE, "Device %s changed present %s to %s", device->uuid, DEVPRESENT[device->present], DEVPRESENT[i]);
408 device->present = i; 420 device->present = i;
409 break; 421 break;
410 } 422 }
411 } 423 }
412 424
413 } else if (strcmp(kwd, (char *)"ADDRESS") == 0) { 425 } else if (strcmp(kwd, (char *)"ADDRESS") == 0) {
414 if (device->address) 426 if (device->address) {
427 if (strcmp(device->address, val))
428 syslog(LOG_NOTICE, "Device %s changed address %s to %s", device->uuid, device->address, val);
415 free(device->address); 429 free(device->address);
430 }
416 device->address = xstrcpy(val); 431 device->address = xstrcpy(val);
417 432
418 } else if (strcmp(kwd, (char *)"SUBDEVICE") == 0) { 433 } else if (strcmp(kwd, (char *)"SUBDEVICE") == 0) {
419 if (sscanf(val, "%d", &ival) == 1) 434 if (sscanf(val, "%d", &ival) == 1) {
435 if (device->subdevice != ival)
436 syslog(LOG_NOTICE, "Device %s changed subdevice %d to %d", device->uuid, device->subdevice, ival);
420 device->subdevice = ival; 437 device->subdevice = ival;
438 }
421 439
422 } else if (strcmp(kwd, (char *)"GPIOPIN") == 0) { 440 } else if (strcmp(kwd, (char *)"GPIOPIN") == 0) {
423 if (sscanf(val, "%d", &ival) == 1) 441 if (sscanf(val, "%d", &ival) == 1) {
442 if (device->gpiopin != ival)
443 syslog(LOG_NOTICE, "Device %s changed gpiopin %d to %d", device->uuid, device->gpiopin, ival);
424 device->gpiopin = ival; 444 device->gpiopin = ival;
445 }
425 446
426 } else if (strcmp(kwd, (char *)"DESCRIPTION") == 0) { 447 } else if (strcmp(kwd, (char *)"DESCRIPTION") == 0) {
427 if (device->description) 448 if (device->description) {
449 if (strcmp(device->description, val))
450 syslog(LOG_NOTICE, "Device %s changed description %s to %s", device->uuid, device->description, val);
428 free(device->description); 451 free(device->description);
452 }
429 device->description = xstrcpy(val); 453 device->description = xstrcpy(val);
430 454
431 } else if (strcmp(kwd, (char *)"COMMENT") == 0) { 455 } else if (strcmp(kwd, (char *)"COMMENT") == 0) {
432 if (device->comment) 456 if (device->comment) {
457 if (strcmp(device->comment, val))
458 syslog(LOG_NOTICE, "Device %s changed comment %s to %s", device->uuid, device->comment, val);
433 free(device->comment); 459 free(device->comment);
460 }
434 device->comment = xstrcpy(val); 461 device->comment = xstrcpy(val);
435 462
436 } 463 }
437 } 464 }
438 } 465 }

mercurial