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

Add capability to include tx power in advertisement #410

Merged
merged 6 commits into from
May 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Support tx-power in advertisement
  • Loading branch information
ukBaz committed May 12, 2024
commit af4f65058d1afdc95985a1277acfbf8c40968915
16 changes: 9 additions & 7 deletions bluezero/advertisement.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self, advert_id, ad_type):
'ManufacturerData': None,
'SolicitUUIDs': None,
'ServiceData': None,
'IncludeTxPower': False,
'Includes': set(),
'Appearance': None,
'LocalName': None
}
Expand Down Expand Up @@ -150,13 +150,15 @@ def service_data(self, data):
@property
def include_tx_power(self):
"""Include TX power in advert (Different from beacon packet)"""
return self.Get(constants.LE_ADVERTISEMENT_IFACE,
'IncludeTxPower')
includes = self.Get(constants.LE_ADVERTISEMENT_IFACE, 'Includes')
return 'tx-power' in includes

@include_tx_power.setter
def include_tx_power(self, state):
return self.Set(constants.LE_ADVERTISEMENT_IFACE,
'IncludeTxPower', state)
if state:
self.props[constants.LE_ADVERTISEMENT_IFACE]['Includes'].add('tx-power')
else:
self.props[constants.LE_ADVERTISEMENT_IFACE]['Includes'].remove('tx-power')

@property
def local_name(self):
Expand Down Expand Up @@ -217,8 +219,8 @@ def GetAll(self, interface_name): # pylint: disable=invalid-name
if self.props[interface_name]['Appearance'] is not None:
response['Appearance'] = dbus.UInt16(
self.props[interface_name]['Appearance'])
response['IncludeTxPower'] = dbus.Boolean(
self.props[interface_name]['IncludeTxPower'])
response['Includes'] = dbus.Array(
self.props[interface_name]['Includes'], signature='s')

return response

Expand Down