58 lines
930 B
C
58 lines
930 B
C
#ifndef CORE_RELAY_H
|
|
#define CORE_RELAY_H
|
|
|
|
#include <string.h>
|
|
#include <uuid/uuid.h>
|
|
|
|
#include <constants.h>
|
|
#include <cJSON.h>
|
|
#include <helpers.h>
|
|
#include <database.h>
|
|
#include <models/schedule.h>
|
|
|
|
typedef struct
|
|
{
|
|
int id;
|
|
char name[MAX_NAME_LENGTH + 1];
|
|
int number;
|
|
int controller_id;
|
|
int active_schedule_id;
|
|
int is_on;
|
|
schedule_t *active_schedule;
|
|
schedule_t *schedules[7];
|
|
} relay_t;
|
|
|
|
int
|
|
relay_save();
|
|
|
|
void
|
|
relay_reload_active_schedule(relay_t *relay);
|
|
|
|
cJSON*
|
|
relay_to_json(relay_t *relay);
|
|
|
|
cJSON*
|
|
relay_list_to_json(relay_t **relays);
|
|
|
|
void
|
|
relay_free(relay_t *relay);
|
|
|
|
void
|
|
relay_free_list(relay_t **relays_list);
|
|
|
|
relay_t*
|
|
relay_get_by_id(int id);
|
|
|
|
relay_t*
|
|
relay_get_for_controller(int controller_id, int relay_num);
|
|
|
|
relay_t**
|
|
relay_get_with_schedule(int schedule_id);
|
|
|
|
relay_t**
|
|
relay_get_all();
|
|
|
|
relay_t**
|
|
relay_get_by_controller_id(int controller_id);
|
|
|
|
#endif /* CORE_RELAY_H */
|