Skip to content

Commit

Permalink
pandora_server: Parse FLAGS into advertising data
Browse files Browse the repository at this point in the history
Bug: 328089785
  • Loading branch information
SilverBzH committed Mar 5, 2024
1 parent e554bd1 commit d6cc760
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions bumble/pandora/host.py
Expand Up @@ -50,6 +50,8 @@
from pandora.host_pb2 import (
NOT_CONNECTABLE,
NOT_DISCOVERABLE,
DISCOVERABLE_LIMITED,
DISCOVERABLE_GENERAL,
PRIMARY_1M,
PRIMARY_CODED,
SECONDARY_1M,
Expand All @@ -65,6 +67,7 @@
ConnectResponse,
DataTypes,
DisconnectRequest,
DiscoverabilityMode,
InquiryResponse,
PrimaryPhy,
ReadLocalAddressResponse,
Expand Down Expand Up @@ -735,6 +738,18 @@ def uuid16_from_str(uuid: str) -> bytes:
)
)

flag_map = {
NOT_DISCOVERABLE: AdvertisingData.BR_EDR_NOT_SUPPORTED_FLAG,
DISCOVERABLE_LIMITED: AdvertisingData.LE_LIMITED_DISCOVERABLE_MODE_FLAG,
DISCOVERABLE_GENERAL: AdvertisingData.LE_GENERAL_DISCOVERABLE_MODE_FLAG,
}

if dt.le_discoverability_mode:
flags = flag_map.get(
dt.le_discoverability_mode, AdvertisingData.BR_EDR_NOT_SUPPORTED_FLAG
)
ad_structures.append((AdvertisingData.FLAGS, flags.to_bytes(1, 'big')))

return AdvertisingData(ad_structures)

def pack_data_types(self, ad: AdvertisingData) -> DataTypes:
Expand Down

0 comments on commit d6cc760

Please sign in to comment.