;
;                   LG Information & Communications, Ltd.
;                   Mobile Communications Research Lab.
;                   R&D Center
;                   MAKE BY LEE, CHANG JAE
;
;
; NV-items are programmed using the nv_write command:
;
;   nv_write itemname { [nam index,] val1, val2, ..., valn }
;
; Only NAM 0 has meaningful values.  Values for NAMs 1-3 are
; zeroed out or set to default values.
;
; Some items require a nam index (0-3). The curly braces
; are required and they surround the values to be written.
; You must supply every value the item expects. Hex values
; you supply need the 0x prefix.
;
; Semi-colons introduce comments. Whole line and
; to-end-of-line comments are possible.
;
; THE FOLLOWING PARAMETERS SHOULD BE SET FOR EACH PHONE:
; ------------------------------------------------------
;
;   1. CDMA preferred serving system (System A or System B)
;   2. Analog preferred serving system (System A or System B)
;   3. Analog Home SID (the SID of the preferred serving system)
;   4. Analog first paging channel (for system A or system B)
;   5. CDMA primary and seconday channels (including PCN, if in
;      use)
;   6. CDMA SID/NID pairs (the SID of the preferred serving system)
;   7. MIN1 and MIN2 parameters.
;   8. Default settings for MISELL (LGIC)
;===================================================================

print "MW560    "
print "통합규격 시비스 프로그램"

print "Start Service Programming"
; Enter the Service Programming Code (factory defaulted to 000000)
; If you don't have version 116 or later, this command will fail.
; This allows access to the SP items (both reading _and_ writing)

spc "000000"

;hs_lock l                       ; HS UNLOCK!

; Put the DMSS in offline analog mode
mode offline-d

; Display the ESN and permanent physical station
; configuration parameters
nv_read esn
nv_read verno_maj
nv_read verno_min
nv_read scm
nv_read slot_cycle_index
nv_read mob_cai_rev
nv_read mob_firm_rev
nv_read mob_model
print "Hit any key to continue"

;pause
wait 1

;*************************************************************************
; 
; MW560 Script 
;
;*************************************************************************

print "Programming System Config    "
;=========================================================================
; SYSTEM CDMA CALL ITEM
;=========================================================================

nv_write min1 		{0, "000-0000", "000-0000"}
nv_write min1 		{1, "000-0000", "000-0000"}
nv_write min2 		{0, "000", "000"}       
nv_write min2 		{1, "000", "000"}      
nv_write dir_number 	{0, "0000000000"}     	
nv_write dir_number 	{1, "0000000000"}     	

nv_write imsi_mcc 	{0, "724"}		
nv_write imsi_mcc	{1, "724"}
nv_write imsi_11_12 	{0, "00"}		; MNC(Mobile Network Code)
nv_write imsi_11_12 	{1, "00"}		;=> 예전에는 10이었으나, 최근 00으로 바뀜.
nv_write imsi_t_mcc 	{0, "724"}		
nv_write imsi_t_mcc 	{1, "724"}
nv_write imsi_t_11_12 	{0, "00"}		; MNC(Mobile Network Code)
nv_write imsi_t_11_12 	{1, "00"}               
nv_write imsi_t_s1 	{0, "000-0000","000-0000"}	
nv_write imsi_t_s1 	{1, "000-0000","000-0000"}           
nv_write imsi_t_s2 	{0, "000", "000"}		
nv_write imsi_t_s2 	{1, "000", "000"} 
nv_write imsi_t_addr_num    {0, 255}            ;In case of class 0 IMSI, num size is fixed to 12 bits ->imsi_t_addr_num value has no meaning. therefore 0xff
nv_write imsi_t_addr_num    {1, 255}   

nv_write accolc 	{0, 0,0}
nv_write accolc 	{1, 0,0}
nv_write slot_cycle_index 	{2}

nv_write mob_term_home 		{0, true, true}
nv_write mob_term_home 		{1, true, true}
nv_write mob_term_for_sid 	{0, true, true}
nv_write mob_term_for_sid 	{1, true, true}
nv_write mob_term_for_nid 	{0, true, true}
nv_write mob_term_for_nid 	{1, true, true}

nv_write pcdmach 	{0, 283,384}		
nv_write pcdmach 	{1, 283,384}
nv_write scdmach 	{0, 691,777}		
nv_write scdmach 	{1, 691,777}
;nv_write home_sid_nid	{0, 0,65535}
;nv_write home_sid_nid	{1, 0,65535}
nv_write home_sid_nid   {0,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535}
nv_write home_sid_nid   {1,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535,0,65535}


nv_write sid_nid_lock 	{0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
nv_write sid_nid_lock 	{1, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
;nv_write cdma_sid_lock	{0, 0,0,0,0,0,0}	;=>사용안함
;nv_write cdma_sid_lock	{1, 0,0,0,0,0,0}
;nv_write cdma_sid_acq 	{0, 22,0,0,0,0,0}      ;=> 사용안함
;nv_write cdma_sid_acq 	{1, 22,0,0,0,0,0}

nv_write pref_voice_so 	{0, 1,0x0003,0x0003,0x0003} ;{Nam, EVRC Capability(0:Off, 1:ON),Home_Page_Voice_SO(0: wildcard, Others : SO)
nv_write pref_voice_so 	{1, 1,0x0003,0x0003,0x0003}
nv_write pref_mode   	{0, "digital only"}    ;MW560 AMPS 지원안함.
nv_write pref_mode   	{1, "digital only"}

;nv_write system_pref   	{0, "standard"}		;MW560 에선 사용하지 않음.
;nv_write system_pref   	{1, "standard"}		;MW560 에선 사용하지 않음.
nv_write roam_pref 	{0, 0xff}              ;0xff=ANY
nv_write roam_pref 	{1, 0xff}
nv_write hybrid_pref 	{"off"}                ;MW560 EVDO 지원안함.
;nv_write band_pref 	{0,0x0387}             ;=> 사용안함 MW560 band_pref값 387(CDMA BC0/1, GSM 900/1800) Hard Coding되어있음. 
;nv_write band_pref 	{1,0x0387}
;nv_write band_pref_16_31 {0,0x0000}	       ;=> 사용안함
;nv_write band_pref_16_31 {1,0x0000}

nv_write prl_enabled 	{0, 1}			; enabled
nv_write prl_enabled 	{1, 1}  
nv_write mru3_table {0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
nv_write mru3_table {1, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

nv_write voice_priv 		{0}	       ;0=Standard  1=Enhanced

nv_write nam_chksum {0, 0xffff}
nv_write nam_chksum {1, 0xffff}
nv_write min_chksum {0, 0xffff, 0xffff}
nv_write min_chksum {1, 0xffff, 0xffff}


;=========================================================================
; SYSTEM OTA ITEM
;=========================================================================
nv_write nam_lock           {0, 1}
nv_write nam_lock           {1, 1}
nv_write otapa_enabled      {0, 1}            ;1=enable
nv_write otapa_enabled      {1, 1} 

nv_write spc_change_enabled {1}          

;=========================================================================
; SYSTEM AUTH ITEM
;=========================================================================
nv_write a_key {0, 0x00000000, 0x00000000 }   ; Nam 1 64 bits A-Key. Published at factory with Random number.
nv_write a_key {1, 0x00000000, 0x00000000 }   ; Nam 2 64 bits A-Key. Published at factory with Random number.
nv_write ssd_a {0, 0x00000000, 0x00000000 }
nv_write ssd_a {1, 0x00000000, 0x00000000 }
nv_write ssd_b {0, 0x00000000, 0x00000000 }
nv_write ssd_b {1, 0x00000000, 0x00000000 }
nv_write count {0, 0}
nv_write count {1, 0}

;=========================================================================
; UI ITEM
;=========================================================================
nv_write lock_code 	{"0000"}	; Lock_code
nv_write sec_code 	{"000000"}	; Security code
nv_write sec_code_two 	{"953047"}
nv_write fsc 		{"000000"}	; Field Service code

nv_write name_nam {0, "    VIVO    "} 	
nv_write name_nam {1, "    VIVO    "} 	
nv_write auto_nam {off}                 ; off = disable
nv_write curr_nam {0}                   ; 0 = NAM1 

nv_write min_lock_enabled	{0}

;nv_write stack_idx     {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff} ;=> UI파트 구현 필요
;nv_write area_code	{0x00}          ;=> UI파트 구현 필요

;----- End System Parameter -----

;=========================================================================
; BREW ITEM
;=========================================================================

nv_write brew_ads1 {"brewtcpos.zaaap.com.br"} 				; byte[64] (char)
nv_write brew_ads2 {"brewtcpre.zaaap.com.br"}	       			; byte[64] (char)
nv_write brew_dns1 {200,142,130,8}					; byte[4] (digit)
nv_write brew_dns2 {200,142,130,11}					; byte[4] (digit)
nv_write brew_carrier_ID {51}						; word
nv_write brew_platform_ID {1151}            			      	; word
nv_write brew_bKey {00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00}	; byte[16]
nv_write brew_wFlags {0x0004}						; word
nv_write brew_user_Auth {0}						; byte
nv_write brew_app_Policy {3}						; byte
nv_write brew_vivo_agenda_class {0x0103C628}				; dword

;  DIF_USE_A_KEY            0x0001    default OFF (use bKey).  If set, use AKey value
;  DIF_TEST_ALLOWED         0x0002    This phone can be used to test local apps
;  DIF_MIN_FOR_SID          0x0004    Use the MIN for the SID if not set
;  DIF_PREPAY               0x0008    Prepay phone
;  DIF_NO_AUTO_ACK          0x0040    Do not force ACKs until user runs MobileShop
;  DIF_SID_ENCODE           0x0080    Uses SID rather than ESN for app encoding
;  DIF_SID_VALIDATE_ALL     0x0100    Validates all apps rather than just SSN apps
;  DIF_RUIM_DEL_OVERRIDE    0x0200    Allows one RUIM user to delete apps owned by another

;  APOLICY_NONE 0  No authentication required
;  APOLICY_SID  1  User's "subscriber ID" is passed to ADS before any set of transactions started
;  APOLICY_TEXT 2  User should be prompted for text "key" and this sent to ADS
;  APOLICY_NUM  3  User should be prompted for numeric "key" and this sent to ADS

;  PPOLICY_BREW			0
;  PPOLICY_CARRIER		1
;  PPOLICY_BREW_AND_CARRIER	2
;  PPOLICY_BREW_OR_CARRIER	3


;=========================================================================
;  F/W ITEM
;=========================================================================
;print "charging mode & mru table enable"
nv_write spare_1 {0x2}           ; charging
nv_write spare_2 {0x1}           ; MRU Table enable

;print "Programming RF config"
nv_write rf_config {6}

;=========================================================================
; MMS ITEM 
;=========================================================================
nv_write mms_mmsc_url {"http://termnat.vivomms.com.br:8088/"}; 120 byte characters
nv_write mms_mmsc_gateway_url {"http://200.142.130.150"}; 120 byte characters
nv_write mms_ppp_id {"internet"}; 120 byte characters
nv_write mms_ppp_pwd {"password"}; 120 byte characters
nv_write mms_mmsc_uaprof_url {"http://lguaprof.vivomms.com.br/lgmw560.xml"}; 120 byte characters
nv_write mms_mmsc_post_url {"mms/"} ;120 byte characters 
nv_write mms_test_authorization {0x00}; byte
nv_write mms_test_gateway {0}; boolean

;=========================================================================
; DATA ITEM
;=========================================================================

nv_write data_qnc_enabled {0}; boolean
nv_write data_so_set {0}; byte
nv_write data_mdr_mode {3}; byte
nv_write data_pkt_orig_str {5, "#777"}; byte
nv_write data_auto_packet_detection {0}; byte
nv_write dmt_timer {120}; byte
nv_write ppp_carrier {0}; byte

;=========================================================================
; GPS ITEM
;=========================================================================

nv_write gps1_pde_transport {0}; word
nv_write gps1_privacy {0}; byte
nv_write gps1_lock {0}; dword
nv_write gps1_net_access {2}; byte
nv_write gps1_pde_address {0xC88E826E}; dword
nv_write gps1_pde_port {0x22B8}; dword

;=========================================================================
err_clr 0xff  

print "End of Service Programming"
mode reset
