getsenic / gatt-python

Bluetooth GATT SDK for Python
MIT License
318 stars 86 forks source link

Insufficient Authorization #62

Open soner89 opened 3 years ago

soner89 commented 3 years ago

Hi all,

on my Raspberry Pi 4, I'm trying to write some characteristics using this gatt module. However, I run into the following issue:

> ACL Data RX: Handle 64 flags 0x02 dlen 9                                               #36 [hci0] 17.312990
      ATT: Error Response (0x01) len 4
        Write Request (0x12)
        Handle: 0x0020
        Error: Insufficient Authorization (0x08)

The python code looks like this:

import gatt

manager = gatt.DeviceManager(adapter_name='hci0')

class AnyDevice(gatt.Device):
    def services_resolved(self):
        super().services_resolved()

        device_information_service = next(
            s for s in self.services
            if s.uuid == '00001234-0000-1000-8000-001234567890')

        firmware_version_characteristic = next(
            c for c in device_information_service.characteristics
            if c.uuid == '00001235-0000-1000-8000-001234567890')

        firmware_version_characteristic.write_value(b'start')

    def characteristic_write_value_succeeded(self, characteristic):
        """
        Called when a characteristic value write command succeeded.
        """
        # To be implemented by subclass
        print("worked")

    def characteristic_write_value_failed(self, characteristic, error):
        """
        Called when a characteristic value write command failed.
        """
        # To be implemented by subclass
        print("failed")

device = AnyDevice(mac_address='00:21:7E:24:A7:F1', manager=manager)
device.connect()

manager.run()

On my computer, this works without any issues. On the RPI, i get the autohrization error.

I read that you can set the permissions in the gatt, but couldn't find a proper function in the implementation.

Any ideas?

Thanks, Soner