/*****************************************************************************

    source::worx libPiGPio
    Copyright © 2022 c.holzheuer
    chris@sourceworx.org

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    Uses:

    pigpiod_if2.h
    by joan2937, pigpio @ abyz.me.uk
    https://abyz.me.uk/rpi/pigpio

    sigslot.h
    by 2017 Pierre-Antoine Lacaze
    https://github.com/palacaze/sigslot

***************************************************************************/




/// ---

#ifdef _WIN32

#include <iostream>

#include <libpigwindows.h>

#include <ws2tcpip.h>
#include <winsock2.h>
#include <windows.h>

namespace pigpio
{


int pigWindows::init( const std::string& , const std::string&  )
{
    //::gpioInitialise();
    return 42;
}
//
// pin config
//

int pigWindows::set_io_mode( bcm_t, io_t )
{
    //::set_io_mode( _Pi, pin.bcm, pin.mode );
    return 0;
}

int pigWindows::get_io_mode( bcm_t )
{
    return 0;
}

int pigWindows::set_pud_mode( bcm_t, pud_t )
{
    //::set_pud_mode( _Pi, pin.bcm, pin.pud );
    return 0;
}


int pigWindows::set_glitch_filter( bcm_t, uint32_t )
{
    // ::set_glitch_filter( _Pi, pin.bcm,  glitch );
    return 0;
}


//Sets a noise filter on a GPIO.
int pigWindows::set_noise_filter( bcm_t, uint32_t, uint32_t )
{
    //int set_noise_filter(int pi, unsigned user_gpio, unsigned steady, unsigned active)
    return 0;
}


///
/// pin operations
///

int pigWindows::get_level( bcm_t )
{
    return 0;
}


int pigWindows::set_level( bcm_t, level_t )
{
    return 0;
}

int pigWindows::wait_for_edge( bcm_t, edge_t, double )
{
    return 0;
}


//This function sends a trigger pulse to a GPIO. The GPIO is set to level for pulseLen microseconds and then reset to not level.
int pigWindows::trigger_level( bcm_t, level_t, uint32_t )
{
    //int trigger_level(int pi, unsigned user_gpio, unsigned pulseLen, unsigned level)
    return 0;
}


///
/// interface
///

int pigWindows::set_callback( bcm_t,  pigCall*, edge_t )
{
    //::callback_ex( _Pi, pin.bcm, pin.edge,  &pigNode::trigger, (void*) &widget );
    //pin.cbId = ::callback_ex( _Pi, pin.bcm, pin.edge, trigger, widget );
    return 0;
}


int pigWindows::cancel_callback( int )
{
    return 0;
}


///
/// ic2
///


int pigWindows::i2c_open( pigI2C& )
{
    return 0;
}

int pigWindows::i2c_close( pigI2C& )
{
    return 0;
}

/*
int pigWindows::i2c_write_quick( pigI2C&, unsigned )
{
    return 0;
}

int pigWindows::i2c_write_byte( pigI2C&, unsigned )
{
    return 0;
}

int pigWindows::i2c_write_byte_data( pigI2C&, unsigned, unsigned )
{
    return 0;
}

int pigWindows::i2c_write_word_data( pigI2C&, unsigned, unsigned )
{
    return 0;
}

int pigWindows::i2c_write_block_data( pigI2C&, unsigned, char* buf, unsigned count  )
{
    return 0;
}

int pigWindows::i2c_write_i2c_block_data( pigI2C&, unsigned, char* buf, unsigned count )
{
    return 0;
}*/


int pigWindows::i2c_write_device( pigI2C&, char*, unsigned )
{
    return 0;
}

/*
int pigWindows::i2c_read_byte( pigI2C& )
{
    return 0;
}

int pigWindows::i2c_read_byte_data( pigI2C&, unsigned )
{
    return 0;
}

int pigWindows::i2c_read_word_data( pigI2C&, unsigned )
{
    return 0;
}



int pigWindows::i2c_read_block_data( pigI2C&, unsigned, char* )
{
    return 0;
}

int pigWindows::i2c_read_i2c_block_data( pigI2C&, unsigned, char*, unsigned )
{
    return 0;
}


int pigWindows::i2c_read_device( pigI2C&, char* buf, unsigned )
{
    return 0;
}

int pigWindows::i2c_process_call( pigI2C&, unsigned, unsigned )
{
    return 0;
}


int pigWindows::i2c_block_process_call( pigI2C&, unsigned, char*, unsigned )
{
    return 0;
}


int pigWindows::i2c_zip( pigI2C&, char*, unsigned, char*, unsigned )
{
    return 0;
}
*/


///
/// advanced
///

//Starts hardware PWM on a GPIO at the specified frequency and dutycycle. Frequencies above 30MHz are unlikely to work.
int pigWindows::hardware_PWM( bcm_t, uint32_t, uint32_t )
{
    //int hardware_PWM(int pi, unsigned gpio, unsigned PWMfreq, uint32_t PWMduty)
    return 0;
}


///
/// convenience
///


int pigWindows::show_error( int error )
{

    std::cout << "Error: " << std::endl;
    return error;
}

//Starts a hardware clock on a GPIO at the specified frequency. Frequencies above 30MHz are unlikely to work.
int pigWindows::hardware_clock( bcm_t, uint32_t )
{
    //int hardware_clock(int pi, unsigned gpio, unsigned clkfreq)
    return 0;
}

uint32_t pigWindows::get_current_tick()
{
    //int hardware_clock(int pi, unsigned gpio, unsigned clkfreq)
    return 0;
}


//Get the Pi's hardware revision number.
int pigWindows::get_hardware_revision()
{
    //uint32_t get_hardware_revision(int pi)
    return 0;
}


//Returns the pigpio version.
int pigWindows::get_pigpio_version()
{
    //uint32_t get_pigpio_version(int pi)
    return 0;
}


//Return the pigpiod_if2 version.
unsigned pigWindows::pigpiod_if_version()
{
    //unsigned pigpiod_if_version(void)
    return 0;
}

} // namespace


#endif
