controller-legacy/include/models/schedule.h

57 lines
1,011 B
C

#ifndef CONTROLLER_SCHEDULE_H
#define CONTROLLER_SCHEDULE_H
#include <stdint.h>
#include <uuid/uuid.h>
#include <models/period.h>
typedef struct
{
int id;
uuid_t uid;
uint8_t weekday;
uint16_t periods_count;
period_t *periods;
} schedule_t;
/**
* @brief Key to save schedule information in database
*/
typedef enum
{
DB_KEY_SCHEDULE_ID = 0,
DB_KEY_SCHEDULE_PERIODS = 1,
} db_key_schedule_e;
schedule_t*
schedule_create(uuid_t uid, uint16_t length, uint16_t *periods_blob);
int
schedule_save(schedule_t *schedule);
schedule_t*
schedule_get_by_uid(uuid_t uid);
schedule_t**
schedule_get_relay_weekdays(int relay_id);
uint16_t*
schedule_periods_to_blob(schedule_t *schedule);
void
schedule_free(schedule_t *schedule);
void
schedule_free_list(schedule_t **schedules_list);
void
schedule_debug(schedule_t *schedule);
int
schedule_uid_parse(const char *uid_str, uuid_t result);
void
schedule_uid_unparse(const uuid_t uid, char *result);
#endif /* CONTROLLER_SCHEDULE_H */