sok-ble 0.1.5__tar.gz → 0.1.8__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.
- {sok_ble-0.1.5 → sok_ble-0.1.8}/.github/copilot-instructions.md +15 -3
- sok_ble-0.1.8/.github/dependabot.yml +15 -0
- sok_ble-0.1.8/.github/workflows/release.yml +62 -0
- sok_ble-0.1.8/.github/workflows/test.yml +44 -0
- sok_ble-0.1.8/.release-please-manifest.json +3 -0
- sok_ble-0.1.8/AGENTS.md +35 -0
- {sok_ble-0.1.5 → sok_ble-0.1.8}/CHANGELOG.md +28 -0
- {sok_ble-0.1.5 → sok_ble-0.1.8}/PKG-INFO +5 -3
- {sok_ble-0.1.5 → sok_ble-0.1.8}/README.md +4 -2
- {sok_ble-0.1.5 → sok_ble-0.1.8}/pyproject.toml +1 -5
- sok_ble-0.1.8/release-please-config.json +14 -0
- {sok_ble-0.1.5 → sok_ble-0.1.8}/src/sok_ble/exceptions.py +0 -1
- {sok_ble-0.1.5 → sok_ble-0.1.8}/src/sok_ble/sok_bluetooth_device.py +18 -15
- {sok_ble-0.1.5 → sok_ble-0.1.8}/src/sok_ble/sok_parser.py +5 -4
- {sok_ble-0.1.5 → sok_ble-0.1.8}/tests/test_derived.py +0 -1
- {sok_ble-0.1.5 → sok_ble-0.1.8}/tests/test_exceptions.py +0 -1
- {sok_ble-0.1.5 → sok_ble-0.1.8}/tests/test_parser_full.py +4 -13
- {sok_ble-0.1.5 → sok_ble-0.1.8}/tests/test_parser_info.py +1 -3
- {sok_ble-0.1.5 → sok_ble-0.1.8}/uv.lock +1 -1
- sok_ble-0.1.5/.github/workflows/ci.yml +0 -84
- sok_ble-0.1.5/AGENTS.md +0 -3
- {sok_ble-0.1.5 → sok_ble-0.1.8}/.github/FUNDING.yml +0 -0
- {sok_ble-0.1.5 → sok_ble-0.1.8}/.gitignore +0 -0
- {sok_ble-0.1.5 → sok_ble-0.1.8}/.python-version +0 -0
- {sok_ble-0.1.5 → sok_ble-0.1.8}/LICENSE +0 -0
- {sok_ble-0.1.5 → sok_ble-0.1.8}/prompts.md +0 -0
- {sok_ble-0.1.5 → sok_ble-0.1.8}/requirements-dev.txt +0 -0
- {sok_ble-0.1.5 → sok_ble-0.1.8}/spec.md +0 -0
- {sok_ble-0.1.5 → sok_ble-0.1.8}/src/sok_ble/__init__.py +0 -0
- {sok_ble-0.1.5 → sok_ble-0.1.8}/src/sok_ble/const.py +0 -0
- {sok_ble-0.1.5 → sok_ble-0.1.8}/tests/.gitkeep +0 -0
- {sok_ble-0.1.5 → sok_ble-0.1.8}/tests/__init__.py +0 -0
- {sok_ble-0.1.5 → sok_ble-0.1.8}/tests/test_const.py +0 -0
- {sok_ble-0.1.5 → sok_ble-0.1.8}/tests/test_device_full.py +0 -0
- {sok_ble-0.1.5 → sok_ble-0.1.8}/tests/test_device_minimal.py +0 -0
- {sok_ble-0.1.5 → sok_ble-0.1.8}/tests/test_integration_mock.py +0 -0
- {sok_ble-0.1.5 → sok_ble-0.1.8}/todo.md +0 -0
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
# Background
|
|
2
|
+
|
|
2
3
|
sok-ble is a library written in Python. Its purpose is to connect to SOK LiFePO4 batteries over Bluetooth low energy and send and receive modbus commands. sok-ble then parses the responses and returns usable data. The primary intent is for sok-ble to be utilized/wrapped/consumed by sok-ha, a custom integration for Home Assistant; however, sok-ble may be used by any 3rd party and must remain independent of Home Assistant.
|
|
3
4
|
|
|
4
5
|
# Documentation
|
|
6
|
+
|
|
5
7
|
- Use Markdown for all documentation
|
|
8
|
+
- Place documentation in the `docs/` directory
|
|
9
|
+
|
|
10
|
+
# Code Style
|
|
11
|
+
|
|
12
|
+
- Add comments to code when it may be unclear what the code does or how it functions.
|
|
13
|
+
- Comments should be full sentences and end with a period.
|
|
14
|
+
- Maintainable and understandable code is preferred over complex code. Simplicity is the ultimate complexity!
|
|
6
15
|
|
|
7
16
|
# Python
|
|
17
|
+
|
|
8
18
|
- Use uv to manage Python and all python packages
|
|
9
19
|
- Use 'uv add [package_name]' instead of 'uv pip install [package_name]'
|
|
10
20
|
|
|
11
21
|
# Testing
|
|
22
|
+
|
|
12
23
|
- Use pytest for Python testing
|
|
13
24
|
- Ensure all code is formatted and linted with Ruff.
|
|
14
25
|
|
|
15
26
|
# Files
|
|
27
|
+
|
|
16
28
|
- Do not create binary files, such as Lambda zip files.
|
|
17
29
|
- Do not modify CHANGELOG.md. This is handled by CI.
|
|
18
30
|
|
|
19
31
|
# Commits
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
32
|
+
|
|
33
|
+
- Use conventional commits for all changes
|
|
34
|
+
- Prefix all commit messages with fix:; feat:; build:; chore:; ci:; docs:; style:; refactor:; perf:; or test: as appropriate.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
|
|
3
|
+
updates:
|
|
4
|
+
- package-ecosystem: "uv"
|
|
5
|
+
directory: "/"
|
|
6
|
+
schedule:
|
|
7
|
+
interval: "weekly"
|
|
8
|
+
|
|
9
|
+
# Enable version updates for GitHub Actions
|
|
10
|
+
- package-ecosystem: "github-actions"
|
|
11
|
+
# Workflow files stored in the default location of `.github/workflows`
|
|
12
|
+
# You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.
|
|
13
|
+
directory: "/"
|
|
14
|
+
schedule:
|
|
15
|
+
interval: "weekly"
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
pull-requests: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
release-please:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
environment: release
|
|
16
|
+
outputs:
|
|
17
|
+
release_created: ${{ steps.release-please.outputs.release_created }}
|
|
18
|
+
tag_name: ${{ steps.release-please.outputs.tag_name }}
|
|
19
|
+
steps:
|
|
20
|
+
- uses: googleapis/release-please-action@v4
|
|
21
|
+
id: release-please
|
|
22
|
+
with:
|
|
23
|
+
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
|
|
24
|
+
config-file: release-please-config.json
|
|
25
|
+
|
|
26
|
+
test:
|
|
27
|
+
uses: ./.github/workflows/test.yml
|
|
28
|
+
|
|
29
|
+
release:
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
environment: release
|
|
32
|
+
if: ${{ needs.release-please.outputs.release_created == 'true' }}
|
|
33
|
+
needs:
|
|
34
|
+
- release-please
|
|
35
|
+
- test
|
|
36
|
+
permissions:
|
|
37
|
+
id-token: write
|
|
38
|
+
contents: write
|
|
39
|
+
steps:
|
|
40
|
+
- uses: actions/checkout@v4
|
|
41
|
+
with:
|
|
42
|
+
fetch-depth: 0
|
|
43
|
+
|
|
44
|
+
- name: Install uv
|
|
45
|
+
uses: astral-sh/setup-uv@v5
|
|
46
|
+
|
|
47
|
+
- name: Set up Python
|
|
48
|
+
run: uv python install
|
|
49
|
+
|
|
50
|
+
- name: Build package
|
|
51
|
+
run: uv build
|
|
52
|
+
|
|
53
|
+
- name: Upload package to PyPI
|
|
54
|
+
run: uv publish
|
|
55
|
+
|
|
56
|
+
- name: Upload Release Artifacts
|
|
57
|
+
env:
|
|
58
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
59
|
+
run: |
|
|
60
|
+
for file in dist/*; do
|
|
61
|
+
gh release upload ${{ needs.release-please.outputs.tag_name }} "$file"
|
|
62
|
+
done
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
8
|
+
workflow_call: # Makes this workflow reusable
|
|
9
|
+
|
|
10
|
+
concurrency:
|
|
11
|
+
group: ${{ github.head_ref || github.run_id }}
|
|
12
|
+
cancel-in-progress: true
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
test:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
environment: test
|
|
18
|
+
strategy:
|
|
19
|
+
fail-fast: false
|
|
20
|
+
matrix:
|
|
21
|
+
python-version:
|
|
22
|
+
- "3.11"
|
|
23
|
+
- "3.12"
|
|
24
|
+
- "3.13"
|
|
25
|
+
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v4
|
|
28
|
+
|
|
29
|
+
- name: Install uv and set the python version
|
|
30
|
+
uses: astral-sh/setup-uv@v5
|
|
31
|
+
with:
|
|
32
|
+
python-version: ${{ matrix.python-version }}
|
|
33
|
+
|
|
34
|
+
- name: Set up Python
|
|
35
|
+
run: uv python install
|
|
36
|
+
|
|
37
|
+
- name: Install the project
|
|
38
|
+
run: uv sync --all-extras --dev
|
|
39
|
+
|
|
40
|
+
- name: Run tests
|
|
41
|
+
run: uv run pytest tests
|
|
42
|
+
|
|
43
|
+
- name: Lint with Ruff
|
|
44
|
+
run: uv run ruff check . --output-format=github
|
sok_ble-0.1.8/AGENTS.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Basic Instructions
|
|
2
|
+
|
|
3
|
+
- Follow all instructions in the .github/copilot-instructions.md file.
|
|
4
|
+
|
|
5
|
+
# Before Checking In Code
|
|
6
|
+
|
|
7
|
+
- Fix all code formatting and quality issues in the entire codebase.
|
|
8
|
+
- Ensure all new code is covered by appropriate unit tests.
|
|
9
|
+
|
|
10
|
+
## Python
|
|
11
|
+
|
|
12
|
+
Fix all Python formatting and linting issues.
|
|
13
|
+
|
|
14
|
+
### Steps:
|
|
15
|
+
|
|
16
|
+
2. **Format with ruff**: `uv run ruff format .`
|
|
17
|
+
3. **Lint with ruff**: `uv run ruff check . --output-format=github`
|
|
18
|
+
4. **Run unit tests**: `uv run pytest tests`
|
|
19
|
+
|
|
20
|
+
## General Process:
|
|
21
|
+
|
|
22
|
+
1. Run automated formatters first
|
|
23
|
+
2. Fix remaining linting issues manually
|
|
24
|
+
3. Resolve type checking errors
|
|
25
|
+
4. Verify all tools pass with no errors
|
|
26
|
+
5. Review changes before committing
|
|
27
|
+
|
|
28
|
+
## Common Issues:
|
|
29
|
+
|
|
30
|
+
- Import order conflicts between tools
|
|
31
|
+
- Line length violations
|
|
32
|
+
- Unused imports/variables
|
|
33
|
+
- Type annotation requirements
|
|
34
|
+
- Missing return types
|
|
35
|
+
- Inconsistent quotes/semicolons
|
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## [0.1.8](https://github.com/IAmTheMitchell/sok-ble/compare/v0.1.7...v0.1.8) (2025-08-03)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* fix release ([9257795](https://github.com/IAmTheMitchell/sok-ble/commit/9257795edaa5937371fd3870ae7434a468bbdca2))
|
|
10
|
+
* fix release ([25395a2](https://github.com/IAmTheMitchell/sok-ble/commit/25395a22d35d62516b5ddb5d1be5e944e654cf15))
|
|
11
|
+
|
|
12
|
+
## [0.1.7](https://github.com/IAmTheMitchell/sok-ble/compare/v0.1.6...v0.1.7) (2025-08-03)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* fix bleak import ([e413bb7](https://github.com/IAmTheMitchell/sok-ble/commit/e413bb75ad3e10a73dba08881829e76dc8358d2c))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Documentation
|
|
21
|
+
|
|
22
|
+
* update CI badges ([a3f4f24](https://github.com/IAmTheMitchell/sok-ble/commit/a3f4f2478dc96a8861820adce5b40eeab1bb581d))
|
|
23
|
+
|
|
24
|
+
## v0.1.6 (2025-07-13)
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
- Prevent reconnect loop in async context
|
|
29
|
+
([`688d298`](https://github.com/IAmTheMitchell/sok-ble/commit/688d29874cb09c2ea40df818d07122d1bad32141))
|
|
30
|
+
|
|
31
|
+
|
|
4
32
|
## v0.1.5 (2025-07-13)
|
|
5
33
|
|
|
6
34
|
### Bug Fixes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sok-ble
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8
|
|
4
4
|
Summary: SOK BLE battery interface library
|
|
5
5
|
Project-URL: Homepage, https://github.com/IAmTheMitchell/sok-ble
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/IAmTheMitchell/sok-ble/issues
|
|
@@ -19,7 +19,8 @@ Description-Content-Type: text/markdown
|
|
|
19
19
|
|
|
20
20
|
# SOK BLE
|
|
21
21
|
|
|
22
|
-

|
|
23
|
+

|
|
23
24
|
|
|
24
25
|
Python library for interacting with SOK Bluetooth-enabled batteries.
|
|
25
26
|
|
|
@@ -42,5 +43,6 @@ asyncio.run(main())
|
|
|
42
43
|
```
|
|
43
44
|
|
|
44
45
|
## References
|
|
46
|
+
|
|
45
47
|
[@zuccaro's comment](https://github.com/Louisvdw/dbus-serialbattery/issues/350#issuecomment-1500658941)
|
|
46
|
-
[Bluetooth-Devices/inkbird-ble](https://github.com/Bluetooth-Devices/inkbird-ble)
|
|
48
|
+
[Bluetooth-Devices/inkbird-ble](https://github.com/Bluetooth-Devices/inkbird-ble)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# SOK BLE
|
|
2
2
|
|
|
3
|
-

|
|
4
|
+

|
|
4
5
|
|
|
5
6
|
Python library for interacting with SOK Bluetooth-enabled batteries.
|
|
6
7
|
|
|
@@ -23,5 +24,6 @@ asyncio.run(main())
|
|
|
23
24
|
```
|
|
24
25
|
|
|
25
26
|
## References
|
|
27
|
+
|
|
26
28
|
[@zuccaro's comment](https://github.com/Louisvdw/dbus-serialbattery/issues/350#issuecomment-1500658941)
|
|
27
|
-
[Bluetooth-Devices/inkbird-ble](https://github.com/Bluetooth-Devices/inkbird-ble)
|
|
29
|
+
[Bluetooth-Devices/inkbird-ble](https://github.com/Bluetooth-Devices/inkbird-ble)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "sok-ble"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.8"
|
|
4
4
|
description = "SOK BLE battery interface library"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.11"
|
|
@@ -35,10 +35,6 @@ dev = [
|
|
|
35
35
|
requires = ["hatchling"]
|
|
36
36
|
build-backend = "hatchling.build"
|
|
37
37
|
|
|
38
|
-
[tool.semantic_release]
|
|
39
|
-
branch = "main"
|
|
40
|
-
version_toml = ["pyproject.toml:project.version"]
|
|
41
|
-
|
|
42
38
|
[tool.ruff]
|
|
43
39
|
line-length = 88
|
|
44
40
|
target-version = "py311"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"packages": {
|
|
3
|
+
".": {
|
|
4
|
+
"changelog-path": "CHANGELOG.md",
|
|
5
|
+
"release-type": "python",
|
|
6
|
+
"include-v-in-tag": true,
|
|
7
|
+
"bump-minor-pre-major": true,
|
|
8
|
+
"bump-patch-for-minor-pre-major": false,
|
|
9
|
+
"draft": false,
|
|
10
|
+
"prerelease": false
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
|
|
14
|
+
}
|
|
@@ -10,8 +10,8 @@ from contextlib import asynccontextmanager
|
|
|
10
10
|
from typing import AsyncIterator, Optional
|
|
11
11
|
|
|
12
12
|
import async_timeout
|
|
13
|
-
from bleak import BleakError
|
|
14
13
|
from bleak.backends.device import BLEDevice
|
|
14
|
+
from bleak.exc import BleakError
|
|
15
15
|
|
|
16
16
|
from sok_ble.const import UUID_RX, UUID_TX, _sok_command
|
|
17
17
|
from sok_ble.exceptions import BLEConnectionError
|
|
@@ -26,6 +26,7 @@ try:
|
|
|
26
26
|
)
|
|
27
27
|
except Exception: # pragma: no cover - optional dependency
|
|
28
28
|
from bleak import BleakClient as BleakClientWithServiceCache
|
|
29
|
+
|
|
29
30
|
establish_connection = None # type: ignore[misc]
|
|
30
31
|
|
|
31
32
|
|
|
@@ -54,6 +55,8 @@ class SokBluetoothDevice:
|
|
|
54
55
|
"""Connect to the device and yield a BLE client."""
|
|
55
56
|
logger.debug("Connecting to %s", self._ble_device.address)
|
|
56
57
|
last_err: Exception | None = None
|
|
58
|
+
client: BleakClientWithServiceCache | None = None
|
|
59
|
+
|
|
57
60
|
for attempt in range(3):
|
|
58
61
|
try:
|
|
59
62
|
if establish_connection:
|
|
@@ -65,7 +68,8 @@ class SokBluetoothDevice:
|
|
|
65
68
|
)
|
|
66
69
|
else:
|
|
67
70
|
client = BleakClientWithServiceCache(
|
|
68
|
-
self._ble_device,
|
|
71
|
+
self._ble_device,
|
|
72
|
+
adapter=self._adapter,
|
|
69
73
|
)
|
|
70
74
|
await client.connect()
|
|
71
75
|
|
|
@@ -73,15 +77,7 @@ class SokBluetoothDevice:
|
|
|
73
77
|
async with async_timeout.timeout(5):
|
|
74
78
|
_ = client.services
|
|
75
79
|
await asyncio.sleep(0.15)
|
|
76
|
-
|
|
77
|
-
try:
|
|
78
|
-
yield client
|
|
79
|
-
finally:
|
|
80
|
-
await client.disconnect()
|
|
81
|
-
logger.debug(
|
|
82
|
-
"Disconnected from %s", self._ble_device.address
|
|
83
|
-
)
|
|
84
|
-
return
|
|
80
|
+
break
|
|
85
81
|
except (BleakError, asyncio.TimeoutError) as err:
|
|
86
82
|
last_err = err
|
|
87
83
|
logger.debug(
|
|
@@ -91,10 +87,17 @@ class SokBluetoothDevice:
|
|
|
91
87
|
err,
|
|
92
88
|
)
|
|
93
89
|
await asyncio.sleep(0.5)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
else:
|
|
91
|
+
raise BLEConnectionError(
|
|
92
|
+
f"Unable to establish GATT connection to {self._ble_device.address}"
|
|
93
|
+
) from last_err
|
|
94
|
+
|
|
95
|
+
assert client is not None
|
|
96
|
+
try:
|
|
97
|
+
yield client
|
|
98
|
+
finally:
|
|
99
|
+
await client.disconnect()
|
|
100
|
+
logger.debug("Disconnected from %s", self._ble_device.address)
|
|
98
101
|
|
|
99
102
|
async def _send_command(
|
|
100
103
|
self, client: BleakClientWithServiceCache, cmd: int, expected: int
|
|
@@ -14,19 +14,20 @@ logger = logging.getLogger(__name__)
|
|
|
14
14
|
|
|
15
15
|
# Endian helper functions copied from the reference addon
|
|
16
16
|
|
|
17
|
+
|
|
17
18
|
def get_le_short(data: Sequence[int] | bytes | bytearray, offset: int) -> int:
|
|
18
19
|
"""Read a little-endian signed short."""
|
|
19
|
-
return struct.unpack_from(
|
|
20
|
+
return struct.unpack_from("<h", bytes(data), offset)[0]
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
def get_le_ushort(data: Sequence[int] | bytes | bytearray, offset: int) -> int:
|
|
23
24
|
"""Read a little-endian unsigned short."""
|
|
24
|
-
return struct.unpack_from(
|
|
25
|
+
return struct.unpack_from("<H", bytes(data), offset)[0]
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
def get_le_int3(data: Sequence[int] | bytes | bytearray, offset: int) -> int:
|
|
28
29
|
"""Read a 3-byte little-endian signed integer."""
|
|
29
|
-
b0, b1, b2 = bytes(data)[offset:offset + 3]
|
|
30
|
+
b0, b1, b2 = bytes(data)[offset : offset + 3]
|
|
30
31
|
val = b0 | (b1 << 8) | (b2 << 16)
|
|
31
32
|
if val & 0x800000:
|
|
32
33
|
val -= 0x1000000
|
|
@@ -35,7 +36,7 @@ def get_le_int3(data: Sequence[int] | bytes | bytearray, offset: int) -> int:
|
|
|
35
36
|
|
|
36
37
|
def get_be_uint3(data: Sequence[int] | bytes | bytearray, offset: int) -> int:
|
|
37
38
|
"""Read a 3-byte big-endian unsigned integer."""
|
|
38
|
-
b0, b1, b2 = bytes(data)[offset:offset + 3]
|
|
39
|
+
b0, b1, b2 = bytes(data)[offset : offset + 3]
|
|
39
40
|
return (b0 << 16) | (b1 << 8) | b2
|
|
40
41
|
|
|
41
42
|
|
|
@@ -4,18 +4,10 @@ from sok_ble.sok_parser import SokParser
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
def test_parse_all():
|
|
7
|
-
info_buf = bytes.fromhex(
|
|
8
|
-
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
"ccf2000000140000000000000000000000000000"
|
|
12
|
-
)
|
|
13
|
-
cap_buf = bytes.fromhex(
|
|
14
|
-
"ccf3000000003200000000000000000000000000"
|
|
15
|
-
)
|
|
16
|
-
cell_buf = bytes.fromhex(
|
|
17
|
-
"ccf401c50c0002c60c0003bf0c0004c00c000000"
|
|
18
|
-
)
|
|
7
|
+
info_buf = bytes.fromhex("ccf0000000102700000000000000320041000000")
|
|
8
|
+
temp_buf = bytes.fromhex("ccf2000000140000000000000000000000000000")
|
|
9
|
+
cap_buf = bytes.fromhex("ccf3000000003200000000000000000000000000")
|
|
10
|
+
cell_buf = bytes.fromhex("ccf401c50c0002c60c0003bf0c0004c00c000000")
|
|
19
11
|
|
|
20
12
|
responses = {
|
|
21
13
|
0xCCF0: info_buf,
|
|
@@ -34,4 +26,3 @@ def test_parse_all():
|
|
|
34
26
|
"num_cycles": 50,
|
|
35
27
|
"cell_voltages": [3.269, 3.27, 3.263, 3.264],
|
|
36
28
|
}
|
|
37
|
-
|
|
@@ -2,9 +2,7 @@ from sok_ble.sok_parser import SokParser
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
def test_parse_info_basic():
|
|
5
|
-
hex_data = bytes.fromhex(
|
|
6
|
-
"ccf0000000102700000000000000320041000000"
|
|
7
|
-
)
|
|
5
|
+
hex_data = bytes.fromhex("ccf0000000102700000000000000320041000000")
|
|
8
6
|
result = SokParser.parse_info(hex_data)
|
|
9
7
|
assert result == {
|
|
10
8
|
"current": 10.0,
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
pull_request:
|
|
8
|
-
|
|
9
|
-
concurrency:
|
|
10
|
-
group: ${{ github.head_ref || github.run_id }}
|
|
11
|
-
cancel-in-progress: true
|
|
12
|
-
|
|
13
|
-
jobs:
|
|
14
|
-
test:
|
|
15
|
-
runs-on: ubuntu-latest
|
|
16
|
-
strategy:
|
|
17
|
-
fail-fast: false
|
|
18
|
-
matrix:
|
|
19
|
-
python-version:
|
|
20
|
-
- "3.11"
|
|
21
|
-
- "3.12"
|
|
22
|
-
- "3.13"
|
|
23
|
-
|
|
24
|
-
steps:
|
|
25
|
-
- uses: actions/checkout@v4
|
|
26
|
-
|
|
27
|
-
- name: Install uv and set the python version
|
|
28
|
-
uses: astral-sh/setup-uv@v5
|
|
29
|
-
with:
|
|
30
|
-
python-version: ${{ matrix.python-version }}
|
|
31
|
-
|
|
32
|
-
- name: Set up Python
|
|
33
|
-
run: uv python install
|
|
34
|
-
|
|
35
|
-
- name: Install the project
|
|
36
|
-
run: uv sync --all-extras --dev
|
|
37
|
-
|
|
38
|
-
- name: Run tests
|
|
39
|
-
run: uv run pytest tests
|
|
40
|
-
|
|
41
|
-
- name: Lint with Ruff
|
|
42
|
-
run: uv run ruff check . --output-format=github
|
|
43
|
-
|
|
44
|
-
release:
|
|
45
|
-
runs-on: ubuntu-latest
|
|
46
|
-
environment: release
|
|
47
|
-
if: github.ref == 'refs/heads/main'
|
|
48
|
-
needs:
|
|
49
|
-
- test
|
|
50
|
-
permissions:
|
|
51
|
-
id-token: write
|
|
52
|
-
contents: write
|
|
53
|
-
|
|
54
|
-
steps:
|
|
55
|
-
- uses: actions/checkout@v4
|
|
56
|
-
with:
|
|
57
|
-
fetch-depth: 0
|
|
58
|
-
|
|
59
|
-
- name: Install uv
|
|
60
|
-
uses: astral-sh/setup-uv@v5
|
|
61
|
-
|
|
62
|
-
- name: Set up Python
|
|
63
|
-
run: uv python install
|
|
64
|
-
|
|
65
|
-
- name: Python Semantic Release
|
|
66
|
-
id: release
|
|
67
|
-
uses: python-semantic-release/python-semantic-release@v9.21.0
|
|
68
|
-
with:
|
|
69
|
-
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
70
|
-
|
|
71
|
-
- name: Build package
|
|
72
|
-
run: uv build
|
|
73
|
-
|
|
74
|
-
- name: Upload package to PyPI
|
|
75
|
-
run: uv publish
|
|
76
|
-
if: steps.release.outputs.released == 'true'
|
|
77
|
-
|
|
78
|
-
- name: Upload Github Release Assets
|
|
79
|
-
uses: python-semantic-release/publish-action@v9.21.0
|
|
80
|
-
if: steps.release.outputs.released == 'true'
|
|
81
|
-
with:
|
|
82
|
-
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
83
|
-
tag: ${{ steps.release.outputs.tag }}
|
|
84
|
-
|
sok_ble-0.1.5/AGENTS.md
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|