npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@lorenzofratus/anki-overdrive-api

v1.0.3-9

Published

API for Anki Overdrive developer interface

Downloads

18

Readme

Anki Overdrive API

Prerequisites

  • Bluetooth Low Enerty (BLE) Adapter
  • Some modifications to get BLE running in your OS (see noble)

Install

npm install anki-overdrive-api --save

Changelog

Changes in the API are tracked in a Changelog.

Documentation

The current documentation of the API can be found here

Usage

The API implements the current specification of the official Anki Overdrive Drive SDK. The API can be used to find and control vehicles in the BLE network.

Searching vehicles

Use the VehicleScanner class to search for vehicles in the BLE network.

import {Bluetooth, VehicleScanner} from "anki-overdrive-api"

const bluetooth = new Bluetooth()
const scanner = new VehicleScanner(bluetooth)

scanner.findAll().then(vehicles => {
    // Do something with vehicles...
}).catch(/* Handle Errors */)

Vehicles can also be found by using the device address or id.

scanner.findByAddress("42:e2:b6:q7").then(vehicle => {
    // Do something with vehicle...
})

scanner.findById("df6as5fda").then(vehicle => {
    // Do something with vehicle...
})

Controlling Vehicles

After connecting the vehicles they can execute several commands like changing the speed or lane. See the documentation to see all commands.

// First the vehicle has to be connected
vehicle.connect().then(() => {
    
    vehicle.setSpeed(500)
    
    // Vehicles are using offset for positioning.
    vehicle.changeLane(-68.0)
   
})

The vehicles can also send messages if they changes their position. Therefore a listener has to be registered on the vehicle.


vehicle.addListener((message:LocalizationPositionUpdate) => {
    console.log("drove over piece: " + message.roadPieceId)
    console.log("drove over location: " + message.locationId)
    console.log("current speed: " + message.speedMmPerSec)
  
    // Do something else with the message...
})

Testing

The API can be tested with unit tests or end-to-end (e2e) tests. Code coverage is also supported.

Run unit tests

npm t

or with code coverage

npm run test:coverage

Run e2e tests

npm run test:e2e

Note: You need to specify at least one vehicle in the settings.json in test/e2e/resources. The vehicle has to be online and full charged placed on the track.

Developing

Clone the repo and install the dependencies, please follow the instructions from the prerequisites section to avoid problems concerning the BLE adapter.

git clone https://github.com/Aspern/anki-overdrive-api.git
cd anki-overdrive-api
npm i

Licence

MIT