/**
 * @file swtimer.cpp
 * @brief Software Timer component implementation
 * @author Mahmoud Elmohtady
 * @company Nabd solutions - ASF
 * @copyright Copyright (c) 2025
 */

#include "swtimer.hpp"

SoftwareTimer::SoftwareTimer()
    : m_isActive(false)
    , m_interval(0)
    , m_type(TimerType::ONE_SHOT)
{
}

SoftwareTimer::~SoftwareTimer()
{
    stop();
}

bool SoftwareTimer::create(uint32_t interval_ms, TimerType type, TimerCallback callback)
{
    if (interval_ms == 0)
    {
        return false;
    }

    m_interval = interval_ms;
    m_type = type;
    m_callback = callback;

    return true;
}

bool SoftwareTimer::start()
{
    if (m_callback == nullptr)
    {
        return false;
    }

    m_isActive = true;
    // TODO: Implement actual timer start logic
    return true;
}

bool SoftwareTimer::stop()
{
    if (!m_isActive)
    {
        return false;
    }

    m_isActive = false;
    // TODO: Implement actual timer stop logic
    return true;
}

bool SoftwareTimer::reset()
{
    if (!m_isActive)
    {
        return false;
    }

    stop();
    return start();
}

bool SoftwareTimer::isActive() const
{
    return m_isActive;
}

uint32_t SoftwareTimer::getInterval() const
{
    return m_interval;
}

