Index: rongyuan/format/app_module.format
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/format/app_module.format	(revision 932)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/format/app_module.format	(working copy)
@@ -38,15 +38,15 @@
 
 	4 mem_last_transmite_clock
 	
-	604 mem_module_uuid_list
+	692 mem_module_uuid_list
 	0 mem_module_uuid_list_end
-	536 mem_module_le_att_list
+	700 mem_module_le_att_list
 	0 mem_module_le_att_list_end
 	0 mem_module_nv_data
-	34 mem_module_nv_data0
-	34 mem_module_nv_data1
-	34 mem_module_nv_data2
-	34 mem_module_nv_data3
+	0 mem_module_nv_data0
+	0 mem_module_nv_data1
+	0 mem_module_nv_data2
+	0 mem_module_nv_data3
 	34 mem_module_nv_data4
 	
 	15 mem_rf_init
@@ -61,8 +61,7 @@
 //24g profile
 8 mem_24g_enter_hibernate
 1 mem_24g_txfail_cnt
-1 mem_mouse_retry_flag
-1 mem_24g_led_flag
+
 
 
 32 mem_24g_txbuf_new
@@ -74,36 +73,27 @@
 1 mem_24g_rxdata_length
 1 mem_24g_pid
 1 mem_24g_datalen
-1 mem_24g_data_type
+
 1 mem_24g_txlen
 2 mem_24g_rx_window
 1 mem_24g_ensure
-1 mem_24g_get_ack_fail
+
 1 mem_24g_retry
 1 mem_24g_ch
-1 mem_24g_current_ch_number
+
 
 
 //ï¿½ï¿½ï¿½ï¿½ï¿½Äµï¿½Ö·
 4 mem_24g_addr
-2 mem_24g_check_dongle_times
-4 mem_24g_device_addr
+
 1 mem_24g_no_ack
-3 mem_24g_sta_crc
-1 mem_24g_sta_pid
+
 1 mem_24g_max_retry
-1 mem_24g_mode
-1 mem_24g_hop_pac_retry
-1 mem_24g_idle_timeout
-1 mem_24g_idle_cnt
-1 mem_24g_auto_paring_switch
-1 mem_24g_enter_lpm_timer
+
 2 mem_24g_syncword
 1 mem_24g_syncword_crc8
 1 mem_24g_get_syncword_crc8
-2 mem_24g_discard_cnt
-2 mem_cb_24g_data
-9 mem_24g_lasttx
+
 
 1 mem_power_ctrl_pac_succ_cnt
 1 mem_power_ctrl_level
@@ -118,14 +108,49 @@
 
 34 mem_24g_ackbuffer
 1 mem_24g_pll_flag
-28 mem_read_otp_data
+
 
 
 1 mem_24g_retransmit_cnt
 1 mem_en_24g_flag
+1 mem_test_ch
+2 mem_module_bt_ptr
+1 mem_24g_send_flag
+
+0 mem_tx_fifo0_new
+1 mem_tx_fifo0_map_new
+2 mem_tx_fifo0_ptr_new
+0 mem_tx_fifo1_new
+1 mem_tx_fifo1_map_new
+2 mem_tx_fifo1_ptr_new
+0 mem_tx_fifo2_new
+1 mem_tx_fifo2_map_new
+2 mem_tx_fifo2_ptr_new
+0 mem_tx_fifo3_new
+1 mem_tx_fifo3_map_new
+2 mem_tx_fifo3_ptr_new
+0 mem_tx_fifo4_new
+1 mem_tx_fifo4_map_new
+2 mem_tx_fifo4_ptr_new
+0 mem_tx_fifo5_new
+1 mem_tx_fifo5_map_new
+2 mem_tx_fifo5_ptr_new
+0 mem_tx_fifo6_new
+1 mem_tx_fifo6_map_new
+2 mem_tx_fifo6_ptr_new
+0 mem_tx_fifo7_new
+1 mem_tx_fifo7_map_new
+2 mem_tx_fifo7_ptr_new
+0 mem_tx_fifo8_new
+1 mem_tx_fifo8_map_new
+2 mem_tx_fifo8_ptr_new
+0 mem_tx_fifo_end_new
+
+
 )
 (
 45 mark_24g_rx
+46 mark_test_24g
 38 BT_CMD_START_UNCONN_ADV
 )
 (
@@ -193,7 +218,16 @@
 //6-7 channel offset
 )
 
-
+ (
+0x55 SYS_ENTER_HIBERNATE
+0x66 SYS_ENTER_LPM
+0xaa SYS_LPM_ACK
+)
+(
+  62 gpcfg_output_low
+  63 gpcfg_output_high
+  0x18700 sec_gpio_conf
+ )
 (
 249 LE_BASEBAND_MAX_BUFFER
 )
@@ -209,6 +243,8 @@
 
 0xb0 HCI_CMD_SEND_HID_DATA
 0xb1 HCI_CMD_CREAT_BT_RECONNECT
+0xb3 HCI_CMD_SET_DB_START
+0xb4 HCI_CMD_CANCEL_BT_RECONN
 
 0xc0 HCI_CMD_24G_RFENABLE
 0xc1 HCI_CMD_24G_TX
@@ -220,8 +256,9 @@
 0xc7 HCI_CMD_24G_NO_ACK_FLAG
 0xc8 HCI_CMD_24G_SET_ACKDATA
 0xc9 HCI_CMD_SEND_24G_DATA
+0xca HCI_CMD_24G_GET_NOISE
 
-
+0xf0 HCI_CMD_TEST_MODE
 0xfe HCI_CMD_ALL_ROUND
 )
 (
Index: rongyuan/output/eeprom.dat
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/output/eeprom.dat	(revision 932)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/output/eeprom.dat	(working copy)
@@ -2,8 +2,8 @@
 02
 aa
 55
-36
-0e
+4e
+12
 c2
 84
 00
@@ -11,39 +11,39 @@
 c0
 00
 81
-68
+8b
 c0
 01
 81
-6e
+91
 c0
 42
 81
-70
+9b
 c0
 44
 81
-96
+c1
 c0
 4a
 01
-4e
+71
 c0
 51
 01
-9f
+f6
 c0
 51
 81
-59
+7c
 c0
 54
 81
-5c
+7f
 c0
 56
 01
-a6
+ff
 c0
 5c
 00
@@ -51,43 +51,43 @@
 c0
 5d
 80
-77
+91
 c0
 5e
-00
-f3
+01
+15
 c0
 5f
-03
-6e
+04
+72
 20
 20
 4a
 8b
 c0
 01
-82
-c3
+83
+8c
 c0
 02
-82
-ba
+83
+83
 c0
 03
 01
-91
+bc
 c0
 09
-82
-e6
+83
+d5
 c0
 0f
-82
-cf
+83
+98
 c0
-10
-82
-e1
+11
+03
+aa
 c0
 18
 00
@@ -95,27 +95,27 @@
 c0
 1e
 01
-0b
+2d
 c0
 1d
 01
-15
+37
 c0
 1e
 81
-25
+48
 c0
 1f
 01
-32
+55
 c0
 20
 81
-44
+67
 c0
 4c
 81
-4a
+6d
 c0
 51
 00
@@ -199,7 +199,7 @@
 58
 00
 00
-3f
+58
 67
 e4
 41
@@ -207,7 +207,7 @@
 58
 00
 00
-5f
+79
 67
 e4
 41
@@ -215,7 +215,15 @@
 58
 00
 00
-63
+42
+67
+e4
+41
+f4
+58
+00
+00
+7d
 67
 e4
 41
@@ -223,7 +231,7 @@
 58
 00
 00
-74
+8e
 67
 e4
 41
@@ -231,15 +239,19 @@
 58
 00
 00
-75
+8f
 67
 e4
 41
 f2
 20
 40
-02
-b4
+03
+7d
+20
+40
+03
+48
 20
 40
 4d
@@ -256,6 +268,94 @@
 20
 50
 4d
+20
+40
+50
+d3
+20
+40
+56
+48
+24
+7a
+00
+00
+6f
+e4
+4f
+fc
+68
+44
+4f
+fe
+98
+46
+7c
+00
+20
+62
+80
+00
+20
+40
+67
+f7
+ef
+e2
+00
+03
+c0
+80
+80
+56
+ef
+e2
+00
+03
+67
+e2
+0a
+ff
+e8
+42
+00
+03
+18
+62
+22
+00
+60
+42
+0b
+00
+70
+0b
+01
+01
+20
+40
+4e
+5a
+6f
+e2
+0b
+01
+c1
+00
+00
+00
+20
+20
+4e
+55
+20
+40
+50
+7e
+20
+20
+4e
+51
 1a
 62
 7e
@@ -263,64 +363,68 @@
 c0
 00
 83
-06
+f7
 c0
 01
 03
-09
+fa
 c0
 02
-03
-17
+04
+08
 c0
 02
-83
-1f
+84
+10
 c0
 03
-03
-20
+04
+11
 c0
 03
-83
-23
+84
+14
 c0
 09
-03
-2c
+04
+1d
 c0
 09
-83
-36
+84
+26
 c0
 13
-83
-37
+84
+27
 c0
 17
-03
-3a
+04
+2a
 c0
 1e
-83
-3b
+84
+2b
 c0
 0c
-03
-3c
+04
+2c
 c0
 14
-82
-fb
+83
+ea
 c0
 05
 80
-4f
+68
 20
 20
 4d
 df
 20
+60
+00
+00
+20
 40
 4d
 d7
@@ -386,16 +490,16 @@
 73
 20
 40
-03
-48
+04
+3a
 20
 40
-03
-50
+04
+42
 20
 40
-03
-53
+04
+45
 20
 60
 00
@@ -466,7 +570,7 @@
 05
 20
 20
-03
+04
 7e
 20
 20
@@ -475,7 +579,7 @@
 20
 20
 00
-76
+90
 20
 20
 4d
@@ -487,79 +591,99 @@
 c0
 08
 80
-d8
+fa
 c0
 0a
-80
-e0
+81
+02
 c0
 13
-80
-ee
+81
+10
 c0
 06
-00
-e5
+01
+07
 c0
 58
-00
-f0
+01
+12
 c0
 58
-83
-63
+84
+57
 c0
 50
 00
-ba
+da
 c0
 01
 00
-a0
+bf
 c0
 3b
 00
-8c
+ab
+c0
+1a
+00
+f8
 c0
 64
-81
-b2
+82
+09
 c0
 60
-01
-a7
+02
+00
 c0
 60
-81
-ac
+82
+05
 c0
 61
-01
-af
+02
+07
 c0
 61
-81
-b8
+82
+0e
 c0
 62
-01
-bd
+02
+12
 c0
 62
-81
-c0
+82
+16
 c0
 64
-01
-d2
+02
+27
 c0
 63
-01
-d8
+02
+2c
 c0
 63
-81
-de
+82
+33
+c0
+78
+02
+3e
+c0
+65
+02
+37
+c0
+59
+84
+62
+c0
+5a
+04
+70
 20
 20
 4e
@@ -567,7 +691,7 @@
 20
 40
 00
-95
+b4
 18
 c0
 8d
@@ -643,7 +767,7 @@
 20
 20
 00
-97
+b6
 6f
 e2
 0b
@@ -691,7 +815,7 @@
 24
 20
 80
-af
+ce
 68
 42
 46
@@ -727,7 +851,7 @@
 20
 20
 80
-b6
+d5
 20
 20
 4d
@@ -748,6 +872,10 @@
 01
 00
 28
+20
+60
+00
+00
 ef
 e2
 00
@@ -759,7 +887,7 @@
 20
 20
 80
-c2
+e2
 2f
 ef
 fe
@@ -767,7 +895,7 @@
 20
 20
 80
-c6
+e6
 2f
 ef
 fe
@@ -775,7 +903,7 @@
 20
 20
 80
-cf
+ef
 20
 20
 50
@@ -868,6 +996,14 @@
 20
 50
 1f
+70
+44
+56
+00
+20
+20
+4f
+bd
 6f
 e4
 46
@@ -942,8 +1078,8 @@
 25
 c0
 01
-80
-ec
+81
+0e
 20
 20
 50
@@ -970,8 +1106,8 @@
 52
 c2
 81
-03
-56
+04
+48
 20
 20
 50
@@ -1027,7 +1163,7 @@
 20
 3a
 01
-07
+29
 e8
 48
 00
@@ -1043,7 +1179,7 @@
 24
 22
 81
-07
+29
 ef
 e2
 00
@@ -1055,7 +1191,7 @@
 20
 20
 01
-07
+29
 70
 46
 7a
@@ -1083,7 +1219,7 @@
 c0
 19
 81
-0f
+31
 20
 20
 61
@@ -1119,11 +1255,11 @@
 c0
 08
 01
-1c
+3e
 c0
 0b
 81
-22
+44
 20
 20
 60
@@ -1151,7 +1287,7 @@
 20
 21
 01
-20
+42
 20
 20
 62
@@ -1164,6 +1300,10 @@
 20
 61
 34
+20
+20
+62
+d2
 6f
 e4
 05
@@ -1187,7 +1327,7 @@
 c0
 05
 81
-29
+4c
 20
 20
 61
@@ -1247,7 +1387,7 @@
 c2
 83
 81
-38
+5b
 20
 20
 63
@@ -1255,11 +1395,11 @@
 c0
 42
 01
-3b
+5e
 c0
 41
 81
-3e
+61
 20
 20
 64
@@ -1267,7 +1407,7 @@
 20
 40
 01
-41
+64
 6f
 e2
 00
@@ -1279,7 +1419,7 @@
 20
 40
 01
-41
+64
 6f
 e2
 00
@@ -1379,7 +1519,7 @@
 20
 40
 01
-65
+88
 20
 20
 4a
@@ -1391,7 +1531,7 @@
 20
 40
 01
-64
+87
 20
 20
 4a
@@ -1423,7 +1563,7 @@
 20
 40
 01
-64
+87
 20
 20
 4b
@@ -1455,7 +1595,7 @@
 20
 40
 01
-6c
+8f
 20
 20
 40
@@ -1471,15 +1611,47 @@
 20
 40
 02
-b2
+37
+20
+40
+03
+11
+20
+40
+03
+0f
 20
 20
 40
 10
 20
+20
+5a
+cc
+20
+40
+7b
+84
+20
+40
+7b
+c1
+20
+40
+4c
+8f
+6f
+e4
+41
+f4
+20
+20
+7d
+77
+20
 30
 81
-80
+ab
 70
 89
 55
@@ -1511,27 +1683,27 @@
 c0
 00
 01
-7e
+a9
 c0
 00
 81
-8e
+b9
 c0
 01
 01
-7e
+a9
 c0
 01
 81
-8e
+b9
 c0
 02
 01
-8e
+b9
 c0
 10
 01
-8e
+b9
 70
 89
 55
@@ -1607,7 +1779,7 @@
 20
 20
 01
-80
+ab
 20
 40
 57
@@ -1615,7 +1787,7 @@
 20
 40
 01
-94
+bf
 20
 20
 58
@@ -1623,7 +1795,7 @@
 20
 36
 81
-9b
+c6
 20
 20
 57
@@ -1660,54 +1832,238 @@
 e2
 89
 06
-20
-20
-49
-37
 70
 89
-06
-7c
-20
-75
-80
 00
-58
+3c
+70
+89
+01
+e0
+70
+89
+6d
+12
+20
 00
 00
+0a
+70
+89
+02
+01
+70
+89
+02
+3d
+20
 00
-67
-e4
-41
-dd
-1c
-43
-7e
 00
-67
-e8
-40
-94
+0a
+70
+89
+03
+b7
 20
-60
 00
 00
-20
-20
-4b
+0a
+70
+89
+02
 7f
-20
-40
-50
-1f
+6f
+e2
+41
+df
+c0
+00
+49
+48
+c0
+00
+c9
+4c
+c0
+01
+01
+dd
+c0
+01
+c9
+54
+c0
+02
+49
+58
+c0
+05
+01
+e1
+c0
+07
+81
+e8
+c0
+0a
+01
+ef
+c0
+10
+49
+5c
+70
+89
+56
+ff
+20
+40
+49
+62
+70
+89
+55
+df
+20
+60
+00
+00
+70
+89
+54
+68
+70
+89
+55
+d8
+70
+89
+56
+e5
+70
+89
+57
+4c
+70
+89
+58
+36
+70
+89
+59
+10
+20
+60
+00
+00
+70
+89
+54
+68
+70
+89
+55
+d8
+70
+89
+56
+e2
+70
+89
+57
+4c
+70
+89
+58
+36
+70
+89
+59
+10
+20
+60
+00
+00
+70
+89
+54
+68
+70
+89
+55
+d8
+70
+89
+56
+e1
+70
+89
+57
+4c
+70
+89
+58
+36
+70
+89
+59
+10
+20
+60
+00
+00
+70
+89
+06
+74
+20
+00
+2e
+e0
+70
+89
+06
+7c
+20
+75
+80
+00
+58
+00
+00
+00
+67
+e4
+41
+dd
+1c
+43
+7e
+00
+67
+e8
+40
+94
+20
+60
+00
+00
+20
+20
+4b
+7f
+20
+40
+50
+1f
 ef
 e2
 00
 03
 20
 3a
-01
-ab
+02
+04
 20
 20
 49
@@ -1721,25 +2077,17 @@
 80
 2d
 20
-40
-50
-1f
-20
 20
 02
-1b
+81
 79
 20
 00
 2d
 20
-40
-02
-4a
-20
-20
-50
-1f
+60
+00
+00
 6f
 e2
 0b
@@ -1757,13 +2105,9 @@
 0b
 61
 20
-40
+20
 67
 ed
-20
-20
-50
-1f
 ef
 e2
 00
@@ -1773,49 +2117,45 @@
 41
 df
 20
-40
-48
-f5
-20
-40
-49
-30
-20
-20
-50
-1f
+60
+00
+00
+70
+4c
+a3
+01
 ef
 e2
 00
 03
 67
 e2
-4b
-f0
-20
+4c
+60
+70
+4c
+a3
+01
 20
-50
-1f
+60
+00
+00
 ef
 e8
 00
 03
 67
 e8
-4b
-f2
-20
-40
-01
-c4
+4c
+61
 20
 20
-50
-1f
+02
+19
 67
 e8
-4b
-f2
+4c
+61
 da
 20
 00
@@ -1826,8 +2166,8 @@
 04
 d8
 c0
-4b
-f2
+4c
+61
 ef
 e2
 00
@@ -1838,8 +2178,8 @@
 00
 c2
 00
-01
-c8
+02
+1d
 1a
 22
 7e
@@ -1847,15 +2187,15 @@
 67
 e4
 4c
-08
+67
 6f
 e2
 4c
-08
+67
 68
 42
 4c
-09
+68
 98
 40
 fe
@@ -1863,7 +2203,7 @@
 67
 e2
 4c
-0a
+69
 20
 60
 00
@@ -1879,19 +2219,15 @@
 67
 e2
 4c
-2f
+81
 d8
 a0
 4c
-30
+82
+20
 20
-40
 67
 ed
-20
-20
-50
-1f
 ef
 e2
 00
@@ -1899,7 +2235,7 @@
 67
 e2
 4c
-6e
+a4
 ef
 e2
 00
@@ -1910,8 +2246,12 @@
 78
 67
 e4
-4b
-eb
+4c
+5c
+20
+60
+00
+00
 20
 20
 50
@@ -1922,8 +2262,80 @@
 03
 67
 e2
-4b
-fc
+4c
+65
+20
+60
+00
+00
+20
+20
+50
+1f
+c6
+96
+80
+00
+20
+40
+03
+26
+58
+00
+00
+ca
+da
+20
+00
+01
+da
+40
+00
+18
+d8
+40
+00
+00
+20
+20
+50
+2b
+ef
+e2
+00
+03
+c0
+00
+82
+42
+79
+3f
+80
+2e
+20
+20
+50
+1f
+ef
+e2
+00
+03
+67
+e2
+4c
+a6
+ef
+e2
+00
+03
+67
+e2
+41
+df
+79
+20
+00
+2e
 20
 20
 50
@@ -1946,8 +2358,8 @@
 00
 6f
 e2
-4b
-f0
+4c
+60
 1f
 ed
 84
@@ -1964,6 +2376,10 @@
 60
 00
 00
+20
+40
+49
+ba
 78
 4d
 fc
@@ -2018,32 +2434,32 @@
 15
 68
 42
-4b
-f0
+4c
+60
 20
 20
-49
-30
+01
+c1
 20
 40
 57
 9e
 6f
 e8
-4b
-f2
+4c
+61
 98
 00
 12
 00
 20
 40
-01
-e1
+02
+48
 20
 40
-01
-f6
+02
+5e
 79
 20
 2a
@@ -2077,14 +2493,6 @@
 86
 28
 78
-4e
-fc
-00
-78
-2d
-fc
-00
-78
 23
 fc
 00
@@ -2095,7 +2503,7 @@
 6f
 e2
 4c
-0a
+69
 08
 00
 86
@@ -2127,7 +2535,7 @@
 c2
 00
 02
-10
+76
 78
 24
 7c
@@ -2161,65 +2569,69 @@
 00
 00
 70
-4b
-ef
+4c
+5f
 00
 20
 40
 02
-30
+97
 24
 37
 82
-23
+88
 20
 40
 02
-92
+f0
 20
 40
 02
-8b
-58
-00
-00
+e9
+70
+4c
+a9
 00
-67
-e4
-4b
-bb
 20
 60
 00
 00
 6f
-e4
-4b
-bb
-1f
-e6
+e2
+4c
+a4
+68
+42
+4c
+5f
+98
+46
 7c
-05
+00
+20
+22
+82
+ec
 24
 21
 02
-8e
+ec
 6f
 e2
-4b
-ef
+4c
+5f
 1f
 e0
 fe
 01
 67
 e2
-4b
-ef
+4c
+5f
 20
 20
 02
-1c
+82
 6f
 e2
 0b
@@ -2251,27 +2663,27 @@
 20
 40
 02
-2a
+91
 20
 40
-01
-f9
+02
+61
 6f
 e2
-4b
-fc
+4c
+65
 c0
 00
 82
-3e
+a5
 18
 00
 2a
 00
 6f
 e8
-4b
-f2
+4c
+61
 98
 00
 12
@@ -2291,11 +2703,11 @@
 20
 40
 02
-4a
+af
 20
 57
-81
-ea
+82
+52
 20
 60
 00
@@ -2310,16 +2722,16 @@
 00
 20
 20
-01
-ea
+02
+52
 20
 40
 57
 9e
 6f
 e8
-4b
-f2
+4c
+61
 98
 00
 12
@@ -2330,28 +2742,20 @@
 15
 68
 42
-4b
-f0
+4c
+60
 20
 40
 49
 1c
-58
-00
-05
-00
-20
-40
-4a
-8e
 20
 40
 49
 21
 20
 40
-01
-e1
+02
+48
 78
 26
 fc
@@ -2370,8 +2774,8 @@
 00
 6f
 e4
-4b
-eb
+4c
+5c
 98
 00
 36
@@ -2382,16 +2786,8 @@
 00
 24
 2c
-01
-ea
-78
-46
-fc
-00
-78
-25
-fc
-00
+02
+51
 78
 23
 fc
@@ -2411,19 +2807,19 @@
 67
 e2
 4c
-0b
+6a
 68
 42
 4c
-0a
+69
 98
 46
 7c
 00
 24
 22
-81
-ea
+82
+52
 09
 80
 00
@@ -2443,7 +2839,7 @@
 20
 22
 82
-66
+c9
 09
 80
 00
@@ -2459,7 +2855,7 @@
 c2
 00
 02
-62
+c5
 09
 80
 00
@@ -2476,14 +2872,10 @@
 e6
 00
 05
-78
-45
-fc
-00
 20
 23
-01
-ea
+02
+52
 78
 37
 fc
@@ -2508,18 +2900,6 @@
 40
 49
 15
-6f
-e2
-4c
-1c
-1f
-e2
-22
-00
-20
-40
-02
-9b
 20
 60
 00
@@ -2527,15 +2907,15 @@
 20
 40
 02
-7b
+da
 24
 37
 82
-8b
+e9
 20
 40
 02
-92
+f0
 78
 57
 fc
@@ -2547,7 +2927,7 @@
 20
 40
 02
-8b
+e9
 78
 57
 fc
@@ -2555,39 +2935,35 @@
 20
 40
 02
-41
+a8
 24
 77
 80
 00
 6f
 e2
-4b
-fc
+4c
+65
 c0
 00
-81
-ea
+82
+52
 20
 40
 02
-85
-20
-40
-01
-f9
+e3
 20
 40
 02
-8b
+61
 20
 20
-01
-ea
+02
+52
 6f
 e2
 4c
-2f
+81
 1f
 e0
 fe
@@ -2599,7 +2975,7 @@
 d8
 c0
 4c
-2f
+81
 d8
 a0
 0b
@@ -2648,10 +3024,6 @@
 e1
 72
 1f
-20
-7a
-00
-00
 1f
 e2
 72
@@ -2675,11 +3047,11 @@
 68
 42
 4c
-2e
+80
 58
 00
 4c
-1d
+6f
 98
 40
 8a
@@ -2703,7 +3075,7 @@
 60
 42
 4c
-2e
+80
 20
 60
 00
@@ -2719,59 +3091,491 @@
 68
 42
 4c
-2d
+7f
 da
 20
 0b
 a2
 20
 40
+03
+08
+60
+42
+4c
+7f
+20
+60
+00
+00
+1a
+22
+7e
+00
+98
+40
+8a
+00
+6f
+e2
+00
+18
+e7
+e2
+00
+05
+18
+40
+84
+01
+18
+41
+04
+ff
+20
+60
+00
+00
+c6
+96
+80
+00
+20
+20
 02
-ab
+d5
+c6
+97
+00
+00
+68
+42
+4c
+a6
+20
+40
+49
+15
+20
+40
+01
+c1
+20
+40
+57
+9e
+79
+20
+2a
+00
+78
+2e
+fc
+00
+78
+30
+7c
+00
+78
+50
+fc
+00
+20
+40
+58
+59
+d8
+a0
+0f
+a2
+58
+00
+00
+20
+67
+e2
+89
+08
+df
+20
+00
+18
+d8
+c0
+0f
+a2
+20
+20
+03
+21
+ef
+e2
+00
+06
+08
+00
+86
+08
+c2
+00
+03
+21
+20
+40
+01
+9b
+20
 60
+00
+00
+20
+40
+57
+9e
+6f
+e8
+4c
+61
+98
+00
+12
+00
+20
+40
+49
+15
+68
 42
 4c
-2d
+60
+20
+40
+49
+1c
+20
+40
+49
+21
+20
+40
+02
+48
+78
+26
+fc
+00
+78
+30
+fc
+00
+78
+50
+7c
+00
+78
+28
+7c
+00
+58
+00
+00
+0c
+98
+00
+36
+00
+37
+c1
+84
+00
+24
+2c
+02
+51
+20
+20
+02
+52
+20
+40
+03
+4a
+20
+20
+03
+46
+20
+40
+03
+4a
+20
+40
+03
+46
+20
+40
+03
+4a
+20
+40
+03
+46
+20
+20
+03
+4a
+20
+40
+03
+4a
+20
+40
+03
+46
+20
+20
+03
+4a
+20
+40
+03
+46
+20
+40
+03
+4a
+20
+20
+03
+46
+20
+40
+03
+46
+20
+20
+03
+4a
+d8
+40
+00
+0f
+20
+20
+03
+55
+d8
+40
+00
+0f
+20
+40
+03
+59
+d8
+40
+00
+0f
+20
+20
+03
+59
+20
+40
+03
+53
+20
+40
+03
+4f
+20
+20
+03
+53
+d8
+40
+00
+16
+20
+20
+03
+55
+d8
+40
+00
+16
+20
+40
+03
+59
+d8
+40
+00
+16
+20
+20
+03
+59
+18
+46
+7c
+ff
+20
+62
+80
+00
+2f
+cf
+fe
+07
+20
+20
+03
+5c
+18
+46
+7c
+ff
+20
+62
+80
+00
+2f
+cc
+00
+07
+58
+00
+00
+00
+7d
+20
+fe
+07
+98
+42
+84
+00
+20
+40
+03
+72
+58
+00
+00
+3f
+28
+4f
+fe
+07
+79
+20
+fe
+00
+20
+20
+03
+64
+e7
+e2
+00
+05
+da
+c0
+00
+00
+20
+60
+00
+00
+20
+40
+03
+6d
+70
+4f
+f0
+66
+20
+20
+03
+6a
+6f
+e2
+4f
+f1
+c0
+d5
+03
+6a
+20
+60
+00
+00
+da
+c0
+00
+00
+6f
+e2
+80
+43
+79
+3f
+fe
+07
+67
+e2
+80
+43
+20
+60
+00
+00
+20
+40
+03
+78
+da
+c0
+00
+0f
+18
+41
+7e
+3f
+d8
+a1
+87
+00
+98
+a0
+8a
+00
 20
 60
 00
 00
-1a
-22
-7e
+da
+c0
 00
-98
-40
-8a
 00
 6f
 e2
-00
-18
-e7
+80
+43
+79
+20
+7e
+07
+67
 e2
-00
-05
-18
-40
-84
-01
-18
-41
-04
-ff
+80
+43
 20
 60
 00
 00
-c6
-96
-80
-00
-20
-20
-02
-76
 58
 00
 00
@@ -2958,8 +3762,8 @@
 06
 c0
 02
-5c
-8b
+03
+af
 c0
 03
 5e
@@ -2972,6 +3776,158 @@
 60
 00
 00
+ef
+e6
+00
+06
+67
+e6
+04
+73
+c0
+05
+03
+b3
+20
+20
+5c
+8d
+68
+44
+04
+74
+6f
+e2
+44
+bb
+c2
+81
+83
+b7
+20
+20
+03
+be
+6f
+e4
+44
+cc
+98
+46
+7c
+00
+24
+22
+83
+be
+20
+40
+5e
+22
+24
+34
+03
+be
+70
+04
+76
+05
+20
+20
+5e
+57
+20
+40
+5b
+4a
+20
+3a
+5e
+56
+18
+c0
+8d
+fe
+ef
+e4
+00
+06
+d8
+40
+2a
+00
+98
+46
+7c
+00
+20
+22
+dd
+b3
+ef
+e2
+00
+06
+18
+c2
+26
+00
+68
+42
+44
+78
+98
+46
+7c
+00
+24
+21
+03
+cb
+6f
+e2
+44
+78
+1a
+62
+0c
+00
+1f
+e2
+26
+00
+20
+40
+7c
+80
+1a
+60
+a2
+01
+20
+40
+5e
+62
+58
+00
+00
+0b
+e7
+e2
+00
+05
+1a
+62
+72
+00
+20
+40
+7c
+7a
+20
+20
+7c
+dc
 20
 40
 5a
@@ -3063,7 +4019,7 @@
 58
 00
 00
-1c
+1d
 20
 40
 50
@@ -3096,17 +4052,25 @@
 40
 67
 d4
+6f
+e2
+44
+60
+e7
+e2
+00
+0a
 20
 20
 67
 b9
 70
-4b
-b1
+4c
+25
 00
 70
-4b
-b0
+4c
+24
 00
 20
 60
@@ -3118,8 +4082,8 @@
 2f
 20
 40
-03
-11
+04
+02
 6f
 e4
 46
@@ -3157,12 +4121,12 @@
 04
 00
 70
-4b
-b0
+4c
+24
 00
 70
-4b
-b1
+4c
+25
 00
 20
 60
@@ -3203,7 +4167,7 @@
 20
 20
 00
-5d
+77
 58
 00
 00
@@ -3237,8 +4201,8 @@
 50
 4e
 70
-4b
-b0
+4c
+24
 00
 58
 00
@@ -3246,8 +4210,8 @@
 01
 67
 e2
-4b
-b1
+4c
+25
 20
 60
 00
@@ -3285,25 +4249,21 @@
 e3
 01
 20
-40
-00
-5d
-20
 20
-4d
-89
+00
+77
 20
 20
-03
-17
+04
+08
 58
 00
 00
 05
 67
 e2
-4b
-b0
+4c
+24
 20
 60
 00
@@ -3318,8 +4278,8 @@
 00
 20
 20
-03
-3d
+04
+2d
 70
 0a
 ff
@@ -3327,7 +4287,7 @@
 58
 00
 00
-1c
+1d
 20
 40
 50
@@ -3360,18 +4320,26 @@
 40
 67
 d4
+58
+00
+00
+00
+e7
+e2
+00
+0a
 20
 20
 67
 b9
 da
 60
-4b
-b0
+4c
+24
 da
 40
-03
-4b
+04
+3d
 20
 20
 4d
@@ -3402,16 +4370,16 @@
 50
 da
 40
-03
-2c
+04
+1d
 20
 20
 4d
 04
 da
 60
-4b
-b1
+4c
+25
 da
 40
 4d
@@ -3422,12 +4390,20 @@
 04
 20
 40
+03
+3e
+20
+40
 56
-4b
+48
 24
 7a
 00
 00
+20
+40
+03
+3e
 6f
 e2
 0b
@@ -3507,7 +4483,7 @@
 20
 40
 00
-5d
+77
 20
 40
 4d
@@ -3516,6 +4492,70 @@
 20
 50
 1f
+18
+62
+26
+00
+6f
+e2
+0b
+00
+1f
+e2
+72
+00
+68
+44
+4c
+a7
+6f
+e4
+45
+47
+98
+40
+8a
+00
+1a
+62
+06
+00
+20
+40
+67
+ed
+18
+a2
+7e
+00
+68
+44
+4c
+a7
+6f
+e2
+0b
+00
+98
+40
+fe
+00
+67
+e4
+4c
+a7
+20
+20
+50
+1f
+20
+40
+4d
+62
+20
+20
+50
+1f
 6f
 e4
 02
@@ -3546,16 +4586,16 @@
 2d
 c0
 05
-03
-7a
+04
+7e
 c0
 02
-83
 84
+8a
 c0
 00
-83
-86
+84
+8c
 c0
 02
 51
@@ -3564,50 +4604,58 @@
 60
 00
 00
-ef
-e4
-00
-06
-67
-e4
-0a
-96
-c0
-00
-83
-7e
-20
-60
-00
-00
 70
 0a
 ff
 b2
-58
-00
-00
+6f
+e2
 02
+62
+1f
+e0
+ff
+ff
 20
 40
 50
 a5
 6f
+e2
+02
+62
+1f
+e0
+ff
+ff
+1f
+e2
+72
+00
+6f
 e4
-0a
-96
-e7
-e4
+02
+60
+1f
+e0
+fe
+01
+1f
+e2
+0c
 00
-0a
+20
+40
+67
+d4
 20
 20
 67
 b9
 20
 40
-03
-7a
+04
+7e
 20
 20
 51
@@ -3621,16 +4669,16 @@
 d1
 1e
 70
-4b
-b2
+4c
+26
 01
 c0
 01
 d1
 2d
 70
-4b
-b2
+4c
+26
 00
 c0
 02
@@ -3640,8 +4688,8 @@
 60
 00
 00
-80
-c7
+c4
+ed
 aa
 55
 40
@@ -3684,7 +4732,7 @@
 00
 08
 80
-02
+04
 00
 01
 74
@@ -3716,36 +4764,22 @@
 55
 01
 00
-02
-4c
-01
-aa
-55
-01
-00
-e9
-4b
-02
-aa
-55
-01
-00
-01
+66
 4c
 40
 aa
 55
 01
 00
-fc
-4b
+65
+4c
 00
 aa
 55
 02
 00
-eb
-4b
+5c
+4c
 c0
 12
 aa
@@ -3768,8 +4802,8 @@
 55
 08
 00
-b3
-4b
+27
+4c
 00
 48
 5d
@@ -3782,8 +4816,8 @@
 55
 04
 00
-e2
-4b
+54
+4c
 ff
 ff
 ff
@@ -3836,7 +4870,7 @@
 00
 78
 44
-17
+e6
 aa
 55
 01
@@ -3976,14 +5010,14 @@
 00
 8e
 44
-df
-48
+37
+49
 aa
 55
 02
 00
-df
-48
+37
+49
 00
 00
 aa
@@ -4793,8 +5827,8 @@
 00
 14
 42
-f7
-4a
+f3
+4b
 00
 aa
 55
@@ -4810,13 +5844,13 @@
 1c
 00
 1c
-80
+e0
 4c
 e0
 4f
-80
+e0
 4c
-80
+e0
 4c
 aa
 55
@@ -4951,8 +5985,8 @@
 40
 20
 00
-00
-20
+ff
+ff
 aa
 55
 04
@@ -5000,8 +6034,8 @@
 55
 0f
 00
-a1
-4b
+15
+4c
 4b
 ba
 55
@@ -5023,7 +6057,7 @@
 00
 c3
 40
-a1
-4b
-86
-3e
+15
+4c
+ef
+53
Index: rongyuan/output/memmap.format
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/output/memmap.format	(revision 932)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/output/memmap.format	(working copy)
@@ -935,69 +935,81 @@
 0x467d mem_module_hci_nofiy_addr
 0x467f mem_last_transmite_clock
 0x4683 mem_module_uuid_list
-0x48df mem_module_uuid_list_end
-0x48df mem_module_le_att_list
-0x4af7 mem_module_le_att_list_end
-0x4af7 mem_module_nv_data
-0x4af7 mem_module_nv_data0
-0x4b19 mem_module_nv_data1
-0x4b3b mem_module_nv_data2
-0x4b5d mem_module_nv_data3
-0x4b7f mem_module_nv_data4
-0x4ba1 mem_rf_init
-0x4bb0 mem_classic_shutter_cable_unplug_conut
-0x4bb1 mem_classic_shutter_hid_disconn_count
-0x4bb2 mem_suspend_flag
-0x4bb3 mem_24g_enter_hibernate
-0x4bbb mem_24g_txfail_cnt
-0x4bbc mem_mouse_retry_flag
-0x4bbd mem_24g_led_flag
-0x4bbe mem_24g_txbuf_new
-0x4bde mem_24g_enter_hibernate_setup
-0x4be2 mem_24g_enter_hibernate_max
-0x4be6 mem_24g_rxdata_length
-0x4be7 mem_24g_pid
-0x4be8 mem_24g_datalen
-0x4be9 mem_24g_data_type
-0x4bea mem_24g_txlen
-0x4beb mem_24g_rx_window
-0x4bed mem_24g_ensure
-0x4bee mem_24g_get_ack_fail
-0x4bef mem_24g_retry
-0x4bf0 mem_24g_ch
-0x4bf1 mem_24g_current_ch_number
-0x4bf2 mem_24g_addr
-0x4bf6 mem_24g_check_dongle_times
-0x4bf8 mem_24g_device_addr
-0x4bfc mem_24g_no_ack
-0x4bfd mem_24g_sta_crc
-0x4c00 mem_24g_sta_pid
-0x4c01 mem_24g_max_retry
-0x4c02 mem_24g_mode
-0x4c03 mem_24g_hop_pac_retry
-0x4c04 mem_24g_idle_timeout
-0x4c05 mem_24g_idle_cnt
-0x4c06 mem_24g_auto_paring_switch
-0x4c07 mem_24g_enter_lpm_timer
-0x4c08 mem_24g_syncword
-0x4c0a mem_24g_syncword_crc8
-0x4c0b mem_24g_get_syncword_crc8
-0x4c0c mem_24g_discard_cnt
-0x4c0e mem_cb_24g_data
-0x4c10 mem_24g_lasttx
-0x4c19 mem_power_ctrl_pac_succ_cnt
-0x4c1a mem_power_ctrl_level
-0x4c1b mem_rssi_avg_received
-0x4c1c mem_rssi_hex_received
-0x4c1d mem_rssi_signal_buf
-0x4c25 mem_rssi_noise_buf
-0x4c2d mem_rssi_noise_index
-0x4c2e mem_rssi_signal_index
-0x4c2f mem_24g_ackbuffer
-0x4c51 mem_24g_pll_flag
-0x4c52 mem_read_otp_data
-0x4c6e mem_24g_retransmit_cnt
-0x4c6f mem_en_24g_flag
+0x4937 mem_module_uuid_list_end
+0x4937 mem_module_le_att_list
+0x4bf3 mem_module_le_att_list_end
+0x4bf3 mem_module_nv_data
+0x4bf3 mem_module_nv_data0
+0x4bf3 mem_module_nv_data1
+0x4bf3 mem_module_nv_data2
+0x4bf3 mem_module_nv_data3
+0x4bf3 mem_module_nv_data4
+0x4c15 mem_rf_init
+0x4c24 mem_classic_shutter_cable_unplug_conut
+0x4c25 mem_classic_shutter_hid_disconn_count
+0x4c26 mem_suspend_flag
+0x4c27 mem_24g_enter_hibernate
+0x4c2f mem_24g_txfail_cnt
+0x4c30 mem_24g_txbuf_new
+0x4c50 mem_24g_enter_hibernate_setup
+0x4c54 mem_24g_enter_hibernate_max
+0x4c58 mem_24g_rxdata_length
+0x4c59 mem_24g_pid
+0x4c5a mem_24g_datalen
+0x4c5b mem_24g_txlen
+0x4c5c mem_24g_rx_window
+0x4c5e mem_24g_ensure
+0x4c5f mem_24g_retry
+0x4c60 mem_24g_ch
+0x4c61 mem_24g_addr
+0x4c65 mem_24g_no_ack
+0x4c66 mem_24g_max_retry
+0x4c67 mem_24g_syncword
+0x4c69 mem_24g_syncword_crc8
+0x4c6a mem_24g_get_syncword_crc8
+0x4c6b mem_power_ctrl_pac_succ_cnt
+0x4c6c mem_power_ctrl_level
+0x4c6d mem_rssi_avg_received
+0x4c6e mem_rssi_hex_received
+0x4c6f mem_rssi_signal_buf
+0x4c77 mem_rssi_noise_buf
+0x4c7f mem_rssi_noise_index
+0x4c80 mem_rssi_signal_index
+0x4c81 mem_24g_ackbuffer
+0x4ca3 mem_24g_pll_flag
+0x4ca4 mem_24g_retransmit_cnt
+0x4ca5 mem_en_24g_flag
+0x4ca6 mem_test_ch
+0x4ca7 mem_module_bt_ptr
+0x4ca9 mem_24g_send_flag
+0x4caa mem_tx_fifo0_new
+0x4caa mem_tx_fifo0_map_new
+0x4cab mem_tx_fifo0_ptr_new
+0x4cad mem_tx_fifo1_new
+0x4cad mem_tx_fifo1_map_new
+0x4cae mem_tx_fifo1_ptr_new
+0x4cb0 mem_tx_fifo2_new
+0x4cb0 mem_tx_fifo2_map_new
+0x4cb1 mem_tx_fifo2_ptr_new
+0x4cb3 mem_tx_fifo3_new
+0x4cb3 mem_tx_fifo3_map_new
+0x4cb4 mem_tx_fifo3_ptr_new
+0x4cb6 mem_tx_fifo4_new
+0x4cb6 mem_tx_fifo4_map_new
+0x4cb7 mem_tx_fifo4_ptr_new
+0x4cb9 mem_tx_fifo5_new
+0x4cb9 mem_tx_fifo5_map_new
+0x4cba mem_tx_fifo5_ptr_new
+0x4cbc mem_tx_fifo6_new
+0x4cbc mem_tx_fifo6_map_new
+0x4cbd mem_tx_fifo6_ptr_new
+0x4cbf mem_tx_fifo7_new
+0x4cbf mem_tx_fifo7_map_new
+0x4cc0 mem_tx_fifo7_ptr_new
+0x4cc2 mem_tx_fifo8_new
+0x4cc2 mem_tx_fifo8_map_new
+0x4cc3 mem_tx_fifo8_ptr_new
+0x4cc5 mem_tx_fifo_end_new
 0x0b1e mem_24g_rxbuf
 0x0b40 mem_24g_txbuf
 0x0b60 mem_24g_txpayload
Index: rongyuan/output/sched.rom
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/output/sched.rom	(revision 932)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/output/sched.rom	(working copy)
@@ -35,7 +35,7 @@
 00	#mem_patch21
 08	#mem_patch22
 80	#mem_patch23
-02	#mem_patch24
+04	#mem_patch24
 00	#mem_patch25
 01	#mem_patch26
 74	#mem_patch27
@@ -63,8 +63,6 @@
 00	#mem_patch3d
 00	#mem_patch3e
 00	#mem_patch3f
-mem_24g_mode:01#tx
-mem_24g_data_type:02        #mouse 1,kb 2
 mem_24g_max_retry:4#max tx retry
 mem_24g_no_ack:00#with ack
 mem_24g_rx_window:c0 12     #400us 
@@ -95,7 +93,7 @@
 
 
 
-mem_le_local_mtu:17
+mem_le_local_mtu:e6
 mem_le_remote_mtu:17
 
 mem_le_secure_connect_enable:00
@@ -518,10 +516,10 @@
 4FF2:FF 1F
 4FF4:00 1C
 4FF6:00 1C
-4FF8:80 4C
+4FF8:e0 4c
 4FFA:E0 4F
-4FFC:80 4C
-4FFE:80 4C
+4FFC:E0 4c
+4FFE:e0 4c
 
 ##############BLUETOOTH CONFIG##############
 ###commom###
@@ -560,7 +558,7 @@
 
 mem_inq_window:20 00
 mem_page_window:20 00
-mem_page_to:00 20
+mem_page_to:ff ff
 mem_rx_window_init:80 04
 mem_rx_window_sniff:00 10
 
Index: rongyuan/patch/patch.prog
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/patch/patch.prog	(revision 932)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/patch/patch.prog	(working copy)
@@ -33,7 +33,7 @@
 	beq patch20_6,p_le_transmit
 	beq patch22_3,p_le_acknowledge
 	beq patch23_7,p_le_parse
-	beq patch24_1,p_le_parse_l2cap
+	beq patch24_2,p_le_parse_l2cap
 	beq patch26_0,p_le_modified_name
 	beq patch27_4,p_parse_lmp_accepted
 	beq patch27_2,p_parse_lmp
@@ -78,6 +78,9 @@
 	setarg p_module_bb_event_timer
 	store 2,mem_cb_event_timer
 
+	setarg p_module_process_idle
+	store 2,mem_cb_idle_process
+
 	setarg p_module_le_receive_data
 	store 2,mem_cb_att_write
 
@@ -88,14 +91,48 @@
 	store 2,mem_cb_bt_process
 
 	call p_keyboard_ble_init
-
+	call p_gpio15_init
 	call module_lpm_uart_init
 	call module_gpio_init
 	call check_module_disabled
 	//call p_check_otp_shaomaqiang_app
 	branch module_hci_event_enter_standby_mode
 
+p_module_process_idle:
+	
+	call module_control_air_flow
+	call l2cap_malloc_is_fifo_full
+	nrtn blank
 
+	
+
+p_module_process:
+	fetch 2,IPC_M02BT_READ_PTR
+	fetcht 2,IPC_M02BT_WRITE_PTR
+	isub temp,null
+	rtn,zero	
+	
+	call uartd_prepare_rx
+	ifetch 1,contru
+	bne 0x01,p_module_hci_in_excp
+	
+	ifetch 1,contru
+	store 1,mem_module_uart_opcode
+	ifetcht 1,contru
+	copy contru,rega
+	storet 1,mem_module_uart_len
+	jam HCI_DISCARD_PACKET,mem_module_temp_nl_discard_packet
+	
+	call module_hci_cmd_control
+	
+	fetch 1,mem_module_temp_nl_discard_packet
+	rtneq HCI_NOT_DISCARD_PACKET
+	
+	branch module_hci_dicard_packet //discard this packet
+
+p_module_hci_in_excp:
+	call module_hci_event_invalid_packet
+	branch module_hci_release_except
 p_module_process_bb_event:
 	copy regc,pdata
 /***************classic shutter event****************/
@@ -127,7 +164,7 @@
 
 
 p_module_process_enter_sniff:
-
+	rtn
 p_module_sniff_param_check:
 	call module_spp_clear_last_transmite_clock
 	//fetch 1,mem_context
@@ -209,6 +246,7 @@
 	branch module_spp_enter_sniff+1
 
 p_module_hci_cmd_control:
+	
 	fetch 1,mem_module_uart_opcode
 	beq HCI_CMD_BT_DISCONNECT,p_module_hci_cmd_bt_disconnect
 	beq HCI_CMD_SET_COD,p_module_hci_cmd_set_cod
@@ -225,7 +263,7 @@
 //	beq HCI_CMD_ADD_CHARACTERISTIC_UUID,module_hci_cmd_add_characteristic_uuid
 
 	beq HCI_CMD_ADD_SERVICE_CHARAC_UUID,p_module_hci_cmd_add_service_charactisic
-
+	beq HCI_CMD_LE_SET_ADV_DATA,p_module_hci_cmd_le_set_adv_data
 	beq HCI_CMD_SEND_24G_DATA,p_module_hci_cmd_send_24g_data
 	beq HCI_CMD_24G_RFENABLE,p_module_hci_cmd_24g_rfenable
 	beq HCI_CMD_24G_TX,p_module_hci_cmd_set_24g_tx
@@ -236,6 +274,13 @@
 	beq HCI_CMD_24G_SET_ACKDATA,p_module_hci_cmd_24g_send_ack_prep
 	beq HCI_CMD_24G_SET_RETRAN_TIME,p_module_hci_cmd_24g_set_retransmit_time
 	beq HCI_CMD_24G_NO_ACK_FLAG,p_module_hci_cmd_set_no_ack
+	beq HCI_CMD_TEST_MODE,p_module_hci_cmd_set_test
+	beq HCI_CMD_24G_GET_NOISE,p_module_hci_cmd_set_noise_rssi
+	beq HCI_CMD_SET_DB_START,p_module_hci_cmd_set_db_start
+	beq HCI_CMD_CANCEL_BT_RECONN,p_module_hci_cmd_cancel_reconn
+
+//	beq HCI_CMD_SET_CRSTAL,
+	
 	branch module_hci_cmd_control + 2
 
 p_module_hci_cmd_add_service_charactisic:
@@ -381,7 +426,7 @@
 	beq ADV_IND,app_ble_start_adv
 	beq ADV_DIRECT_IND,app_ble_start_direct_adv
 	beq ADV_NONCONN_IND,app_ble_start_unconn_adv
-
+	rtn
 
 p_module_hci_cmd_adv_data_change:
 	ifetch 1,contru
@@ -421,8 +466,9 @@
 	call memcpy_fast
 	branch module_hci_event_receive_valid_cmd	
 
-
-
+p_module_hci_cmd_le_set_adv_data:
+	jam ADV_IND,mem_le_adv_type
+	branch module_hci_cmd_le_set_adv_data
 	
 p_module_hci_cmd_bt_disconnect:
 	fetch 2,mem_ui_state_map
@@ -536,6 +582,7 @@
 	branch reject_lmp_packet
 
 p_parse_lmp_sniff_req:
+	branch lmp_reject_sniff
 	fetch 2,mem_rxbuf+6
 	branch lmp_reject_sniff,blank
 	//call parse_lmp_sniff_req_check_sniff_para
@@ -804,9 +851,29 @@
 	branch ui_timer_init
 
 p_main_loop:
+
+	call p_module_hci_cmd_set_noise_rssi
+
+	call p_test_dispatch
+
 	call p_g24_dispatch
+
 	branch main_loop+1
 
+p_le_dispatch:
+	//call le_scan
+	branch  le_adv
+p_app_process_idle:
+
+	call ui_dispatch
+	
+	call check_51cmd
+	
+	call app_process_bb_event
+	
+	fetch 2,mem_cb_idle_process
+	branch callback_func
+
 /*
 	YC3121 shutdown radio bugfix
 	rfen_adc bug ÌÕÆäÎÄÌí¼Ó
@@ -868,15 +935,71 @@
 	call set_freq_tx_offset
 	call rf_write_freq
 	setarg param_pll_setup
-	call sleep
+	call sleep	
 p_txon:	
+	
 	fetch 1,rfen_adc
 	set1 0,pdata
 	store 1,rfen_adc
-	branch txon+1
+	hjam 0x3c,rfen_rx
+	hjam 0xe0,rfen_tx
+	hjam 0x12,0x96d
+	nop 10
+	hjam 0x01,rfen_mdm
+	hjam 0x3d,rfen_mdm
+	nop 10
+	hjam 0xb7,rfen_sn
+	nop 10
+	hjam 0x7f, rfen_mdm
+	fetch 1,mem_tx_power
+	beq TX_POWER_0DB,set_tx_power_0db
+	beq TX_POWER_3DB,set_tx_power_3db	
+	beq TX_POWER_5DB,p_set_tx_power_5db
+	beq TX_POWER_f3DB,set_tx_power_f3db	
+	beq TX_POWER_f5DB,set_tx_power_f5db
+	beq TX_POWER_f10DB,p_set_tx_powerf10db
+	beq TX_POWER_f15DB,p_set_tx_powerf15db
+	beq TX_POWER_f20DB,p_set_tx_powerf20db
+	beq TX_POWER_PAIR,set_tx_power_pair
+
+p_set_tx_power_5db:
+	hjam 0xff,0x956
+	call txon_common
+	hjam 0xdf,0x955
+	
+	rtn
+p_set_tx_powerf10db:
+	hjam 0x68,0x954
+	hjam 0xd8,0x955
+	hjam 0xe5,0x956
+	hjam 0x4c,0x957
+	hjam 0x36,0x958
+	hjam 0x10,0x959
+	rtn
+
+p_set_tx_powerf15db:
+	hjam 0x68,0x954
+	hjam 0xd8,0x955
+	hjam 0xe2,0x956
+	hjam 0x4c,0x957
+	hjam 0x36,0x958
+	hjam 0x10,0x959
+	rtn
+
+p_set_tx_powerf20db:
+	hjam 0x68,0x954
+	hjam 0xd8,0x955
+	hjam 0xe1,0x956
+	hjam 0x4c,0x957
+	hjam 0x36,0x958
+	hjam 0x10,0x959
+	rtn
+
 
 
 p_init_param:
+	hjam 0x74,rfen_adc
+	nop 12000
 	hjam 0x7c,rfen_adc
 	rtn wake
 	setarg 0
@@ -911,43 +1034,54 @@
 	branch shutdown_radio
 
 p_module_hci_cmd_set_24g_tx:
+	
 	set0 mark_24g_rx,mark
-	call module_hci_event_receive_valid_cmd
+//	call module_hci_event_receive_valid_cmd
+	
 	branch p_g24_transmit_packet
 
+
 p_module_hci_cmd_set_24g_rx:
 	set1 mark_24g_rx,mark
-	call p_g24_receive_rxon
-	
-	branch module_hci_event_receive_valid_cmd
+//	call p_g24_receive_rxon
+	rtn
+//	branch module_hci_event_receive_valid_cmd
 
 //function : tx copy 24gdata into buffer waiting for enable is_tx
 p_module_hci_cmd_send_24g_data:
+
 	fetch 1,mem_module_uart_len
 	copy pdata,loopcnt
 	store 1,mem_24g_txpayload
 	arg mem_24g_txpayload+1,contw
-	call uart_copy_rx_bytes
-	branch module_hci_event_receive_valid_cmd
+	branch uart_copy_rx_bytes
+//	branch module_hci_event_receive_valid_cmd
+
+	
 //function : set  tx power
 p_module_hci_cmd_set_txpower:
 	ifetch 1,contru
 	store 1,mem_tx_power
-	call shutdown_radio
-	call set_freq_tx
-	branch module_hci_event_receive_valid_cmd
+	rtn
+	jam 1,mem_24g_pll_flag
+//	call shutdown_radio
+//	branch set_freq_tx
+//	branch module_hci_event_receive_valid_cmd
 
 
 p_module_hci_cmd_set_24g_channel:
 	ifetch 1,contru
 	store 1,mem_24g_ch
-	
-	branch module_hci_event_receive_valid_cmd
+	jam 1,mem_24g_pll_flag
+	rtn
+//	call shutdown_radio
+//	branch set_freq_tx	
+//	branch module_hci_event_receive_valid_cmd
 p_module_hci_cmd_set_24g_addr:	
 	ifetch 4,contru
 	store 4,mem_24g_addr
-	call p_g24_update_addr_and_synccrc8
-	branch module_hci_event_receive_valid_cmd	
+	branch p_g24_update_addr_and_synccrc8
+//	branch module_hci_event_receive_valid_cmd	
 	
 // calculate crc8
 p_g24_update_addr_and_synccrc8:	
@@ -975,26 +1109,65 @@
 	copy pdata,loopcnt
 	store 1,mem_24g_ackbuffer
 	arg mem_24g_ackbuffer+1,contw
-	call uart_copy_rx_bytes
-	branch module_hci_event_receive_valid_cmd
+	branch uart_copy_rx_bytes
+//	branch module_hci_event_receive_valid_cmd
 	
 
 
 p_module_hci_cmd_24g_set_retransmit_time:
+
 //first byte 24g retransmit cnt  second byte 24g receive ack time
 	ifetch 1,contru
 	store 1,mem_24g_retransmit_cnt
 	ifetch 1,contru
 	mul32 pdata,120,pdata
 	store 2,mem_24g_rx_window
+	rtn
 	branch module_hci_event_receive_valid_cmd
 
 p_module_hci_cmd_set_no_ack:
 // 0: without ack 1"with ack
 	ifetch 1,contru
 	store 1,mem_24g_no_ack
+	rtn
 	branch module_hci_event_receive_valid_cmd
 
+
+
+p_module_hci_cmd_set_noise_rssi:
+	rtnmark0 mark_24g_rx
+	call p_g24_receive_packet_noise
+//	hfetch 1,rf_agc_ctrl
+//	set0 7,pdata
+//	hstore 1,rf_agc_ctrl
+	setarg HCI_CMD_24G_GET_NOISE
+	arg 1,rega
+	arg mem_rssi,regb
+	arg 0,temp
+	branch module_hci_event_set_cmd+1
+
+
+
+
+
+
+
+//-----------------------------------------------------------TEST MODE--------------------------------------------------------------------------------
+//----------------------------------------------------------------------------------------------------------------------------------------------------------------------
+//----------------------------------------------------------------------------------------------------------------------------------------------------------------------
+p_module_hci_cmd_set_test:
+// 0: without test mode  1: with test mode 
+	ifetch 1,contru
+	beq 1,p_module_hci_cmd_set_test_valid
+	set0 mark_test_24g,mark
+	branch module_hci_event_receive_valid_cmd
+p_module_hci_cmd_set_test_valid:
+	ifetch 1,contru
+	store 1,mem_test_ch
+	ifetch 1,contru
+	store 1,mem_tx_power
+	set1 mark_test_24g,mark
+	branch module_hci_event_receive_valid_cmd
 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------
 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
@@ -1010,7 +1183,7 @@
 	rshift temp,white_init
 	rtn
 p_g24_sync_timeout:
-//	call p_rssi_noise
+	call save_rssi
 //	branch p_g24_end_of_packet
 p_g24_end_of_packet:
 	disable encode_fec1
@@ -1024,6 +1197,7 @@
 	disable enable_white
 	until null,tx_clear
 	nop 100          /* flush out the last bit */
+	
 	rtn
 
 
@@ -1033,14 +1207,23 @@
 p_g24_set_freq_tx:
 	call set_sync_on
 	fetcht 1,mem_24g_ch
-	branch set_freq_tx
+	branch p_set_freq_tx
+//	storet 1,mem_last_freq
+//	call set_freq_tx_offset
+//	call rf_write_freq
+//	fetch 1,mem_24g_pll_flag
+//	branch p_txon,blank
+//	setarg param_pll_setup
+//	call sleep	
+//	jam 0,mem_24g_pll_flag
+//	branch p_txon
 p_g24_transmit:
+	
 	call le_enable
 	fetch 4,mem_24g_addr
 	iforce access
 	call p_g24_prep
 	call p_g24_set_freq_tx
-	
 	set1 TXGFSK,radio_ctrl
 	enable encode_fec0
 	enable is_tx
@@ -1049,10 +1232,11 @@
 	rshift8 pdata,pdata
 	rshift4 pdata,pdata
 	inject mod,40
-	disable encode_fec0
-	enable encode_fec1
+//	disable encode_fec0
+//	enable encode_fec1
 	enable enable_white
 	enable enable_crc
+	
 	fetch 1,mem_24g_syncword_crc8
 	inject mod,8
 	fetch 1,mem_24g_txbuf		//first byte txpayload len
@@ -1071,6 +1255,7 @@
 	nop 100
 	disable encode_fec0
 	disable encode_fec1
+	
 	rtn
 	
 
@@ -1082,20 +1267,23 @@
 p_g24_transmit_packet:
 	jam 0,mem_24g_retry
 p_g24_transmit_loop:
+
 //	arg param_rx_setup,timeup
 //	until clkn_rt,meet
 	call p_g24_transmit_receive_ack			//if receive ack won't enter retransmit and report ack data
 	nbranch p_g24_retransmit,user3
+	
 	call p_g24_evt_receive_packet_report
 p_g24_transmit_abandon:
 	call p_g24_rx_interrupt_clear
-	setarg 0
-	store 2,mem_24g_txfail_cnt
+	jam 0,mem_24g_send_flag
 	rtn	
 
 p_g24_retransmit:
-	fetch 2,mem_24g_txfail_cnt
-	sub pdata,0x5,null
+	fetch 1,mem_24g_retransmit_cnt
+	fetcht 1,mem_24g_retry
+	isub temp,null
+	branch p_g24_evt_send_data_failed,zero
 	nbranch p_g24_evt_send_data_failed,positive
 
 	fetch 1,mem_24g_retry
@@ -1117,6 +1305,7 @@
 p_g24_transmit_receive_ack:
 	disable user3
 	call p_g24_data_transmit_prep
+	
 	call p_g24_transmit
 	fetch 1,mem_24g_no_ack
 	beq no_ack_24g,p_g24_transmit_no_ack	//tx no ack
@@ -1124,9 +1313,12 @@
 	fetch 4,mem_24g_addr
 	iforce access
 	fetcht 1,mem_last_freq
+	
 	call set_freq_rx
 	call rf_rx_enable
+	
 	call p_g24_receive_rxon
+	
 	call p_g24_end_of_packet,user3
 	rtn
 p_g24_transmit_no_ack:
@@ -1140,14 +1332,15 @@
 /////////////////////////////////////////////////////////////            24G RX DISPATCH           ////////////////////////////////////////////////////////////////		
 //processing for pll time and 24g channel&addr
 p_g24_receive_packet:
+	
 	call le_enable
 	fetch 4,mem_24g_addr
 	iforce access
 	call set_sync_on
 	fetcht 1,mem_24g_ch
 	call set_freq_rx
-	setarg param_pll_setup		//if changing the channel must waiting for pll time 
-	call sleep
+//	setarg param_pll_setup		//if changing the channel must waiting for pll time 
+//	call sleep
 	call rf_rx_enable
 p_g24_receive_rxon:
 	call p_g24_prep
@@ -1159,8 +1352,8 @@
 	iforce stop_watch
 	correlate null,timeout
 	nbranch p_g24_sync_timeout,sync
-	disable decode_fec0
-	enable decode_fec1
+//	disable decode_fec0
+//	enable decode_fec1
 	enable enable_white
 	enable enable_crc
 	parse demod,bucket,8
@@ -1187,7 +1380,7 @@
 	rshift32 pdata,pdata
 	rshift16 pdata,pdata
 	istore 3,contw
-	disable decode_fec1
+//	disable decode_fec1
 	branch p_g24_end_of_packet,crc_failed
 	enable user3
 	fetch 1,mem_last_freq
@@ -1195,9 +1388,9 @@
 	call rf_write_freq
 	disable decode_fec0
 	call set_sync_on
-	fetch 1,mem_rssi_hex_received
-	copy pdata,rega
-	call p_rssi_signal
+//	fetch 1,mem_rssi_hex_received
+//	copy pdata,rega
+//	call p_rssi_signal
 	rtn
 
 
@@ -1223,7 +1416,7 @@
 p_g24tx_with_ack:
 	call p_g24_ackpayload_prep
 	call p_g24_transmit
-	call p_g24_rx_interrupt_clear
+
 	branch p_g24_end_of_packet
 
 
@@ -1248,21 +1441,25 @@
 //-----------------------------------------------------------------------------G24 EVT----------------------------------------------------------------------
 //---------------------------------------------------------------------------------------------------------------------------------------------------------------
 p_g24_evt_send_data_failed:
+	
 	jam HCI_EVNET_SEND_DATA_FAIL,mem_module_uart_opcode
 	setarg 0
 	call module_hci_prepare_tx
-
 	branch uartd_send
+	
 p_g24_evt_receive_packet_report:
+	
 	jam HCI_EVENT_RECEIVE_24G_DATA,mem_module_uart_opcode
 	fetch 1,mem_24g_rxbuf
 	and pdata,0x1f,loopcnt	//max payload: 32bytes
-	rtn blank
+	
 	copy pdata,loopcnt
 	call module_hci_prepare_tx
 	arg mem_24g_rxbuf+1,contr
 	call uart_copy_tx_bytes
-	branch uartd_send
+	branch  uartd_send
+	
+
 	
 	
 p_rssi_signal:
@@ -1294,22 +1491,195 @@
 	rtn
 
 
+p_g24_dispatch:
+
+	rtnmark0 mark_24g_rx
+	branch p_g24_receive_packet_start
+
+
+
+
+
+
+
 
 
 
+
+// enter test mode to send carrier
+p_test_dispatch:
+	rtnmark0 mark_test_24g
+
+
+p_test_tx_new_param:
+	fetcht 1,mem_test_ch
+//	increase -1,temp
+	call set_sync_on
+	call p_set_freq_tx
+	call le_enable
+	set1 TXGFSK,radio_ctrl
+	enable encode_fec0
+	enable is_tx
+	disable is_rx
+	call le_wait_tx
+	arg mem_24g_common_temp,contw
+	setarg 0x20
+	hstore 1,0x8908
+	arg 24,loopcnt
+	arg mem_24g_common_temp,contr
+
+	branch p_pnloop_stable
+p_pnloop_stable:
+	ifetch 1,contr
+	inject mod,8
+	loop p_pnloop_stable
+	call  p_shutdown_radio
+	rtn	
+
+p_g24_receive_packet_noise:
+	call le_enable
+	fetch 4,mem_24g_addr
+	iforce access
+	call set_sync_on
+	fetcht 1,mem_24g_ch
+	call set_freq_rx
+	call rf_rx_enable
+p_g24_receive_rxon_noise:
+	call p_g24_prep
+	enable decode_fec0	
+	enable is_rx
+	disable is_tx
+	enable swfine
+	setarg 0x0c		//1us
+	iforce stop_watch
+	correlate null,timeout
+	nbranch p_g24_sync_timeout,sync
 	
+	branch p_g24_end_of_packet
+ 
 
+p_gpio15_low_high:
+	call p_gpio15_low
+	branch p_gpio15_high
 
+p_gpio15_low_high_low_high_low:
+	call p_gpio15_low
+	call p_gpio15_high
+	call p_gpio15_low
+	call p_gpio15_high
+	branch p_gpio15_low
 
+p_gpio15_low_high_low:
+	call p_gpio15_low
+	call p_gpio15_high
+	branch p_gpio15_low
 
+p_gpio15_high_low_high:
+	call p_gpio15_high
+	call p_gpio15_low
+	branch p_gpio15_high
 
 
 
+p_gpio15_high_low:
+	call p_gpio15_high
+	branch p_gpio15_low
+
+
+p_gpio15_high:
+	arg 15,temp
+	branch gpio_out_inactive
+
+p_gpio15_init:
+	arg 15,temp
+	call gpio_config_output
+p_gpio15_low:
+	arg 15,temp
+	branch gpio_out_active
+
+
+p_gpio22_low_high_low:
+	call p_gpio22_low
+	call p_gpio22_high
+	branch p_gpio22_low
+
+
 
-p_g24_dispatch:
-	rtnmark0 mark_24g_rx
-	branch p_g24_receive_packet_start
 	
+p_gpio22_high:
+	arg 22,temp
+	branch gpio_out_inactive
+
+p_gpio22_init:
+	arg 22,temp
+	call gpio_config_output
+p_gpio22_low:
+	arg 22,temp
+	branch gpio_out_active
+
+//temp [5:0]=GPIO number, 0-47, [7]=0, low active. set gpio to inactive state
+gpio_out_inactive:
+	sub temp,UI_BUTTON_GPIO_DISABLE,null
+	rtn zero
+	isolate1 gpio_active_bit,null
+	branch gpio_out_flag
+
+gpio_config_output:
+gpio_out_active:
+	sub temp,UI_BUTTON_GPIO_DISABLE,null
+	rtn zero
+	isolate0 gpio_active_bit,null
+
+//temp is gpio number,  [7]=1,set out equa true flag if gpio active
+gpio_out_flag:
+	setarg 0
+	nsetflag true,gpio_active_bit,pdata
+	ixor temp,temp
+
+//temp is gpio number,0-47, [7]=out bit value
+gpio_out:
+	call gpio_addr
+	setarg gpcfg_output_high
+	isolate1 gpio_active_bit,temp
+	setflag true,0,pdata
+	branch gpio_write
+gpio_write:
+	istore 1,contw
+	arg 0x00,addhi
+	//call p_m0_enter_lpm
+	rtn
+p_m0_enter_lpm:
+	call p_m0_disable_wakeup
+	jam SYS_ENTER_LPM,0x4ff0
+	branch p_lpm_wait_m0
+
+p_lpm_wait_m0:
+	fetch 1,0x4ff1
+	bne SYS_LPM_ACK,p_lpm_wait_m0
+	rtn
+	
+p_m0_disable_wakeup:
+	arg 0x0,addhi
+	fetch 1,core_config
+	set0 7,pdata
+	store 1,core_config		//m0 enable wakeup
+	rtn
+gpio_addr:
+	call p_m0_wakeup
+	arg 0x0f,addhi
+	and temp,0x3f,pdata
+	arg sec_gpio_conf,contw
+	iadd contw,contw
+	rtn
+
+p_m0_wakeup:
+	arg 0x0,addhi
+	fetch 1,core_config
+	set1 7,pdata
+	store 1,core_config		//m0 enable wakeup
+	rtn
+
+ 
 
 
 p_keyboard_ble_init:
@@ -1382,11 +1752,65 @@
 
 p_le_parse_l2cap:
 	ifetch 2,contr
-	beq LE_L2CAP_CID_ATT,le_parse_att
+	beq LE_L2CAP_CID_ATT,p_le_parse_att
 	beq LE_L2CAP_CID_SMP,le_parse_smp
 	beq LE_L2CAP_CID_SIGNAL,le_parse_signaling
 	rtn
 
+p_le_parse_att:
+	ifetch 3,contr
+	store 3,mem_le_att_opcode
+//	beq ATTOP_READ_BLOB_REQUEST,p_le_parse_att_read_blob_request
+	beq ATTOP_READ_REQUEST,p_le_parse_att_read_request
+	branch le_parse_att+2
+
+	
+p_le_parse_att_read_request:
+	fetcht 2,mem_le_att_handle
+	fetch 1,mem_le_configuration
+	bbit1 BIT_BLE_READ_AUTH,p_le_send_att_read_response_check_auth
+	branch p_le_send_att_read_response
+p_le_send_att_read_response_check_auth:
+	fetch 2,mem_le_pairing_handle
+	isub temp,null
+	nbranch p_le_send_att_read_response,zero
+//le_send_att_read_response_error_insufficient_auth:
+	call le_check_encrypt_state
+	nbranch p_le_send_att_read_response,user
+	jam ATT_ERR_INSUFFICIENT_AUTHENTICATION,mem_le_err_code
+	branch le_send_att_error_response
+p_le_send_att_read_response:
+	call le_att_get_handle_ptr
+	branch le_send_att_error_response_notfound,blank
+	increase -2,contr
+	ifetch 2,contr
+	arg UUID_CHRCTR_DEVICE_NAME,temp
+	isub temp,null
+	branch le_send_device_name,zero
+	ifetch 1,contr
+	copy contr,regc
+	fetcht 1,mem_le_local_mtu
+	
+	isub temp,null
+	nbranch p_le_send_att_read_response_less,positive
+	
+	fetch 1,mem_le_local_mtu
+	
+p_le_send_att_read_response_less:
+	copy regc,contr
+	copy pdata,regc
+	call store_contr
+	add regc,1,rega
+	call le_fifo_malloc_tx_l2cap_gatt
+	setarg ATTOP_READ_RESPONSE
+	istore 1,contw
+	copy regc,loopcnt
+	call get_contr
+	branch memcpy
+
+	
+p_le_parse_att_read_blob_request:
+	
 /*
 	½âÃÜ´íÎó²»½âÎöµÄÎÊÌâ
 */
@@ -1423,7 +1847,7 @@
 
 p_module_hci_event_enc_info:
 	jam HCI_EVENT_BLE_ENC_INFO,mem_module_uart_opcode
-	setarg 28
+	setarg 29
 	call module_hci_prepare_tx
 	fetch 6,mem_le_lap
 	istore 6,contwu
@@ -1432,6 +1856,8 @@
 	arg mem_le_ltk,contr
 	arg 16,loopcnt
 	call uart_copy_tx_bytes
+	fetch 1,mem_le_conn_peer_addr_type
+	istore 1,contwu
 	branch uartd_send
 
 
@@ -1503,8 +1929,8 @@
 	call module_hci_event_enter_standby_mode_len0
 	jam APP_HANDSHAKE_DONE,mem_app_handshake_flag
 //	call app_lpm_mult_enable
-	call keyboard_stop_bluetooth_discovery
-	branch app_bt_enter_sniff
+	branch keyboard_stop_bluetooth_discovery
+	
 
 classic_shutter_process_reconnect_page_timeout:
 	branch classic_shutter_process_reconnect_failed
@@ -1524,7 +1950,7 @@
 	branch p_module_hci_event_bt_enc_info
 p_module_hci_event_bt_enc_info:
 	jam HCI_EVENT_BT_ENC_INFO,mem_module_uart_opcode
-	setarg 28
+	setarg 29
 	call module_hci_prepare_tx
 	fetch 6,mem_lap
 	istore 6,contwu
@@ -1533,6 +1959,8 @@
 	arg mem_link_key,contr
 	arg 16,loopcnt
 	call uart_copy_tx_bytes
+	setarg 0x00
+	istore 1,contwu
 	branch uartd_send
 
 
@@ -1568,8 +1996,10 @@
 
 
 bt_keyboard_send_hid_data:
-	call l2cap_malloc_is_fifo_nearly_full
+	call p_gpio15_low_high_low
+	call l2cap_malloc_is_fifo_full
 	nrtn blank
+	call p_gpio15_low_high_low
 	fetch 1,mem_module_uart_len
 	add pdata,1,rega
 	call hid_malloc_tx_buff
@@ -1597,6 +2027,170 @@
 	branch module_hci_event_receive_valid_cmd
 
 
+p_module_hci_cmd_set_db_start:
+
+	copy contru,regc
+
+	fetch 1,mem_module_uart_len
+	copy pdata,loopcnt 
+	fetcht 2,mem_module_bt_ptr
+	
+	fetch 2,mem_ui_uuid_table
+	iadd temp,contw
+
+	copy regc,contru
+	call uart_copy_rx_bytes
+	copy contw,pdata
+	fetcht 2,mem_module_bt_ptr
+	fetch 1,mem_module_uart_len
+	iadd temp,pdata
+	store 2,mem_module_bt_ptr
+
+	branch module_hci_event_receive_valid_cmd
+
+
+
+p_module_hci_cmd_cancel_reconn:
+	call app_bt_reconnect_cancel
+	branch module_hci_event_receive_valid_cmd
+	
+/*
+p_hid_malloc_tx_buff:
+	call hid_malloc
+	copy rega,temp
+	storet 1,mem_ui_data_txbuff_length
+	copy pdata,contw
+	copy rega,pdata
+	istore 2,contw //hid payload length
+	rtn
+
+hid_malloc:
+	
+	arg 0,regb
+	call hid_malloc_is_fifo_full
+	nbranch assert,blank//assert when fifo full
+	call hid_malloc_get_full_map
+
+	arg mem_tx_buff0,regB//pbuff = buff0;
+	arg 0,queue // i = 0;
+hid_malloc_loop:
+	fetcht 1,mem_used_map
+	qisolate1 temp
+	branch hid_malloc_next,true//if(1 == (used_map & (1 << i)))goto next;
+	call hid_malloc_enough
+	sub timeup,0,null// (0 - timeup)
+	branch hid_malloc_next,positive//if(buff_cnt <= 0)goto next;
+	call hid_malloc_into_fifo
+	branch hid_malloc_rtn//return (pbuff);
+hid_malloc_next:
+	increase 32,regB//pbuff += BUFF_SIZE;//point to next buff
+	increase 1,queue
+	setarg 8//BUFF_MAX_COUNT
+	isub queue,null //BUFF_MAX_COUNT - i
+	branch hid_malloc_loop,positive//while(i < buff_max_count)
+	arg 0,regB//return NULL
+hid_malloc_rtn:
+	copy regB,pdata
+	branch assert,blank
+	rtn//return pointer via pdatah
+	
+	
+hid_malloc_is_fifo_full:
+	fetch 3,mem_tx_fifo0_new
+	rtn
+
+
+hid_malloc_is_fifo_nearly_full:
+	fetch 3,mem_tx_fifo1_new
+	rtn
+
+hid_malloc_is_fifo_empty:
+	fetch 3,mem_tx_fifo8_new
+	rtn
+
+
+	
+hid_malloc_get_full_map:
+	arg 8,loopcnt
+	arg mem_tx_fifo0_map_new,contr
+	arg 0,temp
+hid_malloc_get_full_map_loop:	
+	ifetch 3,contr
+	and pdata,0xff,pdata
+	ior temp,temp
+	loop hid_malloc_get_full_map_loop
+	storet 1,mem_used_map
+	rtn	
+
+
+
+hid_malloc_enough:
+	call hid_malloc_get_full_map
+	copy queue,regC//restore buff_index to regC
+	arg 0,temp
+	arg 0,timeup//default return val
+	//increase 1,queue
+hid_malloc_enough_loop:
+	copy queue,pdata
+	beq 8,hid_malloc_enough_end
+	fetch 1,mem_used_map
+	qisolate1 pdata
+	branch hid_malloc_enough_end,true
+	increase 32,temp
+	increase 1,queue
+	copy regA,pdata
+	isub temp,null
+	branch hid_malloc_enough_end,zero//(max_size_fom_buff_index ==  len)
+	branch hid_malloc_enough_loop,positive//(max_size_fom_buff_index <  len)
+hid_malloc_enough_end:
+	copy temp,pdata
+	isub regA,null
+	nbranch l2cap_malloc_enough_rtn,positive// max_size_fom_buff_index - len > 0
+	copy queue,pdata//i
+	copy regC,temp//buff_index
+	isub temp,timeup//return (i - buff_index)
+hid_malloc_enough_rtn:
+	copy regC,queue//restore buff_index to queue
+	rtn
+
+hid_malloc_into_fifo:
+	call hid_malloc_is_fifo_full
+	nbranch assert,blank //fifo full
+	call hid_malloc_is_fifo_empty
+	branch hid_malloc_into_fifo_no_push,blank//fifo empty, no need to push
+	fetch 3,mem_tx_fifo1_new
+	store 3,mem_tx_fifo0_new
+	ifetch 3,contr//mem_tx_fifo2
+	istore 3,contw//mem_tx_fifo1
+	ifetch 3,contr//mem_tx_fifo3
+	istore 3,contw//mem_tx_fifo2
+	ifetch 3,contr//mem_tx_fifo4
+	istore 3,contw//mem_tx_fifo3
+	ifetch 3,contr//mem_tx_fifo5
+	istore 3,contw//mem_tx_fifo4
+	ifetch 3,contr//mem_tx_fifo6
+	istore 3,contw//mem_tx_fifo5
+	ifetch 3,contr//mem_tx_fifo7
+	istore 3,contw//mem_tx_fifo6
+	ifetch 3,contr//mem_tx_fifo8
+	istore 3,contw//mem_tx_fifo7
+	setarg 0
+	istore 3,contw//mem_tx_fifo8
+hid_malloc_into_fifo_no_push:
+	arg 0,temp
+	copy timeup,pdata
+	iadd queue,pdata
+hid_malloc_into_fifo_loop:
+	qset1 temp//fifo->map |= 1 << i;
+	increase 1,queue
+	isub queue,null
+	nbranch hid_malloc_into_fifo_loop,zero
+	//map in temp
+	lshift8 regB,pdata
+	ior temp,pdata
+	store 3,mem_tx_fifo8_new
+	rtn
+*/
 /*
 	bt hid patch bugfix
 */
@@ -1615,17 +2209,20 @@
 	rtn
 
 p_hid_rx_process_data:
-	ifetch 2,contr
-	store 2,mem_pdatatemp
-	beq HID_REPORT_ID_KB,p_hid_rx_process_data_hid_kb	
-	rtn
 
 p_hid_rx_process_data_hid_kb:
+
 	jam HCI_EVENT_RECEIVE_BT_HID_DATA,mem_module_uart_opcode
-	setarg 2
+	fetch 1,mem_l2cap_rx_pkt_length
+	pincrease -1
 	call module_hci_prepare_tx	
-	fetch 2,mem_pdatatemp
-	istore 2,contwu
+	fetch 1,mem_l2cap_rx_pkt_length
+	pincrease -1
+	copy pdata,loopcnt
+	fetch 2,mem_l2cap_payload_ptr
+	increase 1,pdata
+	copy pdata,contr
+	call uart_copy_tx_bytes
 	branch uartd_send
 
 p_hid_rx_process_set_report:
Index: rongyuan/program_patch/keyboard_24g_spec_code/patch_24g.prog
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/program_patch/keyboard_24g_spec_code/patch_24g.prog	(revision 932)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/program_patch/keyboard_24g_spec_code/patch_24g.prog	(working copy)
@@ -10,43 +10,54 @@
 	branch shutdown_radio
 
 p_module_hci_cmd_set_24g_tx:
+	
 	set0 mark_24g_rx,mark
-	call module_hci_event_receive_valid_cmd
+//	call module_hci_event_receive_valid_cmd
+	
 	branch p_g24_transmit_packet
 
+
 p_module_hci_cmd_set_24g_rx:
 	set1 mark_24g_rx,mark
-	call p_g24_receive_rxon
-	
-	branch module_hci_event_receive_valid_cmd
+//	call p_g24_receive_rxon
+	rtn
+//	branch module_hci_event_receive_valid_cmd
 
 //function : tx copy 24gdata into buffer waiting for enable is_tx
 p_module_hci_cmd_send_24g_data:
+
 	fetch 1,mem_module_uart_len
 	copy pdata,loopcnt
 	store 1,mem_24g_txpayload
 	arg mem_24g_txpayload+1,contw
-	call uart_copy_rx_bytes
-	branch module_hci_event_receive_valid_cmd
+	branch uart_copy_rx_bytes
+//	branch module_hci_event_receive_valid_cmd
+
+	
 //function : set  tx power
 p_module_hci_cmd_set_txpower:
 	ifetch 1,contru
 	store 1,mem_tx_power
-	call shutdown_radio
-	call set_freq_tx
-	branch module_hci_event_receive_valid_cmd
+	rtn
+	jam 1,mem_24g_pll_flag
+//	call shutdown_radio
+//	branch set_freq_tx
+//	branch module_hci_event_receive_valid_cmd
 
 
 p_module_hci_cmd_set_24g_channel:
 	ifetch 1,contru
 	store 1,mem_24g_ch
-	
-	branch module_hci_event_receive_valid_cmd
+	jam 1,mem_24g_pll_flag
+	rtn
+//	call shutdown_radio
+//	branch set_freq_tx	
+//	branch module_hci_event_receive_valid_cmd
 p_module_hci_cmd_set_24g_addr:	
 	ifetch 4,contru
 	store 4,mem_24g_addr
-	call p_g24_update_addr_and_synccrc8
-	branch module_hci_event_receive_valid_cmd	
+	branch p_g24_update_addr_and_synccrc8
+//	branch module_hci_event_receive_valid_cmd	
 	
 // calculate crc8
 p_g24_update_addr_and_synccrc8:	
@@ -74,26 +85,65 @@
 	copy pdata,loopcnt
 	store 1,mem_24g_ackbuffer
 	arg mem_24g_ackbuffer+1,contw
-	call uart_copy_rx_bytes
-	branch module_hci_event_receive_valid_cmd
+	branch uart_copy_rx_bytes
+//	branch module_hci_event_receive_valid_cmd
 	
 
 
 p_module_hci_cmd_24g_set_retransmit_time:
+
 //first byte 24g retransmit cnt  second byte 24g receive ack time
 	ifetch 1,contru
 	store 1,mem_24g_retransmit_cnt
 	ifetch 1,contru
 	mul32 pdata,120,pdata
 	store 2,mem_24g_rx_window
+	rtn
 	branch module_hci_event_receive_valid_cmd
 
 p_module_hci_cmd_set_no_ack:
 // 0: without ack 1"with ack
 	ifetch 1,contru
 	store 1,mem_24g_no_ack
+	rtn
 	branch module_hci_event_receive_valid_cmd
 
+
+
+p_module_hci_cmd_set_noise_rssi:
+	rtnmark0 mark_24g_rx
+	call p_g24_receive_packet_noise
+//	hfetch 1,rf_agc_ctrl
+//	set0 7,pdata
+//	hstore 1,rf_agc_ctrl
+	setarg HCI_CMD_24G_GET_NOISE
+	arg 1,rega
+	arg mem_rssi,regb
+	arg 0,temp
+	branch module_hci_event_set_cmd+1
+
+
+
+
+
+
+
+//-----------------------------------------------------------TEST MODE--------------------------------------------------------------------------------
+//----------------------------------------------------------------------------------------------------------------------------------------------------------------------
+//----------------------------------------------------------------------------------------------------------------------------------------------------------------------
+p_module_hci_cmd_set_test:
+// 0: without test mode  1: with test mode 
+	ifetch 1,contru
+	beq 1,p_module_hci_cmd_set_test_valid
+	set0 mark_test_24g,mark
+	branch module_hci_event_receive_valid_cmd
+p_module_hci_cmd_set_test_valid:
+	ifetch 1,contru
+	store 1,mem_test_ch
+	ifetch 1,contru
+	store 1,mem_tx_power
+	set1 mark_test_24g,mark
+	branch module_hci_event_receive_valid_cmd
 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------
 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
@@ -109,7 +159,7 @@
 	rshift temp,white_init
 	rtn
 p_g24_sync_timeout:
-//	call p_rssi_noise
+	call save_rssi
 //	branch p_g24_end_of_packet
 p_g24_end_of_packet:
 	disable encode_fec1
@@ -123,6 +173,7 @@
 	disable enable_white
 	until null,tx_clear
 	nop 100          /* flush out the last bit */
+	
 	rtn
 
 
@@ -132,14 +183,23 @@
 p_g24_set_freq_tx:
 	call set_sync_on
 	fetcht 1,mem_24g_ch
-	branch set_freq_tx
+	branch p_set_freq_tx
+//	storet 1,mem_last_freq
+//	call set_freq_tx_offset
+//	call rf_write_freq
+//	fetch 1,mem_24g_pll_flag
+//	branch p_txon,blank
+//	setarg param_pll_setup
+//	call sleep	
+//	jam 0,mem_24g_pll_flag
+//	branch p_txon
 p_g24_transmit:
+	
 	call le_enable
 	fetch 4,mem_24g_addr
 	iforce access
 	call p_g24_prep
 	call p_g24_set_freq_tx
-	
 	set1 TXGFSK,radio_ctrl
 	enable encode_fec0
 	enable is_tx
@@ -148,10 +208,11 @@
 	rshift8 pdata,pdata
 	rshift4 pdata,pdata
 	inject mod,40
-	disable encode_fec0
-	enable encode_fec1
+//	disable encode_fec0
+//	enable encode_fec1
 	enable enable_white
 	enable enable_crc
+	
 	fetch 1,mem_24g_syncword_crc8
 	inject mod,8
 	fetch 1,mem_24g_txbuf		//first byte txpayload len
@@ -170,6 +231,7 @@
 	nop 100
 	disable encode_fec0
 	disable encode_fec1
+	
 	rtn
 	
 
@@ -181,20 +243,23 @@
 p_g24_transmit_packet:
 	jam 0,mem_24g_retry
 p_g24_transmit_loop:
+
 //	arg param_rx_setup,timeup
 //	until clkn_rt,meet
 	call p_g24_transmit_receive_ack			//if receive ack won't enter retransmit and report ack data
 	nbranch p_g24_retransmit,user3
+	
 	call p_g24_evt_receive_packet_report
 p_g24_transmit_abandon:
 	call p_g24_rx_interrupt_clear
-	setarg 0
-	store 2,mem_24g_txfail_cnt
+	jam 0,mem_24g_send_flag
 	rtn	
 
 p_g24_retransmit:
-	fetch 2,mem_24g_txfail_cnt
-	sub pdata,0x5,null
+	fetch 1,mem_24g_retransmit_cnt
+	fetcht 1,mem_24g_retry
+	isub temp,null
+	branch p_g24_evt_send_data_failed,zero
 	nbranch p_g24_evt_send_data_failed,positive
 
 	fetch 1,mem_24g_retry
@@ -216,6 +281,7 @@
 p_g24_transmit_receive_ack:
 	disable user3
 	call p_g24_data_transmit_prep
+	
 	call p_g24_transmit
 	fetch 1,mem_24g_no_ack
 	beq no_ack_24g,p_g24_transmit_no_ack	//tx no ack
@@ -223,9 +289,12 @@
 	fetch 4,mem_24g_addr
 	iforce access
 	fetcht 1,mem_last_freq
+	
 	call set_freq_rx
 	call rf_rx_enable
+	
 	call p_g24_receive_rxon
+	
 	call p_g24_end_of_packet,user3
 	rtn
 p_g24_transmit_no_ack:
@@ -239,14 +308,15 @@
 /////////////////////////////////////////////////////////////            24G RX DISPATCH           ////////////////////////////////////////////////////////////////		
 //processing for pll time and 24g channel&addr
 p_g24_receive_packet:
+	
 	call le_enable
 	fetch 4,mem_24g_addr
 	iforce access
 	call set_sync_on
 	fetcht 1,mem_24g_ch
 	call set_freq_rx
-	setarg param_pll_setup		//if changing the channel must waiting for pll time 
-	call sleep
+//	setarg param_pll_setup		//if changing the channel must waiting for pll time 
+//	call sleep
 	call rf_rx_enable
 p_g24_receive_rxon:
 	call p_g24_prep
@@ -258,8 +328,8 @@
 	iforce stop_watch
 	correlate null,timeout
 	nbranch p_g24_sync_timeout,sync
-	disable decode_fec0
-	enable decode_fec1
+//	disable decode_fec0
+//	enable decode_fec1
 	enable enable_white
 	enable enable_crc
 	parse demod,bucket,8
@@ -286,7 +356,7 @@
 	rshift32 pdata,pdata
 	rshift16 pdata,pdata
 	istore 3,contw
-	disable decode_fec1
+//	disable decode_fec1
 	branch p_g24_end_of_packet,crc_failed
 	enable user3
 	fetch 1,mem_last_freq
@@ -294,9 +364,9 @@
 	call rf_write_freq
 	disable decode_fec0
 	call set_sync_on
-	fetch 1,mem_rssi_hex_received
-	copy pdata,rega
-	call p_rssi_signal
+//	fetch 1,mem_rssi_hex_received
+//	copy pdata,rega
+//	call p_rssi_signal
 	rtn
 
 
@@ -322,7 +392,7 @@
 p_g24tx_with_ack:
 	call p_g24_ackpayload_prep
 	call p_g24_transmit
-	call p_g24_rx_interrupt_clear
+
 	branch p_g24_end_of_packet
 
 
@@ -347,21 +417,25 @@
 //-----------------------------------------------------------------------------G24 EVT----------------------------------------------------------------------
 //---------------------------------------------------------------------------------------------------------------------------------------------------------------
 p_g24_evt_send_data_failed:
+	
 	jam HCI_EVNET_SEND_DATA_FAIL,mem_module_uart_opcode
 	setarg 0
 	call module_hci_prepare_tx
-
 	branch uartd_send
+	
 p_g24_evt_receive_packet_report:
+	
 	jam HCI_EVENT_RECEIVE_24G_DATA,mem_module_uart_opcode
 	fetch 1,mem_24g_rxbuf
 	and pdata,0x1f,loopcnt	//max payload: 32bytes
-	rtn blank
+	
 	copy pdata,loopcnt
 	call module_hci_prepare_tx
 	arg mem_24g_rxbuf+1,contr
 	call uart_copy_tx_bytes
-	branch uartd_send
+	branch  uartd_send
+	
+
 	
 	
 p_rssi_signal:
@@ -393,19 +467,192 @@
 	rtn
 
 
+p_g24_dispatch:
+
+	rtnmark0 mark_24g_rx
+	branch p_g24_receive_packet_start
+
+
+
+
+
 
 
 
+
+
+
+// enter test mode to send carrier
+p_test_dispatch:
+	rtnmark0 mark_test_24g
+
+
+p_test_tx_new_param:
+	fetcht 1,mem_test_ch
+//	increase -1,temp
+	call set_sync_on
+	call p_set_freq_tx
+	call le_enable
+	set1 TXGFSK,radio_ctrl
+	enable encode_fec0
+	enable is_tx
+	disable is_rx
+	call le_wait_tx
+	arg mem_24g_common_temp,contw
+	setarg 0x20
+	hstore 1,0x8908
+	arg 24,loopcnt
+	arg mem_24g_common_temp,contr
+
+	branch p_pnloop_stable
+p_pnloop_stable:
+	ifetch 1,contr
+	inject mod,8
+	loop p_pnloop_stable
+	call  p_shutdown_radio
+	rtn	
+
+p_g24_receive_packet_noise:
+	call le_enable
+	fetch 4,mem_24g_addr
+	iforce access
+	call set_sync_on
+	fetcht 1,mem_24g_ch
+	call set_freq_rx
+	call rf_rx_enable
+p_g24_receive_rxon_noise:
+	call p_g24_prep
+	enable decode_fec0	
+	enable is_rx
+	disable is_tx
+	enable swfine
+	setarg 0x0c		//1us
+	iforce stop_watch
+	correlate null,timeout
+	nbranch p_g24_sync_timeout,sync
 	
+	branch p_g24_end_of_packet
+ 
 
+p_gpio15_low_high:
+	call p_gpio15_low
+	branch p_gpio15_high
 
+p_gpio15_low_high_low_high_low:
+	call p_gpio15_low
+	call p_gpio15_high
+	call p_gpio15_low
+	call p_gpio15_high
+	branch p_gpio15_low
 
+p_gpio15_low_high_low:
+	call p_gpio15_low
+	call p_gpio15_high
+	branch p_gpio15_low
 
+p_gpio15_high_low_high:
+	call p_gpio15_high
+	call p_gpio15_low
+	branch p_gpio15_high
 
 
 
+p_gpio15_high_low:
+	call p_gpio15_high
+	branch p_gpio15_low
 
-p_g24_dispatch:
-	rtnmark0 mark_24g_rx
-	branch p_g24_receive_packet_start
+
+p_gpio15_high:
+	arg 15,temp
+	branch gpio_out_inactive
+
+p_gpio15_init:
+	arg 15,temp
+	call gpio_config_output
+p_gpio15_low:
+	arg 15,temp
+	branch gpio_out_active
+
+
+p_gpio22_low_high_low:
+	call p_gpio22_low
+	call p_gpio22_high
+	branch p_gpio22_low
+
+
+
+	
+p_gpio22_high:
+	arg 22,temp
+	branch gpio_out_inactive
+
+p_gpio22_init:
+	arg 22,temp
+	call gpio_config_output
+p_gpio22_low:
+	arg 22,temp
+	branch gpio_out_active
+
+//temp [5:0]=GPIO number, 0-47, [7]=0, low active. set gpio to inactive state
+gpio_out_inactive:
+	sub temp,UI_BUTTON_GPIO_DISABLE,null
+	rtn zero
+	isolate1 gpio_active_bit,null
+	branch gpio_out_flag
+
+gpio_config_output:
+gpio_out_active:
+	sub temp,UI_BUTTON_GPIO_DISABLE,null
+	rtn zero
+	isolate0 gpio_active_bit,null
+
+//temp is gpio number,  [7]=1,set out equa true flag if gpio active
+gpio_out_flag:
+	setarg 0
+	nsetflag true,gpio_active_bit,pdata
+	ixor temp,temp
+
+//temp is gpio number,0-47, [7]=out bit value
+gpio_out:
+	call gpio_addr
+	setarg gpcfg_output_high
+	isolate1 gpio_active_bit,temp
+	setflag true,0,pdata
+	branch gpio_write
+gpio_write:
+	istore 1,contw
+	arg 0x00,addhi
+	//call p_m0_enter_lpm
+	rtn
+p_m0_enter_lpm:
+	call p_m0_disable_wakeup
+	jam SYS_ENTER_LPM,0x4ff0
+	branch p_lpm_wait_m0
+
+p_lpm_wait_m0:
+	fetch 1,0x4ff1
+	bne SYS_LPM_ACK,p_lpm_wait_m0
+	rtn
 	
+p_m0_disable_wakeup:
+	arg 0x0,addhi
+	fetch 1,core_config
+	set0 7,pdata
+	store 1,core_config		//m0 enable wakeup
+	rtn
+gpio_addr:
+	call p_m0_wakeup
+	arg 0x0f,addhi
+	and temp,0x3f,pdata
+	arg sec_gpio_conf,contw
+	iadd contw,contw
+	rtn
+
+p_m0_wakeup:
+	arg 0x0,addhi
+	fetch 1,core_config
+	set1 7,pdata
+	store 1,core_config		//m0 enable wakeup
+	rtn
+
+ 
Index: rongyuan/program_patch/keyboard_ble_spec_code/patch_ble.prog
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/program_patch/keyboard_ble_spec_code/patch_ble.prog	(revision 932)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/program_patch/keyboard_ble_spec_code/patch_ble.prog	(working copy)
@@ -70,11 +70,65 @@
 
 p_le_parse_l2cap:
 	ifetch 2,contr
-	beq LE_L2CAP_CID_ATT,le_parse_att
+	beq LE_L2CAP_CID_ATT,p_le_parse_att
 	beq LE_L2CAP_CID_SMP,le_parse_smp
 	beq LE_L2CAP_CID_SIGNAL,le_parse_signaling
 	rtn
 
+p_le_parse_att:
+	ifetch 3,contr
+	store 3,mem_le_att_opcode
+//	beq ATTOP_READ_BLOB_REQUEST,p_le_parse_att_read_blob_request
+	beq ATTOP_READ_REQUEST,p_le_parse_att_read_request
+	branch le_parse_att+2
+
+	
+p_le_parse_att_read_request:
+	fetcht 2,mem_le_att_handle
+	fetch 1,mem_le_configuration
+	bbit1 BIT_BLE_READ_AUTH,p_le_send_att_read_response_check_auth
+	branch p_le_send_att_read_response
+p_le_send_att_read_response_check_auth:
+	fetch 2,mem_le_pairing_handle
+	isub temp,null
+	nbranch p_le_send_att_read_response,zero
+//le_send_att_read_response_error_insufficient_auth:
+	call le_check_encrypt_state
+	nbranch p_le_send_att_read_response,user
+	jam ATT_ERR_INSUFFICIENT_AUTHENTICATION,mem_le_err_code
+	branch le_send_att_error_response
+p_le_send_att_read_response:
+	call le_att_get_handle_ptr
+	branch le_send_att_error_response_notfound,blank
+	increase -2,contr
+	ifetch 2,contr
+	arg UUID_CHRCTR_DEVICE_NAME,temp
+	isub temp,null
+	branch le_send_device_name,zero
+	ifetch 1,contr
+	copy contr,regc
+	fetcht 1,mem_le_local_mtu
+	
+	isub temp,null
+	nbranch p_le_send_att_read_response_less,positive
+	
+	fetch 1,mem_le_local_mtu
+	
+p_le_send_att_read_response_less:
+	copy regc,contr
+	copy pdata,regc
+	call store_contr
+	add regc,1,rega
+	call le_fifo_malloc_tx_l2cap_gatt
+	setarg ATTOP_READ_RESPONSE
+	istore 1,contw
+	copy regc,loopcnt
+	call get_contr
+	branch memcpy
+
+	
+p_le_parse_att_read_blob_request:
+	
 /*
 	½âÃÜ´íÎó²»½âÎöµÄÎÊÌâ
 */
Index: rongyuan/program_patch/keyboard_ble_spec_code/patch_ble_event_deal.prog
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/program_patch/keyboard_ble_spec_code/patch_ble_event_deal.prog	(revision 932)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/program_patch/keyboard_ble_spec_code/patch_ble_event_deal.prog	(working copy)
@@ -9,7 +9,7 @@
 
 p_module_hci_event_enc_info:
 	jam HCI_EVENT_BLE_ENC_INFO,mem_module_uart_opcode
-	setarg 28
+	setarg 29
 	call module_hci_prepare_tx
 	fetch 6,mem_le_lap
 	istore 6,contwu
@@ -18,5 +18,7 @@
 	arg mem_le_ltk,contr
 	arg 16,loopcnt
 	call uart_copy_tx_bytes
+	fetch 1,mem_le_conn_peer_addr_type
+	istore 1,contwu
 	branch uartd_send
 
Index: rongyuan/program_patch/keyboard_bt_spec_code/patch_bt_event_deal.prog
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/program_patch/keyboard_bt_spec_code/patch_bt_event_deal.prog	(revision 932)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/program_patch/keyboard_bt_spec_code/patch_bt_event_deal.prog	(working copy)
@@ -67,8 +67,8 @@
 	call module_hci_event_enter_standby_mode_len0
 	jam APP_HANDSHAKE_DONE,mem_app_handshake_flag
 //	call app_lpm_mult_enable
-	call keyboard_stop_bluetooth_discovery
-	branch app_bt_enter_sniff
+	branch keyboard_stop_bluetooth_discovery
+	
 
 classic_shutter_process_reconnect_page_timeout:
 	branch classic_shutter_process_reconnect_failed
@@ -88,7 +88,7 @@
 	branch p_module_hci_event_bt_enc_info
 p_module_hci_event_bt_enc_info:
 	jam HCI_EVENT_BT_ENC_INFO,mem_module_uart_opcode
-	setarg 28
+	setarg 29
 	call module_hci_prepare_tx
 	fetch 6,mem_lap
 	istore 6,contwu
@@ -97,6 +97,8 @@
 	arg mem_link_key,contr
 	arg 16,loopcnt
 	call uart_copy_tx_bytes
+	setarg 0x00
+	istore 1,contwu
 	branch uartd_send
 
 
@@ -132,8 +134,10 @@
 
 
 bt_keyboard_send_hid_data:
-	call l2cap_malloc_is_fifo_nearly_full
+	call p_gpio15_low_high_low
+	call l2cap_malloc_is_fifo_full
 	nrtn blank
+	call p_gpio15_low_high_low
 	fetch 1,mem_module_uart_len
 	add pdata,1,rega
 	call hid_malloc_tx_buff
@@ -160,3 +164,168 @@
 	call app_bt_start_reconnect
 	branch module_hci_event_receive_valid_cmd
 
+
+p_module_hci_cmd_set_db_start:
+
+	copy contru,regc
+
+	fetch 1,mem_module_uart_len
+	copy pdata,loopcnt 
+	fetcht 2,mem_module_bt_ptr
+	
+	fetch 2,mem_ui_uuid_table
+	iadd temp,contw
+
+	copy regc,contru
+	call uart_copy_rx_bytes
+	copy contw,pdata
+	fetcht 2,mem_module_bt_ptr
+	fetch 1,mem_module_uart_len
+	iadd temp,pdata
+	store 2,mem_module_bt_ptr
+
+	branch module_hci_event_receive_valid_cmd
+
+
+
+p_module_hci_cmd_cancel_reconn:
+	call app_bt_reconnect_cancel
+	branch module_hci_event_receive_valid_cmd
+	
+/*
+p_hid_malloc_tx_buff:
+	call hid_malloc
+	copy rega,temp
+	storet 1,mem_ui_data_txbuff_length
+	copy pdata,contw
+	copy rega,pdata
+	istore 2,contw //hid payload length
+	rtn
+
+hid_malloc:
+	
+	arg 0,regb
+	call hid_malloc_is_fifo_full
+	nbranch assert,blank//assert when fifo full
+	call hid_malloc_get_full_map
+
+	arg mem_tx_buff0,regB//pbuff = buff0;
+	arg 0,queue // i = 0;
+hid_malloc_loop:
+	fetcht 1,mem_used_map
+	qisolate1 temp
+	branch hid_malloc_next,true//if(1 == (used_map & (1 << i)))goto next;
+	call hid_malloc_enough
+	sub timeup,0,null// (0 - timeup)
+	branch hid_malloc_next,positive//if(buff_cnt <= 0)goto next;
+	call hid_malloc_into_fifo
+	branch hid_malloc_rtn//return (pbuff);
+hid_malloc_next:
+	increase 32,regB//pbuff += BUFF_SIZE;//point to next buff
+	increase 1,queue
+	setarg 8//BUFF_MAX_COUNT
+	isub queue,null //BUFF_MAX_COUNT - i
+	branch hid_malloc_loop,positive//while(i < buff_max_count)
+	arg 0,regB//return NULL
+hid_malloc_rtn:
+	copy regB,pdata
+	branch assert,blank
+	rtn//return pointer via pdatah
+	
+	
+hid_malloc_is_fifo_full:
+	fetch 3,mem_tx_fifo0_new
+	rtn
+
+
+hid_malloc_is_fifo_nearly_full:
+	fetch 3,mem_tx_fifo1_new
+	rtn
+
+hid_malloc_is_fifo_empty:
+	fetch 3,mem_tx_fifo8_new
+	rtn
+
+
+	
+hid_malloc_get_full_map:
+	arg 8,loopcnt
+	arg mem_tx_fifo0_map_new,contr
+	arg 0,temp
+hid_malloc_get_full_map_loop:	
+	ifetch 3,contr
+	and pdata,0xff,pdata
+	ior temp,temp
+	loop hid_malloc_get_full_map_loop
+	storet 1,mem_used_map
+	rtn	
+
+
+
+hid_malloc_enough:
+	call hid_malloc_get_full_map
+	copy queue,regC//restore buff_index to regC
+	arg 0,temp
+	arg 0,timeup//default return val
+	//increase 1,queue
+hid_malloc_enough_loop:
+	copy queue,pdata
+	beq 8,hid_malloc_enough_end
+	fetch 1,mem_used_map
+	qisolate1 pdata
+	branch hid_malloc_enough_end,true
+	increase 32,temp
+	increase 1,queue
+	copy regA,pdata
+	isub temp,null
+	branch hid_malloc_enough_end,zero//(max_size_fom_buff_index ==  len)
+	branch hid_malloc_enough_loop,positive//(max_size_fom_buff_index <  len)
+hid_malloc_enough_end:
+	copy temp,pdata
+	isub regA,null
+	nbranch l2cap_malloc_enough_rtn,positive// max_size_fom_buff_index - len > 0
+	copy queue,pdata//i
+	copy regC,temp//buff_index
+	isub temp,timeup//return (i - buff_index)
+hid_malloc_enough_rtn:
+	copy regC,queue//restore buff_index to queue
+	rtn
+
+hid_malloc_into_fifo:
+	call hid_malloc_is_fifo_full
+	nbranch assert,blank //fifo full
+	call hid_malloc_is_fifo_empty
+	branch hid_malloc_into_fifo_no_push,blank//fifo empty, no need to push
+	fetch 3,mem_tx_fifo1_new
+	store 3,mem_tx_fifo0_new
+	ifetch 3,contr//mem_tx_fifo2
+	istore 3,contw//mem_tx_fifo1
+	ifetch 3,contr//mem_tx_fifo3
+	istore 3,contw//mem_tx_fifo2
+	ifetch 3,contr//mem_tx_fifo4
+	istore 3,contw//mem_tx_fifo3
+	ifetch 3,contr//mem_tx_fifo5
+	istore 3,contw//mem_tx_fifo4
+	ifetch 3,contr//mem_tx_fifo6
+	istore 3,contw//mem_tx_fifo5
+	ifetch 3,contr//mem_tx_fifo7
+	istore 3,contw//mem_tx_fifo6
+	ifetch 3,contr//mem_tx_fifo8
+	istore 3,contw//mem_tx_fifo7
+	setarg 0
+	istore 3,contw//mem_tx_fifo8
+hid_malloc_into_fifo_no_push:
+	arg 0,temp
+	copy timeup,pdata
+	iadd queue,pdata
+hid_malloc_into_fifo_loop:
+	qset1 temp//fifo->map |= 1 << i;
+	increase 1,queue
+	isub queue,null
+	nbranch hid_malloc_into_fifo_loop,zero
+	//map in temp
+	lshift8 regB,pdata
+	ior temp,pdata
+	store 3,mem_tx_fifo8_new
+	rtn
+*/
\ No newline at end of file
Index: rongyuan/program_patch/keyboard_bt_spec_code/patch_bt_hid.prog
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/program_patch/keyboard_bt_spec_code/patch_bt_hid.prog	(revision 932)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/program_patch/keyboard_bt_spec_code/patch_bt_hid.prog	(working copy)
@@ -17,17 +17,20 @@
 	rtn
 
 p_hid_rx_process_data:
-	ifetch 2,contr
-	store 2,mem_pdatatemp
-	beq HID_REPORT_ID_KB,p_hid_rx_process_data_hid_kb	
-	rtn
 
 p_hid_rx_process_data_hid_kb:
+
 	jam HCI_EVENT_RECEIVE_BT_HID_DATA,mem_module_uart_opcode
-	setarg 2
+	fetch 1,mem_l2cap_rx_pkt_length
+	pincrease -1
 	call module_hci_prepare_tx	
-	fetch 2,mem_pdatatemp
-	istore 2,contwu
+	fetch 1,mem_l2cap_rx_pkt_length
+	pincrease -1
+	copy pdata,loopcnt
+	fetch 2,mem_l2cap_payload_ptr
+	increase 1,pdata
+	copy pdata,contr
+	call uart_copy_tx_bytes
 	branch uartd_send
 
 p_hid_rx_process_set_report:
Index: rongyuan/program_patch/main_patch.prog
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/program_patch/main_patch.prog	(revision 932)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/program_patch/main_patch.prog	(working copy)
@@ -33,7 +33,7 @@
 	beq patch20_6,p_le_transmit
 	beq patch22_3,p_le_acknowledge
 	beq patch23_7,p_le_parse
-	beq patch24_1,p_le_parse_l2cap
+	beq patch24_2,p_le_parse_l2cap
 	beq patch26_0,p_le_modified_name
 	beq patch27_4,p_parse_lmp_accepted
 	beq patch27_2,p_parse_lmp
@@ -78,6 +78,9 @@
 	setarg p_module_bb_event_timer
 	store 2,mem_cb_event_timer
 
+	setarg p_module_process_idle
+	store 2,mem_cb_idle_process
+
 	setarg p_module_le_receive_data
 	store 2,mem_cb_att_write
 
@@ -88,14 +91,48 @@
 	store 2,mem_cb_bt_process
 
 	call p_keyboard_ble_init
-
+	call p_gpio15_init
 	call module_lpm_uart_init
 	call module_gpio_init
 	call check_module_disabled
 	//call p_check_otp_shaomaqiang_app
 	branch module_hci_event_enter_standby_mode
 
+p_module_process_idle:
+	
+	call module_control_air_flow
+	call l2cap_malloc_is_fifo_full
+	nrtn blank
+
+	
+
+p_module_process:
+	fetch 2,IPC_M02BT_READ_PTR
+	fetcht 2,IPC_M02BT_WRITE_PTR
+	isub temp,null
+	rtn,zero	
+	
+	call uartd_prepare_rx
+	ifetch 1,contru
+	bne 0x01,p_module_hci_in_excp
+	
+	ifetch 1,contru
+	store 1,mem_module_uart_opcode
+	ifetcht 1,contru
+	copy contru,rega
+	storet 1,mem_module_uart_len
+	jam HCI_DISCARD_PACKET,mem_module_temp_nl_discard_packet
+	
+	call module_hci_cmd_control
+	
+	fetch 1,mem_module_temp_nl_discard_packet
+	rtneq HCI_NOT_DISCARD_PACKET
+	
+	branch module_hci_dicard_packet //discard this packet
 
+p_module_hci_in_excp:
+	call module_hci_event_invalid_packet
+	branch module_hci_release_except
 p_module_process_bb_event:
 	copy regc,pdata
 /***************classic shutter event****************/
@@ -127,7 +164,7 @@
 
 
 p_module_process_enter_sniff:
-
+	rtn
 p_module_sniff_param_check:
 	call module_spp_clear_last_transmite_clock
 	//fetch 1,mem_context
@@ -209,6 +246,7 @@
 	branch module_spp_enter_sniff+1
 
 p_module_hci_cmd_control:
+	
 	fetch 1,mem_module_uart_opcode
 	beq HCI_CMD_BT_DISCONNECT,p_module_hci_cmd_bt_disconnect
 	beq HCI_CMD_SET_COD,p_module_hci_cmd_set_cod
@@ -225,7 +263,7 @@
 //	beq HCI_CMD_ADD_CHARACTERISTIC_UUID,module_hci_cmd_add_characteristic_uuid
 
 	beq HCI_CMD_ADD_SERVICE_CHARAC_UUID,p_module_hci_cmd_add_service_charactisic
-
+	beq HCI_CMD_LE_SET_ADV_DATA,p_module_hci_cmd_le_set_adv_data
 	beq HCI_CMD_SEND_24G_DATA,p_module_hci_cmd_send_24g_data
 	beq HCI_CMD_24G_RFENABLE,p_module_hci_cmd_24g_rfenable
 	beq HCI_CMD_24G_TX,p_module_hci_cmd_set_24g_tx
@@ -236,6 +274,13 @@
 	beq HCI_CMD_24G_SET_ACKDATA,p_module_hci_cmd_24g_send_ack_prep
 	beq HCI_CMD_24G_SET_RETRAN_TIME,p_module_hci_cmd_24g_set_retransmit_time
 	beq HCI_CMD_24G_NO_ACK_FLAG,p_module_hci_cmd_set_no_ack
+	beq HCI_CMD_TEST_MODE,p_module_hci_cmd_set_test
+	beq HCI_CMD_24G_GET_NOISE,p_module_hci_cmd_set_noise_rssi
+	beq HCI_CMD_SET_DB_START,p_module_hci_cmd_set_db_start
+	beq HCI_CMD_CANCEL_BT_RECONN,p_module_hci_cmd_cancel_reconn
+
+//	beq HCI_CMD_SET_CRSTAL,
+	
 	branch module_hci_cmd_control + 2
 
 p_module_hci_cmd_add_service_charactisic:
@@ -381,7 +426,7 @@
 	beq ADV_IND,app_ble_start_adv
 	beq ADV_DIRECT_IND,app_ble_start_direct_adv
 	beq ADV_NONCONN_IND,app_ble_start_unconn_adv
-
+	rtn
 
 p_module_hci_cmd_adv_data_change:
 	ifetch 1,contru
@@ -421,8 +466,9 @@
 	call memcpy_fast
 	branch module_hci_event_receive_valid_cmd	
 
-
-
+p_module_hci_cmd_le_set_adv_data:
+	jam ADV_IND,mem_le_adv_type
+	branch module_hci_cmd_le_set_adv_data
 	
 p_module_hci_cmd_bt_disconnect:
 	fetch 2,mem_ui_state_map
@@ -536,6 +582,7 @@
 	branch reject_lmp_packet
 
 p_parse_lmp_sniff_req:
+	branch lmp_reject_sniff
 	fetch 2,mem_rxbuf+6
 	branch lmp_reject_sniff,blank
 	//call parse_lmp_sniff_req_check_sniff_para
Index: rongyuan/program_patch/patch_chip_common_bugfix.prog
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/program_patch/patch_chip_common_bugfix.prog	(revision 932)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/program_patch/patch_chip_common_bugfix.prog	(working copy)
@@ -56,9 +56,29 @@
 	branch ui_timer_init
 
 p_main_loop:
+
+	call p_module_hci_cmd_set_noise_rssi
+
+	call p_test_dispatch
+
 	call p_g24_dispatch
+
 	branch main_loop+1
 
+p_le_dispatch:
+	//call le_scan
+	branch  le_adv
+p_app_process_idle:
+
+	call ui_dispatch
+	
+	call check_51cmd
+	
+	call app_process_bb_event
+	
+	fetch 2,mem_cb_idle_process
+	branch callback_func
+
 /*
 	YC3121 shutdown radio bugfix
 	rfen_adc bug ÌÕÆäÎÄÌí¼Ó
@@ -120,15 +140,71 @@
 	call set_freq_tx_offset
 	call rf_write_freq
 	setarg param_pll_setup
-	call sleep
+	call sleep	
 p_txon:	
+	
 	fetch 1,rfen_adc
 	set1 0,pdata
 	store 1,rfen_adc
-	branch txon+1
+	hjam 0x3c,rfen_rx
+	hjam 0xe0,rfen_tx
+	hjam 0x12,0x96d
+	nop 10
+	hjam 0x01,rfen_mdm
+	hjam 0x3d,rfen_mdm
+	nop 10
+	hjam 0xb7,rfen_sn
+	nop 10
+	hjam 0x7f, rfen_mdm
+	fetch 1,mem_tx_power
+	beq TX_POWER_0DB,set_tx_power_0db
+	beq TX_POWER_3DB,set_tx_power_3db	
+	beq TX_POWER_5DB,p_set_tx_power_5db
+	beq TX_POWER_f3DB,set_tx_power_f3db	
+	beq TX_POWER_f5DB,set_tx_power_f5db
+	beq TX_POWER_f10DB,p_set_tx_powerf10db
+	beq TX_POWER_f15DB,p_set_tx_powerf15db
+	beq TX_POWER_f20DB,p_set_tx_powerf20db
+	beq TX_POWER_PAIR,set_tx_power_pair
+
+p_set_tx_power_5db:
+	hjam 0xff,0x956
+	call txon_common
+	hjam 0xdf,0x955
+	
+	rtn
+p_set_tx_powerf10db:
+	hjam 0x68,0x954
+	hjam 0xd8,0x955
+	hjam 0xe5,0x956
+	hjam 0x4c,0x957
+	hjam 0x36,0x958
+	hjam 0x10,0x959
+	rtn
+
+p_set_tx_powerf15db:
+	hjam 0x68,0x954
+	hjam 0xd8,0x955
+	hjam 0xe2,0x956
+	hjam 0x4c,0x957
+	hjam 0x36,0x958
+	hjam 0x10,0x959
+	rtn
+
+p_set_tx_powerf20db:
+	hjam 0x68,0x954
+	hjam 0xd8,0x955
+	hjam 0xe1,0x956
+	hjam 0x4c,0x957
+	hjam 0x36,0x958
+	hjam 0x10,0x959
+	rtn
+
 
 
 p_init_param:
+	hjam 0x74,rfen_adc
+	nop 12000
 	hjam 0x7c,rfen_adc
 	rtn wake
 	setarg 0
Index: rongyuan/sched/109x.dat
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/sched/109x.dat	(revision 932)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/sched/109x.dat	(working copy)
@@ -25,7 +25,7 @@
 
 mem_inq_window:20 00
 mem_page_window:20 00
-mem_page_to:00 20
+mem_page_to:ff ff
 mem_rx_window_init:80 04
 mem_rx_window_sniff:00 10
 
Index: rongyuan/sched/24g_keyboard.dat
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/sched/24g_keyboard.dat	(revision 932)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/sched/24g_keyboard.dat	(working copy)
@@ -1,8 +1,6 @@
 
 
 #24g init
-mem_24g_mode:01#tx
-mem_24g_data_type:02        #mouse 1,kb 2
 mem_24g_max_retry:4#max tx retry
 mem_24g_no_ack:00#with ack
 mem_24g_rx_window:c0 12     #400us 
Index: rongyuan/sched/DM_module.dat
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/sched/DM_module.dat	(revision 932)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/sched/DM_module.dat	(working copy)
@@ -14,10 +14,10 @@
 4FF2:FF 1F
 4FF4:00 1C
 4FF6:00 1C
-4FF8:80 4C
+4FF8:e0 4c
 4FFA:E0 4F
-4FFC:80 4C
-4FFE:80 4C
+4FFC:E0 4c
+4FFE:e0 4c
 
 ##############BLUETOOTH CONFIG##############
 ###commom###
Index: rongyuan/sched/ble_keyboard.dat
===================================================================
--- /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/sched/ble_keyboard.dat	(revision 932)
+++ /YC3121_demo/ModuleDemo/BlueTooth/BT_code_patch/keyboard/branches/rongyuan/sched/ble_keyboard.dat	(working copy)
@@ -17,7 +17,7 @@
 
 
 
-mem_le_local_mtu:17
+mem_le_local_mtu:e6
 mem_le_remote_mtu:17
 
 mem_le_secure_connect_enable:00
