togrill-bluetooth 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,54 @@
1
+ # This workflow will install Python dependencies, run tests and lint with a single version of Python
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3
+
4
+ name: CI
5
+
6
+ on:
7
+ push:
8
+ # Use ["main", "master"] for CI only on the default branch.
9
+ # Use ["**"] for CI on all branches.
10
+ branches: ["main", "master"]
11
+ pull_request:
12
+ branches: ["main", "master"]
13
+
14
+ permissions:
15
+ contents: read
16
+
17
+ jobs:
18
+ build:
19
+ strategy:
20
+ matrix:
21
+ # Update this as needed:
22
+ # Common platforms: ["ubuntu-latest", "macos-latest", "windows-latest"]
23
+ os: ["ubuntu-latest"]
24
+ python-version: ["3.11", "3.12", "3.13"]
25
+
26
+ # Linux only by default. Use ${{ matrix.os }} for other OSes.
27
+ runs-on: ${{ matrix.os }}
28
+
29
+ steps:
30
+ # Generally following uv docs:
31
+ # https://docs.astral.sh/uv/guides/integration/github/
32
+
33
+ - name: Checkout (official GitHub action)
34
+ uses: actions/checkout@v4
35
+ with:
36
+ # Important for versioning plugins:
37
+ fetch-depth: 0
38
+
39
+ - name: Install uv (official Astral action)
40
+ uses: astral-sh/setup-uv@v5
41
+ with:
42
+ # Update this as needed:
43
+ version: "0.8.0"
44
+ enable-cache: true
45
+ python-version: ${{ matrix.python-version }}
46
+
47
+ - name: Set up Python (using uv)
48
+ run: uv python install
49
+
50
+ - name: Install all dependencies
51
+ run: uv sync --all-extras
52
+
53
+ - name: Run tests
54
+ run: uv run pytest
@@ -0,0 +1,44 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch: # Enable manual trigger.
7
+
8
+ jobs:
9
+ build-and-publish:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ id-token: write # Mandatory for OIDC.
13
+ contents: read
14
+ steps:
15
+ - name: Checkout (official GitHub action)
16
+ uses: actions/checkout@v4
17
+ with:
18
+ # Important for versioning plugins:
19
+ fetch-depth: 0
20
+
21
+ - name: Install uv (official Astral action)
22
+ uses: astral-sh/setup-uv@v5
23
+ with:
24
+ version: "0.8.0"
25
+ enable-cache: true
26
+ python-version: "3.12"
27
+
28
+ - name: Set up Python (using uv)
29
+ run: uv python install
30
+
31
+ - name: Install all dependencies
32
+ run: uv sync --all-extras
33
+
34
+ - name: Run tests
35
+ run: uv run pytest
36
+
37
+ - name: Build package
38
+ run: uv build
39
+
40
+ - name: Publish to PyPI
41
+ run: uv publish --trusted-publishing always
42
+ # Although uv is newer and faster, the "official" publishing option is the one from PyPA,
43
+ # which uses twine. If desired, replace `uv publish` with:
44
+ # uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,75 @@
1
+ # Additions to standard GitHub .gitignore:
2
+ *.bak
3
+ *.orig
4
+ tmp/
5
+ trash/
6
+ attic/
7
+ .kash/
8
+
9
+ # Byte-compiled / optimized / DLL files
10
+ __pycache__/
11
+ *.py[cod]
12
+ *$py.class
13
+
14
+ # C extensions
15
+ *.so
16
+
17
+ # Distribution / packaging
18
+ .Python
19
+ build/
20
+ develop-eggs/
21
+ dist/
22
+ downloads/
23
+ eggs/
24
+ .eggs/
25
+ lib/
26
+ lib64/
27
+ parts/
28
+ sdist/
29
+ var/
30
+ wheels/
31
+ share/python-wheels/
32
+ *.egg-info/
33
+ .installed.cfg
34
+ *.egg
35
+ MANIFEST
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py,cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+ cover/
55
+
56
+
57
+ # Environments
58
+ .env
59
+ .venv
60
+ env/
61
+ venv/
62
+ ENV/
63
+ env.bak/
64
+ venv.bak/
65
+
66
+ # mkdocs documentation
67
+ /site
68
+
69
+ # mypy
70
+ .mypy_cache/
71
+ .dmypy.json
72
+ dmypy.json
73
+
74
+ # PyPI configuration file
75
+ .pypirc
@@ -0,0 +1,10 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ # Ruff version.
4
+ rev: v0.12.5
5
+ hooks:
6
+ # Run the linter.
7
+ - id: ruff-check
8
+ args: [ --fix ]
9
+ # Run the formatter.
10
+ - id: ruff-format
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Joakim Plate
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,72 @@
1
+ Metadata-Version: 2.4
2
+ Name: togrill-bluetooth
3
+ Version: 0.1.1
4
+ Summary: Module to handle communication with ToGrill compatible temperature probes.
5
+ Project-URL: Repository, https://github.com/elupus/togrill-bluetooth
6
+ Author-email: Joakim Plate <elupus@ecce.se>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Typing :: Typed
18
+ Requires-Python: <4.0,>=3.11
19
+ Requires-Dist: bleak>=1.0.1
20
+ Provides-Extra: cli
21
+ Requires-Dist: anyio>=4.9.0; extra == 'cli'
22
+ Requires-Dist: asyncclick>=8.1.8; extra == 'cli'
23
+ Description-Content-Type: text/markdown
24
+
25
+ # ToGrill Bluetooth Library
26
+
27
+ ToGrill is a Python library for communicating with ToGrill Bluetooth-enabled devices, such as smart grilling thermometers. It provides tools for scanning, connecting, and interacting with these devices, including reading probe temperatures, setting timers, and configuring temperature ranges.
28
+
29
+ It's main target use is for integration into Home Assistant integrations.
30
+
31
+ ## Features
32
+
33
+ - Scan for ToGrill Bluetooth devices
34
+ - Connect and interact with devices using BLE
35
+ - Read probe temperatures and device status
36
+ - Set timers and temperature ranges
37
+ - Command-line interface for easy usage and scripting
38
+
39
+ ## Command-Line Interface
40
+
41
+ ### Commands
42
+
43
+ - scan
44
+ Scan for nearby ToGrill Bluetooth devices and display their information.
45
+
46
+ - connect `address`
47
+ Connect to a device by Bluetooth address. This command opens a group of subcommands:
48
+ Commands can be chained to perform multiple actions in one connection.
49
+
50
+ - list
51
+ List all GATT services and characteristics, and read available data.
52
+
53
+ - timer `probe` `seconds`
54
+ Set a timer on the specified probe for a given number of seconds.
55
+
56
+ - range `probe` `minimum` `maximum`
57
+ Set a minimum and maximum temperature range for a probe.
58
+
59
+ - target `probe` `target`
60
+ Set a target temperature for a probe.
61
+
62
+ - wait
63
+ Wait indefinitely, keeping the connection open.
64
+
65
+ ### Examples
66
+
67
+ - `togrill-bluetooth scan`
68
+ - `togrill-bluetooth connect AA:BB:CC:DD:EE:FF list wait`
69
+ - `togrill-bluetooth connect AA:BB:CC:DD:EE:FF timer 1 600`
70
+ - `togrill-bluetooth connect AA:BB:CC:DD:EE:FF range 1 50.0 80.0`
71
+ - `togrill-bluetooth connect AA:BB:CC:DD:EE:FF target 1 65.0`
72
+ - `togrill-bluetooth connect AA:BB:CC:DD:EE:FF wait`
@@ -0,0 +1,48 @@
1
+ # ToGrill Bluetooth Library
2
+
3
+ ToGrill is a Python library for communicating with ToGrill Bluetooth-enabled devices, such as smart grilling thermometers. It provides tools for scanning, connecting, and interacting with these devices, including reading probe temperatures, setting timers, and configuring temperature ranges.
4
+
5
+ It's main target use is for integration into Home Assistant integrations.
6
+
7
+ ## Features
8
+
9
+ - Scan for ToGrill Bluetooth devices
10
+ - Connect and interact with devices using BLE
11
+ - Read probe temperatures and device status
12
+ - Set timers and temperature ranges
13
+ - Command-line interface for easy usage and scripting
14
+
15
+ ## Command-Line Interface
16
+
17
+ ### Commands
18
+
19
+ - scan
20
+ Scan for nearby ToGrill Bluetooth devices and display their information.
21
+
22
+ - connect `address`
23
+ Connect to a device by Bluetooth address. This command opens a group of subcommands:
24
+ Commands can be chained to perform multiple actions in one connection.
25
+
26
+ - list
27
+ List all GATT services and characteristics, and read available data.
28
+
29
+ - timer `probe` `seconds`
30
+ Set a timer on the specified probe for a given number of seconds.
31
+
32
+ - range `probe` `minimum` `maximum`
33
+ Set a minimum and maximum temperature range for a probe.
34
+
35
+ - target `probe` `target`
36
+ Set a target temperature for a probe.
37
+
38
+ - wait
39
+ Wait indefinitely, keeping the connection open.
40
+
41
+ ### Examples
42
+
43
+ - `togrill-bluetooth scan`
44
+ - `togrill-bluetooth connect AA:BB:CC:DD:EE:FF list wait`
45
+ - `togrill-bluetooth connect AA:BB:CC:DD:EE:FF timer 1 600`
46
+ - `togrill-bluetooth connect AA:BB:CC:DD:EE:FF range 1 50.0 80.0`
47
+ - `togrill-bluetooth connect AA:BB:CC:DD:EE:FF target 1 65.0`
48
+ - `togrill-bluetooth connect AA:BB:CC:DD:EE:FF wait`
@@ -0,0 +1,135 @@
1
+ # ---- Project Info and Dependencies ----
2
+
3
+ [project.urls]
4
+ Repository = "https://github.com/elupus/togrill-bluetooth"
5
+ # Homepage = "https://..."
6
+ # Documentation = "https://..."
7
+
8
+ [project]
9
+ name = "togrill-bluetooth"
10
+ description = "Module to handle communication with ToGrill compatible temperature probes."
11
+ authors = [
12
+ { name="Joakim Plate", email="elupus@ecce.se" },
13
+ ]
14
+ readme = "README.md"
15
+ license = "MIT"
16
+ requires-python = ">=3.11,<4.0"
17
+ dynamic = ["version"]
18
+
19
+ # https://pypi.org/classifiers/
20
+ # Adjust as needed:
21
+ classifiers = [
22
+ # Adjust as needed:
23
+ "Development Status :: 4 - Beta",
24
+ # "Development Status :: 5 - Production/Stable",
25
+ "Intended Audience :: Developers",
26
+ "Operating System :: OS Independent",
27
+ "Programming Language :: Python",
28
+ "Programming Language :: Python :: 3",
29
+ "Programming Language :: Python :: 3.11",
30
+ "Programming Language :: Python :: 3.12",
31
+ "Programming Language :: Python :: 3.13",
32
+ "Typing :: Typed",
33
+ # Include this to avoid accidentally publishing to PyPI:
34
+ # "Private :: Do Not Upload",
35
+ ]
36
+
37
+
38
+ # ---- Main dependencies ----
39
+
40
+ dependencies = [
41
+ "bleak>=1.0.1",
42
+ ]
43
+
44
+
45
+ # ---- Dev dependencies ----
46
+
47
+ [dependency-groups]
48
+ dev = [
49
+ "pytest>=8.3.5",
50
+ "pytest-sugar>=1.0.0",
51
+ "ruff>=0.11.9",
52
+ "codespell>=2.4.1",
53
+ "rich>=14.0.0",
54
+ "pre-commit>=4.2.0",
55
+ ]
56
+
57
+ [project.scripts]
58
+ # Add script entry points here:
59
+ togrill-bluetooth = "togrill_bluetooth.__main__:main"
60
+
61
+ [project.optional-dependencies]
62
+ cli = [
63
+ "anyio>=4.9.0",
64
+ "asyncclick>=8.1.8",
65
+ ]
66
+
67
+
68
+ # ---- Build system ----
69
+ [build-system]
70
+ requires = ["hatchling", "uv-dynamic-versioning"]
71
+ build-backend = "hatchling.build"
72
+
73
+ [tool.hatch.version]
74
+ source = "uv-dynamic-versioning"
75
+
76
+ [tool.uv-dynamic-versioning]
77
+ vcs = "git"
78
+ style = "pep440"
79
+ bump = "true"
80
+ pattern = "default-unprefixed"
81
+
82
+ [tool.hatch.build.targets.wheel]
83
+ # The source location for the package.
84
+ packages = ["src/togrill_bluetooth"]
85
+
86
+
87
+ # ---- Settings ----
88
+
89
+ [tool.ruff]
90
+ # Set as desired, typically 88 (black standard) or 100 (wide).
91
+ line-length = 100
92
+
93
+ [tool.ruff.lint]
94
+ select = [
95
+ # See: https://docs.astral.sh/ruff/rules/
96
+ # Basic list from: https://docs.astral.sh/ruff/linter/#rule-selection
97
+ "E", # https://docs.astral.sh/ruff/rules/#error-e
98
+ "F", # https://docs.astral.sh/ruff/rules/#pyflakes-f
99
+ "UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up
100
+ "B", # https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
101
+ "I", # https://docs.astral.sh/ruff/rules/#isort-i
102
+ # Other possibilities:
103
+ # "D" # https://docs.astral.sh/ruff/rules/#pydocstyle-d
104
+ # "Q" # https://docs.astral.sh/ruff/rules/#flake8-quotes-q
105
+ # "COM" # https://docs.astral.sh/ruff/rules/#flake8-commas-com
106
+ # "SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
107
+
108
+ ]
109
+ ignore = [
110
+ # Disable some rules that are overly pedantic. Add/remove as desired:
111
+ "E501", # https://docs.astral.sh/ruff/rules/line-too-long/
112
+ "E402", # https://docs.astral.sh/ruff/rules/module-import-not-at-top-of-file/
113
+ "E731", # https://docs.astral.sh/ruff/rules/lambda-assignment/
114
+ # We use both ruff formatter and linter so some rules should always be disabled.
115
+ # See: https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
116
+ "W191", # https://docs.astral.sh/ruff/rules/tab-indentation/
117
+ "E111", # https://docs.astral.sh/ruff/rules/indentation-with-invalid-multiple/
118
+ "E114", # https://docs.astral.sh/ruff/rules/indentation-with-invalid-multiple-comment/
119
+ "E117", # https://docs.astral.sh/ruff/rules/over-indented/
120
+ "D206", # https://docs.astral.sh/ruff/rules/docstring-tab-indentation/
121
+ "D300", # https://docs.astral.sh/ruff/rules/triple-single-quotes/
122
+ "Q000", # https://docs.astral.sh/ruff/rules/bad-quotes-inline-string/
123
+ "Q001", # https://docs.astral.sh/ruff/rules/bad-quotes-multiline-string/
124
+ "Q002", # https://docs.astral.sh/ruff/rules/bad-quotes-docstring/
125
+ "Q003", # https://docs.astral.sh/ruff/rules/avoidable-escaped-quote/
126
+ "COM812", # https://docs.astral.sh/ruff/rules/missing-trailing-comma/
127
+ "COM819", # https://docs.astral.sh/ruff/rules/prohibited-trailing-comma/
128
+ "ISC002", # https://docs.astral.sh/ruff/rules/multi-line-implicit-string-concatenation/
129
+ ]
130
+
131
+
132
+ [tool.codespell]
133
+ # Add here as needed:
134
+ # ignore-words-list = "foo,bar"
135
+ # skip = "foo.py,bar.py"
@@ -0,0 +1,22 @@
1
+ """ToGrill main module"""
2
+
3
+ from bleak.uuids import register_uuids
4
+
5
+ from .const import MainService
6
+ from .parse import Service
7
+
8
+ register_uuids(
9
+ {service.uuid: f"ToGrill {service.__name__}" for service in Service.registry.values()}
10
+ )
11
+
12
+ register_uuids(
13
+ {
14
+ char.uuid: f"ToGrill {service.__name__} {char.name}"
15
+ for service in Service.registry.values()
16
+ for char in service.characteristics()
17
+ }
18
+ )
19
+
20
+ __all__ = ( # noqa: F405
21
+ MainService
22
+ )
@@ -0,0 +1,172 @@
1
+ from datetime import timedelta
2
+
3
+ import anyio
4
+ import asyncclick as click
5
+ from bleak import (
6
+ AdvertisementData,
7
+ BleakClient,
8
+ BleakGATTCharacteristic,
9
+ BleakScanner,
10
+ BLEDevice,
11
+ )
12
+ from bleak.uuids import uuidstr_to_str
13
+
14
+ from .const import MainService, ManufacturerData
15
+ from .exceptions import DecodeError
16
+ from .parse import Characteristic, NotifyCharacteristic, WriteCharacteristic
17
+ from .parse_packets import (
18
+ PacketA0Notify,
19
+ PacketA1Notify,
20
+ PacketA7Write,
21
+ PacketA300Write,
22
+ PacketA301Write,
23
+ PacketNotify,
24
+ )
25
+
26
+
27
+ @click.group()
28
+ async def cli():
29
+ pass
30
+
31
+
32
+ @cli.command()
33
+ async def scan():
34
+ click.echo("Scanning for devices")
35
+
36
+ devices = set()
37
+
38
+ def detected(device: BLEDevice, advertisement: AdvertisementData):
39
+ if device not in devices:
40
+ if MainService.uuid not in advertisement.service_uuids:
41
+ return
42
+ devices.add(device)
43
+
44
+ click.echo(f"Device: {device}")
45
+ for service in advertisement.service_uuids:
46
+ click.echo(f" - Service: {service} {uuidstr_to_str(service)}")
47
+ click.echo(f" - Data: {advertisement.service_data}")
48
+ click.echo(f" - Manu: {advertisement.manufacturer_data}")
49
+
50
+ if data := advertisement.manufacturer_data.get(ManufacturerData.company):
51
+ decoded = ManufacturerData.decode(data)
52
+ click.echo(f" - : {decoded}")
53
+
54
+ click.echo(f" - RSSI: {advertisement.rssi}")
55
+ click.echo()
56
+
57
+ async with BleakScanner(detected, service_uuids=[MainService.uuid]):
58
+ await anyio.sleep_forever()
59
+
60
+
61
+ @cli.group(chain=True)
62
+ @click.argument("address")
63
+ @click.option("--code", default="")
64
+ @click.pass_context
65
+ async def connect(ctx: click.Context, address: str, code: str):
66
+ click.echo(f"Connecting to: {address} ...", nl=False)
67
+ client = await ctx.with_async_resource(BleakClient(address, timeout=20))
68
+ ctx.obj = client
69
+ click.echo(" Done")
70
+
71
+ def notify_data(char_specifier: BleakGATTCharacteristic, data: bytearray):
72
+ try:
73
+ packet_data = NotifyCharacteristic.decode(data)
74
+ packet = PacketNotify.decode(packet_data)
75
+ click.echo(f"Notify: {packet}")
76
+ except DecodeError as exc:
77
+ click.echo(f"Failed to decode: {data.hex()} with error {exc}")
78
+
79
+ await client.start_notify(MainService.notify.uuid, notify_data)
80
+
81
+ await client.write_gatt_char(
82
+ MainService.write.uuid, WriteCharacteristic.encode(PacketA0Notify.request()), False
83
+ )
84
+ await client.write_gatt_char(
85
+ MainService.write.uuid, WriteCharacteristic.encode(PacketA1Notify.request()), False
86
+ )
87
+
88
+
89
+ @connect.command()
90
+ @click.pass_obj
91
+ async def list(client: BleakClient):
92
+ for service in client.services:
93
+ click.echo(f"Service: {service}")
94
+
95
+ async def read_print(char: BleakGATTCharacteristic):
96
+ parser = Characteristic.registry.get(char.uuid)
97
+ if "read" in char.properties:
98
+ data = await client.read_gatt_char(char.uuid)
99
+ else:
100
+ data = None
101
+ click.echo(f" - {char}")
102
+ click.echo(f" - {char.properties}")
103
+ if data is not None and parser:
104
+ click.echo(f" - Data: {parser.decode(data)}")
105
+
106
+ async with anyio.create_task_group() as tg:
107
+ for char in service.characteristics:
108
+ tg.start_soon(read_print, char)
109
+
110
+
111
+ @connect.command()
112
+ @click.argument("probe", type=int)
113
+ @click.argument("seconds", type=int)
114
+ @click.pass_obj
115
+ async def timer(client: BleakClient, probe: int, seconds: int):
116
+ click.echo(f"Setting timer on {probe} for delay {seconds} ...", nl=False)
117
+ await client.write_gatt_char(
118
+ MainService.write.uuid,
119
+ WriteCharacteristic.encode(
120
+ PacketA7Write(probe=probe, time=timedelta(seconds=seconds)).encode()
121
+ ),
122
+ False,
123
+ )
124
+ click.echo(" Done")
125
+
126
+
127
+ @connect.command()
128
+ @click.argument("probe", type=int)
129
+ @click.argument("minimum", type=float)
130
+ @click.argument("maximum", type=float)
131
+ @click.pass_obj
132
+ async def range(client: BleakClient, probe: int, minimum: float, maximum: float):
133
+ click.echo(f"Setting range cook on {probe} min: {minimum} max: {maximum} ...", nl=False)
134
+ await client.write_gatt_char(
135
+ MainService.write.uuid,
136
+ WriteCharacteristic.encode(
137
+ PacketA300Write(probe=probe, minimum=minimum, maximum=maximum).encode()
138
+ ),
139
+ False,
140
+ )
141
+ click.echo(" Done")
142
+
143
+
144
+ @connect.command()
145
+ @click.argument("probe", type=int)
146
+ @click.argument("target", type=float)
147
+ @click.pass_obj
148
+ async def target(client: BleakClient, probe: int, target: float):
149
+ click.echo(f"Setting range cook on {probe} target: {target} ...", nl=False)
150
+ await client.write_gatt_char(
151
+ MainService.write.uuid,
152
+ WriteCharacteristic.encode(PacketA301Write(probe=probe, target=target).encode()),
153
+ False,
154
+ )
155
+ click.echo(" Done")
156
+
157
+
158
+ @connect.command()
159
+ async def wait():
160
+ click.echo("Waiting")
161
+ await anyio.sleep_forever()
162
+
163
+
164
+ def main():
165
+ try:
166
+ cli()
167
+ except KeyboardInterrupt:
168
+ pass
169
+
170
+
171
+ if __name__ == "__main__":
172
+ main()
@@ -0,0 +1,23 @@
1
+ """Constants"""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import ClassVar
5
+
6
+ from togrill_bluetooth.parse import NotifyCharacteristic, WriteCharacteristic
7
+
8
+ from .parse import Service
9
+
10
+
11
+ class MainService(Service):
12
+ uuid = "0000cee0-0000-1000-8000-00805f9b34fb"
13
+ write = WriteCharacteristic()
14
+ notify = NotifyCharacteristic()
15
+
16
+
17
+ @dataclass
18
+ class ManufacturerData:
19
+ company: ClassVar[int] = 0x879A
20
+
21
+ @staticmethod
22
+ def decode(data: bytes):
23
+ return ManufacturerData()
@@ -0,0 +1,2 @@
1
+ class DecodeError(Exception):
2
+ pass