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

Is there a way to choose a bluetooth adapter? #12

Open
team1401 opened this issue Nov 15, 2024 · 1 comment
Open

Is there a way to choose a bluetooth adapter? #12

team1401 opened this issue Nov 15, 2024 · 1 comment

Comments

@team1401
Copy link

I have a Pi that's polling another device already on Bluetooth. When that process runs, it kills the vevor-ble-bridge instance. Is there a way to choose a specific bluetooth adpater? I've added an external adapter and assigned the other job to use that one, but this still fails when that process kicks off. I'm hoping I can pin each adapter to each process and they'll play nice.

vevor-ble-bridge_1 | 2024-11-15 03:55:02 +0000 [DEBUG] {'running_state': 0, 'error': 0, 'error_msg': 'No fault', 'running_step': 0, 'running_step_msg': 'Standby', 'altitude': 0, 'running_mode': 0, 'set_level': 1, 'set_temperature': None, 'supply_voltage': 0.0, 'case_temperature': 0, 'cab_temperature': 26, 'md': 3}
vevor-ble-bridge_1 | Traceback (most recent call last):
vevor-ble-bridge_1 | File "//./main.py", line 334, in
vevor-ble-bridge_1 | result = vdh.get_status()
vevor-ble-bridge_1 | ^^^^^^^^^^^^^^^^
vevor-ble-bridge_1 | File "/vevor.py", line 170, in get_status
vevor-ble-bridge_1 | return self._send_command(1, 0, 85)
vevor-ble-bridge_1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
vevor-ble-bridge_1 | File "/vevor.py", line 161, in _send_command
vevor-ble-bridge_1 | response = self.characteristic.write(
vevor-ble-bridge_1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
vevor-ble-bridge_1 | File "/usr/local/lib/python3.11/site-packages/bluepy/btle.py", line 200, in write
vevor-ble-bridge_1 | return self.peripheral.writeCharacteristic(self.valHandle, val, withResponse)
vevor-ble-bridge_1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
vevor-ble-bridge_1 | File "/usr/local/lib/python3.11/site-packages/bluepy/btle.py", line 543, in writeCharacteristic
vevor-ble-bridge_1 | return self._getResp('wr')
vevor-ble-bridge_1 | ^^^^^^^^^^^^^^^^^^^
vevor-ble-bridge_1 | File "/usr/local/lib/python3.11/site-packages/bluepy/btle.py", line 407, in _getResp
vevor-ble-bridge_1 | resp = self._waitResp(wantType + ['ntfy', 'ind'], timeout)
vevor-ble-bridge_1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
vevor-ble-bridge_1 | File "/usr/local/lib/python3.11/site-packages/bluepy/btle.py", line 362, in _waitResp
vevor-ble-bridge_1 | raise BTLEDisconnectError("Device disconnected", resp)
vevor-ble-bridge_1 | bluepy.btle.BTLEDisconnectError: Device disconnected

@bderleta
Copy link
Owner

bderleta commented Dec 4, 2024

There is a way, but it would require code modification. bluepy classes accept interface as an argument, in this case, as a third argument to Peripheral constructor, as per http://ianharvey.github.io/bluepy-doc/peripheral.html
So you'd need to modify this line:

self.peripheral = Peripheral(mac_address, "public")

and make it like:
self.peripheral = Peripheral(mac_address, "public", 1) to use secondary adapter. I don't have multiple BT adapters, so I can't test it - it's on you :)

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

2 participants