43 lines
723 B
C
43 lines
723 B
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>
|
||
|
|
||
|
typedef struct controller
|
||
|
{
|
||
|
uuid_t uuid;
|
||
|
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_read(MDB_env *mdb_env);
|
||
|
|
||
|
int
|
||
|
controller_save(controller *cntrlr, MDB_env *mdb_env);
|
||
|
|
||
|
void
|
||
|
controller_debug(controller *cntrlr);
|
||
|
|
||
|
#endif //CONTROLLER_CONTROLLER_H
|