First for the "Default" script you should determine what sort of request was sent:
// Default Authentication type var xAuthType = '0'; // Serial Number var xSerNum = cpe.Inform.DeviceId.SerialNumber; // Logging support. Literal to prefix logger output var xLogPrefix = "\n>>>>" + xSerNum.substring(5,10) + " "; //First print the device information call("1-PrintDeviceInfo"); var sEvent; var sCommandKey; for( i=0; i<=cpe.Inform.Event.length-1; i++ ) { sEvent = cpe.Inform.Event[i].EventCode; sCommandKey = cpe.Inform.Event[i].CommandKey; switch ( sEvent ) { case '0 BOOTSTRAP': logger('>>>> Bootstrap - Call 2-Configure <<<<'); call("2-Configure"); break; case '1 BOOT': logger('>>>> Boot - Call 2-Configure <<<<'); call("2-Configure"); break; case '2 PERIODIC': logger('>>>> Periodic - Call 2-Configure <<<<'); call("2-Configure"); break; case '3 SCHEDULED': break; case '4 VALUE CHANGE': break; case '5 KICKED': break; case '6 CONNECTION REQUEST': logger('>>>> Connection Request - Call 2-Configure <<<<'); call("2-Configure"); break; case '7 TRANSFER COMPLETE': break; case '8 DIAGNOSTICS COMPLETE': break; } }
Now that you have created a script above, you can create a sub-script that is called and name them "1-DoBootStrap" or similar. I personally numbered them so the order as displayed inside ACS on the left hand side is shown in the order that the scripts are executed, otherwise they are ordered alphabetically.
Now create using the above examples two script 1-PrintDeviceInfo and 2-Configure. Using the below Examples:
1-PrintDeviceInfo
// Device xMessage = xLogPrefix + ' DeviceId:'; xMessage += xLogPrefix + ' Manufacturer: ' + cpe.Inform.DeviceId.Manufacturer; xMessage += xLogPrefix + ' OUI: ' + cpe.Inform.DeviceId.OUI; xMessage += xLogPrefix + ' ProductClass: ' + cpe.Inform.DeviceId.ProductClass; xMessage += xLogPrefix + ' SerialNumber: ' + cpe.Inform.DeviceId.SerialNumber; xMessage += xLogPrefix + ' Misc:'; xMessage += xLogPrefix + ' MaxEnvelopes: ' + cpe.Inform.MaxEnvelopes; xMessage += xLogPrefix + ' RetryCount: ' + cpe.Inform.RetryCount; xMessage += xLogPrefix + ' CurrentTime: ' + cpe.Inform.CurrentTime; // ------------------------------------------------------------------------------ // Events xMessage += xLogPrefix + ' Events:'; for (i = 0; i <= cpe.Inform.Event.length - 1; i++) xMessage += xLogPrefix + ' ' + cpe.Inform.Event[i].EventCode + ' [' + cpe.Inform.Event[i].CommandKey + ']'; // ------------------------------------------------------------------------------ // Parameters xMessage += xLogPrefix + ' Params:'; for (i = 0; i <= cpe.Inform.ParameterList.length - 1; i++) { xMessage += xLogPrefix + ' ' + cpe.Inform.ParameterList[i].Name + '=' + cpe.Inform.ParameterList[i].Value; if (cpe.Inform.ParameterList[i].Name == "InternetGatewayDevice.ManagementServer.ConnectionRequestURL") { ConnURL=cpe.Inform.ParameterList[i].Value; xMessage += xLogPrefix + ' ConURL: ' + ConnURL; } } xMessage += xLogPrefix; logger(xMessage);
2-Configure
// Retrieve the periodic inform interval from the Default device profile in the database try { var dsDevice = db.Query("SELECT informinterval FROM DeviceProfileBean WHERE name='Default'") } catch (e) { // Error reading database logger('Exception : ' + e.message) } // PeriodicInformInterval var xTr98_PeriodicInform = dsDevice[0].informinterval; // ------------------------------------------------------------------------------ // Set the string prefix for the parameters to be configured var xTr98Prefix = 'InternetGatewayDevice.ManagementServer.'; var xTr98Params = new Array(); var c = '0'; xTr98Params[c++] = { name: xTr98Prefix + 'Username', value: 'ACSUsername' }; xTr98Params[c++] = { name: xTr98Prefix + 'Password', value: 'ACSPassword' }; xTr98Params[c++] = { name: xTr98Prefix + 'ConnectionRequestUsername', value: 'CRUsername' }; xTr98Params[c++] = { name: xTr98Prefix + 'ConnectionRequestPassword', value: 'CRPassword' }; xTr98Params[c++] = { name: xTr98Prefix + 'PeriodicInformInterval', value: xTr98_PeriodicInform }; // ------------------------------------------------------------------------------ // Set the values xMessage = xLogPrefix + 'Sending xTr98Params ' + xTr98Params.length; for (ic = 0; ic <= xTr98Params.length - 1; ic++) { xMessage += xLogPrefix + xTr98Params[ic].name + ': ' + xTr98Params[ic].value; } logger(xMessage); // ------------------------------------------------------------------------------ // Set the values xSuccess = cpe.SetParameterValues(xTr98Params, "CommandKey"); // ------------------------------------------------------------------------------ //Check if successfully updated if (xSuccess == 0) { // ------------------------------------------------------------------------------ // Update HostsBean with the TR98 Parameters so that they can be viewed in GUI var xHbDbUpdString; xHbDbUpdString = 'UPDATE HostsBean SET customerid="' + xSerNum + '"'; xHbDbUpdString += ',username="' + xTr98_AcsUsername + '"'; xHbDbUpdString += ',password="' + xTr98_AcsPassword + '"'; xHbDbUpdString += ',conrequser="' + xTr98_CrUsername + '"'; xHbDbUpdString += ',conreqpass="' + xTr98_CrPassword + '"'; xHbDbUpdString += ',authtype="' + xAuthType + '"'; xHbDbUpdString += ' WHERE serialno="' + xSerNum + '"'; try { var rs = db.Update(xHbDbUpdString); } catch (e) { // HostsBean database update failed logger('Exception : ' + e.message) } }
Below are some example scripts:
Print Device Information - Example script showing printing all the device information received in the initial request.
Check Object and Add Object - Check for a Voice Profile and add Voice Profile Object if if it doesn't then call external script to set TR104 Parameters.
SetParameterValues using Array - Set the TR-104 Voice Profile creating an array then using SetParameterValues
Discussion: Problem start communication between CPE device and LibreACS server
Wiki: Example-PrintDeviceInfo
Wiki: Example-SetTR104
Wiki: Example-VoiceProfile
Wiki: Home