Store receiver port in wizard
parent
4fe7728d46
commit
6a514920fa
@ -0,0 +1,51 @@
|
||||
'use strict';
|
||||
|
||||
const mspHelper = require('./msp/MSPHelper');
|
||||
const serialPortHelper = require('./serialPortHelper');
|
||||
const FC = require('./fc');
|
||||
|
||||
var wizardSaveFramework = (function () {
|
||||
|
||||
let self = {};
|
||||
|
||||
self.saveSetting = function (config, callback) {
|
||||
|
||||
switch (config.name) {
|
||||
case 'receiverPort':
|
||||
serialPortHelper.set(config.value, 'RX_SERIAL', null);
|
||||
mspHelper.saveSerialPorts(callback);
|
||||
break;
|
||||
default:
|
||||
callback();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
self.handleSetting = function (configs, finalCallback) {
|
||||
|
||||
if (configs.length > 0) {
|
||||
let setting = configs.shift();
|
||||
self.saveSetting(setting, function () {
|
||||
self.handleSetting(configs, finalCallback);
|
||||
});
|
||||
} else {
|
||||
console.log('Nothing to save');
|
||||
finalCallback();
|
||||
}
|
||||
};
|
||||
|
||||
self.persist = function (config, finalCallback) {
|
||||
if (config === null || config === undefined || config.length === 0) {
|
||||
finalCallback();
|
||||
return;
|
||||
}
|
||||
|
||||
let configCopy = Array.from(config);
|
||||
|
||||
self.handleSetting(configCopy, finalCallback);
|
||||
}
|
||||
|
||||
return self;
|
||||
})();
|
||||
|
||||
module.exports = wizardSaveFramework;
|
Loading…
Reference in New Issue