sok-ble 0.1.8__tar.gz → 0.1.9b2__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.
Files changed (37) hide show
  1. sok_ble-0.1.9b2/.github/workflows/prerelease.yml +105 -0
  2. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/.github/workflows/release.yml +2 -2
  3. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/.github/workflows/test.yml +6 -2
  4. sok_ble-0.1.9b2/.release-please-manifest.json +3 -0
  5. sok_ble-0.1.8/.github/copilot-instructions.md → sok_ble-0.1.9b2/AGENTS.md +33 -0
  6. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/CHANGELOG.md +7 -0
  7. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/PKG-INFO +1 -1
  8. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/pyproject.toml +2 -1
  9. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/src/sok_ble/sok_bluetooth_device.py +30 -8
  10. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/uv.lock +200 -174
  11. sok_ble-0.1.8/.release-please-manifest.json +0 -3
  12. sok_ble-0.1.8/AGENTS.md +0 -35
  13. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/.github/FUNDING.yml +0 -0
  14. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/.github/dependabot.yml +0 -0
  15. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/.gitignore +0 -0
  16. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/.python-version +0 -0
  17. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/LICENSE +0 -0
  18. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/README.md +0 -0
  19. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/prompts.md +0 -0
  20. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/release-please-config.json +0 -0
  21. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/requirements-dev.txt +0 -0
  22. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/spec.md +0 -0
  23. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/src/sok_ble/__init__.py +0 -0
  24. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/src/sok_ble/const.py +0 -0
  25. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/src/sok_ble/exceptions.py +0 -0
  26. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/src/sok_ble/sok_parser.py +0 -0
  27. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/tests/.gitkeep +0 -0
  28. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/tests/__init__.py +0 -0
  29. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/tests/test_const.py +0 -0
  30. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/tests/test_derived.py +0 -0
  31. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/tests/test_device_full.py +0 -0
  32. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/tests/test_device_minimal.py +0 -0
  33. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/tests/test_exceptions.py +0 -0
  34. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/tests/test_integration_mock.py +0 -0
  35. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/tests/test_parser_full.py +0 -0
  36. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/tests/test_parser_info.py +0 -0
  37. {sok_ble-0.1.8 → sok_ble-0.1.9b2}/todo.md +0 -0
@@ -0,0 +1,105 @@
1
+ name: Prerelease
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [main]
6
+ types: [opened]
7
+ workflow_dispatch:
8
+ inputs:
9
+ release_branch:
10
+ description: Branch to build from
11
+ required: false
12
+ default: release-please--branches--main
13
+ semantic_version:
14
+ description: Optional semantic version to publish (x.x.x)
15
+ required: false
16
+ prerelease:
17
+ description: Prerelease type (defaults to beta)
18
+ required: false
19
+ type: choice
20
+ options:
21
+ - beta
22
+ - alpha
23
+ beta_iteration:
24
+ description: Optional alpha/beta iteration identifier (defaults to run number)
25
+ required: false
26
+
27
+ permissions:
28
+ contents: write
29
+ id-token: write
30
+
31
+ jobs:
32
+ publish-beta:
33
+ if: |
34
+ github.event_name == 'workflow_dispatch' ||
35
+ (github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'release-please--'))
36
+ runs-on: ubuntu-latest
37
+ environment: release
38
+ steps:
39
+ - uses: actions/checkout@v6
40
+ with:
41
+ ref: ${{ github.event_name == 'workflow_dispatch' && (inputs.release_branch || 'release-please--main') || github.event.pull_request.head.ref }}
42
+ fetch-depth: 0
43
+
44
+ - name: Install uv
45
+ uses: astral-sh/setup-uv@v7
46
+
47
+ - name: Set up Python
48
+ run: uv python install
49
+
50
+ - name: Derive beta version
51
+ id: version
52
+ env:
53
+ BETA_ITERATION: ${{ github.event_name == 'workflow_dispatch' && inputs.beta_iteration || '' }}
54
+ SEMANTIC_VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.semantic_version || '' }}
55
+ PRERELEASE_ID: ${{ github.event_name == 'workflow_dispatch' && inputs.prerelease || '' }}
56
+ run: |
57
+ python - <<'PY'
58
+ from pathlib import Path
59
+ import os
60
+ import re
61
+ import sys
62
+
63
+ pyproject = Path("pyproject.toml")
64
+ content = pyproject.read_text(encoding="utf-8")
65
+
66
+ match = re.search(r'^version\s*=\s*"(?P<version>[^"]+)"', content, flags=re.MULTILINE)
67
+ if not match:
68
+ sys.exit("Version not found in pyproject.toml")
69
+
70
+ semver_input = os.environ.get("SEMANTIC_VERSION", "").strip()
71
+ prerelease_input = os.environ.get("PRERELEASE_ID", "").strip().lower()
72
+ prerelease_map = {"alpha": "a", "beta": "b", "a": "a", "b": "b"}
73
+ if prerelease_input and prerelease_input not in prerelease_map:
74
+ sys.exit("Invalid prerelease identifier. Use 'alpha' or 'beta'.")
75
+
76
+ if semver_input:
77
+ if not re.fullmatch(r"\d+\.\d+\.\d+", semver_input):
78
+ sys.exit("Invalid semantic version. Use x.x.x format.")
79
+ base_version = semver_input
80
+ else:
81
+ base_version = match.group("version")
82
+
83
+ prerelease = prerelease_map.get(prerelease_input, "b")
84
+ iteration = os.environ.get("BETA_ITERATION") or os.environ.get("GITHUB_RUN_NUMBER")
85
+ beta_version = f"{base_version}{prerelease}{iteration}"
86
+
87
+ new_content = re.sub(
88
+ r'^version\s*=\s*".*"',
89
+ f'version = "{beta_version}"',
90
+ content,
91
+ count=1,
92
+ flags=re.MULTILINE,
93
+ )
94
+ pyproject.write_text(new_content, encoding="utf-8")
95
+
96
+ print(f"Publishing beta version {beta_version}")
97
+ with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output:
98
+ output.write(f"beta_version={beta_version}\n")
99
+ PY
100
+
101
+ - name: Build package
102
+ run: uv build
103
+
104
+ - name: Publish beta to PyPI
105
+ run: uv publish
@@ -37,12 +37,12 @@ jobs:
37
37
  id-token: write
38
38
  contents: write
39
39
  steps:
40
- - uses: actions/checkout@v4
40
+ - uses: actions/checkout@v6
41
41
  with:
42
42
  fetch-depth: 0
43
43
 
44
44
  - name: Install uv
45
- uses: astral-sh/setup-uv@v5
45
+ uses: astral-sh/setup-uv@v7
46
46
 
47
47
  - name: Set up Python
48
48
  run: uv python install
@@ -22,12 +22,13 @@ jobs:
22
22
  - "3.11"
23
23
  - "3.12"
24
24
  - "3.13"
25
+ - "3.14"
25
26
 
26
27
  steps:
27
- - uses: actions/checkout@v4
28
+ - uses: actions/checkout@v6
28
29
 
29
30
  - name: Install uv and set the python version
30
- uses: astral-sh/setup-uv@v5
31
+ uses: astral-sh/setup-uv@v7
31
32
  with:
32
33
  python-version: ${{ matrix.python-version }}
33
34
 
@@ -42,3 +43,6 @@ jobs:
42
43
 
43
44
  - name: Lint with Ruff
44
45
  run: uv run ruff check . --output-format=github
46
+
47
+ - name: Type check with ty
48
+ run: uv run ty check . --output-format=github
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.1.9"
3
+ }
@@ -32,3 +32,36 @@ sok-ble is a library written in Python. Its purpose is to connect to SOK LiFePO4
32
32
 
33
33
  - Use conventional commits for all changes
34
34
  - Prefix all commit messages with fix:; feat:; build:; chore:; ci:; docs:; style:; refactor:; perf:; or test: as appropriate.
35
+
36
+ # Before Checking In Code
37
+
38
+ - Fix all code formatting and quality issues in the entire codebase.
39
+ - Ensure all new code is covered by appropriate unit tests.
40
+
41
+ ## Python
42
+
43
+ Fix all Python formatting and linting issues.
44
+
45
+ ### Steps:
46
+
47
+ 1. **Format with ruff**: `uv run ruff format .`
48
+ 2. **Lint with ruff**: `uv run ruff check . --output-format=github`
49
+ 3. **Type check with ty**: `uv run ty check . --output-format=github`
50
+ 4. **Run unit tests**: `uv run pytest tests`
51
+
52
+ ## General Process:
53
+
54
+ 1. Run automated formatters first.
55
+ 2. Fix remaining linting issues manually.
56
+ 3. Resolve type checking errors.
57
+ 4. Verify all tests pass with no errors.
58
+ 5. Review changes before committing.
59
+
60
+ ## Common Issues:
61
+
62
+ - Import order conflicts between tools
63
+ - Line length violations
64
+ - Unused imports/variables
65
+ - Type annotation requirements
66
+ - Missing return types
67
+ - Inconsistent quotes/semicolons
@@ -1,6 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
3
 
4
+ ## [0.1.9](https://github.com/IAmTheMitchell/sok-ble/compare/v0.1.8...v0.1.9) (2026-02-05)
5
+
6
+
7
+ ### Documentation
8
+
9
+ * update AI directives ([afb9309](https://github.com/IAmTheMitchell/sok-ble/commit/afb9309eaa061d9087fc49f74593b1358810307a))
10
+
4
11
  ## [0.1.8](https://github.com/IAmTheMitchell/sok-ble/compare/v0.1.7...v0.1.8) (2025-08-03)
5
12
 
6
13
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sok-ble
3
- Version: 0.1.8
3
+ Version: 0.1.9b2
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sok-ble"
3
- version = "0.1.8"
3
+ version = "0.1.9b2"
4
4
  description = "SOK BLE battery interface library"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -24,6 +24,7 @@ dev = [
24
24
  "pytest>=7.0.1",
25
25
  "pytest-asyncio>=1.0.0",
26
26
  "ruff>=0.12.3",
27
+ "ty>=0.0.15",
27
28
  ]
28
29
 
29
30
  [project.urls]
@@ -10,6 +10,7 @@ from contextlib import asynccontextmanager
10
10
  from typing import AsyncIterator, Optional
11
11
 
12
12
  import async_timeout
13
+ from bleak.backends.characteristic import BleakGATTCharacteristic
13
14
  from bleak.backends.device import BLEDevice
14
15
  from bleak.exc import BleakError
15
16
 
@@ -114,7 +115,7 @@ class SokBluetoothDevice:
114
115
 
115
116
  queue: asyncio.Queue[bytes] = asyncio.Queue()
116
117
 
117
- def handler(_: int, data: bytearray) -> None:
118
+ def handler(_: BleakGATTCharacteristic, data: bytearray) -> None:
118
119
  queue.put_nowait(bytes(data))
119
120
 
120
121
  await client.start_notify(UUID_RX, handler)
@@ -136,6 +137,10 @@ class SokBluetoothDevice:
136
137
  await asyncio.sleep(0.2)
137
138
  continue
138
139
  raise
140
+ raise BleakError(
141
+ f"Failed to receive response 0x{expected:04X} "
142
+ f"from {self._ble_device.address}"
143
+ )
139
144
 
140
145
  async def async_update(self) -> None:
141
146
  """Poll the device for all telemetry and update attributes."""
@@ -180,13 +185,30 @@ class SokBluetoothDevice:
180
185
  parsed = SokParser.parse_all(responses)
181
186
  logger.debug("Parsed update: %s", parsed)
182
187
 
183
- self.voltage = parsed["voltage"]
184
- self.current = parsed["current"]
185
- self.soc = parsed["soc"]
186
- self.temperature = parsed["temperature"]
187
- self.capacity = parsed["capacity"]
188
- self.num_cycles = parsed["num_cycles"]
189
- self.cell_voltages = parsed["cell_voltages"]
188
+ voltage = parsed.get("voltage")
189
+ self.voltage = voltage if isinstance(voltage, (int, float)) else None
190
+
191
+ current = parsed.get("current")
192
+ self.current = current if isinstance(current, (int, float)) else None
193
+
194
+ soc = parsed.get("soc")
195
+ self.soc = soc if isinstance(soc, int) else None
196
+
197
+ temperature = parsed.get("temperature")
198
+ self.temperature = (
199
+ temperature if isinstance(temperature, (int, float)) else None
200
+ )
201
+
202
+ capacity = parsed.get("capacity")
203
+ self.capacity = capacity if isinstance(capacity, (int, float)) else None
204
+
205
+ num_cycles = parsed.get("num_cycles")
206
+ self.num_cycles = num_cycles if isinstance(num_cycles, int) else None
207
+
208
+ cell_voltages = parsed.get("cell_voltages")
209
+ self.cell_voltages = (
210
+ list(cell_voltages) if isinstance(cell_voltages, list) else None
211
+ )
190
212
 
191
213
  self.num_samples += 1
192
214