Skip to content

Commit

Permalink
Merge bb73538 into 1a99557
Browse files Browse the repository at this point in the history
  • Loading branch information
bl0ggy committed Feb 20, 2020
2 parents 1a99557 + bb73538 commit 1c9f63c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
32 changes: 32 additions & 0 deletions lib/cam.js
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,38 @@ Cam.prototype.systemReboot = function(callback) {
});
};

/**
* @callback Cam~SetSystemFactoryDefaultCallback
* @property {?Error} error
* @property {null}
* @property {string} xml Raw SOAP response
*/

/**
* Reset camera to factory default
* @param {boolean} [hard=false] Reset network settings
* @param {Cam~SetSystemFactoryDefaultCallback} callback
*/
Cam.prototype.setSystemFactoryDefault = function(hard,callback) {
if (callback === undefined) {
callback = hard;
hard = false;
}
let body = this._envelopeHeader() +
'<SetSystemFactoryDefault xmlns="http://www.onvif.org/ver10/device/wsdl">' +
'<FactoryDefault>' + (hard ? 'Hard' : 'Soft') + '</FactoryDefault>' +
'</SetSystemFactoryDefault>' +
this._envelopeFooter();
this._request({
service: 'device',
body: body,
}, function(err, res, xml) {
if (callback) {
callback.call(this, err, null, xml);
}
});
}

/**
* Generate arguments for digest auth
* @return {{passdigest: *, nonce: (*|String), timestamp: string}}
Expand Down
12 changes: 11 additions & 1 deletion test/device.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,14 @@ describe 'Device', () ->
fromDHCP: true
}, (err) ->
assert.equal err, null
done()
done()

describe 'setSystemFactoryDefault', () ->
it 'should request a soft factory default', (done) ->
cam.setSystemFactoryDefault (err) ->
assert.equal err, null
done()
it 'should request a hard factory default', (done) ->
cam.setSystemFactoryDefault true, (err) ->
assert.equal err, null
done()
6 changes: 6 additions & 0 deletions test/serverMockup/device.SetSystemFactoryDefault.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime5="http://www.w3.org/2005/05/xmlmime" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tnsaxis="http://www.axis.com/2009/event/topics">
<SOAP-ENV:Body>
<tds:SetSystemFactoryDefaultResponse></tds:SetSystemFactoryDefaultResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

0 comments on commit 1c9f63c

Please sign in to comment.