controller-legacy/include/models/controller.h
2020-02-08 15:09:34 +01:00

61 lines
1.1 KiB
C

#ifndef CONTROLLER_CONTROLLER_H
#define CONTROLLER_CONTROLLER_H
#include <uuid/uuid.h>
#include <stdint.h>
#include <lmdb.h>
#include <config.h>
#include <models/relay.h>
/**
* @brief Information about this controller
*/
typedef struct controller
{
/**
* @brief A unique UUID for this controller
*/
uuid_t uuid;
/**
* @brief The name of this controller
*
* Includes a \0 terminator.
*/
char name[CONTROLLER_NAME_LENGTH + 1];
uint16_t port;
uint8_t relay_count;
relay **relays;
} controller;
typedef enum controller_db_key
{
KEY_META_UUID,
KEY_META_NAME,
KEY_META_PORT,
KEY_META_RELAY_COUNT,
KEY_META_RELAYS
} controller_db_key;
controller*
controller_create(void);
controller*
controller_load(MDB_env *mdb_env);
/**
* @brief Save a controller to the database
*
* @param cntrlr Instance of a controller
* @param mdb_env Already created MDB_env
*
* @return Indicator to show success (0) or failure (!0)
*/
int
controller_save(controller *cntrlr, MDB_env *mdb_env);
void
controller_debug(controller *cntrlr);
#endif //CONTROLLER_CONTROLLER_H