I have a BLE beacon that makes the app crash with the following exception:
/usr/local/bin/lights.js/src/DeviceFactory.js:36
var DeviceImpl = supportedImplementations[0].default;
^
TypeError: Cannot read property 'default' of undefined
at createDevice (/usr/local/bin/lights.js/src/DeviceFactory.js:15:20)
at Noble.<anonymous> (/usr/local/bin/lights.js/src/application.js:36:16)
at emitOne (events.js:96:13)
at Noble.emit (events.js:188:7)
at Noble.onDiscover (/usr/local/bin/lights.js/node_modules/noble/lib/noble.js:135:10)
at emitMany (events.js:127:13)
at NobleBindings.emit (events.js:201:7)
at NobleBindings.onDiscover (/usr/local/bin/lights.js/node_modules/noble/lib/hci-socket/bindings.js:169:10)
at emitMany (events.js:127:13)
at Gap.emit (events.js:201:7)
I fixed it by adding the following if statement in src/DeviceFactory.js
let supportedImplementations = implementations.filter((item) => item.default.isSupported(peripheral));
if(supportedImplementations.length == 0){
return null;
}
let DeviceImpl = supportedImplementations[0].default;
return new DeviceImpl(peripheral);
Hello,
I have a BLE beacon that makes the app crash with the following exception:
I fixed it by adding the following if statement in src/DeviceFactory.js