mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-16 21:05:30 +03:00
add a helper method to make msp calls via a promise
This commit is contained in:
parent
8ffcb25375
commit
30c191b2a8
1 changed files with 11 additions and 0 deletions
11
js/msp.js
11
js/msp.js
|
@ -1139,6 +1139,17 @@ var MSP = {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* resolves: {command: code, data: data, length: message_length}
|
||||||
|
*/
|
||||||
|
promise: function(code, data) {
|
||||||
|
var self = this;
|
||||||
|
return new Promise(function(resolve) {
|
||||||
|
self.send_message(code, data, false, function(data) {
|
||||||
|
resolve(data);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
callbacks_cleanup: function () {
|
callbacks_cleanup: function () {
|
||||||
for (var i = 0; i < this.callbacks.length; i++) {
|
for (var i = 0; i < this.callbacks.length; i++) {
|
||||||
clearInterval(this.callbacks[i].timer);
|
clearInterval(this.callbacks[i].timer);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue