here is a nice master code you can use:
the comments should help you to adapt the code for your use.
@ERASE
0 REM this is a service master code. It will find a device that
0 REM matches a name and a MAC address filter.
0 REM Line $1 discovered device buffer
1 0
0 REM Line $2 stores the name filter
2 AIRmini
0 REM Line $3 stores the address filter
0 REM only connect to AIRcable devices
3 0025BF
0 REM pin code
4 1234
0 REM CABLE MODE slave address
8 0
@INIT 50
0 REM debug
49 Z = 1
0 REM PIN code
50 $4 = "1234"
0 REM blue LED output and off
51 A = pioclr 20
0 REM RS232 POWER ON out and on, PIO12 (5X: PIO2)
52 A = pioout 3
53 REM A = pioclr 3
54 A = pioset 3
0 REM RS232 POWER OFF out and on, PIO11 (5X: PIO10)
55 A = pioout 11
56 A = pioset 11
0 REM RS232 DTR pin out and on, PIO13 (5X: PIO4)
57 A = pioset 5
58 A = pioout 5
0 REM Sleep mode PIO10 (low no deep sleep) and Handshake PIO15 (high enabled)
59 REM A = pioout 11
60 REM A = pioclr 11
61 REM A = pioout 16
62 REM A = pioset 16
0 REM empty discovered device buffer
63 $1 = "0"
65 A = baud 96
0 REM E will be used for state
0 REM E = 0 disconnected
0 REM E = 1 connected
66 E = 0
67 A = zerocnt
68 G = 1
69 $0="AIRservice "
70 A = getuniq $10
71 PRINTV $10
72 A = name $0
0 REM button state variable
73 W = 0
0 REM check for button, virtual PIO17
0 REM PIO17 goes high when pressed no need to change PIO
74 REM A=pioirq"P00000000000000001"
75 RETURN
0 REM slave call idle, called only exactly once
0 REM call ALARM to get started
@IDLE 90
0 REM set DTR to -5V
90 A = pioset 5;
0 REM LED off
91 A = pioclr 20;
92 ALARM 1
93 RETURN
0 REM change for INDUSTRIAL or other with no button otherwise keep at ALARM 100
@ALARM 120
0 REM check for button pressed
100 A = pioget 17;
101 IF A = 0 THEN 120;
0 REM long press power down
102 ALARM 0;
0 REM wait until button release
103 A = pioset 20
104 A = pioclr 20;
105 A = pioget 17;
106 IF A = 1 THEN 103;
107 W = 3;
108 A = reboot;
109 FOR E = 0 TO 10
110 WAIT 1
111 NEXT E
112 RETURN
0 REM check if we need to start an inquiry (E=1 master connect was successful)
0 REM blink leds
120 IF E = 1 THEN 140
121 A = pioset 20
122 A = delayms 100
123 A = pioclr 20
124 ALARM 5
125 A = strlen $1
126 IF A > 11 THEN 140
0 REM check CABLE MASTER MODE
130 A = strlen $8
131 IF A < 11 THEN 135
0 REM do a master connect, no inquiries
132 GOTO 250
0 REM inquiry stopped because of master match, start again
135 A = inquiry 9
136 RETURN
0 REM check FTP service and disable
140 IF G = 0 THEN 150
141 A = readcnt
142 IF A < 60 THEN 150
143 WAIT 3
144 A = disable 3
145 G = 0
146 GOTO 150
0 REM we are connected, lets check we are still connected
150 A = status
151 IF A = 0 THEN 155
152 ALARM 5
153 RETURN
0 REM we were disconnected
155 $1 = "0"
156 A = pioclr 20
0 REM set DTR to -5V
157 A = pioset 5
0 REM red LED back to charger control
158 A = pioclr 19
159 A = pioin 19
160 ALARM 1
0 REM status disconnected
161 E = 0
162 A = unlink 2
163 RETURN
@INQUIRY 198
198 A = pioclr 19
0 REM when this interrupt gets called we have on $0 an string like this:
0 REM 00112233445566 NAME where the number is the bt address.
0 REM we need to check first if the addess is on our block of address
0 REM then if the name matches the filter
199 $6 = $0[13];
200 REM PRINTU $6
201 $5 = $0;
202 $0 = $6;
203 A = strcmp $2;
204 IF A <> 0 THEN 217;
0 REM check address match
205 REM A = strcmp $3
206 REM IF A <> 0 THEN 217
207 $1 = $5
0 REM found a match, do connect and kill other inq, show on red light
208 A = pioout 19;
209 A = pioset 19;
210 A = inquiry 0;
212 A = master $1;
0 REM save address to try
214 $9 = $1;
0 REM indicate that we have tried the master, reset variable
215 $1 = "0";
0 REM call for ALARM to check connection
0 REM we don't get an IDLE call when master failed
216 ALARM 20;
217 RETURN
0 REM CABLE mode connect
250 A = master $8
251 $9 = $8
253 $1 = "0"
0 REM found a match, do connect and kill other inq, show on red light
254 A = pioout 19
255 A = pioset 19
256 ALARM 20
257 RETURN
@MASTER 300
0 REM connected
300 E = 1
0 REM blue on
301 A = pioset 20
0 REM give back red LED and clear
302 A = pioclr 19
303 A = pioin 19
0 REM set DTR to +5V
304 B = pioclr 5
0 REM RS232_on high
305 B = pioset 3
0 REM save the address that was successful, ENABLE FOR CABLE MODE
306 $8 = $9
0 REM connect RS232 to master
307 C = link 2
308 RETURN
0 REM button press interrupt
0 REM work with ALARM for long press
@PIO_IRQ 400
400 IF $0[17]=49 THEN 410;
0 REM ignore button release on long presses for reboot
401 IF W = 3 THEN 403;
0 REM was it a release, handle it
402 IF W <> 0 THEN 420;
403 RETURN
0 REM button press, save state, start ALARM
411 W = 1;
412 ALARM 3
413 RETURN
0 REM short button release disconnects master
420 A = disconnect 1
421 A = pioclr 20
422 RETURN
@PIN_CODE 500
0 REM fixed PIN code
500 $0=$4;
501 RETURN
512 END
> --
> You received this message because you are subscribed to the Google Groups
> "AIRcable(tm)" group.
> To view this discussion on the web visit
>
https://groups.google.com/d/msg/aircable/-/5NdcKqflRWgJ.
> To post to this group, send email to
airc...@googlegroups.com.
> To unsubscribe from this group, send email to
>
aircable+u...@googlegroups.com.
> For more options, visit this group at
>
http://groups.google.com/group/aircable?hl=en.