bmsd/rdconfig.c

changeset 696
f4de55f587c1
parent 194
d202777ebae5
child 747
b6fbe6821468
equal deleted inserted replaced
695:cfe232710027 696:f4de55f587c1
52 {(char *)"mqtt_host", getstr, (char **)&Config.mqtt_host}, 52 {(char *)"mqtt_host", getstr, (char **)&Config.mqtt_host},
53 {(char *)"mqtt_port", getint, (char **)&Config.mqtt_port}, 53 {(char *)"mqtt_port", getint, (char **)&Config.mqtt_port},
54 {(char *)"mqtt_user", getstr, (char **)&Config.mqtt_user}, 54 {(char *)"mqtt_user", getstr, (char **)&Config.mqtt_user},
55 {(char *)"mqtt_pass", getstr, (char **)&Config.mqtt_pass}, 55 {(char *)"mqtt_pass", getstr, (char **)&Config.mqtt_pass},
56 {(char *)"web_root", getstr, (char **)&Config.web_root}, 56 {(char *)"web_root", getstr, (char **)&Config.web_root},
57 {(char *)"websocket_port", getint, (char **)&Config.websocket_port},
57 {NULL, NULL, NULL} 58 {NULL, NULL, NULL}
58 }; 59 };
59 60
60 61
61 62
97 Config.mqtt_pass = NULL; 98 Config.mqtt_pass = NULL;
98 99
99 if (Config.web_root) 100 if (Config.web_root)
100 free(Config.web_root); 101 free(Config.web_root);
101 Config.web_root = NULL; 102 Config.web_root = NULL;
103 Config.websocket_port = 8010;
102 } 104 }
103 105
104 106
105 107
106 int wrconfig(void) 108 int wrconfig(void)
159 161
160 if (Config.web_root) 162 if (Config.web_root)
161 fprintf(fp, "web_root %s\n", Config.web_root); 163 fprintf(fp, "web_root %s\n", Config.web_root);
162 else 164 else
163 fprintf(fp, "#web_root </path/to/webroot>\n"); 165 fprintf(fp, "#web_root </path/to/webroot>\n");
166 fprintf(fp, "websocket_port %d\n", Config.websocket_port);
164 fprintf(fp, "#\n"); 167 fprintf(fp, "#\n");
165 fprintf(fp, "# End of generated configuration\n"); 168 fprintf(fp, "# End of generated configuration\n");
166 fclose(fp); 169 fclose(fp);
167 free(mypath); 170 free(mypath);
168 mypath = NULL; 171 mypath = NULL;
196 uuid_unparse(uu, Config.bms_uuid); 199 uuid_unparse(uu, Config.bms_uuid);
197 Config.mysql_port = 3306; 200 Config.mysql_port = 3306;
198 Config.mysql_host = xstrcpy((char *)"localhost"); 201 Config.mysql_host = xstrcpy((char *)"localhost");
199 Config.mqtt_port = 1883; 202 Config.mqtt_port = 1883;
200 Config.mqtt_host = xstrcpy((char *)"localhost"); 203 Config.mqtt_host = xstrcpy((char *)"localhost");
204 Config.websocket_port = 8010;
201 return wrconfig(); 205 return wrconfig();
202 } 206 }
203 207
204 linecnt = 0; 208 linecnt = 0;
205 while (fgets(buf, sizeof(buf) -1, fp)) { 209 while (fgets(buf, sizeof(buf) -1, fp)) {

mercurial