Download Accessing RFCOMM Using RFCLI and TCL Application
Transcript
Appendix B
B2
Remote Device Script File
#Remote script
proc start_request {port_speed max_frame_size} {
global result_code connectionAttempts
global psm_remote respond_phandle
#Start Request
puts "RFC START Request"
set ps $port_speed
set fs $max_frame_size
for {set c 1} {$c < $connectionAttempts} {incr c} {
puts "Attempt: $c"
set port_speed $ps
set max_frame_size $fs
RFC_START_REQ - - - $psm_remote $port_speed $max_frame_size
$respond_phandle
RFC_START_CFM
#If result_code is not success we need to wait
while {$result_code == 1} {
RFC_START_CFM
}
puts "result_code: $result_code"
if {$result_code != 6} {return $result_code}
}
return $result_code
}
proc register_rfcomm {} {
global phandle server_chan accept
set state 0x00
while {$state == 0} {
#Register with RFCOMM
puts "Register with RFCOMM"
RFC_REGISTER_REQ $phandle
RFC_REGISTER_CFM
puts "Server Channel: $server_chan"
puts "Accept
: $accept"
puts "phandle
: $phandle"
if {$accept == 1} {
puts "RFCOMM Registration Accepted"
incr state +1
bcore-an-006Pa
© Copyright CSR 2002
This material is subject to CSR’s non-disclosure agreement.
Page 69 of 77
_äìÉ`çêÉ Accessing RFCOMM Using RFCLI and TCL
DM_AM_REGISTER_CFM
#Request RFCOMM Start
puts "Request RFCOMM Start"
start_request ${sys_pars.port_speed} ${sys_pars.max_frame_size}
#RFCOMM Parameter Negotiation
puts "RFCOMM Parameter Negotiation"
RFC_PARNEG_REQ $mux_id - - $max_frame_size $use_flow_control
$initial_credits
RFC_PARNEG_CFM
puts "Credits: ${dlc_pars.initial_credits}"
#RFCOMM Establish
puts "RFCOMM Establish"
RFC_ESTABLISH_REQ $mux_id $loc_server_chan $rem_server_chan
RFC_ESTABLISH_CFM
set state 1
#Main Loop
puts "Main Loop"
while {$state} {
checkstate
}
puts "All Done"
puts "Number of Transmitted Packets = $tx_buffer(transmitted)"
puts "Number of Received Packets
= $rx_buffer(received)"