-
Notifications
You must be signed in to change notification settings - Fork 107
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
ble.NewConnection sometimes never returns #272
Comments
Could you please include the output of running the command with |
I had the same or at least a very similar problem. As long as the vehicle is nearby the command tesla-control works well, even if repeated thousands of times over a longer time period. With the new code from a few weeks ago the BLE connection is very stable on my system. But when the vehicle is driven away, I got the same error A temporary workaround was to restart the bluetooth service (systemctl restart bluetooth), however this does not last long. Reason for the problem might be a missing 'close' for the underlying socket (socket is created by code from "github.com/go-ble/ble", in ble/linux/hci/socket/socket.go starting lin line 63). I'm neither an expert with Go nor the go-ble package, so I haven't prepared a pull request, but was able to add a few lines of code (see attachment) that look to fix the problem for me. Please add that fix (or a better one) . |
Modified code that includes patch to prevent some errors with BLE interface. See teslamotors/vehicle-command#272 (comment)
I think my issue is different. @sethterashima here are the logs: I'am using a custom Go-App (https://github.com/wimaha/TeslaBleHttpProxy) with this library. So here is a mix of logs from my program and this library. The relevant part starts at 15:34:58. I'm posting some additional log lines to provide context. In the relevant part I added to corresponding function calls to the logs from my program.
So the last message from this library is Edit: Running on Raspberry Pi 3+ |
I think I found the issue. It is in the underlaying bluetooth package. In the ble.go we have the following code: There the ble package is called via In the ble package we have the following code in the Connect function (glatt.go): So and here is a bug. When the vehicle can't be found, normally ctx2 fires bevor ctx, so that the function So we need to propose a pull request on the ble package to solve this bug. |
I've opened a PR on the ble package: go-ble/ble#112 |
@wimaha: I still have the issue described above when the vehicle can't be found with latest code from 'tesla-control' on a Raspberry PI 3B+. After a while the hci0 interface is busy and requires a reset. So far I ended up by switching to BLE package from https://github.com/rigado/ble instead of go-ble/ble. The code for BLE has changed a lot and required minor changes in pkg/connector/ble, but now my issue is gone. To me the ble package from rigado looks to be better, but I'm wondering if that code will end up in go-ble some time in the future. |
It turned out that the rigado/ble package has the same issue and that your fix solves 'my' problem. I've opened a PR on that package rigado/ble#76 I'm using the 'tesla-control' utility to track if my car is at home or away via BLE. The problem is easy to reproduce by using the 'tesla-control' utility with a non-existing VIN, e.g. |
I've looked in vain for a well-maintained Golang BLE library. If anyone knows of one, please feel free to put up a PR to migrate or create an Issue asking someone else to. |
Hello,
when there are connection issues the function
ble.NewConnection(ctx, vin)
returns withcontext deadline exceeded
. That's the expected behavior.But after a while (> 15 attempts) the function just never returns.
Any clue what could cause this issue?
The problem also occurs with this #269
The text was updated successfully, but these errors were encountered: