
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
@vernier/godirect
Advanced tools
A JavaScript library to easily interact with [Vernier Go Direct® Sensors](https://www.vernier.com/products/sensors/go-direct-sensors).
A JavaScript library to easily interact with Vernier Go Direct® Sensors.
This library is currently only implemented using WebBluetooth and WebHID both of which have limited browser support
Partial WebHID functionality is available in Chrome 78 behind a flag on desktop OSes. You will need to enable the "Experimental Web Platform Features" flag (chrome://flags/#enable-experimental-web-platform-features) and restart Chrome.
Use the unpkg module version of library in your HTML document:
<script src="https://unpkg.com/@vernier/godirect/dist/godirect.min.umd.js"></script>
Use the library as a JavaScript module:
$ npm i @vernier/godirect
import godirect from './node_modules/@vernier/godirect/dist/godirect.min.esm.js';
A user action is required to open the BLE device list in the browser (e.g. a user click event from a button). Create a button to initiate the request.
<button id="select_device">Select Go Direct Device</button>
Listen for the button click event.
const selectDeviceBtn = document.querySelector('#select_device');
selectDeviceBtn.addEventListener('click', async () => {
// All following code will go here.
});
Open the browsers device list chooser. This call returns your selected device back. We'll assign the selected device to a constant called device
;
NOTE:
you cannot invoke godirect.selectDevice()
outside of a user interaction, like a click event. This is part of the browser security model.
// opens the browser list of ble devices matching to GDX
const device = await godirect.selectDevice();
// Get a filtered array of only the enabled sensor(s).
const enabledSensors = device.sensors.filter(s => s.enabled);
// Loop through the array of `enabledSensors` and log the value changes.
enabledSensors.forEach(sensor => {
sensor.on('value-changed', (sensor) => {
// log the sensor name, new value, and units.
console.log(`Sensor: ${sensor.name} value: ${sensor.value} units: ${sensor.unit}`);
});
});
See this example and others (including our Python versions) at our examples repository: https://github.com/VernierST/godirect-examples or visit the live demos
BSD 3-Clause License.
Vernier products are designed for educational use. Our products are not designed nor are they recommended for any industrial, medical, or commercial process such as life support, patient diagnosis, control of a manufacturing process, or industrial testing of any kind.
FAQs
A JavaScript library to easily interact with [Vernier Go Direct® Sensors](https://www.vernier.com/products/sensors/go-direct-sensors).
We found that @vernier/godirect demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.