parent
b7d0bd5df1
commit
09355c25d0
|
@ -196,11 +196,11 @@ function configuration_backup(callback) {
|
||||||
return MSP.promise(MSPCodes.MSP_SENSOR_CONFIG);
|
return MSP.promise(MSPCodes.MSP_SENSOR_CONFIG);
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
|
return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
|
||||||
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_CRAFT_NAME))
|
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.CRAFT_NAME))
|
||||||
: MSP.promise(MSPCodes.MSP_NAME);
|
: MSP.promise(MSPCodes.MSP_NAME);
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
|
return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
|
||||||
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME)) : Promise.resolve(true);
|
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.PILOT_NAME)) : Promise.resolve(true);
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return MSP.promise(MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG);
|
return MSP.promise(MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG);
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
|
@ -812,8 +812,8 @@ function configuration_restore(callback) {
|
||||||
|
|
||||||
function update_unique_data_list() {
|
function update_unique_data_list() {
|
||||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
|
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
|
||||||
uniqueData.push([MSPCodes.MSP2_SET_TEXT, MSPCodes.MSP2TEXT_CRAFT_NAME]);
|
uniqueData.push([MSPCodes.MSP2_SET_TEXT, MSPCodes.CRAFT_NAME]);
|
||||||
uniqueData.push([MSPCodes.MSP2_SET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME]);
|
uniqueData.push([MSPCodes.MSP2_SET_TEXT, MSPCodes.PILOT_NAME]);
|
||||||
} else {
|
} else {
|
||||||
uniqueData.push(MSPCodes.MSP_SET_NAME);
|
uniqueData.push(MSPCodes.MSP_SET_NAME);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ const INITIAL_CONFIG = {
|
||||||
craftName: '',
|
craftName: '',
|
||||||
displayName: '', // present for backwards compatibility before MSP v1.45
|
displayName: '', // present for backwards compatibility before MSP v1.45
|
||||||
pilotName: '',
|
pilotName: '',
|
||||||
|
pidProfileNames: ["", "", "", ""],
|
||||||
|
rateProfileNames: ["", "", "", ""],
|
||||||
numProfiles: 3,
|
numProfiles: 3,
|
||||||
rateProfile: 0,
|
rateProfile: 0,
|
||||||
boardType: 0,
|
boardType: 0,
|
||||||
|
|
|
@ -195,10 +195,13 @@ const MSPCodes = {
|
||||||
MSP2_SET_MOTOR_OUTPUT_REORDERING: 0x3002,
|
MSP2_SET_MOTOR_OUTPUT_REORDERING: 0x3002,
|
||||||
MSP2_SEND_DSHOT_COMMAND: 0x3003,
|
MSP2_SEND_DSHOT_COMMAND: 0x3003,
|
||||||
MSP2_GET_VTX_DEVICE_STATUS: 0x3004,
|
MSP2_GET_VTX_DEVICE_STATUS: 0x3004,
|
||||||
|
MSP2_GET_OSD_WARNINGS: 0x3005,
|
||||||
MSP2_GET_TEXT: 0x3006,
|
MSP2_GET_TEXT: 0x3006,
|
||||||
MSP2_SET_TEXT: 0x3007,
|
MSP2_SET_TEXT: 0x3007,
|
||||||
|
|
||||||
// MSP2_GET_TEXT and MSP2_SET_TEXT variable types
|
// MSP2_GET_TEXT and MSP2_SET_TEXT variable types
|
||||||
MSP2TEXT_PILOT_NAME: 1,
|
PILOT_NAME: 1,
|
||||||
MSP2TEXT_CRAFT_NAME: 2,
|
CRAFT_NAME: 2,
|
||||||
|
PID_PROFILE_NAME: 3,
|
||||||
|
RATE_PROFILE_NAME: 4,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
// Used for LED_STRIP
|
// Used for LED_STRIP
|
||||||
const ledDirectionLetters = ['n', 'e', 's', 'w', 'u', 'd']; // in LSB bit order
|
const ledDirectionLetters = ['n', 'e', 's', 'w', 'u', 'd']; // in LSB bit order
|
||||||
const ledFunctionLetters = ['i', 'w', 'f', 'a', 't', 'r', 'c', 'g', 's', 'b', 'l']; // in LSB bit order
|
const ledFunctionLetters = ['i', 'w', 'f', 'a', 't', 'r', 'c', 'g', 's', 'b', 'l']; // in LSB bit order
|
||||||
|
@ -52,6 +51,31 @@ function MspHelper() {
|
||||||
self.SIGNATURE_LENGTH = 32;
|
self.SIGNATURE_LENGTH = 32;
|
||||||
|
|
||||||
self.mspMultipleCache = [];
|
self.mspMultipleCache = [];
|
||||||
|
|
||||||
|
self.setText = function(buffer, type, config, length) {
|
||||||
|
// type byte
|
||||||
|
buffer.push8(type);
|
||||||
|
|
||||||
|
const size = Math.min(length, config.length);
|
||||||
|
// length byte followed by the actual characters
|
||||||
|
buffer.push8(size);
|
||||||
|
|
||||||
|
for (let i = 0; i < size; i++) {
|
||||||
|
buffer.push8(config.charCodeAt(i));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
self.getText = function(data) {
|
||||||
|
// length byte followed by the actual characters
|
||||||
|
const size = data.readU8() || 0;
|
||||||
|
let str = '';
|
||||||
|
|
||||||
|
for (let i = 0; i < size; i++) {
|
||||||
|
str += String.fromCharCode(data.readU8());
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -922,20 +946,25 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
||||||
case MSPCodes.MSP2_GET_TEXT:
|
case MSPCodes.MSP2_GET_TEXT:
|
||||||
// type byte
|
// type byte
|
||||||
const textType = data.readU8();
|
const textType = data.readU8();
|
||||||
// length byte followed by the actual characters
|
|
||||||
const textLength = data.readU8() || 0;
|
|
||||||
|
|
||||||
if (textType === MSPCodes.MSP2TEXT_PILOT_NAME) {
|
switch(textType) {
|
||||||
FC.CONFIG.pilotName = '';
|
case MSPCodes.PILOT_NAME:
|
||||||
for (let i = 0; i < textLength; i++) {
|
FC.CONFIG.pilotName = self.getText(data);
|
||||||
FC.CONFIG.pilotName += String.fromCharCode(data.readU8());
|
break;
|
||||||
}
|
case MSPCodes.CRAFT_NAME:
|
||||||
} else if (textType === MSPCodes.MSP2TEXT_CRAFT_NAME) {
|
FC.CONFIG.craftName = self.getText(data);
|
||||||
FC.CONFIG.craftName = '';
|
break;
|
||||||
for (let i = 0; i < textLength; i++) {
|
case MSPCodes.PID_PROFILE_NAME:
|
||||||
FC.CONFIG.craftName += String.fromCharCode(data.readU8());
|
FC.CONFIG.pidProfileNames[FC.CONFIG.profile] = self.getText(data);
|
||||||
}
|
break;
|
||||||
|
case MSPCodes.RATE_PROFILE_NAME:
|
||||||
|
FC.CONFIG.rateProfileNames[FC.CONFIG.rateProfile] = self.getText(data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log('Unsupport text type');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSPCodes.MSP_SET_CHANNEL_FORWARDING:
|
case MSPCodes.MSP_SET_CHANNEL_FORWARDING:
|
||||||
|
@ -2352,40 +2381,26 @@ MspHelper.prototype.crunch = function(code, modifierCode = undefined) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSPCodes.MSP2_GET_TEXT:
|
case MSPCodes.MSP2_GET_TEXT:
|
||||||
if (modifierCode === MSPCodes.MSP2TEXT_PILOT_NAME) {
|
buffer.push8(modifierCode);
|
||||||
// type byte
|
|
||||||
buffer.push8(MSPCodes.MSP2TEXT_PILOT_NAME);
|
|
||||||
} else if (modifierCode === MSPCodes.MSP2TEXT_CRAFT_NAME) {
|
|
||||||
// type byte
|
|
||||||
buffer.push8(MSPCodes.MSP2TEXT_CRAFT_NAME);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSPCodes.MSP2_SET_TEXT:
|
case MSPCodes.MSP2_SET_TEXT:
|
||||||
if (modifierCode === MSPCodes.MSP2TEXT_PILOT_NAME) {
|
switch (modifierCode) {
|
||||||
// type byte
|
case MSPCodes.PILOT_NAME:
|
||||||
buffer.push8(MSPCodes.MSP2TEXT_PILOT_NAME);
|
self.setText(buffer, modifierCode, FC.CONFIG.pilotName, 16);
|
||||||
|
break;
|
||||||
const MAX_NAME_LENGTH = 16;
|
case MSPCodes.CRAFT_NAME:
|
||||||
const pilotNameLength = Math.min(MAX_NAME_LENGTH, FC.CONFIG.pilotName.length);
|
self.setText(buffer, modifierCode, FC.CONFIG.craftName, 16);
|
||||||
// length byte followed by the actual characters
|
break;
|
||||||
buffer.push8(pilotNameLength);
|
case MSPCodes.PID_PROFILE_NAME:
|
||||||
|
self.setText(buffer, modifierCode, FC.CONFIG.pidProfileNames[FC.CONFIG.profile], 8);
|
||||||
for (let i = 0; i < pilotNameLength; i++) {
|
break;
|
||||||
buffer.push8(FC.CONFIG.pilotName.charCodeAt(i));
|
case MSPCodes.RATE_PROFILE_NAME:
|
||||||
}
|
self.setText(buffer, modifierCode, FC.CONFIG.pidProfileNames[FC.CONFIG.rateProfile], 8);
|
||||||
} else if (modifierCode === MSPCodes.MSP2TEXT_CRAFT_NAME) {
|
break;
|
||||||
// type byte
|
default:
|
||||||
buffer.push8(MSPCodes.MSP2TEXT_CRAFT_NAME);
|
console.log('Unsupport text type');
|
||||||
|
break;
|
||||||
const MAX_NAME_LENGTH = 16;
|
|
||||||
const craftNameLength = Math.min(MAX_NAME_LENGTH, FC.CONFIG.craftName.length);
|
|
||||||
// length byte followed by the actual characters
|
|
||||||
buffer.push8(craftNameLength);
|
|
||||||
|
|
||||||
for (let i = 0; i < craftNameLength; i++) {
|
|
||||||
buffer.push8(FC.CONFIG.craftName.charCodeAt(i));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -454,24 +454,15 @@ function processUid() {
|
||||||
|
|
||||||
async function processCraftName() {
|
async function processCraftName() {
|
||||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
|
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
|
||||||
await MSP.promise(
|
await MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.CRAFT_NAME));
|
||||||
MSPCodes.MSP2_GET_TEXT,
|
|
||||||
mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_CRAFT_NAME),
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
await MSP.promise(MSPCodes.MSP_NAME);
|
await MSP.promise(MSPCodes.MSP_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI.log(i18n.getMessage('craftNameReceived', semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
|
GUI.log(i18n.getMessage('craftNameReceived', semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ? [FC.CONFIG.craftName] : [FC.CONFIG.name]));
|
||||||
? [FC.CONFIG.craftName]
|
|
||||||
: [FC.CONFIG.name],
|
|
||||||
));
|
|
||||||
|
|
||||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
|
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
|
||||||
await MSP.promise(
|
await MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.PILOT_NAME));
|
||||||
MSPCodes.MSP2_GET_TEXT,
|
|
||||||
mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FC.CONFIG.armingDisabled = false;
|
FC.CONFIG.armingDisabled = false;
|
||||||
|
|
|
@ -34,11 +34,11 @@ configuration.initialize = function (callback) {
|
||||||
? MSP.promise(MSPCodes.MSP_NAME)
|
? MSP.promise(MSPCodes.MSP_NAME)
|
||||||
: Promise.resolve(true); })
|
: Promise.resolve(true); })
|
||||||
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
|
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
|
||||||
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_CRAFT_NAME))
|
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.CRAFT_NAME))
|
||||||
: Promise.resolve(true); })
|
: Promise.resolve(true); })
|
||||||
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31) ? MSP.promise(MSPCodes.MSP_RX_CONFIG) : true; })
|
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31) ? MSP.promise(MSPCodes.MSP_RX_CONFIG) : true; })
|
||||||
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
|
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
|
||||||
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME)) : Promise.resolve(true); })
|
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.PILOT_NAME)) : Promise.resolve(true); })
|
||||||
.then(() => { return MSP.promise(MSPCodes.MSP_ADVANCED_CONFIG); })
|
.then(() => { return MSP.promise(MSPCodes.MSP_ADVANCED_CONFIG); })
|
||||||
.then(() => { load_html(); });
|
.then(() => { load_html(); });
|
||||||
}
|
}
|
||||||
|
@ -636,10 +636,10 @@ configuration.initialize = function (callback) {
|
||||||
.then(() => { return MSP.promise(MSPCodes.MSP_SET_ARMING_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ARMING_CONFIG)); })
|
.then(() => { return MSP.promise(MSPCodes.MSP_SET_ARMING_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ARMING_CONFIG)); })
|
||||||
.then(() => { return MSP.promise(MSPCodes.MSP_SET_SENSOR_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_CONFIG)); })
|
.then(() => { return MSP.promise(MSPCodes.MSP_SET_SENSOR_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_CONFIG)); })
|
||||||
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
|
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
|
||||||
? MSP.promise(MSPCodes.MSP2_SET_TEXT, mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.MSP2TEXT_CRAFT_NAME))
|
? MSP.promise(MSPCodes.MSP2_SET_TEXT, mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.CRAFT_NAME))
|
||||||
: MSP.promise(MSPCodes.MSP_SET_NAME, mspHelper.crunch(MSPCodes.MSP_SET_NAME)); })
|
: MSP.promise(MSPCodes.MSP_SET_NAME, mspHelper.crunch(MSPCodes.MSP_SET_NAME)); })
|
||||||
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ?
|
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ?
|
||||||
MSP.promise(MSPCodes.MSP2_SET_TEXT, mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME)) : Promise.resolve(true); })
|
MSP.promise(MSPCodes.MSP2_SET_TEXT, mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.PILOT_NAME)) : Promise.resolve(true); })
|
||||||
.then(() => { return (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) ? MSP.promise(MSPCodes.MSP_SET_RX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_RX_CONFIG)) : true; })
|
.then(() => { return (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) ? MSP.promise(MSPCodes.MSP_SET_RX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_RX_CONFIG)) : true; })
|
||||||
.then(() => { return MSP.promise(MSPCodes.MSP_EEPROM_WRITE); })
|
.then(() => { return MSP.promise(MSPCodes.MSP_EEPROM_WRITE); })
|
||||||
.then(() => { reboot(); });
|
.then(() => { reboot(); });
|
||||||
|
|
|
@ -27,12 +27,7 @@ onboard_logging.initialize = function (callback) {
|
||||||
MSP.send_message(MSPCodes.MSP_BLACKBOX_CONFIG, false, false, function() {
|
MSP.send_message(MSPCodes.MSP_BLACKBOX_CONFIG, false, false, function() {
|
||||||
MSP.send_message(MSPCodes.MSP_ADVANCED_CONFIG, false, false, function() {
|
MSP.send_message(MSPCodes.MSP_ADVANCED_CONFIG, false, false, function() {
|
||||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
|
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
|
||||||
MSP.send_message(
|
MSP.send_message(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.CRAFT_NAME), false, load_html);
|
||||||
MSPCodes.MSP2_GET_TEXT,
|
|
||||||
mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_CRAFT_NAME),
|
|
||||||
false,
|
|
||||||
load_html,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
MSP.send_message(MSPCodes.MSP_NAME, false, false, load_html);
|
MSP.send_message(MSPCodes.MSP_NAME, false, false, load_html);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue