google / google/bumble

Descriptors showing on Android but not on iOS

Open
#168 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
555
Forks
138
Avg merge
3d 15h
Merged PRs (30d)
9

Description

Hi!

First, a disclaimer: I am not 100% sure this is an issue with bumble.

I have the following code (based on [run_notifier.py](https://github.com/google/bumble/blob/45ca0ef071425f3c11cb57dc2ae95c9a0f2df483/examples/run_notifier.py)), which creates a device with a service that has a characteristic that has a descriptor. These attributes (service, characteristic and descriptor) have custom UUIDs.

ble_device.py:
```
import asyncio
import os
import logging
import json

from bumble.device import Device, Connection
from bumble.transport import open_transport_or_link
from bumble.gatt import Service, Characteristic, Descriptor
from bumble.att import Attribute
from bumble.core import AdvertisingData

# -----------------------------------------------------------------------------
class Listener(Device.Listener, Connection.Listener):
def __init__(self, device):
self.device = device

def on_connection(self, connection):
print(f'=== Connected to {connection}')
connection.listener = self

def on_disconnection(self, reason):
print(f'### Disconnected, reason={reason}')

def on_characteristic_subscription(
self, connection, characteristic, notify_enabled, indicate_enabled
):
print(
f'$$$ Characteristic subscription for handle {characteristic.handle} '
f'from {connection}: '
f'notify {"enabled" if notify_enabled else "disabled"}, '
f'indicate {"enabled" if indicate_enabled else "disabled"}'
)

# -----------------------------------------------------------------------------
async def main():

print('<<< connecting to HCI...')
# hardcode the device config and the serial port

async with await open_transport_or_link('serial:/dev/tty.usbmodem1101') as (hci_source, hci_sink):
print('<<< connected')

# Create a device to manage the host
device = Device.from_config_file_with_hci('brc1k/device1.json', hci_source, hci_sink)
device.listener = Listener(device)

descriptor = Descriptor("de42bd76-cfd2-11ed-afa1-0242ac120002",
Attribute.READABLE | Attribute.WRITEABLE,
)
characteristic = Characteristic(
"de42bbbe-cfd2-11ed-afa1-0242ac120002",
Characteristic.READ | Characteristic.NOTIFY,
Characteristic.READABLE | Characteristic.WRITEABLE,
bytes(json.dumps("no value here"), encoding='utf8'),
descriptors=[descriptor]
)

service = Service("de42b830-cfd2-11ed-afa1-0242ac120002",
[characteristic]
)

device.add_services([service])
device.advertising_data = bytes(
AdvertisingData(
[
(
AdvertisingData.COMPLETE_LOCAL_NAME,
bytes('Bumble', 'utf-8'),
),
]
)
)

# Get things going
await device.power_on()
await device.start_advertising(auto_restart=True)

while True:
await asyncio.sleep(3.0)

# -----------------------------------------------------------------------------
logging.basicConfig(level=os.environ.get('BUMBLE_LOGLEVEL', 'DEBUG').upper())
asyncio.run(main())
```

device1.json:
```
{
"class_of_device": 2360322,
"keystore": "JsonKeyStore",
"advertising_interval": 100
}
```

On Android I can see this descriptor that I added, but on iOS it is not there. (In both cases, the [CCCD](https://github.com/google/bumble/blob/45ca0ef071425f3c11cb57dc2ae95c9a0f2df483/bumble/gatt.py#L118) descriptor is visible.)

Screenshot from nRF Connect (Android on the left, iOS on the right):
![nRF_Connect_Descriptor](https://user-images.githubusercontent.com/11513215/229477552-8ebe37df-5922-4db4-a5a5-21eaca3145df.png)

Also, when I use one of the pre-defined UUIDs for the descriptor (e.g. [this one](https://github.com/google/bumble/blob/45ca0ef071425f3c11cb57dc2ae95c9a0f2df483/bumble/gatt.py#L116)), it is again seen on Android but not on iOS.

One more thing, this should not be an issue with nRF Connect app, since I see this discrepancy between iOS and Android also using another (custom) app.

User @coalbr reported a [similar issue](https://github.com/NordicSemiconductor/IOS-nRF-Connect/issues/116) on IOS-nRF-Connect repository.

So, my question is: does anyone have any idea why are these descriptors not showing on iOS and how to fix this? Any help would be very much appreciated!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.