From eff295292b454e03b8f4e41e1bfba9b8f27288ff Mon Sep 17 00:00:00 2001 From: mikeller Date: Tue, 16 May 2017 23:48:31 +1200 Subject: [PATCH] Added loading of craft name on startup. --- _locales/en/messages.json | 7 +++++-- js/serial_backend.js | 29 ++++++++++++++++++++--------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 9049c409..478f5e49 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -190,10 +190,13 @@ "message": "Firmware Version: $1" }, "apiVersionReceived": { - "message": "MultiWii API version received - $1" + "message": "MultiWii API version: $1" }, "uniqueDeviceIdReceived": { - "message": "Unique device ID received - 0x$1" + "message": "Unique device ID: 0x$1" + }, + "craftNameReceived": { + "message": "Craft name: $1" }, "boardInfoReceived": { "message": "Board: $1, version: $2" diff --git a/js/serial_backend.js b/js/serial_backend.js index 7f1337b2..ce93ecfe 100755 --- a/js/serial_backend.js +++ b/js/serial_backend.js @@ -208,16 +208,15 @@ function onOpen(openInfo) { 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.defaultAllowedFCTabsWhenConnected.slice(); - if (semver.lt(CONFIG.apiVersion, "1.4.0")) { - GUI.allowedTabs.splice(GUI.allowedTabs.indexOf('led_strip'), 1); + if (semver.gte(CONFIG.apiVersion, "1.20.0")) { + MSP.send_message(MSPCodes.MSP_NAME, false, false, function () { + GUI.log(chrome.i18n.getMessage('craftNameReceived', [CONFIG.name])); + + finishOpen(); + }); + } else { + finishOpen(); } - - onConnect(); - - $('#tabs ul.mode-connected .tab_setup a').click(); }); }); }); @@ -251,6 +250,18 @@ function onOpen(openInfo) { } } +function finishOpen() { + CONFIGURATOR.connectionValid = true; + GUI.allowedTabs = GUI.defaultAllowedFCTabsWhenConnected.slice(); + if (semver.lt(CONFIG.apiVersion, "1.4.0")) { + GUI.allowedTabs.splice(GUI.allowedTabs.indexOf('led_strip'), 1); + } + + onConnect(); + + $('#tabs ul.mode-connected .tab_setup a').click(); +} + function connectCli() { CONFIGURATOR.connectionValid = true; // making it possible to open the CLI tab GUI.allowedTabs = ['cli'];