controller-legacy/include/models/controller.h

62 lines
1.1 KiB
C
Raw Normal View History

2020-01-07 01:23:16 +00:00
#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>
2020-02-08 14:09:34 +00:00
/**
* @brief Information about this controller
*/
2020-01-07 01:23:16 +00:00
typedef struct controller
{
2020-02-08 14:09:34 +00:00
/**
* @brief A unique UUID for this controller
*/
2020-01-07 01:23:16 +00:00
uuid_t uuid;
2020-02-08 14:09:34 +00:00
/**
* @brief The name of this controller
*
* Includes a \0 terminator.
*/
2020-01-07 01:23:16 +00:00
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*
2020-02-08 14:09:34 +00:00
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)
*/
2020-01-07 01:23:16 +00:00
int
controller_save(controller *cntrlr, MDB_env *mdb_env);
void
controller_debug(controller *cntrlr);
#endif //CONTROLLER_CONTROLLER_H