Menu

Example-SetTR104

Peter Lambrechtsen

Setting TR104 parameters

This example shows how to set TR104 parameters to a device. This uses variables as inputs set in other scripts but shows how to set the full set of parameters using a configuration script and send it to the device.

TR-104: http://www.broadband-forum.org/technical/download/TR-104.pdf

First you need to define a counter "c" as 0 and use that when adding elements to the array and create an empty array. Then add the "name" and "value" pairs for each parameter you want to specify and use the "c++" to add one to the counter to the Array. Then once the array is built print the result to the logger and call cpe.SetParameterValues with the array.

// SetTR104Parameters
//=================================================
// Start of Script
//=================================================

var c = '0';

var xTr104_Prefix = 'InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.1.';

var xTr104Params = new Array();
// ------------------------------------------------------------------------------
//VoiceProfile.{i}. elements
xTr104Params[c++] = {name: xTr104_Prefix + 'Enable', value: xTr104_ProfileEnable };
xTr104Params[c++] = {name: xTr104_Prefix + 'DigitMap', value: xTr104_DigitMap };
xTr104Params[c++] = {name: xTr104_Prefix + 'DTMFMethod', value: xTr104_DTMFMethod };

// ------------------------------------------------------------------------------
// VoiceProfile.{i}.SIP. elements
xTr104Params[c++] = {name: xTr104_Prefix + 'SIP.DSCPMark', value: xTr104_SIP_DSCPMark };
xTr104Params[c++] = {name: xTr104_Prefix + 'SIP.OutboundProxy', value: xTr104_SIP_OutboundProxy };
xTr104Params[c++] = {name: xTr104_Prefix + 'SIP.ProxyServer', value: xTr104_SIP_OutboundProxy };
xTr104Params[c++] = {name: xTr104_Prefix + 'SIP.RegistrarServer', value: xTr104_SIP_OutboundProxy };
xTr104Params[c++] = {name: xTr104_Prefix + 'SIP.RegisterExpires', value: xTr104_SIP_RegisterExpires };
xTr104Params[c++] = {name: xTr104_Prefix + 'SIP.RegistrationPeriod', value: xTr104_SIP_RegistrationPeriod };

// ------------------------------------------------------------------------------
// VoiceProfile.{i}.RTP. elements
xTr104Params[c++] = {name: xTr104_Prefix + 'RTP.DSCPMark', value: xTr104_RTP_DSCPMark };
xTr104Params[c++] = {name: xTr104_Prefix + 'RTP.TelephoneEventPayloadType', value: xTr104_RTP_TelephonePayload };

// Add the "Line.1." text to the xTr104_Prefix variable for line parameters for all subsequent elements.
xTr104_Prefix += 'Line.1.';

// ------------------------------------------------------------------------------
//VoiceProfile.{i}.Line.1. elements
xTr104Params[c++] = {name: xTr104_Prefix + 'Enable', value: xTr104_LineEnable };

// ------------------------------------------------------------------------------
//VoiceProfile.{i}.Line.1.CallingFeatures. elementsthe 
xTr104Params[c++] = {name: xTr104_Prefix + 'CallingFeatures.CallerIDEnable', value: xTr104_Feature_CallerID };
xTr104Params[c++] = {name: xTr104_Prefix + 'CallingFeatures.CallWaitingEnable', value: xTr104_Feature_CallWaiting };
xTr104Params[c++] = {name: xTr104_Prefix + 'CallingFeatures.CallTransferEnable', value: xTr104_Feature_CallTransfer };
xTr104Params[c++] = {name: xTr104_Prefix + 'CallingFeatures.MWIEnable', value: xTr104_Feature_MWI };

// ------------------------------------------------------------------------------
//VoiceProfile.{i}.Line.1.Codec.List. elements, this may differ depending on ATA implementation.
//G.711a
xTr104Params[c++] = {name: xTr104_Prefix + 'Codec.List.1.Enable', value: xTr104_G711AEnable };
xTr104Params[c++] = {name: xTr104_Prefix + 'Codec.List.1.PacketizationPeriod', value: xTr104_G711PTime };
xTr104Params[c++] = {name: xTr104_Prefix + 'Codec.List.1.SilenceSuppression', value: xTr104_SilenceSuppression};

// ------------------------------------------------------------------------------
//VoiceProfile.Line.SIP. elements
xTr104Params[c++] = {name: xTr104_Prefix + 'SIP.AuthUserName', value: xTr104_Line_SIP_UserName };
xTr104Params[c++] = {name: xTr104_Prefix + 'SIP.AuthPassword', value: xTr104_Line_SIP_Password };
xTr104Params[c++] = {name: xTr104_Prefix + 'SIP.URI', value: xTr104_Line_SIP_URI };

// ------------------------------------------------------------------------------
// Create variable xMessage to print output to logger
xMessage = xLogPrefix + 'Sending ' + xTr104Params.length + 'xTr104Params';
for (ic = 0; ic <= xTr104Params.length - 1; ic++) {
    xMessage += xLogPrefix + xTr104Params[ic].name + ': ' + xTr104Params[ic].value;
}
logger(xMessage);

//Call cpe.SetParameterValues and set resulting value to xResult.
xResult = cpe.SetParameterValues(xTr104Params, "");
// End of SetTR104Parameters

Related

Wiki: Examples

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.