77 lines
2.5 KiB
C
77 lines
2.5 KiB
C
/*!
|
|
* devices_manager.h
|
|
*
|
|
* Copyright (c) 2015-2020, NADAL Jean-Baptiste. All rights reserved.
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
* MA 02110-1301 USA
|
|
*
|
|
* @Author: NADAL Jean-Baptiste
|
|
* @Date: 24/12/2019
|
|
*
|
|
*/
|
|
|
|
#ifndef _DEVICES_MANAGER_H
|
|
#define _DEVICES_MANAGER_H
|
|
|
|
/*------------------------------- INCLUDES ----------------------------------*/
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
#include <qlibc/qlibc.h>
|
|
|
|
/*--------------------------------- DEPS ------------------------------------*/
|
|
|
|
struct json_object;
|
|
|
|
/*------------------------------- TYPEDEFS ----------------------------------*/
|
|
|
|
typedef struct devices_manager_s devices_manager_t;
|
|
|
|
/**
|
|
* Device Manager Container.
|
|
*/
|
|
struct devices_manager_s
|
|
{
|
|
char *file_path;
|
|
|
|
qlist_t *outlets;
|
|
uint16_t outlets_max_id;
|
|
qlist_t *shutters;
|
|
uint16_t shutters_max_id;
|
|
qlist_t *sprinklers;
|
|
uint16_t sprinklers_max_id;
|
|
};
|
|
|
|
/*--------------------------- PUBLIC FUNCTIONS -------------------------------*/
|
|
|
|
extern devices_manager_t *devices_manager_new(void);
|
|
extern void devices_manager_free(devices_manager_t *devices_manager);
|
|
|
|
extern int devices_manager_load(devices_manager_t *dm, char *config_path);
|
|
extern int devices_manager_save(devices_manager_t *dm);
|
|
|
|
extern char *devices_manager_get(devices_manager_t *dm, const char *capability);
|
|
extern char *devices_manager_get_by_id(devices_manager_t *dm, const char *capability, uint32_t id);
|
|
|
|
extern struct json_object *devices_manager_to_json_object(devices_manager_t *dm, const char *capability);
|
|
|
|
extern int devices_manager_create(devices_manager_t *dm, const char *capability, struct json_object *node);
|
|
extern int devices_manager_update(devices_manager_t *dm, const char *capability, struct json_object *node);
|
|
extern int devices_manager_delete(devices_manager_t *dm, const char *capability, struct json_object *node);
|
|
|
|
#endif /*_DEVICES_MANAGER_H */
|