Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function onStateChange(state) {
if (state === 'poweredOn') {
noble.startScanning([], true);
} else {
noble.stopScanning();
}
}
RED.events.on('runtime-event', (ev) => {
if (TRACE) {
RED.log.info(`[GenericBLE] ${JSON.stringify(ev)}`);
}
if (ev.id === 'runtime-state') {
noble.stopScanning();
bleDevices.flushAll();
startBLEScanning(RED);
}
});
public stopScan(_errorFn?: (errorMsg: string) => void): void {
this.discoverFn = null;
noble.stopScanning();
}
return () => {
noble.removeListener("discover", onDiscover);
noble.stopScanning();
};
});