Skip to content
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

Unable to detect my Sphero Bolt; toy not found exception #7

Closed
stevo399 opened this issue Dec 28, 2019 · 11 comments
Closed

Unable to detect my Sphero Bolt; toy not found exception #7

stevo399 opened this issue Dec 28, 2019 · 11 comments
Assignees

Comments

@stevo399
Copy link

I am running PySphero on an Ubuntu 18.04 LTS installation in VMware, on Python 3.6.
When running examples/find_toy.py, I cannot find my sphero bolt; after a second it just gives a toy not found error. I know it's not my hardware as using the Sphero EDU app in windows on the same machine I can connect to it without error. is there something I need to do aside from installing bluepy and pysphero to get it working? Bolt was the one toy this was tested and found to work on I believe.

@EnotYoyo
Copy link
Owner

Can you connect to sphero using mac address? This example.

@EnotYoyo EnotYoyo self-assigned this Dec 28, 2019
@EnotYoyo
Copy link
Owner

Did you enable bluetooth sharing?

@stevo399
Copy link
Author

Bluetooth sharing is enabled on the vm, still same result.
The example tries to connect to a device with the mac address "aa:bb:cc:dd:ee:ff" by default. Was I supposed to change this? I did not, and just tried running the example, and bluepy returned a connection error.
Thanks for your help so far, hoping to get this figured out!

@EnotYoyo
Copy link
Owner

Um... You should execute python with root privilege for using bluepy.
I tried execute example without root and I got PySpheroNotFoundError.
Try to run example with root privilege.

@stevo399
Copy link
Author

sudo python3 examples/find_toy.py
and sudo python3 examples/wake.py
The result is the same.
Do I need to pair the device in any way to my machine before running this code?

@EnotYoyo
Copy link
Owner

Ok.
Let's check the bluepy and bluetooth.
Please, run this code and send output:

from bluepy.btle import Scanner, DefaultDelegate


class ScanDelegate(DefaultDelegate):
    def __init__(self):
        DefaultDelegate.__init__(self)

    def handleDiscovery(self, dev, isNewDev, isNewData):
        if isNewDev:
            print("Discovered device", dev.addr)
        elif isNewData:
            print("Received new data from", dev.addr)


scanner = Scanner().withDelegate(ScanDelegate())
devices = scanner.scan(10.0)

for dev in devices:
    print("Device %s (%s), RSSI=%d dB" % (dev.addr, dev.addrType, dev.rssi))
    for (adtype, desc, value) in dev.getScanData():
        print("  %s = %s" % (desc, value))

This is copy-paste from bluepy docs.

@stevo399
Copy link
Author

Well, I think we may have found the problem.

After running sudo python3 blue_test.py:

Traceback (most recent call last):
File "blue_test.py", line 13, in
devices = scanner.scan(10.0)
File "/home/stevo399/.local/lib/python3.6/site-packages/bluepy/btle.py", line 852, in scan
self.start(passive=passive)
File "/home/stevo399/.local/lib/python3.6/site-packages/bluepy/btle.py", line 790, in start
self._mgmtCmd("le on")
File "/home/stevo399/.local/lib/python3.6/site-packages/bluepy/btle.py", line 312, in _mgmtCmd
raise BTLEManagementError("Failed to execute management command '%s'" % (cmd), rsp)
bluepy.btle.BTLEManagementError: Failed to execute management command 'le on' (code: 12, error: Not Supported)

@EnotYoyo
Copy link
Owner

See this issue. Maybe it help you.

@stevo399
Copy link
Author

stevo399 commented Jan 3, 2020

I think it was a hardware issue more than anything. This package works with the pi3, which I got and tested it on this week. I'm guessing it was an issue with my computer's hardware or the vm.

@stevo399 stevo399 closed this as completed Jan 3, 2020
@gazialankus
Copy link

This should help with this issue: IanHarvey/bluepy#218 (comment)

In my venv, the bluepy-helper executable is here:
sudo setcap 'cap_net_raw,cap_net_admin+eip' venv/lib/python3.7/site-packages/bluepy/bluepy-helper

@zzrs123
Copy link

zzrs123 commented Jun 28, 2022

I am running PySphero on an Ubuntu 20.04 LTS with Python 3.8.10
Maybe I 'm not good at programming on Ubuntu. I don't know how to connect my sphero bolt, because I can't find my device in my bluetooth list(gui on upper right corner).
Maybe I don't know how to start pysphero?
Here is my oprations:

install the vscode
try run code core.py、wake.py, but it doesn't work.
Traceback (most recent call last):
File "/home/zzrs123/Pysphero/pysphero/examples_lmq/wake.py", line 22, in
main()
File "/home/zzrs123/Pysphero/pysphero/examples_lmq/wake.py", line 10, in main
with Sphero(mac_address=mac_address) as sphero:
File "/home/zzrs123/.local/lib/python3.8/site-packages/pysphero/core.py", line 49, in enter
self._ble_adapter = self._ble_adapter_cls(self.mac_address)
File "/home/zzrs123/.local/lib/python3.8/site-packages/pysphero/bluetooth/gatt_adapter.py", line 39, in init
ch_force_band = self._find_characteristic(SpheroCharacteristic.force_band.value)
File "/home/zzrs123/.local/lib/python3.8/site-packages/pysphero/bluetooth/gatt_adapter.py", line 56, in _find_characteristic
raise PySpheroRuntimeError(f"Characteristic {characteristic} not found")
pysphero.exceptions.PySpheroRuntimeError: Characteristic 00020005-574f-4f20-5370-6865726f2121 not found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants