Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_onConnect () {
const adapter = new ScratchLinkDeviceAdapter(this._scratchLinkSocket, BLEUUID);
godirect.createDevice(adapter, {open: true, startMeasurements: false}).then(device => {
// Setup device
this._device = device;
this._device.keepValues = false; // todo: possibly remove after updating Vernier godirect module
// Enable sensors
this._device.sensors.forEach(sensor => {
sensor.setEnabled(true);
});
// Set sensor value-update behavior
this._device.on('measurements-started', () => {
const enabledSensors = this._device.sensors.filter(s => s.enabled);
enabledSensors.forEach(sensor => {
sensor.on('value-changed', s => {
this._onSensorValueChanged(s);
});