-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No Vehicles Found #3
Comments
Unfortunately I do not own any Apple devices for testing but the BLE library I am using is officially supported on |
I'm on 12.5.1 (21G83). I don't have any non Apple devices to try 🫣 Have to see if I can get one. |
Currently I am identifying vehicles by their manufacturer data - it is possible your device reports this differently or your vehicle has diffent manufacturer data. Can you find the BLE address of your vehicle? Try something like this: import simplepyble
adapters = simplepyble.Adapter.get_adapters()
time=5000
if len(adapters) == 0:
print("No adapters found")
elif len(adapters) == 1:
adapter = adapters[0]
else:
# Query the user to pick an adapter
print("Please select an adapter:")
for i, adapter in enumerate(adapters):
print(f"{i}: {adapter.identifier()} [{adapter.address()}]")
choice = int(input("Enter choice: "))
adapter = adapters[choice]
adapter.scan_for(time)
peripherals = adapter.scan_get_results()
for i, peripheral in enumerate(peripherals):
print(f"{i}: {peripheral.identifier()} [{peripheral.address()}]") Your identifier should be an S followed by the first 8 bytes of the SHA1 hash of your vin - something like |
Thanks, this got me this address: Identifier starts with an S, like you said. Do you need that too? Not sure how private I should keep that info... 🤔 |
Awesome - looks like the issue is that your Bluetooth adapter doesn't seem to be returning the manufacturer data like I was expecting. This could be because the Made in Berlin cars have different manufacturer data, or that your MacBook doesn't pick it up. from pyteslable import BLE
from pyteslable import Vehicle
import simplepyble
adapters = simplepyble.Adapter.get_adapters()
tesla_ble = BLE("private_key.pem")
private_key = tesla_ble.getPrivateKey()
time=5000
if len(adapters) == 0:
print("No adapters found")
elif len(adapters) == 1:
adapter = adapters[0]
else:
# Query the user to pick an adapter
print("Please select an adapter:")
for i, adapter in enumerate(adapters):
print(f"{i}: {adapter.identifier()} [{adapter.address()}]")
choice = int(input("Enter choice: "))
adapter = adapters[choice]
adapter.scan_for(time)
peripherals = adapter.scan_get_results()
for i, peripheral in enumerate(peripherals):
print(f"{i}: {peripheral.identifier()} [{peripheral.address()}]")
choice = int(input("Enter choice: "))
peripheral = peripherals[choice]
vehicle = Vehicle(peripheral, private_key)
# now we can connect to the vehicle
if (vehicle != None):
print("Connecting to vehicle...")
vehicle.connect()
# vehicle.debug()
if not vehicle.isConnected():
print("Vehicle failed to connect")
exit()
if not vehicle.isAdded():
print("Tap your keycard on the center console")
vehicle.whitelist()
# Print closure status of all doors when they change
vehicle.onStatusChange(lambda vehic: print(f"\nStatus update: {vehic.status()}\n"))
# Request status
vehicle.vehicle_status()
command = ""
while True:
print("Enter a command, or 'help' for a list of commands. Type 'exit' to quit.")
command = input("Enter command: ")
command = command.upper().replace(' ', '_')
if command == "LOCK":
vehicle.lock()
elif command == "UNLOCK":
vehicle.unlock()
elif command == "OPEN_TRUNK":
vehicle.open_trunk()
elif command == "OPEN_FRUNK":
vehicle.open_frunk()
elif command == "OPEN_CHARGE_PORT":
vehicle.open_charge_port()
elif command == "CLOSE_CHARGE_PORT":
vehicle.close_charge_port()
elif command == "EXIT":
break
elif command == "HELP":
print("\n\n\nCommands available:")
print("\tEXIT: Exit the program")
print("\tHELP: Print this message")
print("\tLOCK: Lock the vehicle")
print("\tUNLOCK: Unlock the vehicle")
print("\tOPEN_TRUNK: Open the vehicle's trunk")
print("\tOPEN_FRUNK: Open the vehicle's front trunk")
print("\tOPEN_CHARGE_PORT: Open and unlock the vehicle's charge port")
print("\tCLOSE_CHARGE_PORT: Close and lock the vehicle's charge port")
print("\n\n")
else:
print("Unknown command")
print("Disconnecting...")
vehicle.disconnect()
print("Vehicle disconnected successfully")
else:
print("Vehicle not found")
exit() I haven't tested the above script, but I think it should work. You just need to select your vehicle manually after the scan happens. |
Also, your identifier is about the same as your VIN in terms of how confidential it is. You can calculate it by doing a simple SHA1 hash of the VIN, and likewise you can find your VIN from it by creating a rainbow table of the probable VIN ranges. So I would not recommend posting the identifier online, but note that anyone can find it by looking at the VIN displayed on your dash or by doing a BLE scan near your vehicle :) |
Thank you for the detailed support, that worked :) Now I am stuck one step further and not sure if that is also related to unexpected characteristics of my car or not: tapping my key card does not work. With debug enabled I get the following output in a loop:
Tapping the card at that time has no effect. I found a similar message in the docs but can't really make sense of it. What message do we expect here? |
Looks like there was a bug introduced in v0.1.3 that prevented the library from being able to receive the shared key from the vehicle. Just fixed it, try: pip install pyteslable==0.1.4 |
That doesn't work unfortunately. I had the same idea and already tried what you did in 0.1.4. But that doesn't help, as I only get
Due to these But the main issue is something different, as I just found out. On every write I get a warning like:
Which I ignored in the beginning. After some investigation, it turns out that there is some specific behavior to BLE on macOS that results in all messages given to So no wonder that nothing worked for me. If I swap |
So I was able to get everything working by swapping the BLE lib with the bleak library. This is a workaround: while using You may close the issue now, thanks for your support. However, I still think it's a bug that |
@Benjoyo Can you share the code that you swapped the BLE lib with the bleak library? I'm having same issue. |
@runasy-koonta Have you tried doing something like this? If you are on macOS you may need to manually select the correct peripheral.
|
Yes, but shows this message. Also, there is an error: My environment: |
Yes, looks like this is the same issue as @Benjoyo had. |
Okay, thanks for support! |
The issue in your first picture happens when your device tries to send a What does your code look like? Are you using the example in the |
I'm using the code in the 'example/Main.py'. |
See https://github.com/kaedenbrinkman/PyTeslaBLE/#cryptography-library-modification |
Thanks |
When I try the example script, I am not able to find my car.
I tried different locations, car locked/unlocked, outside/inside the car.
Any idea what can cause a car not to be found?
2021 MacBook Pro M1 (Bluetooth access granted)
2022 made in Germany Model Y Long Range
2022.15.103
The text was updated successfully, but these errors were encountered: