/**
 *  @file ins_ut_led.c
 *  @details config unit test
 *
 */

#include <stdlib.h>
#include "unittest.h"
#include "unittest/device/ins_ut_led.h"
#include "ins_mw_config.h"
#include "ins_pal_error_code.h"
#include "ins_comm_log.h"

#include "ins_dev_led.h"

static int32_t InsUT_Device_LedOn(int32_t argc, char **argv)
{
    int32_t led_index = 0;
    InsDev_Led_t *Led_dev = InsDev_Led_Init(0);

    if(argc < 1)
    {
        INSLOG_W("Input para not enough! \n  on 0->red\n on 1->green\n on 2->blue\n");
        return INSERR_NG;
    }

    led_index = atoi(argv[0]);
    //Led_dev->all_off();

    return (int32_t)Led_dev->on(led_index);
}

static int32_t InsUT_Device_LedOff(int32_t argc, char **argv)
{
    int32_t led_index = 0;
    InsDev_Led_t * Led_dev = InsDev_Led_Init(0);

    if(argc < 1)
    {
        INSLOG_W("Input para not enough! \n  on 0->red\n on 1->green\n on 2->blue\n");
        return INSERR_NG;
    }
    led_index = atoi(argv[0]);

    return (int32_t)Led_dev->off(led_index);
}

static int32_t InsUT_Device_LedBlink(int32_t argc, char **argv)
{
    int32_t led_index = 0;
    InsDev_Led_t * Led_dev = InsDev_Led_Init(0);
    uint32_t timer;
    uint32_t cnt;

    if(argc > 0)
	{
		INSLOG_E("argc = %d\n", argc);
	    for(int i = 0; i < argc; i++)
	    {
	        INSLOG_E("argv[%d] = %s\n", i, argv[i]);
	    }
	}
    
    if(argc < 3)
    {
        INSLOG_W("Input para not enough! \n  led_index, timer, cnt\n");
        return INSERR_NG;
    }
    led_index = atoi(argv[0]);
    timer = atoi(argv[1]);
    cnt = atoi(argv[2]);
    
    return (int32_t)Led_dev->blink(led_index, (InsPal_Timer_ID_t)timer, cnt);
}
InsUT_Unittest_CmdInfo_t g_ut_cmd_led[INSUT_CMDCNT_LED] = 
{
    {InsUT_Device_LedOn,        0,  NULL, "on",         "led on"},
    {InsUT_Device_LedOff,       0,  NULL, "off",        "led off"},
    {InsUT_Device_LedBlink,     0,  NULL, "blink",      "led Blink"},
};

