35 lines
924 B
C
35 lines
924 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[100];
|
|
sprintf(address, "udp://0.0.0.0:%u", global_controller->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[100];
|
|
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[100];
|
|
sprintf(address, "tcp://localhost:%u", global_config.mqtt_port);
|
|
struct mg_connection *c = mg_connect(mgr, address, handler_mqtt);
|
|
return c;
|
|
}
|