/*
 * MBIC_Bootloader.h
 *
 *  Created on: 2020. 5. 18.
 *      Author: parkyj
 */

#ifndef MBIC_BOOTLOADER_H_
#define MBIC_BOOTLOADER_H_



#define MBIC_HEADER_SIZE 22
#define MBIC_TAIL_SIZE 3

#define MBIC_PREAMBLE0 0x16
#define MBIC_PREAMBLE1 0x16
#define MBIC_PREAMBLE2 0x16
#define MBIC_PREAMBLE3 0x16
#define MBIC_SUBUID0 0x00
#define MBIC_SUBUID1 0xF1
#define MBIC_RCODE
#define MBIC_TRID
#define MBIC_SEQNUM
#define MBIC_TTL
#define MBIC_TIME
#define MBIC_ERRRESPONSE 0x00
#define MBIC_CMD
#define MBIC_LENGTH
#define MBIC_CHECKSHUM_INDEX MBIC_HEADER_SIZE - 1 //CheckSUM REMOVE INDEX
#define MBIC_ETX 0x03
#define MBIC_NODE_MU 0x80
#define MARK_START_POSITION						0
#define TYPE_START_POSITION						9	
#define FILE_TYPE_START_POSITION				10
#define VERSION_START_POSITION					11
#define FILENAME_START_POSITION					14
#define CREATION_TIME_START_POSITION			55
#define LENGTH_START_POSITION					61
#define CRC_START_POSITION						65
#define RESERVED_START_POSITION					69

typedef enum{
	MBIC_PREAMBLE_0 = 0,
	MBIC_PREAMBLE_1,
	MBIC_PREAMBLE_2,
	MBIC_PREAMBLE_3,
	MBIC_SUBUID_0,
	MBIC_SUBUID_1,
	MBIC_RCODE_0,
	MBIC_TRID_0,
	MBIC_TRID_1,
	MBIC_SEQSUM_0, // 9Index
	
	MBIC_TTL_0, //10 INDEX
	MBIC_TIME_0,
	MBIC_TIME_1,
	MBIC_TIME_2,
	MBIC_TIME_3,
	MBIC_TIME_4,
	MBIC_TIME_5,
	MBIC_ERRRESPONSE_0,
	MBIC_CMD_0,
	
	MBIC_LENGTH_0, // 19INDEX
	MBIC_LENGTH_1, // 20

	MBIC_HEADERCHECKSUM_0,
	MBIC_PAYLOADSTART,
    /*
	 * PayLoadSTART
	 */
}MBICProt_st;
typedef enum{
  MBIC_Notice_REQ = 0x10,
  MBIC_Download_DATA_REQ,
  MBIC_Download_Confirm_REQ,
  MBIC_Complete_Notice_REQ_REQ,
  MBIC_Reboot_Notice_REQ,
}MBIC_Download_Req_L;
typedef enum{
  MBIC_Notice_RSP = 0x90,
  MBIC_Download_DATA_RSP,
  MBIC_Download_Confirm_RSP,
  MBIC_Complete_Notice_RSP,
  MBIC_Reboot_Notice_RSP,
}MBIC_Download_Rsp_L;





typedef struct{
    uint16_t Length;
    uint16_t Crcchk;
    bool FileChk;
}BootLoaderDataCheck_st;

#endif /* MBIC_BOOTLOADER_H_ */
