core-legacy/include/models/controller.h

58 lines
982 B
C
Raw Permalink Normal View History

2020-05-05 09:42:02 +00:00
#ifndef CORE_MODELS_CONTROLLER_H
#define CORE_MODELS_CONTROLLER_H
#include <uuid/uuid.h>
#include <sqlite3.h>
#include <cJSON.h>
#include <constants.h>
2020-05-05 09:42:02 +00:00
#include <helpers.h>
#include <models/relay.h>
#define IP_LENGTH 16
2020-05-05 09:42:02 +00:00
typedef struct
{
int id;
uuid_t uid;
char name[MAX_NAME_LENGTH + 1];
char ip[IP_LENGTH + 1];
2020-05-05 09:42:02 +00:00
int active;
int port;
int relay_count;
relay_t **relays;
} controller_t;
void
2020-11-13 23:34:20 +00:00
controller_free(controller_t *controller);
2020-05-05 09:42:02 +00:00
int
2020-11-13 23:34:20 +00:00
controller_save(controller_t *controller);
2020-05-05 09:42:02 +00:00
int
2020-11-13 23:34:20 +00:00
controller_remove(controller_t *controller);
2020-05-05 09:42:02 +00:00
cJSON*
2020-11-13 23:34:20 +00:00
controller_to_json(controller_t *controller);
2020-05-05 09:42:02 +00:00
controller_t*
controller_get_by_id(int id);
controller_t*
controller_get_by_uid(uuid_t uid);
2020-05-05 09:42:02 +00:00
int
controller_get_id_for_uid(uuid_t uid);
2020-05-05 09:42:02 +00:00
controller_t**
controller_get_all();
int
controller_command(int command_code, char *payload, uint32_t payload_size);
void
controller_free_list(controller_t **controllers_list);
#endif /* CORE_MODELS_CONTROLLER_H */