#ifndef _IKONKE_TOKEN_H_
#define _IKONKE_TOKEN_H_
#include "ikk-debug.h"
#include "tl_common.h"


#define   	TOKEN_USER_LOCATION				0x78000

#define	  	USER_SIZE						256


#define   	INSTALL_CODE_LOC_OFFSET			0					//16Byte   //0
#define   	MODEL_ID_LOC_OFFSET				64					//33Byte   //16+33
#define   	CMEI_LOC_OFFSET					64+64				//33Byte   //16+33+33
#define   	ISN_LOC_OFFSET					64+64+64			//33Byte   //16+33+33+33


enum{
	CUSTOM_ITEMS_INSTALL_CODE 	 = 1,
	CUSTOM_ITEMS_MODEL_ID 			,
	CUSTOM_ITEMS_CMEI_CODE 			,
	CUSTOM_ITEMS_ISN_CODE 			,
	CUSTOM_ITEMS_RESERVED 			,
}CUSTOM_ITEMS;

#define		INSTALL_CODE_INDEX				0
#define		MODEL_ID_INDEX					1
#define		INSTALL_CODE_INDEX				0
#define		INSTALL_CODE_INDEX				0
#define		INSTALL_CODE_INDEX				0

typedef struct
{
	struct{
		uint8_t install_code_data[16];
		uint8_t res[48];
	}install_code;
	struct{
		uint8_t modeid_len;
		uint8_t modeid_data[32];
		uint8_t res[31];
	}modeid;
	struct{
		uint8_t cmei_len;
		uint8_t cmei_data[32];
		uint8_t res[31];
	}cmei;
	struct{
		uint8_t isn_len;
		uint8_t isn_data[32];
		uint8_t res[31];
	}isn;
	uint8_t reserved[32];
}OPTTUNEL_TOKEN_ST;
extern OPTTUNEL_TOKEN_ST sOptunnel_Token;
void Flash_Test_Save(uint8_t value);
uint8_t Flash_Test_Get(void);
uint8_t General_Custom_Token_Save(uint8_t item,uint8_t *buff,uint8_t len);
uint8_t *General_Custom_Token_Get(uint8_t item);

#define INSTALL_CODE_TOKEN_GET()    			(General_Custom_Token_Get(CUSTOM_ITEMS_INSTALL_CODE))
#define MODEL_ID_TOKEN_GET()    				(General_Custom_Token_Get(CUSTOM_ITEMS_MODEL_ID))
#define CMEI_TOKEN_GET()    					(General_Custom_Token_Get(CUSTOM_ITEMS_CMEI_CODE))
#define ISN_TOKEN_GET()    						(General_Custom_Token_Get(CUSTOM_ITEMS_ISN_CODE))

#define INSTALL_CODE_TOKEN_SET(buffer,len)    	(General_Custom_Token_Save(CUSTOM_ITEMS_INSTALL_CODE,buffer,len))
#define MODEL_ID_TOKEN_SET(buffer,len)    		(General_Custom_Token_Save(CUSTOM_ITEMS_MODEL_ID,buffer,len))
#define CMEI_TOKEN_SET(buffer,len)    			(General_Custom_Token_Save(CUSTOM_ITEMS_CMEI_CODE,buffer,len))
#define ISN_TOKEN_SET(buffer,len)    			(General_Custom_Token_Save(CUSTOM_ITEMS_ISN_CODE,buffer,len))


nv_sts_t Gateway_IEEE_Addr_Save(addrExt_t addr);

uint8_t* Gateway_IEEE_Addr_Get(void);

uint16_t MFG_Code_Get(void);

nv_sts_t MFG_Code_Save(uint16_t mfgcode);

bool kGetIndicatorNotDisturbModeFlg(void);
nv_sts_t kSetIndicatorNotDisturbModeFlg(uint8_t value);

nv_sts_t kSetInterpanEnableFlg(uint8_t value);
bool kGetInterpanEnableFlg(void);
#if 1
void falsh_test(uint8_t count);
#endif
#endif /* _SAMPLE_LIGHT_H_ */
