walkingpad-controller 0.4.3__tar.gz → 0.4.4__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.
- {walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/PKG-INFO +5 -7
- {walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/README.md +4 -6
- {walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/pyproject.toml +1 -1
- {walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/src/walkingpad_controller/const.py +25 -0
- {walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/src/walkingpad_controller/ftms.py +14 -0
- {walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/src/walkingpad_controller/models.py +13 -0
- {walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/.github/workflows/publish.yml +0 -0
- {walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/.gitignore +0 -0
- {walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/LICENSE +0 -0
- {walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/docs/ftms-protocol-reference.md +0 -0
- {walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/docs/ks-fit-reverse-engineering.md +0 -0
- {walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/src/walkingpad_controller/__init__.py +0 -0
- {walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/src/walkingpad_controller/controller.py +0 -0
- {walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/src/walkingpad_controller/wilink.py +0 -0
- {walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/tests/test_real_device.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: walkingpad-controller
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.4
|
|
4
4
|
Summary: Python library for controlling KingSmith WalkingPad treadmills over BLE (FTMS and legacy WiLink protocols)
|
|
5
5
|
Project-URL: Homepage, https://github.com/mcdax/walkingpad-controller
|
|
6
6
|
Project-URL: Repository, https://github.com/mcdax/walkingpad-controller
|
|
@@ -39,7 +39,7 @@ Supports both **FTMS** (Fitness Machine Service) and legacy **WiLink** protocols
|
|
|
39
39
|
- **Real-time status** — speed, distance, duration, calories, steps via BLE notifications
|
|
40
40
|
- **Cold-start handling** — waits for belt to start moving and stabilize before sending speed commands, avoiding BLE disconnects on KingSmith devices
|
|
41
41
|
- **Reconnect recovery** — pending target speed is automatically re-applied after BLE reconnection
|
|
42
|
-
- **KingSmith extensions** — step counter
|
|
42
|
+
- **KingSmith vendor extensions** — step counter (FTMS bit 13), MC-21 vendor pre-amble, supplement service detection
|
|
43
43
|
- **Firmware version** — exposed via `controller.firmware_version` (FTMS only)
|
|
44
44
|
|
|
45
45
|
## Installation
|
|
@@ -175,15 +175,13 @@ For advanced use, you can use the protocol controllers directly:
|
|
|
175
175
|
KingSmith FTMS devices require a `START_OR_RESUME` command before the belt will accept speed commands. The library handles this automatically: it sends START, waits for the belt to report speed > 0 via treadmill data notifications, then waits an additional stabilization period before sending `SET_TARGET_SPEED`. This avoids the BLE disconnects that occur when speed commands are sent too early during motor startup.
|
|
176
176
|
|
|
177
177
|
### BLE Connection Drops
|
|
178
|
-
KingSmith FTMS devices may occasionally drop the
|
|
178
|
+
KingSmith FTMS devices may occasionally drop the connection after a cold start. The library stores the pending target speed and re-applies it after reconnection.
|
|
179
179
|
|
|
180
180
|
### Connection Exclusivity
|
|
181
|
-
Only one BLE client can connect to the treadmill at a time
|
|
181
|
+
Only one BLE client can connect to the treadmill at a time — KS Fit and any client of this library are mutually exclusive.
|
|
182
182
|
|
|
183
183
|
### MC-21 Vendor Pre-amble
|
|
184
|
-
The
|
|
185
|
-
|
|
186
|
-
For the full reverse-engineering analysis, see [docs/ftms-protocol-reference.md](docs/ftms-protocol-reference.md) and [docs/ks-fit-reverse-engineering.md](docs/ks-fit-reverse-engineering.md).
|
|
184
|
+
The MC-21 family (`KS-MC21-*`, `KS-SMC21C-*`, `ZP-ZEALR1-*`) requires a vendor pre-amble before each FTMS Control Point command, and acks via Fitness Machine Status events rather than Control Point indications. The library detects this and handles it transparently. See [docs/ftms-protocol-reference.md](docs/ftms-protocol-reference.md) for the protocol details and [docs/ks-fit-reverse-engineering.md](docs/ks-fit-reverse-engineering.md) for the analysis.
|
|
187
185
|
|
|
188
186
|
## Requirements
|
|
189
187
|
|
|
@@ -11,7 +11,7 @@ Supports both **FTMS** (Fitness Machine Service) and legacy **WiLink** protocols
|
|
|
11
11
|
- **Real-time status** — speed, distance, duration, calories, steps via BLE notifications
|
|
12
12
|
- **Cold-start handling** — waits for belt to start moving and stabilize before sending speed commands, avoiding BLE disconnects on KingSmith devices
|
|
13
13
|
- **Reconnect recovery** — pending target speed is automatically re-applied after BLE reconnection
|
|
14
|
-
- **KingSmith extensions** — step counter
|
|
14
|
+
- **KingSmith vendor extensions** — step counter (FTMS bit 13), MC-21 vendor pre-amble, supplement service detection
|
|
15
15
|
- **Firmware version** — exposed via `controller.firmware_version` (FTMS only)
|
|
16
16
|
|
|
17
17
|
## Installation
|
|
@@ -147,15 +147,13 @@ For advanced use, you can use the protocol controllers directly:
|
|
|
147
147
|
KingSmith FTMS devices require a `START_OR_RESUME` command before the belt will accept speed commands. The library handles this automatically: it sends START, waits for the belt to report speed > 0 via treadmill data notifications, then waits an additional stabilization period before sending `SET_TARGET_SPEED`. This avoids the BLE disconnects that occur when speed commands are sent too early during motor startup.
|
|
148
148
|
|
|
149
149
|
### BLE Connection Drops
|
|
150
|
-
KingSmith FTMS devices may occasionally drop the
|
|
150
|
+
KingSmith FTMS devices may occasionally drop the connection after a cold start. The library stores the pending target speed and re-applies it after reconnection.
|
|
151
151
|
|
|
152
152
|
### Connection Exclusivity
|
|
153
|
-
Only one BLE client can connect to the treadmill at a time
|
|
153
|
+
Only one BLE client can connect to the treadmill at a time — KS Fit and any client of this library are mutually exclusive.
|
|
154
154
|
|
|
155
155
|
### MC-21 Vendor Pre-amble
|
|
156
|
-
The
|
|
157
|
-
|
|
158
|
-
For the full reverse-engineering analysis, see [docs/ftms-protocol-reference.md](docs/ftms-protocol-reference.md) and [docs/ks-fit-reverse-engineering.md](docs/ks-fit-reverse-engineering.md).
|
|
156
|
+
The MC-21 family (`KS-MC21-*`, `KS-SMC21C-*`, `ZP-ZEALR1-*`) requires a vendor pre-amble before each FTMS Control Point command, and acks via Fitness Machine Status events rather than Control Point indications. The library detects this and handles it transparently. See [docs/ftms-protocol-reference.md](docs/ftms-protocol-reference.md) for the protocol details and [docs/ks-fit-reverse-engineering.md](docs/ks-fit-reverse-engineering.md) for the analysis.
|
|
159
157
|
|
|
160
158
|
## Requirements
|
|
161
159
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "walkingpad-controller"
|
|
7
|
-
version = "0.4.
|
|
7
|
+
version = "0.4.4"
|
|
8
8
|
description = "Python library for controlling KingSmith WalkingPad treadmills over BLE (FTMS and legacy WiLink protocols)"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
{walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/src/walkingpad_controller/const.py
RENAMED
|
@@ -101,6 +101,31 @@ class FTMSStopPauseParam(IntEnum):
|
|
|
101
101
|
PAUSE = 0x02
|
|
102
102
|
|
|
103
103
|
|
|
104
|
+
@unique
|
|
105
|
+
class FTMSTrainingStatus(IntEnum):
|
|
106
|
+
"""Training Status (0x2AD3) status codes — Bluetooth SIG FTMS standard.
|
|
107
|
+
|
|
108
|
+
KingSmith firmware emits a subset of these. The first byte of the 2AD3
|
|
109
|
+
payload is the flags byte; the second byte is one of these codes.
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
OTHER = 0x00
|
|
113
|
+
IDLE = 0x01
|
|
114
|
+
WARMING_UP = 0x02
|
|
115
|
+
LOW_INTENSITY_INTERVAL = 0x03
|
|
116
|
+
HIGH_INTENSITY_INTERVAL = 0x04
|
|
117
|
+
RECOVERY_INTERVAL = 0x05
|
|
118
|
+
ISO_METRIC = 0x06
|
|
119
|
+
HEART_RATE_CONTROL = 0x07
|
|
120
|
+
FITNESS_TEST = 0x08
|
|
121
|
+
SPEED_OUT_OF_CONTROL = 0x09
|
|
122
|
+
COOL_DOWN = 0x0A
|
|
123
|
+
WATT_CONTROL = 0x0B
|
|
124
|
+
MANUAL_MODE = 0x0C
|
|
125
|
+
PRE_WORKOUT = 0x0D
|
|
126
|
+
POST_WORKOUT = 0x0E
|
|
127
|
+
|
|
128
|
+
|
|
104
129
|
@unique
|
|
105
130
|
class FitnessMachineStatusOpcode(IntEnum):
|
|
106
131
|
"""Fitness Machine Status (0x2ADA) event opcodes.
|
{walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/src/walkingpad_controller/ftms.py
RENAMED
|
@@ -466,6 +466,13 @@ class FTMSController:
|
|
|
466
466
|
"FTMS: Machine status event: 0x%02x (data: %s)", opcode, data.hex()
|
|
467
467
|
)
|
|
468
468
|
|
|
469
|
+
# Record the most-recent event so callers can read it via
|
|
470
|
+
# `controller.status.last_fm_event` and fan out to the status
|
|
471
|
+
# callbacks (e.g. HA coordinator).
|
|
472
|
+
self._status.last_fm_event = opcode
|
|
473
|
+
self._status.timestamp = time.time()
|
|
474
|
+
self._notify_status()
|
|
475
|
+
|
|
469
476
|
# Wake any pending command waiter that's expecting this opcode.
|
|
470
477
|
if (
|
|
471
478
|
self._status_ack_expected_opcode is not None
|
|
@@ -515,6 +522,13 @@ class FTMSController:
|
|
|
515
522
|
data.hex(),
|
|
516
523
|
)
|
|
517
524
|
|
|
525
|
+
# Push the new status code into TreadmillStatus and fan out so
|
|
526
|
+
# downstream consumers (HA coordinator) see the change.
|
|
527
|
+
if self._status.training_status != status_code:
|
|
528
|
+
self._status.training_status = status_code
|
|
529
|
+
self._status.timestamp = time.time()
|
|
530
|
+
self._notify_status()
|
|
531
|
+
|
|
518
532
|
def _on_control_point_response(self, sender: int, data: bytearray) -> None:
|
|
519
533
|
"""Handle FTMS Control Point (2AD9) indication responses.
|
|
520
534
|
|
{walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/src/walkingpad_controller/models.py
RENAMED
|
@@ -40,6 +40,19 @@ class TreadmillStatus:
|
|
|
40
40
|
heart_rate: int = 0
|
|
41
41
|
"""Heart rate in bpm (if available, 0 otherwise)."""
|
|
42
42
|
|
|
43
|
+
training_status: int = 0
|
|
44
|
+
"""FTMS Training Status (0x2AD3) status code. Standard FTMS enum:
|
|
45
|
+
0=other, 1=idle, 2=warming up, 3=low-intensity interval,
|
|
46
|
+
4=high-intensity interval, 5=recovery, 6=isometric, 7=heart-rate control,
|
|
47
|
+
8=fitness test, 9=speed out of control, 10=cool down, 11=watt control,
|
|
48
|
+
12=manual mode, 13=pre-workout, 14=post-workout. Stays 0 if the device
|
|
49
|
+
doesn't expose 0x2AD3."""
|
|
50
|
+
|
|
51
|
+
last_fm_event: int = 0
|
|
52
|
+
"""Opcode of the most recent Fitness Machine Status (0x2ADA) event.
|
|
53
|
+
See `FitnessMachineStatusOpcode` for known values; 0 means no event
|
|
54
|
+
has been received yet this session."""
|
|
55
|
+
|
|
43
56
|
timestamp: float = field(default_factory=time.time)
|
|
44
57
|
"""Wall-clock time when this status was received."""
|
|
45
58
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/docs/ks-fit-reverse-engineering.md
RENAMED
|
File without changes
|
{walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/src/walkingpad_controller/__init__.py
RENAMED
|
File without changes
|
{walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/src/walkingpad_controller/controller.py
RENAMED
|
File without changes
|
{walkingpad_controller-0.4.3 → walkingpad_controller-0.4.4}/src/walkingpad_controller/wilink.py
RENAMED
|
File without changes
|
|
File without changes
|