Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

[Question] Usage #2

Open
djfanatix opened this issue Nov 11, 2020 · 18 comments
Open

[Question] Usage #2

djfanatix opened this issue Nov 11, 2020 · 18 comments
Labels
question Further information is requested

Comments

@djfanatix
Copy link

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

@Poket-Jony Poket-Jony changed the title Readme [Question] Usage Nov 12, 2020
@Poket-Jony Poket-Jony added the question Further information is requested label Nov 12, 2020
@Poket-Jony
Copy link
Owner

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.

@retroactive
Copy link
Contributor

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?

@retroactive
Copy link
Contributor

retroactive commented Nov 14, 2020

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.

@Poket-Jony
Copy link
Owner

Poket-Jony commented Nov 14, 2020

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 eb93d61

@retroactive
Copy link
Contributor

ok let me know if you need a s3 to test, i live in berlin and i am a coder as well :)

@retroactive
Copy link
Contributor

i tried your change.

  1. all service ids have to be lowercase it seems, with your change i just get an exception!
  2. i changed them all to lower case but sill cannot find the bike, where did u get those hex codes from=

@Poket-Jony
Copy link
Owner

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 (eb93d61#diff-c7f977ef208700181a5281c121bad51434fd86db96f26c6a6045e646c40e09aaR69) and see whether it is then displayed. The primary services act as filters for the Bluetooth devices.

@retroactive
Copy link
Contributor

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?

@retroactive
Copy link
Contributor

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[]

@retroactive
Copy link
Contributor

retroactive commented Nov 15, 2020

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 ()
at _default._callee6$ (BluetoothService.js:131)

because the command is undefined in profile

createAuthenticateCommandEntity(passcode) {
return (new BluetoothWriteCommandEntity(undefined, passcode))

@Poket-Jony
Copy link
Owner

With the S1, some services also had to be defined as optional. In commit cf7981f 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.

@DmitriyNoa
Copy link

Great project. Very interested. I have S3 and also can help with testing or contributing. Let me know if I can help.

@retroactive
Copy link
Contributor

retroactive commented Nov 29, 2020

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 ;)

@TFreudi1
Copy link

Thanks retroactive, I also got an S3 I merged your pull request in my repository, no errors now, but also no connect. :-(

@retroactive
Copy link
Contributor

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.

@TFreudi1
Copy link

I have it decompiled it's easy with apktool but the Service ID's in it are the same that you use.

@TFreudi1
Copy link

I made my email adress visible, write me a note if you want to have a look by your self

@retroactive
Copy link
Contributor

retroactive commented Jan 13, 2021

are u still looking into it? did u find how to authenticate? you can send me the code or contact me at ********

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants