vanbike-lib
vanbike-lib copied to clipboard
[Question] Usage
Hi,
I like the idea. Could you give a bit more detailed info how to run the code? I tried the example in chrome and all the requested configs, but without succes
First you have to get the encryption key from Vanmoof. The WebService is used for this (https://github.com/Poket-Jony/vanbike-lib/blob/main/example/index.html#L33). This only works in the browser if the CORS Policy is deactivated, see https://github.com/Poket-Jony/vanbike-lib#cors-policy (alternatively you can also execute this in NodeJS or manually with e.g. Postman). Now you can enter the encryption key in the example, connect to the bike (over WebBluetooth in Chrome) and unlock it. Note: Currently only the Electrified S / X 1 works perfectly. The S / X 2 or 3 should work partially, but I cannot test it.
hi, i got my encryption key but the bluetooth does not seem to work i get:
Uncaught (in promise) Error: Bluetooth driver not available at _default._callee2$ (BluetoothService.js:33) at tryCatch (runtime.js:63) at Generator.invoke [as _invoke] (runtime.js:293) at Generator.next (runtime.js:118) at asyncGeneratorStep (asyncToGenerator.js:3) at _next (asyncToGenerator.js:25) _callee2$ @ BluetoothService.js:33 tryCatch @ runtime.js:63 invoke @ runtime.js:293 (anonymous) @ runtime.js:118 asyncGeneratorStep @ asyncToGenerator.js:3 _next @ asyncToGenerator.js:25 async function (async) (anonymous) @ (index):46
the WebBluetooth samples from the google site workt though! any tipps?
okay the problem was that SSL HAS to be activated otherwise web bluetooth will not work o_O but now i get a window that chrome searches for the device and cannot find it. its an s3.
Thanks for testing. The S3 has different service IDs and was therefore not displayed. I've already started expanding the S3 profile, but there is still a lot of work to be done. See https://github.com/Poket-Jony/vanbike-lib/commit/eb93d61c2875aea52f985f4557f500aef255b587
ok let me know if you need a s3 to test, i live in berlin and i am a coder as well :)
i tried your change.
- all service ids have to be lowercase it seems, with your change i just get an exception!
- i changed them all to lower case but sill cannot find the bike, where did u get those hex codes from=
The service IDs and characteristics are from the Vanmoof app. I guess that some primary services have to be specified as optional services. The best thing is to simply specify the security service in the "createBluetoothConfigEntity()" method (https://github.com/Poket-Jony/vanbike-lib/commit/eb93d61c2875aea52f985f4557f500aef255b587#diff-c7f977ef208700181a5281c121bad51434fd86db96f26c6a6045e646c40e09aaR69) and see whether it is then displayed. The primary services act as filters for the Bluetooth devices.
ok i read a little bit how things work ( i never did anything with bluetooth before) interestingly using only the SERVICE_SECURITY as filter does not work! but it works if i use just the SERVICE_BIKE_INFO service, then i find the bike. i see a bluetooth connect icon and then i get:
BluetoothService.js:123 Uncaught (in promise) Error: Characteristic "6acc5502-e631-4069-944d-b8ca7598ad50" not found!
this is part of the security service. my conclusion is the security service uuid must be wrong. sounds like CHARACTERISTIC_KEY_INDEX is used for authorization?
ok i found one problem, u try to discover all services and swallow all errors, so i put in some more logging while discovering and id get this:
BluetoothService.js:52 try service 6acc5500-e631-4069-944d-b8ca7598ad50 BluetoothService.js:66 SecurityError: Origin is not allowed to access the service. Tip: Add the service UUID to 'optionalServices' in requestDevice() options. https://goo.gl/HxfxSQ
thats why its does not end up in _servicesAndCharacteristics[]
ok now i defined everything as optional except the bike info service and apparently u have to do this in the beginng even though the method that fetches it later is called "getPrimaryService" o_O
now i get
BluetoothService.js:131 Uncaught (in promise) TypeError: Cannot convert undefined or null to object
at Uint8Array.set (
because the command is undefined in profile
createAuthenticateCommandEntity(passcode) { return (new BluetoothWriteCommandEntity(undefined, passcode))
With the S1, some services also had to be defined as optional. In commit https://github.com/Poket-Jony/vanbike-lib/commit/cf7981fef3aa6e5a677fc50a17b03c85e763e601 I think that the problem with the undefined command should be fixed. If you want, you can create a pull request with your changes in GitHub.
Great project. Very interested. I have S3 and also can help with testing or contributing. Let me know if I can help.
ok i created a pull request, but even with your changes authentication does not seem to work, it does no throw any error but eventually the bikes disconnectes me and i cannot send any commands - btw i also never see a "connected" dot in the bike
hmmm i can see that he reads the challenge key correctly (2 bytes) and sets no command but sets the data and encrypts it, after writing that bike disconnects... any idea what wrong with authentication? i do not have the source code of the offical app ;)
Thanks retroactive, I also got an S3 I merged your pull request in my repository, no errors now, but also no connect. :-(
unfortunately i only fixed the obvious errors, why the connect does not work only poket-joney can answer, or someone finds the source code? im not used to disassemble ios/android apps.
I have it decompiled it's easy with apktool but the Service ID's in it are the same that you use.
I made my email adress visible, write me a note if you want to have a look by your self
are u still looking into it? did u find how to authenticate? you can send me the code or contact me at ********