/*
 * This file is part of the split-flap project.
 * Copyright (c) 2024-2025 GuniaLabs (www.dennisgunia.de)
 * Authors: Dennis Gunia
 *
 * This program is licenced under AGPL-3.0 license.
 *
 */

#include "serial/sfbus.h"
#include <ctype.h>
#include <errno.h> // Error integer and strerror() function
#include <fcntl.h> // Contains file controls like O_RDWR
#include <json-c/json.h>
#include <json-c/json_object.h>
#include <json-c/json_tokener.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <termios.h> // Contains POSIX terminal control definitions
#include <unistd.h>  // write(), read(), close()

#ifndef SFDEFICEMGR_H
#define SFDEFICEMGR_H
typedef enum SFDISPLAYMODE
{
    DISPLAY_DIRECT,
    DISPLAY_FULLROTATION
} sfdisplaymode;
#endif

int devicemgr_readStatus(int device_id);
int devicemgr_readCalib(int device_id);
void devicemgr_printDetails(int device_id, json_object *root);
void devicemgr_printDetailsAll(json_object *root);
int devicemgr_register(int rs485_descriptor, u_int16_t address, int x, int y, int nid);
void devicemgr_init();
int devicemgr_print(char *text);
int devicemgr_refresh();
int devicemgr_save(char *file);
void devicemgr_printText(const char *text, int x, int y, sfdisplaymode displayMode);
void devicemgr_printFlap(int flap, int x, int y, sfdisplaymode displayMode);
int devicemgr_load(char *file);
int devicemgr_load_single(json_object *device_obj);
int devicemgr_remove(int id);
void devicemgr_clearscreen();