Utility Functions

eI() – signedInteger()

function eI(value);
Description Used to wrap a numeric value with explicit type information and instruct the ACS to always send this value as a signed integer value.
Parameters value – signed integer value to be set
Returns An object whose internals are not relevant here but should be passed to set() or create()
Required Libraries None
Example

useLibrary("tr069");

set(path, eI(“-42”);

 

eU() – unsignedInteger()

function eU(value);
Description Used to wrap a numeric value with explicit type information and instruct the ACS to always send this value as an unsigned integer value.
Parameters value – unsigned integer value to be set
Returns An object whose internals are not relevant here but should be passed to set() or create()
Required Libraries None
Example

useLibrary("tr069");

set(path, eU(“42”);

 

eS() – explicitString()

function eS(value);
Description Used to wrap a sting value with explicit type information and instruct the ACS to always send this value as a string value
Parameters value – string value to be set
Returns An object whose internals are not relevant here but should be passed to set() or create().
Required Libraries None
Example

useLibrary("tr069");

set(path, eS(“The number 42”);

 

eB - explicitBoolean()

function explicitBoolean(value);
Description Used to wrap a boolean value with explicit type information and instruct the ACS to always send this value as a boolean value.
Parameters value – boolean value to be set
Returns An object whose internals are not relevant here but should be passed to set() or create().
Required Libraries None
Example

useLibrary("tr069");

set(path, eB(“1”);

 

each() – Simplify Path Nested “for” Loops

function each(path, function);
Description Convenient nested for loop construct that loops through all PathObject instances along the specified path and executes the indicated function for each PathObject instance found. See the Path section for details.
Parameters
  • path – Path containing one or more nested PathObjects
  • function – function to be executed for each PathObject instance found along the Path
Returns

An object containing:

  • path - Path with specific instance numbers included
  • value – true/false value indicating the presence of the indicated PathProperty.
Required Libraries None
Example

///////////////////////////////////////////////////////////

// Iterate through all routed IP connections and enable

// NAT for each connection found
///////////////////////////////////////////////////////////

 

// Helper functions

function isFalse(val) {     

return (val === false || val === 0 || val === '0' || val === 'false');

}

function getPath(obj, depth) {     

return obj.nodes.slice(0, depth).join(".");

}

 

// Script entry point

var WANCnxnPath;

each("InternetGatewayDevice.WANDevice.{}.WANConnectionDevice.{}.WANIPConnection|WANPPPConnection.{}.NATEnabled",function(obj) {  

  if (!WANCnxnPath && isFalse(obj.value)) {       

WANCnxnPath = getPath(obj, 7);  

    if (get(WANCnxnPath + ".ConnectionType") == 'IP_Routed'){         

set(WANCnxnPath + ".NATEnabled", 1);   

      log.info ("Internet enabled");  

    }     

}

});

 

useLibrary()

function useLibrary(libraryName, …);
Description Include one or more standard libraries for use with the current script.
Parameters libraryName – name of the library to include
Returns None
Required Libraries None
Example

useLibrary("tr069");

set("InternetGatewayDevice.X_BROADCOM_COM_LoginCfg.SupportPassword","newPassword");