{"id":588,"date":"2009-04-27T01:59:29","date_gmt":"2009-04-27T07:59:29","guid":{"rendered":"http:\/\/gregsowell.com\/?p=588"},"modified":"2009-12-02T13:09:24","modified_gmt":"2009-12-02T19:09:24","slug":"cisco-ata-186-setting-static-vlan-tool-to-calculate-vlan-value","status":"publish","type":"post","link":"https:\/\/gregsowell.com\/?p=588","title":{"rendered":"Cisco ATA 186 Setting Static VLAN &#8211; Tool to Calculate VLAN Value"},"content":{"rendered":"<p>If you are going to setup an ATA in a network that is non Cisco(sans voice vlan on switches), then you will need to manually configure your ATA to support the Voice VLAN.  The easiest way is to let you ATA pull DHCP and configure it via the web interface:<\/p>\n<pre class=\"gs-code\"><code class=\"language-plaintext\">http:\/\/192.168.1.100\/dev<\/code><\/pre>\n<p>If you want to set an alternate VLAN for the voice traffic on the ATA, you need to change the OpFlag value to 0\u00d700000052.<\/p>\n<p>You then have to set the VLAN field to hex representation of what VLAN you want, though the method you have to go about it is somewhat convoluted&#8230;or well, really convoluted hehe.  I&#8217;m not going to explain the complicated process, because someone has already gone through the trouble, <a title=\"explanation\" href=\"http:\/\/cciev.wordpress.com\/2006\/05\/25\/ata-186-setting-static-vlan-id-in-ata-sccp\/\" target=\"_blank\">here<\/a>.<\/p>\n<p>What I did, was to write an Autoit script that will do all the work for you!  All you have to do is type in the VLAN ID you want to convert and click a button.  The prog will display the crazy hex number and also copy it to the clipboard.<\/p>\n<figure id=\"attachment_592\" aria-describedby=\"caption-attachment-592\" style=\"width: 176px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2009\/04\/atavv.jpg\" alt=\"ATA Voice VLAN Prog...oh so pretty.\" title=\"atavv\" width=\"176\" height=\"180\" class=\"size-full wp-image-592\" \/><figcaption id=\"caption-attachment-592\" class=\"wp-caption-text\">ATA Voice VLAN Prog...oh so pretty.<\/figcaption><\/figure>\n<p>You can download the compiled program <div class=\"wp-block-button\">\n<a  data-e-Disable-Page-Transition=\"true\" class=\"dlm-download-link dlm-download-default wp-block-button__link wp-element-button\" title=\"\" href=\"https:\/\/gregsowell.com?download=5673&amp;tmstv=1784656281\" rel=\"nofollow\" id=\"download-link-5673\" data-redirect=\"false\" >\n\tATA Voice Vlan\t(2528 downloads\t)\n<\/a>\n<\/div>\n, or use the code below:<\/p>\n<pre class=\"gs-code\"><code class=\"language-plaintext\">#include &lt;EditConstants.au3&gt;\r\n#include &lt;GUIConstantsEx.au3&gt;\r\n#include &lt;StaticConstants.au3&gt;\r\n#include &lt;WindowsConstants.au3&gt;\r\n\r\n#Region ### START Koda GUI section ### Form=C:\\Documents and Settings\\gsowell\\Desktop\\autoit\\ata voice vlan\\ata voice vlan.kxf\r\n$Form1_1 = GUICreate(&quot;GregSowell.com&quot;, 165, 152, 193, 115)\r\n$Input1 = GUICtrlCreateInput(&quot;&quot;, 16, 24, 49, 21)\r\n$Label1 = GUICtrlCreateLabel(&quot;VLAN ID&quot;, 16, 8, 46, 17)\r\n$Label2 = GUICtrlCreateLabel(&quot;ATA Voice VLAN in Hex&quot;, 16, 56, 119, 17)\r\n$Input2 = GUICtrlCreateInput(&quot;&quot;, 16, 72, 121, 21)\r\n$Button1 = GUICtrlCreateButton(&quot;calc + clipboard&quot;, 72, 24, 83, 25, 0)\r\n$Label3 = GUICtrlCreateLabel(&quot;Remember to set OpFlag to&quot;, 16, 104, 133, 17)\r\n$Input3 = GUICtrlCreateInput(&quot;0\u00d700000052&quot;, 16, 120, 73, 21)\r\nGUISetState(@SW_SHOW)\r\n#EndRegion ### END Koda GUI section ###\r\n\r\nWhile 1\r\n\t$nMsg = GUIGetMsg()\r\n\tSwitch $nMsg\r\n\t\tCase $GUI_EVENT_CLOSE\r\n\t\t\tExit\r\n\t\tcase $Button1\r\n\t\t\t_rockIt()\r\n\tEndSwitch\r\n\tsleep(20)\r\nWEnd\r\n\r\nFunc _rockIt()\r\n\t$converted = &quot;&quot;\r\n\tGUICtrlSetData($Input2,$converted)\r\n\tif GUICtrlRead($Input1) &lt;&gt; &quot;&quot; Then\r\n\t\t;calc it and producte the hex\r\n\t\t;0000 0000 0000 0000 0000 0000 0010 1011\r\n\t\t;00 [00 0000 0000 00] 00 0000 0000 0010 1011\r\n\r\n\t\t$converted = _DecToBinary(GUICtrlRead($Input1))\r\n\t\tif StringLen($converted) == 4 Then\r\n\t\t\t;need to append 8 zeros first\r\n\t\t\t$converted = &quot;00000000&quot; &amp; $converted\r\n\t\tElseif StringLen($converted) == 8 Then\r\n\t\t\t;need to append 4\r\n\t\t\t$converted = &quot;0000&quot; &amp; $converted\r\n\t\tEndIf\r\n\t\t;append the proper amount of zeroes\r\n\t\t$converted = &quot;00&quot; &amp; $converted &amp; &quot;00&quot;\r\n\t\t;ToolTip($converted,0,0)\r\n\t\t$converted = &quot;0x&quot; &amp; _BinaryToHexString(StringLeft($converted, 4)) &amp; _BinaryToHexString(StringMid($converted, 5,4)) &amp; _BinaryToHexString(StringMid($converted, 9,4)) &amp; _BinaryToHexString(StringRight($converted, 4)) &amp; &quot;002b&quot;\r\n\t\tGUICtrlSetData($Input2,$converted)\r\n\t\tClipPut($converted)\r\n\t\t\r\n\tEndIf\r\nEndFunc\r\n\r\n; Decimal To Binary\r\nFunc _DecToBinary($iDec)\r\nLocal $i, $sBinChar = &quot;&quot;\r\n\r\nIf StringRegExp($iDec,&#039;[[:digit:]]&#039;) then\r\n$i = 1\r\n\r\nDo\r\n $x = 16^$i\r\n $i +=1 \r\n ; Determine the Octets\r\nUntil $iDec &lt; $x\r\n \r\nFor $n = 4*($i-1) To 1 Step -1\r\n    If BitAND(2 ^ ($n-1), $iDec) Then\r\n        $sBinChar &amp;= &quot;1&quot;\r\n    Else\r\n        $sBinChar &amp;= &quot;0&quot;\r\n    EndIf\r\nNext\r\n Return $sBinChar\r\nElse\r\n    MsgBox(0,&quot;Error&quot;,&quot;Wrong input, try again ...&quot;)\r\n    Return\r\nEndIf   \r\nEndFunc\r\n\r\n\r\n; Binary To Hex\r\nFunc _BinaryToHexString($BinaryValue)\r\n    Local $test, $Result = &#039;&#039;,$numbytes,$nb\r\n\r\nIf StringRegExp($BinaryValue,&#039;[0-1]&#039;) then\r\n    \r\n    if $BinaryValue = &#039;&#039; Then\r\n        SetError(-2)\r\n        Return\r\n    endif\r\n\r\n    Local $bits = &quot;0000|0001|0010|0011|0100|0101|0110|0111|1000|1001|1010|1011|1100|1101|1110|1111&quot;\r\n    $bits = stringsplit($bits,&#039;|&#039;)\r\n    #region check string is binary\r\n\r\n    $test = stringreplace($BinaryValue,&#039;1&#039;,&#039;&#039;)\r\n    $test = stringreplace($test,&#039;0&#039;,&#039;&#039;)\r\n    if $test &lt;&gt; &#039;&#039; Then\r\n        SetError(-1);non binary character detected\r\n        Return\r\n    endif\r\n    #endregion check string is binary\r\n\r\n    #region make binary string an integral multiple of 4 characters\r\n    While 1\r\n        $nb = Mod(StringLen($BinaryValue),4)\r\n        if $nb = 0 then exitloop\r\n        $BinaryValue = &#039;0&#039; &amp; $BinaryValue\r\n    WEnd\r\n    #endregion make binary string an integral multiple of 4 characters\r\n\r\n    $numbytes = Int(StringLen($BinaryValue)\/4);the number of bytes\r\n\r\n    Dim $bytes[$numbytes],$Deci[$numbytes]\r\n    For $j = 0 to $numbytes - 1;for each byte\r\n    ;extract the next byte\r\n        $bytes[$j] = StringMid($BinaryValue,1+4*$j,4)\r\n\r\n    ;find what the dec value of the byte is\r\n        for $k = 0 to 15;for all the 16 possible hex values\r\n            if $bytes[$j] = $bits[$k+1] Then\r\n                $Deci[$j] = $k\r\n                ExitLoop\r\n            EndIf\r\n        next\r\n    Next\r\n    \r\n;now we have the decimal value for each byte, so stitch the string together again\r\n    $Result = &#039;&#039;\r\n    for $l = 0 to $numbytes - 1\r\n        $Result &amp;= Hex($Deci[$l],1)\r\n    Next\r\n    return $Result\r\nElse\r\n    MsgBox(0,&quot;Error&quot;,&quot;Wrong input, try again ...&quot;)\r\n    Return\r\nEndIf   \r\nEndFunc<\/code><\/pre>\n<p>If you need to reset your ATA to default, plug in a handset and hit the button on top.  Then type in 322873738#.  To check ATA IP, type in 80#.  This and more can be found in the <a href=\"http:\/\/www.cisco.com\/en\/US\/products\/hw\/gatecont\/ps514\/products_configuration_example09186a00800c3a50.shtml\">ATA Basic Config Guide<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are going to setup an ATA in a network that is non Cisco(sans voice vlan on switches), then you will need to\u2026<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,16],"tags":[],"class_list":["post-588","post","type-post","status-publish","format-standard","hentry","category-autoit","category-cisco"],"_links":{"self":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/588","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=588"}],"version-history":[{"count":9,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/588\/revisions"}],"predecessor-version":[{"id":1185,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/588\/revisions\/1185"}],"wp:attachment":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}