mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-25 17:25:16 +03:00
Use firmware options on introduction (#3900)
* Use firmware options * Enable telemetry for CRSF, GHST and FPORT * Add supported date * Only add telemetry when not included in firmware * Reduce brain overload
This commit is contained in:
parent
16f70a5be8
commit
37fada11ef
4 changed files with 36 additions and 20 deletions
|
@ -1,5 +1,5 @@
|
||||||
import { bit_check, bit_set, bit_clear } from "./bit";
|
import { bit_check, bit_set, bit_clear } from "./bit";
|
||||||
import { API_VERSION_1_44, API_VERSION_1_45 } from './data_storage';
|
import { API_VERSION_1_44, API_VERSION_1_45, API_VERSION_1_46 } from './data_storage';
|
||||||
import semver from "semver";
|
import semver from "semver";
|
||||||
import { tracking } from "./Analytics";
|
import { tracking } from "./Analytics";
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
|
@ -51,6 +51,18 @@ const Features = function (config) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add TELEMETRY feature if any of the following protocols are used: CRSF, GHST, FPORT
|
||||||
|
if (semver.gte(config.apiVersion, API_VERSION_1_46)) {
|
||||||
|
let enableTelemetry = false;
|
||||||
|
if (config.buildOptions.some(opt => opt.includes('CRSF') || opt.includes('GHST') || opt.includes('FPORT'))) {
|
||||||
|
enableTelemetry = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enableTelemetry) {
|
||||||
|
self._features.push({bit: 10, group: 'telemetry', name: 'TELEMETRY', haveTip: true, dependsOn: 'TELEMETRY'});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self._features.sort((a, b) => a.name.localeCompare(b.name, window.navigator.language, { ignorePunctuation: true }));
|
self._features.sort((a, b) => a.name.localeCompare(b.name, window.navigator.language, { ignorePunctuation: true }));
|
||||||
self._featureMask = 0;
|
self._featureMask = 0;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import semver from 'semver';
|
||||||
import vtxDeviceStatusFactory from "../utils/VtxDeviceStatus/VtxDeviceStatusFactory";
|
import vtxDeviceStatusFactory from "../utils/VtxDeviceStatus/VtxDeviceStatusFactory";
|
||||||
import MSP from "../msp";
|
import MSP from "../msp";
|
||||||
import MSPCodes from "./MSPCodes";
|
import MSPCodes from "./MSPCodes";
|
||||||
import { API_VERSION_1_42, API_VERSION_1_43, API_VERSION_1_44, API_VERSION_1_45, API_VERSION_1_46, API_VERSION_1_47 } from '../data_storage';
|
import { API_VERSION_1_42, API_VERSION_1_43, API_VERSION_1_44, API_VERSION_1_45, API_VERSION_1_46 } from '../data_storage';
|
||||||
import EscProtocols from "../utils/EscProtocols";
|
import EscProtocols from "../utils/EscProtocols";
|
||||||
import huffmanDecodeBuf from "../huffman";
|
import huffmanDecodeBuf from "../huffman";
|
||||||
import { defaultHuffmanTree, defaultHuffmanLenIndex } from "../default_huffman_tree";
|
import { defaultHuffmanTree, defaultHuffmanLenIndex } from "../default_huffman_tree";
|
||||||
|
@ -795,7 +795,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
||||||
FC.CONFIG.gitRevision = String.fromCharCode.apply(null, buff);
|
FC.CONFIG.gitRevision = String.fromCharCode.apply(null, buff);
|
||||||
console.log("Fw git rev:", FC.CONFIG.gitRevision);
|
console.log("Fw git rev:", FC.CONFIG.gitRevision);
|
||||||
|
|
||||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47)) {
|
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) {
|
||||||
let option = data.readU16();
|
let option = data.readU16();
|
||||||
while (option) {
|
while (option) {
|
||||||
FC.CONFIG.buildOptions.push(option);
|
FC.CONFIG.buildOptions.push(option);
|
||||||
|
|
|
@ -10,7 +10,7 @@ import MSP from "./msp";
|
||||||
import MSPCodes from "./msp/MSPCodes";
|
import MSPCodes from "./msp/MSPCodes";
|
||||||
import PortUsage from "./port_usage";
|
import PortUsage from "./port_usage";
|
||||||
import PortHandler from "./port_handler";
|
import PortHandler from "./port_handler";
|
||||||
import CONFIGURATOR, { API_VERSION_1_45, API_VERSION_1_46, API_VERSION_1_47 } from "./data_storage";
|
import CONFIGURATOR, { API_VERSION_1_45, API_VERSION_1_46 } from "./data_storage";
|
||||||
import UI_PHONES from "./phones_ui";
|
import UI_PHONES from "./phones_ui";
|
||||||
import { bit_check } from './bit.js';
|
import { bit_check } from './bit.js';
|
||||||
import { sensor_status, have_sensor } from "./sensor_helpers";
|
import { sensor_status, have_sensor } from "./sensor_helpers";
|
||||||
|
@ -353,7 +353,7 @@ function onOpen(openInfo) {
|
||||||
gui_log(i18n.getMessage('buildInfoReceived', [FC.CONFIG.buildInfo]));
|
gui_log(i18n.getMessage('buildInfoReceived', [FC.CONFIG.buildInfo]));
|
||||||
|
|
||||||
// retrieve build options from the flight controller
|
// retrieve build options from the flight controller
|
||||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47)) {
|
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) {
|
||||||
FC.processBuildOptions();
|
FC.processBuildOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,7 +540,7 @@ function checkReportProblems() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function processBuildOptions() {
|
async function processBuildOptions() {
|
||||||
const supported = semver.satisfies(FC.CONFIG.apiVersion, `${API_VERSION_1_45} - ${API_VERSION_1_46}`);
|
const supported = semver.eq(FC.CONFIG.apiVersion, API_VERSION_1_45);
|
||||||
|
|
||||||
// firmware 1_45 or higher is required to support cloud build options
|
// firmware 1_45 or higher is required to support cloud build options
|
||||||
// firmware 1_46 or higher retrieves build options from the flight controller
|
// firmware 1_46 or higher retrieves build options from the flight controller
|
||||||
|
|
|
@ -12,7 +12,7 @@ import FC from '../fc';
|
||||||
import MSP from '../msp';
|
import MSP from '../msp';
|
||||||
import MSPCodes from '../msp/MSPCodes';
|
import MSPCodes from '../msp/MSPCodes';
|
||||||
import PortHandler, { usbDevices } from '../port_handler';
|
import PortHandler, { usbDevices } from '../port_handler';
|
||||||
import { API_VERSION_1_39, API_VERSION_1_45, API_VERSION_1_47 } from '../data_storage';
|
import { API_VERSION_1_39, API_VERSION_1_45, API_VERSION_1_46 } from '../data_storage';
|
||||||
import serial from '../serial';
|
import serial from '../serial';
|
||||||
import STM32DFU from '../protocols/stm32usbdfu';
|
import STM32DFU from '../protocols/stm32usbdfu';
|
||||||
import { gui_log } from '../gui_log';
|
import { gui_log } from '../gui_log';
|
||||||
|
@ -1305,7 +1305,7 @@ firmware_flasher.verifyBoard = function() {
|
||||||
|
|
||||||
function getBoardInfo() {
|
function getBoardInfo() {
|
||||||
MSP.send_message(MSPCodes.MSP_BOARD_INFO, false, false, function() {
|
MSP.send_message(MSPCodes.MSP_BOARD_INFO, false, false, function() {
|
||||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47)) {
|
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) {
|
||||||
FC.processBuildOptions();
|
FC.processBuildOptions();
|
||||||
self.cloudBuildOptions = FC.CONFIG.buildOptions;
|
self.cloudBuildOptions = FC.CONFIG.buildOptions;
|
||||||
}
|
}
|
||||||
|
@ -1320,20 +1320,24 @@ firmware_flasher.verifyBoard = function() {
|
||||||
getBoardInfo();
|
getBoardInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBuildInfo() {
|
async function getBuildInfo() {
|
||||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) && FC.CONFIG.flightControllerIdentifier === 'BTFL') {
|
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) && FC.CONFIG.flightControllerIdentifier === 'BTFL') {
|
||||||
MSP.send_message(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.BUILD_KEY), false, () => {
|
await MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.BUILD_KEY));
|
||||||
MSP.send_message(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.CRAFT_NAME), false, () => {
|
await MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.CRAFT_NAME));
|
||||||
// store FC.CONFIG.buildKey as the object gets destroyed after disconnect
|
await MSP.promise(MSPCodes.MSP_BUILD_INFO);
|
||||||
self.cloudBuildKey = FC.CONFIG.buildKey;
|
|
||||||
|
|
||||||
if (self.validateBuildKey() && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_47)) {
|
// store FC.CONFIG.buildKey as the object gets destroyed after disconnect
|
||||||
self.buildApi.requestBuildOptions(self.cloudBuildKey, getCloudBuildOptions, getBoardInfo);
|
self.cloudBuildKey = FC.CONFIG.buildKey;
|
||||||
} else {
|
|
||||||
getBoardInfo();
|
// 3/21/2024 is the date when the build key was introduced
|
||||||
}
|
const supportedDate = new Date('3/21/2024');
|
||||||
});
|
const buildDate = new Date(FC.CONFIG.buildInfo);
|
||||||
});
|
|
||||||
|
if (self.validateBuildKey() && (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_46) || buildDate < supportedDate)) {
|
||||||
|
self.buildApi.requestBuildOptions(self.cloudBuildKey, getCloudBuildOptions, getBoardInfo);
|
||||||
|
} else {
|
||||||
|
getBoardInfo();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
getBoardInfo();
|
getBoardInfo();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue