# HG changeset patch # User Michiel Broek # Date 1398785262 -7200 # Node ID 21901dc955018eeaa2a787a8fdb2ffb948e9cd53 # Parent 7f8432413321f9115fe00834ec9524a1f90bc03f Added alias names diff -r 7f8432413321 -r 21901dc95501 thermometers/main.c --- a/thermometers/main.c Sat Apr 26 22:53:10 2014 +0200 +++ b/thermometers/main.c Tue Apr 29 17:27:42 2014 +0200 @@ -326,6 +326,32 @@ sprintf(buf, "1"); rc = mosquitto_publish(mosq, &mid_sent, state, strlen(buf), buf, qos, 1); + /* + * Report alias names + */ + for (tmp1 = Config.w1therms; tmp1; tmp1 = old1) { + old1 = tmp1->next; + + alias = xstrcpy((char *)"/raw/"); + alias = xstrcat(alias, hostname); + alias = xstrcat(alias, (char *)"/thermometers/w1/"); + alias = xstrcat(alias, tmp1->master); + alias = xstrcat(alias, (char *)"/"); + alias = xstrcat(alias, tmp1->name); + alias = xstrcat(alias, (char *)"/alias"); + + sprintf(buf, "%s", tmp1->alias); + if ((rc = mosquitto_publish(mosq, &mid_sent, alias, strlen(buf), buf, qos, 1))) { + if (rc == MOSQ_ERR_NO_CONN) + mosquitto_reconnect(mosq); + else + syslog(LOG_NOTICE, "mainloop: error %d from mosquitto_publish", rc); + } + + free(alias); + alias = NULL; + } + if (debug) fprintf(stdout, (char *)"Enter loop, connected %d\n", connected);