Commit 1893c1f
committed
Simplify BLE payload parsing; drop the table-driven framework
The READ_VALUES/DOOR_STATUS_PARSER table plus reflection-based
_update_data_from_values was a generic parser built to decode a single
field. Replace it with an explicit, typed parse:
- RunChickenDoorState.from_raw() maps the raw byte safely (0=open,
1=closed, anything else -> UNKNOWN) instead of indexing a dict that
raised KeyError on unexpected values.
- _parse_door_state() reads the byte at a named offset with a length
guard (no IndexError) and returns a RunChickenDoorState instead of a
mistyped dict[str, int | float].
- Set door_state directly rather than via hasattr/setattr reflection;
remove the never-read `values` catch-all from the data model and drop
the unused struct import.1 parent 6d3632a commit 1893c1f
2 files changed
Lines changed: 19 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
16 | 21 | | |
17 | 22 | | |
18 | 23 | | |
| |||
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
28 | | - | |
29 | | - | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
| |||
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
33 | 27 | | |
34 | 28 | | |
35 | 29 | | |
| |||
103 | 97 | | |
104 | 98 | | |
105 | 99 | | |
106 | | - | |
| 100 | + | |
| 101 | + | |
107 | 102 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
126 | 107 | | |
127 | 108 | | |
128 | | - | |
129 | | - | |
| 109 | + | |
| 110 | + | |
130 | 111 | | |
131 | | - | |
132 | | - | |
133 | | - | |
| 112 | + | |
134 | 113 | | |
135 | 114 | | |
136 | 115 | | |
137 | 116 | | |
138 | | - | |
139 | | - | |
140 | | - | |
| 117 | + | |
141 | 118 | | |
142 | 119 | | |
143 | 120 | | |
144 | 121 | | |
145 | 122 | | |
146 | | - | |
147 | | - | |
148 | | - | |
| 123 | + | |
149 | 124 | | |
0 commit comments