controller-legacy/src/connections.c
Tobias Reisinger 9602e6e937 remove: lmdb
add: sqlite
add: new commands
2020-08-24 16:00:08 +02:00

35 lines
935 B
C

#include <stdio.h>
#include <connections.h>
#include <models/controller.h>
#include <config.h>
#include <handlers.h>
struct mg_connection *global_connection_mqtt;
struct mg_connection*
connection_discovery_bind(struct mg_mgr *mgr)
{
char address[32];
sprintf(address, "udp://0.0.0.0:%u", global_config.discovery_port);
struct mg_connection *c = mg_bind(mgr, address, handler_discovery);
return c;
}
struct mg_connection*
connection_command_bind(struct mg_mgr *mgr)
{
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;
}
struct mg_connection*
connection_mqtt_connect(struct mg_mgr *mgr)
{
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;
}