#include "hal_interface_ircut.h"
#include "hlog.h"

#define TAG "TAG_HAL_IRCUT"


static IRCUT_MODE ircut_mode = IRCUT_UNKNOWN;

extern void hal_ircut_switch(IRCUT_MODE mode);

static void *hal_ircut_mode_set(void *param){
	kpacket *packet = (kpacket*)param;
	IRCUT_MODE new_mode = *((IRCUT_MODE*)packet->box->payload);
	hlogd("%s set_mode:%d", __func__, new_mode);
	if (ircut_mode != new_mode){
		ircut_mode = new_mode;
		hal_ircut_switch(new_mode);
	}else{
		hlogd("%s same as old no need to set new mode:%d", __func__, new_mode);
	}
	return 0;
}

uint32_t hal_ircut_init(){
	hlogi("%s ok", __func__);
	hal_sub(EVENT_HAL_DAYNIGHT, hal_ircut_mode_set, NULL);
	return 0;
}


uint32_t hal_ircut_deinit(){
	hal_unsub(EVENT_HAL_DAYNIGHT, hal_ircut_mode_set);
	return 0;
}

IRCUT_MODE hal_ircut_mode_get(){
	return ircut_mode;
}

DECLARE_INIT(PRI_AFTER_DRIVER, hal_ircut_init);

