Giter Club home page Giter Club logo

vanbike-lib's Introduction

VanBike-Library

Latest Release GitHub stars Downloads Open Issues Closed Issues

Allows direct access to VanMoof Bikes Bluetooth-API in Javascript using the Web-Bluetooth-API.

Features

  • Retrieve Parameters (Battery, Distance, Settings, ...)
  • Retrieve Firmware/Hardware/Software/Model/Serial Number
  • Start Bike-Module
  • Unlock Bike
  • Set Region Settings
  • Set Lightning Settings
  • Set Power Level
  • Set Units
  • Show Firmware
  • Reset Distance
  • Pair Remote
  • Error Logging
  • Set Offroad Mode
  • Update Firmware (not implemented)
  • ...

Compatibility

Bikes

  • Electrified S/X 1 (2016/2017) - tested
  • Smart S/X 1 (2018) - unsupported (work in progress)
  • Electrified S/X 2 - untested (some parameters/functions missing)
  • Electrified S/X 3 - untested (some parameters/functions missing)

Browsers

See full list.

Desktop
  • Chrome
    • Mac: >56
    • Linux: >56
    • Windows: >70
  • Edge: >79
  • Firefox: unsupported
  • Internet Explorer: unsupported
  • Opera
    • Mac: >43
    • Linux: >43
    • Windows: >57
  • Safari: unsupported
Mobile
  • Android webview: unsupported
  • Chrome for Android: >56
  • Firefox for Android: unsupported
  • Internet Explorer: unsupported
  • Opera for Android: >43
  • Safari on iOS: unsupported
  • Samsung Internet: >6.0

Usage

Install

Download pre build file from GitHub-Releases or add via NPM.

# Yarn
yarn add vanbike-lib

# NPM
npm i vanbike-lib

Build

# Development
yarn dev

# Production
yarn prod

ES6

import { VanBikeService, ElectrifiedSX1Profile, ModuleStateEntity, LockStateEntity } from 'vanbike-lib';
const bikeProfile = new ElectrifiedSX1Profile();
const vanBikeService = new VanBikeService(bikeProfile, 'ENCRYPTION-KEY');

Browser

<script type="text/javascript" src="/dist/vanbike-lib.js"></script>
const bikeProfile = new VanBikeLib.ElectrifiedSX1Profile();
const vanBikeService = new VanBikeLib.VanBikeService(bikeProfile, 'ENCRYPTION-KEY');
const ModuleStateEntity = VanBikeLib.ModuleStateEntity;
const LockStateEntity = VanBikeLib.LockStateEntity;

Example

For more examples see example folder.

// Event listener
vanBikeService.subscribe((parameters) => {
    console.log(parameters);
});

// Connect
await vanBikeService.connect();

// Authenticate
await vanBikeService.authenticate();

// Turn on
const moduleState = new ModuleStateEntity();
moduleState.setState(moduleState.STATE_ON);
await vanBikeService.setModuleState(moduleState);

// Unlock
const lockState = new LockStateEntity();
lockState.setState(lockState.STATE_UNLOCKED);
await vanBikeService.setLockState(lockState);

// Disconnect
vanBikeService.disconnect();

Documentation

VanBikeService

  • constructor(encryptionKey : string) : void
  • async connect() : Promise
  • disconnect() : void
  • isConnected() : bool
  • subscribe(function callback) : Number
  • unsubscribe(handleIndex) : void
  • async authenticate() : Promise
  • async getParameters() : ParametersEntity
  • async getFirmwareRevision() : string
  • async getHardwareRevision() : string
  • async getSoftwareRevision() : string
  • async getModelNumber() : string
  • async getSerialNumber() : string
  • async setModuleState(ModuleStateEntity moduleState) : Promise
  • async setLockState(LockStateEntity lockState) : Promise
  • async setLightningState(LightningStateEntity lightningState) : Promise
  • async setPowerLevelState(PowerStateEntity powerState, RegionStateEntity regionState) : Promise
  • async setUnitState(UnitStateEntity unitState) : Promise
  • async showFirmware() : Promise
  • async resetDistance() : Promise
  • async pairRemote() : Promise
  • async enableErrors() : Promise
  • async disableErrors() : Promise
  • async setOffroadMode() : Promise

Todo:

  • async startFirmwareUpdate(FirmwareEntity firmware) : Promise
  • async stopFirmwareUpdate() : Promise

Notice

This project is not related to VanMoof. The guarantee expires with use.

CORS Policy

The WebService calls the VanMoof API directly. This is probably not possible in Browsers because of CORS-Policy. Use a workaround with the Chrome-Plugin: Allow CORS: Access-Control-Allow-Origin. Or use this service from NodeJS.

License

MIT

vanbike-lib's People

Contributors

poket-jony avatar

Stargazers

 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.