Index: format/app_shutter.format
===================================================================
--- /branch/Shutter/Ble shutter/AB Shutter3 YC1062SA/format/app_shutter.format	(revision 1070)
+++ /branch/Shutter/Ble shutter/AB Shutter3 YC1062SA/format/app_shutter.format	(working copy)
@@ -159,6 +159,7 @@
 1 mem_shutter_power_off_timeout
 1 mem_shutter_power_off_timer
 
+2 mem_key_value_copy
 )
 
 
Index: output/eeprom.dat
===================================================================
--- /branch/Shutter/Ble shutter/AB Shutter3 YC1062SA/output/eeprom.dat	(revision 1070)
+++ /branch/Shutter/Ble shutter/AB Shutter3 YC1062SA/output/eeprom.dat	(working copy)
@@ -2,8 +2,8 @@
 02
 aa
 55
-6e
-01
+06
+02
 c2
 84
 00
@@ -11,43 +11,51 @@
 c0
 00
 00
-0c
+0e
 c0
 42
 80
-0f
+11
 c0
 58
 80
-28
+2a
 c0
 7a
 80
-2a
+2c
 20
 20
 2a
 8e
 c0
+2c
+80
+3b
+c0
+33
+00
+48
+c0
 41
 00
-39
+5f
 c0
 42
 80
-4b
+71
 c0
 51
 00
-51
+77
 c0
 51
 80
-57
+7d
 c0
 66
 80
-58
+7e
 20
 20
 2a
@@ -67,7 +75,7 @@
 20
 30
 80
-1f
+21
 70
 89
 55
@@ -99,27 +107,27 @@
 c0
 00
 00
-1d
+1f
 c0
 00
 80
-21
+23
 c0
 01
 00
-1d
+1f
 c0
 01
 80
-21
+23
 c0
 02
 00
-21
+23
 c0
 10
 00
-21
+23
 70
 89
 55
@@ -147,7 +155,7 @@
 20
 20
 00
-1f
+21
 d8
 e0
 00
@@ -167,7 +175,7 @@
 20
 40
 00
-24
+26
 20
 20
 2c
@@ -175,7 +183,7 @@
 58
 00
 00
-30
+32
 60
 01
 41
@@ -199,7 +207,7 @@
 20
 40
 00
-33
+35
 20
 40
 68
@@ -232,6 +240,150 @@
 20
 68
 30
+68
+00
+84
+3f
+c4
+03
+00
+00
+20
+40
+00
+40
+24
+74
+00
+00
+20
+20
+55
+a0
+78
+34
+7c
+00
+68
+00
+84
+5a
+1f
+f1
+fe
+00
+c1
+87
+80
+00
+68
+00
+84
+60
+1f
+f1
+fe
+00
+c1
+80
+00
+00
+20
+20
+7f
+e9
+c6
+07
+80
+00
+20
+40
+58
+90
+24
+7a
+00
+00
+68
+00
+82
+d9
+1f
+e1
+7e
+03
+60
+00
+c5
+0c
+e8
+c0
+80
+00
+1f
+e1
+7e
+1f
+60
+00
+c5
+0b
+20
+7a
+00
+00
+18
+c2
+7e
+00
+60
+01
+45
+0d
+68
+00
+c5
+0c
+c0
+01
+80
+57
+20
+20
+56
+8d
+68
+00
+82
+db
+c0
+00
+80
+5a
+20
+20
+5c
+65
+e8
+c2
+80
+00
+60
+02
+c3
+ce
+e8
+c1
+00
+00
+60
+01
+04
+5f
+20
+20
+5c
+8a
 78
 54
 7c
@@ -251,7 +403,7 @@
 c2
 83
 80
-3f
+65
 20
 20
 60
@@ -259,11 +411,11 @@
 c0
 42
 00
-42
+68
 c0
 41
 80
-45
+6b
 20
 20
 60
@@ -271,7 +423,7 @@
 20
 40
 00
-48
+6e
 68
 00
 80
@@ -283,7 +435,7 @@
 20
 40
 00
-48
+6e
 68
 00
 80
@@ -330,8 +482,8 @@
 00
 68
 01
-4f
-fe
+48
+ed
 60
 01
 0b
@@ -346,8 +498,8 @@
 14
 60
 01
-4f
-fe
+48
+ed
 20
 60
 00
@@ -368,8 +520,8 @@
 20
 74
 bd
-2a
-35
+0f
+53
 aa
 55
 01
@@ -383,7 +535,7 @@
 00
 a0
 44
-73
+74
 31
 20
 98
@@ -653,7 +805,7 @@
 48
 00
 00
-08
+86
 a0
 01
 a0
@@ -664,7 +816,7 @@
 00
 01
 07
-08
+86
 a0
 03
 a0
@@ -827,8 +979,8 @@
 00
 e9
 46
-06
 04
+05
 0d
 aa
 55
@@ -1004,8 +1156,8 @@
 00
 00
 00
-00
-00
+02
+40
 00
 00
 00
@@ -1181,5 +1333,5 @@
 40
 e1
 41
-0a
-27
+93
+ff
Index: output/memmap.format
===================================================================
--- /branch/Shutter/Ble shutter/AB Shutter3 YC1062SA/output/memmap.format	(revision 1070)
+++ /branch/Shutter/Ble shutter/AB Shutter3 YC1062SA/output/memmap.format	(working copy)
@@ -1728,4 +1728,5 @@
 0x48e0 mem_shutter_soft_swtich_led_struct_temp
 0x48eb mem_shutter_power_off_timeout
 0x48ec mem_shutter_power_off_timer
+0x48ed mem_key_value_copy
 0x469a mem_24g_dongle_head_ptr
Index: output/program.lis
===================================================================
--- /branch/Shutter/Ble shutter/AB Shutter3 YC1062SA/output/program.lis	(revision 1070)
+++ /branch/Shutter/Ble shutter/AB Shutter3 YC1062SA/output/program.lis	(working copy)
@@ -1,50 +1,52 @@
 include "bt_format "
 org 0x0000
 0000 c2840006 bbit1 8 ,pf_patch_ext 
-0001 c000000c beq patch00_0 ,p_soft_reset 
-0002 c042800f beq patch10_5 ,p_shutdown_radio 
-0003 c0588028 beq patch16_1 ,p_lpm_check_wake_lock 
-0004 c07a802a beq patch1e_5 ,p_shutter_init 
+0001 c000000e beq patch00_0 ,p_soft_reset 
+0002 c0428011 beq patch10_5 ,p_shutdown_radio 
+0003 c058802a beq patch16_1 ,p_lpm_check_wake_lock 
+0004 c07a802c beq patch1e_5 ,p_shutter_init 
 0005 20202a8e branch loop 
 
 pf_patch_ext:
-0006 c0410039 beq patch30_2 ,p_send_lmp 
-0007 c042804b beq patch30_5 ,p_ssp_disable 
-0008 c0510051 beq patch34_2 ,p_keyscan_key_process 
-0009 c0518057 beq patch34_3 ,p_keyscan_send_key_data 
-000a c0668058 beq patch39_5 ,p_sdp_process 
-000b 20202a8e branch loop 
+0006 c02c803b beq patch2b_1 ,p_le_update_channel_map 
+0007 c0330048 beq patch2c_6 ,p_le_parse 
+0008 c041005f beq patch30_2 ,p_send_lmp 
+0009 c0428071 beq patch30_5 ,p_ssp_disable 
+000a c0510077 beq patch34_2 ,p_keyscan_key_process 
+000b c051807d beq patch34_3 ,p_keyscan_send_key_data 
+000c c066807e beq patch39_5 ,p_sdp_process 
+000d 20202a8e branch loop 
 
 p_soft_reset:
-000c 20800000 clear_stack 
-000d 204074b9 call enable_authrom 
-000e 20202003 branch soft_reset + 2 
+000e 20800000 clear_stack 
+000f 204074b9 call enable_authrom 
+0010 20202003 branch soft_reset + 2 
 
 p_shutdown_radio:
-000f 2030801f branch p_shutdown_radio0 ,is_rx 
-0010 708955d4 hjam 0xd4 ,0x955 
-0011 20000004 nop 4 
-0012 708955d2 hjam 0xd2 ,0x955 
+0011 20308021 branch p_shutdown_radio0 ,is_rx 
+0012 708955d4 hjam 0xd4 ,0x955 
 0013 20000004 nop 4 
-0014 708955d1 hjam 0xd1 ,0x955 
+0014 708955d2 hjam 0xd2 ,0x955 
 0015 20000004 nop 4 
-0016 6800c1de fetch 1 ,mem_tx_power 
-0017 c000001d beq tx_power_0db ,p_shutdown_radio_0db 
-0018 c0008021 beq tx_power_3db ,p_shutdown_radio_3db 
-0019 c001001d beq tx_power_5db ,p_shutdown_radio_5db 
-001a c0018021 beq tx_power_f3db ,p_shutdown_radio_f3db 
-001b c0020021 beq tx_power_f5db ,p_shutdown_radio_f5db 
-001c c0100021 beq tx_power_pair ,p_shutdown_radio_pair 
+0016 708955d1 hjam 0xd1 ,0x955 
+0017 20000004 nop 4 
+0018 6800c1de fetch 1 ,mem_tx_power 
+0019 c000001f beq tx_power_0db ,p_shutdown_radio_0db 
+001a c0008023 beq tx_power_3db ,p_shutdown_radio_3db 
+001b c001001f beq tx_power_5db ,p_shutdown_radio_5db 
+001c c0018023 beq tx_power_f3db ,p_shutdown_radio_f3db 
+001d c0020023 beq tx_power_f5db ,p_shutdown_radio_f5db 
+001e c0100023 beq tx_power_pair ,p_shutdown_radio_pair 
 
 p_shutdown_radio_5db:
 
 p_shutdown_radio_0db:
-001d 708955d0 hjam 0xd0 ,0x955 
-001e 708956e0 hjam 0xe0 ,0x956 
+001f 708955d0 hjam 0xd0 ,0x955 
+0020 708956e0 hjam 0xe0 ,0x956 
 
 p_shutdown_radio0:
-001f 18002a08 force 0x08 ,radio_ctrl 
-0020 2020290a branch shutdown_radio0 
+0021 18002a08 force 0x08 ,radio_ctrl 
+0022 2020290a branch shutdown_radio0 
 
 p_shutdown_radio_pair:
 
@@ -53,92 +55,138 @@
 p_shutdown_radio_f3db:
 
 p_shutdown_radio_3db:
-0021 708955d0 hjam 0xd0 ,0x955 
-0022 708956c0 hjam 0xc0 ,0x956 
-0023 2020001f branch p_shutdown_radio0 
+0023 708955d0 hjam 0xd0 ,0x955 
+0024 708956c0 hjam 0xc0 ,0x956 
+0025 20200021 branch p_shutdown_radio0 
 
 p_lpm_check_ble_tx:
-0024 d8e00004 arg wake_lock_ble_tx_patch ,queue 
-0025 6800c4ff fetch 1 ,mem_le_tx_buff_used 
-0026 243a2c32 nbranch lpm_get_wake_lock ,blank 
-0027 20202c36 branch lpm_put_wake_lock 
+0026 d8e00004 arg wake_lock_ble_tx_patch ,queue 
+0027 6800c4ff fetch 1 ,mem_le_tx_buff_used 
+0028 243a2c32 nbranch lpm_get_wake_lock ,blank 
+0029 20202c36 branch lpm_put_wake_lock 
 
 p_lpm_check_wake_lock:
-0028 20400024 call p_lpm_check_ble_tx 
-0029 20202c3b branch lpm_check_wake_lock + 1 
+002a 20400026 call p_lpm_check_ble_tx 
+002b 20202c3b branch lpm_check_wake_lock + 1 
 
 p_shutter_init:
-002a 58000030 setarg p_shutter_process_lpm_before 
-002b 600141ed store 2 ,mem_cb_before_lpm 
-002c 68108a00 hfetch 1 ,core_usb_config 
-002d 793ffe04 set0 4 ,pdata 
-002e 60108a00 hstore 1 ,core_usb_config 
-002f 20204603 branch shutter_init + 0x25 
+002c 58000032 setarg p_shutter_process_lpm_before 
+002d 600141ed store 2 ,mem_cb_before_lpm 
+002e 68108a00 hfetch 1 ,core_usb_config 
+002f 793ffe04 set0 4 ,pdata 
+0030 60108a00 hstore 1 ,core_usb_config 
+0031 20204603 branch shutter_init + 0x25 
 
 p_shutter_process_lpm_before:
-0030 20400033 call p_ice_gpio_set_input_pu 
-0031 20406835 call gpio_set_before_lpm_common 
-0032 202046b3 branch shutter_process_lpm_before 
+0032 20400035 call p_ice_gpio_set_input_pu 
+0033 20406835 call gpio_set_before_lpm_common 
+0034 202046b3 branch shutter_process_lpm_before 
 
 p_ice_gpio_set_input_pu:
-0033 d840001d arg 29 ,temp 
-0034 204067fb call gpio_config_input 
 0035 d840001d arg 29 ,temp 
-0036 79200407 set1 gpio_active_bit ,temp 
-0037 d8a08078 arg core_gpio_pu0 ,contw 
-0038 20206830 branch gpio_set_bit 
+0036 204067fb call gpio_config_input 
+0037 d840001d arg 29 ,temp 
+0038 79200407 set1 gpio_active_bit ,temp 
+0039 d8a08078 arg core_gpio_pu0 ,contw 
+003a 20206830 branch gpio_set_bit 
+
+p_le_update_channel_map:
+003b 6800843f fetch 1 ,mem_le_state 
+003c c4030000 rtnbit0 lestate_update_map 
+003d 20400040 call p_le_channel_map_overflow_check 
+003e 24740000 nrtn user 
+003f 202055a0 branch le_update_channel_map + 3 
+
+p_le_channel_map_overflow_check:
+0040 78347c00 enable user 
+0041 6800845a fetch 1 ,mem_le_event_count + 1 
+0042 1ff1fe00 rshift4 pdata ,pdata 
+0043 c1878000 rtnne 0x0f 
+0044 68008460 fetch 1 ,mem_le_instant + 1 
+0045 1ff1fe00 rshift4 pdata ,pdata 
+0046 c1800000 rtnne 0x00 
+0047 20207fe9 branch disable_user 
+
+p_le_parse:
+0048 c6078000 rtnmark1 mark_old_packet 
+0049 20405890 call le_fifo_check_full 
+004a 247a0000 nrtn blank 
+004b 680082d9 fetch 1 ,mem_le_rxbuf 
+004c 1fe17e03 and pdata ,0x3 ,pdata 
+004d 6000c50c store 1 ,mem_le_packet_llid 
+004e e8c08000 ifetch 1 ,contr 
+004f 1fe17e1f and pdata ,0x1f ,pdata 
+0050 6000c50b store 1 ,mem_le_packet_size 
+0051 207a0000 rtn blank 
+0052 18c27e00 copy contr ,pdata 
+0053 6001450d store 2 ,mem_le_payload_ptr 
+0054 6800c50c fetch 1 ,mem_le_packet_llid 
+0055 c0018057 beq llid_le_ll ,p_le_parse_ll 
+0056 2020568d branch le_parse_l2cap 
+
+p_le_parse_ll:
+0057 680082db fetch 1 ,mem_le_rxbuf + 2 
+0058 c000805a beq ll_channel_map_req ,p_le_parse_channel_map_req 
+0059 20205c65 branch le_parse_ll + 1 
+
+p_le_parse_channel_map_req:
+005a e8c28000 ifetch 5 ,contr 
+005b 6002c3ce store 5 ,mem_le_new_map 
+005c e8c10000 ifetch 2 ,contr 
+005d 6001045f store 2 ,mem_le_instant 
+005e 20205c8a branch le_parse_channel_map_req + 7 
 
 p_send_lmp:
-0039 78547c00 disable user 
-003a 204062c1 call lmo_fifo_process 
-003b 68008048 fetch 1 ,mem_lmp_to_send 
-003c 207a0000 rtn blank 
-003d c283803f bbit1 7 ,p_send_lmp_escape 
-003e 20206010 branch send_lmp0 
+005f 78547c00 disable user 
+0060 204062c1 call lmo_fifo_process 
+0061 68008048 fetch 1 ,mem_lmp_to_send 
+0062 207a0000 rtn blank 
+0063 c2838065 bbit1 7 ,p_send_lmp_escape 
+0064 20206010 branch send_lmp0 
 
 p_send_lmp_escape:
-003f c0420042 beq lmp_ext_features_res ,p_send_lmpext_features_res 
-0040 c0418045 beq lmp_ext_features_req ,p_send_lmpext_features_req 
-0041 2020603f branch send_lmp_escape 
+0065 c0420068 beq lmp_ext_features_res ,p_send_lmpext_features_res 
+0066 c041806b beq lmp_ext_features_req ,p_send_lmpext_features_req 
+0067 2020603f branch send_lmp_escape 
 
 p_send_lmpext_features_res:
-0042 20400048 call p_check_ssp_enable 
-0043 68008048 fetch 1 ,mem_lmp_to_send 
-0044 20206099 branch send_lmpext_features_res 
+0068 2040006e call p_check_ssp_enable 
+0069 68008048 fetch 1 ,mem_lmp_to_send 
+006a 20206099 branch send_lmpext_features_res 
 
 p_send_lmpext_features_req:
-0045 20400048 call p_check_ssp_enable 
-0046 68008048 fetch 1 ,mem_lmp_to_send 
-0047 2020610d branch send_lmpext_features_req 
+006b 2040006e call p_check_ssp_enable 
+006c 68008048 fetch 1 ,mem_lmp_to_send 
+006d 2020610d branch send_lmpext_features_req 
 
 p_check_ssp_enable:
-0048 6800c65a fetch 1 ,mem_ssp_enable 
-0049 203a612b branch ssp_disable ,blank 
-004a 20206124 branch ssp_enable 
+006e 6800c65a fetch 1 ,mem_ssp_enable 
+006f 203a612b branch ssp_disable ,blank 
+0070 20206124 branch ssp_enable 
 
 p_ssp_disable:
-004b 6800c09e fetch 1 ,mem_features + 6 
-004c 793ffe03 set0 param_featrue_ssp ,pdata 
-004d 6000c09e store 1 ,mem_features + 6 
-004e 58000001 setarg 0x1 
-004f 600104ce store 2 ,mem_lmpext_ssp_enable 
-0050 20600000 rtn 
+0071 6800c09e fetch 1 ,mem_features + 6 
+0072 793ffe03 set0 param_featrue_ssp ,pdata 
+0073 6000c09e store 1 ,mem_features + 6 
+0074 58000001 setarg 0x1 
+0075 600104ce store 2 ,mem_lmpext_ssp_enable 
+0076 20600000 rtn 
 
 p_keyscan_key_process:
-0051 68014ffe fetch 2 ,0x4ffe 
-0052 60010b14 store 2 ,mem_key_value 
-0053 20406981 call keyscan_key_process + 9 
-0054 68010b14 fetch 2 ,mem_key_value 
-0055 60014ffe store 2 ,0x4ffe 
-0056 20600000 rtn 
+0077 680148ed fetch 2 ,mem_key_value_copy 
+0078 60010b14 store 2 ,mem_key_value 
+0079 20406981 call keyscan_key_process + 9 
+007a 68010b14 fetch 2 ,mem_key_value 
+007b 600148ed store 2 ,mem_key_value_copy 
+007c 20600000 rtn 
 
 p_keyscan_send_key_data:
-0057 202069a2 branch keyscan_send_key_data + 1 
+007d 202069a2 branch keyscan_send_key_data + 1 
 
 p_sdp_process:
-0058 204074b9 call enable_authrom 
-0059 20406e12 call sdp_process + 1 
-005a 202074bd branch disable_authrom 
+007e 204074b9 call enable_authrom 
+007f 20406e12 call sdp_process + 1 
+0080 202074bd branch disable_authrom 
 org 0x2000
 
 start:
Index: program/patch.prog
===================================================================
--- /branch/Shutter/Ble shutter/AB Shutter3 YC1062SA/program/patch.prog	(revision 1070)
+++ /branch/Shutter/Ble shutter/AB Shutter3 YC1062SA/program/patch.prog	(working copy)
@@ -1,5 +1,4 @@
 
-//define USB
 
 ifdef PATCH
 	bbit1 8,pf_patch_ext
@@ -9,6 +8,8 @@
 	beq patch1e_5,p_shutter_init
 	branch loop
 pf_patch_ext:
+	beq patch2b_1,p_le_update_channel_map
+	beq patch2c_6,p_le_parse
 	beq patch30_2,p_send_lmp
 	beq patch30_5,p_ssp_disable
 	beq patch34_2,p_keyscan_key_process
@@ -78,12 +79,57 @@
 	call gpio_set_before_lpm_common
 	branch shutter_process_lpm_before
 p_ice_gpio_set_input_pu: 
-	 arg 29,temp
+	arg 29,temp
  	call gpio_config_input
-	 arg 29,temp
-	 set1 gpio_active_bit,temp
-	 arg core_gpio_pu0,contw
-	 branch gpio_set_bit
+	arg 29,temp
+	set1 gpio_active_bit,temp
+	arg core_gpio_pu0,contw
+	branch gpio_set_bit
+	
+
+p_le_update_channel_map:
+	fetch 1,mem_le_state
+	rtnbit0 lestate_update_map
+	call p_le_channel_map_overflow_check
+	nrtn user
+	branch le_update_channel_map+3
+p_le_channel_map_overflow_check:
+	enable user
+	fetch 1,mem_le_event_count+1
+	rshift4 pdata,pdata
+	rtnne 0x0f
+	fetch 1,mem_le_instant+1
+	rshift4 pdata,pdata
+	rtnne 0x00
+	branch disable_user
+
+p_le_parse:
+	rtnmark1 mark_old_packet
+	call le_fifo_check_full
+	nrtn blank
+	fetch 1,mem_le_rxbuf
+	and pdata,0x3,pdata
+	store 1,mem_le_packet_llid
+	ifetch 1,contr
+	and pdata,0x1f,pdata
+	store 1,mem_le_packet_size
+	rtn blank							//empty rtn
+	copy contr,pdata
+	store 2,mem_le_payload_ptr
+	fetch 1,mem_le_packet_llid
+	beq LLID_LE_LL,p_le_parse_ll
+	branch le_parse_l2cap
+p_le_parse_ll:
+	fetch 1,mem_le_rxbuf+2
+	beq LL_CHANNEL_MAP_REQ,p_le_parse_channel_map_req
+	branch le_parse_ll+1
+p_le_parse_channel_map_req:
+	ifetch 5,contr
+	store 5,mem_le_new_map
+	ifetch 2,contr
+	store 2,mem_le_instant
+	branch le_parse_channel_map_req+7
+
 
 p_send_lmp:
 	disable user
@@ -121,11 +167,11 @@
 	rtn
 
 p_keyscan_key_process:
-	fetch 2,0x4ffe
+	fetch 2,mem_key_value_copy
 	store 2,mem_key_value
 	call keyscan_key_process + 9
 	fetch 2,mem_key_value
-	store 2,0x4ffe
+	store 2,mem_key_value_copy
 	rtn
 
 p_keyscan_send_key_data:
Index: sched/109x.dat
===================================================================
--- /branch/Shutter/Ble shutter/AB Shutter3 YC1062SA/sched/109x.dat	(revision 1070)
+++ /branch/Shutter/Ble shutter/AB Shutter3 YC1062SA/sched/109x.dat	(working copy)
@@ -44,8 +44,8 @@
 00   #mem_patch28
 00   #mem_patch29
 00   #mem_patch2A
-00   #mem_patch2B
-00   #mem_patch2C
+02   #mem_patch2B
+40   #mem_patch2C
 00   #mem_patch2D
 00   #mem_patch2E
 00   #mem_patch2F
