Skip to content

Commit

Permalink
remove mqtt creds from status page and add uptime
Browse files Browse the repository at this point in the history
  • Loading branch information
softypit committed Mar 2, 2020
1 parent 5a57625 commit d49ebc8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ifndef IDF_PATH
endif

PROJECT_NAME := eq3_trv_control
PROJECT_VER := 1.49-beta
PROJECT_VER := 1.55-beta

COMPONENT_ADD_INCLUDEDIRS := components/include

Expand Down
11 changes: 10 additions & 1 deletion main/eq3_bootwifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ static int mongoose_serve_log(struct mg_connection *nc){

/* Serve the status page */
static int mongoose_serve_status(struct mg_connection *nc){
uint32_t seconds, minutes, hours, days;
if(sta_configured == false){
mongoose_serve_content(nc, (char *)apstatus, true);
nc->flags |= MG_F_SEND_AND_CLOSE;
Expand All @@ -364,8 +365,16 @@ static int mongoose_serve_status(struct mg_connection *nc){
sprintf(status, "not connected");
break;
}
seconds = (uint32_t)(esp_timer_get_time() / 1000000);
minutes = (seconds / 60);
hours = (minutes / 60);
days = (hours / 24);
seconds %= 60;
minutes %= 60;
hours %= 24;

char *htmlstr = malloc(strlen(connectedstatus) + strlen(connectionInfo.mqtturl) + strlen(connectionInfo.mqttuser) + strlen(connectionInfo.mqttpass) + strlen(connectionInfo.mqttid) + 15);
sprintf(htmlstr, connectedstatus, connectionInfo.mqtturl, connectionInfo.mqttuser, connectionInfo.mqttpass, connectionInfo.mqttid, status);
sprintf(htmlstr, connectedstatus, connectionInfo.mqtturl, connectionInfo.mqttid, status, days, hours, minutes, seconds);
mongoose_serve_content(nc, htmlstr, true);
free(htmlstr);
nc->flags |= MG_F_SEND_AND_CLOSE;
Expand Down
3 changes: 1 addition & 2 deletions main/eq3_htmlpages.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ const char connectedstatus[] = "<title>EQ3 status</title> \
<div style='text-align:center;'><h1>EQ3 relay status</h1></div> \
<table style=\"margin:1em auto;\"> \
<tr><td>MQTT URL:</td><td>%s</td></tr> \
<tr><td>MQTT user:</td><td>%s</td></tr> \
<tr><td>MQTT pass:</td><td>%s</td></tr> \
<tr><td>MQTT ID:</td><td>%s</td></tr> \
<tr><td>MQTT status:</td><td>%s</td></tr> \
<tr><td>Uptime:</td><td>%01d days %02d:%02d:%02d</td></tr> \
</table>";

const char apstatus[] = "<title>Please configure me</title> \
Expand Down
2 changes: 1 addition & 1 deletion main/eq3_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define EQ3_MAIN_H

#define EQ3_MAJVER "1"
#define EQ3_MINVER "51"
#define EQ3_MINVER "55"
#define EQ3_EXTRAVER "-beta"

void eq3_log_init(void);
Expand Down
4 changes: 4 additions & 0 deletions main/eq3_wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ int connect_server(char *url, char *user, char *password, char *id){
return -1;
}

/* Only submit the password if the username is set */
if(user == NULL)
password = NULL;

snprintf(lwt_topic_buff, LWT_TOPIC_LEN, "/%sradout", id);
snprintf(intopicbase, IN_TOPIC_LEN, "/%sradin", id);
snprintf(outtopicbase, OUT_TOPIC_LEN, "/%sradout", id);
Expand Down

0 comments on commit d49ebc8

Please sign in to comment.