/*
// Copyright (c) 2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/
#pragma once

#include <nlohmann/json.hpp>
#include <sdbusplus/bus.hpp>
#include <string>
#include <vector>

// this struct has the gpio config for single gpio
struct gpioInfo
{
    int fd; // io fd mapped with the gpio
    uint32_t number;
    std::string direction;
};

// this struct represents button interface
struct buttonConfig
{
    std::string formFactorName;   // name of the button interface
    std::vector<gpioInfo> gpios;  // holds single or group gpio config
    nlohmann::json extraJsonInfo; // corresponding to button interface
};

/**
 * @brief iterates over the list of gpios and configures gpios them
 * config which is set from gpio defs json file.
 * The fd of the configured gpio is stored in buttonConfig.gpios container
 * @return int returns 0 on successful config of all gpios
 */

int configGroupGpio(buttonConfig& buttonCfg);

/**
 * @brief  configures and initializes the single gpio
 * @return int returns 0 on successful config of all gpios
 */

int configGpio(gpioInfo& gpioConfig);

uint32_t getGpioNum(const std::string& gpioPin);
void closeGpio(int fd);
// global json object which holds gpio_defs.json configs
extern nlohmann::json gpioDefs;
