VanBike-Library
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 (profile missing)
- 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 poket-jony/vanbike-lib # NPM npm i poket-jony/vanbike-lib
Build
# Development yarn dev # Production yarn prod
ES6
;const bikeProfile = ;const vanBikeService = bikeProfile 'ENCRYPTION-KEY';
Browser
const bikeProfile = ;const vanBikeService = bikeProfile 'ENCRYPTION-KEY';const ModuleStateEntity = VanBikeLibModuleStateEntity;const LockStateEntity = VanBikeLibLockStateEntity;
Example
For more examples see example
folder.
// Event listenervanBikeService; // Connectawait vanBikeService; // Authenticateawait vanBikeService; // Turn onconst moduleState = ;moduleState;await vanBikeService; // Unlockconst lockState = ;lockState;await vanBikeService; // DisconnectvanBikeService;
Documentation
VanBikeService
constructor(encryptionKey : string) : void
getBluetoothService() : BluetoothService
connect() : Promise
disconnect() : void
isConnected() : bool
subscribe(callback : function) : Number
unsubscribe(handleIndex) : void
authenticate() : Promise
setModuleState(ModuleStateEntity moduleState) : Promise
setLockState(LockStateEntity lockState) : Promise
setLightningState(LightningStateEntity lightningState) : Promise
setPowerLevelState(PowerStateEntity powerState, RegionStateEntity regionState) : Promise
setUnitState(UnitStateEntity unitState) : Promise
showFirmware() : Promise
resetDistance() : Promise
pairRemote() : Promise
enableErrors() : Promise
disableErrors() : Promise
setOffroadMode() : Promise
Todo:
startFirmwareUpdate(FirmwareEntity firmware) : Promise
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