Fix paho-mqtt v2.x compatibility
Handle both paho-mqtt v1.x and v2.x in MQTTPublisher: - Try v2.x format with callback_api_version first - Fall back to v1.x format if needed - Ensures compatibility across different paho-mqtt versions Fixes: ValueError when using paho-mqtt 2.0+
This commit is contained in:
@@ -34,7 +34,7 @@ source .venv/bin/activate
|
||||
### 4. Install Python Dependencies
|
||||
```bash
|
||||
pip install --upgrade pip
|
||||
pip install bluepy paho-mqtt
|
||||
pip install pybluez bluepy paho-mqtt
|
||||
|
||||
# Or install the package in development mode
|
||||
pip install -e .
|
||||
@@ -43,8 +43,12 @@ pip install -e .
|
||||
### 5. Set Bluetooth Capabilities
|
||||
This allows Python to access Bluetooth without sudo:
|
||||
```bash
|
||||
# Set capabilities on the Python interpreter in the venv
|
||||
sudo setcap 'cap_net_raw,cap_net_admin+eip' .venv/bin/python3
|
||||
# Set capabilities on the actual Python binary (not the symlink)
|
||||
sudo setcap 'cap_net_raw,cap_net_admin+eip' $(readlink -f .venv/bin/python3)
|
||||
|
||||
# Verify it was set correctly
|
||||
getcap $(readlink -f .venv/bin/python3)
|
||||
# Should show: cap_net_raw,cap_net_admin+eip
|
||||
```
|
||||
|
||||
### 6. Configure the Application
|
||||
@@ -88,13 +92,13 @@ Press Ctrl+C to stop.
|
||||
If you get permission errors:
|
||||
```bash
|
||||
# Check if capabilities are set
|
||||
getcap .venv/bin/python3
|
||||
getcap $(readlink -f .venv/bin/python3)
|
||||
|
||||
# If not set, run:
|
||||
sudo setcap 'cap_net_raw,cap_net_admin+eip' .venv/bin/python3
|
||||
sudo setcap 'cap_net_raw,cap_net_admin+eip' $(readlink -f .venv/bin/python3)
|
||||
|
||||
# Verify Bluetooth device is up
|
||||
hciconfig hci0 up
|
||||
sudo hciconfig hci0 up
|
||||
```
|
||||
|
||||
### MQTT Connection Issues
|
||||
|
||||
Reference in New Issue
Block a user