noble-winrt
noble-winrt copied to clipboard
Improve error handling
Currently we only log error in the noble-winrt package as noble has a rather bad error handling story (https://github.com/noble/noble/issues/830). The problem is that it only emits a warning if e.g. a peripheral is not found and there is no way for bindings to return an error.
A proper solution would be to add a error argument in the bindings interface and the noble interface to let bindings error bubble up to the user.
Noble.prototype.onDisconnect = function(peripheralUuid, error) {
var peripheral = this._peripherals[peripheralUuid];
if (peripheral) {
peripheral.emit('disconnect', error);
} else {
this.emit('warning', 'unknown peripheral ' + peripheralUuid + ' disconnected!');
}
};