iRobotEducation / irobot-edu-python-sdk

Python SDK for iRobot Edu robots (Root or Create 3)
BSD 3-Clause "New" or "Revised" License
16 stars 6 forks source link

Device with address MA:CA:DD:RE:SS:12 was not found. It may have been removed from BlueZ when scanning stopped. #23

Closed JEREDEK closed 7 months ago

JEREDEK commented 1 year ago

I cannot start any example, as when i try running any, i get this error.

Connecting to MA-CA-DD-RE-SS-12 (MA:CA:DD:RE:SS:12) Traceback (most recent call last): File "/home/pekabex/lidar.py", line 28, in robot.play() File "/home/pekabex/.local/lib/python3.10/site-packages/irobot_edu_sdk/robot.py", line 282, in play self._loop.run_until_complete(self._main()) File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete return future.result() File "/home/pekabex/.local/lib/python3.10/site-packages/irobot_edu_sdk/robot.py", line 156, in _main await self._backend.connect() File "/home/pekabex/.local/lib/python3.10/site-packages/irobot_edu_sdk/backend/bluetooth_desktop.py", line 58, in connect if await self._client.connect(): File "/home/pekabex/.local/lib/python3.10/site-packages/bleak/init.py", line 471, in connect return await self._backend.connect(**kwargs) File "/home/pekabex/.local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 185, in connect raise BleakDeviceNotFoundError( bleak.exc.BleakDeviceNotFoundError: Device with address MA:CA:DD:RE:SS:12 was not found. It may have been removed from BlueZ when scanning stopped.

shamlian commented 1 year ago

Can you show what you are typing to get this error? It looks like you are specifying an invalid robot MAC address.

shamlian commented 1 year ago

Closing as invalid, please re-open if you can give me more info to reproduce.

DenizAydin99 commented 7 months ago

I'm having the exact same problem on my raspberry pi 3. I'm trying to establish connection using the Bluetooth function of irobot-edu-sdk in my python script (it worked on my macbook and I was able to control the create3 using the keyboard). I ran a ble scan on raspberry pi to check if create3 was dicoverable via Bluetooth and the robot was listed there with the correct MAC address (the same address that I saw on my macbook when I ran the script).

shamlian commented 7 months ago

Could you please give me your BlueZ version? I'm wondering if this is related to #3 or https://bleak.readthedocs.io/en/latest/troubleshooting.html#id4 ; unfortunately in BlueZ prior to 5.62, it was necessary to explicitly remove devices from the GATT cache.

DenizAydin99 commented 7 months ago

My BlueZ version seems to be 5.55

I ran “sudo apt-get upgrade bluez” on raspberry pi and it still prints 5.55 after the update. Would you in this case recommend to remove devices from the GATT cache? As far as I can remember, the Bluetooth connection worked for once on pi. So it probably should be removed manually, since the first try was successful.

shamlian commented 7 months ago

You have two options, I think: either to upgrade BlueZ without the package manager, or to explicitly remove the device from the GATT cache before each run. Neither is great but both are doable. You can confirm that the latter works by typing bluetoothctl remove MA:CA:DD:RE:SS:## (where MA:CA:DD:RE:SS:## is your mac address) and then seeing if the program works. If you want to try updating BlueZ without the package manager, there was a user who I helped to do that here #24 , explicitly in this comment.

DenizAydin99 commented 7 months ago

I tried to remove the mac address manually but got an error like “‘mac address’ - device not available”. Then I uninstalled the blueZ and installed the blueZ 5.66. I’m now able to connect via bluetooth without any issues. Thank you for responding so quick

DenizAydin99 commented 7 months ago

I rebooted the raspberry pi today and I found out that the raspberry pi can no longer find the bluetooth device (it has the receiver installed on it). hciconfig and hcitool commands could not be found and bluetoothctl gets stuck in terminal. In addition to that, systemctl status bluetooth returned the status as inactive (dead).

I tried to uninstall the BlueZ again but package manager could not find the BlueZ and didn’t remove any files since I installed it manually (it couldn’t find the new path I think)

shamlian commented 7 months ago

Sounds like something went wrong with your BlueZ installation from source. You could try

sudo make install
sudo systemctl daemon-reload
sudo systemctl unmask bluetooth.service
sudo systemctl restart bluetooth

from the directory you had previously made BlueZ in, or else you could sudo make uninstall the custom version and then reinstall the package manager version (which is pinned to whatever it was when you started), but then you will have to remove the device from the cache before each time you run the script.

shamlian commented 7 months ago

sorry -- keeping this open in case you have any questions -- but this is not a problem with the library itself, as far as I can tell.

DenizAydin99 commented 7 months ago

Yes, you were right. Everything was fine after manually installing the BlueZ again.

Appreciate your guidance

shamlian commented 7 months ago

Closing invalid, again.