/*
 * hal.c
 *
 *  Created on: 14.06.2017
 *      Author: balbekova
 */

#include "stm32f4xx.h"
#ifndef BT6702_SERVICE
#include "log.h"
#include "snmp_api.h"
#include "trap_api.h"
#include "syslog.h"
#endif
#include "hal.h"
#include <stddef.h>
#include "FreeRTOS.h"
#include "task.h"

static source_act_t source_act = OTHER_ACT;

void Reboot(source_act_t source_reset)
{
#ifndef BT6702_SERVICE
    SNMP_SendUserTrap(DEVICE_REBOOTED);
    syslog_str(SYSLOG_INFORMATIONAL, "Устройство перезагружено");
    switch (source_reset) {
        case WEB_ACT:
            log_event_data(LOG_SYSTEM_BOOT, name_login);
            break;
        case SNMP_ACT:
        case OTHER_ACT:
#ifdef CLI_ENABLE
        case CLI_ACT:
#endif
            log_event_data(LOG_SYSTEM_BOOT, "Администратор");
            break;
        default:
            break;
    }
    vTaskDelay(1010);
    LOG_Disable();
#endif
    NVIC_SystemReset();
}

void set_act_source(source_act_t source)
{
    source_act = source;
}

source_act_t get_act_source(void)
{
    return source_act;
}

