Index: do.bat
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/bt_hfp_ble/do.bat	(revision 951)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/bt_hfp_ble/do.bat	(working copy)
@@ -75,4 +75,6 @@
 echo create bt_code.c file
 perl .\util\rom2h.pl  <.\output\eeprom.dat>  .\output\bt_code.c
 copy .\output\bt_code.c   ..\..\BT_HFP_BLE_DEMO\user
+copy .\output\bt_code.c 	E:\yichip_DATA\3121\mysvn_g6\Libraries\core
+
 
Index: format/app_module.format
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/bt_hfp_ble/format/app_module.format	(revision 951)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/bt_hfp_ble/format/app_module.format	(working copy)
@@ -7,6 +7,7 @@
 1 mem_module_prepare_write_request_opcode
 2 mem_module_prepare_write_request_handle
 600 mem_temp_prepare_write_request_Data
+0 mem_end
 )
 
 
Index: format/memblocks.format
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/bt_hfp_ble/format/memblocks.format	(revision 951)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/bt_hfp_ble/format/memblocks.format	(working copy)
@@ -31,6 +31,25 @@
 //end address: 0x1bff
 )
 
+//l2cap RX buffers
+(
+0x1000 mem_l2cap_rxbuff1_new		//0x200
+0x1200 mem_l2cap_rxbuff2_new		//0x200
+)
+
+//l2cap TX buffers
+(
+0x1400 mem_tx_buff0_new		//128
+0x1480 mem_tx_buff1_new		//128
+0x1500 mem_tx_buff2_new		//128
+0x1580 mem_tx_buff3_new		//128
+0x1600 mem_tx_buff4_new		//128
+0x1680 mem_tx_buff5_new		//128
+0x1700 mem_tx_buff6_new		//128
+0x1780 mem_tx_buff7_new		//128
+)
+
+
 (
 0x1800 mem_le_tx_buffer0
 0x1900 mem_le_tx_buffer1
Index: program/patch.prog
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/bt_hfp_ble/program/patch.prog	(revision 951)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/bt_hfp_ble/program/patch.prog	(working copy)
@@ -29,9 +29,15 @@
 	beq patch17_3,p_module_hci_cmd_control
 	beq patch17_4,p_module_hci_cmd_transmit_le_notify
 	beq patch1d_3,p_le_init_conn
+	
+	beq patch0b_5,p_process_dmh_data_l2cap_start_pkt
+	beq patch0b_6,p_process_dmh_data_l2cap_continue_pkt
+	beq patch0c_0,p_process_dmh_data_end
+	beq patch0e_1,p_parse_l2cap_cont
+	beq patch1b_3,p_l2cap_malloc
 	//context patch
 	beq patch00_5,p_connection_incontext
-	beq patch05_4,p_context_new
+//	beq patch05_4,p_context_new
 	beq patch05_6,p_context_search
 	beq patch0d_7,p_sniff_check_window
 	beq patch14_6,p_lpm_recover_clk
@@ -277,7 +283,6 @@
 
 
 p_module_init:
-
 	setarg p_module_process_bb_event
 	store 2,mem_cb_bb_event_process
 
@@ -645,7 +650,7 @@
 
 
 p_moudle_hci_cmd_create_bt_reconnect:
-	fetch 1,mem_context
+	fetch 1,mem_state
 	bbit1 state_inconn,module_hci_event_receive_invalid_cmd
 	bbit1 state_inpage,module_hci_event_receive_invalid_cmd
 	fetch 2,mem_ui_state_map
@@ -668,10 +673,10 @@
 	branch module_hci_event_receive_valid_cmd
 
 p_moudle_hci_cmd_cancel_bt_reconnect:
-	fetch 1,mem_context
-	bbit1 state_inconn,module_hci_event_receive_invalid_cmd
-	fetch 2,mem_ui_state_map
-	bbit1 UI_STATE_BT_CONNECTED,module_hci_event_receive_invalid_cmd
+//	fetch 1,mem_context
+//	bbit1 state_inconn,module_hci_event_receive_invalid_cmd
+//	fetch 2,mem_ui_state_map
+//	bbit1 UI_STATE_BT_CONNECTED,module_hci_event_receive_invalid_cmd
 	jam 0,mem_bt_reconnect_timer
 	call app_bt_reconnect_cancel
 	branch module_hci_event_receive_valid_cmd
@@ -719,6 +724,78 @@
 	call module_clear_le_tx_data_flag
 	branch module_hci_event_receive_invalid_cmd
 
+p_process_dmh_data_l2cap_start_pkt:
+//	bpatch patch0b_5,mem_patch0b
+	bmark1 mark_old_packet,ack_payload
+	fetch 2,mem_len
+	arg 0x1f0,temp //l2cap buffer size
+	isub temp,null
+	branch error_payload,positive
+	fetch 1,mem_l2cap_rxbuff_inuse
+	bbit0 L2CAP_INUSE_BUFF1,process_dmh_data_into_buff1
+	bbit0 L2CAP_INUSE_BUFF2,p_process_dmh_data_into_buff2
+	branch end_of_packet
+	
+p_process_dmh_data_into_buff2:
+	jam 2,mem_l2cap_rxbuff_new //new data in buff 2
+	fetch 2,mem_l2cap_rxbuff2_len
+	bne 0,end_of_packet
+	arg mem_l2cap_rxbuff2_new,contw
+	branch process_dmh_data
+
+p_process_dmh_data_l2cap_continue_pkt:
+//	bpatch patch0b_6,mem_patch0b
+	bmark1 mark_old_packet,ack_payload
+	fetch 2,mem_len
+	arg 0x1f0,temp //l2cap buffer size
+	isub temp,null
+	branch error_payload,positive
+	fetch 1,mem_l2cap_rxbuff_new
+	beq 1,process_dmh_data_l2cap_continue_pkt1
+	beq 2,p_process_dmh_data_l2cap_continue_pkt2
+	branch end_of_packet
+
+p_process_dmh_data_l2cap_continue_pkt2:
+	arg mem_l2cap_rxbuff2_new,contw
+	branch process_dmh_data_l2cap_continue_pkt2+1
+
+p_process_dmh_data_end:	
+//	bpatch patch0c_0,mem_patch0c
+	fetch 1,mem_l2cap_rxbuff_new
+	beq 1,process_l2cap_pass_crc_buff1
+	beq 2,p_process_l2cap_pass_crc_buff2
+	branch assert
+	
+p_process_l2cap_pass_crc_buff2:
+	fetch 2,mem_l2cap_rxbuff2_len
+	fetcht 2,mem_len
+	iadd temp,pdata
+	store 2,mem_l2cap_rxbuff2_len
+	beq 0,assert
+	fetcht 2,mem_l2cap_rxbuff2_new // l2cap payload length 
+	branch process_l2cap_pass_crc_buff2+6
+
+p_parse_l2cap_cont:
+//	bpatch patch0e_1,mem_patch0e
+	fetch 1,mem_l2cap_rx_done
+	beq L2CAP_RX_DONE,parse_l2cap_release_buff1
+	
+	jam L2CAP_RX_CLEAR,mem_l2cap_rx_done
+	fetch 1,mem_l2cap_rxbuff_inuse
+	rtnbit0 L2CAP_INUSE_BUFF2
+	arg mem_l2cap_rxbuff2_new,contr	
+	branch parse_l2cap_cont+13
+	
+p_l2cap_malloc:
+//	bpatch patch1b_3,mem_patch1b
+	arg 0,regb
+	call l2cap_malloc_is_fifo_full
+	nbranch assert,blank//assert when fifo full
+	call l2cap_malloc_get_full_map
+	arg mem_tx_buff0_new,regB//pbuff = buff0;
+	arg 0,queue // i = 0;
+	branch l2cap_malloc_loop
+
 p_le_init_conn:
 	fetch 1,mem_ble_dle_enable
 	nbranch le_init_conn+1,blank
@@ -1430,7 +1507,7 @@
 	loop p_context_get_next_loop
 	rtn
 
-
+/*
 p_context_new:
 	arg p_context_search_empty,regc
 	branch context_new+2
@@ -1439,7 +1516,7 @@
 	bbit1 state_inpage,context_search_next
 	force 0,null
 	rtn
-
+*/
 
 p_context_search:
 	arg mem_context_new,rega
@@ -2055,8 +2132,8 @@
 p_hfp_acceptcall:
 p_hfp_hangup:
 p_hfp_vgm_ok:
-	jam HF_CMD_IDLE,mem_hf_command
-	rtn
+//	jam HF_CMD_IDLE,mem_hf_command
+//	rtn
 p_hfp_vgs_ok:
 	jam HF_CMD_IDLE,mem_hf_command
 	rtn
@@ -2769,16 +2846,16 @@
 	byteswap rega,rega
 	copy rega,pdata
 	istore 2,contw
-	setarg 0x0335
-	istore 2,contw
-	setarg 0x19
-	istore 1,contw
+	setarg 0x190335
+	istore 3,contw
+//	setarg 0x19
+//	istore 1,contw
 	fetch 2,mem_search_uuid
 	istore 2,contw
 	setarg 0x0008
-	istore 2,contw
-	setarg 0
-	istore 1,contw
+	istore 3,contw
+//	setarg 0
+//	istore 1,contw
 	rtn
 
 //rega:l2cap len
@@ -2797,12 +2874,12 @@
 	istore 4,contw
 	setarg 0x2c01
 	istore 2,contw
-	setarg 0x0535
-	istore 2,contw
-	setarg 0x0a
-	istore 1,contw
-	setarg 0
-	istore 2,contw
+	setarg 0xa0535
+	istore 5,contw
+//	setarg 0x0a
+//	istore 1,contw
+//	setarg 0
+//	istore 2,contw
 	setarg -1
 	istore 2,contw
 	setarg 0
@@ -2858,12 +2935,12 @@
 	branch master_page_no_interval+1
 
 
-	fetcht 2,mem_page_window
+/*	fetcht 2,mem_page_window
 	force 40,queue
 	call sniff_check_window
 	branch page_exit,user
 	branch page_start
-
+*/
 
 /**********************************page patch**********************************************/
 
