2019-11-15 00:23:43 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <uuid/uuid.h>
|
|
|
|
|
2019-12-08 22:39:10 +00:00
|
|
|
#include <models/controller.h>
|
2019-11-15 00:23:43 +00:00
|
|
|
#include <macros.h>
|
|
|
|
|
|
|
|
controller*
|
|
|
|
controller_create(void)
|
|
|
|
{
|
|
|
|
controller *result = malloc(sizeof(*result));
|
|
|
|
uuid_generate(result->uuid);
|
|
|
|
|
|
|
|
strcpy(result->name, "new emgauwa device");
|
|
|
|
result->port = 0;
|
|
|
|
result->relay_count = 10;
|
|
|
|
|
|
|
|
result->relays = malloc(sizeof(*result->relays) * result->relay_count);
|
|
|
|
uint8_t i;
|
|
|
|
for(i = 0; i < result->relay_count; i++)
|
|
|
|
{
|
|
|
|
result->relays[i] = relay_init(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-01-07 01:23:16 +00:00
|
|
|
void
|
|
|
|
controller_debug(controller *cntrlr)
|
|
|
|
{
|
|
|
|
char uuid_str[37];
|
|
|
|
uuid_unparse(cntrlr->uuid, uuid_str);
|
|
|
|
printf("%s @ %p\n", uuid_str, cntrlr);
|
|
|
|
printf("name: %s\n", cntrlr->name);
|
2020-02-08 12:50:54 +00:00
|
|
|
printf("port: %5d relays: %3d\n", cntrlr->port, cntrlr->relay_count);
|
2020-01-07 01:23:16 +00:00
|
|
|
}
|