Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
gan-web-bluetooth
Advanced tools
Library for interaction with GAN Smart Timers and GAN Smart Cubes using Web Bluetooth API
This library is designed for easy interaction with GAN Smart Timers and Smart Cubes on the platforms that support Web Bluetooth API.
Nature of the GAN Smart Timer and Smart Cubes is event-driven, so this library is depends on RxJS, and library API provide Observable where you can subscribe for events.
Package gan-web-bluetooth
is available in the npm registry:
$ npm install gan-web-bluetooth
Supported GAN timer devices:
Sample application how to use this library with GAN Smart Timer can be found here:
Sample TypeScript code:
import { connectGanTimer, GanTimerState } from 'gan-web-bluetooth';
var conn = await connectGanTimer();
conn.events$.subscribe((timerEvent) => {
switch (timerEvent.state) {
case GanTimerState.RUNNING:
console.log('Timer is started');
break;
case GanTimerState.STOPPED:
console.log(`Timer is stopped, recorded time = ${timerEvent.recordedTime}`);
break;
default:
console.log(`Timer changed state to ${GanTimerState[timerEvent.state]}`);
}
});
You can read last times stored in the timer memory:
Please note that you should not use
getRecordedTimes()
in polling fashion to get currently displayed time. Timer and its bluetooth protocol does not designed for that.
var recTimes = await conn.getRecordedTimes();
console.log(`Time on display = ${recTimes.displayTime}`);
recTimes.previousTimes.forEach((pt, i) => console.log(`Previous time ${i} = ${pt}`));
State | Description |
---|---|
IDLE | Timer is reset and idle |
HANDS_ON | Hands are placed on the timer |
HANDS_OFF | Hands removed from the timer before grace delay expired |
GET_SET | Grace delay is expired and timer is ready to start |
RUNNING | Timer is running |
STOPPED | Timer is stopped, this event includes recorded time |
FINISHED | Move to this state immediately after STOPPED |
DISCONNECT | Fired when timer is disconnected from bluetooth |
stateDiagram-v2
direction LR
IDLE --> HANDS_ON
HANDS_ON --> HANDS_OFF
HANDS_OFF --> HANDS_ON
HANDS_ON --> GET_SET
GET_SET --> RUNNING
RUNNING --> STOPPED
STOPPED --> FINISHED
FINISHED --> IDLE
Supported Smart Cube devices:
Sample application how to use this library with GAN Smart Cubes can be found here:
Sample TypeScript code:
import { connectGanCube } from 'gan-web-bluetooth';
var conn = await connectGanCube();
conn.events$.subscribe((event) => {
if (event.type == "FACELETS") {
console.log("Cube facelets state", event.facelets);
} else if (event.type == "MOVE") {
console.log("Cube move", event.move);
}
});
await conn.sendCubeCommand({ type: "REQUEST_FACELETS" });
Since internal clock of the most GAN Smart Cubes is not ideally calibrated, they typically introduce
noticeable time skew with host device clock. Best practice here is to record timestamps of move events
during solve using both clocks - host device and cube. Then apply linear regression algorithm
to fit cube timestamp values and get fairly measured elapsed time. This approach is invented
and firstly implemented by Chen Shuang in the csTimer. This library also contains cubeTimestampLinearFit()
function to accomplish such procedure. You can look into the mentioned sample application code for details,
and this Jupyter notebook for visualisation
of such approach.
FAQs
Library for interaction with GAN Smart Timers and GAN Smart Cubes using Web Bluetooth API
The npm package gan-web-bluetooth receives a total of 22 weekly downloads. As such, gan-web-bluetooth popularity was classified as not popular.
We found that gan-web-bluetooth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.