#!/bin/sh
 
PATH="/usr/local/asterisk/usr/sbin:/bin:/usr/bin"
export PATH

XDIALOG_HIGH_DIALOG_COMPAT=1
export XDIALOG_HIGH_DIALOG_COMPAT

TMP="/tmp/celliaxconfig.tmp$$"
CELLIAXTMP="/tmp/celliaxconf.tmp$$"
CELLIAXCONFIG="celliax.conf"
ASTCONFDIR="/etc/asterisk/"
[ -d /usr/local/asterisk/etc/asterisk ] && ASTCONFDIR="/usr/local/asterisk/etc/asterisk/"


CRWRAP="--cr-wrap"
   
bailout(){
   rm -f "$TMP"
   exit $1
}

DIALOG="dialog"
[ -x /usr/bin/whiptail ] && DIALOG="whiptail" && CRWRAP=""
[ -x /usr/bin/dialog ] && DIALOG="dialog" && CRWRAP=""
[ -n "$DISPLAY" ] && [ "$DISPLAY" != ":99" ] && [ -x /usr/bin/Xdialog ] && DIALOG="Xdialog" && CRWRAP="--cr-wrap"

echo ";; 
;; 
; Celliax Asterisk Driver 
; 
; Configuration file 
; lines beginning with semicolon (\" are ignored (commented out)
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; The first interface (named nicephone)
[nicephone] 
;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;
; general settings, valid on all platforms
;
; 
; Default language 
; 
language=en 
; 
; Default context (is overridden with @context syntax) 
; 
context=default 
; 
; Default extension (in extensions.conf) where incoming calls land
; 
extension=s 
; 
;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;
; Debugging settings, valid globally for all interfaces on all platforms
;
; the debug values are global for all the interfaces.
;
; default is no celliax debugging output, you **have** to activate debugging here to obtain debugging from celliax
;
; To see the debugging output you have to \"set debug 100\" from the Asterisk CLI or launch
; Asterisk with -ddddddddddd option, and have the logger.conf file activating debug info for console and messages
;
; You can activate each of the following separately, but you can't disactivate. Eg: debug_at=no does not subtract debug_at from debug_all
; debug_all activate all possible debugging info
;
;debug_all=yes
debug_at=yes
debug_fbus2=yes
debug_serial=yes
debug_pbx=yes
debug_sound=yes
;debug_locks=yes
debug_skype=yes
debug_call=yes
;debug_cvm=yes


; wanna skype support?
skype=yes 

;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;
; serial settings, valid for all platforms
;
;control_device_protocol can be AT or FBUS2 or NO_SERIAL (with NO_SERIAL the speed and name of the port are ignored)
;control_device_protocol=at

;speed of the serial port
control_device_speed=115200

;name of the serial port device
;control_device_name=/dev/ttyACM0 ; this is a Motorola phone, recognized as a modem by Linux
;control_device_name=/dev/ttyS9 ; this is the COM10 on windows
;control_device_name=/dev/ttyUSB0 ; this is the first USB serial port in Linux

;cvm_subscription_1_pin = 0000 ; CVM hold registration info about two FP (DECT base stations)
;cvm_subscription_2_pin = 1234 ; these are PINs for each FP, used only during registartion process

;cvm_subscription_no = 1 ; CVM can be locked to one FP at the time, please choose 1 or 2

;cvm_serial_delay = 1 ; used to fix problems with serial communication, probably not needed any more, please see alsa settings, it looks for me that I have a problem with CM108 and PL2303HX on USB.
;cvm_volume_level = 1 ; volume level control in CVM (0-9)

;watch the soundcard for noise (ring), because the serial port do not tell us about incoming calls (eg 3310nokia), NO_SERIAL protocol watch for acoustic ring in any case
need_acoustic_ring=0

;audio noise threshold beyond which we declare there is a ring (512 is default, put it to 1024 or 2048 if you have false positive), ignored if not watching for ring
dsp_silence_threshold=1024

;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;
; audio boost settings, valid for all platforms, to compensate for different soundcard/phone input/output signal levels
; tweak it if you get horrible (or not hearable) sound
;
;boost can be positive or negative (-40 to +40) in db
;experiment to find which values are best for your soundcard
playback_boost=0 ; for usb audio cm-108 on motorola c650
capture_boost=0 ; for usb audio cm-108 on motorola c650
;playback_boost=10 ; for integrated mobo audio for motorola c650
;capture_boost=10 ; for integrated mobo audio for motorola c650

;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;
; alsa settings, ignored in windows
;
;alsa internal settings, if in doubt, leave them alone ;-)
;to check and do the audio fine tuning, use microphone and headset directly connected to the soundcard, is easier and cheaper
;period_size, if you hear a scratchy background noise, increase it to 170 and check if is better
;CVM - these alsa setting give good sound quality, CM108 USB card + PL2303HX Serial converter
;alsa_period_size=32
;alsa_periods_in_buffer, if you get too many XRUNs, or if you get noise after EAGAINs, increase it (it will increase your alsa latency, but is nothing. The real latency is introduced by the round trip of audio from cellphone to cellphone)
;alsa_periods_in_buffer=32

alsa_period_size=160
alsa_periods_in_buffer=4

;names of the sound devices in linux
;if you don't use skype on this interface (eg don't need to share the audio device with other applications while celliax is running), use the plughw:n devices (plughw:0 is the first, plughw:1 is the second soundcard, etc). They have the best latency
;if you use skype on this interface use the default:n devices (default:0 is the first, default:1 is the second soundcard, etc). They have worst latency, but you can share them
;alsa_capture_device_name=default:0
;alsa_playback_device_name=default:0

;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;
; window multimedia settings, ignored in linux
;
;names of the sound devices in windows, this is the first soundcard, the second would be 1
;winmm_capture_device_name=0
;winmm_playback_device_name=0

;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;
; at \"modem\" commands settings for this interface (if controldevice_protocol is not AT they are ignored)
;
;what the modem is expecting in the part of the dial command before the number to be dialed (eg: ATD)
at_dial_pre_number=AT+CKPD=\"EEE
;what the modem is expecting in the part of the dial command after the number to be dialed (eg: ;)
at_dial_post_number=S\"
;what the modem will answer after succesful execution of the dial command
at_dial_expect=OK

;command to hangup the current call
at_hangup=AT+CKPD=\"EEE\"
;what the modem will answer after succesful execution of the hangup command
at_hangup_expect=OK

;command to answer an incoming call
at_answer=ATA
;what the modem will answer after succesful execution of the answer command
at_answer_expect=OK

;pause right after serial port opening, before any command is sent, in usecs (1million usec= 1sec)
at_initial_pause=1000000
;custom commands to be sent after the initial pause and before the \"built in\" initialization commands, and what the modem is expected to send as reply
;the first empty string stop the preinit sending
at_preinit_1=atciapa ; nonsense entry, just to show the preinit
at_preinit_1_expect=OK
at_preinit_2=
at_preinit_2_expect=
at_preinit_3=
at_preinit_3_expect=
at_preinit_4=
at_preinit_4_expect=
at_preinit_5=
at_preinit_5_expect=
;pause right after the custom preinit commands, before any \"built in\" command is sent, in usecs (1million usec= 1sec)
at_after_preinit_pause=1000000
;custom commands to be sent after the \"built in\" initialization commands, and what the modem is expected to send as reply
;the first empty string stop the postinit sending
at_postinit_1=atcucu ; nonsense entry, just to show the postinit
at_postinit_1_expect=OK
at_postinit_2=AT+CKPD=\"EEE\" ;send three \"end\" buttonpress, to have the phone in a sane state, ready to dialing with furter CKPDs ***THIS IS IMPORTANT, needed on c650***
at_postinit_2_expect=OK
at_postinit_3=
at_postinit_3_expect=
at_postinit_4=
at_postinit_4_expect=
at_postinit_5=
at_postinit_5_expect=

;what command to query the battery status, and what the modem is expected to send as reply
at_query_battchg=AT+CBC
at_query_battchg_expect=OK
;what command to query the signal status, and what the modem is expected to send as reply
at_query_signal=AT+CSQ
at_query_signal_expect=OK

;the modem will send us the following messages to signal that the visual indicators on the phone has changed because of events (without us to ask for them), loosely based on ETSI standard (see CIND/CIEV/CMER in ETSI). Variable by manufacturer and phone model
; no service
at_indicator_noservice_string=+CIEV: 2,0
; no signal
at_indicator_nosignal_string=+CIEV: 5,0
; low signal
at_indicator_lowsignal_string=+CIEV: 5,1
; low battery
at_indicator_lowbattchg_string=+CIEV: 0,1
; no battery battery
at_indicator_nobattchg_string=+CIEV: 0,0
; call is up
at_indicator_callactive_string=+CIEV: 3,1
; call is down
at_indicator_nocallactive_string=+CIEV: 3,0
; call is no more in process
at_indicator_nocallsetup_string=+CIEV: 6,0
; call incoming is in process
at_indicator_callsetupincoming_string=+CIEV: 6,1
; call outgoing is in process
at_indicator_callsetupoutgoing_string=+CIEV: 6,2
; remote party is ringing because of our call outgoing 
at_indicator_callsetupremoteringing_string=+CIEV: 6,3

;call processing unsolicited messages, proprietary for each phone manufacturer
;the modem will send us the following mesage to signal that the line is idle (eg. after an outgoing call has failed, or after hangup)
at_call_idle=+MCST: 1
;the modem will send us the following mesage to signal that there is an incoming voice call
at_call_incoming=+MCST: 2
;the modem will send us the following mesage to signal that there is an active call (eg. the remote party has answered us, or we answered them)
at_call_active=+MCST: 3
;the modem will send us the following mesage to signal that our outgoing call has failed
at_call_failed=+MCST: 65
;the modem will send us the following mesage to signal that our outgoing call is in the calling phase
at_call_calling=+MCST: 64

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;another interface, called nokianice, commented out. Remove two semicolon (\" from the beginning of all the following lines to activate it
;;[nokianice]
;;
;;; skype is not yet supported, but will come back in the future
;;skype=no 
;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; serial settings, valid for all platforms
;;;
;;; control_device_protocol can be AT or FBUS2 or NO_SERIAL
;;control_device_protocol=fbus2
;;
;;;speed of the serial port
;;control_device_speed=115200
;;
;;;name of the serial port device
;;control_device_name=/dev/ttyUSB0 ; this is the first USB serial port in linux
;;;control_device_name=/dev/ttyS11 ; this is COM12 in windows
;;
;;;watch the soundcard for noise (ring), because the serial port do not tell us about incoming calls (eg 3310nokia), NO_SERIAL protocol watch for acoustic ring in any case
;;need_acoustic_ring=1
;;
;;;audio noise threshold beyond which we declare there is a ring (512 is default, put it to 1024 or 2048 if you have false positive), ignored if not watching for ring
;;dsp_silence_threshold=1024
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; audio boost settings, valid for all platforms
;;;
;;;boost can be positive or negative (-40 to +40) in db
;;;experiment to find which values are best for your soundcard
;;playback_boost=10 ; for integrated mobo audio for nokia3110
;;capture_boost=-5 ; for integrated mobo audio for nokia3110
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; alsa settings, ignored in windows
;;;
;;;alsa internal settings, if in doubt, leave them alone ;-)
;;;to check and do the audio fine tuning, use microphone and headset directly connected to the soundcard, is easier and cheaper
;;;period_size, if you hear a scratchy background noise, increase it to 170 and check if is better
;;alsa_period_size=170
;;;alsa_periods_in_buffer, if you get too many XRUNs, or if you get noise after EAGAINs, increase it (it will increase your alsa latency, but is nothing. The real latency is introduced by the round trip of audio from cellphone to cellphone)
;;alsa_periods_in_buffer=4
;;
;;;names of the sound devices in linux
;;;if you don't use skype on this interface (eg don't need to share the audio device with other applications while celliax is running), use the plughw:n devices (plughw:0 is the first, plughw:1 is the second soundcard, etc). They have the best latency
;;;if you use skype on this interface use the default:n devices (default:0 is the first, default:1 is the second soundcard, etc). They have worst latency, but you can share them
;;alsa_capture_device_name=plughw:1
;;alsa_playback_device_name=plughw:1
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; window multimedia settings, ignored in linux
;;;
;;;names of the sound devices in windows, this is the second soundcard, the first would be 0
;;winmm_capture_device_name=1
;;winmm_playback_device_name=1
;;
" > $CELLIAXTMP

rm -f "$TMP"

trap bailout 2 15
    
TITLE="Welcome to Celliax"

$DIALOG  $CRWRAP --clear --title "$TITLE" --yesno "Welcome!

You will be guided through the configuration of Celliax.

Your answers will be saved, so the next time you start Celliax you will just press ENTER to all questions (if you will not want to change the previous answers).

Booting from the LiveCD, your answers will be saved only until the next reboot (you can stop Celliax typing \"stop now\" in the console, then relaunch it from the menu).

More info and help can be found starting Firefox in the LiveCD, playing the LiveCD in Windows, or at http://www.celliax.org.

Start configuration procedure?  " 22 70 || bailout 1

###################
rm -f "$TMP"

trap bailout 2 15

TITLE="Where is the Asterisk configuration directory?"
CONF="${ASTCONFDIR}celliax_myconfdir.conf"
CELLIAX_MYASTCONFDIR="`cat $CONF`"

ASTCONFDIR="${CELLIAX_MYASTCONFDIR##CELLIAX_MYASTCONFDIR=}"

$DIALOG  $CRWRAP --clear --title "$TITLE" --default-item "$ASTCONFDIR" --menu "


Please choose where is the Asterisk configuration directory. 
You can insert one of the following: 

/etc/asterisk/ or /usr/local/asterisk/etc/asterisk/

If you have compiled and installed Asterisk from the celliax.org sources, choose the alternate place.

If you are on Trixbox, choose the standard place.




" 22 70 2 "/etc/asterisk/" "The standard place" "/usr/local/asterisk/etc/asterisk/" "The alternate place" 2>"$TMP" || bailout 1

CELLIAX_MYASTCONFDIR="`cat $TMP`"

ASTCONFDIR=$CELLIAX_MYASTCONFDIR

CONF="${ASTCONFDIR}celliax_myconfdir.conf"

echo "CELLIAX_MYASTCONFDIR=$CELLIAX_MYASTCONFDIR" >"$CONF"


###################


###################
rm -f "$TMP"

trap bailout 2 15

TITLE="Windows or Linux ?"
CONF="${ASTCONFDIR}celliax_myos.conf"
CELLIAX_MYOS="`cat $CONF`"

OS="${CELLIAX_MYOS##CELLIAX_MYOS=}"

$DIALOG  $CRWRAP --clear --title "$TITLE" --default-item "$OS" --menu "


Please insert the Operating System you are using now. You can insert one of the following: LINUX WINDOWS_XP


Note that Windows Vista is not supported at this time.


" 22 70 2 "WINDOWS_XP" "We all have it somewhere" "LINUX" "Long Live free software" 2>"$TMP" || bailout 1

CELLIAX_MYOS="`cat $TMP`"

echo "CELLIAX_MYOS=$CELLIAX_MYOS" >"$CONF"
echo ";Configured for $CELLIAX_MYOS" >>"$CELLIAXTMP"


###################


rm -f "$TMP"

trap bailout 2 15
    
TITLE="(cell)phone number you want Celliax to call"
CONF="${ASTCONFDIR}celliax_mycellnumber.conf"
CELLIAX_MYCELLNUMBER="`cat $CONF`"

NUMBER="${CELLIAX_MYCELLNUMBER##CELLIAX_MYCELLNUMBER=}"

$DIALOG  $CRWRAP --clear --title "$TITLE" --inputbox "

Please insert the (cell)phone number you want Celliax to call you to.

Eg. the number that Celliax will call to connect you to the incoming Skype or VoIP calls (in most cases: your personal cellphone number).

If in the next step you choose the NO_SERIAL protocol, this number will be ignored (NO_SERIAL can't make outgoing (cell)phone calls).

Do not insert spaces or funny characters, just the number as you would dial:" 22 70 "$NUMBER" 2>"$TMP" || bailout 1

CELLIAX_MYCELLNUMBER="`cat $TMP`"

echo "CELLIAX_MYCELLNUMBER=$CELLIAX_MYCELLNUMBER" >"$CONF"

###################
rm -f "$TMP"

trap bailout 2 15

TITLE="Celliax serial protocol"
CONF="${ASTCONFDIR}celliax_myserialprotocol.conf"
CELLIAX_MYSERIALPROTOCOL="`cat $CONF`"

SERIALPROTOCOL="${CELLIAX_MYSERIALPROTOCOL##CELLIAX_MYSERIALPROTOCOL=}"

$DIALOG  $CRWRAP --clear --title "$TITLE" --default-item "$SERIALPROTOCOL" --menu "Please insert the serial protocol you want Celliax to use to manage the cellphone (or modem). You can insert one of the following: AT FBUS2 NO_SERIAL

NO_SERIAL can't pickup the line and can't make calls. It is activated by an incoming sound. You use it for testing (with mic and headphones) or with a cellphone that can answer automatically (eg. in handsfree mode)." 22 70 3 "AT" "For the vast majority of cellphones"  "FBUS2" "For various Nokia models (3310, 3210, 5110, etc.)" "NO_SERIAL" "Soundcard Only" 2>"$TMP" || bailout 1

CELLIAX_MYSERIALPROTOCOL="`cat $TMP`"

echo "CELLIAX_MYSERIALPROTOCOL=$CELLIAX_MYSERIALPROTOCOL" >"$CONF"
echo "control_device_protocol=$CELLIAX_MYSERIALPROTOCOL" >>"$CELLIAXTMP"

###################

rm -f "$TMP"

trap bailout 2 15

case "$CELLIAX_MYOS" in

LINUX)

TITLE="Celliax Audio Device on Linux"
CONF="${ASTCONFDIR}celliax_myaudiodevice.conf"
CELLIAX_MYAUDIODEVICE="`cat $CONF`"

AUDIODEVICE="${CELLIAX_MYAUDIODEVICE##CELLIAX_MYAUDIODEVICE=}"

$DIALOG  $CRWRAP --clear --title "$TITLE" --default-item "$AUDIODEVICE" --menu "Please insert the name of the audio device you want Celliax to use. 
REMEMBER to configure Skype to use the SAME device.

On Linux, you can insert: default:0 default:1 default:2 etc for the first, second and third soundcard.

You can scroll the list up and down.

(programmers and computers counts starting with zero ;-) )" 22 70 4 "default:0" "Linux First Soundcard"  "default:1" "Linux Second Soundcard"  "default:2" "Linux Third Soundcard"  "default:3" "Linux Fourth Soundcard"  2>"$TMP" || bailout 1

CELLIAX_MYAUDIODEVICE="`cat $TMP`"

echo "CELLIAX_MYAUDIODEVICE=$CELLIAX_MYAUDIODEVICE" >"$CONF"
echo "alsa_capture_device_name=$CELLIAX_MYAUDIODEVICE" >>"$CELLIAXTMP"
echo "alsa_playback_device_name=$CELLIAX_MYAUDIODEVICE" >>"$CELLIAXTMP"

;;

WINDOWS_XP)

TITLE="Celliax Audio Device on Windows XP"
CONF="${ASTCONFDIR}celliax_myaudiodevice.conf"
CELLIAX_MYAUDIODEVICE="`cat $CONF`"

AUDIODEVICE="${CELLIAX_MYAUDIODEVICE##CELLIAX_MYAUDIODEVICE=}"

$DIALOG  $CRWRAP --clear --title "$TITLE" --default-item "$AUDIODEVICE" --menu "Please insert the name of the audio device you want Celliax to use. 
REMEMBER to configure Skype to use the SAME device.

On Windows, you can insert: 0 1 2 etc for the first, second and third soundcard.

You can scroll the list up and down.

(programmers and computers counts starting with zero ;-) )" 22 70 4 "0" "Windows XP First Soundcard"  "1" "Windows XP Second Soundcard"  "2" "Windows XP Third Soundcard"  "3" "Windows XP Fourth Soundcard"  2>"$TMP" || bailout 1

CELLIAX_MYAUDIODEVICE="`cat $TMP`"

echo "CELLIAX_MYAUDIODEVICE=$CELLIAX_MYAUDIODEVICE" >"$CONF"
echo "winmm_capture_device_name=$CELLIAX_MYAUDIODEVICE" >>"$CELLIAXTMP"
echo "winmm_playback_device_name=$CELLIAX_MYAUDIODEVICE" >>"$CELLIAXTMP"

;;

*)

exit 1

;;

esac

###################

rm -f "$TMP"

trap bailout 2 15

case "$CELLIAX_MYOS" in

LINUX)


TITLE="Celliax serial control device on Linux"
CONF="${ASTCONFDIR}celliax_mycontroldevice.conf"
CELLIAX_MYCONTROLDEVICE="`cat $CONF`"

CONTROLDEVICE="${CELLIAX_MYCONTROLDEVICE##CELLIAX_MYCONTROLDEVICE=}"

$DIALOG  $CRWRAP --clear --title "$TITLE" --default-item "$CONTROLDEVICE" --menu "
ONLY the AT and the FBUS2 protocols use this name. Other protocols ignores it.

On Linux: /dev/ttyUSB0 for the first serial USB datacable (eg Nokia), /dev/ttyACM0 for the first USB phonemodem (eg Motorola) or /dev/ttyS0 for the first serial port.

You can scroll the list up and down." 22 70 6 "/dev/ttyACM0" "First USB Modem (eg: Motorola)"  "/dev/ttyACM1" "Second USB Modem (eg: Motorola)"  "/dev/ttyACM2" "Third USB Modem (eg: Motorola)" "/dev/ttyUSB0" "First USB DataCable (eg: old Nokia)"  "/dev/ttyUSB1" "Second USB DataCable (eg: old Nokia)"  "/dev/ttyUSB2" "Third USB DataCable (eg: old Nokia)"  "/dev/ttyS0" "First Serial Port (eg: old, real one)"  "/dev/ttyS1" "Second Serial Port (eg: old, real one)"  2>"$TMP" || bailout 1

CELLIAX_MYCONTROLDEVICE="`cat $TMP`"

echo "CELLIAX_MYCONTROLDEVICE=$CELLIAX_MYCONTROLDEVICE" >"$CONF"
echo "control_device_name=$CELLIAX_MYCONTROLDEVICE" >>"$CELLIAXTMP"

;;

WINDOWS_XP)


TITLE="Celliax serial control device"
CONF="${ASTCONFDIR}celliax_mycontroldevice.conf"
CELLIAX_MYCONTROLDEVICE="`cat $CONF`"

CONTROLDEVICE="${CELLIAX_MYCONTROLDEVICE##CELLIAX_MYCONTROLDEVICE=}"

$DIALOG  $CRWRAP --clear --title "$TITLE" --default-item "$CONTROLDEVICE" --menu "
ONLY the AT and the FBUS2 protocols use this name. Other protocols ignores it.

On Windows: /dev/ttyS0 for the first COM (serial) port. Windows USB DataCables are to be named from the COM port Windows assigned them.

You can scroll the list up and down." 22 70 6 "/dev/ttyS0" "First Serial Port (COM1)"  "/dev/ttyS1" "Second Serial Port (COM2)"  "/dev/ttyS2" "Third Serial Port (COM3)" "/dev/ttyS3" "Fourth Serial Port (COM4)"  "/dev/ttyS4" "Fifth Serial Port (COM5)"  "/dev/ttyS5" "Sixth Serial Port (COM6)"   "/dev/ttyS6" "Seventh Serial Port (COM7)"  "/dev/ttyS7" "Eighth Serial Port (COM8)" "/dev/ttyS8" "Ninth Serial Port (COM9)"  "/dev/ttyS9" "Tenth Serial Port (COM10)"  "/dev/ttyS10" "Eleventh Serial Port (COM11)" "/dev/ttyS11" "Twelfth Serial Port (COM12)"  "/dev/ttyS12" "Thirteenth Serial Port (COM13)"  "/dev/ttyS13" "Fourteenth Serial Port (COM14)"   "/dev/ttyS14" "Fifteenth Serial Port (COM15)"  "/dev/ttyS15" "Sixteenth Serial Port (COM16)"  2>"$TMP" || bailout 1

CELLIAX_MYCONTROLDEVICE="`cat $TMP`"

echo "CELLIAX_MYCONTROLDEVICE=$CELLIAX_MYCONTROLDEVICE" >"$CONF"
echo "control_device_name=$CELLIAX_MYCONTROLDEVICE" >>"$CELLIAXTMP"

;;


*)

exit 1

;;

esac



###################

cp -f $CELLIAXTMP $ASTCONFDIR$CELLIAXCONFIG


rm -f "$CELLIAXTMP"


bailout 0
