#!/usr/bin/expect -f
#
# This script is used for a KAM TNC. It initializes the TNC and then
# transmits every DX spot three times in UA mode. This configuration 
# was used by the TK5NN Multi/Multi group in the CQWW DX Phone Contest 
# 1997 from Corsica to receive spots vif HF from the Munich area.
#

# --------------------- User configurable ---------------------
set port "/dev/ttyS0"
set mycall "dj0zy"
# --------------------- User configurable ---------------------

set timeout 10
log_user 1

spawn /usr/bin/cu -l $port
set cu $spawn_id

expect "Connected."
sleep 1
expect *

send "\3\r"
expect "cmd:"
expect *

send "intface term\r"
expect "cmd:"

send "reset\r"
expect "cmd:"

send "echo on\r"
expect "cmd:"

send "mycall $mycall\r"
expect "cmd:"

send "monitor off/off\r"
expect "cmd:"

send "conok off\r"
expect "cmd:"

send "beacon 0/0\r"
expect "cmd:"

send "maxframe 1/1\r"
expect "cmd:"

send "digipeat off/off\r"
expect "cmd:"

send "hid off/off\r"
expect "cmd:"

send "streamsw \$7E/\$7C\r"
expect "cmd:"

send "convers\r"
sleep 1
expect *

send "~~aStarting DX Broadcast mode from $mycall\r"


send_user "\n\n\n***** TNC initialisation finished ***** \n\n\n"

expect "\n"

spawn ~clx_us/bin/net_usr $mycall
set net_usr $spawn_id

while 1 {
	expect -re "(\[^\r]*)\r\n" {
		send -i $cu "$expect_out(1,string)\n"
		send -i $cu "$expect_out(1,string)\n"
		send -i $cu "$expect_out(1,string)\n"
		expect -i $cu *
	}
}

