//************************
#include <stdio.h>
//**********************************
#include "bms_module_event.h"
#include "common_module_event.h"
//*************************************
static char *get_evt_type_str(enum bms_module_event_type type)
{
	switch (type) {
        case BMS_PIN_SUCCESS:return "BMS_PIN_HARDWARE_CONFIGURATION_OK";
        case BMS_PIN_FAIL: return "BS_PIN_HARDWARE_CONFIGURATION_FAIL";
        case BMS_DETACHED: return "BMS_REMOVED";
	case BMS_ATTACHED:
		return "BMS_ATTACHED";
	case BMS_DATA_ERROR:
		return "BMS_EVT_ERROR";
        case BMS_DATA_READY: 
                return "BMS_DATA_READY";
	default:
		return "Unknown BMS event";
	}
}

static void log_event(const struct app_event_header *eh)
{
	const struct bms_module_event *event = cast_bms_module_event(eh);
	char event_name[50] = "\0";

	strcpy(event_name, get_evt_type_str(event->type));

	if (event->type == BMS_DATA_ERROR) {
	} else if (event->type == BMS_DATA_READY) {
		
	}
        else if (event->type == BMS_ATTACHED) {

        }
}


#if defined(CONFIG_PROFILER)

static void profile_event(struct log_event_buf *buf,
			 const struct app_event_header *aeh)
{
	const struct bms_module_event *event = cast_bms_module_event(aeh);

#if defined(CONFIG_PROFILER_EVENT_TYPE_STRING)
	profiler_log_encode_string(buf, get_evt_type_str(event->type));
#else
	profiler_log_encode_uint8(buf, event->type);
#endif
}

COMMON_APP_EVENT_INFO_DEFINE(bms_module_event,
			 profile_event);

#endif /* CONFIG_PROFILER */

COMMON_APP_EVENT_TYPE_DEFINE(bms_module_event,
			 log_event,
			 &bms_module_event_info,
			 APP_EVENT_FLAGS_CREATE(
				IF_ENABLED(CONFIG_BMS_EVENTS_LOG,
					(APP_EVENT_TYPE_FLAGS_INIT_LOG_ENABLE))));