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>
|
|
|
|
|
2020-05-05 23:16:43 +00:00
|
|
|
#include <constants.h>
|
2020-05-05 23:05:36 +00:00
|
|
|
#include <cJSON.h>
|
2020-05-05 09:42:02 +00:00
|
|
|
#include <helpers.h>
|
|
|
|
#include <models/relay.h>
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2020-05-05 23:05:36 +00:00
|
|
|
int id;
|
|
|
|
uuid_t uid;
|
2020-05-05 23:16:43 +00:00
|
|
|
char name[MAX_NAME_LENGTH + 1];
|
2020-05-05 09:42:02 +00:00
|
|
|
char ip[17];
|
|
|
|
int active;
|
|
|
|
int port;
|
|
|
|
int relay_count;
|
|
|
|
relay_t **relays;
|
|
|
|
} controller_t;
|
|
|
|
|
|
|
|
void
|
|
|
|
controller_free(controller_t* contoller);
|
|
|
|
|
|
|
|
int
|
|
|
|
controller_save(controller_t* contoller);
|
|
|
|
|
|
|
|
int
|
|
|
|
controller_remove(controller_t* contoller);
|
|
|
|
|
2020-05-05 23:05:36 +00:00
|
|
|
cJSON*
|
2020-05-05 09:42:02 +00:00
|
|
|
controller_to_json(controller_t* contoller);
|
|
|
|
|
2020-05-05 23:05:36 +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
|
|
|
|
|
|
|
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 */
|