From 443f3991f254ef1e65c0f133155776a2a66d0fdb Mon Sep 17 00:00:00 2001 From: drowe67 Date: Wed, 6 Jan 2010 03:55:11 +0000 Subject: [PATCH] first pass at working ip phones page git-svn-id: https://svn.code.sf.net/p/freetel/code@98 01035d8c-6547-0410-b346-abe4f91aad63 --- easy-asterisk-gui/Makefile | 2 +- easy-asterisk-gui/at-530.html | 15 ++++ easy-asterisk-gui/ipphones.js | 4 -- easy-asterisk-gui/ipphones.pl | 87 +++++++++++++++++++++++ easy-asterisk-gui/ipphones.sh | 31 +++++--- easy-asterisk-gui/login.sh | 2 +- easy-asterisk-gui/menu.html | 2 +- easy-asterisk-gui/{phone.js => phones.js} | 0 easy-asterisk-gui/{phone.pl => phones.pl} | 11 ++- easy-asterisk-gui/{phone.sh => phones.sh} | 18 ++--- easy-asterisk-gui/tooltips.html | 14 ++++ 11 files changed, 158 insertions(+), 28 deletions(-) create mode 100644 easy-asterisk-gui/at-530.html create mode 100755 easy-asterisk-gui/ipphones.pl rename easy-asterisk-gui/{phone.js => phones.js} (100%) rename easy-asterisk-gui/{phone.pl => phones.pl} (94%) rename easy-asterisk-gui/{phone.sh => phones.sh} (83%) diff --git a/easy-asterisk-gui/Makefile b/easy-asterisk-gui/Makefile index 544598a8..2543554b 100644 --- a/easy-asterisk-gui/Makefile +++ b/easy-asterisk-gui/Makefile @@ -9,5 +9,5 @@ TESTIP=192.168.1.150 # rcp index.html root@$(TESTIP):/var/lib/asterisk/static-http/ test: - rcp ipphones.sh ipphones.js voipline.jpg anphone.png phoneline.jpg ipphone.png phone.pl tooltips.html phone.sh phone.js tick.png cross.png banner.html menu.html check_loggedin.sh logout.sh login.sh network.sh network.js set_network.sh tooltip.js tooltip.css root@$(TESTIP):/www/cgi-bin + rcp at-530.html ipphones.pl ipphones.sh ipphones.js voipline.jpg anphone.png phoneline.jpg ipphone.png phones.pl tooltips.html phones.sh phones.js tick.png cross.png banner.html menu.html check_loggedin.sh logout.sh login.sh network.sh network.js set_network.sh tooltip.js tooltip.css root@$(TESTIP):/www/cgi-bin rcp sip.conf extensions.conf root@$(TESTIP):/etc/asterisk diff --git a/easy-asterisk-gui/at-530.html b/easy-asterisk-gui/at-530.html new file mode 100644 index 00000000..ab94e3d7 --- /dev/null +++ b/easy-asterisk-gui/at-530.html @@ -0,0 +1,15 @@ +
    +
  1. Connect the WAN port of the AT-530 to your LAN, it will boot and obtain an IP via DHCP. +
  2. Find the IP of the phone by pressing the Sysinfo button a few times. +
  3. Open another browser window. Go to the phones IP, for example http://192.168.1.160 +
  4. Login to the phone using the username/password admin/admin. +
  5. Optional: set a static IP using the WAN menu (I like static IPs for SIP phones). +
  6. Go to the phone SIP Config menu. +
  7. Set Register Server Address to your Phone System IP Address. +
  8. Set Register Username to the phone number (e.g. 6011). +
  9. Also set Register Password to the phone number (e.g. 6011) and +the Phone Number to the phone number (e.g. 6011). +
  10. Check the *Enable Register* box. +
  11. Then click on Apply. +
  12. Refresh this page to see if the phone is connected to your Phone system. +
diff --git a/easy-asterisk-gui/ipphones.js b/easy-asterisk-gui/ipphones.js index 74d6eaf1..9c50ceac 100644 --- a/easy-asterisk-gui/ipphones.js +++ b/easy-asterisk-gui/ipphones.js @@ -1,7 +1,3 @@ function localInit() { - if (init_internet == "yes") - $('internet').innerHTML = 'tick'; - else - $('internet').innerHTML = 'tick'; } diff --git a/easy-asterisk-gui/ipphones.pl b/easy-asterisk-gui/ipphones.pl new file mode 100755 index 00000000..cdd93d19 --- /dev/null +++ b/easy-asterisk-gui/ipphones.pl @@ -0,0 +1,87 @@ +#!/sbin/microperl +# ipphones.pl +# David Rowe 6 Jan 2010 +# +# Test processing for the ipphones screen + +$ipaddress = $ARGV[0]; +$more = $ARGV[1]; + +# Slurp up SIP extension (Sip) data from extensions.conf + +my %ip = (); # ip extension keyed on sip.conf name + +open EXT, "/etc/asterisk/extensions.conf"; +while () { + if (/.*=>[ ]*([0-9]*),1.*SIP\/([0-9]*)\)/) { + $ip{$2} = $1; + #print "'$1' '$2' $ip{$2}\n"; + } +} +close EXT; + +my %sip = (); # SIP IP phone status keyed on sip.conf names + # if no entry we can't see IP phone device +my %voip = (); # SIP trunks status keyed on sip.conf names + # if no entry we can't see SIP trunk +my %ipad = (); # IP address of SIP device keyed on sip.conf names + +open SIP, "sipshowpeers.txt"; +while () { + if (/^([0-9]*)[\s\/].*(OK)/) { + $sip{$1} = $2; + #print "'$1' '$2' $sip{$1}\n"; + $e = $1; + if (/\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s/) { + $ipad{$e} = $1; + #print "'$1'\n"; + } + } + if (/^(voip[0-9]*)[\s\/].*(OK)/) { + $voip{$1} = $2; + #print "'$1' '$2' $voip{$1}\n"; + $e = $1; + if (/\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s/) { + $ipad{$e} = $1; + #print "'$1'\n"; + } + } +} + +close SIP; + +# print list of IP phones with connection status + +$unconnected = 0; +foreach $e (sort keys %ip) { + if ($sip{$e} eq "OK") { + $icon = "\"Connected\""; + $tooltip_status = "onMouseOver=\"popUp(event,'ipphones_connected')\" onmouseout=\"popUp(event,'ipphones_connected')\""; + $comment=$ipad{$e}; + $tooltip_ext = "onMouseOver=\"popUp(event,'phone_ext')\" onmouseout=\"popUp(event,'phone_ext')\""; + $tooltip_ip = "onMouseOver=\"popUp(event,'phone_ipphone_ip')\" onmouseout=\"popUp(event,'phone_ipphone_ip')\""; + } + else { + $unconnected = $unconnected + 1; + $icon = "\"Not"; + $tooltip_status = "onMouseOver=\"popUp(event,'ipphones_notconnected')\" onmouseout=\"popUp(event,'ipphones_notconnected')\""; + $comment="Available"; + $tooltip_id = "iphones_$e"; + print "
Configure your IP phone with username/password $e/$e, SIP Server IP $ipaddress
"; + $tooltip_ext = "onMouseOver=\"popUp(event,'$tooltip_id')\" onmouseout=\"popUp(event,'$tooltip_id')\""; + $tooltip_ip = ""; + } + + if ($more == 1 || ($unconnected < 5)) { + print "$e$comment$icon\n"; + } +} + +if ($more == 0) { + print 'more'; +} +else { + print 'less'; +} + + diff --git a/easy-asterisk-gui/ipphones.sh b/easy-asterisk-gui/ipphones.sh index 6f63dab1..fccfb08a 100644 --- a/easy-asterisk-gui/ipphones.sh +++ b/easy-asterisk-gui/ipphones.sh @@ -3,6 +3,9 @@ # David Rowe 6 Jan 2010 # Dashboard screen for Easy Asterisk GUI +more=`echo "$QUERY_STRING" | grep -oe "more=[^&?]*" | sed -n "s/more=//p"` +ipaddress=`ifconfig eth0 | sed -n 's/.*inet addr:\(.*\) Bcast.*/\1/p'` + # Construct the web page ------------------------------- sh check_loggedin.sh @@ -34,19 +37,27 @@ cat < -
- - - - - -

Dashboard

Internet Connection:
-  
-
+

IP Phones

+ + Phone System IP Address: +EOF +echo "$ipaddress " + + # use perl to construct list of IP phones for us + asterisk "-rx sip show peers" 2>/dev/null > sipshowpeers.txt + ./ipphones.pl $ipaddress $more - +cat < +

 
How to Configure IP Phones

+

1. Atcom AT-530

+EOF +cat at-530.html +cat < diff --git a/easy-asterisk-gui/login.sh b/easy-asterisk-gui/login.sh index afe42e3f..3213d685 100644 --- a/easy-asterisk-gui/login.sh +++ b/easy-asterisk-gui/login.sh @@ -42,7 +42,7 @@ else echo "" echo "" echo "Easy Asterisk - Login" - echo '' + echo '' echo "" echo "Please wait a few seconds....." echo "" diff --git a/easy-asterisk-gui/menu.html b/easy-asterisk-gui/menu.html index c4bc9f74..d56b597d 100644 --- a/easy-asterisk-gui/menu.html +++ b/easy-asterisk-gui/menu.html @@ -12,7 +12,7 @@ Network - IP Phones + IP Phones Phones diff --git a/easy-asterisk-gui/phone.js b/easy-asterisk-gui/phones.js similarity index 100% rename from easy-asterisk-gui/phone.js rename to easy-asterisk-gui/phones.js diff --git a/easy-asterisk-gui/phone.pl b/easy-asterisk-gui/phones.pl similarity index 94% rename from easy-asterisk-gui/phone.pl rename to easy-asterisk-gui/phones.pl index 93157bbc..518b40f2 100755 --- a/easy-asterisk-gui/phone.pl +++ b/easy-asterisk-gui/phones.pl @@ -1,12 +1,13 @@ #!/sbin/microperl -# phone.pl +# phones.pl # David Rowe 5 Jan 2010 # -# Extracts the phone extension infor from /etc/asterisk/extensions.conf -# and generate html. Perl used as faster than equivalent shell script +# Test processing for the phones screen. $tool_tip = "onMouseOver=\"popUp(event,'network_internet')\" onmouseout=\"popUp(event,'network_internet')\""; +# Slurp up analog port (Zap) data from extensions.conf + my %analog = (); # analog extension keyed on zap port open EXT, "/etc/asterisk/extensions.conf"; @@ -18,6 +19,8 @@ while () { } close EXT; +# Slurp up data on installed zaptel ports from /etc/zaptel.conf + my %zap = (); # zaptel port type keyed on zap port # (fxs/fxo or no entry if not live) open ZAP, "/etc/zaptel.conf"; @@ -31,6 +34,8 @@ while () { } close ZAP; +# Slurp up SIP extension (Sip) data from extensions.conf + my %ip = (); # ip extension keyed on sip.conf name open EXT, "/etc/asterisk/extensions.conf"; diff --git a/easy-asterisk-gui/phone.sh b/easy-asterisk-gui/phones.sh similarity index 83% rename from easy-asterisk-gui/phone.sh rename to easy-asterisk-gui/phones.sh index 7a36ccb3..98bec0c4 100644 --- a/easy-asterisk-gui/phone.sh +++ b/easy-asterisk-gui/phones.sh @@ -1,7 +1,7 @@ #!/bin/sh -x -# phone.sh +# phones.sh # David Rowe 4 Jan 2010 -# CGI for Easy Asterisk phones GUI +# Phones screen for Easy Asterisk GUI # See if we have Internet connectivity, first check dns as time outs can be very slow @@ -30,7 +30,7 @@ EOF echo "" cat << EOF @@ -50,8 +50,7 @@ cat < -

Phone System

- Add IP Phone +

Phone System

Internet Connection: @@ -64,14 +63,17 @@ echo "$ipaddress" cat <   - -

Phones

+ +

Phones

+ + Add IP Phone EOF # use perl to construct list of phones and phone lines for us asterisk "-rx sip show peers" 2>/dev/null > sipshowpeers.txt -./phone.pl +./phones.pl cat< diff --git a/easy-asterisk-gui/tooltips.html b/easy-asterisk-gui/tooltips.html index 6b9963cb..20d90e12 100644 --- a/easy-asterisk-gui/tooltips.html +++ b/easy-asterisk-gui/tooltips.html @@ -68,3 +68,17 @@
Instructions and help on adding a new IP phone
+ +
+ List of possible IP phones. Choose a free one + (cross) for a new phone. Refresh this page tp + update
+ +
+ The IP phone is connected to your phone system and ready to use
+ +
+ No IP phone is connected. This could be + because no IP phone is present, or the IP + phone has not been set up.
+ -- 2.25.1