diff -r 597688feda2f -r 350401bac16e thermferm/server.c --- a/thermferm/server.c Tue Jul 22 23:14:19 2014 +0200 +++ b/thermferm/server.c Wed Jul 23 16:49:37 2014 +0200 @@ -201,7 +201,8 @@ char *opt, *filename, *p, q[2], buffer[256]; units_list *unit; profiles_list *profile; - int i; + prof_step *step; + int i, j, ref; DIR *fd; FILE *fp; struct dirent *de; @@ -230,18 +231,47 @@ srv_send((char *)"212 1-wire bus devices:"); while ((de = readdir(fd))) { if (de->d_name[0] != '.') { + ref = 0; if (strncmp(de->d_name, (char *)"w1", 2) == 0) { - srv_send((char *)"%s,N/A,System device", de->d_name); + srv_send((char *)"%s,0,NA,System device", de->d_name); } else if (strncmp(de->d_name, (char *)"10", 2) == 0) { - srv_send((char *)"%s,18S20,Digital thermometer", de->d_name); + if (Config.air_address && (strncmp((char *)"10", Config.air_address, 2) == 0)) + ref++; + for (unit = Config.units; unit; unit = unit->next) { + if (unit->air_address && (strncmp((char *)"10", unit->air_address, 2) == 0)) + ref++; + if (unit->beer_address && (strncmp((char *)"10", unit->beer_address, 2) == 0)) + ref++; + } + srv_send((char *)"%s,%d,18S20,Digital thermometer", ref, de->d_name); } else if (strncmp(de->d_name, (char *)"28", 2) == 0) { - srv_send((char *)"%s,18B20,Digital thermometer", de->d_name); + if (Config.air_address && (strncmp((char *)"28", Config.air_address, 2) == 0)) + ref++; + for (unit = Config.units; unit; unit = unit->next) { + if (unit->air_address && (strncmp((char *)"28", unit->air_address, 2) == 0)) + ref++; + if (unit->beer_address && (strncmp((char *)"28", unit->beer_address, 2) == 0)) + ref++; + } + srv_send((char *)"%s,%d,18B20,Digital thermometer", ref, de->d_name); } else if (strncmp(de->d_name, (char *)"29", 2) == 0) { - srv_send((char *)"%s,2408,8 Channel addressable switch/LCD", de->d_name); + for (unit = Config.units; unit; unit = unit->next) { + if (unit->io1_address && (strncmp((char *)"29", unit->io1_address, 2) == 0)) + ref++; + if (unit->io2_address && (strncmp((char *)"29", unit->io2_address, 2) == 0)) + ref++; + } + srv_send((char *)"%s,%d,2408,8 Channel addressable switch/LCD", ref, de->d_name); } else if (strncmp(de->d_name, (char *)"3a", 2) == 0) { - srv_send((char *)"%s,2413,Dual channel addressable switchs", de->d_name); + for (unit = Config.units; unit; unit = unit->next) { + if (unit->io1_address && (strncmp((char *)"3a", unit->io1_address, 2) == 0)) + ref++; + if (unit->io2_address && (strncmp((char *)"3a", unit->io2_address, 2) == 0)) + ref++; + } + srv_send((char *)"%s,%d,2413,Dual channel addressable switchs", ref, de->d_name); } else { - srv_send((char *)"%s,N/A,Unknown device", de->d_name); + srv_send((char *)"%s,0,NA,Unknown device", de->d_name); } } } @@ -305,7 +335,10 @@ i = 0; for (profile = Config.profiles; profile; profile = profile->next) { i++; - srv_send((char *)"%d,%s,%s", i, profile->uuid, profile->name); + j = 0; + for (step = profile->steps; step; step = step->next) + j++; + srv_send((char *)"%d,%s,%s,%d", i, profile->uuid, profile->name, j); } srv_send((char *)"."); return 0;