54 lines
850 B
C
54 lines
850 B
C
#ifndef CONTROLLER_RELAY_H
|
|
#define CONTROLLER_RELAY_H
|
|
|
|
#include <stdint.h>
|
|
#include <time.h>
|
|
#include <lmdb.h>
|
|
|
|
#include <constants.h>
|
|
#include <models/schedule.h>
|
|
|
|
typedef struct
|
|
{
|
|
int id;
|
|
uint8_t number;
|
|
int is_on;
|
|
int pulse_timer;
|
|
int sent_to_broker;
|
|
char name[MAX_NAME_LENGTH + 1];
|
|
schedule_t *schedules[7];
|
|
} relay_t;
|
|
|
|
/**
|
|
* @brief Key to save relay information in database
|
|
*/
|
|
typedef enum
|
|
{
|
|
DB_KEY_RELAY_NAME = 0,
|
|
} db_key_relay_e;
|
|
|
|
relay_t*
|
|
relay_create(uint8_t number);
|
|
|
|
void
|
|
relay_set_name(relay_t *relay, const char *name);
|
|
|
|
relay_t*
|
|
relay_load(uint8_t number);
|
|
|
|
int
|
|
relay_save(relay_t *relay);
|
|
|
|
void
|
|
relay_reload_schedules(relay_t *relay);
|
|
|
|
int
|
|
relay_is_on_schedule(relay_t *relay, struct tm *time_struct);
|
|
|
|
void
|
|
relay_free(relay_t *relay);
|
|
|
|
void
|
|
relay_debug(relay_t *relay);
|
|
|
|
#endif //CONTROLLER_RELAY_H
|