coolers/mosquitto.c

changeset 40
dafbbd5e9922
parent 35
f3c5ae78b746
equal deleted inserted replaced
39:442357970a34 40:dafbbd5e9922
40 static int last_mid_sent = -1; 40 static int last_mid_sent = -1;
41 static bool connected = true; 41 static bool connected = true;
42 static bool disconnect_sent = false; 42 static bool disconnect_sent = false;
43 static bool connect_lost = false; 43 static bool connect_lost = false;
44 44
45 extern bool shutdown; 45 extern bool my_shutdown;
46 extern bool debug; 46 extern bool debug;
47 extern sys_config Config; 47 extern sys_config Config;
48 extern int lcdHandle; 48 extern int lcdHandle;
49 extern int lcdupdate; 49 extern int lcdupdate;
50 50
65 65
66 66
67 67
68 void my_disconnect_callback(struct mosquitto *mosq, void *obj, int rc) 68 void my_disconnect_callback(struct mosquitto *mosq, void *obj, int rc)
69 { 69 {
70 if (shutdown) { 70 if (my_shutdown) {
71 syslog(LOG_NOTICE, "Acknowledged DISCONNECT from %s", Config.mosq_host); 71 syslog(LOG_NOTICE, "Acknowledged DISCONNECT from %s", Config.mosq_host);
72 connected = false; 72 connected = false;
73 } else { 73 } else {
74 /* 74 /*
75 * The remove server was brought down. We must keep running 75 * The remove server was brought down. We must keep running
328 free(alias); 328 free(alias);
329 alias = NULL; 329 alias = NULL;
330 } 330 }
331 } 331 }
332 332
333 if (shutdown) { 333 if (my_shutdown) {
334 /* 334 /*
335 * Final publish 0 to clients/<hostname>/coolers/state 335 * Final publish 0 to clients/<hostname>/coolers/state
336 */ 336 */
337 sprintf(buf, "0"); 337 sprintf(buf, "0");
338 mosquitto_publish(mymosq, &mid_sent, state, strlen(buf), buf, qos, true); 338 mosquitto_publish(mymosq, &mid_sent, state, strlen(buf), buf, qos, true);
339 last_mid = mid_sent; 339 last_mid = mid_sent;
340 status = STATUS_WAITING; 340 status = STATUS_WAITING;
341 lcdClear(lcdHandle); 341 mb_lcdClear(lcdHandle);
342 lcdPosition(lcdHandle, 0, 0); 342 // lcdPosition(lcdHandle, 0, 0);
343 lcdPuts(lcdHandle, "Shuting down ..."); 343 mb_lcdPuts(lcdHandle, "Shuting down ...");
344 } 344 }
345 345
346 } else if (status == STATUS_WAITING) { 346 } else if (status == STATUS_WAITING) {
347 if (debug) 347 if (debug)
348 fprintf(stdout, (char *)"Waiting\n"); 348 fprintf(stdout, (char *)"Waiting\n");

mercurial