thermferm/devices.c

changeset 715
f5d85af156ab
parent 714
24749c296a50
child 716
5c30c8ef83a8
equal deleted inserted replaced
714:24749c296a50 715:f5d85af156ab
38 38
39 extern const char DEVTYPE[8][6]; 39 extern const char DEVTYPE[8][6];
40 extern const char DEVPRESENT[4][6]; 40 extern const char DEVPRESENT[4][6];
41 extern const char DEVDIR[7][11]; 41 extern const char DEVDIR[7][11];
42 42
43
44 #ifdef USE_SIMULATOR
45
46 extern int SIMcooling;
47 extern int SIMheating;
48 extern int SIMfan;
49 extern int SIMlight;
50
51 #endif
52
53
54 void devices_ws(void);
55 43
56 44
57 /* 45 /*
58 * Since kernel version 4 there is a module, and a dtoverlay so that the 46 * Since kernel version 4 there is a module, and a dtoverlay so that the
59 * temperature and humidity can simply read from the /sys filesystem. 47 * temperature and humidity can simply read from the /sys filesystem.
384 return present; 372 return present;
385 } 373 }
386 } 374 }
387 375
388 return DEVPRESENT_NO; 376 return DEVPRESENT_NO;
377 }
378
379
380 int device_present(char *address, int present)
381 {
382 devices_list *device;
383
384 if (address == NULL || present < DEVPRESENT_UNDEF || present > DEVPRESENT_ERROR) {
385 return -1;
386 }
387
388 for (device = Config.devices; device; device = device->next) {
389 if (! strcmp(address, device->address)) {
390 if (device->present != present) {
391 device->present = present;
392 device->timestamp = time(NULL);
393 return 1;
394 }
395 return 0;
396 }
397 }
398 return -1;
389 } 399 }
390 400
391 401
392 /* 402 /*
393 * Return json data for one device. 403 * Return json data for one device.

mercurial