asf02 0.1.0__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.
- asf02-0.1.0/LICENSE +202 -0
- asf02-0.1.0/PKG-INFO +175 -0
- asf02-0.1.0/README.md +154 -0
- asf02-0.1.0/asf02/__init__.py +45 -0
- asf02-0.1.0/asf02/client.py +311 -0
- asf02-0.1.0/asf02/discovery.py +66 -0
- asf02-0.1.0/asf02/protocol.py +221 -0
- asf02-0.1.0/asf02.egg-info/PKG-INFO +175 -0
- asf02-0.1.0/asf02.egg-info/SOURCES.txt +14 -0
- asf02-0.1.0/asf02.egg-info/dependency_links.txt +1 -0
- asf02-0.1.0/asf02.egg-info/requires.txt +5 -0
- asf02-0.1.0/asf02.egg-info/top_level.txt +1 -0
- asf02-0.1.0/pyproject.toml +36 -0
- asf02-0.1.0/setup.cfg +4 -0
- asf02-0.1.0/tests/test_client.py +154 -0
- asf02-0.1.0/tests/test_protocol.py +201 -0
asf02-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
asf02-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: asf02
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python client for Lulumiao pet slow feeders (OEM ASF02 / CWH01L-A1, BLE JSON-RPC)
|
|
5
|
+
Author: cptskippy, AgentCarlBrutananadilewski
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Classifier: Development Status :: 4 - Beta
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Topic :: Home Automation
|
|
11
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
12
|
+
Classifier: Topic :: System :: Hardware
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: bleak>=0.22
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
19
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# asf02
|
|
23
|
+
|
|
24
|
+
Lulumiao pet slow feeders can only be managed via an App that has since been
|
|
25
|
+
delisted from the Google Play store. Without the App, owners cannot update
|
|
26
|
+
feed schedules or synchronize the feeder clock which is prone to drift. This
|
|
27
|
+
library allows you to once again manage your slow feeder and save it from
|
|
28
|
+
the landfill.
|
|
29
|
+
|
|
30
|
+
Python client library for managing **Lulumiao pet slow feeders** over BLE.
|
|
31
|
+
The protocol was reverse-engineered from the vendor Android app and
|
|
32
|
+
**verified to work with devices having v1.19.12 firmware**.
|
|
33
|
+
|
|
34
|
+
The feeder speaks a small JSON-RPC dialect over two GATT characteristics.
|
|
35
|
+
This library wraps the whole conversation — discovery, pairing, unlock,
|
|
36
|
+
schedule management, on-demand feeding, and status — behind a tiny async
|
|
37
|
+
API. Built on [`bleak`](https://github.com/hbldh/bleak); no other runtime
|
|
38
|
+
dependencies.
|
|
39
|
+
|
|
40
|
+
## Product Details
|
|
41
|
+
| | |
|
|
42
|
+
|---|---|
|
|
43
|
+
| Brand | Lulumiao |
|
|
44
|
+
| Device | Pet slow feeder |
|
|
45
|
+
| Manufacturer | Hong Kong M Spacer Limited |
|
|
46
|
+
| Model | CWH01L-A1 (OEM model `ASF02`, per `info` and BLE advertising) |
|
|
47
|
+
| FCC ID | [2A9QN-CWH01L-A1](https://fccid.io/2A9QN-CWH01L-A1) |
|
|
48
|
+
|
|
49
|
+
## Product Images
|
|
50
|
+

|
|
51
|
+
|
|
52
|
+
## Install
|
|
53
|
+
|
|
54
|
+
### From a local repo checkout
|
|
55
|
+
```bash
|
|
56
|
+
pip install -e ".[dev]" # includes pytest
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### From GitHub
|
|
60
|
+
```bash
|
|
61
|
+
pip install git+https://github.com/cptskippy/asf02.git
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### From PyPI
|
|
65
|
+
```bash
|
|
66
|
+
pip install asf02
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Quick start
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
import asyncio
|
|
73
|
+
from asf02 import ASF02Client
|
|
74
|
+
|
|
75
|
+
async def main():
|
|
76
|
+
async with ASF02Client("<DEVICE_MAC>", token="<BIND_TOKEN>") as feeder:
|
|
77
|
+
await feeder.unlock() # required on every connect
|
|
78
|
+
await feeder.sync_time(-25200) # PDT w/DST in seconds
|
|
79
|
+
info = await feeder.info() # {'f': '1.19.12', 'm': 'ASF02', ...}
|
|
80
|
+
status = await feeder.status() # {'n': 1065, 'b': 458, ...}
|
|
81
|
+
await feeder.feed(1) # dispense 1 portion now
|
|
82
|
+
await feeder.set_schedule([(15, 30, 1), (16, 0, 1)])
|
|
83
|
+
|
|
84
|
+
asyncio.run(main())
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Discovery
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from asf02 import discover_feeders
|
|
91
|
+
|
|
92
|
+
async def main():
|
|
93
|
+
for f in await discover_feeders(timeout=10):
|
|
94
|
+
print(f.address, f.model, f.rssi)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Feeders advertise continuously: local name `ASF02-<last6 of MAC>` plus
|
|
98
|
+
manufacturer data (company `0xFFFF`) starting `02 03`, with the MAC embedded.
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
## Pairing / tokens
|
|
102
|
+
|
|
103
|
+
- Generate a token: `ASF02Client.new_token()` (10 chars, same charset as the vendor app).
|
|
104
|
+
- Keep the token with your device config. The unlock code is always derived
|
|
105
|
+
from it (`md5("0000:"+token)` — see `unlock_code_for`).
|
|
106
|
+
- Store it in the device: `await feeder.bind(token)`. **Re-binding overwrites**
|
|
107
|
+
the previous token — the old one stops working.
|
|
108
|
+
|
|
109
|
+
## Schedules
|
|
110
|
+
|
|
111
|
+
- The device stores a **fixed 10-slot array**; `set_schedule` replaces it.
|
|
112
|
+
- Entries are `(hour, minute, portion)` or `(hour, minute, portion, enabled)`.
|
|
113
|
+
- `set_schedule([])` (or `clear=True`) wipes the schedule.
|
|
114
|
+
- **Time fields are hex on the wire** — the library handles this, but know it:
|
|
115
|
+
`0012000200` is 18:00, not 12:00.
|
|
116
|
+
- The **write response** is the authoritative confirmation (some firmware
|
|
117
|
+
builds answer schedule *reads* with stale/empty data).
|
|
118
|
+
|
|
119
|
+
## Behavior notes (learned from the hardware)
|
|
120
|
+
|
|
121
|
+
- The device **locks across every (re)connect** — call `unlock()` each time
|
|
122
|
+
(or use `connect_unlocked()`). Only `info` works while locked.
|
|
123
|
+
- `time.calibration` takes **epoch seconds** + tz offset in **seconds**
|
|
124
|
+
(incl. DST; e.g. −25200 for PDT — same convention the vendor app uses).
|
|
125
|
+
Always re-sync on connect; schedules run on the device clock.
|
|
126
|
+
- `feeder.log` may return **no notification at all** — `get_log()` returns
|
|
127
|
+
`None` in that case instead of erroring.
|
|
128
|
+
- No MTU negotiation needed for any documented command (the link carries the
|
|
129
|
+
full 79-byte responses fine).
|
|
130
|
+
- Transient connections are fine: connect → work → disconnect. The feeders
|
|
131
|
+
run autonomously between visits.
|
|
132
|
+
- The feeder clock drifts over time and freezes entirely while unpowered.
|
|
133
|
+
Sync it (`sync_time()`) semi-regularly — and on every reconnect if you
|
|
134
|
+
want schedules to stay on time — since the schedule runs on the device
|
|
135
|
+
clock, not yours.
|
|
136
|
+
|
|
137
|
+
## API Status
|
|
138
|
+
|
|
139
|
+
| Method | Status |
|
|
140
|
+
|---|---|
|
|
141
|
+
| `info` | ✅ Working |
|
|
142
|
+
| `bind` | ✅ Working |
|
|
143
|
+
| `unlock` | ✅ Working |
|
|
144
|
+
| `time.calibration` | ✅ Working |
|
|
145
|
+
| `feeder.status` | ✅ Working |
|
|
146
|
+
| `feeder.feed` | ✅ Working |
|
|
147
|
+
| `feeder.stop` | ✅ Working |
|
|
148
|
+
| `feeder.plan` (read) | ⚠️ No result on v1.19.12 firmware |
|
|
149
|
+
| `feeder.plan` (write) | ✅ Working |
|
|
150
|
+
| `feeder.log` | ⚠️ No result on v1.19.12 firmware |
|
|
151
|
+
|
|
152
|
+
**IMPORTANT NOTE:** While `feeder.plan` (read) and `feeder.log` are defined, the
|
|
153
|
+
v1.19.12 firmware appears to have a bug and it will always return `null`. It
|
|
154
|
+
is advised to retain a copy of any plan sent the feeder as you may not be
|
|
155
|
+
able to retrieve it in the future.
|
|
156
|
+
|
|
157
|
+
## Project layout
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
asf02/
|
|
161
|
+
protocol.py pure codecs + constants (unit-testable, no I/O)
|
|
162
|
+
client.py async device client (bleak)
|
|
163
|
+
discovery.py scanner
|
|
164
|
+
examples/cli.py demo CLI (run on a machine with Bluetooth)
|
|
165
|
+
tests/ unit tests anchored to real captured wire traffic
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Publishing
|
|
169
|
+
|
|
170
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for how releases are cut and how
|
|
171
|
+
PyPI publishing is configured.
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
Apache-2.0
|
asf02-0.1.0/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# asf02
|
|
2
|
+
|
|
3
|
+
Lulumiao pet slow feeders can only be managed via an App that has since been
|
|
4
|
+
delisted from the Google Play store. Without the App, owners cannot update
|
|
5
|
+
feed schedules or synchronize the feeder clock which is prone to drift. This
|
|
6
|
+
library allows you to once again manage your slow feeder and save it from
|
|
7
|
+
the landfill.
|
|
8
|
+
|
|
9
|
+
Python client library for managing **Lulumiao pet slow feeders** over BLE.
|
|
10
|
+
The protocol was reverse-engineered from the vendor Android app and
|
|
11
|
+
**verified to work with devices having v1.19.12 firmware**.
|
|
12
|
+
|
|
13
|
+
The feeder speaks a small JSON-RPC dialect over two GATT characteristics.
|
|
14
|
+
This library wraps the whole conversation — discovery, pairing, unlock,
|
|
15
|
+
schedule management, on-demand feeding, and status — behind a tiny async
|
|
16
|
+
API. Built on [`bleak`](https://github.com/hbldh/bleak); no other runtime
|
|
17
|
+
dependencies.
|
|
18
|
+
|
|
19
|
+
## Product Details
|
|
20
|
+
| | |
|
|
21
|
+
|---|---|
|
|
22
|
+
| Brand | Lulumiao |
|
|
23
|
+
| Device | Pet slow feeder |
|
|
24
|
+
| Manufacturer | Hong Kong M Spacer Limited |
|
|
25
|
+
| Model | CWH01L-A1 (OEM model `ASF02`, per `info` and BLE advertising) |
|
|
26
|
+
| FCC ID | [2A9QN-CWH01L-A1](https://fccid.io/2A9QN-CWH01L-A1) |
|
|
27
|
+
|
|
28
|
+
## Product Images
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
### From a local repo checkout
|
|
34
|
+
```bash
|
|
35
|
+
pip install -e ".[dev]" # includes pytest
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### From GitHub
|
|
39
|
+
```bash
|
|
40
|
+
pip install git+https://github.com/cptskippy/asf02.git
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### From PyPI
|
|
44
|
+
```bash
|
|
45
|
+
pip install asf02
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Quick start
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
import asyncio
|
|
52
|
+
from asf02 import ASF02Client
|
|
53
|
+
|
|
54
|
+
async def main():
|
|
55
|
+
async with ASF02Client("<DEVICE_MAC>", token="<BIND_TOKEN>") as feeder:
|
|
56
|
+
await feeder.unlock() # required on every connect
|
|
57
|
+
await feeder.sync_time(-25200) # PDT w/DST in seconds
|
|
58
|
+
info = await feeder.info() # {'f': '1.19.12', 'm': 'ASF02', ...}
|
|
59
|
+
status = await feeder.status() # {'n': 1065, 'b': 458, ...}
|
|
60
|
+
await feeder.feed(1) # dispense 1 portion now
|
|
61
|
+
await feeder.set_schedule([(15, 30, 1), (16, 0, 1)])
|
|
62
|
+
|
|
63
|
+
asyncio.run(main())
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Discovery
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from asf02 import discover_feeders
|
|
70
|
+
|
|
71
|
+
async def main():
|
|
72
|
+
for f in await discover_feeders(timeout=10):
|
|
73
|
+
print(f.address, f.model, f.rssi)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Feeders advertise continuously: local name `ASF02-<last6 of MAC>` plus
|
|
77
|
+
manufacturer data (company `0xFFFF`) starting `02 03`, with the MAC embedded.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
## Pairing / tokens
|
|
81
|
+
|
|
82
|
+
- Generate a token: `ASF02Client.new_token()` (10 chars, same charset as the vendor app).
|
|
83
|
+
- Keep the token with your device config. The unlock code is always derived
|
|
84
|
+
from it (`md5("0000:"+token)` — see `unlock_code_for`).
|
|
85
|
+
- Store it in the device: `await feeder.bind(token)`. **Re-binding overwrites**
|
|
86
|
+
the previous token — the old one stops working.
|
|
87
|
+
|
|
88
|
+
## Schedules
|
|
89
|
+
|
|
90
|
+
- The device stores a **fixed 10-slot array**; `set_schedule` replaces it.
|
|
91
|
+
- Entries are `(hour, minute, portion)` or `(hour, minute, portion, enabled)`.
|
|
92
|
+
- `set_schedule([])` (or `clear=True`) wipes the schedule.
|
|
93
|
+
- **Time fields are hex on the wire** — the library handles this, but know it:
|
|
94
|
+
`0012000200` is 18:00, not 12:00.
|
|
95
|
+
- The **write response** is the authoritative confirmation (some firmware
|
|
96
|
+
builds answer schedule *reads* with stale/empty data).
|
|
97
|
+
|
|
98
|
+
## Behavior notes (learned from the hardware)
|
|
99
|
+
|
|
100
|
+
- The device **locks across every (re)connect** — call `unlock()` each time
|
|
101
|
+
(or use `connect_unlocked()`). Only `info` works while locked.
|
|
102
|
+
- `time.calibration` takes **epoch seconds** + tz offset in **seconds**
|
|
103
|
+
(incl. DST; e.g. −25200 for PDT — same convention the vendor app uses).
|
|
104
|
+
Always re-sync on connect; schedules run on the device clock.
|
|
105
|
+
- `feeder.log` may return **no notification at all** — `get_log()` returns
|
|
106
|
+
`None` in that case instead of erroring.
|
|
107
|
+
- No MTU negotiation needed for any documented command (the link carries the
|
|
108
|
+
full 79-byte responses fine).
|
|
109
|
+
- Transient connections are fine: connect → work → disconnect. The feeders
|
|
110
|
+
run autonomously between visits.
|
|
111
|
+
- The feeder clock drifts over time and freezes entirely while unpowered.
|
|
112
|
+
Sync it (`sync_time()`) semi-regularly — and on every reconnect if you
|
|
113
|
+
want schedules to stay on time — since the schedule runs on the device
|
|
114
|
+
clock, not yours.
|
|
115
|
+
|
|
116
|
+
## API Status
|
|
117
|
+
|
|
118
|
+
| Method | Status |
|
|
119
|
+
|---|---|
|
|
120
|
+
| `info` | ✅ Working |
|
|
121
|
+
| `bind` | ✅ Working |
|
|
122
|
+
| `unlock` | ✅ Working |
|
|
123
|
+
| `time.calibration` | ✅ Working |
|
|
124
|
+
| `feeder.status` | ✅ Working |
|
|
125
|
+
| `feeder.feed` | ✅ Working |
|
|
126
|
+
| `feeder.stop` | ✅ Working |
|
|
127
|
+
| `feeder.plan` (read) | ⚠️ No result on v1.19.12 firmware |
|
|
128
|
+
| `feeder.plan` (write) | ✅ Working |
|
|
129
|
+
| `feeder.log` | ⚠️ No result on v1.19.12 firmware |
|
|
130
|
+
|
|
131
|
+
**IMPORTANT NOTE:** While `feeder.plan` (read) and `feeder.log` are defined, the
|
|
132
|
+
v1.19.12 firmware appears to have a bug and it will always return `null`. It
|
|
133
|
+
is advised to retain a copy of any plan sent the feeder as you may not be
|
|
134
|
+
able to retrieve it in the future.
|
|
135
|
+
|
|
136
|
+
## Project layout
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
asf02/
|
|
140
|
+
protocol.py pure codecs + constants (unit-testable, no I/O)
|
|
141
|
+
client.py async device client (bleak)
|
|
142
|
+
discovery.py scanner
|
|
143
|
+
examples/cli.py demo CLI (run on a machine with Bluetooth)
|
|
144
|
+
tests/ unit tests anchored to real captured wire traffic
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Publishing
|
|
148
|
+
|
|
149
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for how releases are cut and how
|
|
150
|
+
PyPI publishing is configured.
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
Apache-2.0
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""ASF02 — Python client library for Lulumiao pet slow feeders (OEM model ASF02, sold as CWH01L-A1; BLE JSON-RPC).
|
|
2
|
+
|
|
3
|
+
Talks the JSON-RPC-over-GATT protocol used by the ASF02 pet feeder family:
|
|
4
|
+
connect, bind/unlock, schedule management, on-demand feeding, and status.
|
|
5
|
+
|
|
6
|
+
Requires `bleak` for BLE. No other runtime dependencies.
|
|
7
|
+
"""
|
|
8
|
+
from asf02.client import ASF02Client, ASF02Error, ASF02ProtocolError, ASF02LockedError
|
|
9
|
+
from asf02.protocol import (
|
|
10
|
+
SERVICE_UUID,
|
|
11
|
+
WRITE_CHAR_UUID,
|
|
12
|
+
NOTIFY_CHAR_UUID,
|
|
13
|
+
decode_advertisement,
|
|
14
|
+
encode_plan_entry,
|
|
15
|
+
decode_plan_entry,
|
|
16
|
+
plan_entry_valid,
|
|
17
|
+
unlock_code_for,
|
|
18
|
+
generate_token,
|
|
19
|
+
decode_plan_slot,
|
|
20
|
+
is_clear_marker,
|
|
21
|
+
PlanEntry,
|
|
22
|
+
)
|
|
23
|
+
from asf02.discovery import discover_feeders
|
|
24
|
+
|
|
25
|
+
__version__ = "0.1.0"
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"ASF02Client",
|
|
29
|
+
"ASF02Error",
|
|
30
|
+
"ASF02ProtocolError",
|
|
31
|
+
"ASF02LockedError",
|
|
32
|
+
"SERVICE_UUID",
|
|
33
|
+
"WRITE_CHAR_UUID",
|
|
34
|
+
"NOTIFY_CHAR_UUID",
|
|
35
|
+
"decode_advertisement",
|
|
36
|
+
"encode_plan_entry",
|
|
37
|
+
"decode_plan_entry",
|
|
38
|
+
"decode_plan_slot",
|
|
39
|
+
"plan_entry_valid",
|
|
40
|
+
"is_clear_marker",
|
|
41
|
+
"unlock_code_for",
|
|
42
|
+
"generate_token",
|
|
43
|
+
"PlanEntry",
|
|
44
|
+
"discover_feeders",
|
|
45
|
+
]
|