Skip to content

Commit 8e984b6

Browse files
authored
Add capability to include tx power in advertisement (#410)
* Support tx-power in advertisement * Use discard rather than remove for tx-power * pep8 fixes * Update GitHub Actions dependencies * Update required packages Update to reflect BlueZ version changes and PEP 707 * doc config update
1 parent 2b0aba8 commit 8e984b6

File tree

8 files changed

+31
-23
lines changed

8 files changed

+31
-23
lines changed

.github/workflows/pypi-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v4
1717
- name: Set up Python
18-
uses: actions/setup-python@v2
18+
uses: actions/setup-python@v5
1919
with:
2020
python-version: '3.x'
2121
- name: Install dependencies

.github/workflows/python-app.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1919
- name: Set up Python 3.10
20-
uses: actions/setup-python@v3
20+
uses: actions/setup-python@v5
2121
with:
2222
python-version: "3.10"
2323
- name: Install python dependencies

bluezero/advertisement.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def __init__(self, advert_id, ad_type):
7979
'ManufacturerData': None,
8080
'SolicitUUIDs': None,
8181
'ServiceData': None,
82-
'IncludeTxPower': False,
82+
'Includes': set(),
8383
'Appearance': None,
8484
'LocalName': None
8585
}
@@ -150,13 +150,19 @@ def service_data(self, data):
150150
@property
151151
def include_tx_power(self):
152152
"""Include TX power in advert (Different from beacon packet)"""
153-
return self.Get(constants.LE_ADVERTISEMENT_IFACE,
154-
'IncludeTxPower')
153+
includes = self.Get(constants.LE_ADVERTISEMENT_IFACE, 'Includes')
154+
return 'tx-power' in includes
155155

156156
@include_tx_power.setter
157157
def include_tx_power(self, state):
158-
return self.Set(constants.LE_ADVERTISEMENT_IFACE,
159-
'IncludeTxPower', state)
158+
if state:
159+
self.props[
160+
constants.LE_ADVERTISEMENT_IFACE][
161+
'Includes'].add('tx-power')
162+
else:
163+
self.props[
164+
constants.LE_ADVERTISEMENT_IFACE][
165+
'Includes'].discard('tx-power')
160166

161167
@property
162168
def local_name(self):
@@ -217,8 +223,8 @@ def GetAll(self, interface_name): # pylint: disable=invalid-name
217223
if self.props[interface_name]['Appearance'] is not None:
218224
response['Appearance'] = dbus.UInt16(
219225
self.props[interface_name]['Appearance'])
220-
response['IncludeTxPower'] = dbus.Boolean(
221-
self.props[interface_name]['IncludeTxPower'])
226+
response['Includes'] = dbus.Array(
227+
self.props[interface_name]['Includes'], signature='s')
222228

223229
return response
224230

docs/_static/.gitkeep

Whitespace-only changes.

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
#
8383
# This is also used if you do content translation via gettext catalogs.
8484
# Usually you set "language" from the command line for these cases.
85-
language = None
85+
language = 'en'
8686

8787
# There are two options for replacing |today|: either, you set today to some
8888
# non-false value, then it is used:

docs/developer_docs.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,20 @@ of installing for edit is as follows:
1212
1313
git clone https://github.com/ukBaz/python-bluezero.git
1414
cd python-bluezero
15-
python3 -m venv --system-site-packages venv
15+
python3 -m venv venv
1616
. venv/bin/activate
1717
pip3 install -e .[dev]
1818
1919
2020
.. note::
2121

22-
Use of a Python Virtual environment is good practice when developing
23-
with Python. Because some of the dependencies for Bluezero are installed
24-
system-wide with `apt`, then it is necessary to use the
25-
`--system-site-packages` option when creating the virtual environment so
26-
those packages can be found.
22+
Use of a Python Virtual environment has become the preferred with `PEP707 <https://peps.python.org/pep-0704/>`_
23+
Some of the dependencies for Bluezero are installed
24+
system-wide with `apt` and historically haven't worked reliably in a virtual environment.
25+
These issues have been fixed in recent releases. However,
26+
occasionally people see a `ModuleNotFoundError: No module named 'gi'` reported.
27+
If this happens take a look at the `PyGObject <https://pygobject.gnome.org/getting_started.html#ubuntu-getting-started>`_
28+
install notes.
2729

2830

2931
Release Checklist

docs/system_setup.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ Overview
66
--------
77

88
Bluezero relies on the dbus interface of BlueZ. This version of Bluezero is
9-
tested wtih BlueZ version **5.50**. As the BlueZ DBus API is undergoing
9+
tested wtih BlueZ version **5.64**. As the BlueZ DBus API is undergoing
1010
changes between versions it is best to aim for that version when working
1111
with Bluezero.
12-
BlueZ 5.50 was chosen as the version to align with as this is the default version
13-
of BlueZ in Debian Stretch which was the latest/popular version at the time of
12+
BlueZ 5.64 was chosen as the version to align with as this is the default version
13+
of BlueZ in Ubuntu 22.04.4 LTS which was the latest/popular version at the time of
1414
release. This means it is likely that the Linux version you have installed will
1515
have the correct version.
1616
To check the version use bluetoothctl and type version::
1717

1818
$ bluetoothctl -v
19-
5.50
19+
5.64
2020

2121

2222
More instructions are available in the `Getting Started

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
here = path.abspath(path.dirname(__file__))
1515

16-
required_packages = []
16+
required_packages = ['PyGObject']
1717
extras_rel = ['bumpversion', 'twine']
1818
extras_doc = ['sphinx', 'sphinx_rtd_theme']
1919
extras_test = ['coverage', 'pycodestyle', 'python-dbusmock']

0 commit comments

Comments
 (0)