/*
a,基站功能结构体指针的实现，
b,各个功能函数的初始化
c,
*/
#include 	"platform_interface.h"
#include 	"function_interface.h"
#include 	"function.h"
#include 	"base_core_user.h"


/*
除了0x60,0x61之外的类型!
复制pc转发给键盘的数据,用于用户开发，此数据不可以修改;
*/
void user__pc_transfer2keypad(const unsigned char *pc_kp)
{



}

/*
*/
void user__keypad_transfer2pc(const unsigned char *kp_pc)
{
	
}


/*
* sdk设置0x60默认之外的类型，供功能开发用户使用
*/
void user__pc_0x60cmd(const unsigned char *pc_kp)
{

}

/*
*
*/
void user__pc_0x61cmd(const unsigned char *pc_kp)
{


}


/*
*
*/
void user__pc_0x61cmd_type0x0B(const unsigned char *pc_kp)
{

}



#include "string.h"
/*
*功能： 用于回复sdk的统一接口，（core之外）
* input :
cmd =0x60,0x61
type =对应协议中的byte3?
ack_buf =协议中的byte4,基站需要根据不同的情况回复不同的数据；
len = ack_buf数据的长度
*/
void user__pc_cmd_ack(unsigned char cmd,unsigned char type, const unsigned char *ack_buf,unsigned char type_data_len)
{
		unsigned char tmp[32]; //whitelist 需要的buf长些

		memset(tmp,0,sizeof(tmp)/sizeof(tmp[0]));
		tmp[0]= 31;
		tmp[1]= (cmd&0x0f) | 0xE0;//0xE1;
		tmp[2]= base_core.get_id();
		tmp[3]= type;
		memcpy( tmp+4,ack_buf,type_data_len);//mem_cpy( ack_buf,tmp+4,type_data_len);	
		//send to pc 
		base_core.send_data_to_pc(tmp);//user__base_tx_to_pc_sub(tmp);
}



/*-------------------------------------------------------------------
定义功能开关及相关功能函数，并初始化，之后不允许修改!!!
*/
//定义功能相关的结构体
struct function_STR function={
		/*-------------------------------------------------------
			!!!!!!!!!!!! 警戒线  此后的数据禁止任何修改 !!!!!!!!
		--------------------------------------------------------*/	
		//whitelist 
		.whitelist__SW =WHITELIST,
		.whitelist__init =whitelist_init,
		.whitelist__enter=  whitelist_enter,
		.whitelist__search_special_list =search_special_list,
		.whitelist__base_confirm_keypad_request =base_confirm_keypad_whitelist_request,
		.whitelist__keypad_idsn_record_request =keypad_idsn_record_whitelist_request,
	
		//fastmatch
		.fastmatch__SW =FAST_MATCH,
		.fastmatch__enter_exit =fastmatch_enter_exit,	
		.fastmatch__load_info_to_vote_beacon =fastmatch_load_info_to_vote_beacon,
		.fastmatch__success_check =fastmatch_success_check,
		.fastmatch__lowPA_setup =fastmatch_lowerPA_setup,
	  .fastmatch__lowPA_ack=fastmatch_lowerPA_ack,
		.fastmatch__get_status = fastmatch_status,
	
		//base test 
		.basetest__SW=BASE_TEST,	//功能开关
		.basetest__progress=basetest_progress,
		.basetest__init=basetest_init,
		.basetest__get_status=basetest_get_status,
		.basetest__rx_and_ack_pc=basetest_rx_and_ack_pc,			
	
		//update keypad firmeware
		.updatekp__SW =UPDATE_KP,
		.update__kp_enter=update_kp_enter,
		.update__kp_progress=update_kp_progress,	
		.update__save_keypad_ack_data=save_keypad_ack_data,
		.update__get_status =update_get_status,
		.update__monitor_sdk_connect =update_monitor_sdk_connect,
		
		//montior other base at same freq 
		.monitor__SW=MON_FREQ,	//功能开关
		.monitor__auto_search_freq_enter=auto_search_freq_enter,
		.monitor__rf_data=monitor_rf_data,
		.monitor__freq_process=monitor_freq_process,

		//hard info
		.hdinfo_HMODEL=HMODEL,
		.hdinfo_SW1=SW1,		
		.hdinfo_SW2=SW2,
		.hdinfo_SW3=SW3,

		.rf_speed_set=RF_SPEED,
		.rf_channel_max=FREQ_MAX,//2.4G有80个频点，433M只有32个
		.rf_id ={RF_MODUAL0_SET,RF_MODUAL1_SET,RF_MODUAL2_SET,RF_MODUAL3_SET},//记录硬件模块编号
		//
		.crs2__SW=CRS2,
		.lock_channel=LOCK_CHAN,
		.mask_spec_channel =MASK_SPEC_CHAN,
		.lock_logmode=LOCK_LOGMODE,	
		.no_matchcode__SW=NO_MATCHCODE,
		.aux_att__SW=AUX_ATT,
		.aux_beat__SW=AUX_BEATS,
		.no_ID_mode__SW =NO_ID_MODE,
		.lock_rf_count =LOCK_RF_CNT,
//		.fix_rf_tx_beacon_cnt =FIX_RF_TX_BEACON_CNT,
//		.match_keypad_type = KEYPAD_TYPE,
		.base_type = BASE_TYPE,
		
		.crc16_keypad__SW =CRC16_CHECK_KEYPAD,
		.crc16_pc__SW =CRC16_CHECK_PC,

		#if (NFC==1) //#if defined(NFC)&&(NFC==1)
		.nfc__SW =NFC,
		.nfc__pc_interaction =base_record_keypad_NFC_info,
		.nfc__scan = NFC_monitor,
		#endif
		
		//AES function
		.AES__SW =AES,
		.aes__init= aes_init,
		.aes__load_fastmatch =aes_load_fastmatch_data,
		.aes__config_enter =process_pc_aes_config,
		.aes__keycode_upgrade =aes_keycode_upgrade,	
		.aes__rf_Encrypt =rf_Encrypt,
		.aes__rf_Decrypt =rf_Decrypt,
		.aes__get_key =get_aes_key,
		.aes__get_status =	get_aes_status,
		
		#if (TCPIP==1) 	//#if defined(TCPIP)&&(TCPIP==1)
		//tcp ip
		.TCPIP__SW =TCPIP,
		.tcpip__init =w5500_init,
		.tcpip__config_enter =_0x61_tcpip_sub,		
		.tcpip__process = do_tcp_server,
		#endif
		
		//broadcast
		.BROADCAST__SW =BROADCAST,
		.broadcast__config_enter =broadcast_config,
		.broadcast__startup =startup_broadcast,
		.broadcast__keypad_request =process_keypad_broadcast_requst,
		.broadcast__det_content_err = det_blank_content,
		
		//user interface //后续根据需要增加；
		.user_keypad_transfer2pc =user__keypad_transfer2pc,
		.user_pc_0x60cmd = user__pc_0x60cmd,
		.user_pc_0x61cmd = user__pc_0x61cmd,
		.user_pc_0x61cmd_type0x0B =user__pc_0x61cmd_type0x0B,
		.user_pc_transfer2keypad =user__pc_transfer2keypad,
		
		
		._debug__function_enter =_debug_function_enter,
	/*-------------------------------------------------------
		!!!!!!!!!!!! 警戒线  此前的数据禁止任何修改 !!!!!!!!
		如需添加请在此之后!!!!!!!!!!!!!!!!!
	--------------------------------------------------------*/
        //message broadcast
        #if TEXT_MESSAGE 
        .msg__polling = msg_polling,
        #endif
        
        //network
        .network__polling = network_polling,
        .network__get_netseq = network_get_netseq,
        .network__set_netseq_change = network_set_netseq_change,
        .network__get_pwd = network_get_pwd,
        .network__set_pwd = network_set_pwd,
        .network__get_name = network_get_name,
        .network__set_name = network_set_name,
        .network__get_nameview = network_get_nameview,
        .network__set_nameview = network_set_nameview,
        
//        //list_name
//        .list_mgnt__init = list__init_all,
//        .list_mgnt__read_from_e2prom = list__fetch_e2prom,
//        .list_mgnt__pc_rx = user_ops_list,

};




/*
初始化基站功能模块，所有的！！！ 
*/
void function_init_all(void)
{	
	//
	function.whitelist__init();
		
}







