Before you can use this script, you need to create several folders to include the parts you need to do the update:
- /v6: includes the 6.5.15 firmware which is needed to update to v7 (snom3X0-6.5.15-SIP-j.bin)
- /v6ux: includes the 3.38 Linux system also needed for v7 but can only be installed once the firmware is 6.5.15 (snom3X0-3.38-l.bin)
- v6to7: this folder includes the special firmware that will update v6 to v7 while keeping all settings (snom3X0-update6to7-7.1.30-bf.bin)
- v7: the normal firmware files for phones that already have v7 installed
To test it, you can simply use an URL like .../snom-firmware.asp?UA=Mozilla/4.0+(compatible;+snom320-SIP+6.5.15;+snom320+jffs2+v3.36;+snom320+linux+3.38) which will tell the script you would like to use the User agent of a Snom 320.
Once all these files are in place, you might use the following ASP script:
# Auto Update Skript
# Coypright (C) 2007-2008 TeX HeX
# http://texhex.blogspot.com
# All Rights Reserved
<%
'Example URLs (for testing):
'.../snom-firmware.asp?UA=Mozilla/4.0+(compatible;+snom320-SIP+6.5.10;+snom320+jffs2+v3.36;+snom320+linux+3.25)
'.../snom-firmware.asp?UA=Mozilla/4.0+(compatible;+snom320-SIP+6.5.15;+snom320+jffs2+v3.36;+snom320+linux+3.38)
'../snom-firmware.asp?UA=Mozilla/4.0+(compatible;+snom320-SIP+7.1.30)
'Definition of download URLs
URL_BASE="http://my-server.internal.company.com/snom"
URL_BASE_V6=URL_BASE & "/v6"
URL_BASE_V6_UX=URL_BASE & "/v6ux"
URL_BASE_V6TO7=URL_BASE & "/v6to7"
URL_BASE_V7=URL_BASE & "/v7"
URL_V6_FW_300=URL_BASE_V6 & "/snom300-6.5.15-SIP-j.bin"
URL_V6_FW_320=URL_BASE_V6 & "/snom320-6.5.15-SIP-j.bin"
URL_V6_FW_360=URL_BASE_V6 & "/snom360-6.5.15-SIP-j.bin"
URL_V6_UX_300=URL_BASE_V6_UX & "/snom300-3.38-l.bin"
URL_V6_UX_320=URL_BASE_V6_UX & "/snom320-3.38-l.bin"
URL_V6_UX_360=URL_BASE_V6_UX & "/snom360-3.38-l.bin"
URL_V6TO7_FW_300=URL_BASE_V6TO7 & "/snom300-from6to7-7.1.30-bf.bin"
URL_V6TO7_FW_320=URL_BASE_V6TO7 & "/snom320-from6to7-7.1.30-bf.bin"
URL_V6TO7_FW_360=URL_BASE_V6TO7 & "/snom360-from6to7-7.1.30-bf.bin"
URL_V7_FW_300=URL_BASE_V7 & "/snom300-7.1.30-SIP-f.bin"
URL_V7_FW_320=URL_BASE_V7 & "/snom320-7.1.30-SIP-f.bin"
URL_V7_FW_360=URL_BASE_V7 & "/snom360-7.1.30-SIP-f.bin"
'''URL_V7_FW_370=URL_BASE_V7 & "/snom370-7.1.30-SIP-f.bin"
'----------STOP EDITING-------------------
Dim CRLF
CRLF=chr(13) + chr(10)
Function Log(Text)
Response.Write("# " & Text)
Response.Write(CRLF)
End function
Function SendOutFirmware_V6
Log("Sending v6 Firmware")
Call SendOutFirmware(URL_V6_FW_300,URL_V6_FW_320,URL_V6_FW_360)
End Function
Function SendOutLinux_V6
Log("Sending v6 Linux")
Call SendOutFirmware(URL_V6_UX_300,URL_V6_UX_320,URL_V6_UX_360)
End Function
Function SendOutFirmware_V6to7
Log("Sending v6 to v7 Firmware")
Call SendOutFirmware(URL_V6TO7_FW_300,URL_V6TO7_FW_320,URL_V6TO7_FW_360)
End Function
Function SendOutFirmware_V7
Log("Sending v7 Firmware")
Call SendOutFirmware(URL_V7_FW_300,URL_V7_FW_320,URL_V7_FW_360)
End Function
Function SendOutFirmware(url300, url320, url360)
'Only write out "firmware:"" tag if it's in the night (21:00 = 9 PM, 05:00 = 5 AM)
if ( (hour(now())>=21 or hour(now())<=5) or sNow="1" ) then
'if true then
Dim sURL
pos=InStr(sUA,"snom300")
if pos>0 then
sURL=url300
end if
pos=InStr(sUA,"snom320")
if pos>0 then
sURL=url320
end if
pos=InStr(sUA,"snom360")
if pos>0 then
sURL=url360
end if
if len(sURL)>0 then
Response.Write("firmware: " + sURL)
Response.Write(CRLF)
else
Log("Unable to get download URL!")
end if
else
'Debug output, I don't think Snoms can actually undestand this :)
Log("Firmware download disabled: It's not in the night! We have now: " + cstr(now()) )
end if
End Function
Dim sUA
sUA=Request.QueryString("UA")
if len(sUA)=0 then
Log("Parameter UA is empty, defaulting to HTTP_USER_AGENT")
sUA=Request.ServerVariables("HTTP_USER_AGENT")
Response.Write(CRLF)
end if
Dim sNow
sNow=Request.QueryString("Now")
'Debug output, just for reference
Log("Parameter [USER AGENT] is --> " + sUA)
Log("Parameter [Now] (direct update) is --> " + sNow)
'Try to find out the current firmware version
Dim iPosStart,iPosEnd,sTmp
iPosStart=0
iPosEnd=0
sTmp=""
'Start searching
Log("Searching firmware version")
iPosStart=InStr(sUA,"-SIP")
if iPosStart>0 then
sTmp=Right(sUA,len(sUA)- (iPosStart+4)) '+4 to cut the "SIP " part
Call Log("Version sniffing - part 1: " + sTmp)
'now search for next ;
iPosEnd=InStr(sTmp,";")
if iPosEnd>0 then
sTmp=left(sTmp,iPosEnd-1)
Call Log("Version: " + sTmp)
else
'maybe a new 7.x phone - search for ")"
iPosEnd=InStr(sTmp,")")
if iPosEnd>0 then
sTmp=left(sTmp,iPosEnd-1)
Call Log("Version: " + sTmp)
end if
end if
end if
'Log sTmp
Dim sCurVersion
sCurVersion=""
'Now check if the version can be found!
if iPosStart<=0 or iPosEnd<=0 then
'No version info found, send to last v6 release!
Call Log("No version info found!")
Call SendOutFirmware_V6()
else
'Okay, we have a version! If this is 6.5.15 we need to send out the newest linux!
sCurVersion=sTmp
Call Log("Found version: " & sCurVersion)
if CInt(left(sCurVersion,1))<=6 and sCurVersion<>"6.5.15" then
Call Log("Version is 6 or below but not 6.5.15!")
Call SendOutFirmware_V6()
else
'Is this 6.5.15?
If sCurVersion="6.5.15" then
'Do we need to do a linux update?
iPosStart=0
iPosEnd=0
sTmp=""
Log("Searching linux version")
iPosStart=InStr(sUA," linux")
if iPosStart>0 then
sTmp=Right(sUA,len(sUA)- (iPosStart+6)) '+4 to cut the " linux" part
Call Log("Version sniffing - part 1: " + sTmp)
'now search for )
iPosEnd=InStr(sTmp,")")
if iPosEnd>0 then
sTmp=left(sTmp,iPosEnd-1)
Call Log("Version: " + sTmp)
end if
end if
if iPosStart<=0 or iPosEnd<=0 then
Log("Unable to find linux version!")
else
if sTmp<>"3.38" then
Log("Version to old, sending new linux!")
Call SendOutLinux_V6()
else
'Firmware is 6.5.15 and linux version okay!
'-> Update to 7.1.30!
Call SendOutFirmware_V6to7()
end if
end if
else
'Firmware is not 6.5.15/UX 3.38, more like 7+
Call SendOutFirmware_V7()
end if
end if
end if
Log("Done!")
%>
Hello TEX HEX,
ReplyDeleteWhere can I get a copy of this firmware update script please?
I've been trying to write one myself without much success :(
Duncan
I think I don't understand your question correctly.
ReplyDeleteThe auto update script is located at the end of the post (after the line "Once all these files are in place, you might use the following ASP script:").
Simply copy it over to a file, call it e.g. "Update.ASP" and upload it a web server that has ASP enabled. This should do the trick.
I'm a newbie at web scripting and I was looking for a php script that contained e.g.
ReplyDelete$user = $_SERVER['HTTP_USER_AGENT'];
One thing that confused me was that the scripts I downloaded from snom use $HTTP_SERVER_VARS , which isn't in my php5 help index
After I posted my message I found out it's the old name for $_SERVER
I'm still confused though.
Once all these files are in place, you might use the following ASP script:
# Auto Update Skript
# Coypright (C) 2007-2008 TeX HeX
# http://texhex.blogspot.com
# All Rights Reserved
Posted by TeX HeX at Monday, January 21, 2008
Are those 4 lines starting with # the entire asp script??
thanks,
Duncan
Yes, the script starts with the four "#" lines and goes until the end of the post.
ReplyDelete