mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-24 16:55:22 +03:00
Fix connection to flight controller
Also, refactor the code for invalid firmware variant/version a bit, removing code used for versions older than 1.6.0.
This commit is contained in:
parent
a9dfd90f1e
commit
3b5660bdcc
1 changed files with 56 additions and 57 deletions
|
@ -207,6 +207,51 @@ $(document).ready(function () {
|
||||||
PortHandler.initialize();
|
PortHandler.initialize();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function onValidFirmware()
|
||||||
|
{
|
||||||
|
MSP.send_message(MSPCodes.MSP_BUILD_INFO, false, false, function () {
|
||||||
|
|
||||||
|
googleAnalytics.sendEvent('Firmware', 'Using', CONFIG.buildInfo);
|
||||||
|
GUI.log(chrome.i18n.getMessage('buildInfoReceived', [CONFIG.buildInfo]));
|
||||||
|
|
||||||
|
MSP.send_message(MSPCodes.MSP_BOARD_INFO, false, false, function () {
|
||||||
|
|
||||||
|
googleAnalytics.sendEvent('Board', 'Using', CONFIG.boardIdentifier + ',' + CONFIG.boardVersion);
|
||||||
|
GUI.log(chrome.i18n.getMessage('boardInfoReceived', [CONFIG.boardIdentifier, CONFIG.boardVersion]));
|
||||||
|
|
||||||
|
MSP.send_message(MSPCodes.MSP_UID, false, false, function () {
|
||||||
|
|
||||||
|
GUI.log(chrome.i18n.getMessage('uniqueDeviceIdReceived', [CONFIG.uid[0].toString(16) + CONFIG.uid[1].toString(16) + CONFIG.uid[2].toString(16)]));
|
||||||
|
|
||||||
|
// continue as usually
|
||||||
|
CONFIGURATOR.connectionValid = true;
|
||||||
|
GUI.allowedTabs = GUI.defaultAllowedTabsWhenConnected.slice();
|
||||||
|
onConnect();
|
||||||
|
|
||||||
|
$('#tabs ul.mode-connected .tab_setup a').click();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function onInvalidFirmwareVariant()
|
||||||
|
{
|
||||||
|
GUI.log(chrome.i18n.getMessage('firmwareVariantNotSupported'));
|
||||||
|
CONFIGURATOR.connectionValid = true; // making it possible to open the CLI tab
|
||||||
|
GUI.allowedTabs = ['cli'];
|
||||||
|
onConnect();
|
||||||
|
$('#tabs .tab_cli a').click();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onInvalidFirmwareVersion()
|
||||||
|
{
|
||||||
|
GUI.log(chrome.i18n.getMessage('firmwareVersionNotSupported', [CONFIGURATOR.firmwareVersionAccepted]));
|
||||||
|
CONFIGURATOR.connectionValid = true; // making it possible to open the CLI tab
|
||||||
|
GUI.allowedTabs = ['cli'];
|
||||||
|
onConnect();
|
||||||
|
$('#tabs .tab_cli a').click();
|
||||||
|
}
|
||||||
|
|
||||||
function onOpen(openInfo) {
|
function onOpen(openInfo) {
|
||||||
if (openInfo) {
|
if (openInfo) {
|
||||||
// update connected_to
|
// update connected_to
|
||||||
|
@ -255,69 +300,23 @@ function onOpen(openInfo) {
|
||||||
}
|
}
|
||||||
GUI.log(chrome.i18n.getMessage('apiVersionReceived', [CONFIG.apiVersion]));
|
GUI.log(chrome.i18n.getMessage('apiVersionReceived', [CONFIG.apiVersion]));
|
||||||
|
|
||||||
if (semver.gte(CONFIG.flightControllerVersion, CONFIGURATOR.firmwareVersionAccepted)) {
|
MSP.send_message(MSPCodes.MSP_FC_VARIANT, false, false, function () {
|
||||||
|
|
||||||
MSP.send_message(MSPCodes.MSP_FC_VARIANT, false, false, function () {
|
googleAnalytics.sendEvent('Firmware', 'Variant', CONFIG.flightControllerIdentifier + ',' + CONFIG.flightControllerVersion);
|
||||||
|
GUI.log(chrome.i18n.getMessage('fcInfoReceived', [CONFIG.flightControllerIdentifier, CONFIG.flightControllerVersion]));
|
||||||
|
|
||||||
|
if (CONFIG.flightControllerIdentifier == 'INAV') {
|
||||||
MSP.send_message(MSPCodes.MSP_FC_VERSION, false, false, function () {
|
MSP.send_message(MSPCodes.MSP_FC_VERSION, false, false, function () {
|
||||||
|
if (semver.gte(CONFIG.flightControllerVersion, CONFIGURATOR.firmwareVersionAccepted)) {
|
||||||
googleAnalytics.sendEvent('Firmware', 'Variant', CONFIG.flightControllerIdentifier + ',' + CONFIG.flightControllerVersion);
|
onValidFirmware();
|
||||||
GUI.log(chrome.i18n.getMessage('fcInfoReceived', [CONFIG.flightControllerIdentifier, CONFIG.flightControllerVersion]));
|
|
||||||
|
|
||||||
if (CONFIG.flightControllerIdentifier == 'INAV') {
|
|
||||||
|
|
||||||
MSP.send_message(MSPCodes.MSP_BUILD_INFO, false, false, function () {
|
|
||||||
|
|
||||||
googleAnalytics.sendEvent('Firmware', 'Using', CONFIG.buildInfo);
|
|
||||||
GUI.log(chrome.i18n.getMessage('buildInfoReceived', [CONFIG.buildInfo]));
|
|
||||||
|
|
||||||
MSP.send_message(MSPCodes.MSP_BOARD_INFO, false, false, function () {
|
|
||||||
|
|
||||||
googleAnalytics.sendEvent('Board', 'Using', CONFIG.boardIdentifier + ',' + CONFIG.boardVersion);
|
|
||||||
GUI.log(chrome.i18n.getMessage('boardInfoReceived', [CONFIG.boardIdentifier, CONFIG.boardVersion]));
|
|
||||||
|
|
||||||
MSP.send_message(MSPCodes.MSP_UID, false, false, function () {
|
|
||||||
GUI.log(chrome.i18n.getMessage('uniqueDeviceIdReceived', [CONFIG.uid[0].toString(16) + CONFIG.uid[1].toString(16) + CONFIG.uid[2].toString(16)]));
|
|
||||||
|
|
||||||
// continue as usually
|
|
||||||
CONFIGURATOR.connectionValid = true;
|
|
||||||
GUI.allowedTabs = GUI.defaultAllowedTabsWhenConnected.slice();
|
|
||||||
//TODO here we can remove led_strip tab from NAZE and CC3D at least!
|
|
||||||
|
|
||||||
if (semver.lt(CONFIG.flightControllerVersion, "1.5.0")) {
|
|
||||||
GUI.allowedTabs.splice(GUI.allowedTabs.indexOf('osd'), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Remove Presets on older than 1.6
|
|
||||||
*/
|
|
||||||
if (semver.lt(CONFIG.flightControllerVersion, "1.6.0")) {
|
|
||||||
GUI.allowedTabs.splice(GUI.allowedTabs.indexOf('profiles'), 1);
|
|
||||||
GUI.allowedTabs.splice(GUI.allowedTabs.indexOf('advanced_tuning'), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
onConnect();
|
|
||||||
|
|
||||||
$('#tabs ul.mode-connected .tab_setup a').click();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
GUI.log(chrome.i18n.getMessage('firmwareVariantNotSupported'));
|
onInvalidFirmwareVersion();
|
||||||
CONFIGURATOR.connectionValid = true; // making it possible to open the CLI tab
|
|
||||||
GUI.allowedTabs = ['cli'];
|
|
||||||
onConnect();
|
|
||||||
$('#tabs .tab_cli a').click();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
} else {
|
||||||
} else {
|
onInvalidFirmwareVariant();
|
||||||
GUI.log(chrome.i18n.getMessage('firmwareVersionNotSupported', [CONFIGURATOR.firmwareVersionAccepted]));
|
}
|
||||||
CONFIGURATOR.connectionValid = true; // making it possible to open the CLI tab
|
});
|
||||||
GUI.allowedTabs = ['cli'];
|
|
||||||
onConnect();
|
|
||||||
$('#tabs .tab_cli a').click();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log('Failed to open serial port');
|
console.log('Failed to open serial port');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue