diff --git a/data_model_202BC1-BM632w-8KA8WA1151100043.csv b/data_model_202BC1-BM632w-8KA8WA1151100043.csv index 958cfd0..9db651f 100644 --- a/data_model_202BC1-BM632w-8KA8WA1151100043.csv +++ b/data_model_202BC1-BM632w-8KA8WA1151100043.csv @@ -657,6 +657,117 @@ InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.X_HUAW InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnectionNumberOfEntries,false,false,1,xsd:unsignedInt InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection,true,true,, InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnectionNumberOfEntries,false,false,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1,true,true,, +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.ConnectionStatus,false,false,Connected,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.ConnectionTrigger,false,true,,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.ConnectionType,false,true,IP_Routed,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.CurrentMRUSize,false,false,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.DNSEnabled,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.DNSOverrideAllowed,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.DNSServer,false,true,202.155.0.150,202.155.0.10,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Enable false,true,true,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.ExternalIPAddress,false,false,182.29.4.3,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.IdleDisconnectTime,false,true,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.LastConnectionError,false,false,ERROR_NONE,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.MACAddress,false,false,d4:9a:a0:98:56:cb,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.MACAddressOverride,false,false,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.NATEnabled,false,true,true,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Name,false,true,INTERNET,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.PPPAuthenticationProtocol,false,true,AUTO_AUTH,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.PPPCompressionProtocol,false,false,,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.PPPEncryptionProtocol,false,false,,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.PPPLCPEcho,false,true,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.PPPLCPEchoRetry,false,true,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.PPPMtu,false,true,1492,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.PPPoEServiceName,false,true,,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Password,false,true,,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.PortMapping,true,true,, +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.PortMappingNumberOfEntries,false,false,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.PossibleConnectionTypes,false,false,Unconfigured IP_Routed,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.RSIPAvailable,false,false,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.RemoteIPAddress,false,false,182.29.16.3,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.RouteProtocolRx,false,false,Off,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats,true,false,, +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats.ByteRateReceived,false,false,4486,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats.ByteRateSent,false,false,33008505,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats.EthernetBytesReceived,false,false,293120503,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats.EthernetBytesSent,false,false,1027558218,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats.EthernetPacketsReceived,false,false,1056947658,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats.EthernetPacketsSent,false,false,995488963,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats.X_BROADCOM_COM_BroadcastPacketsReceived,false,false,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats.X_BROADCOM_COM_BroadcastPacketsSent,false,false,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats.X_BROADCOM_COM_MulticastBytesReceived,false,false,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats.X_BROADCOM_COM_MulticastBytesSent,false,false,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats.X_BROADCOM_COM_MulticastPacketsReceived,false,false,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats.X_BROADCOM_COM_MulticastPacketsSent,false,false,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats.X_BROADCOM_COM_RxDrops,false,false,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats.X_BROADCOM_COM_RxErrors,false,false,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats.X_BROADCOM_COM_TxDrops,false,false,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats.X_BROADCOM_COM_TxErrors,false,false,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats.X_BROADCOM_COM_UnicastPacketsReceived,false,false,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Stats.X_BROADCOM_COM_UnicastPacketsSent,false,false,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.TransportType,false,false,,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Uptime,false,false,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Username,false,true,GG10114601,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.WanIdx,false,true,3,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_AFlag,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_AddPppToBridge,false,false,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_ConnectionEstablishedTime,false,false,33,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_DefaultGateway,false,false,182.29.16.3,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_DefaultIPv6Gateway,false,false,fe80::12e8:78ff:fe6f:6751,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_Dhcp6cForAddress,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_Dhcp6cForPrefixDelegation,false,true,true,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_Dhcp6cPid,false,true,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_Enable_Debug,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_ExternalIPv6Address,false,false,,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_FirewallEnabled,false,true,true,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_FirewallException,true,true,, +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_FirewallException.1,true,true +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_FirewallException.1.DestinationIPAddress,false,true,,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_FirewallException.1.DestinationNetMask,false,true,,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_FirewallException.1.DestinationPortEnd,false,true,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_FirewallException.1.DestinationPortStart,false,true,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_FirewallException.1.Enable,false,true,true,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_FirewallException.1.FilterName,false,true,open_icmp,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_FirewallException.1.IPVersion,false,true,4,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_FirewallException.1.Protocol,false,true,ICMP,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_FirewallException.1.SourceIPAddress,false,true,,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_FirewallException.1.SourceNetMask,false,true,,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_FirewallException.1.SourcePortEnd,false,true,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_FirewallException.1.SourcePortStart,false,true,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_FullconeNATEnabled,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_IGMPEnabled,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_IGMP_SOURCEEnabled,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_IPExtension,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_IPv4Enabled,false,true,true,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_IPv6AddressingType,false,true,DHCP,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_IPv6ConnStatus,false,false,Unconfigured,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_IPv6DNSServers,false,true,2001:e00:e:3::10 2001:e00:e:9::2,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_IPv6DomainName,false,true,,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_IPv6Enabled,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_IPv6PppUp,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_IPv6PrefixDelegationEnabled,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_IPv6SitePrefix,false,false,2001:e00:100:cb61::/64,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_IPv6SitePrefixPltime,false,false,600,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_IPv6SitePrefixVltime,false,false,600,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_IfName,false,true,ppp0.0,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_LFlag,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_LocalIPAddress,false,false,,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_MFlag,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_MLDEnabled,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_MLD_SOURCEEnabled,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_NoMcastVlanFilter,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_OFlag,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_PCPMode,false,false,0,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_PCPServer,false,false,,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_PortTriggering,true,true,, +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_TransientLayer2LinkStatus,false,false,Up,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_UnnumberedModel,false,false,true,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_UseStaticIPAddress,false,true,false,xsd:boolean +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_UserRequest,false,false,None,xsd:string +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_VlanMux8021p,false,true,1,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_VlanMuxID,false,true,30,xsd:unsignedInt +InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.X_BROADCOM_COM_VlanTpid,false,true,33024,xsd:unsignedInt InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WiMAXLinkConfig,true,false,, InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WiMAXLinkConfig.SubscriptionParametersIdentifier,false,false,,xsd:string InternetGatewayDevice.WANDevice.1.WANConnectionNumberOfEntries,false,false,1,xsd:unsignedInt diff --git a/genieacs-sim b/genieacs-sim index b64037e..3fdd352 100755 --- a/genieacs-sim +++ b/genieacs-sim @@ -64,14 +64,21 @@ cluster.on("fork", function(worker) { }); cluster.on("exit", function(worker, code, signal) { - console.log(`Simulator ${worker.env["SERIAL_NUMBER"]} died (${signal || code}). Restarting in 10 seconds...`) - setTimeout(function() { - let newWorker = cluster.fork(worker.env); - newWorker.env = worker.env; - }, 10000); + if(code == 255){ + console.log(`Simulator ${worker.env["SERIAL_NUMBER"]} - Factory Reset - Restarting`); + setTimeout(function() { + let newWorker = cluster.fork(worker.env); + newWorker.env = worker.env; + }, 1000); + }else{ + console.log(`Simulator ${worker.env["SERIAL_NUMBER"]} died (${signal || code}). Restarting in 10 seconds... ${signal} and ${code}`); + setTimeout(function() { + let newWorker = cluster.fork(worker.env); + newWorker.env = worker.env; + }, 10000); + }; }); - for (let i = 0; i < program.processes; ++ i) { setTimeout(function() { let env = { diff --git a/methods.js b/methods.js index 1df5a6f..c48166c 100644 --- a/methods.js +++ b/methods.js @@ -24,6 +24,11 @@ const INFORM_PARAMS = [ "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress" ]; +var deviceTemplate = null; + +function setDeviceTemplate(device){ + deviceTemplate = JSON.parse(JSON.stringify(device)); +} function inform(device, event, callback) { let manufacturer = ""; @@ -123,9 +128,21 @@ function inform(device, event, callback) { ] ); - let evnt = xmlUtils.node("Event", { - "soap-enc:arrayType": "cwmp:EventStruct[1]" - }, eventStruct); + let strEvent = (event || "2 PERIODIC").split(","); + let events = []; + + for(let p of strEvent){ + let evt = p.replace(/^\s+|\s+$/gm,''); + if(evt === "") { + continue; + } + events.push(xmlUtils.node("EventStruct",{},[ + xmlUtils.node("EventCode", {}, evt), + xmlUtils.node("CommandKey")] + ) + ); + } + let evnt = xmlUtils.node("Event", {"soap-enc:arrayType": `cwmp:EventStruct[${events.length}]`}, events); let params = []; for (let p of INFORM_PARAMS) { @@ -172,6 +189,7 @@ function getSortedPaths(device) { function GetParameterNames(device, request, callback) { + //console.log(device); let parameterNames = getSortedPaths(device); let parameterPath, nextLevel; @@ -230,6 +248,7 @@ function GetParameterNames(device, request, callback) { function GetParameterValues(device, request, callback) { let parameterNames = request.children[0].children; + let params = [] for (let p of parameterNames) { let name = p.text; @@ -298,18 +317,21 @@ function AddObject(device, request, callback) { "xsd:dateTime": "0001-01-01T00:00:00Z" }; - for (let p of getSortedPaths(device)) { + getSortedPaths(device); + for (let p of getSortedPaths(deviceTemplate)) { if (p.startsWith(objectName) && p.length > objectName.length) { let n = `${objectName}${instanceNumber}${p.slice(p.indexOf(".", objectName.length))}`; if (!device[n]) - device[n] = [device[p][0], defaultValues[device[p][2]] || "", device[p][2]]; + device[n] = [deviceTemplate[p][0], defaultValues[deviceTemplate[p][2]] || "", deviceTemplate[p][2]]; } } + let response = xmlUtils.node("cwmp:AddObjectResponse", {}, [ xmlUtils.node("InstanceNumber", {}, String(instanceNumber)), xmlUtils.node("Status", {}, "0") ]); + delete deviceTemplate._sortedPaths; delete device._sortedPaths; return callback(response); } @@ -409,7 +431,24 @@ function Download(device, request, callback) { return callback(response); } +function Reboot(device, request, callback) { + let response = xmlUtils.node("cwmp:RebootResponse", {}, ""); + callback(response); + return "inform"; +} + + +function FactoryReset(device, request, callback) { + let response = xmlUtils.node("cwmp:FactoryResetResponse", {}, ""); + callback(response); + return "reset"; +} + +function getDeviceTemplate(){ + return deviceTemplate; +} +exports.setDeviceTemplate = setDeviceTemplate; exports.inform = inform; exports.getPending = getPending; exports.GetParameterNames = GetParameterNames; @@ -418,3 +457,6 @@ exports.SetParameterValues = SetParameterValues; exports.AddObject = AddObject; exports.DeleteObject = DeleteObject; exports.Download = Download; +exports.Reboot = Reboot; +exports.FactoryReset = FactoryReset; +exports.getDeviceTemplate = getDeviceTemplate; \ No newline at end of file diff --git a/simulator.js b/simulator.js index 986bddb..c386095 100644 --- a/simulator.js +++ b/simulator.js @@ -200,6 +200,7 @@ function handleMethod(xml) { } } let method = methods[requestElement.localName]; + if (!method) { let body = createFaultResponse(9000, "Method not supported"); @@ -210,12 +211,30 @@ function handleMethod(xml) { return; } - method(device, requestElement, function(body) { + let nextStep=method(device, requestElement, function(body) { let xml = createSoapDocument(requestId, body); sendRequest(xml, function(xml) { handleMethod(xml); }); }); + if(nextStep === "boot"){ + return startSession("1 BOOT,M Reboot"); + + methods.inform(device, "1 BOOT, M Reboot", function(body) { + requestId = Math.random().toString(36).slice(-8); + let xml = createSoapDocument(requestId, body); + sendRequest(xml, function(xml) { + handleMethod(xml); + }); + }) + } + else if(nextStep == "reset"){ + //device = JSON.parse(JSON.stringify(methods.getDeviceTemplate())) + //console.log(device); + setTimeout(function(){process.exit(255) + },0); + //return startSession("0 BOOTSTRAP,1 BOOT"); + } } function listenForConnectionRequests(serialNumber, acsUrlOptions, callback) { @@ -260,7 +279,7 @@ function listenForConnectionRequests(serialNumber, acsUrlOptions, callback) { function start(dataModel, serialNumber, acsUrl) { device = dataModel; - + methods.setDeviceTemplate(device); if (device["DeviceID.SerialNumber"]) device["DeviceID.SerialNumber"][1] = serialNumber; if (device["Device.DeviceInfo.SerialNumber"]) @@ -291,7 +310,7 @@ function start(dataModel, serialNumber, acsUrl) { } else if (device["Device.ManagementServer.ConnectionRequestURL"]) { device["Device.ManagementServer.ConnectionRequestURL"][1] = connectionRequestUrl; } - startSession(); + startSession("0 BOOTSTRAP,1 BOOT"); }); }