add: mqtt host config option
This commit is contained in:
parent
b2ac46c0fd
commit
eefe50b3cd
5 changed files with 12 additions and 8 deletions
src
|
@ -10,7 +10,7 @@ struct mg_connection *global_connection_mqtt;
|
|||
struct mg_connection*
|
||||
connection_discovery_bind(struct mg_mgr *mgr)
|
||||
{
|
||||
char address[100];
|
||||
char address[32];
|
||||
sprintf(address, "udp://0.0.0.0:%u", global_controller->discovery_port);
|
||||
struct mg_connection *c = mg_bind(mgr, address, handler_discovery);
|
||||
return c;
|
||||
|
@ -19,7 +19,7 @@ connection_discovery_bind(struct mg_mgr *mgr)
|
|||
struct mg_connection*
|
||||
connection_command_bind(struct mg_mgr *mgr)
|
||||
{
|
||||
char address[100];
|
||||
char address[32];
|
||||
sprintf(address, "tcp://0.0.0.0:%u", global_controller->command_port);
|
||||
struct mg_connection *c = mg_bind(mgr, address, handler_command);
|
||||
return c;
|
||||
|
@ -28,8 +28,8 @@ connection_command_bind(struct mg_mgr *mgr)
|
|||
struct mg_connection*
|
||||
connection_mqtt_connect(struct mg_mgr *mgr)
|
||||
{
|
||||
char address[100];
|
||||
sprintf(address, "tcp://127.0.0.1:%u", global_config.mqtt_port);
|
||||
char address[512];
|
||||
sprintf(address, "tcp://%s:%u", global_config.mqtt_host, global_config.mqtt_port);
|
||||
struct mg_connection *c = mg_connect(mgr, address, handler_mqtt);
|
||||
return c;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ helper_load_config(IniDispatch *disp, void *config_void)
|
|||
}
|
||||
if(CONFINI_IS_KEY("controller", "database"))
|
||||
{
|
||||
config->database = malloc(sizeof(char) * (strlen(disp->value) + 1));
|
||||
strcpy(config->database, disp->value);
|
||||
return 0;
|
||||
}
|
||||
|
@ -75,6 +74,11 @@ helper_load_config(IniDispatch *disp, void *config_void)
|
|||
config->mqtt_port = atoi(disp->value);
|
||||
return 0;
|
||||
}
|
||||
if(CONFINI_IS_KEY("controller", "mqtt-host"))
|
||||
{
|
||||
strcpy(config->mqtt_host, disp->value);
|
||||
return 0;
|
||||
}
|
||||
if(CONFINI_IS_KEY("controller", "relay-count"))
|
||||
{
|
||||
config->relay_count = atoi(disp->value);
|
||||
|
|
|
@ -43,8 +43,6 @@ terminate(int signum)
|
|||
LOG_DEBUG("freeing global controller\n");
|
||||
controller_free(global_controller);
|
||||
|
||||
LOG_DEBUG("freeing database config\n");
|
||||
free(global_config.database);
|
||||
LOG_DEBUG("freeing relay configs config\n");
|
||||
free(global_config.relay_configs);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue