1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-16 12:55:14 +03:00

add a helper method to make msp calls via a promise

This commit is contained in:
nathan 2016-06-24 02:06:34 -07:00
parent 8ffcb25375
commit 30c191b2a8

View file

@ -1139,6 +1139,17 @@ var MSP = {
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 () {
for (var i = 0; i < this.callbacks.length; i++) {
clearInterval(this.callbacks[i].timer);