367 srv_send((char *)"."); |
366 srv_send((char *)"."); |
368 return 0; |
367 return 0; |
369 |
368 |
370 } else if (strcmp(opt, (char *)"BUS") == 0) { |
369 } else if (strcmp(opt, (char *)"BUS") == 0) { |
371 /* |
370 /* |
372 * 1-wire bus |
371 * Bus devices |
373 */ |
372 */ |
374 if ((fd = opendir((char *)"/sys/bus/w1/devices"))) { |
373 srv_send((char *)"212 bus devices:"); |
375 srv_send((char *)"212 1-wire bus devices:"); |
374 for (device = Config.devices; device; device = device->next) { |
376 while ((de = readdir(fd))) { |
375 srv_send((char *)"%s,%s,%d,%d,%s", device->uuid, device->address, device->subdevice, device->inuse, device->comment); |
377 if (de->d_name[0] != '.') { |
376 } |
378 ref = 0; |
377 srv_send((char *)"."); |
379 if (strncmp(de->d_name, (char *)"w1", 2) == 0) { |
378 return 0; |
380 srv_send((char *)"%s,0,NA,System device", de->d_name); |
|
381 } else if (strncmp(de->d_name, (char *)"10", 2) == 0) { |
|
382 if (Config.air_address && (strcmp(de->d_name, Config.air_address) == 0)) |
|
383 ref++; |
|
384 for (unit = Config.units; unit; unit = unit->next) { |
|
385 if (unit->air_address && (strcmp(de->d_name, unit->air_address) == 0)) |
|
386 ref++; |
|
387 if (unit->beer_address && (strcmp(de->d_name, unit->beer_address) == 0)) |
|
388 ref++; |
|
389 } |
|
390 srv_send((char *)"%s,%d,18S20,Digital thermometer", de->d_name, ref); |
|
391 } else if (strncmp(de->d_name, (char *)"28", 2) == 0) { |
|
392 if (Config.air_address && (strcmp(de->d_name, Config.air_address) == 0)) |
|
393 ref++; |
|
394 for (unit = Config.units; unit; unit = unit->next) { |
|
395 if (unit->air_address && (strcmp(de->d_name, unit->air_address) == 0)) |
|
396 ref++; |
|
397 if (unit->beer_address && (strcmp(de->d_name, unit->beer_address) == 0)) |
|
398 ref++; |
|
399 } |
|
400 srv_send((char *)"%s,%d,18B20,Digital thermometer", de->d_name, ref); |
|
401 } else if (strncmp(de->d_name, (char *)"29", 2) == 0) { |
|
402 for (unit = Config.units; unit; unit = unit->next) { |
|
403 if (unit->io1_address && (strncmp((char *)"29", unit->io1_address, 2) == 0)) |
|
404 ref++; |
|
405 if (unit->io2_address && (strncmp((char *)"29", unit->io2_address, 2) == 0)) |
|
406 ref++; |
|
407 } |
|
408 srv_send((char *)"%s,%d,2408,8 Channel addressable switch/LCD", de->d_name, ref); |
|
409 } else if (strncmp(de->d_name, (char *)"3a", 2) == 0) { |
|
410 for (unit = Config.units; unit; unit = unit->next) { |
|
411 if (unit->io1_address && (strncmp((char *)"3a", unit->io1_address, 2) == 0)) |
|
412 ref++; |
|
413 if (unit->io2_address && (strncmp((char *)"3a", unit->io2_address, 2) == 0)) |
|
414 ref++; |
|
415 } |
|
416 srv_send((char *)"%s,%d,2413,Dual channel addressable switch", de->d_name, ref); |
|
417 } else { |
|
418 srv_send((char *)"%s,0,NA,Unknown device", de->d_name); |
|
419 } |
|
420 } |
|
421 } |
|
422 srv_send((char *)"."); |
|
423 closedir(fd); |
|
424 return 0; |
|
425 } else { |
|
426 srv_send((char *)"503 directory /sys/bus/w1/devices: %s", strerror(errno)); |
|
427 return 1; |
|
428 } |
|
429 |
379 |
430 } else if (strcmp(opt, (char *)"LOG") == 0) { |
380 } else if (strcmp(opt, (char *)"LOG") == 0) { |
431 /* |
381 /* |
432 * Get the logfile data and emit only one line per hour. |
382 * Get the logfile data and emit only one line per hour. |
433 */ |
383 */ |