mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-16 04:45:18 +03:00
Retrieve and display MSP API Version from new MSP_API_VERSION command.
Requires latest firmware.
This commit is contained in:
parent
f64b558d5c
commit
2733f4832e
4 changed files with 33 additions and 14 deletions
|
@ -85,6 +85,9 @@
|
|||
"firmwareVersion": {
|
||||
"message": "Firmware Version: <strong>$1</strong>"
|
||||
},
|
||||
"apiVersionReceived": {
|
||||
"message": "MultiWii API version <span style=\"color: green\">received</span> - <strong>$1</strong>"
|
||||
},
|
||||
"uniqueDeviceIdReceived": {
|
||||
"message": "Unique device ID <span style=\"color: green\">received</span> - <strong>0x$1</strong>"
|
||||
},
|
||||
|
|
|
@ -10,6 +10,9 @@ var CONFIGURATOR = {
|
|||
};
|
||||
|
||||
var CONFIG = {
|
||||
apiVersion: 0,
|
||||
flightControllerIdentifier: '',
|
||||
flightControllerVersion: '',
|
||||
version: 0,
|
||||
multiType: 0,
|
||||
msp_version: 0,
|
||||
|
|
10
js/msp.js
10
js/msp.js
|
@ -2,6 +2,7 @@
|
|||
|
||||
// MSP_codes needs to be re-integrated inside MSP object
|
||||
var MSP_codes = {
|
||||
MSP_API_VERSION: 1,
|
||||
|
||||
// MSP commands for Cleanflight original features
|
||||
MSP_CHANNEL_FORWARDING: 32,
|
||||
|
@ -169,6 +170,15 @@ MSP.process_data = function(code, message_buffer, message_length) {
|
|||
var data = new DataView(message_buffer, 0); // DataView (allowing us to view arrayBuffer as struct/union)
|
||||
|
||||
switch (code) {
|
||||
case MSP_codes.MSP_API_VERSION:
|
||||
CONFIG.apiVersion = data.getUint8(1) + '.' + data.getUint8(2);
|
||||
var identifier = '';
|
||||
for (i = 0; i < 4; i++) {
|
||||
identifier += String.fromCharCode(data.getUint8(3 + i));
|
||||
}
|
||||
CONFIG.flightControllerIdentifier = identifier;
|
||||
CONFIG.flightControllerVersion = data.getUint8(7) + '.' + data.getUint8(8) + '.' + data.getUint8(9);
|
||||
break;
|
||||
case MSP_codes.MSP_IDENT:
|
||||
CONFIG.version = parseFloat((data.getUint8(0) / 100).toFixed(2));
|
||||
CONFIG.multiType = data.getUint8(1);
|
||||
|
|
|
@ -136,6 +136,8 @@ function onOpen(openInfo) {
|
|||
}, 10000);
|
||||
|
||||
// request configuration data
|
||||
MSP.send_message(MSP_codes.MSP_API_VERSION, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('apiVersionReceived', [CONFIG.apiVersion]));
|
||||
MSP.send_message(MSP_codes.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)]));
|
||||
MSP.send_message(MSP_codes.MSP_IDENT, false, false, function () {
|
||||
|
@ -154,6 +156,7 @@ function onOpen(openInfo) {
|
|||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
$('div#port-picker a.connect').text(chrome.i18n.getMessage('disconnect')).addClass('active');
|
||||
GUI.log('Connection opened in <strong>pass-through</strong> mode');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue