Comments (4)
@bedenko any idea for a quick solution to this?
from adafruit_python_bluefruitle.
Well, at least for linux part, this part is hard-coded, so "Adapter1" and "Device1" are static.
Quick fix: change the value Adapter1 to Adapter2
Permanent fix: change the code, to be able to switch between adapters.
P.S.: this line also returns following error:
AttributeError: 'NoneType' object has no attribute 'GetManagedObjects'
from adafruit_python_bluefruitle.
You can use adapters = ble.list_adapters()
, then choose the adapter you want from the list using indexing adapter = adapters[-1]
.
But on a related issue, I wasn't sure that the adapters would always be enumerated in the right order, so I added adapter selection using the MAC of the Bluetooth dongle, as follows.
Add the following patch to the library, which gives you easy access to the BLE adapter address:
diff --git a/Adafruit_BluefruitLE/bluez_dbus/adapter.py b/Adafruit_BluefruitLE/bluez_dbus/adapter.py
index 0d262d2..811c0bc 100644
--- a/Adafruit_BluefruitLE/bluez_dbus/adapter.py
+++ b/Adafruit_BluefruitLE/bluez_dbus/adapter.py
@@ -62,7 +62,13 @@ class BluezAdapter(Adapter):
def name(self):
"""Return the name of this BLE network adapter."""
return self._props.Get(_INTERFACE, 'Name')
-
+
+ @property
+ def address(self):
+ """Return the address of this BLE network adapter."""
+ return self._props.Get(_INTERFACE, 'Address')
+
+
def start_scan(self, timeout_sec=TIMEOUT_SEC):
"""Start scanning for BLE devices with this adapter."""
self._scan_started.clear()
Then in my initialisation code, I have:
adapters = ble.list_adapters()
adapter = None
if len(adapters) == 1:
print("Single Bluetooth adapter found (no MAC filtering).")
adapter = adapters[0]
if len(adapters) > 1:
filtered_adapters = [a for a in adapters if a.address == BLUETOOTH_ADAPTER_MAC]
if len(filtered_adapters) > 0:
print("Multiple Bluetooth adapters found: filtered by MAC.")
adapter = filtered_adapters[0]
else:
print("Multiple Bluetooth adapters found: MAC filtering failed, using last enumerated adapter.")
adapter = adapters[-1]
elif len(adapters) == 0:
print("No Bluetooth adapter found.")
return
from adafruit_python_bluefruitle.
This library has been deprecated. Please update to use this new library:
https://github.com/adafruit/Adafruit_Blinka_bleio
If you continue to have this issue, please open a new issue in that repo.
from adafruit_python_bluefruitle.
Related Issues (20)
- Incompatibility with BlueZ version >= 5.38 HOT 9
- AttributeError: 'NoneType' object has no attribute 'power_on' HOT 1
- org.freedesktop.DBus.Error.LimitsExceeded: Connection ":1.26" is not allowed to add more match rules HOT 11
- OC_PythonException/NSException on example script HOT 8
- Occurrd Error with connected USB Serial device HOT 5
- Add support for pip HOT 3
- Get service data from advertising data on Mac OSX. HOT 1
- ble.find_device name argument on Linux HOT 3
- dbus.exceptions.DBusException No such property 'Characteristics' HOT 2
- no module named 'dbus' HOT 1
- This code doesn't find uart service for Bluefruit
- Exceptions are platform specific HOT 1
- Download error when installed on Mac OS 10.11 HOT 1
- Cannot run this with Python 3.7 HOT 2
- Issues in macOS 10.15 Catalina HOT 4
- How to run bluetooth in event loop? HOT 1
- UART.find_devices() returns empty list HOT 1
- trouble running examples on mac OS HOT 1
- device.rssi gives error: No such property 'RSSI' HOT 1
- General question, what thread is CoreBluetooth running on? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adafruit_python_bluefruitle.