/*
 * sys_api.h
 *
 *  Created on: 12.03.2017
 *      Author: jesstr
 */

#ifndef SYS_API_H_
#define SYS_API_H_

#include <stdbool.h>
#include <stdint.h>

#ifndef DEVICE_MAC
#define DEVICE_MAC "EC-4C-4D-00-C7-FF"
#endif

#ifndef DEVICE_SERIAL
#define DEVICE_SERIAL "7020000"
#endif


#define SYS_MAC 		DEVICE_MAC
#define SYS_SERIAL 		DEVICE_SERIAL
#define SYS_CUSTOMER 	"Rotek"


#define MAC_LEN		18
#define SER_LEN		16
#define CUST_LEN	16
#define PROD_LEN	20

/**
  * @brief  Cтруктура системных настроек
  */
typedef struct
{
  char  mac[MAC_LEN];    	// MAC адрес
  char  serial[SER_LEN];	// Серийный номер
  char  customer[CUST_LEN];	// Заказчик
  char 	proddate[PROD_LEN];	// Дата производства
  char 	testState[16];
  uint32_t controlword;
  uint32_t crc;
} SYS_t;


bool SYS_BackupInfo(char *mac, char *serial);

bool SYS_RestoreInfo(SYS_t *settings);

/**
  * @brief
  * @retval
  */
uint32_t SYS_GetCRC(SYS_t *settings);

/**
  * @brief  Загрузка структуры системных настроек из flash
  */
bool SYS_Load(SYS_t *settings);

/**
  * @brief  Запись структуры настроек во flash
  */
bool SYS_Save(SYS_t *settings);


#endif /* SYS_API_H_ */