?///////////////////////////////////////////////////////////////////////                                             */
?//   FILE: OPTS_04.MAC
?//                                                                   
?//   DOCUMENT/REVISION: TBD                         
?//                                                                   
?//   DESCRIPTION: This macro is used to test IRDB MS code            
?//                using OVER THE AIR PROGRAMMING TELESERVICES        
?//                (OPTS). All IRDB information elements are input    
?//                from the user and are assembled to be put into     
?//                the RDATA information element. This script also 
?//                includes the added protocol discriminator element.                     
?//                Number cellular and Number PCS fields are increased
?//                8 to 16 bits.
?//                                                                   
?//   Copyright Ericsson Inc. 1996                                    
?//                The copyright to the computer program here is the  
?//                property of Ericsson Inc. The program(s) may be    
?//                used and/or copied only with the written           
?//                permission from Ericsson Inc. or in accordance     
?//                with the terms and conditions stipulated in the    
?//                agreement or contract uner which the program(s)    
?//                have been supplied.                                
?///////////////////////////////////////////////////////////////////////
?///////////////////////////////////////////////////////////////////////
?// Current Version Information - DO NOT MODIFY THIS AREA              $
?// $Revision::   1.0                                                  $
?//     $Date::   27 Jan 1997 13:52:04                                 $
?//   $Author::   watson                                               $
?///////////////////////////////////////////////////////////////////////
? 
?// Main macro: OPTS_04.MAC
?// Sub macros: print_menu, get_mask, store_rdata_temp_word,
?//             set_user_values, build_data_block
?//             print_data_block, send_SPACH_Notification
?//             wait_for_accept, send_SPACH, Send_RDATA, dcch_setup
?//             get_ch, rnd_ch_ab, ch_a, ch_b
? 
? 
?*pmc
?var pch_sub
?var block[355]
?var RDataRejectCause
?var spach_notify_fail, spach_data_fail
?var tempirdb[87]
?var index
?var open_bits_in_word = 8
?var system_select, band_select
? 
?var phnum       // for storing the MSID, added 8/15/97
?var nfb, neb 
? 
?const PLC_TIME, 4                                 
?const NOTIFY_TIME, 4000
?const ACCEPT_TIME, 4000
?const REL_TIME, 400      // limit for Release Ack
?const SBC_SOC, 4             // sah 8/15/97
? 
?///////////////////////////////////////////////////////////////////////
?//PrintMenu: displays a menu of options from which the user will choose
?///////////////////////////////////////////////////////////////////////
?*dmc "PrintMenu", begin
?   var key_value
?   erase:text 0,305,640
?   center "  Select an OPTS message",0,305,640
?   print "  Enter option desired from menu below (1 for OPTS)"
?   print "  1)  OPTS test 1: User sets all values"
?   print "  'q' or 'Q' to quit"
?   do
?     tpause
?   until key?
?   key_value = key
?   return key_value
?end
? 
?///////////////////////////////////////////////////////////////////////
?//get_mask: gets mask based upon bit position given as input
?///////////////////////////////////////////////////////////////////////
?*dmc "get_mask", begin
?    var mask32bits = 0
?  
?    case $1
?      of 0:
?        mask32bits = #h00000000
?      of 1:
?        mask32bits = #h00000001
?      of 2:
?        mask32bits = #h00000003
?      of 3:
?        mask32bits = #h00000007
?      of 4:
?        mask32bits = #h0000000f
?      of 5:
?        mask32bits = #h0000001f
?      of 6:
?        mask32bits = #h0000003f
?      of 7:
?        mask32bits = #h0000007f
?      of 8:
?        mask32bits = #h000000ff
?      of 9:
?        mask32bits = #h000001ff
?      of 10:
?        mask32bits = #h000003ff
?      of 11:
?        mask32bits = #h000007ff
?      of 12:
?        mask32bits = #h00000fff
?      of 13:
?        mask32bits = #h00001fff
?      of 14:
?        mask32bits = #h00003fff
?      of 15:
?        mask32bits = #h00007fff
?      of 16:
?        mask32bits = #h0000ffff
?      of 17:
?        mask32bits = #h0001ffff
?      of 18:
?        mask32bits = #h0003ffff
?      of 19:
?        mask32bits = #h0007ffff
?      of 20:
?        mask32bits = #h000fffff
?      of 21:
?        mask32bits = #h001fffff
?      of 22:
?        mask32bits = #h003fffff
?      of 23:
?        mask32bits = #h007fffff
?      of 24:
?        mask32bits = #h00ffffff
?      of 25:
?        mask32bits = #h01ffffff
?      of 26:
?        mask32bits = #h03ffffff
?      of 27:
?        mask32bits = #h07ffffff
?      of 28:
?        mask32bits = #h0fffffff
?      of 29:
?        mask32bits = #h1fffffff
?      of 30:
?        mask32bits = #h3fffffff
?      of 31:
?        mask32bits = #h7fffffff
?      of 32:
?        mask32bits = #hffffffff
?      otherwise:
?        print "error getting mask, Please try again"
?    endcase
? 
?    return mask32bits
?end
? 
?///////////////////////////////////////////////////////////////////////
?// store_rdata_temp_word: stores variable number of bits given as input
?//                        and messages it into an 8 bit word  
?//                        for temporary RDATA storage.
?///////////////////////////////////////////////////////////////////////
?*dmc "store_rdata_temp_word", begin
?   var bit_mask = 0
?   index = $1                     // save the array element indicator
?   var number_of_bits             // for input value
?   var shift_number               // number of bits to shift left or right
?   var open_bits_in_word2         // available bits in 8 bit word
?   var inputvalue                 // copy of tempirdb value that won't change
? 
?   number_of_bits = $2            // save the number of bits to store
?                                  //  in the temporary RDATA array.
?   inputvalue = tempirdb[index]
?   do 
?     open_bits_in_word2 = open_bits_in_word
?     bit_mask = get_mask number_of_bits  
?     tempirdb[index] = inputvalue & bit_mask    
?                                  // calculate number of bits to shift
?                                  //  and in what direction.
?     if (number_of_bits >= open_bits_in_word)
?       shift_number = number_of_bits - open_bits_in_word
?       tempirdb[index] = tempirdb[index] >>shift_number  
?     else     
?       shift_number = open_bits_in_word - number_of_bits
?       tempirdb[index] = tempirdb[index] <<shift_number  
?     endif
?                                  // or in data to array that will be 
?                                  //  input to IFR rdata command.                              
?     block[x] = block[x] | tempirdb[index] 
?                                  // reset the number of bits available to 
?                                  //  to be stored into word if the number
?                                  //  of bits to store is greater than
?                                  //  or equal to.
?     if (open_bits_in_word <= number_of_bits)
?       open_bits_in_word = 8      // RDATA will be on byte boundaries
?       ++x                        // increment to the next word
?     else
?                                  // number of bits to store is less than
?                                  // what's available in this word so 
?                                  //  figure out what is left and available
?       open_bits_in_word = open_bits_in_word - number_of_bits
?     endif
?                                  // calculate number of bits that are left
?                                  //  to store
?     number_of_bits = number_of_bits - open_bits_in_word2
? 
?   until (number_of_bits <= 0)    // stay in loop until all bits have been
?                                  //  stored
?end
? 
?///////////////////////////////////////////////////////////////////////
?// set_user_values: For OPTS programming, this macro takes user input
?//                  for the values that make up the IRDB database and
?//                  stores them in an array to be used as the RDATA
?///////////////////////////////////////////////////////////////////////
?*dmc "set_user_values", begin
?  var enter_pd = 0
?  var enter_opts_msgtype = 0
?  var enter_opts_msglength = 0
?  var enter_bands_search = 0
?  var enter_ir_ctrl_data = 0
?  var enter_irdb_socs = 0
?  var enter_irdb_sids = 0
?  var enter_irdb_favsids = 0
?  var enter_irdb_forbidsid = 0 
?  var enter_irdb_favsocs = 0
?  var enter_irdb_forbidsocs = 0
?  var enter_irdb_rescanlp = 0
?  var enter_irdb_rescanct = 0
?  var enter_irdb_cellular = 1 
?  var enter_irdb_pcs = 1
? 
?  for y = 0 to 87
?    tempirdb[y] = 0
?  next y
?  
? 
?  x = 0
?  y = 0
?  // input "Enter Protocol Discriminator (PD = 2 bits)",enter_pd
?  enter_pd = 0     // hard coded to 0 by br, 11/19/97
?  tempirdb[y] = enter_pd
?  store_rdata_temp_word y, 2
? 
?  // input "OPTS message type (1 = IRDB)",enter_opts_msgtype
?  enter_opts_msgtype = 1     // hard coded to 1 by br, 11/19/97
?  tempirdb[y] = enter_opts_msgtype
?  store_rdata_temp_word y, 6
? 
?  tempirdb[y] = enter_opts_msglength
?  store_rdata_temp_word y, 8
?                                                  
?  input "IR Control Data - Bit0 (0 or 1)",enter_ir_ctrl_data
?  tempirdb[y] = enter_ir_ctrl_data
?  store_rdata_temp_word y, 8
? 
?  for y = 0 to 7
?    tempirdb[y] = 0
?  next y
?  
?  input "Number of bands to be searched", enter_bands_search
?  if enter_bands_search != 0 
? 
?   print "1 = a cellular"
?   print "2 = b cellular"
?   print "3 = A PCS"
?   print "4 = B PCS"
?   print "5 = C PCS"
?   print "6 = D PCS"
?   print "7 = E PCS"
?   print "8 = F PCS"
?   print "0 = no search"
? 
?   y = 0
?   do 
?     input "Next PCS or cellular band",a
?     tempirdb[y] = a
?     y = y + 1
?     enter_bands_search = enter_bands_search - 1
?   until enter_bands_search = 0
?  endif
?  
?  for y = 0 to 7
?    store_rdata_temp_word y, 4
?  next y
?    
?  y = 0
?  input "Number of partner SOCs", enter_irdb_socs
?  tempirdb[y] = enter_irdb_socs
?  store_rdata_temp_word y, 8
? 
?  if enter_irdb_socs != 0 
?   do
?     input "Next SOC value",a 
?     tempirdb[y] = a
?     store_rdata_temp_word y, 16
?     enter_irdb_socs = enter_irdb_socs - 1
?   until enter_irdb_socs = 0
?  endif
?  
?  input "Number of partner SIDs", enter_irdb_sids
?  tempirdb[y] = enter_irdb_sids
?  store_rdata_temp_word y, 8
? 
?  if enter_irdb_sids != 0 
?   do 
?     input "Next SID value",a
?     tempirdb[y] = a
?     store_rdata_temp_word y, 16
?     enter_irdb_sids = enter_irdb_sids - 1
?   until enter_irdb_sids = 0
?  endif
? 
?  input "Number of favored SOCs", enter_irdb_favsocs
?  tempirdb[y] = enter_irdb_favsocs
?  store_rdata_temp_word y, 8
? 
?  if enter_irdb_favsocs != 0 
?   do 
?     input "Next favored SOC number", a
?     tempirdb[y] = a
?     store_rdata_temp_word y, 16
?     enter_irdb_favsocs = enter_irdb_favsocs - 1
?   until enter_irdb_favsocs = 0
?  endif
? 
?  input "Number of favored SIDs", enter_irdb_favsids
?  tempirdb[y] = enter_irdb_favsids
?  store_rdata_temp_word y, 8
? 
?  if enter_irdb_favsids != 0 
?   do
?     input "Next favored SID number", a
?     tempirdb[y] = a
?     store_rdata_temp_word y, 16
?     enter_irdb_favsids = enter_irdb_favsids - 1
?   until enter_irdb_favsids = 0
?  endif
? 
?  input "Number of forbidden SOCs", enter_irdb_forbidsocs
?  tempirdb[y] = enter_irdb_forbidsocs
?  store_rdata_temp_word y, 8
? 
?  if enter_irdb_forbidsocs != 0 
?   do 
?     input "Next forbidden SOC number", a
?     tempirdb[y] = a
?     store_rdata_temp_word y, 16
?     enter_irdb_forbidsocs = enter_irdb_forbidsocs - 1
?   until enter_irdb_forbidsocs = 0
?  endif
? 
?  input "Number of forbidden SIDs", enter_irdb_forbidsid
?  tempirdb[y] = enter_irdb_forbidsid
?  store_rdata_temp_word y, 8
?  
?  if enter_irdb_forbidsid != 0 
?   do
?     input "Next forbidden SID number", a                        
?     tempirdb[y] = a
?     store_rdata_temp_word y, 16
?     enter_irdb_forbidsid = enter_irdb_forbidsid - 1
?   until enter_irdb_forbidsid = 0
?  endif
? 
?  input "Number of cellular probability blocks to search (1-16)", enter_irdb_cellular
?  tempirdb[y] = enter_irdb_cellular
?  store_rdata_temp_word y, 16
? 
?  input "Number of PCS sub-bands to search (1-7)", enter_irdb_pcs
?  tempirdb[y] = enter_irdb_pcs
?  store_rdata_temp_word y, 16
? 
?  input "Rescan Count", enter_irdb_rescanct
?  tempirdb[y] = enter_irdb_rescanct
?  store_rdata_temp_word y, 16
? 
?  input "Rescan Loop", enter_irdb_rescanlp
?  tempirdb[y] = enter_irdb_rescanlp
?  store_rdata_temp_word y, 16
? 
?// note: opts message length calculation = (x+1)-2 because array starts
?//       from 0 which accounts for the (x + 1) and (-2) because the 
?//       array includes pd,message type and message length which account
?//       for 2 array positions.
? 
?  enter_opts_msglength = (x+1) - 2
?  enter_opts_msglength = enter_opts_msglength & #h000000ff
?  block[1] = enter_opts_msglength
? 
?end
? 
?///////////////////////////////////////////////////////////////////////
?// build_data_block:This macro transfers data from temporary storage to
?//                  the IFR rdata unit. 
?///////////////////////////////////////////////////////////////////////
?*dmc "build_data_block", begin
?  var i, j
?    // use block array to build hlp data statements
?  j = 0
?  while j <= x
?    :css:spach:rdata_unit:hlp:data j, block[j]
?    j++
?  wend
?  :css:spach:rdata_unit:length j+1     // length is block size + 1 (for Protocol ID)
?end
? 
?///////////////////////////////////////////////////////////////////////
?// print_data_block:This macro prints the hlp data
?///////////////////////////////////////////////////////////////////////
?*dmc "print_data_block", begin
?var  j
?  print "hlp data length", x
? 
?  j=0
?  print "data block built"
?  while j+1 < :css:spach:rdata_unit:length?  // 1 to length-1 gives all data bytes
?    print ":hlp:data ", j, block[j]
?    j++
?  wend
?end
? 
?///////////////////////////////////////////////////////////////////////
?// Send_SPACH_Notification: This macro sends the spach notification
?//                          message on the paging channel of the FDCCH
?///////////////////////////////////////////////////////////////////////
?*dmc "Send_SPACH_Notification",begin
?var ktimer
?  erase:text 0,35,640
?  center "Sending SPACH Notification",0,35,640
?  delay 500
?  :rdcch:length:normal
?  :rdcch:l3data:sel 0
?  //Header A
?  :css:spach:bu 7                       // PCH = 7; (spec chart 7.1 says PCH)
?  // :css:spach:pcon ?? // 0=no PCH continuation
?  :css:spach:bcn 0                      // BCN (Broadcast Channel Change Flag) = 0
?  :css:spach:pfm 0                      // PFM (Paging Frame Modifier) = 0
?  //Header B
?  :css:spach:bt 0                       // Burst Type = 0    (Single MSG Frame)
?  :css:spach:idt 2                      // Identity Type = 2 (34 bit MSID)
?  :css:spach:mm 0                       // MM  (Message Mapping) = 0
?  // :css:spach:srm ??  // how MS is to respond 0=contention, 1=reservation
?  :css:spach:ehi 0                      // EHI (Extended Header Information) = 0
?  :css:spach:min1 phnum        // Min Number
?  :css:spach:msgtype1:spachnotification
?  :css:spach:notification 26             // R-DATA message
?  send_pch pch_sub                       // send the notification in slot pch_sub
?  // get confirmation to SPACH Notification
?  erase:text 0,35,640
?  center "Waiting for SPACH Confirmation",0,35,640
?  ktimer = 0
?  spach_notify_fail = 0
?  do
?    tpause
?    $ = :rdcch:msgtype?                 // Wait for something on the RACH
?    if ($ != "-1")
?      print $
?    endif
?    ktimer++
?  until key? or ($ = "SPACHCON") or (ktimer > NOTIFY_TIME)
? 
?  if ktimer > NOTIFY_TIME
?     spach_notify_fail = 1
?  elif ($ != "SPACHCON")
?     print key
?  else
?    print
?    print "Data Received on the RACH"
?    print "========================="
?    print "Message #1: ", $
?    :rdcch:l3data:sel 1
?    print "Message #2: ", :rdcch:msgtype?
?    :rdcch:l3data:sel 2
?    print "Message #3: ", :rdcch:msgtype?
?  endif
?end
? 
?///////////////////////////////////////////////////////////////////////
?// wait_for_accept: This macro waits for the RDATA accept message from
?//                  the mobile station since the RDATA has been sent by
?//                  the IFR
?///////////////////////////////////////////////////////////////////////
?*dmc "wait_for_accept", begin
?var ktimer
?var k
?  ktimer = 0
?  spach_data_fail = 0
?  do
?    tpause
?    $ = :rdcch:msgtype?                 // Wait for something on the RACH
?    if ($ != "-1")
?      print $
?    endif
?    ktimer++
?  until key? or ($ = "R-DATA ACCEPT") or (ktimer > ACCEPT_TIME) or ($ = "R-DATA REJECT") // br 11/18/97
?  if ($ = "R-DATA REJECT")
?     RDataRejectCause = :rdcch:rcause?
?     spach_data_fail = 1     // added 9/4/97, ckc
?  elif ktimer > ACCEPT_TIME
?     spach_data_fail = 2     // changed from 1 to 2 9/4/97, ckc
?  elif ($ != "R-DATA ACCEPT")
?    k = key   // resets key function
?  endif
?end
? 
?///////////////////////////////////////////////////////////////////////
?// send_SPACH: This macro sends the actual RDATA
?///////////////////////////////////////////////////////////////////////
?*dmc "send_SPACH", begin
?var i, j, sz
?  :css:spach:bu 4                       // Burst Usage = 4   (SMSCH)
?  :css:spach:bt 0                       // Burst Type = 0    (Single MSG Frame)
?  :css:spach:idt 2                      // Identity Type = 2 (34 bit MSID)
?  :css:spach:min1 phnum         // Min Number
?  :css:spach:bcn 0                      // BCN (Broadcast Channel Change Flag) = 0
?  :css:spach:pfm 0                      // PFM (Paging Frame Modifier) = 0
?  :css:spach:mm 0                       // MM  (Message Mapping) = 0
?  :css:spach:ehi 0                      // EHI (Extended Header Information) = 0
?  :css:spach:msgtype1:rdata             // Send SPACH data
?  :css:spach:build:nonarq
?  sz=:css:spach:length:nonarq?
?  print "Size of OPTS data =", sz
?  do                                    // Wait until the end of the superframe
?  until key? or (:css:fdcch:super:num? = 31 and :css:fbcch:super? = 1)
?  :css:spach:program:nonarq pch_sub,0,sz
?  delay 50
?  do                                    // Wait until the end of the superframe
?  until key? or (:css:fdcch:super:num? = 31 and :css:fbcch:super? = 1)
?  for j = 0 to sz-1
?    for i = 0 to 6                      // Zero out the message just sent.
?      :css:fdcch:super:data pch_sub+j,i,0
?    next i
?  next j
?end
? 
?///////////////////////////////////////////////////////////////////////
?// SendRDATA: This macro transfers the RDATA from temporary storage to 
?//            the actual IFR command that will hold the data and then
?//            causes the data to be sent
?///////////////////////////////////////////////////////////////////////
?*dmc "SendRDATA",begin
?  :css:spach:msgtype1:rdata
?  :css:spach:rtransaction RND(256)      // random
?  // R-Data Unit (do length in build_data_block macro)
?  :css:spach:rdata_unit:hlp:id 128        // OPTS hlp identifier = x80
?  build_data_block   // sets block array to current values
?  print_data_block
?  send_SPACH
?end
? 
? 
?///////////////////////////////////////////////////////////////////////
?//ch_a: choose a side channel with input from the user
?///////////////////////////////////////////////////////////////////////
?*dmc "ch_a",begin
?var cn
? 
?  case band_select
? 
?    of 1:    // cellular
?       cn = 0
?       while cn = 0
?           input "Choose A side channel (0-333, 667-716, 991-1023)", cn
?           if cn > 1023
?             cn = 0 
?           endif
?          if cn > 333 and cn < 667
?             cn = 0
?          endif 
?          if cn > 717 and cn < 991
?             cn = 0
?           endif
?           if cn <0
?             cn = 0
?           endif
?       wend
? 
?    of 2:    // PCS
?       cn = 0
?       while cn = 0
?           input "Choose A side channel (2-501)", cn
?           if cn > 501 
?             cn = 0 
?           endif
?           if cn < 2
?             cn = 0
?           endif
?       wend
? 
?     otherwise:
?          cn = 0
? 
? endcase
? 
? return cn
?end
? 
?///////////////////////////////////////////////////////////////////////
?//ch_b: choose b side channel with input from the user
?///////////////////////////////////////////////////////////////////////
?*dmc "ch_b",begin
?var cn
? 
?  case band_select
? 
?    of 1:    // cellular
?       cn = 0
?       while cn = 0
?           input "Choose B side channel (334-666, 717-799)", cn
?           if cn >= 800 
?             cn = 0 
?           endif
?           if cn <= 716 and cn  >= 667
?             cn = 0
?           endif
?           if cn <= 333
?             cn = 0
?           endif
?       wend
? 
?    of 2:    // PCS
?       cn = 0
?       while cn = 0
?           input "Choose B side channel (666-1167)", cn
?           if cn > 1167 
?             cn = 0 
?           endif
?           if cn < 666
?             cn = 0
?           endif
?       wend
? 
?     otherwise:
?          cn = 0
? 
? endcase
? 
? return cn
? 
?end
? 
?///////////////////////////////////////////////////////////////////////
?//get_ch: get channel based on system selected (random, a or b)
?///////////////////////////////////////////////////////////////////////
?*dmc "get_ch",begin
? 
?   if system_select = 1 
?      a = ch_a 
?   endif
? 
?   if system_select = 2
?    a =  ch_b
?   endif
?return a
?end 
? 
?///////////////////////////////////////////////////////////////////////
?// reg_ms: This macro waits for the MS to register,
?//      determines the MSID, and sends Reg Accept
?///////////////////////////////////////////////////////////////////////
?*dmc "reg_ms", begin
?  var paid, ns, nsb, nrs, nnp, nb, np
?  var key_value = 0
? 
?  :rdcch:length:normal
?  :rdcch:l3data:sel 0
? 
?  key_value=0
?  print "Waiting for Registration"
?  print "Hit any key to quit"
?  do
?    tpause
?    $ = :rdcch:msgtype?
?    if ($ != "-1") 
?      print $
?    endif
?  until key? or ($ = "REGISTRATION")
? 
? 
? 
?  if ($="REGISTRATION")
?    phnum = :rdcch:min?
?    print "MSID: ",phnum," Registered"
?    :css:spach:min1 phnum     // added for correct calculation of paid, ckc 9/3/97
? 
?    // Calculate our PCH subchannel
?    paid = (:css:spach:msid:ls? 0) & #hffff
?    print "PAID: ", paid
?    ns = 2
?    nsb = :css:fbcch:number:sbcch?
?    nrs = :css:fbcch:number:res?
?    nnp = :css:fbcch:number:non_pch?
?    nb = nfb+neb+nsb+nrs
?    print  "nb=",nb                 // number of system broadcasts
?    np = (32-nb)-(nnp*2)
?    print "np=",np
?    pch_sub = ((paid/ns)%np)+nb
?    print "pch_subchan = ",pch_sub
? 
? 
?    :css:spach:bu 3
?    :css:spach:bt 0
?    :css:spach:idt 2
?    :css:spach:min1 phnum
?    :css:spach:bcn 0
?    :css:spach:pfm 0
?    :css:spach:mm 0
?    :css:spach:ehi 0
?    :css:spach:enable:rnum:list 0
?    :css:spach:enable:pfc:assignment 0
?    :css:spach:enable:msid:assignment 0
?    :css:spach:enable:user:group 0
?    :css:spach:enable:psid_rsid:avail 0
?    :css:spach:enable:disp 0
?    :css:spach:enable:dir:addr 0
?    :css:spach:enable:dir:sub 0
?    :css:spach:msgtype1:reg_accept
? 
?    send_arch pch_sub
?    print "Sending Registration Accept to Mobile"
? 
?  else      // $ != Registration
? 
?    print "Exiting (phone has not registered)"
?    key_value = key
? 
?  endif
? 
?  return key_value
? 
?end
? 
? 
?///////////////////////////////////////////////////////////////////////
?// dcch_setup:This macro sets up the DCCH with all the mandatory FBCCH
?//            and EBCCH messages. 
?///////////////////////////////////////////////////////////////////////
?*dmc "dcch_setup", begin
?var enter_sid
?// var paid,np,nb,nfb,neb,nsb,nrs,nnp,ns  // moved to reg_ms macro
?var i
?var ch_num
? 
?  //-------------------------------------- SETUP EQUIPMENT TO TRANSMIT
?  :css:set
?  delay 500
? 
?  input "SELECT HYPERBAND (1 = Cellular, 2 = PCS): ", band_select
?  freq:band band_select
? 
?  input "SELECT SYSTEM (1 = A only, 2 = B only)", system_select
?  ch_num = get_ch
?  :css:chan ch_num                    // Channel number
? 
?  // set RF level
?  :css:rflvl -55                      // (DCC 4/5 needs valid DCCH rflvl >= -89 dBm)
?  :css:rate 0                         // Full Rate
? 
?  //sets Automatic Gain Control from 0-255
?  host ":dup:inp:agc:man 100"
? 
?  //sends previous commands out the SCSI to the 1600S
?  hflush
? 
?  //set the rdcch to be rach
?  :css:fdcch:super:acc:rand            // Random Access
?  :css:fdcch:super:access:pe 0         // No collision because we are only conversation on the air
?  enable_sat 0
? 
?  //-------------------------------------- DATA COMMON TO ALL SLOTS
?  :css:fdcch:super:zero                // Set all fields to zero
?  for i = 0 to 31
?    :css:fdcch:super:sfp i,i           // Program the SFP
?    :css:fdcch:super:rn i,0            // RN (received/not received) bits programed to 0
?    :css:fdcch:super:bri i,0           // BRI (busy/resv/idle) bits programed to 0
?    :css:fdcch:super:pe i,0            // PE (partial echo) bits programed to 0
?  next i
?  //by definition, we send *at least* 4 frames
?  for i = 4 to 31                      // Frames 7-32 are SPACH
?    css:fdcch:super:type i,3
?  next i
?  :css:fdcch:super:start
?  :css:fdcch:super:dvcc #h2c
?  :css:fbcch:fc 0                    // F-BCCH Change (new data?)
?  :css:fbcch:ec 0                    // E-BCCH Change (new data?)
?  //-------------------------------------- FBCCH Structure Message
?  :css:fbcch:msg:struct 1               // Enable FBCCH Structure Message
?  :css:fbcch:num:fbcch 2                // Number of FBCCH = 0
?  :css:fbcch:num:ebcch 1                // Number of EBCCH = 0
?  :css:fbcch:num:sbcch 0                // No SBCCH
?  :css:fbcch:num:res 0                  // No reserved
?  :css:fbcch:con 1                      // Use slot configurtion 1
?  :css:fbcch:dvcc #h2c                  // Use DVCC of #h2c???
?  :css:fbcch:pfc 0                      // Max supported PFC = 0
?  :css:fbcch:pch 0                      // PCH Displacement = 0
?  :css:fbcch:pfm 0                      // PFM Direction = 0
?  :css:fbcch:num:non_pch 0              // Number of non-pch subchannel slots
?  //-------------------------------------- FBCCH System Access Message
?  :css:fbcch:msg:acc 1                  // Enable Access Parameters Message
?  :css:fbcch:auth 0                     // Disable Authentication
?  :css:fbcch:s 1                        // Send serial number message
?  :css:fbcch:rand 0                     // Random number for auth = 0
?  :css:fbcch:acc:ms_pwr 0               // Mobile station shall use ATTN=0
?  :css:fbcch:acc:burstsize 0            // Use abbreviated length burst on the RACH ???
?  :css:fbcch:max:retries 7              // Max Retries=7
?  :css:fbcch:max:busy 1                 // Max Busy/Reserved = 1
?  :css:fbcch:max:repetitions 3          // Max Repetitions = 3
?  :css:fbcch:max:stop 1                 // Max Stop Counter = 1
?  :css:fbcch:rdata:length 0             // R-DATA Message Length = 0
?  :css:fbcch:barred 0                   // Cell Barred = off
?  :css:fbcch:subaddressing 0            // Subaddressing support = no
?  :css:fbcch:dic 0                      // Delay Interval Compenstation = off
?  //-------------------------------------- FBCCH Control Channel Selection
?  :css:fbcch:msg:sel 1                  // Enable Control Channel Selection Param.
?  :css:fbcch:ss_suff 0                  // Minimum Signal Strength allowed = -120 dB
?  :css:fbcch:acc:rss_min 0              // Minimum signal strength to access cell = -120 dB
?  :css:fbcch:scan:interval 0            // Scan Interval = 0
?  :css:fbcch:initial 0                  // Initial Selection Control = 0
?  :css:fbcch:delay 0                    // Delay 0 Superframes
?  :css:fbcch:scan:option 0              // Do not use optional enhancements
?  //------------------------------------- FBCCH Registration Parameters
?:css:fbcch:msg:registration 1        // Enable Registration Message
?  :css:fbcch:regh 1                    // Allow home mobile station to register
?  :css:fbcch:regr 1                            // Allow roaming
?  :css:fbcch:pureg 1                           // Allow power-up registration
?  :css:fbcch:pdreg 1                   // Allow power-down registration
?  :css:fbcch:syreg 1                   // Register when entering a new ID area
?  :css:fbcch:lareg 1
?  :css:fbcch:dereg 1                   // Allow de-registration
?  :css:fbcch:foreg 1                   // Forced registration
?  :css:fbcch:capability 1              // Send a Capability Request Message
?  //------------------------------------- FBCCH System ID
?  :css:fbcch:msg:sysid 1               // Enable System ID Message
?  input "enter SID for phone to register on",enter_sid
?  :css:fbcch:sid  enter_sid            // System ID=??
?  :css:fbcch:net 4                     // Network type = 4 (Public)
?:css:fbcch:prot 4                    // Protocol Version = 4 (IS136-A, sah 8/13/97)
?  :css:fbcch:enable:psid_rsid 0        // do not build PSID/RSID list
?  :css:fbcch:enable:alpha:sid 1        // Enable ALPHA SID
?  :css:fbcch:alpha:sid "OPTS via IFR" // Set ALPHA SID
?  //------------------------------------- Build FBCCH Frames
?  :css:fbcch:build
?  nfb =  :css:fbcch:length?
?  print "Building FBCCH Frames ..."
?  print "Number of FBCCH Frames = ",nfb
?  if nfb < 0
?    nfb = 0
?  endif
?  :css:ebcch:ecl 2  // number of unique ebcch per superframe
?  //------------------------------------- Build EBCCH Neighbor Cell MSG
?  :css:ebcch:msg:neigh:cell 1           // Enable Neighbor Cell Message
?  :css:ebcch:serv_ss 0                 // Reselection Trigger condition not allowed
?  :css:ebcch:enable:neighbor:tdma 0    // Enable TDMA Neighbor List OE
?  :css:ebcch:neighbor:tdma:number 0    // Send 3 NL entries
?  //------------------------------------- Build EBCCH Regulatory Config MSG
?  :css:ebcch:msg:rci 1                 // Enable Regulatory Information
?  :css:ebcch:rci 1                     // RCI=1 (ref 6.3.1.1.2)
?  //------------------------------------- Build a Service Menu MSG
?  :css:ebcch:msgtype:service 1         // Enable Service Menu
?  :css:ebcch:map:vpm 0                 // No voice privacy map
?  :css:ebcch:map:dpm 0                 // No digital voice privacy
?  :css:ebcch:map:coder 3               // Support multiple coders
?  :css:ebcch:map:mea:domain 0
?  :css:ebcch:map:mea:algor 0,0         // No message encryption
?  :css:ebcch:map:mek 0
?  :css:ebcch:map:menu 4                // Full Rate DTC
?  :css:ebcch:map:arq 0                 // No ARQ
?  :css:ebcch:map:user 0
?  :css:ebcch:map:sms 3                 // SMS (All rx/tx)
?  //-------------------------------------- FBCCH SOC/BSMC ID Message (sah 8/13/97) moved to ebcch (br 10/4/97)
?  :css:ebcch:msg:soc_bsmc 1            // enable soc_bsmc message
?  :css:ebcch:soc SBC_SOC               // set soc=4 (Soutwestern Bell)
?  :css:ebcch:bsmc 0                    // set bsmc=0
? 
?  ///////////////////////////////////////////////////////////////////////
?  // Added IRA and OATS Service Menu IE's (sah 8/14/97)
?  :css:ebcch:ira 1                // IRA support IE is set on
? 
?  // build OATS Support IE using user defined messaging
?  :css:ebcch:opt:msg 0,8          // build service menu message type
?  :css:ebcch:opt:length 0,1       // IE is 1 bit long
?  :css:ebcch:opt:data 0,0,#h8000  // Set MSB=1 of 16-bit word to set on
?  ///////////////////////////////////////////////////////////////////////
? 
?  //------------------------------------- Build the EBCCH Messages
?  :css:ebcch:build
?  neb = :css:ebcch:length?
?  :css:fbcch:number:fbcch nfb-3    //number:fbcch is number of additional fbcch (past required 3)
?  :css:fbcch:number:ebcch neb-1    // (past required 1)
?  print "Building EBCCH Messages"
?  print "Number of EBCCH Messages: ",neb
?  :css:fbcch:build;program
?  :css:ebcch:program nfb,0,neb  // 0 is the start location in the ebcch buffer
?  :css:fdcch:super:increment 1  // automatically increment hyperframe counter
? 
?end
? 
?///////////////////////////////////////////////////////////////////////
?// OPTS_04:This is the main macro that will call all the sub macros.
?//         Macro will call to setup the DCCH and then coordinate 
?//         sending the RDATA for OPTS
?///////////////////////////////////////////////////////////////////////
?*dmc "OPTS_04",begin
?   var i, j, KeyValue, temp
?   var a, new_str
? 
?  a = syst:time?
?  rand a
? 
?  dcch_setup
?  
?  user
?  erase:text 0,5,640
?  center "OPTS_04 MACRO PROGRAM", 0, 5, 640  
?  erase:text 0,35,640
?  center "Test OPTS Functionality for IS-136-A Mobiles", 0, 35, 640
? 
?  ///////////////////////////////////////////////////////////////////////
?  // Added by sah 8/15/97 to get MIN at power up
?  print "Power up the Mobile"
?  KeyValue = reg_ms
?  if(KeyValue = 0)
? 
?     erase:text 0,150,640
?     center phnum, 0, 150, 640
? 
?  while (KeyValue!=81) and (KeyValue!=113)
?    tpause
?    KeyValue = PrintMenu
? 
?    case KeyValue
?      of 49:
?        set_user_values
?      otherwise:
?        print "XXX, Please try again"
?    endcase
? 
?    if (KeyValue!=81) and (KeyValue!=113) and (KeyValue!=13)
?      print "Sending Spach Notification ...."
?      Send_SPACH_Notification
? 
?      if (spach_notify_fail = 0)  //success
? 
?        :rdcch:length:normal
?        :rdcch:l3data:sel 0
?        
?        SendRDATA   // send message
?        
?        print "Waiting for R-Data Accept"
?        wait_for_accept  //Get R-DATA Accept
?      
?        if (spach_data_fail = 0) //success
?          print "Received R-Data Accept"
?        else
?          print "Spach Data Failed"
?        if(spach_data_fail = 1)     // added check for RDATA Reject 9/4/97, ckc
?           print "RDataRejectCause",RDataRejectCause
?        else
?           print "Timer expired"
?        endif
?        endif   // (spach_data_fail)
? 
?      else
?        print "Spach Notify Failed"
?      endif
? 
?    else
?      print "Exiting Program"
?    endif
? 
?  wend
? 
?  print "End of OPTS Testing"
? 
? endif // (KeyValue=0)
? 
?end
? 
?//   FILE OPTS_04.MAC                                                
?opts_04
SELECT HYPERBAND (1 = Cellular, 2 = PCS): ?1
SELECT SYSTEM (1 = A only, 2 = B only)?2
Choose B side channel (334-666, 717-799)?790
enter SID for phone to register on?164
Building FBCCH Frames ...
Number of FBCCH Frames =          4
Building EBCCH Messages
Number of EBCCH Messages:          2
Power up the Mobile
Waiting for Registration
Hit any key to quit
REGISTRATION
MSID: 000/200-3530 Registered
PAID:      52653
nb=         6
np=        26
pch_subchan =         20
Sending Registration Accept to Mobile
  Enter option desired from menu below (1 for OPTS)
  1)  OPTS test 1: User sets all values
  'q' or 'Q' to quit
IR Control Data - Bit0 (0 or 1)?0
Number of bands to be searched?3
1 = a cellular
2 = b cellular
3 = A PCS
4 = B PCS
5 = C PCS
6 = D PCS
7 = E PCS
8 = F PCS
0 = no search
Next PCS or cellular band?3
Next PCS or cellular band?2
Next PCS or cellular band?1
Number of partner SOCs?1
Next SOC value?45
Number of partner SIDs?1
Next SID value?46
Number of favored SOCs?1
Next favored SOC number?47
Number of favored SIDs?1
Next favored SID number?48
Number of forbidden SOCs?1
Next forbidden SOC number?49
Number of forbidden SIDs?1
Next forbidden SID number?50
Number of cellular probability blocks to search (1-16)?5
Number of PCS sub-bands to search (1-7)?3
Rescan Count?0
Rescan Loop?4
Sending Spach Notification ....
SPACHCON

Data Received on the RACH
=========================
Message #1: SPACHCON
Message #2: SERIAL NUMBER
Message #3: CAPABILITY
hlp data length        33
data block built
:hlp:data          0         1
:hlp:data          1        32
:hlp:data          2         0
:hlp:data          3        50
:hlp:data          4        16
:hlp:data          5         0
:hlp:data          6         0
:hlp:data          7         1
:hlp:data          8         0
:hlp:data          9        45
:hlp:data         10         1
:hlp:data         11         0
:hlp:data         12        46
:hlp:data         13         1
:hlp:data         14         0
:hlp:data         15        47
:hlp:data         16         1
:hlp:data         17         0
:hlp:data         18        48
:hlp:data         19         1
:hlp:data         20         0
:hlp:data         21        49
:hlp:data         22         1
:hlp:data         23         0
:hlp:data         24        50
:hlp:data         25         0
:hlp:data         26         5
:hlp:data         27         0
:hlp:data         28         3
:hlp:data         29         0
:hlp:data         30         0
:hlp:data         31         0
:hlp:data         32         4
:hlp:data         33         0
Size of OPTS data =         4
Waiting for R-Data Accept
R-DATA ACCEPT
Received R-Data Accept
  Enter option desired from menu below (1 for OPTS)
  1)  OPTS test 1: User sets all values
  'q' or 'Q' to quit
XXX, Please try again
Exiting Program
End of OPTS Testing
