add: mqtt status client

This commit is contained in:
Tobias Reisinger 2020-06-26 01:28:00 +02:00
parent 1d1ae61310
commit 679175f1a9
11 changed files with 119 additions and 40 deletions

35
src/connections.c Normal file
View file

@ -0,0 +1,35 @@
#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;
}