#ifndef CONTROLLER_RELAY_H #define CONTROLLER_RELAY_H #include #include #include #include #include typedef struct { uint8_t number; int is_on; 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); /** * @brief Load a relay for database or create a new one * * @param mdb_env An opened MDB_env to load from * * @return A loaded or new instance of relay */ relay_t* relay_load(MDB_env *mdb_env, uint8_t num); /** * @brief Save a relay to the database * * @param relay Instance of a relay * @param mdb_env Already created MDB_env * * @return Indicator to show success (0) or failure (!0) */ int relay_save(relay_t *relay, MDB_env *mdb_env); int relay_is_active(relay_t *relay, struct tm *time_struct); void relay_free(relay_t *relay); void relay_debug(relay_t *relay); #endif //CONTROLLER_RELAY_H