Commit 3482839
authored
fix(cli): honor optional --port in local proxy mode (#11)
* fix(cli): honor optional --port via lazy local-server attach
The v1.6.6 docs and feat(cli) commit (2c1bf58) state '--port is
optional in proxy mode (server owns the serial port)'. This was
implemented for remote --server-url, but local mode still returned
offline immediately when --port was omitted, so device commands run
through 'fpb_cli.py' without --port failed against a locally-running
server with a connected device.
Approach:
- Init no longer probes the network. Without --port, it just remembers
server_url/token/baudrate ('pending local server'). This keeps
FPBCLI() instantiation side-effect-free, so unit tests do not depend
on ambient network state.
- Add try_attach_local_server(), called from main() before dispatching
any device-needing command, which lazily probes the local server and
attaches if /api/status reports connected=true.
- Add ServerProxy.probe_status(): single short-timeout probe returning
the raw /api/status dict. Replaces the old is_server_running() +
is_device_connected() pair so we hit /api/status only once and avoid
any inconsistency between the two responses (per Copilot review).
- Verbose 'Using WebServer proxy mode' log is gated on
_device_state.connected so a disconnect race during attach does not
produce a misleading message.
Tests:
- test_init_no_port_no_probe: FPBCLI() must not call ServerProxy at all.
- test_try_attach_local_server_*: device connected / no device /
unreachable. Mocks probe_status() and asserts is_server_running() is
not called, locking in the single-probe contract.
- TestFPBCLICommands.run_cli pins --server-url to http://127.0.0.1:1
so subprocess-based command tests do not pick up an unrelated local
WebServer in the developer's environment.
* docs(cli): clarify port-less mode for local servers
The 'About --port' section already promised that --port is optional
when the server has a connected device, but the operating modes table
only listed port-less attach implicitly via the remote-proxy row.
- State that port-less attach applies to BOTH local and remote.
- Add a 'Local proxy (port-less)' row to the modes table.
- Clarify that 'offline fallback' is local-only: in remote mode the
CLI still attaches the proxy when the server is reachable even if
no device is connected (per Copilot review).1 parent 36055f3 commit 3482839
4 files changed
Lines changed: 165 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
60 | | - | |
| 62 | + | |
| 63 | + | |
61 | 64 | | |
62 | 65 | | |
63 | 66 | | |
64 | | - | |
| 67 | + | |
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
129 | 132 | | |
130 | 133 | | |
131 | 134 | | |
| |||
149 | 152 | | |
150 | 153 | | |
151 | 154 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
156 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
157 | 164 | | |
158 | 165 | | |
159 | 166 | | |
| |||
179 | 186 | | |
180 | 187 | | |
181 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
182 | 222 | | |
183 | 223 | | |
184 | 224 | | |
| |||
1182 | 1222 | | |
1183 | 1223 | | |
1184 | 1224 | | |
1185 | | - | |
| 1225 | + | |
1186 | 1226 | | |
1187 | 1227 | | |
1188 | 1228 | | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
1189 | 1233 | | |
1190 | 1234 | | |
1191 | 1235 | | |
1192 | 1236 | | |
1193 | 1237 | | |
1194 | 1238 | | |
1195 | | - | |
1196 | | - | |
1197 | | - | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
1198 | 1244 | | |
1199 | 1245 | | |
1200 | 1246 | | |
| |||
1540 | 1586 | | |
1541 | 1587 | | |
1542 | 1588 | | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
1543 | 1603 | | |
1544 | 1604 | | |
1545 | 1605 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
234 | 247 | | |
235 | 248 | | |
236 | 249 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
143 | 208 | | |
144 | 209 | | |
145 | 210 | | |
| |||
1731 | 1796 | | |
1732 | 1797 | | |
1733 | 1798 | | |
1734 | | - | |
1735 | | - | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
1736 | 1811 | | |
1737 | 1812 | | |
1738 | 1813 | | |
| |||
0 commit comments